text
stringlengths
28
935k
meta
stringlengths
137
139
red_pajama_subset
stringclasses
1 value
\section{Introduction} \label{sec:introduction}} \IEEEPARstart{R}{eal-world} images generally contain objects belonging to multiple diverse categories; thus, recognizing the multiple object categories in images is a more fundamental and practical task compared with single-object image recognition in computer vision and multimedia fields. Recently, researchers have concentrated on developing a series of algorithms for multi-label image analysis \cite{li2017improving,wei2016hcp,cabral2014matrix,song2014generalized,lapin2017analysis} that underpin many critical applications, such as content-based image retrieval and recommendation systems \cite{chua1994concept,yang2015pinterest}. Despite these achievements, identifying the existence of multiple semantic categories requires not only mining diverse semantic object regions but also capturing the interplay among these regions and their semantics, making multi-label image analysis a challenging and unsolved task. The current MLR approaches mainly employ object localization techniques \cite{wei2016hcp,yang2016exploit,ren2017faster} or adopt visual attentional mechanisms \cite{zhu2017learning,wang2017multi} to adaptively discover regions with meaningful semantic categories. However, object localization techniques \cite{uijlings2013selective,zitnick2014edge,zhang2017sequential,pont2016multiscale} need to search numerous category-agnostic and superfluous region proposals, which cannot be unified into deep neural networks for end-to-end optimization. Moreover, visual attentional mechanisms cannot accurately locate semantic object regions due to a lack of explicit supervision and guidance. More recent works have further introduced RNN/LSTM models \cite{hochreiter1997long,wang2016cnn,chen2018recurrent} to identify the contextual dependencies among located regions and thus implicitly capture label dependencies. However, these algorithms merely model sequential region/label dependencies; they cannot fully exploit these properties because a direct correlation or dependency exists between each region/label pair. In addition, they do not explicitly integrate statistical category correlations that provide direct and key guidance to aid multi-label image analysis. The current methods depend on deep convolution networks \cite{he2016deep,simonyan2015very} for learning image features; such networks require large numbers of training samples for each category and are unable to generalize to novel categories with limited samples. To address this issue, researchers have recently developed a series of few-shot learning algorithms that can learn novel categories after being trained on a set of base categories with sufficient training samples. These algorithms utilize the meta-learning paradigm \cite{sung2018learning,kim2019variational} to help learn the novel categories by distilling the knowledge of the categories with sufficient training samples or use sample synthesis technologies \cite{hariharan2017low} to generate more diverse samples for the novel categories. Although these techniques have achieved impressive progress, they focus mainly on single-label scenarios rather than on more general multi-label cases. Objects in visual scenes commonly have strong correlations. For example, desks tend to co-occur with chairs, while computers usually co-exist with keyboards. These correlations can provide extra guidance for capturing the interplay among different categories and thus facilitate multi-label analysis, especially for complex and few-shot scenarios. In this work, we show that semantic correlations can be explicitly represented by a structured knowledge graph and that such interplay can be effectively captured by information propagation through the graph. To this end, we propose a knowledge-guided graph routing (KGGR) framework that captures the interplay of features from different semantic regions to help learn more powerful contextualized image representation and guides the propagation of semantic information through different categories to help train the classifiers. The framework builds on two graph propagation networks that perform message propagation on feature and semantic spaces. Specifically, it first constructs a graph based on statistical label co-occurrences to correlate different categories. For the feature space, we designed a semantically guided attention module that applies category semantics to guide learning category-related image features that focus more on the corresponding semantic regions. By initializing the graph node with the feature vector of the corresponding category, we introduce a graph propagation network to propagate features through the graph to capture feature interactions and learn contextualized feature representations. Regarding the semantic space, we treat each node as the classifier weight of each category and utilize another graph propagation network to transfer node messages throughout the graph, allowing each category to derive information from its correlated categories to improve classifier training. A preliminary version of this work was presented as a conference paper \cite{chen2019learning}. In this version, we inherit the idea of explicitly integrating statistical category correlations with deep graph propagation networks and strengthen the framework from several aspects as follows. First, we propagate information in both the feature and semantic spaces, which guides the learning of more powerful contextualized features and simultaneously regularizes learning classifier weights. Second, we generalize the proposed framework to the more challenging multi-label few-shot learning task and demonstrate its superiority on this task. Finally, we conduct more extensive experiments and analyses on several widely used benchmarks and demonstrate the effectiveness of the proposed framework while verifying the contribution of each component. In summary, the contributions of this work can be summarized as follows: 1) We propose a novel knowledge-guided graph routing (KGGR) framework that explores category interplay in both feature and semantic spaces under the explicit guidance of statistical category co-occurrence correlations. This approach can help learn more powerful contextualized features and simultaneously regularize learning classifier weights. 2) We propose a simple yet effective semantically guided attention mechanism that exploits category semantics to learn semantic-aware features that focus more on semantic regions of corresponding categories. 3) We apply the KGGR framework to address both multi-label image recognition and multi-label few-shot learning tasks and conduct experiments on various benchmarks, including PASCAL VOC 2007 \& 2012 \cite{everingham2010pascal}, Microsoft-COCO \cite{lin2014microsoft}, and Visual Genome with larger-scale categories \cite{krishna2017visual}, and demonstrate that our framework exhibits substantial performance improvements on both tasks. \section{Related Works} In this section, we review the related works following three main research streams: multi-label image recognition, few-shot learning, and knowledge representation learning. \subsection{Multi-label Image Recognition} Recent progress on multi-label image classification relies on a combination of object localization and deep learning techniques \cite{wei2016hcp,yang2016exploit}. Generally, such works introduced object proposals \cite{zitnick2014edge} that were assumed to include all possible foreground objects in the image; then, they aggregated the features extracted from all these proposals to incorporate local information. Although these methods have achieved notable performance improvement, the region candidate localization step usually incurred redundant computation costs and prevented the models from being applied to end-to-end training approaches with deep neural networks. Zhang et al. \cite{zhang2018multi} further utilized a learning-based region proposal network and integrated it with deep neural networks. Although this method could be jointly optimized, it required additional bounding box annotations to train the proposal generation component. To solve this issue, some other works \cite{zhu2017learning,wang2017multi} resorted to attention mechanisms to locate the informative regions. These methods could be trained with image-level annotations in an end-to-end manner. For example, Wang et al. \cite{wang2017multi} introduced a spatial transformer to adaptively search for semantic regions and then aggregated the features from these regions to identify multiple labels. However, due to a lack of supervision and guidance, these methods could merely locate the regions roughly. Modeling label dependencies can help capture label co-occurrence, which is also a key aspect of multi-label recognition. To achieve this, a series of works have introduced graphic models such as the conditional random field \cite{ghamrawi2005collective}, dependency network \cite{guo2011multi}, or co-occurrence matrix \cite{xue2011correlative} to capture pairwise label correlations. Recently, Wang et al. \cite{wang2016cnn} formulated a CNN-RNN framework that implicitly utilized semantic redundancy and co-occurrence dependency to facilitate effective multi-label classification. Some works \cite{zhang2018multi,chen2018recurrent} further capitalized on the proposal generation/visual attention mechanism to search local discriminative regions and used RNN/LSTM \cite{hochreiter1997long} models to explicitly model label dependencies. For example, Chen et al. \cite{chen2018recurrent} proposed a recurrent attention reinforcement learning framework to iteratively discover a sequence of attentional and informative regions to model long-term dependencies among them to help capture semantic label co-occurrences. Furthermore, Chen et al. \cite{chen2019multi} directly mapped the GloVe vector to the corresponding object classifier via a graph convolutional network. Different from all these methods, we correlate all label pairs in the form of a structured graph and introduce two parallel graph neural networks to simultaneously explore interactions among category-specific features to learn contextualized feature representation and to explore information propagation from correlated categories to learn classifier weights. Besides, the semantically guided attention mechanism that introduces category semantic to guide learning category-specific features is also original to current works. \subsection{Few-shot learning} Few-shot learning aims to understand novel concepts from only a few examples, mimicking the human cognitive abilities. Learning robust feature representations and training classifiers to recognize novel categories is the essential image recognition issue in the few-shot scenario. To address this task, the existing works are mainly characterized by three types of helpful techniques: metric learning, meta-learning and data synthesis, which are often combined. Metric learning-based methods \cite{vinyals2016matching,kim2019variational,snell2017prototypical,sung2018learning} are intended to learn an appropriate embedding space in which same-category samples are close while different-category samples are distant. A matching network using an attention mechanism and memory unit was introduced in \cite{vinyals2016matching} to compare the test and support samples. Snell et al. \cite{snell2017prototypical} proposed a prototypical network that adopts the mean of the embedded sample features in novel categories as a class prototype and then recognizes test samples using nearest-neighbor classifiers. In \cite{sung2018learning}, a relational network was proposed to learn a transferable deep metric. Some recent works have further adaptively generated the classifier weights of novel categories from feature embedding \cite{qiao2018few,qi2018low}. Meta-learning, also known as learning to learn, seeks to transfer some ``meta knowledge'' from previously learned tasks to achieve rapid learning of new tasks. Meta-learning is popular among few-shot learning approaches \cite{sung2018learning,Ravichandran2019ICCV,finn2017model,ravi2016optimization}. Finn et al. \cite{finn2017model} proposed a model-agnostic meta-learning approach to initialize the network well and make fine-tuning the model easier for novel categories with few samples. In \cite{ravi2016optimization}, transferable optimization strategies are learned using an LSTM-based meta-learner to achieve effective model training in the few-shot regime. Data synthesis tries to generate new samples from the few given training samples to augment model training in the few-shot task, motivated by the human ability to generate new object examples from known primitives. In addition to simple data augmentation tricks such as horizontal flipping, scaling and positional shifts, more sophisticated approaches have been introduced \cite{hariharan2017low,SchwartzKSHMKFG18nips,Tokmakov2019ICCV,AlfassyKASHFGB19cvpr}. In \cite{SchwartzKSHMKFG18nips}, a delta-encoder model was designed that learned to extract transferable intraclass deformations and synthesize samples for novel categories. Alfassy et al. \cite{AlfassyKASHFGB19cvpr} proposed a label-set operations network to synthesize samples with multiple labels to address the new and challenging multi-label few-shot task and was the first to introduce a benchmark. In this work, we generalize our KGGR framework to this task and demonstrate its superior ability to learn robust features and classifiers from limited samples. \subsection{Knowledge Representation Learning} Deep neural networks have made impressive breakthroughs in recent years and are capable of learning powerful representations from raw training data \cite{he2016deep,ren2017faster,chen2016disc,chen2018learning}. However, these models also have a bottleneck. One potential reason is that they lack the notable human capability of exploiting prior knowledge, which arises from knowledge accumulation and reasoning. Thus, the ability to incorporate prior knowledge into deep representation learning has become a new trend, and promising progress has been made in computer vision for tasks ranging from object detection/recognition \cite{marino2017more,jiang2018hybrid,TangWWGDGC18pami,chen2018fine,xie2020adversarial} to visual navigation/reasoning \cite{chen2019knowledge,wang2018deep,chen2018neural,WeiYang2019ICLR}. In \cite{marino2017more}, Marino et al. constructed a knowledge graph to correlate category relationships and introduced a graph search neural network to incorporate the knowledge graph into end-to-end representation learning for image classification. Tang et al. \cite{TangWWGDGC18pami} incorporated object similarity knowledge from the visual and semantic domains during the transfer learning process to help improve semisupervised object detection. To address the zero-shot recognition task, Wang et al. \cite{wang2018zero} proposed building on a graph convolutional network to utilize both semantic embeddings and categorical relationships for classifier prediction. A hierarchical semantic embedding framework was presented in \cite{chen2018fine} to incorporate hierarchal category knowledge into a deep neural network to enhance fine-grained representation learning and recognition. In \cite{wang2018deep}, an end-to-end trainable graph reasoning model was introduced to explicitly model the interplay of knowledge of people and contextual objects to perform reasoning regarding social relationships. Li et al. \cite{li2019large} introduced hierarchical category knowledge via semantic clustering \cite{yang2020fast} and used it to regularize the learning of transferable visual features for large-scale few-shot image classification. Yang et al. \cite{WeiYang2019ICLR} studied incorporating semantic priors to address the semantic navigation task, in which the prior knowledge was fused into a deep reinforcement learning framework by graph convolutional networks. In \cite{Zhang2020AAAI}, a knowledge integration network was designed to encode human and scene knowledge for action recognition. Inspired by these works, we propose a new knowledge-guided graph routing (KGGR) framework that incorporates prior knowledge to propagate both feature and semantic space information to effectively boost multi-label analysis performance. \begin{figure*}[!t] \centering \includegraphics[width=1.0\linewidth]{./pipeline-new-v1.pdf} \caption{Illustration of our knowledge-guided graph routing framework. It first uses a CNN to extract image features, and then introduces two graph propagation networks to transfer message on both feature and semantic spaces to learn contextualized features and simultaneously regularize learning classifier weights.} \label{fig:pipeline} \end{figure*} \section{KGGR Framework} In this section, we provide an overall introduction to the proposed KGGR framework. The framework builds on a graph that encodes prior knowledge of category correlations. Then, it introduces two graph propagation networks that propagate information in both the feature and semantic spaces. For feature propagation, the framework first feeds the input image into a fully convolutional network to generate the feature maps and incorporates category semantics to guide learning semantic-specific feature vectors that focus more on the semantic regions for each category. Then, it further initializes the graph nodes with the corresponding feature vectors and applies a graph propagation network to explore feature interplay to learn contextualized features. For semantic propagation, each node is initialized with the classifier weights of the corresponding category. Then, another graph propagation network is learned to adaptively propagate node messages through the graph to explore node interactions and transfer the classifier's information of the correlated categories to help train the classifiers. The overall pipeline of the proposed KGGR framework is presented in Figure \ref{fig:pipeline}. \subsection{Knowledge Graph Construction} \label{sec:kgc} We first introduce the knowledge graph $\mathcal{G}=\{\mathbf{V}, \mathbf{A}\}$, in which the nodes represent categories and the edges represent co-occurrences between corresponding categories. Specifically, suppose that the dataset covers $C$ categories, $\mathbf{V}$ can be represented as $\{v_0, v_2, \dots, v_{C-1}\}$ where element $v_c$ denotes category $c$ and $\mathbf{A}$ can be represented as $\{a_{00}, a_{01}, \dots, a_{0(C-1)}, \dots, a_{(C-1)(C-1)}\}$ where element $a_{cc'}$ denotes the probability that an object belongs to category $c'$ when in the presence of an object belonging to category $c$. We compute the probabilities between all the category pairs using the annotations from the samples in the training set; thus, we do not introduce any additional annotation. \subsection{Graph Feature Propagation} Here, we describe the feature propagation module, which first decouples the image into $C$ category-specific feature vectors via a semantically guided attention mechanism and then propagates these vectors throughout the graph to learn contextualized features for each category via a knowledge-embedded propagation mechanism. \subsubsection{Semantically guided attention mechanism} In this part, we introduce the semantically guided attention mechanism, which adopts the category semantic to guide the learning of semantic-specific feature representations. Specifically, given an input image $I$, this mechanism first extracts feature maps $\mathbf{f}^I \in \mathcal{R}^{W\times H \times N}$, where $W$, $H$, and $N$ are the width, height and channel numbers of the feature maps, respectively, formulated as \begin{equation} \mathbf{f}^I=f_{cnn}(I), \label{eq:image-feature-extraction} \end{equation} where $f_{cnn}(\cdot)$ is a feature extractor implemented by a fully convolutional network. For each category $c$, the framework extracts a $d_s$-dimensional semantic-embedding vector using the pretrained GloVe \cite{pennington2014glove} model \begin{equation} \mathbf{x}_c=f_{g}(w_c), \label{eq:semantic-feature-extraction} \end{equation} where $w_c$ is the semantic word representing category $c$. Then, we incorporate the semantic vector $\mathbf{x}_c$ to guide the focus to the semantic-aware regions and thus learn a feature vector corresponding to this category. More specifically, for each location $(w, h)$, we first fuse the corresponding image features $\mathbf{f}^I_{wh}$ and $\mathbf{x}_c$ using a low-rank bilinear pooling method \cite{kim2016hadamard} \begin{equation} \tilde{\mathbf{f}}^I_{c,wh}=\mathbf{P}^T\left(\tanh\left((\mathbf{U}^T\mathbf{f}^I_{wh})\odot(\mathbf{V}^T\mathbf{x}_c)\right)\right)+\mathbf{b}, \end{equation} where $\tanh(\cdot)$ is the hyperbolic tangent function, and $\mathbf{U}\in \mathcal{R}^{N\times d_1}$, $\mathbf{V}\in \mathcal{R}^{d_s\times d_1}$, $\mathbf{P}\in \mathcal{R}^{d_1\times d_2}$, and $\mathbf{b}\in \mathcal{R}^{d_2}$ are the learnable parameters, $\odot$ represents elementwise multiplication, and $d_1$ and $d_2$ are the dimensions of the joint embeddings and the output features, respectively. Then, we compute an attentional coefficient under the guidance of $\mathbf{x}_c$ as follows: \begin{equation} \tilde{a}_{c,wh}=f_{a}(\tilde{\mathbf{f}}^I_{c,wh}), \end{equation} which indicates the importance of location $(w, h)$. $f_{a}(\cdot)$ is an attentional function implemented by a fully connected network. The process is repeated for all locations. To allow the coefficients to be easily compared across different samples, we normalize them over all the locations using a softmax function: \begin{equation} a_{c,wh}=\frac{\mathrm{exp}(\tilde{a}_{c,wh})}{\sum_{w',h'}{\mathrm{exp}(\tilde{a}_{c,w'h'}})}. \end{equation} Finally, we perform weighted average pooling over all the locations to obtain a feature vector \begin{equation} \mathbf{f}_{c}=\sum_{w,h}a_{c,wh}\mathbf{f}_{c,wh} \end{equation} that encodes the information related to category $c$. We repeat the process for all categories and obtain all the category-related feature vectors $\{\mathbf{f}_{0}, \mathbf{f}_{1}, \dots, \mathbf{f}_{C-1}\}$. In this way, we can learn the feature $\mathbf{f}_c$, which focuses more on the semantic regions of each category $c$ and primarily encodes the features for each category. We also present some examples for quantitative analysis in Fig. \ref{fig:semantic-map}. \subsubsection{Knowledge-embedded feature propagation} \label{sec:SI} After obtaining the feature vectors corresponding to all the categories, we initialize the nodes of $\mathcal{G}$ with the feature vector of the corresponding category and introduce a graph neural network to propagate messages through the graph to explore their interactions and learn a contextualized representation. Inspired by the gated graph neural networks method \cite{li2016gated}, we adopt a gated recurrent update mechanism to propagate messages through the graph and learn the contextualized node-level features. Specifically, each node $v_c \in \mathbf{V}$ has a hidden state $\mathbf{h}_c^t$ at timestep $t$. In this work, because each node corresponds to a specific category and our model aims to explore the interactions among semantic-specific features, we initialize the hidden state at $t=0$ with the feature vector that relates to the corresponding category, formulated as \begin{equation} \mathbf{h}_c^0=\mathbf{f}_{c}. \end{equation} At timestep $t$, the framework aggregates messages from its neighbor nodes as follows: \begin{equation} \mathbf{a}_c^t=\left[\sum_{c'}(a_{cc'})\mathbf{h}_c^{t-1}, \sum_{c'}(a_{c'c})\mathbf{h}_c^{t-1}\right]. \end{equation} In this way, the framework encourages message propagation when node $c'$ is highly correlated with node $c$; otherwise, it suppresses propagation. Therefore, this approach propagates messages through the graph and explores node interactions under the prior knowledge guidance of statistical label co-occurrences. Then, the framework updates the hidden state based on the aggregated feature vector $\mathbf{a}_c^t$ and its hidden state at the previous timestep $\mathbf{h}_c^{t-1}$ via a gated mechanism similar to the gated recurrent unit, formulated as \begin{equation} \begin{split} \mathbf{z}_c^t=&{}\sigma(\mathbf{W}^z{\mathbf{a}_c^t}+\mathbf{U}^z{\mathbf{h}_c^{t-1}}) \\ \mathbf{r}_c^t=&{}\sigma(\mathbf{W}^r{\mathbf{a}_c^t}+\mathbf{U}^r{\mathbf{h}_c^{t-1}}) \\ \widetilde{\mathbf{h}_c^t}=&{}\tanh\left(\mathbf{W}{\mathbf{a}_c^t}+\mathbf{U}({\mathbf{r}_c^t}\odot{\mathbf{h}_c^{t-1}})\right) \\ \mathbf{h}_c^t=&{}(1-{\mathbf{z}_c^t}) \odot{\mathbf{h}_c^{t-1}}+{\mathbf{z}_c^t}\odot{\widetilde{\mathbf{h}_c^t}}, \end{split} \label{eq:ggnn} \end{equation} where $\sigma(\cdot)$ is the logistic sigmoid function, $\tanh(\cdot)$ is the hyperbolic tangent function, and $\odot$ is elementwise multiplication. In this way, each node aggregates messages from the other nodes and simultaneously propagates their information through the graph, enabling interactions among all the feature vectors corresponding to all categories. The process is repeated $T_f$ times; the generated final hidden states are $\{\mathbf{h}_0^{T_f}, \mathbf{h}_1^{T_f}, \dots, \mathbf{h}_{C-1}^{T_f}\}$. Here, the hidden state of each node $\mathbf{h}_{c}^{T_f}$ not only encodes features from category $c$ but also carries contextualized messages from other categories. Finally, we concatenate $\mathbf{h}_{c}^{T_f}$ and the input feature vector $\mathbf{h}_{c}^0$ to obtain the feature vector for each category \begin{equation} \begin{split} \mathbf{o}_c=f_o(\mathbf{h}_{c}^{T_f}, \mathbf{h}_{c}^0) \\ \end{split} \label{eq:cls} \end{equation} where $f_o(\cdot)$ is an output function that maps the concatenation of $\mathbf{h}_{c}^T$ and $\mathbf{h}_{c}^0$ into an output vector $\mathbf{o}_c$. \subsection{Graph Semantic Propagation} A classifier weight can be regarded as the prototype representation of the corresponding category. Transferring the prototype representations among similar categories can substantially enhance classifier training, especially for categories with few training samples. To achieve this, we integrate the graph $\mathcal{G}$ to guide the prototype representation propagation among all the categories to fully exploit the information of correlated categories and improve classifier training. Specifically, we initialize each graph node with the classifier weight of the corresponding category and iteratively propagate the node messages though the graph. In each iteration $t$, node $v_c$ has a hidden state $\mathbf{h}_c^t$. The hidden state $\mathbf{h}_c^0$ at iteration $t=0$ is set to the initial classifier weight $\mathbf{w}_{c}^{init}$, formulated as follows: \begin{equation} \mathbf{h}_c^0=\mathbf{w}_{c}^{init}, \label{eq:node-initialization} \end{equation} where $\mathbf{w}_c^{init}$ is randomly initialized before training. At each iteration $t$, each node $k$ aggregates the messages from its correlated nodes such that the parameter vectors of those nodes can help refine the node's own parameter vector, formulated as follows: \begin{equation} \mathbf{a}_c^t=[\sum_{c'=1}^K{a_{kk'}\mathbf{h}_{c}^{t-1}},\sum_{c'=1}^K{a_{c'c}\mathbf{h}_{c}^{t-1}}]. \label{eq:node-aggregation} \end{equation} In this way, a high correlation between nodes $k$ and $k'$ encourages message propagation from $k'$ to $k$; otherwise, it suppresses the propagation. Then, the framework uses these aggregated feature vectors and the hidden state of the previous iteration as input to update the hidden state via a gated mechanism as Eq. \ref{eq:ggnn}. In this way, each node can aggregate more message from the nodes of correlated categories to help update its classifiers. The iteration is repeated $T_s$ times; eventually, the final hidden states $\{\mathbf{h}_0^{T_s}, \mathbf{h}_1^{T_s}, \dots, \mathbf{h}_{C-1}^{T_s}\}$ are generated. Finally, we also utilize a simple output network to predict the classifier weight \begin{equation} \mathbf{w}_c^*=w_o(\mathbf{h}_c^{T_s}, \mathbf{h}_c^0). \label{eq:node-output} \end{equation} \subsection{Network Architecture} Following existing multi-label image classification works \cite{zhu2017learning}, we implement the feature extractor $f_{cnn}(\cdot)$ based on the widely used ResNet-101 \cite{he2016deep}. Specifically, we replace the last average pooling layer with another average pooling layer with a size of $2\times 2$ and a stride of 2. The other layers remain unchanged in this implementation. For the low rank bilinear pooling operation, $N$, $d_s$, $d_1$, and $d_2$ are set to 2,048, 300, 1,024, and 1,024, respectively. Thus, $f_a(\cdot)$ is implemented by a 1,024-to-1 fully connected layer that maps the 1,024-feature vector to a single attentional coefficient. The two gate graph networks share the same architecture. Specifically, the hidden state dimension is set to 2,048, while the iteration numbers $T_f$ and $T_s$ are set to 3. The output vector dimension $\mathbf{o}_c$ is also set to 2,048. Thus, the output networks $f_o(\cdot)$ and $w_o(\cdot)$ are implemented by a 4,096-to-2,048 fully connected layer followed by the hyperbolic tangent function. \subsection{From MLR to ML-FSL} As we obtain the feature vector $\mathbf{f}_c$ and classifier $\mathbf{w}_c^*$ for each category $c$, we multiply them to obtain the score: \begin{equation} s_c=\mathbf{w}_c^{*\top}\mathbf{f}_c. \label{eq:score} \end{equation} We conduct this multiplication process for all the categories and obtain a score vector $\mathbf{s}=\{s_0, s_1, \dots, s_{C-1}\}$. Next, we apply the framework to multi-label image recognition and adapt it to a more challenging task, i.e., multi-label few shot learning. \subsubsection{Multi-label Image Recognition} \label{sec:mlr} Given a dataset that contains $M$ training samples $\{I_i, y_i\}_{i=0}^{M-1}$, in which $I_i$ is the $i$-th image and $y_i=\{y_{i0}, y_{i1}, \dots, y_{i(C-1)}\}$ is the corresponding annotation. $y_{ic}$ is assigned a 1 if the sample is annotated with category $c$ and 0 otherwise. Given an image $I_i$, we can obtain a predicted score vector $\mathbf{s}_i=\{s_{i0}, s_{i1}, \dots, s_{i(C-1)}\}$ and compute the corresponding probability vector $\mathbf{p}_i=\{p_{i0}, p_{i1}, \dots, p_{i(C-1)}\}$ via a sigmoid function \begin{equation} p_{ic}=\sigma(s_{ic}). \end{equation} We adopt cross entropy as the objective loss function \begin{equation} \mathcal{L}=\sum_{i=0}^{N-1}\sum_{c=0}^{C-1}\left(y_{ic}\log p_{ic}+(1-y_{ic})\log(1-p_{ic})\right). \label{eq:mlr_loss} \end{equation} We train the proposed framework with the loss $\mathcal{L}$ in an end-to-end fashion. Specifically, we first apply the ResNet-101 parameters pretrained on the ImageNet dataset \cite{deng2009imagenet} to initialize the parameters of the corresponding layers in $f_{cnn}$; we initialize the parameters of other layers randomly. Because the lower layer parameters pretrained on the ImageNet dataset generalize well across different datasets, we fix the parameters of the previous 92 convolutional layers in $f_{cnn}(\cdot)$ and jointly optimize all the other layers. The framework is trained with the Adam algorithm \cite{kingma2015adam} with a batch size of 4 and momentums of 0.999 and 0.9. The learning rate is initialized to $10^{-5}$ and divided by 10 when the error plateaus. During training, the input image is resized to $640\times 640$, and we randomly choose a number from $\{640, 576, 512, 448, 384, 320\}$ as the width and height to crop random patches. Finally, the cropped patches are further resized to $576\times 576$. During testing, we simply resize the input image to $640\times 640$ and perform a center crop with a size of $576\times 576$ for evaluation. \subsubsection{Multi-Label Few-Shot Learning} For multi-label few-shot learning, the dataset contains a set of $C_b$ base categories with sufficient training samples and a set of $C_n$ novel categories with limited training samples (e.g., 1, 2, or 5). Because the training samples for the base and novel categories are extremely unbalanced, it inevitably leads to poor performances if using the loss as Equation (\ref{eq:mlr_loss}) for training, especially on the novel categories. Thus, we follow the previous work \cite{alfassy2019laso} to adopt a two-stage process to train the proposed framework. \noindent\textbf{Stage 1.} In the first stage, we train the framework using the training samples of the base categories. Here, we have $C_b$ categories, and construct the adjacent matrix $\mathbf{A}=\mathbf{A}_b\in \mathcal{R}^{C_b \times C_b}$ based on the co-occurrences among these $C_b$ categories (following the process described in Sec. \ref{sec:kgc}). Given a sample from the $C_b$ categories, we can compute the score vector $\mathbf{s}_i=\{s_{i0}, s_{i1}, \dots, s_{i(C_b-1)}\}$ and the corresponding probability vector $\mathbf{p}_i=\{p_{i0}, p_{i1}, \dots, p_{i(C_b-1)}\}$. Then, we define the loss similarly to Eq. \ref{eq:mlr_loss}, expressed as \begin{equation} \mathcal{L}_b=\sum_{i=0}^{N_b-1}\sum_{c=0}^{C_b-1}\left(y_{ic}\log p_{ic}+(1-y_{ic})\log(1-p_{ic})\right). \label{eq:mlr_fsl_loss} \end{equation} where $N_b$ is the number of training samples from the base set. Similarly, the parameters of the backbone network are initialized with the parameters pretrained on the ImageNet dataset, while those of the other layers are randomly initialized. We also fix the previous convolutional layers in the backbone networks and jointly train all the other layers using the Adam algorithm with a batch size of 4 and momentums of 0.999 and 0.9. We set the initial learning rate to $10^{-5}$ and divided it by 10 after 12 epochs. The framework is trained with 20 epochs in total. During training, the augmentation strategy is the same as that adopted for multi-label recognition (described in Sec. \ref{sec:mlr}). \noindent\textbf{Stage 2.} In the second stage, we fix the parameters of the backbone network and the attention modules for feature extraction and train the two graph neural networks using the novel sets. Because the training samples are limited during this stage, we cannot compute the statistical co-occurrence to obtain the adjacent matrix. To address this issue, we consider semantic similarity to compute the label correlations. Specifically, we use Glove \cite{pennington2014glove} to extract semantic vector for each category, compute the cosine distance between each category pair to obtain their semantic similarities, and construct the adjacent matrix $\mathbf{A}=\mathbf{A}_n\in \mathcal{R}^{C_n \times C_n}$. In addition, we introduce an additional regularization term on the classifier weights and thus the loss function can be formulated as \begin{equation} \begin{split} \mathcal{L}_b=&\sum_{i=0}^{N_n-1}\sum_{c=0}^{C_n-1}\left(y_{ic}\log p_{ic}+(1-y_{ic})\log(1-p_{ic})\right) \\ &+\gamma\sum_{c=0}^{C_n-1}||\mathbf{w}^*_c||^2_2, \end{split} \end{equation} where $N_n$ is the number of samples from the novel set and $\gamma$ is a balance parameter that is set to 0.001. We train the model using the Adam algorithm with the same batch size, momentums, and data augmentation strategy as in stage 1. Because we merely train the two graph neural networks while fixing other layers, we set a large learning rate $10^{-4}$ and train the framework for merely 500 iterations. \begin{table*}[!t] \centering \begin{tabular}{c|c|cccccc|cccccc} \hline & & \multicolumn{6}{c|}{Top 3} &\multicolumn{6}{c}{All} \\ \hline \centering Methods & mAP & CP & CR & CF1 & OP & OR & OF1 & CP & CR & CF1 & OP & OR & OF1 \\ \hline \hline WARP \cite{gong2014deep} &- & 59.3 & 52.5 & 55.7 & 59.8 & 61.4 & 60.7 & - & - & -&- & -&- \\ CNN-RNN \cite{wang2016cnn} &- & 66.0 & 55.6 & 60.4 & 69.2 & 66.4 & 67.8 &- & - & -&- & -&-\\ RLSD \cite{zhang2018multi} &- & 67.6 & 57.2 & 62.0 & 70.1 & 63.4 & 66.5 &- & - & -&- & -&-\\ RARL \cite{chen2018recurrent} & - & 78.8 & 57.2 & 66.2 & 84.0 & 61.6 & 71.1 & \\ RDAR \cite{wang2017multi} & 73.4 & 79.1 & 58.7 & 67.4 & 84.0 & 63.0 & 72.0 &- & - & -&- & -&-\\ KD-WSD \cite{DBLP:conf/mm/LiuSSYXP18}& 74.6 & - & -& 66.8 & - &- &72.7 &- &-& 69.2 & - & -&74.0 \\ ResNet-SRN-att \cite{zhu2017learning} & 76.1 & 85.8 & 57.5 & 66.3 & 88.1 & 61.1 & 72.1 & 81.2 & 63.3 & 70.0 & 84.1 & 67.7 & 75.0\\ ResNet-SRN \cite{zhu2017learning} & 77.1 & 85.2 & 58.8 & 67.4 & 87.4 & 62.5 & 72.9 & 81.6 & 65.4 & 71.2 & 82.7 & 69.9 & 75.8 \\ ML-GCN \cite{DBLP:conf/cvpr/ChenWWG19} & 83.1 & 89.2 & 64.1 & 74.6 & 90.5 & 66.5 & 76.7 &85.1 & 72.0 & 78.0 & 85.8 &75.4 & 80.3 \\ \hline Ours & \textbf{84.3} & \textbf{89.4} & \textbf{64.6} & \textbf{75.0} & \textbf{91.3} & \textbf{66.6} & \textbf{77.0} & \textbf{85.6} & \textbf{72.7} & \textbf{78.6} & \textbf{87.1} & \textbf{75.6} & \textbf{80.9} \\ \hline \end{tabular} \caption{Comparison of the mAP, CP, CR, CF1 and OP, OR, OF1 (in \%) scores of our framework and other state-of-the-art methods under settings of all and top-3 labels on the Microsoft COCO dataset. A hyphen ``-'' denotes that no corresponding result was provided.} \vspace{-10pt} \label{table:result-coco} \end{table*} \section{Experiments} In this section, we conduct extensive experiments on various benchmarks to evaluate the performance of the proposed framework over existing state-of-the-art methods and perform ablative studies to further analyze the actual contribution of each component. \subsection{Evaluation Metrics} For multi-label image recognition, we follow current state-of-the-art works \cite{wei2016hcp,chen2019multi} by adopting the average precision (AP) on each category and the mean average precision (mAP) over all categories. For more comprehensive comparisons, we further follow the current works \cite{zhu2017learning,li2017improving} to present the precision, recall, and F1-measure values. Here, we assign the labels with the top-$3$ highest scores for each image and compare them with the ground truth labels. Concretely, we adopt overall precision, recall, and F1-measure (OP, OR, and OF1) and per-class precision, recall, and F1-measure (CP, CR, and CF1), which are defined as shown below: \begin{equation} \begin{split} \mathrm{OP}&=\frac{\sum_{i}N_{i}^{c}}{\sum_{i}N_{i}^{p}},\quad\\ \mathrm{OR}&=\frac{\sum_{i}N_{i}^{c}}{\sum_{i}N_{i}^{g}},\quad\\ \mathrm{OF}1&=\frac{2 \times \mathrm{OP} \times \mathrm{OR}}{\mathrm{OP}+\mathrm{OR}},\quad \end{split} \begin{split} \mathrm{CP}&=\frac{1}{C}\sum_{i}\frac{N_{i}^{c}}{N_{i}^{p}},\\ \mathrm{CR}&=\frac{1}{C}\sum_{i}\frac{N_{i}^{c}}{N_{i}^{g}},\\ \mathrm{CF}1&=\frac{2 \times \mathrm{CP} \times \mathrm{CR}}{\mathrm{CP}+\mathrm{CR}}, \end{split} \label{eqn:metric} \end{equation} where $C$ is the number of labels, $N_{i}^{c}$ is the number of images for which the $i$-th label is correctly predicted, $N_{i}^{p}$ is the number of images for which the $i$-th label is predicted, and $N_{i}^{g}$ is the number of ground truth images for the $i$-th label. The above metrics require a fixed number of labels, but the label numbers of different images generally vary. Thus, we further present the OP, OR, OF1 and the CP, CR, CF1 metrics using the idea that a label is predicted as positive when its estimated probability is greater than 0.5 \cite{zhu2017learning}. Among these metrics, mAP, OF1, and CF1 are the most important and provide a more comprehensive evaluation. \subsection{Datasets} \noindent\textbf{Pascal VOC 2007 \& 2012} \cite{everingham2010pascal} are the datasets most widely used to evaluate the multi-label image classification task, and most of the existing works report their results on these datasets. Therefore, we also conducted experiments on these two datasets for evaluation purposes. Specifically, both datasets include 20 common categories. Pascal VOC 2007 contains a training and validation (trainval) set with 5,011 images and a test set with 4,952 images, while VOC 2012 includes 11,540 images as the trainval set and 10,991 images as the test set. For fair comparison purposes, the proposed framework and existing competitors were all trained on the trainval set and evaluated on the test set. However, because the number of categories in these two datasets is limited, we use these datasets merely to evaluate the multi-label image recognition task; we do not use them to evaluate the multi-label few-shot learning task. \noindent\textbf{Microsoft COCO} \cite{lin2014microsoft} was originally constructed for object detection and segmentation but has recently been adopted to evaluate multi-label image classification. This dataset contains 122,218 images and covers 80 common categories. The dataset is further divided into a training set with 82,081 images and a validation set with 40,137 images. Because no ground-truth annotations are available for the test set, we trained our method and all the compared methods on the training set and evaluated them on the validation set. For multi-label few-shot learning, we follow the previous work \cite{alfassy2019laso} to split the 80 categories into 64 base categories and 16 novel categories. Specifically, the novel categories are \emph{bicycle, boat, stop sign, bird, backpack, frisbee, snowboard, surfboard, cup, fork, spoon, broccoli, chair, keyboard, microwave,} and \emph{vase}. To ensure fair comparisons with current works, we utilize the trainval samples of the base categories as the base set and randomly select $K$ ($K$=1,5) trainval samples from the novel categories as the novel set. We evaluate the test samples of the novel categories. \noindent\textbf{Visual Genome} \cite{krishna2017visual} is a dataset that contains 108,249 images and covers 80,138 categories. Because most categories have very few samples, we consider only the 500 most frequent categories, resulting in a Visual Genome 500 (VG-500) subset. We randomly selected 10,000 images as the test set and the remaining 98,249 images as the training set. Compared with other existing benchmarks, this one covers more categories, i.e., 500 categories as opposed to 20 in Pascal VOC \cite{everingham2010pascal} and 80 in Microsoft-COCO \cite{lin2014microsoft}; thus, it can be used to evaluate multi-label image recognition performance with larger-scale categories. For multi-label few-shot learning, we split VG-500 into 400 base categories and 100 novel categories. Similar to Microsoft COCO, we used all training samples of the base categories as the base set and selected $K$ ($K$=1,5) training samples of the novel categories as the novel set. Then, we evaluate the models on the test samples of the novel categories. \begin{table*}[htp] \centering \scriptsize \begin{tabular} {p{2.5cm}|p{0.2cm}p{0.2cm}p{0.2cm}p{0.2cm}p{0.3cm}p{0.3cm}p{0.20cm}p{0.20cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.4cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}|p{0.5cm}} \hline \centering Methods & aero & bike & bird & boat & bottle & bus & car & cat & chair & cow & table & dog & horse & mbike & person & plant & sheep & sofa & train & tv & mAP \\ \hline \hline \centering CNN-RNN~\cite{wang2016cnn} & 96.7 & 83.1 & 94.2 & 92.8 & 61.2 & 82.1 & 89.1 & 94.2 & 64.2 & 83.6 & 70.0 & 92.4 & 91.7 & 84.2 & 93.7 & 59.8 & 93.2 & 75.3 & 99.7 & 78.6 & 84.0 \\ \centering RMIC \cite{DBLP:conf/aaai/He0G0T18} & 97.1 & 91.3 & 94.2 & 57.1 & 86.7 & 90.7 & 93.1 & 63.3 & 83.3 & 76.4 & 92.8 & 94.4 & 91.6 & 95.1 & 92.3 & 59.7 & 86.0 & 69.5 & 96.4 & 79.0 & 84.5 \\ \centering VGG16+SVM~\cite{simonyan2015very} & - & -&- & -&- & - & -&- &- & -& -& -& - & -& -&- &- & - &- &- & 89.3\\ \centering VGG19+SVM~\cite{simonyan2015very} & - & -&- & -&- & - & -&- &- & -& -& -& - & -& -&- &- & - &- &- & 89.3\\ \centering RLSD \cite{zhang2018multi} & 96.4 & 92.7 & 93.8 & 94.1 & 71.2 & 92.5 & 94.2 & 95.7 & 74.3 & 90.0 & 74.2 & 95.4 & 96.2 & 92.1 & 97.9 & 66.9 & 93.5 & 73.7 & 97.5 & 87.6 & 88.5\\ \centering HCP~\cite{wei2016hcp} & 98.6 & 97.1 & \textcolor[rgb]{0,0,1}{98.0} & 95.6 & 75.3&94.7 & 95.8 &97.3 & 73.1 & 90.2 & 80.0 & 97.3 & 96.1 & 94.9 & 96.3 & 78.3 & 94.7 & 76.2 & 97.9 & 91.5 & 90.9\\ \centering FeV+LV~\cite{yang2016exploit} & 97.9 & 97.0 & 96.6 & 94.6 & 73.6 & 93.9 & 96.5& 95.5 & 73.7 & 90.3 & 82.8 & 95.4 & 97.7 & \textcolor[rgb]{0,0,1}{95.9} & 98.6 & 77.6 & 88.7 & 78.0 & 98.3 & 89.0 & 90.6\\ \centering RDAR \cite{wang2017multi} & 98.6 & 97.4 & 96.3 & 96.2 & 75.2 & 92.4 & 96.5 & 97.1 & 76.5 & 92.0 & \textcolor[rgb]{1,0,0}{87.7} & 96.8 & 97.5 & 93.8 & 98.5 & 81.6 & 93.7 & \textcolor[rgb]{0,0,1}{82.8} & \textcolor[rgb]{0,0,1}{98.6} &89.3 & 91.9 \\ \centering RARL \cite{chen2018recurrent} & 98.6 & 97.1 & 97.1 & 95.5 & 75.6 & 92.8 & \textcolor[rgb]{0,0,1}{96.8} & 97.3 & \textcolor[rgb]{0,0,1}{78.3} & 92.2 & \textcolor[rgb]{0,0,1}{87.6} & 96.9 & 96.5 & 93.6 & 98.5 & 81.6 & 93.1 & 83.2 & 98.5 & 89.3 & 92.0 \\ \centering RCP \cite{wang2016beyond} & \textcolor[rgb]{0,0,1}{99.3} & \textcolor[rgb]{0,0,1}{97.6} & \textcolor[rgb]{0,0,1}{98.0} & 96.4 & 79.3 & 93.8 & 96.6 & 97.1 & 78.0 & 88.7 & 87.1 & 97.1 & 96.3 & 95.4 & \textcolor[rgb]{1,0,0}{99.1} & 82.1 & 93.6 & 82.2 & 98.4 & \textcolor[rgb]{0,0,1}{92.8} & 92.5 \\ \centering \textbf{Ours} & \textcolor[rgb]{1,0,0}{99.8} & 97.1 & \textcolor[rgb]{1,0,0}{98.4} & \textcolor[rgb]{0,0,1}{98.0} & \textcolor[rgb]{0,0,1}{84.2} & \textcolor[rgb]{0,0,1}{95.1} & \textcolor[rgb]{0,0,1}{96.9} & \textcolor[rgb]{0,0,1}{98.4} & \textcolor[rgb]{0,0,1}{78.6} & \textcolor[rgb]{0,0,1}{94.9} & 87.0& \textcolor[rgb]{0,0,1}{98.1} &\textcolor[rgb]{0,0,1}{97.7} & \textcolor[rgb]{1,0,0}{97.4} & \textcolor[rgb]{0,0,1}{98.7} & \textcolor[rgb]{0,0,1}{82.4} &\textcolor[rgb]{0,0,1}{97.1} & 82.5 & \textcolor[rgb]{0,0,1}{98.7} & 92.0 & \textcolor[rgb]{0,0,1}{93.6}\\ \centering \textbf{Ours (pre)} & \textcolor[rgb]{0,0,1}{99.3} & \textcolor[rgb]{1,0,0}{98.6} & 97.9 & \textcolor[rgb]{1,0,0}{98.4} & \textcolor[rgb]{1,0,0}{86.2} & \textcolor[rgb]{1,0,0}{97.0} & \textcolor[rgb]{1,0,0}{98.0} & \textcolor[rgb]{1,0,0}{99.2} & \textcolor[rgb]{1,0,0}{82.6} & \textcolor[rgb]{1,0,0}{98.3} & 87.5 & \textcolor[rgb]{1,0,0}{99.0} & \textcolor[rgb]{1,0,0}{98.9} & \textcolor[rgb]{1,0,0}{97.4} & \textcolor[rgb]{1,0,0}{99.1} & \textcolor[rgb]{1,0,0}{86.9} & \textcolor[rgb]{1,0,0}{98.2} & \textcolor[rgb]{1,0,0}{84.1} & \textcolor[rgb]{1,0,0}{99.0} & \textcolor[rgb]{1,0,0}{95.0} & \textcolor[rgb]{1,0,0}{95.0}\\ \hline \hline \centering VGG16\&19+SVM~\cite{simonyan2015very} & 98.9 & 95.0 & 96.8 & 95.4 & 69.7 & 90.4 & 93.5 & 96.0 & 74.2 & 86.6 & 87.8 & 96.0 & 96.3 & 93.1 & 97.2 & 70.0 & 92.1 & 80.3 & 98.1 & 87.0 & 89.7\\ \centering FeV+LV (fusion)~\cite{yang2016exploit} & 98.2 & 96.9 & 97.1 & 95.8 & 74.3 & 94.2 & 96.7 & 96.7 & 76.7 & 90.5 & 88.0 & 96.9 & 97.7 & \textcolor[rgb]{0,0,1}{95.9} & 98.6 & 78.5 & 93.6 & 82.4 & 98.4 & 90.4 & 92.0 \\ \hline \end{tabular} \vspace{1pt} \caption{Comparison of the AP and mAP (in \%) results of our framework and those of state-of-the-art methods on the PASCAL VOC 2007 dataset. The upper part presents the results of single models and the lower part presents those that aggregate multiple models. ``Ours'' and ``Ours (pre)'' denote our framework without and with pretraining on the COCO dataset, respectively. The best and second-best results are highlighted in {\color{red}{red}} and {\color{blue}{blue}}, respectively. A hyphen ``-'' denotes that no corresponding result was provided. Best viewed in color.} \label{table:comparision_voc07} \end{table*} \begin{table*}[htp] \centering \scriptsize \begin{tabular} {p{2.5cm}|p{0.2cm}p{0.2cm}p{0.2cm}p{0.2cm}p{0.3cm}p{0.3cm}p{0.20cm}p{0.20cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.4cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}p{0.3cm}|p{0.5cm}} \hline \centering Methods & aero & bike & bird & boat & bottle & bus & car & cat & chair & cow & table & dog & horse & mbike & person & plant & sheep & sofa & train & tv & mAP \\ \hline \hline \centering RMIC \cite{DBLP:conf/aaai/He0G0T18} & 98.0 & 85.5 & 92.6 & 88.7 & 64.0 & 86.8 & 82.0 & 94.9 & 72.7 & 83.1 & 73.4 & 95.2 & 91.7 & 90.8 &95.5 & 58.3 & 87.6 & 70.6 & 93.8 & 83.0 & 84.4 \\ \centering VGG16+SVM~\cite{simonyan2015very} & 99.0 & 88.8 & 95.9 & 93.8 & 73.1 & 92.1 & 85.1 & 97.8 & 79.5 & 91.1 & 83.3 & 97.2 & 96.3 & 94.5 & 96.9 & 63.1 & 93.4 & 75.0 & 97.1 & 87.1 & 89.0 \\ \centering VGG19+SVM~\cite{simonyan2015very} & 99.1 & 88.7 & 95.7 & 93.9 & 73.1 & 92.1 & 84.8 & 97.7 & 79.1 & 90.7 & 83.2 & 97.3 & 96.2 & 94.3 & 96.9 & 63.4 & 93.2 & 74.6 & 97.3 & 87.9 & 89.0 \\ \centering HCP \cite{wei2016hcp} & 99.1 & 92.8 & 97.4 & 94.4 & 79.9 & 93.6 & 89.8 & 98.2 & 78.2 & 94.9 & 79.8 & 97.8 & 97.0 & 93.8 & 96.4 & 74.3 & 94.7 & 71.9 & 96.7 & 88.6 & 90.5 \\ \centering FeV+LV~\cite{yang2016exploit} & 98.4 & 92.8 & 93.4 & 90.7 & 74.9 & 93.2 & 90.2 & 96.1 & 78.2 & 89.8 & 80.6 & 95.7 & 96.1 & 95.3 & 97.5 & 73.1 & 91.2 & 75.4 & 97.0 & 88.2 & 89.4 \\ \centering RCP \cite{wang2016beyond} & \textcolor[rgb]{0,0,1}{99.3} & 92.2 & \textcolor[rgb]{0,0,1}{97.5} & 94.9 & 82.3 & 94.1 & 92.4 & \textcolor[rgb]{0,0,1}{98.5} & 83.8 & 93.5 & 83.1 & 98.1 & 97.3 & 96.0 & \textcolor[rgb]{0,0,1}{98.8} & 77.7 & 95.1 & 79.4 & 97.7 & 92.4 & 92.2 \\ \centering \textbf{Ours} & \textcolor[rgb]{1,0,0}{99.6} & \textcolor[rgb]{0,0,1}{95.1} & \textcolor[rgb]{0,0,1}{97.5} & \textcolor[rgb]{1,0,0}{96.9} & \textcolor[rgb]{0,0,1}{83.1} & \textcolor[rgb]{0,0,1}{94.8} & \textcolor[rgb]{0,0,1}{94.2} & \textcolor[rgb]{0,0,1}{98.9} & \textcolor[rgb]{0,0,1}{86.5} & \textcolor[rgb]{0,0,1}{97.0} & \textcolor[rgb]{0,0,1}{84.9} & \textcolor[rgb]{0,0,1}{98.9} & \textcolor[rgb]{0,0,1}{98.9} & \textcolor[rgb]{0,0,1}{96.6} & \textcolor[rgb]{0,0,1}{98.8} & \textcolor[rgb]{0,0,1}{81.8} & \textcolor[rgb]{0,0,1}{98.3} & \textcolor[rgb]{0,0,1}{84.0} & \textcolor[rgb]{0,0,1}{98.4} & \textcolor[rgb]{0,0,1}{93.1} & \textcolor[rgb]{0,0,1}{93.9} \\ \centering \textbf{Ours (pre)} & \textcolor[rgb]{1,0,0}{99.6} & \textcolor[rgb]{1,0,0}{96.8} & \textcolor[rgb]{1,0,0}{97.9} & \textcolor[rgb]{0,0,1}{96.7} & \textcolor[rgb]{1,0,0}{87.3} & \textcolor[rgb]{1,0,0}{96.5} & \textcolor[rgb]{1,0,0}{96.2} & \textcolor[rgb]{1,0,0}{99.1} & \textcolor[rgb]{1,0,0}{87.9} & \textcolor[rgb]{1,0,0}{97.7} & \textcolor[rgb]{1,0,0}{86.8} & \textcolor[rgb]{1,0,0}{99.3} & \textcolor[rgb]{1,0,0}{99.3} & \textcolor[rgb]{1,0,0}{97.5} & \textcolor[rgb]{1,0,0}{99.1} & \textcolor[rgb]{1,0,0}{85.39} & \textcolor[rgb]{1,0,0}{98.8} & \textcolor[rgb]{1,0,0}{84.9} &\textcolor[rgb]{1,0,0}{99.6} & \textcolor[rgb]{1,0,0}{94.4} & \textcolor[rgb]{1,0,0}{95.0} \\ \hline \hline \centering VGG16\&19+SVM~\cite{simonyan2015very} & \textcolor[rgb]{0,0,1}{99.1} & 89.1 & 96.0 & 94.1 & 74.1 & 92.2 & 85.3 & 97.9 & 79.9 & 92.0 & 83.7 & 97.5 & 96.5 & 94.7 & 97.1 & 63.7 & 93.6 & 75.2 & 97.4 & 87.8 & 89.3 \\ \centering FeV+LV (fusion)~\cite{yang2016exploit} & 98.9 & 93.1 & 96.0 & 94.1 & 76.4 & 93.5 & 90.8 & 97.9 & 80.2 & 92.1 &82.4 & 97.2 & 96.8 & 95.7 & 98.1 & 73.9 & 93.6 & 76.8 & 97.5 & 89.0 & 90.7 \\ \centering HCP+AGS \cite{wei2016hcp,dong2013subcategory} & \textcolor[rgb]{1,0,0}{99.8} & \textcolor[rgb]{0,0,1}{94.8} & 97.7 & 95.4 & 81.3 & 96.0 & 94.5 & 98.9 & 88.5 & 94.1 & 86.0 & 98.1 & 98.3 & 97.3 & 97.3 & 76.1 & 93.9 & 84.2 & 98.2 & 92.7 & 93.2 \\ \centering RCP+AGS \cite{wang2016beyond,dong2013subcategory} & \textcolor[rgb]{1,0,0}{99.8} & 94.5 & \textcolor[rgb]{0,0,1}{98.1} & \textcolor[rgb]{0,0,1}{96.1} & \textcolor[rgb]{0,0,1}{85.5} & \textcolor[rgb]{0,0,1}{96.1} & \textcolor[rgb]{0,0,1}{95.5} & \textcolor[rgb]{0,0,1}{99.0} & \textcolor[rgb]{1,0,0}{90.2} & \textcolor[rgb]{0,0,1}{95.0} & \textcolor[rgb]{0,0,1}{87.8} & \textcolor[rgb]{0,0,1}{98.7} & \textcolor[rgb]{0,0,1}{98.4} & \textcolor[rgb]{0,0,1}{97.5} & \textcolor[rgb]{0,0,1}{99.0} & \textcolor[rgb]{0,0,1}{80.1} & \textcolor[rgb]{0,0,1}{95.9} & \textcolor[rgb]{0,0,1}{86.5} & \textcolor[rgb]{0,0,1}{98.8} & \textcolor[rgb]{0,0,1}{94.6} & \textcolor[rgb]{0,0,1}{94.3} \\ \centering \textbf{Ours (pre \& fusion)} & \textcolor[rgb]{1,0,0}{99.8} & \textcolor[rgb]{1,0,0}{97.3} & \textcolor[rgb]{1,0,0}{98.4} & \textcolor[rgb]{1,0,0}{97.1} & \textcolor[rgb]{1,0,0}{87.9} & \textcolor[rgb]{1,0,0}{97.3} & \textcolor[rgb]{1,0,0}{96.5} & \textcolor[rgb]{1,0,0}{99.3} & \textcolor[rgb]{0,0,1}{89.4} & \textcolor[rgb]{1,0,0}{97.8} & \textcolor[rgb]{1,0,0}{88.7} & \textcolor[rgb]{1,0,0}{99.4} & \textcolor[rgb]{1,0,0}{99.4} & \textcolor[rgb]{1,0,0}{97.9} & \textcolor[rgb]{1,0,0}{99.2} & \textcolor[rgb]{1,0,0}{86.3} & \textcolor[rgb]{1,0,0}{98.8} & \textcolor[rgb]{1,0,0}{86.3} & \textcolor[rgb]{1,0,0}{99.7} & \textcolor[rgb]{1,0,0}{95.2} & \textcolor[rgb]{1,0,0}{95.6}\\ \hline \end{tabular} \vspace{1pt} \caption{Comparison of the AP and mAP scores (in \%) of our model and those of state-of-the-art methods on the PASCAL VOC 2012 dataset. The upper part presents the results of single models and the lower part presents those that aggregate multiple models. ``Ours'' and ``Ours (pre)'' denote our framework without and with pretraining on the COCO dataset. ``Ours (pre \& fusion)'' denotes the results when fusing our two scale results. The best and second-best results are highlighted in {\color{red}{red}} and {\color{blue}{blue}}, respectively. Best viewed in color.} \label{table:comparision_voc12} \end{table*} \subsection{Results on Multi-Label Image Recognition} In this subsection, we provide the comparison of the proposed framework with current state-of-the-art methods on the multi-label image recognition task. \subsubsection{Comparison on Microsoft COCO} We first present the evaluation results on the Microsoft COCO \cite{lin2014microsoft} dataset. To fairly compare the OP, OR, OF1 and CP, CR, CF1 metrics with the top-3 constraint, we follow the existing method \cite{wang2016cnn} to exclude labels with probabilities below a threshold (0.5 in our experiments). The comparison results are presented in Table \ref{table:result-coco}. As shown, the current best-performing methods are ResNet-SRN and ML-GCN, in which ResNet-SRN builds on ResNet-101 and applies an attention mechanism to model the label relations, while ML-GCN further uses a graph convolutional network to capture the label dependencies and achieves a mAP of 83.1\%. In contrast to these methods, our framework models label dependencies in both the feature and label spaces, leading to notable performance improvements on all the metrics. Specifically, it achieves a mAP of 84.3\%, improving on the results of the previous best methods by 1.2\%. \begin{figure*}[!t] \centering \includegraphics[width=0.98\linewidth]{./ap-comparison.pdf} \caption{The AP (in \%) of each category of our proposed framework and the ResNet-101 baseline on the Microsoft COCO dataset.} \label{fig:ap-comparison} \end{figure*} \begin{table*}[!t] \centering \begin{tabular}{c|c|cccccc|cccccc} \hline & & \multicolumn{6}{c|}{Top 3} &\multicolumn{6}{c}{All} \\ \hline \centering Methods & mAP & CP & CR & CF1 & OP & OR & OF1 & CP & CR & CF1 & OP & OR & OF1 \\ \hline \hline ResNet-101 \cite{he2016deep} & 30.9 & 39.1 & 25.6 & 31.0 & 61.4 & 35.9 & 45.4 & 39.2 & 11.7 & 18.0 & 75.1 & 16.3 & 26.8 \\ ML-GCN \cite{DBLP:conf/cvpr/ChenWWG19} & 32.6 & 42.8 & 20.2 & 27.5 & 66.9 & 31.5 & 42.8 & 39.4 & 10.6 & 16.8 & 77.1 & 16.4 & 27.1 \\ \hline Ours & \textbf{37.4} & \textbf{47.4} & \textbf{24.7} & \textbf{32.5} & \textbf{66.9} & \textbf{36.5} & \textbf{47.2} & \textbf{48.7} & \textbf{12.1} & \textbf{19.4} & \textbf{78.6} & \textbf{17.1} & \textbf{28.1} \\ \hline \end{tabular} \caption{Comparison of the mAP, CP, CR, CF1 and OP, OR, OF1 (in \%) scores of our framework and other state-of-the-art methods under settings of all and top-3 labels on the VG-500 dataset.} \vspace{-10pt} \label{table:result-vg} \end{table*} \subsubsection{Comparisons on Pascal VOC 2007 and 2012} Here, we present the AP of each category and the mAP over all categories on the Pascal VOC 2007 dataset in Table \ref{table:comparision_voc07}. Most of the existing state-of-the-art methods focus on locating informative regions (e.g., proposal candidates \cite{yang2016exploit,wei2016hcp,zhang2018multi}, attentive regions \cite{wang2017multi}, or random regions \cite{wang2016beyond}) to aggregate local discriminative features to facilitate recognizing multiple labels in the given image. For example, RCP achieves a mAP of 92.5\%, which is the best result to date. In contrast, our framework incorporates category semantics to better learn semantic-specific features and explores their interactions under the explicit guidance of statistical label dependencies, which further improves the mAP to 93.6\%. In addition, when our framework is pretrained on the COCO dataset, it achieves an even better performance, i.e., 95.0\%, as shown in Table \ref{table:comparision_voc07}. Note that the existing methods aggregate multiple models \cite{simonyan2015very} or fuse the results with other methods \cite{yang2016exploit} to improve the overall performance. For example, FeV+LV (fusion) aggregates its results with those of VGG16\&19+SVM, which improves the mAP from 90.6\% to 92.0\%. Although our results are generated by a single model, it still outperforms all these aggregated results. We also compare the performances on the Pascal VOC 2012 dataset, as depicted in Table \ref{table:comparision_voc12}. VOC 2012 is more challenging and larger in size, but our framework still achieves the best performance compared with the state-of-the-art competitors. Specifically, it obtains mAP scores of 93.9\% and 95.0\% without and with pretraining on the COCO dataset, respectively, with improvements over the previous best method by 1.7\% and 2.8\%, respectively. Similarly, the existing methods also aggregate the results of multiple models to boost performance. To ensure a fair comparison, we trained another model with an input of $448 \times 448$. Specifically, during training, we resized the input image to $512 \times 512$, and randomly choose a number from {512, 448, 384, 320, 256} as the width and height to randomly crop patches; then, we further resized the cropped patches to $448 \times 448$. We denote the original model as ``scale 640" and this modified model as ``scale 512". The two models are both pretrained on the COCO dataset and retrained on the VOC 2012 dataset. Then, we perform ten crop evaluations (the four corner crops and the center crop as well as their horizontally flipped versions) for each scale and aggregate the results from the two scales. As shown in the lower part of Table \ref{table:comparision_voc12}, our framework boosts the mAP to 95.6\%, outperforming all the existing methods with single and multiple models. \subsubsection{Comparison on Visual Genome 500} The Visual Genome 500 is a new dataset that can be used to evaluate multi-label image recognition with larger-scale categories; thus, no existing methods have reported their results on this dataset. To demonstrate the effectiveness of our proposed framework on this dataset, we implemented a ResNet-101 baseline network and trained it using the same process as was used for our model previously. Because ML-GCN \cite{chen2019multi} is the best-performing method on the Microsoft-COCO dataset, we further follow its released code to train the model on VG-500 for comparison. All the methods were trained on the training set and evaluated on the test set. The comparison results are presented in Table \ref{table:result-vg}. Our framework performs considerably better than the existing state-of-the-art and the ResNet-101 baseline methods on all metrics. Specifically, it achieves the mAP, top-3 CF1 and OF1, and top-all CF1 and OF1 of 37.4\%, 32.5\%, 47.2\%, 19.4\%, 28.1\%, improving the existing best method ML-GCN by 4.8\%, 1.5\%, 1.8\%, 1.4\%, 1.0\%, respectively. This comparison suggests that our framework also performs better for recognizing large-scale categories. \subsection{Results on Multi-Label Few-Shot Learning} In this subsection, we present comparisons of our proposed framework with current methods on the multi-label few-shot learning task. \subsubsection{Comparison on Microsoft COCO} The previous best-performing method for multi-label few-shot learning is LaSO \cite{alfassy2019laso}, and its results are mainly presented on Microsoft COCO. In this section, we compare our proposed method with this work and the baseline method that uses the mixUp \cite{zhang2017mixup} augmentation technique to directly train on the small novel set. The results are presented in Table \ref{table:result-fs-coco}. As shown, LaSO achieves mAPs of 45.3\% and 58.1\% on the 1-shot and 5-shot settings, respectively. In contrast, our method incorporates prior knowledge of category correlation to guide feature and semantic propagation among the different categories, leading to superior performance. Specifically, our method's mAP scores on the 1-shot and 5-shot settings are 52.3\% and 63.5\%, outperforming LaSO by 7.0\% and 5.4\%, respectively. Note that we use ResNet-101 \cite{he2016deep} as the backbone, while LaSO uses GoogleNet-v3 \cite{szegedy2015going,szegedy2016rethinking}. To ensure a fair comparison, we further replaced our backbone network with GoogleNet-v3, keeping the other components and the training process unchanged. Nevertheless, our framework still outperforms LaSO, achieving mAP scores of 49.4\% and 61.0\% on the 1-shot and 5-shot settings, respectively. \begin{table}[!t] \centering \begin{tabular}{c|cc} \hline \centering Methods & 1-shot & 5-shot \\ \hline \hline Baseline w/ Mixup Aug \cite{zhang2017mixup} & 40.2 & 54.0 \\ LaSO (GoogleNet-v3) \cite{alfassy2019laso} & 45.3 & 58.1 \\ \hline Ours (GoogleNet-v3) & 49.4 & 61.0 \\ Ours (ResNet-101) & 52.3 & 63.5\\ \hline \end{tabular} \vspace{2pt} \caption{Comparison of the mAP (in \%) on 1-shot and 5-shot settings on the Microsoft COCO dataset. We present the results of both 1-shot and 5-shot settings.} \label{table:result-fs-coco} \end{table} \begin{figure*}[!t] \centering \includegraphics[width=0.9\linewidth]{./semantic-map-v1.pdf} \caption{Several examples of input images (left), semantic feature maps corresponding to categories with the top-$k$ ($k=4,5$) highest confidences (middle), and the predicted label distribution (right).} \label{fig:semantic-map} \vspace{4pt} \end{figure*} \subsubsection{Comparison on Visual Genome 500} Microsoft-COCO contains only 80 categories, but current works \cite{zhang2019few,chen2020knowledge} for few-shot learning may contain thousands of categories, which is more realistic. To remedy this issue, we utilize Visual Genome 500 as a new evaluation benchmark. Because LaSO is the previous best-performing method, we followed the code \footnote{https://github.com/leokarlin/LaSO} released by the authors to train the LaSO model on the VG-500 dataset. For a fair comparison, we used ResNet-101 as the backbone network for both methods. The results are listed in Table \ref{table:result-fs-vg}. Our framework clearly outperform the LaSO by a sizable margin. Specifically, our framework achieves mAPs of 20.7\% and 26.1\% on the 1-shot and 5-shot settings, outperforming LaSO by 4.1\% and 4.3\%, respectively. \begin{table}[ht] \centering \begin{tabular}{c|cc} \hline \centering Methods & 1-shot & 5-shot \\ \hline \hline LaSO \cite{alfassy2019laso} & 16.6 & 21.8 \\ \hline Ours & 20.7 & 26.1\\ \hline \end{tabular} \vspace{2pt} \caption{Comparison of the mAP (in \%) on 1-shot and 5-shot settings on the VG-500 dataset. We present the results of 1-shot and 5-shot settings.} \label{table:result-fs-vg} \end{table} \subsection{Ablative study} The proposed framework builds on ResNet-101 \cite{he2016deep}; thus, we first compare it with this baseline to analyze the contributions of knowledge-guided graph routing (KGGR). Specifically, we simply replace the last fully connected layer of ResNet-101 with a 2,048-to-$C$ fully connected layer and use $C$ sigmoid functions to predict the probability of each category. The training and test settings are the same as those described in Section \ref{sec:mlr}. We conducted the experiments on the Microsoft-COCO dataset and present the results in Table \ref{table:result-ablation-mlr}. As shown, the mAP drops from 84.3\% to 80.3\%. To more deeply analyze the performance comparisons, we further present the AP of each category in Figure \ref{fig:ap-comparison}, which shows that the AP improvement by our framework is more evident for the categories that are more difficult to recognize (i.e., the categories for which the baseline obtains lower AP). For example, for categories such as giraffe and zebra, the baseline obtains a very high AP; thus, our framework achieves only slight improvements. In contrast, for more difficult categories such as toaster and hair drier, our framework improves the AP by a sizable margin---27.3\% and 38.3\% improvements for toaster and hair drier, respectively. We also present a comparison with the baseline ResNet-101 on the multi-label few-shot learning task in Table \ref{table:result-ablation-mlfsl}. As shown, our method achieves evident improvements over the baseline (i.e., improving the mAP by 8.8\% and 7.0\% on the 1-shot and 5-shot settings, respectively). \begin{table}[h] \centering \begin{tabular}{c|c} \hline \centering Methods & mAP \\ \hline \hline ResNet-101 \cite{he2016deep} &80.3\\ \hline Ours w/o KEFP & 80.9\\ Ours w/o SGA & 82.2\\ Ours w/o GFP & 80.6\\ Ours w/o GSP & 83.8 \\ Ours & 84.3 \\ \hline \end{tabular} \vspace{2pt} \caption{Comparison of mAP (in \%) of our framework (Ours), our framework without the graph feature propagation module (Ours w/o GFP), our framework without the graph semantic propagation module (Ours w/o GSP), our framework without semantically guided attention (Ours w/o SGA), our framework without knowledge-embedded feature propagation (Ours w/o KEFP), and the baseline ResNet-101 from the multi-label image recognition task on the Microsoft-COCO dataset.} \label{table:result-ablation-mlr} \end{table} \begin{table}[h] \centering \begin{tabular}{c|c|c} \hline \centering Methods & 1-shot & 5-shot \\ \hline \hline ResNet-101 \cite{he2016deep} & 43.5 & 56.5\\ \hline Ours w/o GFP & 44.1 & 56.0 \\ Ours w/o GSP & 50.4 & 61.0 \\ Ours & 52.3 & 63.5 \\ \hline \end{tabular} \vspace{2pt} \caption{Comparison of mAP (in \%) of our framework (Ours), our framework without the graph feature propagation module (Ours w/o GFP), our framework without the graph semantic propagation module (Ours w/o GSP), and the baseline ResNet-101 from the multi-label few-shot task on the Microsoft-COCO dataset.} \label{table:result-ablation-mlfsl} \end{table} The foregoing comparisons verify the contribution of the proposed KGGR as a whole. Actually, the KGGR contains two graph propagation modules that conduct information interactions to learn features and classifiers. In the following, we further conduct ablation experiments to analyze the true contribution of each module. \begin{figure}[!t] \centering \includegraphics[width=0.90\linewidth]{./baseline_feature_map.pdf} \caption{Several examples of the feature maps generated by the baseline ResNet-101. The samples are the same as those in Figure \ref{fig:semantic-map} for direct comparisons.} \label{fig:visualization-baseline} \end{figure} \subsubsection{Contribution of graph feature propagation} Graph feature propagation can help learn the contextualized feature vectors for each category, and it is the key module in this work. Here, we first remove this module and directly use $\mathbf{f}$ for classification. We find that the resulting model suffers from an obvious performance drop (i.e., the mAP decreased from 84.3\% to 80.6\%). Moreover, this module uses a semantically guided attention mechanism that decouples the image into C category-specific feature vectors and a knowledge-embedded feature propagation that explores feature interactions to learn contextualized features. We also analyze these two components in the following. 1) To analyze the semantically guided attention mechanism, we remove it and directly use $\mathbf{f}$ to initialize the graph nodes. As shown in Table \ref{table:result-ablation-mlfsl}, this model achieve a mAP of 80.9\%. It performs slightly better than the baseline method, because it does not incur any additional information but does increase the model complexity. As discussed above, this component can learn semantic-specific feature maps that focus on corresponding semantic regions via semantically guided attention mechanism. We present some examples in Figure \ref{fig:semantic-map}. From left to right in each row are the input images, the semantic maps corresponding to categories with the top $k (k=4,5)$ highest confidences, and the predicted label distribution. These results show that our semantically guided attention mechanism is able to highlight the semantic regions well when the objects of the corresponding categories exist. Taking the first sample as an example, it contains person, dog, sport ball, and baseball glove objects, which highlight the corresponding regions of these semantic objects, respectively. Similar phenomena can be observed for the other examples. To clearly verify that it is the semantically guided attention mechanism that brings about this appealing characteristic, we further visualize the feature maps generated by the baseline ResNet-101. As shown in Figure \ref{fig:visualization-baseline}, it tends to highlight the most salient regions, but neglect some regions that are less salient but equally important, e.g., the dog in the first example and the chair in the seventh example. 2) To validate the knowledge-embedded feature propagation component, we remove the graph propagation network; thus, $\mathbf{o}_c=\mathbf{f}_c$. As shown in Table \ref{table:result-ablation-mlr}, the mAP is 82.2\%, a decrease in the mAP of 2.1\%. We also analyze the effect of this module on the multi-label few-shot task and present the result with and without the graph feature propagation component in Table \ref{table:result-ablation-mlfsl}. The mAP falls from 52.3\% and 63.5\% to 44.1\% and 56.0\% on the 1-shot and 5-shot settings, respectively. \subsubsection{Contribution of graph semantic propagation} Graph semantic propagation helps transfer the information of correlated categories to better learn the classifiers. To validate its contribution, we remove this component and use $C$ fully connected layers that directly take the corresponding contextualized feature vector as input to predict the probability of the corresponding category. As shown in Table \ref{table:result-ablation-mlr}, the mAP decreases from 84.3\% to 83.8\% on Microsoft COCO. We found a similar phenomenon for the multi-label few-shot task, where the mAP decreases from 52.3\% and 63.5\% to 50.4\% and 61.0\% on the 1-shot and 5-shot settings, respectively. \subsubsection{Analysis of different losses} In this work, we learn a contextualized feature vector for each category and adopt the logistic regressor to predict the existence probability for each category. We follow recent multi-label works \cite{chen2019multi,Tokmakov2019ICCV} to train the models with the cross-entropy loss. Earlier works \cite{wei2016hcp,chen2018recurrent} has also used the euclidean loss between the output score and normalized ground truth to train the model. In this part, we conduct an experiment that follows works \cite{wei2016hcp,chen2018recurrent} to replace the loss with Euclidean loss to analyze the effect of different losses. As shown in Table \ref{table:result-ablation-loss-mlr}, the model trained with the entropy loss achieves much better performance. \begin{table}[h] \centering \begin{tabular}{c|c} \hline \centering Methods & mAP \\ \hline \hline Ours EU & 79.2 \\ Ours CE& 84.3 \\ \hline \end{tabular} \vspace{2pt} \caption{Comparison of mAP (in \%) of our framework with the cross entropy (Ours CE) and euclidean (Ours EU) losses on the Microsoft-COCO dataset.} \label{table:result-ablation-loss-mlr} \end{table} \section{Conclusion} In this work, we explore integrating prior knowledge of label correlations into deep neural networks to guide learning both feature and classifier representations. To achieve this end, we propose a novel knowledge-guided graph routing (KGGR) framework that consists of two graph propagation mechanisms. The first propagation mechanism introduces category semantic to guide learning semantic-specific features and exploit a graph neural network to explore feature interaction to learn contextualized feature representation for each category. The second propagation mechanism exploits another graph neural network that takes initial classifier weight as input and transfers classifier information through different categories to help better learn the classifiers. We apply the proposed framework to both multi-label image recognition and multi-label few-shot learning tasks on the Microsoft-COCO, Pascal VOC 2007 \& 2012, and Visual Genome datasets, and demonstrate its effectiveness over all existing leading methods on both two tasks. \ifCLASSOPTIONcaptionsoff \newpage \fi { \bibliographystyle{IEEEtran}
{'timestamp': '2020-09-22T02:17:28', 'yymm': '2009', 'arxiv_id': '2009.09450', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09450'}
arxiv
\section{Dataset} We train and evaluate Longformer on MS MARCO document ranking dataset. It consists of more than 370k queries, 3.2 million documents, and the corresponding relevance labels for query-document pairs. Relevance labels are transferred from the MS MARCO passage ranking task, by mapping a positive passage to a document containing the passage, for each query. This is done under an assumption that the document that contains a relevant passage is a relevant document. Additional information about the dataset is present in Table \ref{tbl:marco}. \begin{table}[] \centering \begin{tabular}{llr} \toprule \# documents & & 3.2M \\ \midrule \multirow{3}{*}{\# queries} & train & 367,013 \\ & dev & 5,193 \\ & test & 5,793 \\ \bottomrule \\ \end{tabular} \caption{Number of documents in MS MARCO corpus and the number of queries in train, dev, and test set.} \label{tbl:marco} \end{table} The document ranking task features two tasks: \begin{description} \item[Document Re-Ranking] Given a candidate top 100 documents for each query, as retrieved by BM25, re-rank the documents by relevance. \item[Document Full Ranking] Given a corpus of 3.2m documents generate a candidate top 100 documents for each query, sorted by relevance. \end{description} We participate in the document re-ranking task, where we use Longformer to assign relevance to the 100 documents retrieved by BM25, which are provided by the organizers. \section{Introduction} Document ranking is central problems in information retrieval (IR). Given a query, the task is to rank the documents of some collection so that the most relevant ones appear on top of the list. Recently, neural ranking models have shown superior performance compare to the traditional IR methods. Given the much higher computational need of neural models, the two step retrieval process is widely adapted. First, a traditional IR method, like BM25 or query likelihood, retrieves top $k$ documents from a given collection. Then, a computationaly expensive neural model re-ranks the top $k$ documents from the initial retrieval step. A number of neural models for ranking has been proposed in recent years. Some of them are: DRMM \cite{guo}, KNRM \cite{xiong}, Co-PACRR \cite{hui}, DUET \cite{mitra}, and Conformer-Kernel with QTI \cite{conformer}. With a combination of new generation of neural models, namely the transformer architecture, and large-scale datasets, neural rankers arose as superior to traditional methods, which was not possible before \cite{lin}. Most notable model from the transformers family is probably BERT \cite{bert}, which has been very successfully applied to passage ranking \cite{marco_bert}, outperforming state-of-the-art by a large margin. The largest dataset for the document ranking task is MS MARCO (Microsoft Machine Reading Comprehension). Transformer architecture, namely BERT, has already proven effective on the MS MARCO passage ranking task. However, the documents are much longer than the passages, making the task of document ranking more challenging. To address the issue of increased length of the documents, we employ Longformer \cite{longformer} -- a BERT-like model for long documents. Longformer has an adjusted attention mechanism that combines local, BERT-like windowed attention, with a global attention, allowing the model to attend over much longer sequences than standard self-attention. Compared to BERT that typicaly processes up to $512$ tokens at a time, Longformer is pre-trained on documents with length of $4096$ tokens. We reach MRR@100 of $0.329$ and $0.305$ on the official dev and the test sets, respectively. \section{Experiments} We train Longformer \cite{longformer} to estimate relevance of a query-document pair. The training setting is formulated as in \cite{marco_bert}. We feed the query as sentence A and the document as sentence B to the tokenizer, which yields the following input to the Longformer\footnote{Tokens <s> and </s> are equivalent to the [CLS] and [SEP] tokens in BERT tokenizer, respectively.}: \begingroup \setlength{\thickmuskip}{0mu} \begin{equation*} <s>\ query\ </s>\ document\ </s> \end{equation*} \endgroup We truncate the document such that the sequence of the concatenated query, document, and the seperator tokens does not exceed $4096$ tokens. After passing the sequence through the Longformer model, the\begingroup \setlength{\thickmuskip}{0mu} <s> \endgroup vector is given as input to a classifier head, consisting of two linear layers with dropout and a non-linear function. The classifier outputs a two-dimensional vector, where the first dimension indicates probability of a document not being relevant to the query, while the second indicates relevance probability. For a given query, we rank the candidate documents based on the relevance probability, which is computed independently for each document. We fine-tune the pre-trained Longformer with a cross-entropy loss, using the following hyperparameters: batch size of $128$, Adam optimizer with the initial learning rate of $3\times10^{-5}$, a linear scheduler with warmup for $2500$ steps, trained for 150k iterations. Further hyperparameter tuning might yield better results. For training, we also reduce the positive to negative document ratio to 1:10, from the given 1:100 (as each query is given top 100 documents extracted by BM25 by the organizers). We use PytorchLightning \cite{pl} for our training setting implementation and HuggingFace's Transformers package \cite{hug} for Longformer implementation. \section{Results} The results on the MS MARCO document re-ranking task on the dev and the test set are presented in Table \ref{tab:results}. The official metric is mean reciprocal rank (MRR@100). Other submissions and approaches can be found on the official leaderboard\footnote{https://microsoft.github.io/msmarco/\#docranking}. \begin{table}[] \centering \begin{tabular}{lrr} \toprule & dev & test \\ \midrule Indri Query Likelihood & & 0.192 \\ Conformer-kernel with QTI (NDRM3) & & 0.293 \\ Conformer-kernel with QTI (NDRM1) & & 0.307 \\ Longformer & 0.336 & 0.305 \\ \bottomrule \\ \end{tabular} \caption{MRR@100 of the Longformer and the official baselines provided by the organizers. \cite{conformer}} \label{tab:results} \end{table}
{'timestamp': '2020-09-22T02:15:27', 'yymm': '2009', 'arxiv_id': '2009.09392', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09392'}
arxiv
\section{ Bias Subspace Construction as PCA \label{apdx:pca}} \begin{repproposition}{prop1} Suppose $|D_n| = 2$ for all $n$. Then we have \begin{equation} {\bm{C}} = \frac{1}{2} \sum_{i=1}^{2N} {\bm{W}}_{i,\cdot}^{\top}\,{\bm{W}}_{i,\cdot} \end{equation} where we define the following design matrix \begin{align}\label{eq:design-matrix} {\bm{W}}_{i,\cdot} =\left( {\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right)^{\top} \nonumber \end{align} \end{repproposition} \begin{proof} \begin{align} {\bm{C}} &= \sum_{n=1}^N \frac{1}{|D_n|} \sum_{i \in D_n}\left( {\vec{w}}_i - {\vec{\mu}}_{D_n} \right)\left({\vec{w}}_i - {\vec{\mu}}_{D_n} \right)^{\top} \\ &= \frac{1}{2} \sum_{n=1}^N \sum_{i \in D_n}\left( {\vec{w}}_i - {\vec{\mu}}_{D_n} \right)\left({\vec{w}}_i - {\vec{\mu}}_{D_n} \right)^{\top} \\ &= \frac{1}{2} \sum_{i=1}^{2N} \left( {\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right)\left({\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right)^{\top} \\ &=\frac{1}{2} \sum_{i=1}^{2N} {\bm{W}}_{i,\cdot}^{\top}\,{\bm{W}}_{i,\cdot} \end{align} where ${\bm{W}}_{i,\cdot} \in \mathbb{R}^{2N \times d}$ is defined as above. \end{proof} Next, we show that the matrix is centered, which is a requirement for PCA. \begin{repproposition}{prop2} The matrix ${\bm{W}}$ is centered. \end{repproposition} \begin{proof} \begin{align} \frac{1}{2} \sum_{i=1}^{2N} {\bm{W}}_{i,\cdot}^{\top} &= \frac{1}{2} \sum_{i=1}^{2N} \left( {\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right) \\ &=\frac{1}{2} \sum_{n=1}^{N} \sum_{i \in \mathcal{D}_n} \left( {\vec{w}}_{i} - {\vec{\mu}}_{D_n} \right) \\ &=\frac{1}{2} \sum_{n=1}^{N} \left( \sum_{i \in \mathcal{D}_n} {\vec{w}}_{i} - 2 {\vec{\mu}}_{D_n} \right) \\ &=\frac{1}{2} \sum_{n=1}^{N} \left( 2 {\vec{\mu}}_{D_n} - 2 {\vec{\mu}}_{D_n} \right) = 0 \end{align} \end{proof} \begin{table*}[t!] \begin{tabular}{@{}llllcllllll@{}} \toprule \multirow{2}{*}{Targets} & \multicolumn{2}{l}{Original} & \multicolumn{2}{l}{PCA} & \multicolumn{2}{l}{KPCA (poly-2)} & \multicolumn{2}{l}{KPCA (poly-3)} & \multicolumn{2}{l}{KPCPA (poly-4)} \\ \cmidrule(l){2-11} & d & p & d & p & d & p & d & p & d & p \\ \midrule \multicolumn{11}{l}{ \hspace{3.5cm} Google News Word2Vec \cite{mikolov2013efficient} } \\ \midrule Career , Family & 1.622 & 0.000 & 1.327 & 0.001 & 1.320 & 0.004 & 1.321 & 0.001 & 1.312 & 0.002 \\ Math, Arts & 0.998 & 0.017 & -0.540 & 0.859 & -0.755 & 0.927 & -0.755 & 0.933 & -0.754 & 0.932 \\ Science , Arts & 1.159 & 0.005 & 0.288 & 0.281 & 0.271 & 0.312 & 0.272 & 0.305 & 0.272 & 305 \\ \midrule \multicolumn{11}{l}{ \hspace{5cm} GloVe \cite{glove}} \\ \midrule Career , Family & 1.749 & 0.000 & 1.160 & 0.007 & 1.166 & 0.000 & 1.166 & 0.009 & 1.667 & 0.005 \\ Math, Arts & 1.162 & 0.007 & 0.144 & 0.389 & 0.096 & 0.429 & 0.097 & 0.421 & 0.097 & 0.432 \\ Science , Arts & 1.281 & 0.008 & -1.074 & 0.985 & -1.113 & 0.995 & -1.114 & 0.994 & -1.114 & 0.992 \\ \bottomrule \end{tabular} \caption{Results for polynomial Kernel Experiments on Glove and Google News embeddings.} \label{tab:polyglove} \end{table*} \section{Neutralizing in feature space: Metric correction \label{apdx:neut}} \begin{repproposition}{prop:neut} The corrected inner product in the feature space for two neutralized words ${\vec{z}}, {\vec{w}}$ is given by \begin{align} \langle { {\bm{\Phi}}_{\mathrm{ntr}}}&({\vec{z}}),{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}) \rangle \\ &=\kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{z}})\,\beta_k({\vec{w}}) \label{eq:neutrkhs} \end{align} \end{repproposition} \begin{proof} \begin{align} \Big<&{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{z}}), { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}) \Big> = \nonumber\\ &\Big<{\bm{\Phi}}({\vec{z}})- \P_K {\bm{\Phi}}({\vec{z}}),\: {\bm{\Phi}}({\vec{w}})- \P_K {\bm{\Phi}}({\vec{w}})\Big> \nonumber\\ &=\kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\sum_{i=1}^{N}\alpha_i^{k} \kappa({\vec{z}}, {\vec{w}}_{i})\nonumber \\ &- \sum_{k=1}^{K}\beta_k({\vec{z}})\sum_{i=1}^{N}\alpha_i^{k} \kappa({\vec{w}}, {\vec{w}}_{i})+\sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}) \nonumber\\ &= \kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\sum_{i=1}^{N}\alpha_i^{k} \kappa({\vec{z}}, {\vec{w}}_{i}) \nonumber\\ &= \kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}), \label{eq:testsim1} \end{align} where $\beta_k({\vec{w}})=\bm{V}_{k}^{\top} {\bm{\Phi}}({\vec{w}}) = \sum_{i=1}^N\alpha_{i}^{k}\,\kappa({\vec{w}}, {\vec{w}}_i)$ as per \citet{scholkopf1998nonlinear}. \end{proof} \section{Equalizing in feature space: Metric correction\label{apdx:amonproof}} \begin{repproposition}{prop:amon} For a given neutral word ${\vec{w}}$ and a word in an equality set ${\bm{e}} \in E$ the inner product $\left<{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), {\bm{\theta}}({\bm{e}})\right>$ is invariant across members in the equality set $E$. \end{repproposition} \begin{proof} \begin{align} \langle & { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), {\bm{\theta}}({\bm{e}}) \rangle = \langle { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), {\vec{\nu}}^{{\bm{\Phi}}} \rangle \\ &= \frac{1}{|E|} \sum_{i \in E} \langle{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), \P_K^{\perp}{\bm{\Phi}}({\vec{w}}_i) \rangle \nonumber \\ &= \frac{1}{|E|} \sum_{i \in E}\left(\kappa({\vec{w}}, {\vec{w}}_i) - \sum_{k=1}^K \beta_{k}({\vec{w}})\beta_{k}({\vec{w}}_i) \right) \nonumber \end{align} \end{proof} \begin{repproposition}{prep0} For any two vectors in the observed space ${\vec{w}}, {\vec{z}}$ and their corresponding representations in feature space ${\bm{\Phi}}({\vec{w}}), {\bm{\Phi}}({\vec{z}})$ the inner product $\langle {\bm{\Phi}}({\vec{w}}) - \P_k{\bm{\Phi}}({\vec{w}}), \P_k{\bm{\Phi}}({\vec{z}}) \rangle$ is $0$. \end{repproposition} \begin{proof} \begin{align} \langle {\bm{\Phi}}&({\vec{w}}) - \P_K{\bm{\Phi}}({\vec{w}}), \P_K{\bm{\Phi}}({\bm{e}})\rangle \\ \nonumber\\ &=\langle{\bm{\Phi}}({\vec{w}}),\P_K{\bm{\Phi}}({\vec{z}})\rangle - \langle \P_k{\bm{\Phi}}({\vec{w}}),\P_K{\bm{\Phi}}({\vec{z}}) \rangle \nonumber \\ &= \sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}) \nonumber \\ &= 0 \nonumber \end{align} \end{proof} \section{Polynomial Kernel Results}\label{apdx:poly} For experimental completeness we provide direct bias experiments on WEAT using a range of polynomial Kernels. Results can be found on \cref{tab:polyglove}. The results for the polynomial Kernels agree with the conclusions derived from the non-linear Kernels in the main Experiments. \bibliographystyle{acl_natbib} \section{Introduction} Pre-trained word representations are a necessity for strong performance on modern NLP tasks. These embeddings now serve as input to neural methods \cite{goldberg}, which recently have become the standard models in the field. However, because these representations are constructed from large, human-created corpora, they naturally contain societal biases encoded in that data; gender bias is among the most well studied of these biases \cite{caliskan2017semantics}. Both a-contextual word embeddings \cite{mikolov2013efficient, glove} and contextual word embeddings \cite{elmo, bert} have been shown to encode gender bias \cite{bolukbasi2016man,caliskan2017semantics,zhao2019gender, may2019measuring,karve2019conceptor}. More importantly, the bias in those embeddings has been shown to influence models for downstream tasks where they are used as input, e.g. coreference resolution \citep{CorefRes,CorefRes2}. \newcite{bolukbasi2016man} present one of the first methods for detecting and mitigating gender bias in word embeddings. They provide a novel linear-algebraic approach that post-processes word embeddings in order to partially remove gender bias. Under their evaluation, they find they can nearly perfectly remove bias in an analogical reasoning task. However, subsequent work \cite{gonen-goldberg-2019-lipstick-pig,hall-maudslay-etal-2019-name} has indicated that gender bias still lingers in the embeddings, despite \newcite{bolukbasi2016man}'s strong experimental results. In the development of their method, \newcite{bolukbasi2016man} make a critical and unstated assumption: Gender bias forms a linear subspace of word embedding space. In mathematics, linearity is a strong assumption and there is no reason \textit{a-priori} why one should expect complex and nuanced societal phenomena, such as gender bias, should be represented by a linear subspace.\looseness=-1 In this work, we present the first non-linear gender bias mitigation technique for a-contextual word embeddings. In doing so, we directly test the linearity assumption made by \newcite{bolukbasi2016man}. Our method is based on the insight that \newcite{bolukbasi2016man}'s method bears a close resemblance to principal component analysis (PCA). Just as one can kernelize PCA \cite{scholkopf1997kernel}, we show that one can kernelize the method of \newcite{bolukbasi2016man}. Due to the kernelization, the bias is removed in the feature space, rather in the word embedding space. Thus, we also explore pre-image techniques \cite{mika1999kernel} to project the bias-mitigated vectors back into $\mathbb{R}^d$. As previously noted, there are now multiple bias removal methodologies \citep{CorefRes2,zhao2019gender, may2019measuring} that have succeed the method by \citet{bolukbasi2016man}. Furthermore \citet{gonen-goldberg-2019-lipstick-pig} point out multiple flaws in \citet{bolukbasi2016man}'s bias mitigation technique and the aforementioned methods. Nonetheless we believe that this method has received sufficient attention from the community such that research into its properties is both interesting and useful. We test our non-linear gender bias technique in several experiments. First, we consider the Word Embedding Association Test \cite[WEAT;][]{caliskan2017semantics}; we notice that across five non-linear kernels and convex combinations thereof, there is seemingly no significant difference between the non-linear bias mitigation technique and the linear one. Secondly, we consider the professions task \cite{bolukbasi2016man,gonen-goldberg-2019-lipstick-pig} that measures how word embeddings representing different professions are potentially gender-stereotyped. Again, as with the WEAT evaluation, we find that our non-linear bias mitigation technique performs on par with the linear method. We also consider whether the non-linear gender mitigation technique removes indirect bias from the vectors \cite{gonen-goldberg-2019-lipstick-pig}; yet again, we find the non-linear method performs on par with the linear methods. As a final evaluation, we evaluate whether non-linear bias mitigation hurts semantic performance. On Simlex-999 \cite{hill2015simlex}, we show that similarity estimates between the vectors remain on par with the linear methods. We conclude that much of the gender bias in word embeddings is indeed captured by a linear subspace, answering this paper's titular question. \section{Bias as a Linear Subspace} The first step of \newcite{bolukbasi2016man}'s technique is the discovery of a subspace $B \subset \mathbb{R}^d$ that captures most of the gender bias. Specifically, they stipulate that this space is linear. Given word embeddings that live in $\mathbb{R}^d$, they provide a spectral method for isolating the bias subspace. In this section, we review their approach and show how it is equivalent to principal component analysis (PCA) on a specific design (input) matrix. Then, we introduce and discuss the implicit assumption made by their work; we term this assumption the \defn{linear subspace hypothesis} and test it in \cref{sec:kpca}. \begin{hypothesis}\label{eq:hypothesis} Gender bias in word embeddings may be represented as a linear subspace. \end{hypothesis} \subsection{Construction of a Bias Subspace}\label{sec:construction} We will assume the existence of a fixed and finite vocabulary $V$, each element of which is a word ${\vec{w}}_i$. The hard-debiasing approach takes a set of \mathcheck{$N$} sets \mathcheck{$\mathcal{D} = \{D_n\}_{n=1}^N$} as input. Each set \mathcheck{$D_n$} contains words that are considered roughly semantically equivalent modulo their gender; \newcite{bolukbasi2016man} call the \mathcheck{$D_n$} \defn{defining sets}. For example, \mathcheck{$\{\word{man}, \word{woman}\}$} and \mathcheck{$\{\word{he}, \word{she}\}$} form two such defining sets. We identify each word with a unique integer \mathcheck{$i$} for the sake of our indexing notation; indeed, we exclusively reserve the index \mathcheck{$i$} for words. We additionally introduce the function $f : [|V|] \rightarrow [N]$ that maps an individual word to its defining set. In general, the defining sets are not limited to a cardinality of two, but in practice \citet{bolukbasi2016man} exclusively employ defining sets with a cardinality of two in their experiments. Using the sets \mathcheck{$D_n$}, \citet{bolukbasi2016man} define the matrix \mathcheck{${\bm{C}}$}\looseness=-1 \mathcheck{\begin{equation} {\bm{C}} := \sum_{n=1}^N \frac{1}{|D_n|} \sum_{i \in D_n}\left( {\vec{w}}_i - {\vec{\mu}}_{D_n} \right)\left({\vec{w}}_i - {\vec{\mu}}_{D_n} \right)^{\top} \nonumber \end{equation}} where we write \mathcheck{${\vec{w}}_i$} for the \mathcheck{$i^\text{th}$} word's embedding and the empirical mean vector \mathcheck{${\vec{\mu}}_{D_n}$} is defined as \mathcheck{\begin{equation} {\vec{\mu}}_{D_n} := \frac{1}{|D_n|} \sum_{i\in D_n} {\vec{w}}_i \nonumber \end{equation}} \newcite{bolukbasi2016man} then extract a bias subspace \mathcheck{$B$} using the singular value decomposition (SVD). Specifically, they define the bias subspace to be the space spanned by the first $k$ rows of ${\bm{V}}$ where \begin{equation}\label{eq:svd} {\bm{V}} {\bm{S}} {\bm{V}}^{\top} = \SVD({\bm{C}}) \end{equation} Since ${\bm{C}}$ is symmetric and positive semi-definite, the SVD is equivalent to an eigendecomposition as our notation in Equation \ref{eq:svd} shows. We assume the rows of ${\bm{V}}$, the eigenvectors of ${\bm{C}}$, are ordered by the magnitude of their corresponding eigenvalues. \subsection{Bias Subspace Construction as PCA}\label{sec:pca} As briefly noted by \newcite{bolukbasi2016man}, this can thus be cast as performing principal component analysis (PCA) on a recentered input matrix. We prove this assertion more formally. We first prove that the matrix \mathcheck{${\bm{C}}$} may be written as an empirical covariance matrix. \begin{proposition}\label{prop1} Suppose \mathcheck{$|D_n| = 2$} for all \mathcheck{$n$}. Then we have \mathcheck{\begin{equation} {\bm{C}} = \frac{1}{2} \sum_{i=1}^{2N} {\bm{W}}_{i,\cdot}^{\top}\,{\bm{W}}_{i,\cdot} \end{equation}} where we define the design matrix \mathcheck{${\bm{W}}$} as: \mathcheck{\begin{align}\label{eq:design-matrix} {\bm{W}}_{i,\cdot} =\left( {\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right)^{\top} \end{align}} \end{proposition} \begin{proof} \mathcheck{\begin{align*} {\bm{C}} &= \sum_{n=1}^N \frac{1}{|D_n|} \sum_{i \in D_n}\left( {\vec{w}}_i - {\vec{\mu}}_{D_n} \right)\left({\vec{w}}_i - {\vec{\mu}}_{D_n} \right)^{\top} \\ &= \frac{1}{2} \sum_{n=1}^N \sum_{i \in D_n}\left( {\vec{w}}_i - {\vec{\mu}}_{D_n} \right)\left({\vec{w}}_i - {\vec{\mu}}_{D_n} \right)^{\top} \\ &= \frac{1}{2} \sum_{i=1}^{2N} \left( {\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right)\left({\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right)^{\top} \\ &=\frac{1}{2} \sum_{i=1}^{2N} {\bm{W}}_{i,\cdot}^{\top}\,{\bm{W}}_{i,\cdot} \end{align*}} where \mathcheck{${\bm{W}}_{i,\cdot} \in \mathbb{R}^{2N \times d}$} is defined as above. \end{proof} Next, we show that the matrix is centered, which is a requirement for PCA. \begin{proposition}\label{prop2} The matrix \mathcheck{${\bm{W}}$} is row-wise centered. \end{proposition} \begin{proof} \mathcheck{\begin{align*} \frac{1}{2} \sum_{i=1}^{2N} {\bm{W}}_{i,\cdot}^{\top} &= \frac{1}{2} \sum_{i=1}^{2N} \left( {\vec{w}}_i - {\vec{\mu}}_{D_{f(i)}} \right) \\ &=\frac{1}{2} \sum_{n=1}^{N} \sum_{i \in \mathcal{D}_n} \left( {\vec{w}}_{i} - {\vec{\mu}}_{D_n} \right) \\ &=\frac{1}{2} \sum_{n=1}^{N} \left( - 2 {\vec{\mu}}_{D_n} + \sum_{i \in \mathcal{D}_n} {\vec{w}}_{i} \right) \\ &=\frac{1}{2} \sum_{n=1}^{N} \left( 2 {\vec{\mu}}_{D_n} - 2 {\vec{\mu}}_{D_n} \right) = 0 \end{align*}} \end{proof} \begin{remark} The method of \newcite{bolukbasi2016man} may be considered principal component analysis performed on the matrix \mathcheck{$2 {\bm{C}}$}. \end{remark} \begin{proof} As the algebra in \cref{prop1} and \cref{prop2} show we may formulate the problem as an SVD on a mean-centered covariance matrix. One view of PCA is performing matrix factorization on such a matrix. \end{proof} \section{\newcite{bolukbasi2016man}} In this section, we review the bias mitigation technique introduced by \newcite{bolukbasi2016man}. When possible, we take care to reformulate their method in terms of matrix notation. They introduce a two-step process that \defn{neutralizes} and \defn{equalizes} the vectors to mitigate gender bias in the embeddings. The underlying assumption of their method is that there exists a linear subspace $B \subset \mathbb{R}^d$ that captures most of the gender bias. \subsection{Neutralize\label{sub:neut}} After finding the linear bias subspace \mathcheck{$B$}, the gist behind \newcite{bolukbasi2016man}'s approach is based on elementary linear algebra. We may decompose any word vector \mathcheck{${\vec{w}}$} as the sum of its orthogonal projection onto the bias subspace (range of the projection) and its orthogonal projection onto the complement of the bias subspace (null space of the projection), i.e. \mathcheck{\begin{equation} {\vec{w}} = {\vec{w}}_{B} + {\vec{w}}_{\perp B} \end{equation}} We may then re-embed every vector as \mathcheck{\begin{equation} {\vec{w}}_{\mathrm{ntr}} := {\vec{w}} - {\vec{w}}_B = {\vec{w}}_{\perp B} \end{equation}} We may re-write this in terms of matrix notation in the following manner. Let \mathcheck{$\{{\vec{v}}_k\}_{k=1}^K$} be an orthogonal basis for the linear bias subspace \mathcheck{$B$}. This may be found by taking the eigenvectors \mathcheck{${\bm{C}}$} that correspond to the top-$K$ eigenvalues with largest magnitude. Then, we define the projection matrix onto the bias subspace as \mathcheck{${\bm{P}}_K = \sum_{k=1}^K {\vec{v}}_k {\vec{v}}_k^{\top}$} it follows that the matrix \mathcheck{$({\bm{I}} - {\bm{P}}_K)$} is a projection matrix on the complement of \mathcheck{$B$}. We can then write the neutralize step using matrices \mathcheck{\begin{equation} {\vec{w}}_{\mathrm{ntr}} := ({\bm{I}} - {\bm{P}}_K)\,{\vec{w}} \label{neutralise} \end{equation}} The matrix formulation of the neutralize step offers a cleaner presentation of what the neutralize step does: it projects the vectors onto the orthogonal complement of the bias subspace. \subsection{Equalize} \newcite{bolukbasi2016man} decompose words into two classes. The neutral words which undergo neutralization as explained above, and the gendered words, some of which receive the equalizing treatment. Given a set of \defn{equality sets} \mathcheck{$\mathcal{E} = \{E_1, \ldots, E_L\}$} which we can see as a greater extension of the defining sets \mathcheck{$\mathcal{D}$}, i.e. \mathcheck{$E_i =\{\word{guy}, \word{gal}\}$}, \citet{bolukbasi2016man} then proceed to decompose each of the words \mathcheck{${\vec{w}} \in \mathcal{E}$} into their gendered and neutral counterparts, setting their neutral component to a constant (the mean of the equality set) and the gendered component to its mean-centered projection into the gendered subspace: \mathcheck{\begin{equation} {\vec{w}}_{\mathrm{eq}} := {\vec{\nu}} + Z\,({\vec{w}}_{B} - {\vec{\mu}}_{B}) \label{amon} \end{equation}} where we define the following quantities: \mathcheck{\begin{align} Z := \frac{\sqrt{1 - ||{\vec{\nu}}||_2^2}}{|| {\vec{w}}_{B} - {\vec{\mu}}_{B} ||_2}\, \nonumber\\ {\vec{\mu}} := \frac{1}{|E_i|} \sum_{{\vec{w}} \in E_i} {\vec{w}} \nonumber \\ {\vec{\nu}} := ({\bm{I}} - {\bm{P}}_K)\,{\vec{\mu}} \nonumber \end{align}} the ``normalizer'' \mathcheck{$Z$} ensures the vector is of unit length. This fact is left unexplained in the original work, but \newcite{hall-maudslay-etal-2019-name} provide a proof in their appendix. \section{Bias as a Non-Linear Subspace \label{sec:kpca}} We generalize the framework presented in \citet{bolukbasi2016man} and cast it to a non-linear setting by exploiting its relationship to PCA. Thus, the natural extension of \citet{bolukbasi2016man} is to kernelize it analogously to \citet{scholkopf1997kernel}, which is the kernelized generalization of PCA. Our approach preserves all the desirable formal properties presented in the linear method of \newcite{bolukbasi2016man}. \subsection{Adapting the Design Matrix} The idea behind our non-linear bias mitigation technique is based on kernel PCA \cite{scholkopf1998nonlinear}. In short, the idea is to map the original word embeddings \mathcheck{${\vec{w}}_i \in \mathbb{R}^{d}$} to a higher-dimensional space \mathcheck{${\mathcal{H}}$} via a function \mathcheck{${\bm{\Phi}}: \mathbb{R}^{d} \rightarrow {\mathcal{H}}$}. We will consider cases where \mathcheck{${\mathcal{H}}$} is a reproducing kernel Hilbert space (RKHS) with reproducing kernel \mathcheck{$\kappa({\vec{w}}_{i}, {\vec{w}}_{j}) = \langle {\bm{\Phi}}({\vec{w}}_{i}) , {\bm{\Phi}}({\vec{w}}_{j}) \rangle$} where the notation \mathcheck{$\langle \cdot, \cdot \rangle$} refers to an inner product in the RKHS. Traditionally, one calls \mathcheck{${\mathcal{H}}$} the feature space and will use this terminology throughout this work. Exploiting the reproducing kernel property, we may carry out \newcite{bolukbasi2016man}'s bias isolation technique and construct a non-linear analogue. We start the development of bias mitigation technique in feature space with a modification of the design matrix presented in \cref{eq:design-matrix}. In the RKHS setting the non-linear analogue is \mathcheck{\begin{align} {\bm{W}}^{{\bm{\Phi}}}_{i, \cdot} := {\bm{\Phi}}({\vec{w}}_i) - {\boldsymbol M}^{{\bm{\Phi}}}_{D_f(i)}, \quad \forall\,{\vec{w}}_i \in V \end{align}} where we define \mathcheck{\begin{align} {\boldsymbol M}^{{\bm{\Phi}}}_{D_n} := \frac{1}{|D_n|}\sum_{i \in D_n}{\bm{\Phi}}({\vec{w}}_i) \end{align}} As one can see, this is a relatively straightforward mapping from the set of linear operations to non-linear ones. \subsection{Kernel PCA} Using our modified design matrix, we can cast our non-linear bias mitigation technique as a form of kernel PCA. Specifically, we form the following matrix \mathcheck{\begin{align} {\bm{C}}^{{\bm{\Phi}}} &= \frac{1}{2} \sum_{i=1}^{2N} ({\bm{W}}^{{\bm{\Phi}}}_{i,\cdot})^{\top} {\bm{W}}^{{\bm{\Phi}}} _{i, \cdot} \nonumber \end{align}} Our goal is to find the eigenvalues \mathcheck{$\lambda_k$} and their corresponding eigenfunctions \mathcheck{${\bm{V}}_k^{{\bm{\Phi}}} \in {\mathcal{H}}$} by solving the eigenvalue problem \mathcheck{\begin{align}\label{eq:eigen1} {\bm{C}}^{{\bm{\Phi}}}\,{\bm{V}}^{{\bm{\Phi}}}_k &= \lambda_k {\bm{V}}^{{\bm{\Phi}}}_k \end{align}} Computing these directly from Equation \ref{eq:eigen1} is impossible since \mathcheck{${\mathcal{H}}$}'s dimension may be prohibitively large or even infinite. However, \citeauthor{scholkopf1997kernel} note that \mathcheck{${\bm{V}}_k^{{\bm{\Phi}}}$} is spanned by \mathcheck{$\{{\bm{\Phi}}({\vec{w}}_i)\}_{i=1}^{2N}$}. This allows us to rewrite \cref{eq:eigen1} as \mathcheck{\begin{align}\label{eq:span} {\bm{V}}^{{\bm{\Phi}}}_k = \sum_{i=1}^{2N} \alpha^{k}_{i}\,{\bm{\Phi}}({\vec{w}}_i) \end{align}} where there exist coefficients \mathcheck{$ \alpha^{k}_i \in \mathbb{R}$}. Now, by substituting \cref{eq:span} and \cref{eq:eigen1} into the respective terms in \mathcheck{$\lambda \langle {\bm{\Phi}}({\vec{w}}_i),{\bm{V}}_k^{{\bm{\Phi}}} \rangle = \langle {\bm{\Phi}}({\vec{w}}_i),{\bm{C}}\,{\bm{V}}_k^{{\bm{\Phi}}} \rangle$}, \citet{scholkopf1997kernel} derive a computationally feasible eigendecomposition problem. Specifically, they consider \mathcheck{\begin{align} 2N \lambda_k\,{\boldsymbol \alpha}^k = {\bm{K}} {\boldsymbol \alpha}^k \label{eigk} \end{align}} where \mathcheck{${\bm{K}}_{ij} = \langle {\bm{\Phi}}({\vec{w}}_i), {\bm{\Phi}}({\vec{w}}_j) \rangle$}. Once all the \mathcheck{${\boldsymbol \alpha}^k$} vectors have been estimated the inner product between an eigenfunction \mathcheck{${\bm{V}}_k^{{\bm{\Phi}}}$} and a point \mathcheck{${\vec{w}}$} can be computed as \mathcheck{\begin{align} \beta_k({\vec{w}}) &= \langle {\bm{V}}^{{\bm{\Phi}}}_k , {\bm{\Phi}}({\vec{w}}_i) \rangle \nonumber \\ &= \sum_{i=1}^{2N} \alpha_i^k\,\kappa({\vec{w}}_i, {\vec{w}}) \label{beta} \end{align}} A projection into the basis \mathcheck{$\{{\bm{V}}^{{\bm{\Phi}}}_k\}_{k=1}^K$} can then be carried out by applying the projection operator \mathcheck{$\P_K : {\mathcal{H}} \rightarrow {\mathcal{H}}$} as follows: \mathcheck{\begin{align} \P_K {\bm{\Phi}}({\vec{w}}) = \sum_{k=1}^K\beta_k({\vec{w}})\,{\bm{V}}^{{\bm{\Phi}}}_k \label{proj} \end{align}} where \mathcheck{$K$} is the number of principal components. Projection operator \mathcheck{$\P_K$} is analogous to the linear projection \mathcheck{${\bm{P}}_K$} introduced in \cref{sub:neut}. \subsection{Centering Kernel Matrix} We can perform the required mean-centering operations on the design matrix by centering the kernel matrix in a similar fashion to \citet{scholkopf1998nonlinear}. For the case of equality sets of size 2, which is what \citeauthor{bolukbasi2016man} use in practice, we realize that the centered design matrix reduces to pairwise differences: \mathcheck{\begin{align} {\bm{W}}^{{\bm{\Phi}}}_{i, \cdot} &= \frac{1}{2} ({\bm{\Phi}}({\vec{w}}_i) -{\bm{\Phi}}({\vec{w}}_j)), \\ &\quad\quad\quad {\vec{w}}_i, {\vec{w}}_j \in D_n \wedge {\vec{w}}_j \neq {\vec{w}}_i \nonumber \end{align}} which leads to a very simple re-centering in terms of the Gram matrices: \mathcheck{\begin{align} \tilde{{\bm{K}}} = {\bm{K}}^{(11)} - {\bm{K}}^{(12)} - ({\bm{K}}^{(12)})^{\top} + {\bm{K}}^{(22)}\nonumber \end{align}} where \mathcheck{\begin{align} {\bm{K}}^{(xy)}_{ij} &= \frac{1}{2}\kappa\left({\bm{W}}^{(x)}_{i,\cdot}, {\bm{W}}^{(y)}_{j, \cdot}\right), \nonumber\\ {\bm{W}}^{(z)}_{i.\cdot} &= \begin{cases} {\vec{w}}_{\pi_{1 + i\text{\,mod\,}2}(\hat{f}({\lceil \frac{i}{2} \rceil}))} & z = 1 \\ {\vec{w}}_{\pi_{2 -i\text{\,mod\,}2}(\hat{f}({\lceil \frac{i}{2} \rceil}))} & z = 2 \end{cases}\label{eq:checkerboard} \end{align}} where \mathcheck{$\hat{f}: [N] \rightarrow [|V|]\times[|V|]$} maps a defining set index to a tuple containing the word indices in the corresponding defining set and \mathcheck{$\pi_1,\pi_2: [|V|]\times[|V|] \rightarrow [|V|]$} are projection operators which return the first or second elements of a tuple respectively. In simpler terms, \cref{eq:checkerboard} is creating two matrices: matrix \mathcheck{${\bm{W}}^{(1)}$} which is constructed by looping over the definition sets and placing pairs within the same definition set as adjacent rows, then \mathcheck{${\bm{W}}^{(2)}$} is constructed in the same way but the order of the adjacent pairs is swapped relative to \mathcheck{${\bm{W}}^{(1)}$}. Once we have this pairwise centered Gram matrix \mathcheck{$\tilde{{\bm{K}}}$} we can apply the eigendecomposition procedure described in Equation \ref{eigk} directly on \mathcheck{$\tilde{{\bm{K}}}$}. We note that carrying out this procedure using a linear kernel recovers the linear bias subspace from \citet{bolukbasi2016man}. \subsection{Inner Product Correction (Neutralize) \label{sub:neutkpca}} We now focus on neutralizing and equalizing the inner products in the RKHS rather than correcting the word embeddings directly. Just as in the linear case, we can decompose the representation of a word in the RKHS into biased and neutral components \mathcheck{\begin{align} {\bm{\Phi}}({\vec{w}}) = \P_K^{\perp}{\bm{\Phi}}({\vec{w}}) + \P_K {\bm{\Phi}}({\vec{w}}), \end{align}} which provides a nonlinear equivalent for \cref{neutralise} \mathcheck{\begin{align} { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}) &= \P_K^{\perp}{\bm{\Phi}}({\vec{w}}) \\ &= {\bm{\Phi}}({\vec{w}}) - \P_K {\bm{\Phi}}({\vec{w}}) \nonumber \end{align}} \begin{proposition}\label{prop:neut} The corrected inner product in the feature space for two neutralized words \mathcheck{${\vec{z}}, {\vec{w}}$} is given by \mathcheck{\begin{align} \langle { {\bm{\Phi}}_{\mathrm{ntr}}}&({\vec{z}}),{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}) \rangle \label{eq:neutrkhs} \\ &=\kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{z}})\,\beta_k({\vec{w}}) \nonumber \end{align}} \end{proposition} \begin{proof} \mathcheck{\begin{align*} \Big<&{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{z}}), { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}) \Big> = \nonumber\\ &\Big<{\bm{\Phi}}({\vec{z}})- \P_K {\bm{\Phi}}({\vec{z}}),\: {\bm{\Phi}}({\vec{w}})- \P_K {\bm{\Phi}}({\vec{w}})\Big> \nonumber\\ \end{align*}} Applying \cref{beta} and \cref{proj} \mathcheck{\begin{align} &=\kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\sum_{i=1}^{2N}\alpha_i^{k} \kappa({\vec{z}}, {\vec{w}}_{i})\nonumber \\ &- \sum_{k=1}^{K}\beta_k({\vec{z}})\sum_{i=1}^{2N}\alpha_i^{k} \kappa({\vec{w}}, {\vec{w}}_{i})+\sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}) \nonumber\\ &= \kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\sum_{i=1}^{2N}\alpha_n^{k} \kappa({\vec{z}}, {\vec{w}}_{i}) \nonumber\\ &= \kappa({\vec{z}}, {\vec{w}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}), \label{eq:testsim1} \end{align}} where \[\beta_k({\vec{w}})=\bm{V}_{k}^{{\bm{\Phi}}\top} {\bm{\Phi}}({\vec{w}}) = \sum_{i=1}^{2N}\alpha_{i}^{k}\,\kappa({\vec{w}}, {\vec{w}}_i) \] as derived by \citet{scholkopf1998nonlinear}. \end{proof} An advantage of this approach is that it will not rely on errors due to the approximation of the pre-image. However, it will not give us back a set of debiased embeddings. Instead, it returns a debiased metric, thus limiting the classifiers and regressors we could use. Equation \cref{eq:neutrkhs} provides us with an \mathcheck{$\mathcal{O}(KNd)$} approach to compute the inner product between two feature-space neutralized words. \subsection{Inner Product Correction (Equalize)} To equalize, we may naturally convert \cref{amon} to its feature-space equivalent. We define an equalizing function \mathcheck{\begin{align} {\bm{\theta}}_{\mathrm{eq}}({\vec{w}}_i) & := {\vec{\nu}}^{{\bm{\Phi}}}+ Z^{{\bm{\Phi}}}\,\P_K\left({\bm{\Phi}}({\vec{w}}_i) - {\boldsymbol M}^{{\bm{\Phi}}}_{E_{g(i)}}\right) \nonumber \end{align}} where we define \mathcheck{\begin{align*} {\vec{\nu}}^{{\bm{\Phi}}} &:= \P_K^{\perp} {\boldsymbol M}^{{\bm{\Phi}}}_{E_{g(i)}} \\ Z^{{\bm{\Phi}}} & := \frac{\sqrt{1- || \nu_{{\bm{\Phi}}}||^2}}{|| \P_K({\bm{\Phi}}({\vec{w}}) - {\boldsymbol M}^{{\bm{\Phi}}}_{E_{g(i)}}) ||} \end{align*}} where \mathcheck{$g: [|V|] \rightarrow [L]$} maps an individual word index to its corresponding equality set index. Given vector dot products in the linear case follow the same geometric properties as inner products in the RKHS we can show that \mathcheck{${\bm{\theta}}_{\mathrm{eq}}({\vec{w}})$} is unit norm follows directly from the proof for Proposition 1 in \cite{hall-maudslay-etal-2019-name} which can be found in Appendix A of \citet{hall-maudslay-etal-2019-name} \begin{proposition} For any two vectors in the observed space \mathcheck{${\vec{w}}, {\vec{z}}$} and their corresponding representations in feature space \mathcheck{${\bm{\Phi}}({\vec{w}}), {\bm{\Phi}}({\vec{z}})$} the inner product \mathcheck{$\langle {\bm{\Phi}}({\vec{w}}) - \P_K{\bm{\Phi}}({\vec{w}}), \P_K{\bm{\Phi}}({\vec{z}}) \rangle$} is \mathcheck{$0$}. \label{prep0} \end{proposition} \begin{proof} \begin{align*} \langle {\bm{\Phi}}&({\vec{w}}) - \P_K{\bm{\Phi}}({\vec{w}}), \P_K{\bm{\Phi}}({\bm{e}})\rangle \\ \nonumber\\ &=\langle{\bm{\Phi}}({\vec{w}}),\P_K{\bm{\Phi}}({\vec{z}})\rangle - \langle \P_k{\bm{\Phi}}({\vec{w}}),\P_K{\bm{\Phi}}({\vec{z}}) \rangle \nonumber \\ &= \sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}) - \sum_{k=1}^{K}\beta_k({\vec{w}})\beta_k({\vec{z}}) = 0\nonumber \end{align*} \end{proof} \begin{proposition}\label{prop:amon} For a given neutral word \mathcheck{${\vec{w}}$} and a word in an equality set \mathcheck{${\bm{e}} \in \mathcal{E}$} the inner product \mathcheck{$\left<{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), {\bm{\theta}}_{\mathrm{eq}}({\bm{e}})\right>$} is invariant across members in the equality set \mathcheck{$\mathcal{E}$}. \end{proposition} \begin{proof} \begin{align*} \langle & { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), {\bm{\theta}}_{\mathrm{eq}}({\bm{e}}) \rangle\overset{\textit(i)}{=} \langle { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), {\vec{\nu}}^{{\bm{\Phi}}} \rangle \\ &= \frac{1}{|E|} \sum_{i \in E} \langle{ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), \P_K^{\perp}{\bm{\Phi}}({\vec{w}}_i) \rangle \nonumber \\ &= \frac{1}{|E|} \sum_{i \in E} \langle \P_K^{\perp}{\bm{\Phi}}({\vec{w}}), \P_K^{\perp}{\bm{\Phi}}({\vec{w}}_i) \rangle \\ &\overset{\textit(ii)}{=} \frac{1}{|E|} \sum_{i \in E}\left(\kappa({\vec{w}}, {\vec{w}}_i) - \sum_{k=1}^K \beta_{k}({\vec{w}})\beta_{k}({\vec{w}}_i) \right) \end{align*} where \textit{(i)} follows from \cref{prep0} and \textit{(ii)} follows from \cref{prop:neut}. \end{proof} At this point we have completely kernelized the approach in \citet{bolukbasi2016man}. Note that a linear kernel reduces to the method described in \citet{bolukbasi2016man} as we would expect. We can see an initial disadvantage that equalizing via inner product correction has in comparison to \citet{bolukbasi2016man} and that is that we now require switching in between three different inner products at test time depending on whether the words are neutral or not. To overcome this in practice, we neutralize all words and do not use the equalize correction, however we present it for completeness. \begin{figure} \centering \includegraphics[width=\linewidth]{images/lintorkhs.png} \caption{Pre-image problem illustration for the neutralised embeddings (null-space). The plane represents represents the bias subspace in the RKHS.} \label{fig:my_rkhs} \end{figure} \section{Computing the Pre-Image}\label{sub:preimage} As mentioned in the previous section, a downfall of the metric correction approach is that it does not provide us embeddings that we can use in downstream tasks: the bias-mitigated embeddings only exist in feature space. Thus, when it comes to transfer tasks such as classification we are limited to kernel methods such (i.e. support vector machines). One way to resolve this problem is by obtaining the pre-image of the corrected representations in the feature space. Finding the pre-image is a well studied problem for kernel PCA \cite{kwok2004pre}. The goal is to fine the pre-image mappings \mathcheck{$\Gamma: \mathcal{H}_K \oplus \mathcal{H}_{K}^{\perp} \rightarrow \mathbb{R}^d$}, \mathcheck{$\Gamma^{\perp}: \mathcal{H}_{K}^{\perp} \rightarrow \mathbb{R}^d$} and \mathcheck{$\Gamma^{\top}: \mathcal{H}_{K} \rightarrow \mathbb{R}^d$} that compute (or approximate) the pre-images for \mathcheck{${\bm{\Phi}}({\vec{w}}_i), {\bm{\Phi}}_{\P_K}^{\perp}({\vec{w}}_i)$} and \mathcheck{${\bm{\Phi}}_{\P_K}({\vec{w}}_i)$}, respectively. In our case, with the pre-image maping, the neutralize step from \citet{bolukbasi2016man} becomes \mathcheck{\begin{align} {\vec{z}}_i^\star = \Gamma^{\perp}\left({\bm{\Phi}}({\vec{w}}_i) - \P_K{\bm{\Phi}}({\vec{w}}_i) \right) \end{align}} In general, we will not have access to \mathcheck{$\Gamma^{\perp}$} so we discuss the following approximation scheme. \paragraph{Additive Decomposition Approach.} Alternatively, following \citet{kandasamy2016additive}, we can construct an approximation to \mathcheck{$\Gamma$} that additively decomposes over the direct sum \mathcheck{$\oplus$}. We decompose \mathcheck{$\Gamma$} additively over the direct sum \mathcheck{$\mathcal{H}_K \oplus \mathcal{H}_{K}^{\perp}$}. That is, we assume that the pre-image mappings have the following form: \begin{table} \begin{tabular}{@{}ll@{}} \toprule \textbf{kernel} & \mathcheck{$\kappa({\vec{w}}_i, {\vec{w}}_j)$} \\ \midrule Cosine & \mathcheck{$\frac{{\vec{w}}_i^{\top} {\vec{w}}_j}{||{\vec{w}}_i||_2\,||{\vec{w}}_j||_2}$} \\ RBF Kernel & \mathcheck{$\exp\left(-\gamma\,|| {\vec{w}}_i - {\vec{w}}_j||_2^2\right)$} \\ Sigmoid Kernel & \mathcheck{$\tanh(\gamma\,{\vec{w}}_i^{\top} {\vec{w}}_j + c_0)$} \\ Polynomial Kernel & \mathcheck{$(\gamma\,{\vec{w}}_i^{\top} {\vec{w}}_j + c_0)^d$} \\ Laplace Kernel & \mathcheck{$ \exp(-\gamma\,|| {\vec{w}}_i - {\vec{w}}_j||_1)$} \\ Convex Combination & \mathcheck{$\sum_{\ell=1}^L \alpha_\ell \,\kappa_n({\vec{w}}_i, {\vec{w}}_j),$} \\ \bottomrule \end{tabular} \caption{Different kernels used throughout experiments.} \label{tab:kern} \end{table} \begin{table*}[] \begin{tabular}{@{}p{2.5cm}llclllllll@{}} \toprule \multirow{2}{*}{ Targets } & \multicolumn{2}{l}{Original} & \multicolumn{2}{l}{PCA} & \multicolumn{2}{l}{KPCA (rbf)} & \multicolumn{2}{l}{KPCA (sig)} & \multicolumn{2}{l}{KPCPA (lap)} \\ \cmidrule(l){2-11} & d & p & d & p & d & p & d & p & d & p \\ \midrule \multicolumn{11}{l}{ \hspace{3.5cm} Google News Word2Vec \cite{mikolov2013efficient} } \\ \midrule Career , Family & 1.622 & 0.000 & 1.327 & 0.001 & 1.321 & 0.005 & 1.319 & 0.006 & 1.311 & 0.002 \\ Math, Arts & 0.998 & 0.017 & -0.540 & 0.859 & -0.755 & 0.922 & -0.754 & 0.933 & -0.024 & 0.507 \\ Science , Arts & 1.159 & 0.005 & 0.288 & 0.281 & 0.271 & 0.307 & 0.269 & 0.283 & 1.110 & 0.009 \\ \midrule \multicolumn{11}{l}{ \hspace{5cm} GloVe \cite{glove}} \\ \midrule Career , Family & 1.749 & 0.000 & 1.160 & 0.007 & 1.166 & 0.006 & 1.165 & 0.01 & 1.443 & 0.000 \\ Math, Arts & 1.162 & 0.007 & 0.144 & 0.389 & 0.096 & 0.437 & 0.095 & 0.411 & 0.999 & 0.015 \\ Science , Arts & 1.281 & 0.008 & -1.074 & 0.985 & -1.114 & 0.995 & -1.112 & 0.993 & -0.522 & 0.839 \\ \bottomrule \end{tabular} \caption{ WEAT results using GloVe and Google News word embeddings.} \label{tab:weat_glove} \end{table*} \mathcheck{\begin{align} \Gamma({\bm{\Phi}}({\vec{w}})) &= \Gamma^{\perp}\left({\bm{\Phi}}_{\P_K}^{\perp}({\vec{w}}) \right) + \Gamma^{\top}({\bm{\Phi}}_{\P_K}({\vec{w}}) ) \nonumber \\ \Gamma^{\perp}\left(\hspace{-0.09cm}{\bm{\Phi}}_{\P_K}^{\perp}({\vec{w}})\hspace{-0.1cm}\right) \hspace{-0.1cm}&= \Gamma({\bm{\Phi}}({\vec{w}})) \hspace{-0.07cm}- \Gamma^{\top}({\bm{\Phi}}_{\P_K}({\vec{w}}) ) \nonumber \end{align}} Given that we will always know that the pre-image of \mathcheck{$\Gamma({\bm{\Phi}}({\vec{w}}))$} exists and is \mathcheck{${\vec{w}}$}, we can select \mathcheck{$\Gamma$} to return \mathcheck{${\vec{w}}$} resulting in: \mathcheck{\begin{align} \Gamma^{\perp}\left({\bm{\Phi}}_{\P_k}^{\perp}({\vec{w}}) \right) = {\vec{w}} - \Gamma^{\top}({\bm{\Phi}}^{\top}({\vec{w}}) ) \label{preimageq} \end{align}} We then learn an analytic approximation for \mathcheck{$\Gamma^{\top}$} using the method in \citet{bakir2004learning}. \begin{table} \begin{adjustbox}{width=\columnwidth} \begin{tabular}{@{}lllll@{}} \toprule \multirow{2}{*}{Dataset} & \multicolumn{2}{l}{\newcite{bolukbasi2016man}} & \multicolumn{2}{l}{PCA} \\ \cmidrule(l){2-5} & d & p & \multicolumn{1}{c}{d} & p \\ \midrule \multicolumn{5}{l}{Google News Word2Vec \cite{mikolov2013efficient}} \\ \midrule Career , Family & 1.299 & 0.003 & 1.327 & 0.001 \\ Math, Arts & -1.173 & 0.995 & -0.540 & 0.859 \\ Science , Arts & -0.509 & 0.832 & 0.288 & 0.281 \\ \midrule \multicolumn{5}{l}{ \hspace{1cm} GloVe \cite{glove}} \\ \midrule Career , Family & 1.160 & 0.000 & \multicolumn{1}{c}{1.160} & 0.007 \\ Math, Arts & -0.632 & 0.887 & \multicolumn{1}{c}{0.144} & 0.389 \\ Science , Arts & 0.937 & 0.937 & \multicolumn{1}{c}{-1.074} & 0.985 \\ \bottomrule \end{tabular} \end{adjustbox} \caption{Effect of the equalize step} \label{equalizetab} \end{table} Note that most pre-imaging methods, e.g., \citet{mika1999kernel} and \newcite{bakir2004learning}, are designed to approximate a pre-image \mathcheck{$\Gamma^{\top}$} and do not generalize to approximating the pre-image mappings \mathcheck{$\Gamma$} and \mathcheck{$\Gamma^{\perp}$}. This is because such methods explicitly optimise for pre-imaging representations in the space \mathcheck{$\Gamma^{\top}$} using points in the training set as examples of their pre-image, for the null-space \mathcheck{$\Gamma^{\perp}$} we have no such examples. \section{Experiments and Results} \label{sec:experiments} We carry out experiments across a range of benchmarks and statistical tests designed to quantify the underlying bias in word embeddings \cite{gonen-goldberg-2019-lipstick-pig}. Our experiments focus on quantifying both direct and indirect bias as defined in \citet{gonen-goldberg-2019-lipstick-pig,hall-maudslay-etal-2019-name}. Furthermore we also carry out word similarity experiments using the \citet{hill2015simlex} benchmark in order to asses that our new debiased spaces still preserve the original properties of word embeddings \cite{mikolov2013efficient}. \subsection{Experimental Setup} Across all experiments we apply the neutralize metric correction step to all word embeddings, in contrast to \citet{bolukbasi2016man} where the equalize step is applied to the equality sets \mathcheck{$\mathcal{E}$} and the neutralize step to a set of neutral words as determined in \citet{bolukbasi2016man}. We show in \cref{equalizetab} that applying the equalize step does not bring an enhancement over neutralizing all words. We varied kernel hyper-parameters using a grid search and found that they had little effect on performance, as a result we used default initialisation strategies as suggested in \citet{scholkopf1998nonlinear}. Unless mentioned otherwise, all experiments use the inner product correction approach introduced in \cref{sub:neutkpca}. \begin{figure} \hspace{-0.5cm}\includegraphics[scale=0.26]{images/toysim.png} \caption{2D toy example of non-linear component removal using Kernel PCA and the pre-image (neutralize step) described in \cref{sub:preimage}.} \label{fig:removal} \end{figure} \subsection{Kernel Variations} The main kernels used throughout experiments are specified in \cref{tab:kern}. We also explored the following compound kernels: \begin{enumerate*}[label=(\roman*)] \item convex combinations of the Laplace, radial basis function (RBF), cosine and sigmoid kernels; \item convex combinations of cosine similarity, RBF, and sigmoid kernels; \item convex combinations of RBF and sigmoid kernels; \item polynomial kernels up to 4$^{\text{th}}$ degree. \end{enumerate*} We only report the results on the most fundamental kernels out of the explored kernels. \subsection{Direct Bias: WEAT} The Word Embeddings Association Test \newcite[WEAT;][]{caliskan2017semantics} is a statistical test analogous to the implicit association test (IAT) for quantifying human biases in textual data \citep{greenwald1995implicit}. WEAT computes the difference in relative cosine similarity between two sets of target words \mathcheck{$X$} and \mathcheck{$Y$} (e.g. careers and family) and two sets of attribute words \mathcheck{$A$} and \mathcheck{$B$} (e.g. male names and female names). Formally, this quantity is Cohen's \mathcheck{$d$}-measure \cite{cohen1992statistical} also known as the effect size: The higher the measure, the more biased the embeddings. To quantify the significance of the estimated \mathcheck{$d$}, \newcite{caliskan2017semantics} define the null-hypothesis that there is no difference between the two sets of target words and the sets of attribute words in terms of their relative similarities (i.e. \mathcheck{$d=0$}). Using this null hypothesis, \citet{caliskan2017semantics} then carry out a one-sided hypothesis test where failure to reject the null-hypothesis \mathcheck{$(p > 0.05)$} means that the degree of bias measured by \mathcheck{$d$} is not significant. We obtain WEAT scores across different kernels (\cref{tab:weat_glove}). We observe that the differences between the linear and the non-linear kernels is small and, in most cases, the linear kernel has a smaller value for the effect size indicating a lesser degree of bias in the corrected space. Overall, we conclude that the non-linear kernels do not reduce the linear bias as measured by WEAT further than the linear kernels. We also experiment with polynomial kernels and obtain similar results, which can be found in \cref{tab:polyglove} of \cref{apdx:poly}. \subsection{Professions \cite{gonen-goldberg-2019-lipstick-pig}}\label{subsec:professions} We consider the professions dataset introduced by \newcite{bolukbasi2016man} and apply the benchmark defined in \citet{gonen-goldberg-2019-lipstick-pig}. We find the neighbors (100 nearest neighbors) of each word using the corrected cosine similarity and count the number of male neighbors. We then report the Pearson correlation coefficient between the number of male neighbors for each word and the original bias of that word. The original bias of a word vector \mathcheck{${\vec{w}}$} is given by the cosine similarity \mathcheck{$\cos({\vec{w}}, \textbf{\textit{he}} - \textbf{\textit{she}})$} in the original word embedding space. We can observe from the results in \cref{professions} that the non-linear kernels yield only marginally different results which in most cases seem to be slightly worse, i.e. their induced space exhibits marginally higher correlations with the original biased vector space. \begin{table} \centering \begin{adjustbox}{width=\columnwidth} \begin{tabular}{@{}llllll@{}} \toprule Embeddings & Original & PCA & KPCA(rbf) & KPCA(sig) & KPCA(lap) \\ \midrule Word2Vec & 0.740 & 0.675 & 0.678 & 0.675 & 0.708 \\ Glove & 0.758 & 0.675 & 0.681 & 0.680 & 0.715 \\ \bottomrule \end{tabular} \end{adjustbox} \caption{Pearson correlation coefficients of professions analogy task. All observed at significant at \mathcheck{$\alpha= 0.05$}. Indeed, all have \mathcheck{$p$}-values \mathcheck{$<10^{-30}$}.} \label{professions} \end{table} \begin{table} \centering \begin{adjustbox}{width=\columnwidth} \begin{tabular}{@{}llllll@{}} \toprule Embeddings & Original & PCA & KPCA(rbf) & KPCA(sig) & KPCA(lap) \\ \midrule Word2Vec & 0.974 & 0.702 & 0.716 & 0.715 & 0.720 \\ Glove & 0.978 & 0.757 & 0.754 & 0.753 & 0.914 \\ \bottomrule \end{tabular} \end{adjustbox} \caption{Classification accuracy results on male versus female terms.} \label{classification} \end{table} \subsection{Indirect Bias} Following \newcite{gonen-goldberg-2019-lipstick-pig}, we build a balanced training set of male and female words using the 5000 most biased words according to the bias in the original embeddings as described in Section \ref{subsec:professions}, and then train an RBF-kernel support vector machine (SVM) classifier \cite{scikit-learn} on a random sample of 1000 (training set) of them to predict the gender, and evaluate its generalization on the remaining 4000 (test set). We can perform classification in our corrected RKHS with any SVM kernel \mathcheck{$\kappa_{\mathrm{svm}}({ {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{z}}))$} that can be written in the forms \footnote{Stationary kernels are sometimes written in the form \mathcheck{$\kappa({\vec{w}},{\vec{z}}) = \kappa(\langle {\vec{w}},{\vec{z}} \rangle)$} or \mathcheck{$\kappa({\vec{w}},{\vec{z}}) = \kappa(||{\vec{w}}-{\vec{z}}||^2)$}, i.e. \mathcheck{$\kappa_{\mathrm{RBF}}(r) = \exp(-\gamma r^2)$}} \mathcheck{$\kappa_{\mathrm{svm}}(\langle {\vec{w}}, {\vec{z}}\rangle)$} or \mathcheck{$\kappa_{\mathrm{svm}}(||{\vec{w}} - {\vec{z}}||^{2})$} since we can use the kernel trick in our corrected RKHS \mathcheck{$\langle { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{w}}), { {\bm{\Phi}}_{\mathrm{ntr}}}({\vec{z}}) \rangle = \tilde{\kappa}({\vec{w}}, {\vec{z}})$} to compute the inputs to our SVM kernel, resulting in \mathcheck{\begin{align} \kappa_{\mathrm{svm}}&(||{\vec{w}} - {\vec{z}}||^{2}) \label{eq:svmkern} \\ &= \kappa_{\mathrm{svm}}(\tilde{\kappa}({\vec{w}}, {\vec{w}})-2\tilde{\kappa}({\vec{w}}, {\vec{z}}) + \tilde{\kappa}({\vec{z}}, {\vec{z}})). \nonumber \end{align}} It is clear that the RBF kernel is an example of a kernel that follows \cref{eq:svmkern}. We can see that the bias removal induced by non-linear kernels results in a slightly higher classification accuracy (shown in \cref{classification}) of gendered words for GoogleNews Word2Vec embeddings \cite{mikolov2013efficient} and a slightly lower classification accuracy for GloVe embeddings \cite{glove} (with the exception of the Laplace kernel which has a very high classification accuracy). Overall for the RBF and the sigmoid kernels there is no improvement in comparison to the linear kernel (PCA), the Laplace kernel seems to have notably worse results than the others, still being able to classify gendered words at a high accuracy of 91.4\% for GloVe embeddings. \subsection{Word Similarity: SimLex-999} The quality of a word vector space is traditionally measured by how well it replicates human judgments of word similarity. We use the SimLex-999 benchmark by \citet{hill2015simlex} which provides a ground-truth measure of similarity produced by 500 native English speakers. Similarity scores by our method are computed using Spearman correlation between embedding and human judgments are reported. We can observe that the metric corrections only slightly change the Spearman correlation results on SimLex-999 (\cref{tab:simlex}) from the original embedding space. We can thus conclude that the embedding quality is mostly preserved. \saveForCR{ \section{Discussion} We observe that our non-linear extensions of \cite{bolukbasi2016man} report no notable performance differences across a set of benchmarks and statistical tests reported in Section \ref{sec:experiemtns} designed to quantify bias in word embeddings. Furthermore the results in Table \ref{tab:polyglove} (\cref{apdx:poly}) show that gradually increasing the degree of non-linearity has again no significance change in performance for the WEAT \cite{caliskan2017semantics} benchmark. These results provide empirical evidence supporting the \textbf{linear subspace hypothesis} (\cref{eq:hypothesis}) and thus suggest that representing Gender bias in word embeddings as a linear subspace is a suitable assumption. This result overall has a positive practical impact since as can be seen from the methodology in this paper our non-linear alternative to the method in \cite{bolukbasi2016man} are not only computationally more complex but also partly limited to kernel methods for transfer tasks. } \begin{table} \centering \begin{adjustbox}{width=\columnwidth} \begin{tabular}{@{}llllll@{}} \toprule Embeddings & Original & PCA & KPCA(rbf) & KPCA(sig) & KPCA(lap) \\ \midrule Word2Vec & 0.121 & 0.119 & 0.118 & 0.118 & 0.118 \\ Glove & 0.302 & 0.298 & 0.298 & 0.298 & 0.305 \\ \bottomrule \end{tabular} \end{adjustbox} \caption{Correlation on SimLex-999 using GoogleNews Word2Vec and GloVe embeddings. The significance level is \mathcheck{$\alpha = 0.05$} with \mathcheck{$p < 0.001$}.}\label{tab:simlex} \end{table} \section{Conclusion} We offer a non-linear extension to the method presented in \citet{bolukbasi2016man} by connecting its bias space construction to PCA and subsequently applying kernel PCA. We contend our extension is natural in the sense that it reduces to the method of \citet{bolukbasi2016man} in the special case when we employ a linear kernel and in the non-linear case it preserves all the desired linear properties in the feature space. This allows us to provide equivalent constructions of the neutralize and equalize steps presented. We compare the linear bias mitigation technique to our new kernelized non-linear version across a suite of tasks and datasets. We observe that our non-linear extensions of \newcite{bolukbasi2016man} show no notable performance differences across a set of benchmarks designed to quantify gender bias in word embeddings. Furthermore, the results in \cref{tab:polyglove}(\cref{apdx:poly}) show that gradually increasing the degree of non-linearity has again no significant change in performance for the WEAT \cite{caliskan2017semantics} benchmark. Thus, we provide empirical evidence for the linear subspace hypothesis; our results suggest representing gender bias as a linear subspace is a suitable assumption. We would like to highlight that our results are specific to our proposed kernelized extensions and does not imply that all non-linear variants of \cite{bolukbasi2016man} will yield similar results. There may very well exist a non-linear technique that works better, but we were unable to find one in this work. \bibliographystyle{acl_natbib}
{'timestamp': '2020-10-08T02:18:25', 'yymm': '2009', 'arxiv_id': '2009.09435', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09435'}
arxiv
\section{Introduction} \label{sec:int} \subfile{paragraphs/1-introduction.tex} \section{Learning from streams} \label{sec:streams} \subfile{paragraphs/2-streams.tex} \section{Limited budget and underfitting} \label{sec:framework} \subfile{paragraphs/3-budget.tex} \section{Enhancing adaptation} \label{sec:risky} \subfile{paragraphs/4-risky.tex} \section{Experimental study} \label{sec:exp} \subfile{paragraphs/5-exp.tex} \section{Summary} \label{sec:sum} \subfile{paragraphs/6-sum.tex} \section*{References} \bibliographystyle{elsarticle-num} \subsection{Idea} Our hypothesis is that when dealing with temporary and evolving concepts under strictly limited access to labeled data, it is reasonable to aggressively exploit the data we currently have in order to overcome underfitting and obtain efficient up-to-date models. Let us consider the following example. In Fig. \ref{fig:vis} we can see an adaptation process for a classifier while recognizing two classes (marked as red and blue points). Fig. \ref{fig:vis}a presents a state just before a drift. The classifier has learned the previous concept with sufficient accuracy, however, after the change (Fig. \ref{fig:vis}b) its model becomes practically useless. There is a need to update it, but due to a limited budget only few labeled instances selected by the active learning strategy are available (yellow). Since we deal with data streams, we can assume that the data points are currently stored in a sliding window. \begin{figure}[h] \centering \begin{subfigure}{0.24\linewidth}{ \includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/vis/1.pdf} \subcaption{Before drift}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.24\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/vis/2.pdf} \subcaption{After drift, $\lambda=0$}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.24\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/vis/3.pdf} \subcaption{$\lambda=10$}} \end{subfigure}\vspace*{3pt}\\ \begin{subfigure}{0.24\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/vis/4.pdf} \subcaption{$\lambda=50$}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.24\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/vis/5.pdf} \subcaption{$\lambda=100$}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.24\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/vis/6.pdf} \subcaption{$\lambda=200$}} \end{subfigure}% \caption{Decision boundaries created by an incremental classifier, while tackling a concept drift, after learning on $\lambda$ duplicates of the selected instances.} \label{fig:vis} \end{figure} In the standard active learning approach, the chosen objects are used only once ($\lambda=0$) and the effect is unacceptable -- the class boundary did not change at all. This observation is connected with the nature of many incremental parameters maintained by the classifiers. Their internal estimators, cannot be updated efficiently using only few new values. The most straightforward solution is to reuse the limited labeled instances several times to influence the metrics in a more significant manner and boost the adaptation. We can clearly see that after some number of repetitions $\lambda$ the decision boundary is reshaping towards a proper model -- we exploit the acquired knowledge (Fig. \ref{fig:vis}c - \ref{fig:vis}f). The final result is highly dependent on the representativeness of the instances selected by active learning, but this has been already investigated in other publications \cite{Zliobaite:2014}. While we are aware of the fact that such an approach may potentially cause overfitting to the few instances, our assumption is that it is less important than the underfitting problem encountered before the risky adaptation was performed. Such a wrapper can work with many online base learners, especially with those dedicated to evolving data streams. The currently most important online algorithm -- Adaptive Hoeffding Tree (AHT) -- may benefit from such a method, since its internal splits are rearranged only if a significantly large amount of data differs from a previous concept \cite{Bifet:2009}. In the case of the stochastic gradient descent classifier (SGD) or neural networks, while exposing wrongly classified instances several times, we can speed-up the gradient-based optimization of a loss function. Of course, while using such algorithms we can also directly focus on the criterion, for example by adjusting learning rate or momentum, however, such solutions are limited only to the gradient-based classifiers \cite{Zhu:2017cls}. Finally, Na\"ive Bayes may also work with the introduced method, since its internal estimators can be updated incrementally. It is also worth noting that we may avoid reusing instances several times by employing weight-sensitive classifiers, which can be straightforwardly adapted for this approach. In this work, due to their greater flexibility, we focus only on the more generic instance-based algorithms. This approach can be associated with a mechanism similar to experience replay, which is a method of tackling catastrophic forgetting in deep neural networks \cite{Masson:2019}. The fundamental difference is that instead of reusing instances for stabilizing models of incoming classes, we want to erase outdated knowledge more quickly and practically "overfit" an online model to current concepts. The method is also related to resampling, known from imbalance learning, which also utilizes some instances multiple times \cite{Krawczyk:2016imb}. One may notice that another popular approach, that allows for the most current instances to significantly affect a maintained model, is to simply retrain the model from scratch, using a collected batch of data \cite{Gama:2014}. However, while such methods work well with sudden concept drifts, they are not suitable for incremental changes. In addition, forgetting the whole priorly gathered information may be a wrong idea if the budget is limited and if we take into consideration the fact that streams may be characterized by hybrid drifts or changes affecting only some parts of the analyzed space. In the example above (Fig. \ref{fig:vis}), we would lose all the information about red points at the bottom, which were not influenced by the concept drift. We do not want to completely forget previous knowledge, just quickly and incrementally adapt to the current situation when lacking labels. One well-known way to overcome this problem is to use ensembles that consist of classifiers constructed on the basis of the most current batches \cite{Wang:2003}. Still, such an approach is much more time and memory consuming than single-classifier frameworks. Another problem is that highly limited budgets may be prohibitive in the context of building a diverse pool of classifiers. Finally, all the strategies using the retraining approach, are highly dependent on effective concept drift detectors, which increase the overall complexity of a system and are often affected by the limited access to labeled instances as well. \subsection{Instance exploitation} \label{sec:frame} We propose a simple, generic, single-classifier framework that uses aggressive online updates based on instances selected for labeling by an active learning strategy. Our implementation utilizes a reactive sliding window that stores the most recent labeled instances and exposes them several times to the online classifier in order to exploit the knowledge that comes with them. We present three different probabilistic sampling methods that determine how the instances are selected from the window. The general assumption is that while active learning will effectively explore a decision space, by selecting the most representative seeds, the instance exploitation wrapper will sufficiently utilize them in order to enhance the adaptation of a classifier using only few labels. That should help us tackle the underfitting problem. \subsubsection{Framework} The generic wrapper framework is presented in Alg. \ref{alg:framework}. When a new instance $x$ appears, the actual budget spending $\hat{b}$ is checked. Since the data stream is infinite by definition, the current spending has to be estimated as a ratio of objects that have been already labeled to the total number of registered instances \cite{Zliobaite:2014}. If the value is below an available budget $B$, we use the active learning strategy to check if the instance is worth labeling. Some of the online strategies that can be used here were presented in \cite{Zliobaite:2014}. The methods are focused on selecting instances close to the decision boundary, based on the uncertainty of a classifier. The idea is that those regions are most likely to be affected by drifts. In order to make the strategies more exploratory and sensitive to changes in other subspaces, randomization techniques can be utilized. One of the methods implementing a hybrid comprehensive querying is the RandVar algorithm. In addition to the complex sampling, the strategy uses a variable threshold balancing budget spending. We select this method as our default strategy due to its theoretically sound design. After receiving a positive response, the object is queried (we obtain its true label $y$), the current labeling expenses are increased and the classifier is updated with the labeled instance. Then, we activate our instance exploitation strategy, which selects indices $I$ of previously acquired labeled instances in order to reuse them and boost the adaptation process. \begin{algorithm}[h] \BlankLine \KwData{labeling budget $B$, \textot{ActiveLearningStrategy}, \textot{ExploitationStrategy}, window size $\omega_{max}$} \KwResult{classifier $L$ at every iteration} \KwInit{$\hat{b} \gets 0$, $I \gets []$, $W \gets []$} \Repeat{stream ends}{ receive incoming instance $x$\; \uIf{$\hat{b} < B$ {\normalfont and} \upshape\textot{ActiveLearningStrategy} $(x) = true$}{ request the true label $y$ of instance $x$\; update labeling expenses $\hat{b}$\; update classifier $L$ and sliding window $W$ with $(x,y)$\; \BlankLine $I \gets $ \textot{ExploitationStrategy} $(W)$\; \ForEach{$i \in I$}{ update classifier $L$ with $w_i \in W$\; } } } \caption{Combining active learning with instance exploitation.} \label{alg:framework} \end{algorithm} Since we want to adapt a predictive model to current concepts, our exploitation methods work with a batch of the most recent instances. We maintain a sliding window $W$ that is updated with every labeled instance we receive, before using an exploitation strategy. We define the window $W$ as a sequence of $\omega \in \langle1,\omega_{max}\rangle$ instances $w_i \in W$, where $i \in \langle1,\omega\rangle$, the oldest instance is $w_1$ and the newest one is $w_{\omega}$. It is important to remember that for very low budgets, wide windows may not be able to represent actual concept properly, since the relatively small number of labeled instances will cover only few batches. For example, if $B=1\%$, $\omega_{max}=1000$ and a stream consists of 100 000 instances, then the window will not slide at all, since all labeled instances will cover exactly one such window. Therefore, in order to have a reactive sliding window, when using a low budget or dealing with a low-rate stream, its size must be adequate. \subsubsection{Exploitation strategies} \label{sec:strategies} Our exploitation methods consists of strategies that simply reuse instances selected from a sliding window. In practice, they generate a multiset of indices $I = \{i~|~i \in \langle1,\omega\rangle\}$, where $|I| = \lambda$. The $\lambda$ parameter determines the intensity of the exploitation process. A single index is selected using the formula $i = \phi(\omega, r) = \lceil r\omega \rceil$, where $r$ is a random variable $r \sim \mathcal{P}(0,1)$. As a result, each strategy is modeled by a probability distribution $\mathcal{P}(0,1)$ -- it determines on which parts of the window a strategy focuses. We may see the sliding window as a probabilistic or fuzzy one. \bigskip\bigskip \noindent \textbf{Uniform Window} (\textbf{UW}) -- the most straightforward solution is to select the instances uniformly, which results in each instance having an equal chance of being chosen (Fig. \ref{fig:strats}a). The probability value is given by the uniform distribution, so a single object has $1/\omega$ chance of being used again, where $\omega$ is a number of instances within the window after a new object is added. Therefore, the indices $i$ are drawn by the strategy using $r = u \sim \mathcal{U}(0,1)$, where $u$ is a random variable sampled from the uniform distribution $\mathcal{U}(0,1)$. This approach keeps adapting a classifier to a wider context of the maintained batch of data and by doing so it may reduce the risk of falling into local minima. On the other hand, if the sliding window is insufficiently reactive, this method may fail at handling more rapid changes, since, in such case, the strategy will keep providing outdated instances. We assume that this method may work well while dealing with gradual concept drifts, when instances for both older and newer concepts should contribute to updates. The complexity for this method is solely based on the intensity $\lambda$, so it is $O(\lambda)$.\\ \noindent \textbf{Exponential Window} (\textbf{EW}) -- instead of selecting instances with an equal probability, we can focus more on the newer objects, while leaving a non-zero sampling rate for the rest of the window (Fig. \ref{fig:strats}b). We model this behavior, using the normalized exponential distribution $r = e \sim \mathcal{E}_{n}(0,1)$. Utilizing a truncated exponential transform, we have $e = -ln(u)/\gamma$, where $\gamma$ is the parameter of the exponential distribution and $u \sim \mathcal{U}(0,1)$ \cite{Eisenberg:2008}. This strategy assumes that a sliding window may imperfectly represent the current concepts, e.g, by having an inadequate size or by insufficient exploitation of the newer instances. It attempts to handle this problem on its own by increasing the chances for the more recent data. Theoretically, this approach may be adequate for more rapid incremental changes and, at the same time, acceptable for gradual and sudden concept drifts. We set $\gamma=4$ as our default value, which provides a functionality balanced between the two other strategies. The complexity is the same as for the previous approach -- $O(\lambda)$.\\ \noindent \textbf{Single Exposition} (\textbf{SE}) -- the most extreme method is reusing only the latest instance $w_{\omega}$ (Fig. \ref{fig:strats}c). Obviously, probabilities for such a strategy are: $P[i=\omega]=1$ and $P[i\neq\omega]=0$, so formally $I = \bigcup_{\lambda \in \mathbb{N}}\{\omega\}$. One of the advantages of this method is that, in practice, we do not even have to maintain a sliding window. It is enough to update the classifier with the instance several times and proceed to the next incoming objects. The strategy is a fully online one. While it has indisputable advantages regarding processing performance, it is also possible that such intense focus on a single instance may more likely lead to detrimental overfitting, which is opposite to the problem we want to solve (we spend more time on this aspect in the next sections). On the other hand, it may be a good choice for sudden drifts. The complexity of this strategy is also $O(\lambda)$. \medskip \begin{figure}[h] \centering \begin{subfigure}{0.32\linewidth}{ \includegraphics[width=\linewidth]{img/vis/strat_vis_uw.pdf} \subcaption{Uniform window}} \end{subfigure} \begin{subfigure}{0.32\linewidth} {\includegraphics[width=\linewidth]{img/vis/strat_vis_ex.pdf} \subcaption{Exponential window, $\gamma=4$}} \end{subfigure} \begin{subfigure}{0.32\linewidth} {\includegraphics[width=\linewidth]{img/vis/strat_vis_se.pdf} \subcaption{Single exposition}} \end{subfigure} \caption{Histograms for selected window indices (x-axis) depending on a strategy.} \label{fig:strats} \end{figure} \subsubsection{Dynamic parameters} \label{sec:dynamic} It is easy to notice that two the most important parameters of the strategies are: intensity $\lambda$ and the size of the sliding window $\omega_{max}$. Generally, we may want to keep $\lambda$ relatively high for low budgets, low-rate data and unstable temporary concepts to compensate limited exploration, and low for the opposite, since having an abundance of labeled data and a sufficiently updated model, we can rely on the mechanism less. In addition, we have to control the computation time. When it comes to $\omega_{max}$, we most likely should do the opposite -- keep the size of the window low for limited budgets, low-rate data and drifting concepts, and high for more labeled instances and stable streams. These two heuristics should give us more reactivity to changes (plasticity) in the former case and provide us with more comprehensive and stable generalization (stability) in the latter one. In other words, depending on the situation we may either need to entirely focus on tackling underfitting, or to be a bit more careful no to end up with overfitting. In our work, we empirically analyze how the values of the parameters should change depending on an amount of labeled data, as well as we provide a dynamic control technique for adjusting the values adequately to the state of a stream in a learning process. The idea is that since a model should quickly adapt to new data when it suffers from underfitting or after a concept drift, we can control $\lambda$ and $\omega_{max}$ based on a value of a current error, which should be high in both situations and which is a reliable state-of-the-art input in many drift detectors \cite{Barros:2018}. Therefore, if $\epsilon \in \langle0,1\rangle$ is a currently registered error for a model learning from a stream, for the intensity we can use: \begin{equation}\label{eq:lambda} \lambda(\epsilon) = \epsilon \lambda_{max} \end{equation} \noindent and for the size of a window: \begin{equation}\label{eq:omega} \omega'_{max}(\epsilon) = (1 - \epsilon) \omega_{max}, \end{equation} \noindent where $\lambda_{max}$ and $\omega_{max}$ are fixed maximum values selected for a given budget. Obviously, a new problem emerges -- how should we determine the current value of $\epsilon$? The most straightforward solution is to calculate an error within a sliding window. However, in such case, we will, again, struggle with finding a proper window size $\omega_\epsilon$ that should depend on the amount of available data and a state of a stream. Fortunately, this problem has been already addressed by the well-known ADWIN algorithm \cite{Bifet:2007}, which provides an adaptive window capable of calibrating its size adequately to incoming data. At its core, the algorithm checks for each subwindow $W_0$ and $W_1$ whether $|\epsilon_{W_0} - \epsilon_{W_1}| > \theta_{cut}$, where $\theta_{cut}$ is a significance threshold based on the Hoeffding bound \cite{Hoeffding:1963} using a specified confidence value $\alpha_\theta$\footnote{Its actual implementation optimizes the computations, allowing updates with O(1) amortized and O(logW) worst-case time \cite{Bifet:2007}. Therefore, it is a very efficient algorithm for streaming data.}. If the condition holds, the algorithm shrinks the window in order to keep only the most recent consistent values, which are used for the calculation of the estimated average $\epsilon_{ADW}$. We use this indicator as a control signal in our methods, so we have $\epsilon = \epsilon_{ADW}$. Finally, since ADWIN provides the optimal window size in an online way, we can set $\omega_{max} = \omega_{ADW}$. We empirically show that all of those choices are reasoned, also in our scenario involving strict limitations on supervision. \subsection{Alleviating overfitting} The presented approach to handling underfitting while learning on a budget has one significant potential weakness -- it may turn one problem into its opposite. Since our method prefers aggressive updates using few labeled instances, it becomes more likely that at some point we may encounter the overfitting problem instead of underfitting, even if we try to adequately adjust the dynamic parameters $\lambda$ and $\omega_{max}$ or when we choose a safer exploitation strategy. To alleviate it, we propose an ensemble of two paired learners, in which one of them performs risky adaptation with instance exploitation ($L_r$) and the another one learns in a standard way, without any additional enhancement ($L_s$). Such a simple ensemble can learn in two modes. \medskip \noindent \textbf{Switching} -- in this mode, we maintain both learners in parallel (Alg. \ref{alg:switch-learn}) and use only the currently better one for prediction, based on their respective errors $\epsilon_{r}$ and $\epsilon_{s}$ (Alg. \ref{alg:switch-pred}). The assumption is that for some parts of a stream the learner intensively exploiting instances will take the risk in the right direction, providing an efficient up-to-date model more quickly, while for the other parts (mostly more stable) it will fall into local minima, giving way to the basic learner. Since the latter tries to learn in a different way, it is possible that its perspective will allow it to temporarily outperform its counterpart, preventing overfitting. \begin{algorithm}[h] \BlankLine \KwIn{incoming instance $\mathbf{x}$, true label $y$, risky base learner $L_{r}$, standard base learner $L_{s}$, \textot{ExploitationStrategy}} \KwResult{up-to-date models $L_{r}$, $L_{s}$} \KwInit{$\epsilon_{r} \gets 0$, $\epsilon_{s} \gets 0$} update $\epsilon_{r}$ and $\epsilon_{s}$\; update $L_{r}$ with ($\mathbf{x}$, y) using \textot{ExploitationStrategy} (Algorithm 1)\; update $L_{s}$ with ($\mathbf{x}$, y) \; \caption{The switching learning mode.} \label{alg:switch-learn} \end{algorithm} \begin{algorithm}[h] \BlankLine \KwData{incoming instance $\mathbf{x}$ risky base learner $L_{r}$, standard base learner $L_{s}$} \KwResult{prediction $\hat{y}$} \uIf{$\epsilon_{r} < \epsilon_{s}$}{ $\hat{y} \gets L_{r}(\mathbf{x})$\; }\uElse { $\hat{y} \gets L_{s}(\mathbf{x})$\; } \Return $\hat{y}$\; \caption{The switching and elevating prediction mode.} \label{alg:switch-pred} \end{algorithm} \noindent \textbf{Elevating} -- in the alternative mode, we not only temporarily switch between better approaches (Alg. \ref{alg:switch-pred}), but also elevate the worse model (replacing it with the better one), if a difference between them is significant according to a chosen test $\delta$($\epsilon_{r}$, $\epsilon_{s}, \alpha_e$) (Alg. \ref{alg:elev-learn}), where $\alpha_e$ determines a significance level of the test. In this case, the idea is that instead of waiting for one model to catch up with learning, we simply instantly bring it up to speed by replacing with the more effective model. One should be careful, however, since having a better model for one timestamp does not mean that it will be easier to adapt it to a new concept from there. \begin{algorithm}[h] \BlankLine \KwIn{incoming instance $\mathbf{x}$, true label $y$, risky base learner $L_{r}$, standard base learner $L_{s}$, \textot{ExploitationStrategy}, significance level $\alpha_e$} \KwResult{up-to-date models $L_{r}$, $L_{s}$} \KwInit{$\epsilon_{r} \gets 0$, $\epsilon_{s} \gets 0$} update $\epsilon_{r}$ and $\epsilon_{s}$\; \uIf{$\delta$($\epsilon_{r}$, $\epsilon_{s}, \alpha_e$) $=$ True}{ replace the worse model L and error $\epsilon$ with their counterparts\; } update $L_{r}$ and $L_{s}$ as in Algorithm 2\; \caption{The elevating learning mode.} \label{alg:elev-learn} \end{algorithm} To test whether two classifiers are significantly different we can use the Welch's test, which assumes that two populations (for $\epsilon_{r}$ and $\epsilon_{s}$) have unequal variances \cite{Welch:1947}. We find this assumption reasonable in our case. The statistic $t$ required for the test is obtained using the formula: \begin{equation} t = \dfrac{\epsilon_{r} - \epsilon_{s}}{\sqrt{\dfrac{\sigma_r^2}{N_r} + \dfrac{\sigma_s^2}{N_s}}}, \end{equation} \noindent where required average errors $\epsilon$, their variance $\sigma$ and the numbers of samples $N$ can be easily calculated within a sliding window, including ADWIN, which we use as a default estimator. The same values are required for the degrees of freedom $\nu$, which can be approximated using the Welch-Satterthwaite equation: \begin{equation} \nu \approx \dfrac{\left(\dfrac{\sigma_r^2}{N_r} + \dfrac{\sigma_s^2}{N_s}\right)^2}{\dfrac{\sigma_r^4}{N_r^2\nu_r} + \dfrac{\sigma_s^4}{N_s^2\nu_s}}, \end{equation} \noindent where $\nu_r = N_r - 1$ and $\nu_s = N_s - 1$ are the degrees of freedom associated with variance estimates. Since the Welch's test can be easily implemented in our setting, we use it as our default test. It is worth noting that the effectiveness of both modes highly depends on the precision of determining the true value of a current error, especially when supervision is strictly limited. This problem has been already mentioned in Sec. \ref{sec:dynamic} and we empirically investigate it in the context of the proposed ensembles. \end{document} \subsection{Data streams} \label{sec:data} For the purpose of the experiments, we utilized two groups of data stream benchmarks. Each of them was dedicated to a different goal of this study. \medskip \noindent\textbf{Synthetic streams}. The first one consists of streams that were created using artificial drift generators. Such benchmarks are commonly used while evaluating algorithms on dynamic data \cite{Barros:2018, Cano:2020}. Their well-defined characteristics can be utilized to evaluate the algorithms in very specific situations, for example, when adapting to stable or unstable concepts, or to different types of drifts. The streams were created using tools available in MOA \cite{Bifet:2010moa}, which provides some state-of-the-art generators that synthesize drifting streams by simulating transitions between different concepts. They are based on the following sigmoidal formula: \begin{equation} f(t) = 1/(1 + e^{-s(t-t_0)}), \end{equation} \noindent where $s$ controls the duration of change and $t_0$ is a peak of it. There are several different concepts that can be generated -- gaussian clusters (RBF), decision spaces modeled by a random decision tree (TREE), linearly separated subspaces (SEA) or concepts defined by some fixed formulas (STAG). There is also a simulation of a rotating hyperplane (HYPER), which does not use the function given above. We generated 14 synthetic streams (Tab. \ref{tab:data}), using different types of concepts and drifts. The latter include very sudden, less or more gradual and very slow changes. For the HYPER concept we used mediocre incremental rotations (defined by the rate parameter $\rho$). This diversification of benchmarks should provide a reliable generalization of observations. \begin{table}[h] \caption{Summary of the used synthetic (left) and real (right) data streams.} \centering \hspace*{1.25cm}\scalebox{0.8}{ \begin{subtable}{\textwidth} \begin{tabular}[H]{lcccccc} Name & \#Inst & \#Att & \#Cls & Drift & \#Drifts & Noise\\ \midrule RBF1 & 1m & 15 & 5 & 100 & 3 & 0.05\\ RBF2 & 1m & 15 & 5 & 10k & 3 & 0.05\\ RBF3 & 1.2m & 15 & 5 & 50k & 2 & 0.05\\ RBF4 & 1.2m & 15 & 5 & 100k & 2 & 0.05\\ TREE1 & 1m & 15 & 5 & 100 & 3 & -\\ TREE2 & 1m & 15 & 5 & 10k & 3 & -\\ TREE3 & 1.2m & 15 & 5 & 50k & 2 & -\\ TREE4 & 1.2m & 15 & 5 & 100k & 2 & -\\ SEA1 & 600k & 3 & 2 & 100 & 3 & 0.05\\ SEA2 & 600k & 3 & 2 & 10k & 3 & 0.05\\ STAG1 & 600k & 3 & 2 & 100 & 3 & -\\ STAG2 & 600k & 3 & 2 & 10k & 3 & -\\ HYPER1 & 500k & 15 & 5 & $\rho=0.001$ & - & 0.05\\ HYPER2 & 500k & 15 & 5 & $\rho=0.01$ & - & 0.05\\ \bottomrule \end{tabular} \end{subtable}}% \hspace*{-5cm}\scalebox{0.8}{ \begin{subtable}{\textwidth} \begin{tabular}[H]{lccc} Name & \#Inst & \#Att & \#Cls\\ \midrule Activity & 10 853 & 43 & 8\\ Activity-Raw & 1 048 570 & 3 & 6\\ Connect4 & 67 557 & 42 & 3\\ Cover & 581 012 & 54 & 7\\ Crimes & 878 049 & 3 & 39\\ DJ30 & 138 166 & 8 & 30\\ EEG & 14 980 & 14 & 2\\ Elec & 45 312 & 8 & 2\\ Gas & 13 910 & 128 & 6\\ Poker & 829 201 & 10 & 10\\ Power & 29 929 & 2 & 24\\ Sensor & 2 219 804 & 5 & 57\\ Spam & 9 324 & 499 & 2\\ Weather & 1 8158 & 8 & 2\\ \bottomrule \end{tabular} \end{subtable}} \label{tab:data} \end{table} Due to the deterministic character of the synthetic streams, we decided to use them in the first part of our experiments, in which we thoroughly investigate the influence of different configurations and the potential usability of the presented heuristics. \medskip \noindent\textbf{Real streams}. While the artificial data provides a well-defined environment for evaluation, real world streams may differ from them in some unspecified, unknown aspects. There is still very little research done on general dynamics of streams, therefore, it is difficult to say how realistic are the concepts and drifts generated by the artificial sources. Due to this reason, it is always important to evaluate streaming algorithms on real examples. In our experiments, we used 14 state-of-the-art real streams that are widely used in data stream mining \cite{Bifet:2010, Cano:2020}. Analogously to the synthetic streams, the chosen set represent a variety of different problems with diverse characteristics (Tab. \ref{tab:data}). Most of the selected streams are snapshots of some continuous observations registered in industrial systems or laboratories. All of them can be found either in the UCI repository, Kaggle competitions or in popular related publications. As opposed to the synthetic data, most of the real streams are not transparent when it comes to their internal characteristics. It means that usually we cannot say when exactly a drift occurs or what its specific type is. On the other hand, they provide a more realistic general validation. Because of that, we utilized the real streams in the second part of our experiments, conducting the final comparison between our methods (tuned in the previous step), baseline models without instance exploitation and some state-of-the-art streaming classifiers. By doing so, we also avoided fitting parameters of our algorithms to a specific testing set and fairly evaluated proposed default settings. \subsection{Set-up} \label{sec:set} In this subsection, we present details of the set-up used in the experiments. For any very specific parameters or subroutines, please, refer to the source code given in the repository in Sec. \ref{sec:exp}. \medskip \noindent\textbf{Overview.} The experiments were conducted in the following order. First, using the synthetic streams, we evaluated how the exploitation strategies should be configured. We checked how different values of intensity ($\lambda_{max}$) and window size ($\omega_{max}$) affect the learning process. We also investigated whether adjusting these values dynamically provides any improvements in terms of performance and utilized resources. As the last part of the tuning stage, we analyzed the behavior of the supporting ensembles, focusing on the correctness of deciding which approach (standard or risky) is currently the better one, depending on the significance threshold ($\alpha_e$). Finally, we prepared the final comparison between the proposed algorithms, baseline and other well-known classifiers learning in a conservative way. It was conducted using the real streams. Last but not least, since at its core our work emphasizes the problem of limiting the access to supervision, the whole analysis was considered mainly from the perspective of having different labeling budgets ($B$). \medskip \noindent\textbf{Evaluated parameters.} Below, we enclose values of parameters that were considered in our experiments. We evaluated all the values given in the third column. The last one presents other parameters that were predetermined before evaluating the main parameter. \begin{table}[h] \caption{Summary of the parameters' values evaluated in the tuning experiments.} \centering \scalebox{0.8}{ \begin{tabular}{llll} Parameter & Description & Values & Other \\ \midrule $\lambda$ & intensity & \{1,10,100,1k\} & $\omega_{max} = \omega_{ADW}$, $\epsilon = \epsilon_{ADW}$ \\ $\omega_{max}$ & sliding window size & \{10,100,1k,10k\} & $\lambda=100$, $\epsilon = \epsilon_{ADW}$ \\ \hdashline $\alpha_e$ & elevating significance & \{0.01,0.05,0.1,0.2\} & \begin{tabular}[c]{@{}l@{}}$\lambda_{AHT}=\{1,1,1,10,10,10\},$ \\ $\lambda_{SGD}=100$ (both dynamic)\\ $\omega_{max} = \omega_{ADW}$, $\epsilon = \epsilon_{ADW}$\end{tabular}\\ \bottomrule \end{tabular}} \end{table} While the choice of the default value for $\omega_{max}$ and the input error $\epsilon$ was somehow justified theoretically and empirically \cite{Bifet:2007}, we chose $\lambda$ either arbitrarily for the initial tests ($\omega_{max}$), or based on empirical observations, for the experiments involving ensembles ($\alpha_e$), which should use reasonably tuned base learners. Due to significant differences, we decided to set individual $\lambda_{max}$ for both classifiers. Multiple values in the last column mean that different settings were used for different labeling budgets. In our experiments, we considered $B=\{50\%,20\%,10\%,5\%,1\%\}$ and $B=100\%$ where it was necessary, including the final comparison. In addition to the given fixed values, we used $\alpha_{\theta}=\{0.05, 0.1, 0.1, 0.2, 0.2\}$ and 0.002 for $B=100\%$ (its default value) in all cases. It is the only parameter that has to be set for ADWIN. For the final comparison, we extracted recommended default configurations, based on the obtained results. We present them after the tuning phase, at the beginning of the final evaluation. \medskip \noindent\textbf{Classifiers.} We used two different base learners: AHT and SGD, in order to show that our framework is, indeed, able to work as a flexible wrapper. Since these classifiers use completely different learning approaches, they seem to be good candidates for providing a more general insight. As our baseline (Base) we used AHT and SGD combined with RandVar (ALRV) -- the active learning strategy mentioned in Sec. \ref{sec:frame}. Due to the fact that we utilize the same algorithm as the default query strategy in our framework, the proposed methods differ from the baseline only by applying the exploitation strategy. During the final comparison, beside of the mentioned baseline, we tested two additional variants using other active learning approaches: random query (ALR) and selective sampling (ALS) \cite{Zliobaite:2014}. Furthermore, since our methods involve ensemble techniques, we compared them with some of the state-of-the-art committees for streaming data: online bagging (OBAG) \cite{Oza:2001}, incremental bagging with ADWIN (ABAG), adaptive online boosting (ADOB) \cite{Carvalho:2014}, DWM \cite{Kolter:2007}, LNSE \cite{Polikar:2011}, AUC \cite{Brzezinski:2014} (only for AHT due to the implementation constraints) and AWE \cite{Wang:2003} (only for SGD). It is worth noting that the given ensembles represent diverse approaches to adaptation, as mentioned in Sec. \ref{sec:streams}, which, to the best of our knowledge, have not been evaluated in the context of limited supervision. All of the mentioned classifiers used recommended parameter settings given in MOA. \medskip \noindent\textbf{Metrics.} Most of our experiments measured the predictive performance of the considered algorithms. For this purpose, we collected kappa values in two ways. The first one involved obtaining averaged global results for whole streams (aggregated predictions), based on the test-then-train procedure \cite{Gama:2014}. The second approach was focused on registering temporal performance within a sliding window, using the prequential evaluation technique \cite{Bifet:2015}. In the case of synthetic streams, it allowed us to distinguish between stable and drift periods, and to report them separately. It is important to keep in mind that the global average tends to be biased towards stable periods, which are longer in most of the streams. Due to this reason, we also reported the average of the two separated metrics, which is more balanced. Analogously to the discussion made in Sec. \ref{sec:dynamic}, we used the ADWIN-based metrics, as recommended in \cite{Bifet:2015}. In the final phase of the experiments, we employed the Bonferroni-Dunn rank test ($\alpha=0.05$) to analyze the statistical generalization and significance of results. Finally, we find more specific metrics used in this study self-explanatory. They are briefly introduced with their presentation. \subsection{Results and discussion} \label{sec:res} As we mentioned in the previous sections, the first part of the study presents different configurations and versions of the proposed algorithms, evaluated using fully controlled synthetic streams. It should provide the reader with some intuition about what to expect from those techniques under specific levels of supervision. After that, we proceed to the final evaluation and conclusions that can be drawn based on all the conducted experiments. \subsubsection{Intensity} \smallskip \noindent\textbf{Fixed intensity}. The first evaluation focused on studying how intense the instance exploitation should be, meaning, how many labeled instances from the sliding window should be sampled at each step, after receiving a new object. In Tab. \ref{tab:fix_gen} we can see kappa values averaged over all streams for the given budgets and both classifiers. One distinctive observation is that for different classifiers we can observe significantly different preferences. While with AHT majority of the best results were obtained for $\lambda < 100$, SGD worked best with the most intensive exploitation for $\lambda=1000$. It suggests that, in general, AHT better adapts to streams even under limited supervision, while SGD severely suffers from underfitting, leaving plenty of room for improvements. \begin{table}[h] \caption{Average kappa for AHT and SGD using fixed intensities.} \vspace*{-0.1cm} \centering \scalebox{0.8}{ \begin{subtable}{\textwidth}\leftskip-15pt \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{AHT}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule Base & 0.8556 & 0.8311 & 0.8103 & 0.7850 & 0.6916\\ \hdashline UW-1 & 0.8680 & 0.8446 & 0.8202 & 0.7944 & 0.7129\\ UW-10 & \textbf{0.8708} & \textbf{0.8533} & \textbf{0.8333} & 0.8115 & 0.7318\\ UW-100 & 0.8571 & 0.8428 & 0.8255 & \textbf{0.8144} & \textbf{0.7324}\\ UW-1k & 0.8359 & 0.8213 & 0.8022 & 0.7863 & 0.7059\\ \hdashline EW-1 & 0.8668 & 0.8461 & 0.8252 & 0.8008 & 0.7226\\ EW-10 & \textbf{0.8720} & \textbf{0.8567} & \textbf{0.8380} & \textbf{0.8280} & 0.7669\\ EW-100 & 0.8555 & 0.8427 & 0.8347 & 0.8191 & \textbf{0.7753}\\ EW-1k & 0.8445 & 0.8326 & 0.8184 & 0.8009 & 0.7559\\ \hdashline SE-1 & \textbf{0.8698} & \textbf{0.8420} & \textbf{0.8270} & \textbf{0.8040} & \textbf{0.7330}\\ SE-10 & 0.6763 & 0.6648 & 0.6631 & 0.6532 & 0.6630\\ SE-100 & 0.4128 & 0.3986 & 0.3901 & 0.3853 & 0.3799\\ SE-1k & 0.2438 & 0.2352 & 0.2289 & 0.2110 & 0.2295\\ \bottomrule \end{tabular} \hspace*{0.25cm} \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{SGD}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule Base & 0.4089 & 0.2892 & 0.2229 & 0.2018 & 0.1750\\ \hdashline UW-1 & 0.4734 & 0.3806 & 0.2933 & 0.2245 & 0.1731\\ UW-10 & 0.6047 & 0.5243 & 0.4721 & 0.4088 & 0.2401\\ UW-100 & 0.6854 & 0.6557 & 0.6252 & 0.5774 & 0.4350\\ UW-1k & \textbf{0.7069} & \textbf{0.6978} & \textbf{0.6826} & \textbf{0.6663} & \textbf{0.5573}\\ \hdashline EW-1 & 0.4774 & 0.3840 & 0.2944 & 0.2239 & 0.1812\\ EW-10 & 0.6078 & 0.5355 & 0.4798 & 0.4139 & 0.2259\\ EW-100 & 0.6934 & 0.6670 & 0.6372 & 0.5975 & 0.4532\\ EW-1k & \textbf{0.7148} & \textbf{0.7037} & \textbf{0.6955} & \textbf{0.6817} & \textbf{0.5943}\\ \hdashline SE-1 & 0.4791 & 0.3851 & 0.3002 & 0.2335 & 0.1786\\ SE-10 & 0.6143 & 0.5460 & 0.4866 & 0.4195 & 0.2310\\ SE-100 & \textbf{0.6824} & 0.6594 & 0.6341 & 0.5964 & 0.4594\\ SE-1k & 0.6760 & \textbf{0.6710} & \textbf{0.6654} & \textbf{0.6537} & \textbf{0.6024}\\ \bottomrule \end{tabular} \end{subtable}} \label{tab:fix_gen} \end{table} Another pattern that the results suggest is that for AHT using UW and EW there is a trend in relation between required intensity and the available labeling budget. Indeed, if we look closer and analyze Fig. \ref{fig:fix_gen_aht}, which presents the ratio between our strategies and the baseline, we will notice that as supervision is getting more and more limited, we gain more and more from exploiting the labeled instances we have (from about 1.05 to 1.2 on average). Furthermore, one should notice that for lower budgets below $B=10\%$, the difference between safer exploitation ($\lambda\leq10$) and more risky one ($\lambda\geq100$) becomes much more significant in favor of the latter approach. Finally, the gain that comes with applying the strategies is higher during drifts (1-1.4), when underfitting is more likely to occur regardless of the budget, than during stable periods (1.02-1.15). One can also notice that the EW strategy (in Fig. \ref{fig:fix_gen_aht}, the red line represents the best value for a given budget) was slightly better than UW, especially for the lowest budget $B=1\%$. It is not surprising since in such scenarios even a reactive sliding window may contain some relatively old instances, while it is more important to focus on the strictly limited amount of the most recent information. The EW strategy provides this additional focus. \begin{figure}[h] \centering \leftskip0pt\begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.98, ymax=1.17, ytick={1.0,1.05,1.1,1.15}, ymajorgrids=true, ylabel={UW / Base}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny] at (axis cs: 0.5,0.99) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,1.018998997689418) (1,1.0277155310039696) (2,1.0490074143381483) (3,1.0458012631631572) (4,1.1203560229371907)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.02173355983242) (1,1.03439822414923) (2,1.0412168064211) (3,1.05171352655329) (4,1.09805196307381)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.02835473749238) (1,1.03707722494688) (2,1.03862119501353) (3,1.04102472694165) (4,1.10136265161407)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.02063912500603) (1,1.01947973910339) (2,1.01661625065474) (3,1.01168288883821) (4,1.04304212107833)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.7}, line width=0.8pt ] coordinates {(0,1.02535090767702) (1,1.03900182353767) (2,1.04670071121853) (3,1.05881646158835) (4,1.15380172924896)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.9, ymax=1.5, ytick={1.0,1.2,1.4}, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\footnotesize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \node[font=\tiny] at (axis cs: 3.5,0.965) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,0.978399873420752) (1,1.00307544799404) (2,1.09019558397225) (3,1.18807525929443) (4,1.24260388463702)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.01673357060812) (1,1.05032751004499) (2,1.12840138307144) (3,1.26727481218819) (4,1.24920436139242)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.02325177069129) (1,1.05502341486412) (2,1.1170825176423) (3,1.23714027222904) (4,1.16031703711935)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.01404851775822) (1,1.02230476532372) (2,1.05195348426952) (3,1.06303060991769) (4,1.01898597092849)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.7}, line width=0.8pt ] coordinates {(0,1.03566061624146) (1,1.07400617693083) (2,1.15693553751837) (3,1.28790834393723) (4,1.37676286772662)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\footnotesize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny] at (axis cs: 3.5,0.985) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,0.99296050637618) (1,1.01093876040169) (2,1.05013863278576) (3,1.09092821442937) (4,1.12930728121526)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.01947145275659) (1,1.04145777760176) (2,1.07802410206436) (3,1.13579372927443) (4,1.15236739180079)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.02604604105512) (1,1.04503063151006) (2,1.07174573618256) (3,1.11752007143713) (4,1.12254744761912)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.0176573867221) (1,1.02073173644576) (2,1.03153480683573) (3,1.03171119208809) (4,1.03439773221355)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.7}, line width=0.8pt ] coordinates {(0,1.02988857371431) (1,1.05350829501919) (2,1.093239284871) (3,1.14616826317283) (4,1.23392106549886)}; \end{axis} \end{tikzpicture}% \end{subfigure}\\ \begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel={SE / Base}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny] at (axis cs: 0.5,0.95) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,0.327755764914704) (1,0.323871164248097) (2,0.321281218259916) (3,0.304846522153109) (4,0.37936784022744)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,0.521453475942921) (1,0.51645858599242) (2,0.517958289169789) (3,0.524652944955192) (4,0.58647781899406)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,0.812741809156096) (1,0.82305304675471) (2,0.841888126404002) (3,0.849666089331746) (4,0.987225801900935)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.01993236008648) (1,1.01457684233261) (2,1.02189483917661) (3,1.01860194702221) (4,1.06693240663554)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.25, ymax=1.35, ytick={0.4,0.6,0.8,1.0,1.2}, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\footnotesize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \node[font=\tiny] at (axis cs: 0.5,0.93) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,0.328498587034075) (1,0.349633234642019) (2,0.374702624628602) (3,0.352140813576666) (4,0.435265618614236)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,0.522750882266987) (1,0.544919848781614) (2,0.563950543327518) (3,0.645510063480793) (4,0.751383894786007)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,0.863736213854579) (1,0.888547153527287) (2,0.975482975242411) (3,1.1129838277361) (4,1.15802157409264)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.02075672660287) (1,1.03626817243876) (2,1.09968777058396) (3,1.17869577586247) (4,1.02397951672521)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\footnotesize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny] at (axis cs: 0.5,0.94) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,0.328091834273443) (1,0.33528841886855) (2,0.343834490563765) (3,0.323293775326298) (4,0.399454268439875)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,0.522040451613115) (1,0.529072070821672) (2,0.537375146613196) (3,0.571793557407912) (4,0.645735523840015)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,0.835812819616603) (1,0.852078776508872) (2,0.898288756957417) (3,0.952373812380902) (4,1.04859992295056)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.02030532195623) (1,1.02419002307047) (2,1.05473720115481) (3,1.0810469335774) (4,1.05149762256004)}; \end{axis} \end{tikzpicture} \end{subfigure}% \caption{Improvement over Base given a budget for AHT using fixed intensities: \mycircle{blue1} 1k, \mycircle{blue2} 100, \mycircle{blue3} 10, \mycircle{blue4} 1, \mytriangle{red2} best EW.} \label{fig:fix_gen_aht} \end{figure} \begin{figure}[h] \centering \leftskip0pt\begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.75, ymax=3.45, ymajorgrids=true, ylabel={UW / Base}, ylabel near ticks, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny] at (axis cs: 0.5,0.87) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,1.71483286001613) (1,2.25109597856433) (2,2.73427727332352) (3,3.12629150621111) (4,3.08962567597951)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.66933306741231) (1,2.12961255940472) (2,2.52679883811415) (3,2.7259556254465) (4,2.37625174787219)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.48974393175142) (1,1.69489562255845) (2,1.88865562162743) (3,1.90298147577507) (4,1.36145227325155)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.15254873811833) (1,1.23349973930064) (2,1.23683436091615) (3,1.16981410241866) (4,0.988921899817938)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.7}, line width=0.8pt ] coordinates {(0,1.72513581452955) (1,2.2546500326659) (2,2.76312189418025) (3,3.16977372320708) (4,3.25020809726809)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.6, ymax=3.7, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \node[font=\tiny] at (axis cs: 0.5,0.83) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,2.1815535284795) (1,3.02584870565871) (2,3.37879106631933) (3,3.28582639017075) (4,2.55621156703242)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,2.00147522951245) (1,2.62419793088778) (2,2.77145826139974) (3,2.51042110835616) (4,2.00615431425707)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.58456805176115) (1,1.89562389332268) (2,1.96179031992252) (3,1.69408768991993) (4,1.20511698172335)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.20681994969672) (1,1.30572932900629) (2,1.16028936391312) (3,1.03514733166859) (4,0.973570700491524)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.7}, line width=0.8pt ] coordinates {(0,2.19999853018682) (1,3.0807736963246) (2,3.46827328305367) (3,3.43592692127765) (4,2.89614349653329)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny] at (axis cs: 0.5,0.87) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,1.90106973434089) (1,2.54378717688883) (2,2.98680095036795) (3,3.19288128472758) (4,2.86641075682458)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.80186869799549) (1,2.31646028512497) (2,2.62265760461855) (3,2.63599162886171) (4,2.22137907514347)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.52758186976122) (1,1.77072807342046) (2,1.91731015646239) (3,1.81578931699255) (4,1.29603148877247)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.17420473386297) (1,1.26078711038835) (2,1.20684365425848) (3,1.11360426156627) (4,0.982497966406539)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.7}, line width=0.8pt ] coordinates {(0,1.91462163307825) (1,2.56674848243494) (2,3.0394036798091) (3,3.28086593119999) (4,3.10204459745995)}; \end{axis} \end{tikzpicture}% \end{subfigure}\\ \begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.75, ymax=3.45, ymajorgrids=true, ylabel={SE / Base}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \node[font=\tiny] at (axis cs: 0.5,0.87) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,1.62887645595342) (1,2.14173731912172) (2,2.63277356027865) (3,3.02480897073971) (4,3.30221387703675)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.64194954918135) (1,2.11028746619462) (2,2.5246343144027) (3,2.77942840561535) (4,2.48026537071541)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.50306339358714) (1,1.76416923359536) (2,1.93455674884306) (3,1.94310213727799) (4,1.38627379210424)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.16771327454983) (1,1.24097608471383) (2,1.23738001787601) (3,1.16738832497633) (4,1.03644294781513)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.6, ymax=3.7, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \node[font=\tiny] at (axis cs: 0.5,0.83) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,2.13259983901149) (1,2.99853283180654) (2,3.35549524148651) (3,3.3361008179447) (4,3.06455513560546)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,2.01481118005843) (1,2.63118640386282) (2,2.81978122407037) (3,2.64606094123038) (4,2.24761555066451)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.5956615580294) (1,1.99867088549332) (2,2.06217960878896) (3,1.77585554096561) (4,1.21118852413674)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.21969489344903) (1,1.3171383692083) (2,1.16030051083126) (3,1.04857835436021) (4,0.963507539831374)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny] at (axis cs: 0.5,0.89) {$Base$}; \addplot [ draw=blue1,smooth,mark=*,mark options={blue1,scale=0.7} ] coordinates {(0,1.82987862861034) (1,2.46542318243876) (2,2.91593947294288) (3,3.15474202766667) (4,3.20276210801669)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.79073358507761) (1,2.30707610460814) (2,2.64027432662206) (3,2.72376089457153) (4,2.382909657953)}; \addplot [ draw=blue3,smooth,mark=*,mark options={blue3,scale=0.7} ] coordinates {(0,1.54001310222274) (1,1.85276081527395) (2,1.98456001365864) (3,1.8732934939916) (4,1.31300680632516)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.18845564762279) (1,1.26974917519319) (2,1.20717988755259) (3,1.11779710434475) (4,1.00592206184014)}; \end{axis} \end{tikzpicture}% \end{subfigure} \caption{Improvement over Base given a budget for SGD using fixed intensities: \mycircle{blue1} 1k, \mycircle{blue2} 100, \mycircle{blue3} 10, \mycircle{blue4} 1, \mytriangle{red2} best EW.} \label{fig:fix_gen_sgd} \end{figure} Interestingly, in the case of AHT, the SE strategy was able to provide some small improvements (1-1.1 on average) only for lower budgets and only with $\lambda=1$, so when using the newest instance twice. It shows that this strategy may tend to overfit more than UW or EW as it focuses entirely on one instance without replaying a wider context of instances. Nevertheless, even with $\lambda=1$ the SE strategy provides competitive results for budgets higher than $B=5\%$, when exploitation becomes less important. Trends presented in Fig. \ref{fig:fix_gen_sgd} confirm that SGD requires much more attention that AHT, especially for lower budgets. One can easily see that the baseline using this classifier benefits enormously from employing instance exploitation. Regardless of a strategy used, our wrapper was able to improve the learning process 2-3 times over the baseline. The characteristic curvature of the trends comes from the fact that there is a sweet spot between possible improvements and available supervision. Analogously to the results for AHT, the EW strategy seems to be the best choice. \medskip \noindent\textbf{Dynamic intensity}. In our next experiment, we investigated if the proposed heuristic for controlling intensity in a dynamic way -- increasing it during drifts and decreasing for stable concepts, based on the current error -- may provide any improvements. Tab. \ref{tab:dyn_gen} presents the average performance of strategies using the dynamic control. We can see that general trends and relations remained the same for both classifiers. \begin{table}[h] \caption{Average kappa for AHT and SGD using dynamic intensities.} \vspace*{-0.1cm} \centering \scalebox{0.8}{ \begin{subtable}{\textwidth}\leftskip-15pt \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{AHT}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule Base & 0.8556 & 0.8311 & 0.8103 & 0.7850 & 0.6916\\ \hdashline UW-1 & \textbf{0.8677} & 0.8453 & 0.8203 & 0.7966 & 0.7092\\ UW-10 & 0.8763 & \textbf{0.8566} & \textbf{0.8391} & \textbf{0.8245} & \textbf{0.7500}\\ UW-100 & 0.8612 & 0.8431 & 0.8312 & 0.8060 & 0.7382\\ UW-1k & 0.8362 & 0.8240 & 0.8067 & 0.7831 & 0.7098\\ \hdashline EW-1 & 0.8652 & 0.8467 & 0.8230 & 0.7994 & 0.7187\\ EW-10 & \textbf{0.8774} & \textbf{0.8577} & \textbf{0.8431} & \textbf{0.8225} & 0.7596\\ EW-100 & 0.8621 & 0.8461 & 0.8358 & 0.8207 & \textbf{0.7674}\\ EW-1k & 0.8472 & 0.8320 & 0.8232 & 0.8018 & 0.7467\\ \hdashline SE-1 & \textbf{0.8668} & \textbf{0.8460} & \textbf{0.8263} & \textbf{0.8004} & \textbf{0.7201}\\ SE-10 & 0.7058 & 0.6969 & 0.6950 & 0.6852 & 0.6825\\ SE-100 & 0.4587 & 0.4418 & 0.4380 & 0.4328 & 0.4347\\ SE-1k & 0.3005 & 0.2872 & 0.2777 & 0.2773 & 0.2864\\ \bottomrule \end{tabular} \hspace*{0.25cm} \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{SGD}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule Base & 0.4089 & 0.2892 & 0.2229 & 0.2018 & 0.1750\\ \hdashline UW-1 & 0.4731 & 0.3810 & 0.2941 & 0.2339 & 0.1766\\ UW-10 & 0.5756 & 0.4924 & 0.4186 & 0.3337 & 0.1987\\ UW-100 & 0.6618 & 0.6292 & 0.5865 & 0.5382 & 0.3592\\ UW-1k & \textbf{0.7039} & \textbf{0.6888} & \textbf{0.6650} & \textbf{0.6394} & \textbf{0.5385}\\ \hdashline EW-1 & 0.4758 & 0.3819 & 0.2924 & 0.2292 & 0.1795\\ EW-10 & 0.5821 & 0.5020 & 0.4256 & 0.3393 & 0.1985\\ EW-100 & 0.6748 & 0.6361 & 0.5983 & 0.5547 & 0.3756\\ EW-1k & \textbf{0.7101} & \textbf{0.6950} & \textbf{0.6813} & \textbf{0.6601} & \textbf{0.5651}\\ \hdashline SE-1 & 0.4799 & 0.3816 & 0.2987 & 0.2276 & 0.1779\\ SE-10 & 0.5845 & 0.5059 & 0.4292 & 0.3423 & 0.1980\\ SE-100 & 0.6632 & 0.6309 & 0.5989 & 0.5547 & 0.3830\\ SE-1k & \textbf{0.6745} & \textbf{0.6655} & \textbf{0.6544} & \textbf{0.6361} & \textbf{0.5679}\\ \bottomrule \end{tabular} \end{subtable}} \label{tab:dyn_gen} \end{table} More useful information gives us Fig. {\ref{fig:gen_dyn_trade}} presenting the trade-off between obtained change in performance and computational time for less ($\lambda_{max}=\{1, 10\}$) and more risky ($\lambda_{max}=\{100, 1000\}$) exploitation, compared with its fixed-intensity counterparts. It is clear that those adjustments provide speed-up approximately proportional to the error used as the control signal (Eq. \ref{eq:lambda}). In the case of AHT, it is the most significant for the worst-performing risky SE (more than 2.5 times faster) and lower for more reliable strategies and configurations (1.2-1.6). For SGD the speed-up is extremely high (1.5-5.5) due to generally worse performance of the classifier. We can see that the speed-up for both base learners increases as budget gets smaller, since the performance gets worse on average when we limit supervision. \begin{figure}[h] \centering \leftskip20pt\begin{subfigure}{0.4\textwidth} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={AHT / EW}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0.65, ymajorgrids=true, ylabel={Improvement}, ylabel near ticks, ylabel style={font=\scriptsize, at={(-0.13,0.5)}}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, enlarge x limits={0.15}, legend cell align={left}, legend image post style={scale=0.7}, legend style={font=\scriptsize,column sep=0.5ex, legend columns=2, at={(0.05,0.95)}, anchor=north west, nodes={scale=0.7}, draw opacity=0.1}, legend entries={1-10 PERF, 1-10 TIME, 100-1k PERF, 100-1k TIME}, clip mode=individual ] \node[font=\tiny, shift={(0.67cm,0.0cm)}] at (axis cs: 50,1.05) {$Fix$}; \addplot [bar width=4pt, fill=blue2, draw=none] coordinates {(50,0.999596150905184) (20,1.00088121022185) (10,0.994358313119455) (5,0.994389325302087) (1,0.984708400138725)}; \addplot [bar width=4pt, fill=blue4, draw=none] coordinates {(50,1.20129727930037) (20,1.23332886074766) (10,1.28303703346197) (5,1.34828777384647) (1,1.63196664953622)}; \addplot [bar width=4pt, fill=red2, draw=none] coordinates {(50,1.00652733314413) (20,1.0010613577619) (10,1.00689097095556) (5,1.00081679623178) (1,0.984805379179393)}; \addplot [bar width=4pt, fill=red4, draw=none] coordinates {(50,1.20265586100045) (20,1.23363700181112) (10,1.25437435537883) (5,1.2987810600039) (1,1.46653637259363)}; \end{axis} \end{tikzpicture}% \hspace*{0.4cm} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={AHT / SE}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0.4, ymax=3.1, ymajorgrids=true, ylabel near ticks, ylabel style={font=\scriptsize}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, enlarge x limits={0.15}, ] \node[font=\tiny, shift={(0.67cm,0.0cm)}] at (axis cs: 50,1.13) {$Fix$}; \addplot [bar width=4pt, fill=blue2, draw=none] coordinates {(50,1.01588242499491) (20,1.01924789603554) (10,1.02158367420729) (5,1.01311600991915) (1,1.01575106206426)}; \addplot [bar width=4pt, fill=blue4, draw=none] coordinates {(50,1.30718237731729) (20,1.34509738591202) (10,1.36945667909816) (5,1.43225374011569) (1,1.65050798201843)}; \addplot [bar width=4pt, fill=red2, draw=none] coordinates {(50,1.17853271262723) (20,1.15958262193215) (10,1.17004529944882) (5,1.2469291497342) (1,1.21849249055887)}; \addplot [bar width=4pt, fill=red4, draw=none] coordinates {(50,2.48014227082559) (20,2.5817523844745) (10,2.65270439024902) (5,2.70829654729361) (1,2.80526909294148)}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={SGD / EW}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=1.2, ymajorgrids=true, ylabel={Improvement (log)}, ylabel near ticks, ylabel style={font=\scriptsize}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, /tikz/.cd }, extra y ticks=2.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, ymode=log, log basis y={10}, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, enlarge x limits={0.15}, clip mode=individual ] \node[font=\tiny, shift={(0.67cm,0.0cm)}] at (axis cs: 50,2.15) {$Fix$}; \addplot [bar width=4pt, fill=blue2, draw=none] coordinates {(50,1.963702172650874) (20,1.958470345220187) (10,1.937267724746455) (5,1.902063845546036) (1,1.930053674519836)}; \addplot [bar width=4pt, fill=blue4, draw=none] coordinates {(50,2.78458666227384) (20,3.07329909731747) (10,3.51599105855485) (5,4.1887364018789) (1,6.40270966669437)}; \addplot [bar width=4pt, fill=red2, draw=none] coordinates {(50,1.977765857691693) (20,1.960372925560755) (10,1.947050077695957) (5,1.929460433137187) (1,1.865401084535496)}; \addplot [bar width=4pt, fill=red4, draw=none] coordinates {(50,2.42844585091421) (20,2.48352714284084) (10,2.53663394424383) (5,2.60614783973116) (1,3.02966432474629)}; \end{axis} \end{tikzpicture}% \hspace*{0.2cm} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={SGD / SE}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=1.2, ymajorgrids=true, ylabel near ticks, ylabel style={font=\scriptsize}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, /tikz/.cd }, extra y ticks=2.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, ymode=log, log basis y={10}, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, enlarge x limits={0.15}, clip mode=individual, ] \node[font=\tiny, shift={(0.67cm,0.0cm)}] at (axis cs: 50,2.15) {$Fix$}; \addplot [bar width=4pt, fill=blue2, draw=none] coordinates {(50,1.965107622358298) (20,1.954351762952433) (10,1.932440727696415) (5,1.89736840930171) (1,1.90152346591575)}; \addplot [bar width=4pt, fill=blue4, draw=none] coordinates {(50,2.77548330704252) (20,3.06726564363521) (10,3.47574248469325) (5,4.17572766913803) (1,6.34836360644272)}; \addplot [bar width=4pt, fill=red2, draw=none] coordinates {(50,1.973913173401006) (20,1.962651118427877) (10,1.950719396351632) (5,1.940530987457339) (1,1.870394201349555)}; \addplot [bar width=4pt, fill=red4, draw=none] coordinates {(50,2.47159537919051) (20,2.51793793969116) (10,2.56267843083044) (5,2.63027802510628) (1,2.98273495409206)}; \end{axis} \end{tikzpicture} \end{subfigure} \caption{Trade-off between performance and time-consumption for AHT and SGD using dynamic intensity (vs. fixed).} \label{fig:gen_dyn_trade} \end{figure} On the other hand, one should notice that the mentioned improvement of running time comes at some cost of predictive performance. It is significant for SGD, especially on very low budgets (about 0.9 of the kappa obtained for fixed intensity), but barely noticeable for AHT with $B\leq10\%$ (0.98 at most) and practically negligible for higher budgets. In fact, it even provided some improvements for SE, which exhibited the worst performance so far (which we can most likely attribute to overfitting). The explanation of these observations is simple -- since the dynamic control may only lower intensity and since SGD gained a substantial amount of enhancement by enabling very intensive instance exploitation, any reduction of it will cause drops in obtained improvements. Due to the fact that AHT is less reliant on our strategies, its adaptation will be impaired to a lesser extent. \subsubsection{Instance window} \smallskip \noindent\textbf{Fixed window size}. In this subsection, we investigate how the size of a sliding window of labeled instances should be configured in order to provide necessary reactivity to new concepts and better performance as a consequence. The average results presented in Tab. \ref{tab:fix_win} definitely outline an easily visible trend for both classifiers -- the less labeled data we have, the smaller sliding window should be used. \begin{table}[h] \caption{Average kappa for AHT and SGD using fixed sliding windows.} \vspace*{-0.1cm} \centering \scalebox{0.8}{ \begin{subtable}{\textwidth}\leftskip-15pt \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{AHT}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule UW-10 & 0.4966 & 0.4918 & 0.4887 & 0.4867 & 0.4864\\ UW-100 & 0.7340 & 0.7319 & 0.7286 & 0.7195 & \textbf{0.7054}\\ UW-1k & 0.8169 & \textbf{0.8093} & \textbf{0.7991} & \textbf{0.7713} & 0.6563\\ UW-10k & \textbf{0.8323} & 0.7921 & 0.7220 & 0.6170 & 0.5323\\ \hdashline EW-10 & 0.4752 & 0.4695 & 0.4641 & 0.4629 & 0.4534\\ EW-100 & 0.7060 & 0.7053 & 0.7040 & 0.7027 & 0.6860\\ EW-1k & 0.8142 & 0.8062 & \textbf{0.7981} & \textbf{0.7818} & \textbf{0.7065}\\ EW-10k & \textbf{0.8446} & \textbf{0.8230} & 0.7786 & 0.7174 & 0.5618\\ \bottomrule \end{tabular} \hspace*{0.25cm} \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{SGD}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule UW-10 & 0.6871 & 0.6650 & 0.6386 & 0.6018 & 0.4691\\ UW-100 & 0.6929 & \textbf{0.6706} & \textbf{0.6443} & \textbf{0.6084} & \textbf{0.4697}\\ UW-1k & \textbf{0.6953} & 0.6703 & 0.6400 & 0.5941 & 0.4117\\ UW-10k & 0.6780 & 0.6275 & 0.5567 & 0.4614 & 0.2631\\ \hdashline EW-10 & 0.6857 & 0.6634 & 0.6376 & 0.6022 & 0.4694\\ EW-100 & 0.6918 & 0.6697 & 0.6432 & \textbf{0.6078} & \textbf{0.4731}\\ EW-1k & \textbf{0.6952} & \textbf{0.6718} & \textbf{0.6435} & 0.6032 & 0.4505\\ EW-10k & 0.6878 & 0.6512 & 0.6035 & 0.5349 & 0.3188\\ \bottomrule \end{tabular} \end{subtable}} \label{tab:fix_win} \end{table} The differences between considered sizes for a given budget are more significant and dynamic for AHT, which is visualized in Fig. \ref{fig:fix_win_aht} showing obtained kappa for both UW and EW. It is clear and intuitive that larger windows ($\omega_{max}=10 000$ and $\omega_{max}=1000$) are more reliable when we have more labeled data and when concepts are stable, since more labeled instances will better generalize a given problem and help prevent overfitting. Once we limit the available supervision, the rate of changes between subsequent instances is more likely to increase (Sec. \ref{sec:risky}). Therefore, in order to keep the representation of current concepts up-to-date we need to replace older instances with newer ones faster, so the window size should be smaller. For example, we can see that while $\omega_{max}=10 000$ is the optimal size if we can label half of a whole stream, it becomes completely useless once we limit the budget to $B=1\%$, when even $\omega_{max}=1000$ becomes less adequate than $\omega_{max}=100$. An observation that the size has to be even smaller for drifting concepts is not surprising -- the problem of developing reactive windows for drifting data has been already covered in many related publications \cite{Bifet:2007}. \begin{figure}[h] \centering \leftskip0pt\begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.55, ymax=0.95, ytick={0.6, 0.7, 0.8, 0.9}, ymajorgrids=true, ylabel={UW}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.8864) (1,0.8443) (2,0.7756) (3,0.6611) (4,0.5739)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.8663) (1,0.8596) (2,0.8524) (3,0.8244) (4,0.7063)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.7883) (1,0.7877) (2,0.7839) (3,0.7744) (4,0.7677)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.5470) (1,0.5406) (2,0.5369) (3,0.5343) (4,0.5382)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.8},line width=0.8pt ] coordinates {(0,0.8927) (1,0.8743) (2,0.8481) (3,0.8329) (4,0.7578)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.5648) (1,0.5395) (2,0.5130) (3,0.4971) (4,0.4386)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.6891) (1,0.6437) (2,0.5719) (3,0.5129) (4,0.4424)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.6732) (1,0.6562) (2,0.6381) (3,0.6057) (4,0.4578)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.4646) (1,0.4624) (2,0.4629) (3,0.4479) (4,0.4012)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.7},line width=0.8pt ] coordinates {(0,0.7126) (1,0.6779) (2,0.6367) (3,0.6034) (4,0.4870)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymax=0.85, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.7256) (1,0.6919) (2,0.6443) (3,0.5791) (4,0.5063)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.7777) (1,0.7516) (2,0.7121) (3,0.6687) (4,0.5744)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.7307) (1,0.7220) (2,0.7110) (3,0.6901) (4,0.6128)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.5058) (1,0.5015) (2,0.4999) (3,0.4911) (4,0.4697)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.7},line width=0.8pt ] coordinates {(0,0.7877) (1,0.7663) (2,0.7424) (3,0.7091) (4,0.6156)}; \end{axis} \end{tikzpicture}% \end{subfigure}\\ \begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.55, ymax=0.95, ytick={0.6, 0.7, 0.8, 0.9}, ymajorgrids=true, ylabel={EW}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.8927) (1,0.8743) (2,0.8344) (3,0.7686) (4,0.5951)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.8629) (1,0.8548) (2,0.8481) (3,0.8329) (4,0.7578)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.7594) (1,0.7588) (2,0.7578) (3,0.7572) (4,0.7443)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.5263) (1,0.5194) (2,0.5130) (3,0.5130) (4,0.5046)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.6259) (1,0.5656) (2,0.5335) (3,0.5047) (4,0.4486)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.7126) (1,0.6779) (2,0.6367) (3,0.5854) (4,0.4613)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.6477) (1,0.6433) (2,0.6310) (3,0.6034) (4,0.4870)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.4480) (1,0.4400) (2,0.4286) (3,0.4203) (4,0.3780)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.35, ymax=0.85, ytick={0.4,0.5,0.6,0.7,0.8}, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.7593) (1,0.7200) (2,0.6840) (3,0.6367) (4,0.5219)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.7877) (1,0.7663) (2,0.7424) (3,0.7091) (4,0.6095)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.7035) (1,0.7010) (2,0.6944) (3,0.6803) (4,0.6156)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.4871) (1,0.4797) (2,0.4708) (3,0.4667) (4,0.4413)}; \end{axis} \end{tikzpicture}% \end{subfigure} \caption{Average kappa given a budget for AHT using fixed sliding windows: \mycircle{red1} 10k, \mycircle{red2} 1k, \mycircle{red3} 100, \mycircle{red4} 10, \mytriangle{blue2} best EW.} \label{fig:fix_win_aht} \end{figure} \begin{figure}[h] \centering \leftskip0pt\begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.15, ytick={0.2, 0.35, 0.5, 0.65}, ymajorgrids=true, ylabel={UW}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.6832) (1,0.6384) (2,0.5682) (3,0.4632) (4,0.2613)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.6889) (1,0.6700) (2,0.6463) (3,0.6023) (4,0.4125)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.6846) (1,0.6669) (2,0.6453) (3,0.6124) (4,0.4741)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.6778) (1,0.6603) (2,0.6390) (3,0.6053) (4,0.4710)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.7},line width=0.8pt ] coordinates {(0,0.6876) (1,0.6695) (2,0.6461) (3,0.6114) (4,0.4756)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.13, ymax=0.58, ytick={0.2,0.3,0.4,0.5}, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.4055) (1,0.3554) (2,0.3301) (3,0.3082) (4,0.2324)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.5357) (1,0.4623) (2,0.3884) (3,0.3465) (4,0.2627)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.5536) (1,0.5041) (2,0.4590) (3,0.4072) (4,0.3005)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.5503) (1,0.5021) (2,0.4566) (3,0.4151) (4,0.3120)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.7},line width=0.8pt ] coordinates {(0,0.5558) (1,0.5066) (2,0.4612) (3,0.4132) (4,0.3100)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.15, ymax=0.7, ytick={0.2, 0.35, 0.5, 0.65}, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.5443) (1,0.4969) (2,0.4492) (3,0.3857) (4,0.2469)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.6123) (1,0.5662) (2,0.5173) (3,0.4744) (4,0.3376)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.6191) (1,0.5855) (2,0.5521) (3,0.5098) (4,0.3873)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.6141) (1,0.5812) (2,0.5478) (3,0.5102) (4,0.3915)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.7},line width=0.8pt ] coordinates {(0,0.6194) (1,0.5861) (2,0.5522) (3,0.5123) (4,0.3928)}; \end{axis} \end{tikzpicture} \end{subfigure}\\ \begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.15, ytick={0.2, 0.35, 0.5, 0.65}, ymajorgrids=true, ylabel={EW}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.6868) (1,0.6569) (2,0.6116) (3,0.5407) (4,0.3111)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.6876) (1,0.6695) (2,0.6461) (3,0.6090) (4,0.4539)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.6831) (1,0.6656) (2,0.6431) (3,0.6114) (4,0.4756)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.6761) (1,0.6590) (2,0.6374) (3,0.6049) (4,0.4689)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.4700) (1,0.3888) (2,0.3544) (3,0.3230) (4,0.2499)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.5479) (1,0.4873) (2,0.4310) (3,0.3725) (4,0.2707)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.5558) (1,0.5066) (2,0.4612) (3,0.4132) (4,0.3100)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.5498) (1,0.5016) (2,0.4549) (3,0.4124) (4,0.3090)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.24,0.5)}}, extra y ticks=1.0, extra y tick labels={}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \addplot [ draw=red1,smooth,mark=*,mark options={red1,scale=0.7} ] coordinates {(0,0.5784) (1,0.5228) (2,0.4830) (3,0.4319) (4,0.2805)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,0.6178) (1,0.5784) (2,0.5386) (3,0.4908) (4,0.3623)}; \addplot [ draw=red3,smooth,mark=*,mark options={red3,scale=0.7} ] coordinates {(0,0.6194) (1,0.5861) (2,0.5522) (3,0.5123) (4,0.3928)}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,0.6130) (1,0.5803) (2,0.5462) (3,0.5086) (4,0.3890)}; \end{axis} \end{tikzpicture}% \end{subfigure} \caption{Average kappa given a budget for SGD using fixed sliding windows: \mycircle{red1} 10k, \mycircle{red2} 1k, \mycircle{red3} 100, \mycircle{red4} 10, \mytriangle{blue2} best EW.} \label{fig:fix_win_sgd} \end{figure} In the case of SGD, the differences between window sizes are slightly smaller (Fig. \ref{fig:fix_win_sgd}), since the overall performance of this classifier is predominantly reliant on a proper choice of the level of intensity. Also, it seems that SGD works best with $\omega_{max}\leq100$, which suggests that it prefers intensive updates based on the most recent data. Finally, for both classifiers, the EW strategy was able to reduce the negative impact of too large window sizes for smaller budgets -- one can notice that the curves for $\omega_{max}=10000$ and $\omega_{max}=1000$ are slightly elevated compared with UW. The reason for that is the inherent focus of EW on the most recent instances, which alleviates the problem of storing too old instances, which we assumed in Sec. \ref{sec:strategies}. Regardless of that, we did not find any significant difference between EW and UW in this experiment, which suggests that intensity is a more impactful factor. \medskip \noindent\textbf{Dynamic window size}. Analogously to the experiments focused on intensity, we studied the impact of controlling the window size in a dynamic way. In Tab. \ref{tab:dyn_win} one can see that while the general trends and relations remain, again, unchanged, using the size returned by ADWIN is definitely the most reliable solution for AHT, providing from 0.02 to more than 0.15 higher kappa values than any other window. For SGD differences between smaller sizes and ADWIN are hardly significant for $B \geq 20\%$ and in favor of the former for $B \leq 10\%$. \begin{table}[b] \caption{Average kappa for AHT and SGD using dynamic sliding windows.} \vspace*{-0.1cm} \centering \scalebox{0.8}{ \begin{subtable}{\textwidth}\leftskip-30pt \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{AHT}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule UW-10 & 0.4439 & 0.4295 & 0.4350 & 0.4281 & 0.4263\\ UW-100 & 0.7161 & 0.7128 & 0.7102 & 0.7068 & 0.6896\\ UW-1k & 0.8161 & 0.8104 & 0.7988 & 0.7845 & 0.6976\\ UW-10k & 0.8416 & 0.8078 & 0.7651 & 0.6896 & 0.5585\\ UW-ADW & \textbf{0.8603} & \textbf{0.8452} & \textbf{0.8243} & \textbf{0.8098} & \textbf{0.7418}\\ \hdashline EW-10 & 0.4424 & 0.4252 & 0.4235 & 0.4259 & 0.4250\\ EW-100 & 0.6798 & 0.6779 & 0.6778 & 0.6748 & 0.6730\\ EW-1k & 0.8081 & 0.8062 & 0.7985 & 0.7919 & 0.7356\\ EW-10k & 0.8502 & 0.8306 & 0.8068 & 0.7557 & 0.6209\\ EW-ADW & \textbf{0.8598} & \textbf{0.8483} & \textbf{0.8312} & \textbf{0.8202} & \textbf{0.7717}\\ \bottomrule \end{tabular} \hspace*{0.25cm} \begin{tabular}[H]{l >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm} >{\centering\arraybackslash} m{1.1cm}} \textbf{SGD}& $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule UW-10 & 0.6864 & 0.6642 & 0.6395 & 0.6023 & 0.4664\\ UW-100 & 0.6940 & 0.6717 & \textbf{0.6459} & \textbf{0.6088} & \textbf{0.4712}\\ UW-1k & \textbf{0.6966} & \textbf{0.6730} & 0.6451 & 0.6041 & 0.4467\\ UW-10k & 0.6831 & 0.6418 & 0.5887 & 0.5154 & 0.3180\\ UW-ADW & 0.6892 & 0.6568 & 0.6275 & 0.5799 & 0.4379\\ \hdashline EW-10 & 0.6851 & 0.6631 & 0.6373 & 0.6003 & 0.4679\\ EW-100 & 0.6918 & 0.6694 & 0.6445 & 0.6065 & \textbf{0.4731}\\ EW-1k & \textbf{0.6966} & \textbf{0.6731} & \textbf{0.6474} & \textbf{0.6072} & 0.4643\\ EW-10k & 0.6908 & 0.6594 & 0.6208 & 0.5631 & 0.3823\\ EW-ADW & 0.6941 & 0.6682 & 0.6380 & 0.5968 & 0.4572\\ \bottomrule \end{tabular} \end{subtable}} \label{tab:dyn_win} \end{table} The trade-off between the quality of classification and memory consumption is presented in Fig. \ref{fig:win_dyn_trade}. The results for EW (UW exhibits analogous characteristics) show that while combining the dynamic adjustments with smaller windows we can use less memory (about 1.4-1.7 times less) at a cost of impaired performance (about 0.94), doing the same with larger windows results in improving both (about 1.1-1.7 for memory and 1.01-1.05 for kappa). It is intuitive, since the shrinking heuristic (Eq. \ref{eq:omega}), by making the small windows (containing 10-100 instances) even smaller, will more likely increase a chance of overfitting than efficiently improve reactivity. On the other hand, making too large windows more flexible provides enhanced reactivity to new concepts without too significant loss in generalization, especially for smaller budgets $B\leq10\%$ for which concepts evolve at a higher rate. \begin{figure}[h] \centering \leftskip15pt\begin{subfigure}{0.4\textwidth} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={AHT / EW}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0.7, ymax=1.9, ymajorgrids=true, ylabel={Improvement}, ylabel near ticks, ylabel style={font=\scriptsize}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, clip mode=individual, enlarge x limits={0.15}, legend cell align={left}, legend image post style={scale=0.7}, legend style={font=\scriptsize,column sep=0.5ex, legend columns=2, at={(0.05,0.95)}, anchor=north west, nodes={scale=0.75}, draw opacity=0.1}, legend entries={10-100 PERF, 10-100 MEM, 1k-10k PERF, 1k-10k MEM} ] \node[font=\tiny, shift={(0.7cm,0.0cm)}] at (axis cs: 50, 1.05) {$Fix$}; \addplot [bar width=4pt, fill=blue2, draw=none] coordinates {(50,0.94571396600022) (20,0.930954802315649) (10,0.938624007228922) (5,0.949166352334759) (1,0.960896349218413)}; \addplot [bar width=4pt, fill=blue4, draw=none] coordinates {(50,1.44739098375749) (20,1.44573978586891) (10,1.44879613005496) (5,1.4482458379837) (1,1.45347474700451)}; \addplot [bar width=4pt, fill=red2, draw=none] coordinates {(50,1.01487498199656) (20,1.01908104111032) (10,1.02745152701351) (5,1.03819825650222) (1,1.05729585518725)}; \addplot [bar width=4pt, fill=red4, draw=none] coordinates {(50,1.11208498504937) (20,1.12077869842001) (10,1.13398190323755) (5,1.15780775315885) (1,1.25454630002006)}; \end{axis} \end{tikzpicture}% \hspace*{0.2cm} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={AHT / EW-ADW}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0.2, ymax=2.2, ytick={0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2.1}, ymajorgrids=true, ylabel near ticks, ylabel style={font=\scriptsize}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, enlarge x limits={0.15}, clip mode=individual, legend cell align={left}, legend image post style={scale=0.7}, legend style={font=\scriptsize,column sep=0.5ex, legend columns=2, at={(0.05,0.95)}, anchor=north west, nodes={scale=0.75}, draw opacity=0.1}, legend entries={ADW PERF, ADW MEM} ] \node[font=\tiny, shift={(0.5cm,0.0cm)}] at (axis cs: 50, 1.08) {$Fix$}; \addplot [bar width=4pt, fill=green2, draw=none] coordinates {(50,1.0616998090226) (20,1.0686114212596) (10,1.07266729358845) (5,1.1024933349337) (1,1.11179251177111)}; \addplot [bar width=4pt, fill=green4, draw=none] coordinates {(50,0.373084236837807) (20,0.709938871900499) (10,1.14203157930311) (5,1.70143194992726) (1,1.90308166404234)}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={SGD / EW}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0.7, ymajorgrids=true, ylabel={Improvement}, ylabel near ticks, ylabel style={font=\scriptsize}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, enlarge x limits={0.15}, clip mode=individual ] \node[font=\tiny, shift={(0.7cm,0.0cm)}] at (axis cs: 50, 1.05) {$Fix$}; \addplot [bar width=4pt, fill=blue2, draw=none] coordinates {(50,0.998446830641616) (20,0.999428009274032) (10,1.002778874198) (5,1.00041484860534) (1,0.996949006582305)}; \addplot [bar width=4pt, fill=blue4, draw=none] coordinates {(50,1.40930039426965) (20,1.43593450187205) (10,1.46903125571606) (5,1.50932961505217) (1,1.69441570476055)}; \addplot [bar width=4pt, fill=red2, draw=none] coordinates {(50,1.01673032959242) (20,1.02775517652381) (10,1.02840765873539) (5,1.03763640484149) (1,1.11675106608308)}; \addplot [bar width=4pt, fill=red4, draw=none] coordinates {(50,1.35071291136052) (20,1.37862300681295) (10,1.41188421615588) (5,1.46306687232385) (1,1.69465759277365)}; \end{axis} \end{tikzpicture}% \hspace*{0.2cm} \begin{tikzpicture} \begin{axis}[ ybar, title style={yshift=-0.5ex}, title={SGD / EW-ADW}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0.2, ymajorgrids=true, ylabel near ticks, ylabel style={font=\scriptsize}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, symbolic x coords={50,20,10,5,1}, xtick=data, enlarge x limits={0.15}, clip mode=individual ] \node[font=\tiny, shift={(0.5cm,0.0cm)}] at (axis cs: 50, 1.1) {$Fix$}; \addplot [bar width=4pt, fill=green2, draw=none] coordinates {(50,1.04209435782583) (20,1.07331914266605) (10,1.09813542793405) (5,1.11718413071174) (1,1.11981151051368)}; \addplot [bar width=4pt, fill=green4, draw=none] coordinates {(50,0.29109294938429) (20,0.679699113636252) (10,1.08189543561764) (5,1.87623073044891) (1,2.4882381336009)}; \end{axis} \end{tikzpicture} \end{subfigure} \caption{Trade-off between performance and memory given a budget for AHT and SGD using dynamic windows (vs. fixed).} \label{fig:win_dyn_trade} \end{figure} When it comes to using a window size based on ADWIN, beside of the good predictive performance, we also observed that this approach tends to aggregate relatively large amounts of instances, especially for high budgets. Since there is no fixed counterpart for ADWIN, in Fig. \ref{fig:win_dyn_trade} we present a ratio between ADWIN and a standard window storing a comparable number of instances, which was $\omega_{max}=10000$. Based on that, we can see that the ADWIN-driven control provides the presented performance at a quite relevant memory cost, which decreases with the budget. It is also important that even if ADWIN stores plenty of instances, it maintains a good quality of classification regardless of the number of labeled instances, doing it better than $\omega_{max}=10000$ and $\omega_{max}=1000$ for AHT and competitively for SGD. \subsubsection{Elevating significance} In the final section of the first part of the experiments, we analyze the significance level $\alpha_e$, which is the only parameter that has to be set for the elevating strategy. Simultaneously, we also use this section to investigate the potential usefulness of the proposed ensemble techniques. All results for the elevating ensemble (EWE, SEE) using different $\alpha_e$ along with results for the switching committee (EWS, SES), baseline and single-classifier exploitation methods (EW, SE) are presented in Fig. \ref{tab:sign_perf}. Since EW performed at least as good as UW in all previous evaluations, we decided to omit it in the rest of the study. \begin{table}[b] \caption{Average kappa for AHT and SGD ensembles compared with Base and single-classifier models.} \vspace*{-0.1cm} \centering \scalebox{0.8}{ \begin{subtable}{\textwidth}\leftskip-45pt \begin{tabular}[H]{l >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm}} \textbf{AHT}& $100\%$ & $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule Base & 0.8673 & 0.8556 & 0.8311 & 0.8103 & 0.7850 & 0.6916\\ \hdashline EW & 0.8779 & 0.8636 & 0.8425 & 0.8402 & 0.8226 & 0.7560\\ EWS & 0.8798 & 0.8691 & 0.8457 & 0.8478 & 0.8318 & 0.7612\\ EWE-1 & 0.8795 & 0.8704 & 0.8451 & 0.8523 & 0.8301 & 0.7604\\ EWE-5 & 0.8787 & 0.8677 & 0.8440 & 0.8462 & 0.8272 & 0.7611\\ EWE-10 & 0.8793 & 0.8706 & 0.8462 & 0.8463 & 0.8323 & 0.7599\\ EWE-20 & 0.8796 & 0.8697 & 0.8449 & 0.8527 & 0.8286 & 0.7556\\ \hdashline SE & 0.8768 & 0.8695 & 0.8459 & 0.6914 & 0.6856 & 0.6800\\ SES & 0.8800 & 0.8698 & 0.8470 & 0.8136 & 0.7919 & 0.7394\\ SEE-1 & 0.8817 & 0.8737 & 0.8457 & 0.8189 & 0.7983 & 0.7472\\ SEE-5 & 0.8819 & 0.8697 & 0.8424 & 0.8174 & 0.8022 & 0.7485\\ SEE-10 & 0.8782 & 0.8687 & 0.8441 & 0.8238 & 0.7966 & 0.7573\\ SEE-20 & 0.8808 & 0.8692 & 0.8450 & 0.8205 & 0.8018 & 0.7480\\ \bottomrule \end{tabular}% \hspace*{0.15cm} \begin{tabular}[H]{l >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm}} \textbf{SGD}& $100\%$ & $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule Base & 0.4772 & 0.4089 & 0.2892 & 0.2229 & 0.2018 & 0.1750\\ \hdashline EW & 0.7026 & 0.6752 & 0.6424 & 0.6020 & 0.5621 & 0.3707\\ EWS & 0.7027 & 0.6723 & 0.6415 & 0.6005 & 0.5508 & 0.3779\\ EWE-1 & 0.7030 & 0.6720 & 0.6365 & 0.5980 & 0.5536 & 0.3788\\ EWE-5 & 0.7028 & 0.6722 & 0.6401 & 0.5980 & 0.5530 & 0.3767\\ EWE-10 & 0.7025 & 0.6730 & 0.6389 & 0.5985 & 0.5503 & 0.3761\\ EWE-20 & 0.7023 & 0.6700 & 0.6371 & 0.5926 & 0.5532 & 0.3793\\ \hdashline SE & 0.6913 & 0.6632 & 0.6311 & 0.5987 & 0.5543 & 0.3813\\ SES & 0.6953 & 0.6643 & 0.6311 & 0.5994 & 0.5551 & 0.3810\\ SEE-1 & 0.7001 & 0.6687 & 0.6325 & 0.6020 & 0.5576 & 0.3799\\ SEE-5 & 0.6995 & 0.6697 & 0.6385 & 0.6008 & 0.5564 & 0.3824\\ SEE-10 & 0.6994 & 0.6692 & 0.6309 & 0.6006 & 0.5566 & 0.3846\\ SEE-20 & 0.6986 & 0.6695 & 0.6320 & 0.5977 & 0.5564 & 0.3810\\ \bottomrule \end{tabular} \end{subtable}} \label{tab:sign_perf} \end{table} The presented results clearly indicate that there is no significant difference when changing the $\alpha_e$ value. Furthermore, it seems that for synthetic streams the ensemble methods were not able to provide significant improvements over tuned EW or SE for both classifiers. The only exception is for SE for which we purposely set nonoptimal intensity $\lambda_{max}=10$, slightly higher than previously obtained results suggested. This allowed us to check whether the ensembles are able to surpass the ineffective exploitation strategy by using the alternative standard base learner when it is needed. In Fig. \ref{fig:sign_aht} we can see that, indeed, improperly configured SE failed for budgets $B\leq10\%$, performing worse than the baseline for stable concepts by leading to overfitting. However, when combined with switching or elevating, the whole method was able to achieve performance at least as good as the baseline, or even to improve upon it for $B\leq5\%$. In addition, the ensembles boosted adaptation during concept drifts (by about 0.1), which is a very important observation, since dealing with changes under strictly limited supervision is an extremely challenging task. \begin{figure}[h] \centering \leftskip0pt\begin{subfigure}{0.33\textwidth} \begin{tikzpicture} \begin{axis} [ title={STABLE}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.75, ymajorgrids=true, ylabel={SE / Base}, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize, at={(-0.15,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={100,50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, legend cell align={left}, legend style={font=\scriptsize,column sep=0.5ex, legend columns=1, at={(0.05,0.4)}, draw opacity=0.1, anchor=north west, nodes={scale=0.75}}, legend entries={SE,SES,SEE} ] \node[font=\tiny, shift={(0.45cm,0.0cm)}] at (axis cs: 0, 0.975) {$Base$}; \addplot [ draw=green3,smooth,mark=triangle*,mark options={green3,scale=0.8} ] coordinates {(0,1.01216038027493) (1,1.01705078039078) (2,1.01663886932884) (3,0.871392848007827) (4,0.88639972272552) (5,0.999999952862728)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,1.01498185602007) (1,1.01840987800054) (2,1.01869976720405) (3,1.0008907586278) (4,1.005966947519) (5,1.07597699077145)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.01775417252337) (1,1.01915018967809) (2,1.01378704651466) (3,1.0104450698465) (4,1.02201144767867) (5,1.09778248061905)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={DRIFT}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\footnotesize, at={(-0.25,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={100,50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \node[font=\tiny, shift={(0.0cm,0.0cm)}] at (axis cs: 4.5, 1.018) {$Base$}; \addplot [ draw=green3,smooth,mark=triangle*,mark options={green3,scale=0.8} ] coordinates {(0,1.02093313415123) (1,1.02139346487853) (2,1.04589579097367) (3,1.001827145207) (4,1.14123023374736) (5,1.24922976337359)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,1.02409000047476) (1,1.02933897094219) (2,1.04785007033546) (3,1.10281080574929) (4,1.20618707177811) (5,1.28668337858036)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.02413730423941) (1,1.03193747774953) (2,1.04417985709001) (3,1.11741060461493) (4,1.23524770765055) (5,1.28070676330874)}; \end{axis} \end{tikzpicture}% \hspace*{0.05cm} \begin{tikzpicture} \begin{axis} [ title={AVG}, title style={yshift=-1.5ex}, width=1.05\textwidth, height=.75\textwidth, ymin=0.85, ymax=1.25, ytick={0.9,1.0,1.1,1.2}, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\footnotesize, at={(-0.25,0.5)}}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={100,50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny, shift={(0.45cm,0.0cm)}] at (axis cs: 0, 0.975) {$Base$}; \addplot [ draw=green3,smooth,mark=triangle*,mark options={green3,scale=0.8} ] coordinates {(0,1.01615962552483) (1,1.02086140907367) (2,1.03153171586302) (3,0.926459167344158) (4,0.985796982132004) (5,1.08955873036162)}; \addplot [ draw=red2,smooth,mark=*,mark options={red2,scale=0.7} ] coordinates {(0,1.01913399615297) (1,1.02335444435192) (2,1.03161862147413) (3,1.04391902636167) (4,1.08406329300596) (5,1.15169267849232)}; \addplot [ draw=blue2,smooth,mark=*,mark options={blue2,scale=0.7} ] coordinates {(0,1.02066405801142) (1,1.02493544511154) (2,1.02725655621105) (3,1.05560342483457) (4,1.10518476849612) (5,1.16351488678254)}; \end{axis} \end{tikzpicture \end{subfigure} \caption{Improvement over Base given a budget for AHT using SE and the SE-based ensembles.} \label{fig:sign_aht} \end{figure} The elevation of results obtained for SE is a good indicator that our ensembles should be able to increase the lower bound of our approach, by providing that it will never be worse than the baseline. After looking at the results in Fig. \ref{fig:elev} we can understand that this is not a coincidence. The bar plots present how many times on average either the standard base learner (Stand-TP, Stand-FP) or the risky one (Risky-TP, Risky-FP) was correctly (true positive, TP) or incorrectly (false positive, FP) elevated with respect to the available budget and used significance level $\alpha_e$. The correctness depended on the precision of the error estimated based on the partial information from labeled instances. We can easily notice that a prevalent number of elevations was done correctly. The only configuration that stands out with a visible number of false positives is the one using $\alpha_e=0.2$, which is, in fact, an unusual value for the Welch's test. Nevertheless, it still did not affect performance in a meaningful way. The results prove that we can effectively track an error even under strictly limited supervision and utilize it in switching or elevating techniques. \begin{figure}[t] \centering \leftskip15pt\begin{subfigure}{0.4\textwidth} \begin{tikzpicture} \begin{axis}[ title={AHT / EW}, title style={yshift=-0.2ex}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0, ymajorgrids=true, ylabel={Elevations}, ylabel near ticks, ytick style={font=\footnotesize}, ylabel style={font=\footnotesize, at={(-0.1,0.5)}}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, table/header=false, table/row sep=\\, xticklabels from table={ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ }{[index]0}, x tick label style={rotate=90, font=\tiny}, xlabel style={yshift=-4ex,}, enlarge x limits={abs=1}, legend image post style={scale=0.7}, legend cell align={left}, legend style={font=\scriptsize,column sep=1ex, legend columns=2, at={(0.5,0.95)}, anchor=north west, nodes={scale=0.75}, draw opacity=0.1}, legend entries={Stand-TP,Stand-FP,Risky-TP,Risky-FP}, clip mode=individual, ] \addplot [ bar width=4pt, ybar stacked, fill=red4, draw=none, ] table[x expr=\coordindex,y index=0]{ 25\\19.4285714285714\\17.5\\12.9285714285714\\0\\ 18.2142857142857\\14.7857142857143\\12.9285714285714\\11.2857142857143\\0\\ 12.1428571428571\\10.1428571428571\\9.57142857142857\\6.85714285714286\\0\\ 15.4285714285714\\12.2142857142857\\11.7857142857143\\9.42857142857143\\0\\ 11.2857142857143\\10\\9\\6.57142857142857\\0\\ 5.5\\5.28571428571429\\4.5\\3.14285714285714\\}; \addplot [ bar width=4pt, ybar stacked, fill=red2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 1.28571428571429\\0.785714285714286\\0.714285714285714\\0.142857142857143\\0\\ 1.5\\1\\0.285714285714286\\0.428571428571429\\0\\ 0.571428571428571\\0.285714285714286\\0.428571428571429\\0.285714285714286\\0\\ 0.428571428571429\\0.428571428571429\\0.214285714285714\\0.142857142857143\\0\\ 0.642857142857143\\0.142857142857143\\0.071428571428572\\0.142857142857143\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue4, draw=none, ] table[x expr=\coordindex,y index=0]{ 12.5\\8.07142857142857\\6.35714285714286\\4.28571428571429\\0\\ 8.28571428571429\\7\\5.14285714285714\\3.5\\0\\ 6.57142857142857\\4.21428571428571\\4.21428571428571\\2.92857142857143\\0\\ 4.78571428571429\\3.71428571428571\\2.28571428571429\\2\\0\\ 2.85714285714286\\3.35714285714286\\2.78571428571429\\1.92857142857143\\0\\ 0.928571428571429\\1.07142857142857\\0.928571428571429\\0.428571428571429\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 1.28571428571429\\0.857142857142857\\0.428571428571429\\0.142857142857143\\0\\ 1.42857142857143\\0.714285714285714\\0.285714285714286\\0\\0\\ 0.642857142857143\\0.785714285714286\\0.357142857142857\\0\\0\\ 1\\0.428571428571429\\0.071428571428572\\0\\0\\ 0.642857142857143\\0.071428571428572\\0.142857142857143\\0.142857142857143\\}; \begin{scope}[ every label/.append style={ label distance=3.5ex, font=\footnotesize }, ] \node [label=below:{100}] at (axis cs:1.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{50}] at (axis cs:6.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{20}] at (axis cs:11.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{10}] at (axis cs:16.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{5}] at (axis cs:21.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{1}] at (axis cs:26.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \end{scope} \end{axis} \end{tikzpicture}% \hspace*{0.2cm} \begin{tikzpicture} \begin{axis}[ title={AHT / SE}, title style={yshift=-0.2ex}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0, ymajorgrids=true, ylabel near ticks, ylabel style={font=\scriptsize}, ytick style={font=\footnotesize}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, table/header=false, table/row sep=\\, xticklabels from table={ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ }{[index]0}, x tick label style={rotate=90, font=\tiny}, xlabel style={yshift=-4ex,}, enlarge x limits={abs=1}, clip mode=individual, ] \addplot [ bar width=4pt, ybar stacked, fill=red4, draw=none, ] table[x expr=\coordindex,y index=0]{ 20.7857142857143\\16.5\\14.2142857142857\\12.3571428571429\\0\\ 16.4285714285714\\13.7857142857143\\11.0714285714286\\9.28571428571429\\0\\ 12.3571428571429\\9.64285714285714\\8.28571428571429\\7.64285714285714\\0\\ 4.21428571428571\\3.92857142857143\\3.64285714285714\\2.5\\0\\ 5.28571428571429\\3.92857142857143\\3.14285714285714\\2.92857142857143\\0\\ 4.07142857142857\\3.71428571428571\\3.78571428571429\\3.42857142857143\\}; \addplot [ bar width=4pt, ybar stacked, fill=red2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 1.14285714285714\\1\\0.5\\0.285714285714286\\0\\ 1.42857142857143\\0.571428571428571\\0.642857142857143\\0.071428571428572\\0\\ 0.5\\0.357142857142857\\0.214285714285714\\0.071428571428572\\0\\ 0.642857142857143\\0.428571428571429\\0.071428571428572\\0\\0\\ 0.5\\0.357142857142857\\0.285714285714286\\0.071428571428572\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue4, draw=none, ] table[x expr=\coordindex,y index=0]{ 20\\15.4285714285714\\11.0714285714286\\8.28571428571429\\0\\ 16.2142857142857\\12.0714285714286\\9.71428571428571\\7\\0\\ 12.2142857142857\\7.42857142857143\\4.92857142857143\\4.14285714285714\\0\\ 152.928571428571\\144\\136.5\\118.357142857143\\0\\ 81.9285714285714\\72.8571428571429\\70.5\\63.3571428571429\\0\\ 15.2857142857143\\10.4285714285714\\9.21428571428571\\8.92857142857143\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 1.14285714285714\\0.571428571428571\\0.5\\0.285714285714286\\0\\ 0.928571428571429\\0.571428571428571\\0.428571428571429\\0.357142857142857\\0\\ 1.14285714285714\\0.928571428571429\\0.785714285714286\\0.5\\0\\ 0.785714285714286\\0.928571428571429\\0.857142857142857\\0.285714285714286\\0\\ 0.428571428571429\\0.357142857142857\\0.5\\0.142857142857143\\}; \begin{scope}[ every label/.append style={ label distance=3.5ex, font=\footnotesize }, ] \node [label=below:{100}] at (axis cs:1.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{50}] at (axis cs:6.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{20}] at (axis cs:11.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{10}] at (axis cs:16.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{5}] at (axis cs:21.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{1}] at (axis cs:26.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \end{scope} \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ title={SGD / EW}, title style={yshift=-0.2ex}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0, ymajorgrids=true, ylabel={Elevations}, ylabel near ticks, ylabel style={font=\footnotesize, at={(-0.1,0.5)}}, ytick style={font=\footnotesize}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, table/header=false, table/row sep=\\, xticklabels from table={ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ }{[index]0}, x tick label style={rotate=90, font=\tiny}, xlabel style={yshift=-4ex,}, enlarge x limits={abs=1}, clip mode=individual, ] \addplot [ bar width=4pt, ybar stacked, fill=red4, draw=none, ] table[x expr=\coordindex,y index=0]{ 43.8333333333333\\37.3333333333333\\33.6666666666667\\28.0833333333333\\0\\ 35.25\\31.9166666666667\\26.75\\23.25\\0\\ 26.25\\22.0833333333333\\20.0833333333333\\16.75\\0\\ 18.25\\15.5833333333333\\13.8333333333333\\12\\0\\ 13.9166666666667\\12.1666666666667\\11.4166666666667\\9\\0\\ 6.08333333333333\\6.33333333333333\\5.16666666666667\\4.75\\}; \addplot [ bar width=4pt, ybar stacked, fill=red2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 0.25\\0.25\\0.25\\0.166666666666667\\0\\ 0.333333333333333\\0\\0\\0\\0\\ 0.166666666666667\\0.083333333333333\\0.083333333333333\\0\\0\\ 0.416666666666667\\0.083333333333333\\0.083333333333333\\0\\0\\ 0.333333333333333\\0.083333333333333\\0\\0\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue4, draw=none, ] table[x expr=\coordindex,y index=0]{ 6.41666666666667\\3.66666666666667\\2.83333333333333\\1.83333333333333\\0\\ 3.08333333333333\\1.91666666666667\\2.25\\0.916666666666667\\0\\ 2.41666666666667\\1.33333333333333\\0.666666666666667\\0.416666666666667\\0\\ 1.58333333333333\\0.75\\0.833333333333333\\0.5\\0\\ 1\\1.08333333333333\\0.75\\0.083333333333333\\0\\ 2.33333333333333\\0.666666666666667\\0.5\\0.416666666666667\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 0.25\\0.583333333333333\\0.083333333333333\\0.083333333333333\\0\\ 0.583333333333333\\0.166666666666667\\0.083333333333333\\0.083333333333333\\0\\ 0.583333333333333\\0.083333333333333\\0\\0.083333333333333\\0\\ 0.333333333333333\\0.083333333333333\\0\\0.083333333333333\\0\\ 0.083333333333333\\0.166666666666667\\0.083333333333333\\0\\}; \begin{scope}[ every label/.append style={ label distance=3.5ex, font=\footnotesize }, ] \node [label=below:{100}] at (axis cs:1.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{50}] at (axis cs:6.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{20}] at (axis cs:11.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{10}] at (axis cs:16.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{5}] at (axis cs:21.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{1}] at (axis cs:26.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \end{scope} \end{axis} \end{tikzpicture}% \hspace*{0.2cm} \begin{tikzpicture} \begin{axis}[ title={SGD / SE}, title style={yshift=-0.2ex}, footnotesize, width=1.15\textwidth, height=0.7\textwidth, ymin=0, ymajorgrids=true, ylabel near ticks, ylabel style={font=\scriptsize}, ytick style={font=\footnotesize}, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, table/header=false, table/row sep=\\, xticklabels from table={ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ 0.2\\0.1\\0.05\\0.01\\ {} \\ }{[index]0}, x tick label style={rotate=90, font=\tiny}, xlabel style={yshift=-4ex,}, enlarge x limits={abs=1}, clip mode=individual ] \addplot [ bar width=4pt, ybar stacked, fill=red4, draw=none, ] table[x expr=\coordindex,y index=0]{ 39.2857142857143\\33.1428571428571\\29.7142857142857\\26\\0\\ 33.2142857142857\\29.6428571428571\\26.2142857142857\\23.4285714285714\\0\\ 25.1428571428571\\21.1428571428571\\20.3571428571429\\17.3571428571429\\0\\ 19.3571428571429\\16.7857142857143\\15.0714285714286\\13\\0\\ 15.5\\14.2142857142857\\12.7142857142857\\11.0714285714286\\0\\ 7.14285714285714\\7.57142857142857\\6.57142857142857\\5.21428571428571\\}; \addplot [ bar width=4pt, ybar stacked, fill=red2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 0.857142857142857\\0.357142857142857\\0.357142857142857\\0.214285714285714\\0\\ 0.571428571428571\\0.642857142857143\\0.214285714285714\\0.214285714285714\\0\\ 0.214285714285714\\0.214285714285714\\0.142857142857143\\0.071428571428572\\0\\ 0.5\\0.642857142857143\\0.142857142857143\\0\\0\\ 0.214285714285714\\0.214285714285714\\0.142857142857143\\0.071428571428572\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue4, draw=none, ] table[x expr=\coordindex,y index=0]{ 115.714285714286\\101.142857142857\\84.2142857142857\\71.9285714285714\\0\\ 85.2142857142857\\79.3571428571429\\68.1428571428571\\61.4285714285714\\0\\ 43\\28.2857142857143\\28.7142857142857\\19.3571428571429\\0\\ 20.4285714285714\\16.2857142857143\\11.7142857142857\\7.21428571428571\\0\\ 12.3571428571429\\9.35714285714286\\7.14285714285714\\4\\0\\ 3.57142857142857\\1.21428571428571\\1\\0.571428571428571\\}; \addplot [ bar width=4pt, ybar stacked, fill=blue2, draw=none, ] table[x expr=\coordindex,y index=0]{ 0\\0\\0\\0\\0\\ 1.21428571428571\\0.571428571428571\\0.357142857142857\\0.357142857142857\\0\\ 0.357142857142857\\0.5\\0.428571428571429\\0\\0\\ 0.357142857142857\\0.357142857142857\\0.071428571428572\\0.285714285714286\\0\\ 0.714285714285714\\0.571428571428571\\0.357142857142857\\0.285714285714286\\0\\ 0.357142857142857\\0.285714285714286\\0.142857142857143\\0\\}; \begin{scope}[ every label/.append style={ label distance=3.5ex, font=\footnotesize }, ] \node [label=below:{100}] at (axis cs:1.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{50}] at (axis cs:6.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{20}] at (axis cs:11.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{10}] at (axis cs:16.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{5}] at (axis cs:21.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:{1}] at (axis cs:26.5,\pgfkeysvalueof{/pgfplots/ymin}) {}; \end{scope} \end{axis} \end{tikzpicture} \end{subfigure} \caption{Number of elevations given a budget and significance level for ATH and SGD using elevating ensembles.} \label{fig:elev} \end{figure} A more careful analysis of the average number of elevations gives us some additional observations. Firstly, the total number of elevations decreases with the budget and significance level $\alpha_e$, which is intuitive. Secondly, in most of the cases, if an exploitation strategy is properly configured, we will be replacing mainly the standard learner with the risky one. This can be mostly seen for EW, however, we would observe the same relation also for SE, if it was properly configured for AHT, or for SGD with the exclusion of the SEA stream. This was the only benchmark for which the SE strategy was constantly failing when combined with the latter classifier, resulting in more than 500 elevations and biasing the average value. We could use median instead, however, we decided to keep the average to show that the SE strategy tends to be more sensitive to improper configuration and overfitting than EW or UW, taking into consideration results for both AHT and SGD. Finally, one may wonder why even if we replace EW or SE with a standard learner multiple times, we do not obtain significant improvements over them (except for the specified cases for AHT with SE)? The reason may be that even if we elevate the exploiting learner it keeps falling into the same pitfalls again and again, as the internal characteristics of the streams do not allow any more improvements than the strategies give themselves in other parts of the streams. For a similar reason, we cannot see additional enhancements when using switching. Fortunately, the differences are more visible for real data streams, in favor of the ensembles, which makes them more than just safe lower bound providers. \subsubsection{Final comparison} \smallskip \noindent\textbf{Default configurations.} Based on the observations made in the previous sections, we determined default settings for our strategies and used them in the final comparison, which was conducted using real streams. Since we found trade-offs obtained for the dynamic heuristics fair, we decided to use dynamic intensity controlled by the ADWIN error ($\epsilon=\epsilon_{ADW}$), as well as dynamic window size determined by the same algorithm ($\omega_{max}=\omega_{ADW}$). We used the same significance levels $\alpha_{\theta}$ as for synthetic streams. For our elevating ensembles, due to the lack of impact, we chose one of the widely used values, $\alpha_e=0.05$. Finally, in order to find a compromise between evidence suggesting lower values of intensity for AHT and making sure that we fully utilize the potential of our strategies, we distinguished two groups of $\lambda_{max}$ values: less risky $\lambda^l_{max}$ and risky $\lambda^r_{max}$. In addition to that, since AHT and SGD exhibited substantially different preferences regarding required intensity, we set: $\lambda^l_{max}=\{1,1,1,1,1,10\}$, $\lambda^r_{max}=\{100, 100, 100, 1000, 1000, 1000\}$ for AHT, where each value corresponds to a budget ranging from $B=100\%$ to $B=1\%$, respectively, and $\lambda^l_{max}=10$, $\lambda^r_{max}=1000$ for SGD. \medskip \noindent\textbf{Results.} The average performance of all considered classifiers under varying budget is presented in Tab. \ref{tab:final}. It provides a general overview of the final comparison. The main observation is that the proposed instance exploitation strategies are capable of providing the best predictive quality (in bold) out of all models and that the risky ones exhibited much better quality than the more conservative configurations. Most importantly, our best strategies were able to outperform baseline models using only active learning (ALR, ALRV, ALS) for both base learners (by about 0.1 kappa for AHT and 0.15 for SGD), regardless of the available budget. It shows that the depicted problem of underfitting while learning temporary drifting concepts under limited supervision is critical in real scenarios and active learning fails to solve it efficiently on its own. \begin{table}[t] \caption{Final average kappa for AHT and SGD on real data streams.} \vspace*{-0.1cm} \centering \scalebox{0.8}{ \begin{subtable}{\textwidth}\leftskip-45pt \begin{tabular}[H]{l >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm}} \textbf{AHT}& $100\%$ & $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule EW$^{l}$ & 0.5637 & 0.5275 & 0.4611 & 0.4116 & 0.3721 & 0.3040\\ EWS$^{l}$ & 0.5831 & 0.5387 & 0.4765 & 0.4108 & 0.3880 & 0.3306\\ EWE$^{l}$ & 0.5638 & 0.5246 & 0.4707 & 0.4177 & 0.3780 & 0.3326\\ SE$^{l}$ & 0.5752 & 0.5378 & 0.4778 & 0.4362 & 0.3953 & 0.3401\\ SES$^{l}$ & 0.5914 & 0.5516 & 0.4990 & 0.4463 & 0.4035 & 0.3503\\ SEE$^{l}$ & 0.5838 & 0.5345 & 0.4859 & 0.4202 & 0.3842 & \textbf{0.3578}\\ \hdashline EW$^{r}$ & 0.6432 & 0.5959 & 0.5520 & 0.5035 & 0.4521 & 0.3315\\ EWS$^{r}$ & 0.6492 & 0.6128 & \textbf{0.5634} & \textbf{0.5161} & 0.4525 & 0.3287\\ EWE$^{r}$ & \textbf{0.6569} & \textbf{0.6182} & 0.5620 & 0.5099 & \textbf{0.4690} & 0.3405\\ SE$^{r}$ & 0.5655 & 0.5404 & 0.4915 & 0.3900 & 0.3530 & 0.2541\\ SES$^{r}$ & 0.6424 & 0.6052 & 0.5594 & 0.4984 & 0.4684 & 0.3500\\ SEE$^{r}$ & 0.6416 & 0.6044 & 0.5557 & 0.5025 & 0.4573 & 0.3473\\ \hdashline ALR & 0.5403 & 0.4978 & 0.4475 & 0.3946 & 0.3527 & 0.2997\\ ALRV & 0.5063 & 0.5036 & 0.4466 & 0.3953 & 0.3537 & 0.3030\\ ALS & 0.5242 & 0.5082 & 0.4424 & 0.3858 & 0.3496 & 0.2986\\ AUC & 0.4297 & 0.4218 & 0.3680 & 0.2990 & 0.2656 & 0.2324\\ DWM & 0.6154 & 0.5897 & 0.5309 & 0.4993 & 0.4501 & 0.3335\\ LNSE & 0.2734 & 0.2986 & 0.3096 & 0.3000 & 0.2237 & 0.1717\\ ADOB & 0.2588 & 0.2564 & 0.2608 & 0.2705 & 0.2562 & 0.2464\\ ABAG & 0.6204 & 0.6003 & 0.5414 & 0.4918 & 0.4455 & 0.3203\\ OBAG & 0.5752 & 0.5438 & 0.4711 & 0.4129 & 0.3805 & 0.2964\\ \bottomrule \end{tabular} \hspace*{0.25cm} \begin{tabular}[H]{l >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{1cm}} \textbf{SGD}& $100\%$ & $50\%$ & $20\%$ & $10\%$ & $5\%$ & $1\%$\\ \midrule EW$^{l}$ & 0.3397 & 0.3171 & 0.2685 & 0.2043 & 0.1568 & 0.0764\\ EWS$^{l}$ & 0.3751 & 0.3519 & 0.3073 & 0.2706 & 0.2357 & 0.1345\\ EWE$^{l}$ & 0.3684 & 0.3429 & 0.3021 & 0.2681 & 0.2304 & 0.1164\\ SE$^{l}$ & 0.3954 & 0.3760 & 0.3363 & 0.3044 & 0.2819 & 0.1743\\ SES$^{l}$ & 0.3956 & 0.3707 & 0.3355 & 0.3045 & 0.2804 & 0.1679\\ SEE$^{l}$ & 0.3960 & 0.3710 & 0.3410 & 0.3073 & 0.2812 & 0.1647\\ \hdashline EW$^{r}$ & 0.4124 & 0.3962 & 0.3533 & 0.3027 & 0.2711 & 0.1753\\ EWS$^{r}$ & 0.4351 & 0.4188 & 0.3879 & 0.3600 & 0.3184 & 0.2344\\ EWE$^{r}$ & 0.4379 & 0.4208 & 0.3878 & 0.3576 & 0.3176 & 0.2114\\ SE$^{r}$ & \textbf{0.4714} & \textbf{0.4455} & \textbf{0.4109} & \textbf{0.3813} & \textbf{0.3634} & \textbf{0.2891}\\ SES$^{r}$ & 0.4698 & 0.4421 & 0.4042 & 0.3730 & 0.3469 & 0.2664\\ SEE$^{r}$ & 0.4683 & 0.4414 & 0.4044 & 0.3742 & 0.3411 & 0.2679\\ \hdashline ALR & 0.3440 & 0.3098 & 0.2644 & 0.2195 & 0.1865 & 0.1054\\ ALRV & 0.3151 & 0.3156 & 0.2653 & 0.2215 & 0.1863 & 0.1228\\ ALS & 0.3204 & 0.3135 & 0.2669 & 0.2199 & 0.1800 & 0.1158\\ AWE & 0.1289 & 0.1062 & 0.0918 & 0.0559 & 0.0427 & 0.0298\\ DWM & 0.3689 & 0.3375 & 0.2861 & 0.2593 & 0.2369 & 0.1404\\ LNSE & 0.1242 & 0.1325 & 0.1163 & 0.0843 & 0.0456 & 0.0210\\ ADOB & 0.4553 & 0.4347 & 0.4050 & 0.3632 & 0.3271 & 0.2299\\ ABAG & 0.3673 & 0.3444 & 0.2873 & 0.2427 & 0.2169 & 0.1381\\ OBAG & 0.3343 & 0.3056 & 0.2553 & 0.2147 & 0.1845 & 0.1239\\ \bottomrule \end{tabular} \end{subtable}} \label{tab:final} \end{table} In Fig. \ref{fig:final_impr} we can see gain obtained from using our exploitation strategies compared with the best baseline model using only active learning (AL) for each budget. It provides more insight into trends and relations present in the aggregated results. Firstly, as we already mentioned, the more risky approaches, applying more intense exploitation of labeled instances, outperforms the safer configurations in almost all cases. We can see that EW$^r$ and EWS$^r$ provided about 0.1-0.2 improvement in gain over EW$^l$ and EWS$^l$ for both AHT and SGD. In the case of SE and SES, the enhancement remained the same for SGD and for AHT using SES. These relations are analogous for EWE and SEE. Interestingly, for AHT with SE$^r$ we noticed that while for lower budgets the base learner did not work well with this extreme strategy, the switching technique SES$^r$ empowered the strategy to become more efficient even than SE$^l$, which was initially better than SE$^r$. This shows that taking even a very risky adaptation while having a good lower-bound backup may still be beneficial. On the other hand, results for AHT using SE$^r$ and SE$^l$ indicate that we may need to be a bit more careful with more reactive classifiers. Statistical rank tests presented in Fig. \ref{fig:bonferroni_in} prove that the advantage of the more risky exploitation is significant, as the best risky strategies for AHT (EWS$^r$, EWE$^r$) and SGD (SE$^r$, SES$^r$, SEE$^r$) are significantly better than any less risky method. Secondly, Fig. \ref{fig:final_impr} shows that, generally and analogously to the results for the synthetic streams, the improvement over the baseline models increases as we limit available supervision. It is, again, intuitively correct, since if we have less labeled instances, the risk of encountering underfitting becomes higher. The only exception for this trend can be noticed when using the extremely limited budget $B=1\%$ and the reason for that is the same as the one given for the characteristic curve for SGD in Fig. \ref{fig:fix_gen_sgd}. The increase is more clear for SGD, which, in general, adapts less efficiently than AHT, giving more occasions for improvements. Regardless of the budget, almost all strategies turned out to be significantly better than a model without instance exploitation (Fig. \ref{fig:bonferroni_in}, ALRV, in bold), which proves the general usefulness of the proposed approaches. Interestingly, since our methods were able to provide some improvements also for fully labeled streams ($B=100\%$), we can assume that it may enhance adaptation to unstable data in general -- limiting budget only makes the problem harder and more severe. \begin{figure}[h] \centering \leftskip25pt\begin{subfigure}{0.4\textwidth} \begin{tikzpicture} \begin{axis} [ title={AHT / EW / EWS}, title style={yshift=-0.2ex}, footnotesize, width=1.1\textwidth, height=.75\textwidth, ymin=0.65, ymax=1.45, ymajorgrids=true, ylabel={Improvement}, ylabel near ticks, ylabel style={font=\footnotesize, at={(-0.15,0.5)}}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={100,50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, legend cell align={left}, legend style={font=\scriptsize,column sep=0.5ex, legend columns=2, at={(0.05,0.25)}, anchor=north west, draw opacity=0.1, nodes={scale=0.75}}, legend entries={EW$^{r}$,EW$^{l}$,EWS$^{r}$,EWS$^{l}$} ] \node[font=\tiny, shift={(-0.65cm,0.0cm)}] at (axis cs: 1, 0.96) {$AL$}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,1.19039628880225) (1,1.17266441887619) (2,1.23367103694875) (3,1.27367480140995) (4,1.27823333144828) (5,1.09404568058795)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.04315747914919) (1,1.03811185600147) (2,1.03048271752086) (3,1.04135395409239) (4,1.05214047390149) (5,1.00347665361088)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.8} ] coordinates {(0,1.20140156936288) (1,1.20586961940622) (2,1.25916269368296) (3,1.30561786382878) (4,1.27942091274105) (5,1.08500198037231)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.8} ] coordinates {(0,1.07913438286532) (1,1.06017868622332) (2,1.06483909415971) (3,1.0392626448316) (4,1.09713660954966) (5,1.09116313867007)}; \end{axis} \end{tikzpicture}% \hspace*{0.4cm} \begin{tikzpicture} \begin{axis} [ title={AHT / SE / SES}, title style={yshift=-0.2ex}, footnotesize, width=1.1\textwidth, height=.75\textwidth, ymin=0.65, ymax=1.45, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={100,50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, legend cell align={left}, legend style={font=\scriptsize,column sep=0.5ex, legend columns=2, at={(0.05,0.25)}, anchor=north west, draw opacity=0.1, nodes={scale=0.75}}, legend entries={SE$^{r}$,SE$^{l}$,SES$^{r}$,SES$^{l}$} ] \node[font=\tiny, shift={(-0.65cm,0.0cm)}] at (axis cs: 1, 0.96) {$AL$}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,1.04647633617924) (1,1.06355037193498) (2,1.09851013110846) (3,0.986507682188454) (4,0.998058398838809) (5,0.838599656735466)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.06446478803731) (1,1.05827637327316) (2,1.06775923718713) (3,1.10358726999814) (4,1.11764594997078) (5,1.12267306253576)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.8} ] coordinates {(0,1.1888787445097) (1,1.19105781719429) (2,1.25014898688915) (3,1.26082336869445) (4,1.32447359987936) (5,1.15517317255644)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.8} ] coordinates {(0,1.09455658096037) (1,1.08555160515855) (2,1.11510727056019) (3,1.12905401986744) (4,1.14083206092481) (5,1.15622937112177)}; \end{axis} \end{tikzpicture} \end{subfigure}\\ \vspace*{0.1cm} \begin{subfigure}{0.4\textwidth} \begin{tikzpicture} \begin{axis} [ title={SGD / EW / EWS}, title style={yshift=-0.2ex}, footnotesize, width=1.1\textwidth, height=.75\textwidth, ymin=0.4, ymax=2.7, ytick={0.5, 0.8, 1.1, 1.4, 1.7, 2.0, 2.3, 2.6}, ymajorgrids=true, ylabel={Improvement}, ylabel near ticks, ylabel style={font=\footnotesize, at={(-0.15,0.5)}}, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={100,50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize} ] \node[font=\tiny, shift={(-0.65cm,0.0cm)}] at (axis cs: 1, 0.865) {$AL$}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,1.19883324288705) (1,1.2555879494655) (2,1.32347578489897) (3,1.36661349065406) (4,1.45347299181353) (5,1.42723769201542)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,0.987692844406543) (1,1.00473232771369) (2,1.00591952443989) (3,0.922433254070975) (4,0.841061023129446) (5,0.622157086250882)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.8} ] coordinates {(0,1.26484611210171) (1,1.32705877382009) (2,1.45323076154557) (3,1.62516931041748) (4,1.70746791548994) (5,1.90880964012376)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.8} ] coordinates {(0,1.09054965501202) (1,1.11505471753919) (2,1.15148487648925) (3,1.22195466995756) (4,1.2638973295678) (5,1.09531563806112)}; \end{axis} \end{tikzpicture}% \hspace*{0.4cm} \begin{tikzpicture} \begin{axis} [ title={SGD / SE / SES}, title style={yshift=-0.2ex}, footnotesize, width=1.1\textwidth, height=.75\textwidth, ymin=0.4, ymax=2.7, ytick={0.5, 0.8, 1.1, 1.4, 1.7, 2.0, 2.3, 2.6}, ymajorgrids=true, ylabel near ticks, y tick label style={ font=\scriptsize, /pgf/number format/.cd, fixed, fixed zerofill, precision=2, /tikz/.cd }, ylabel style={font=\scriptsize}, extra y ticks=1.0, extra y tick labels={}, extra y tick style={ ymajorgrids=true, ytick style={ /pgfplots/major tick length=0pt, }, grid style={ gray, dashed, /pgfplots/on layer=axis foreground, }, }, grid style={dashed,white!90!black}, xtick style={draw=none}, xtick=data, xticklabels={100,50,20,10,5,1}, xlabel style={font=\footnotesize}, x tick label style={font=\scriptsize}, ] \node[font=\tiny, shift={(-0.65cm,0.0cm)}] at (axis cs: 1, 0.865) {$AL$}; \addplot [ draw=red4,smooth,mark=*,mark options={red4,scale=0.7} ] coordinates {(0,1.37045507403675) (1,1.41164913170237) (2,1.53960086919599) (3,1.72151822532583) (4,1.94891502520287) (5,2.35363404440102)}; \addplot [ draw=blue4,smooth,mark=*,mark options={blue4,scale=0.7} ] coordinates {(0,1.149643383208) (1,1.19138462838552) (2,1.25980967604965) (3,1.37434909550613) (4,1.51145747685268) (5,1.41942137545459)}; \addplot [ draw=red2,smooth,mark=triangle*,mark options={red2,scale=0.8} ] coordinates {(0,1.36578416931545) (1,1.40089576203152) (2,1.51442415765417) (3,1.68413448514583) (4,1.86032960354628) (5,2.16929924550833)}; \addplot [ draw=blue2,smooth,mark=triangle*,mark options={blue2,scale=0.8} ] coordinates {(0,1.15005039150322) (1,1.17465246968353) (2,1.25698728675975) (3,1.37480058995274) (4,1.50337825760555) (5,1.36693263854964)}; \end{axis} \end{tikzpicture} \end{subfigure} \caption{Improvement over the bast AL given a budget for AHT and SGD using different strategies on real data streams.} \label{fig:final_impr} \end{figure} Finally, based on Fig. \ref{fig:final_impr} and Fig. \ref{fig:bonferroni_in} we can claim that switching and elevating ensembles provide intended improvements. In almost all cases they maintained at least as good performance as the best base learner, either a single-classifier strategy (SE, EW) or a standard model without exploitation (ALRV). As a consequence, the ensembles are always at least as good as the baseline, providing noticeable improvements in almost all cases, as opposed to simpler strategies (SE$^r$ for AHT and EW$^l$ for SGD). Fig. \ref{fig:bonferroni_in} suggests that the improvements over the single-classifier methods are usually on the verge of significance. The only exception is, one more time, SE$^r$ for SGD -- since it worked outstandingly well with this classifier (especially for the lowest budgets), there was a low chance that the baseline could provide better prediction and, as a consequence, any incorrect switch led to some reduction in improvements. This once again shows that even very extreme and risky exploitation makes sense. In addition, compared with results obtained for synthetic streams, the ensembles were also able to improve upon SE and EW in some cases, even if the simpler strategies already provided gain over the baseline. This very likely shows that real streams are more unstable or complex than synthetic ones, thus requiring more intensive adaptation from classifiers. Last but not least, we did not obtain a significant difference between the switching and elevating techniques. \begin{figure}[h] \centering \small {\begin{subfigure}{\textwidth} \begin{tikzpicture} \pgfmathsetmacro{\sc}{2.49} \pgfmathsetmacro{\b}{4} \draw (0,0) -- ({\sc*(11-\b)},0); \foreach \x in {4,5,6,7,8,9,10,11} { \draw ({\sc*(\x-\b)}, 0) -- ++(0,.1) node [below=0.15cm,scale=1.25] {\tiny \x}; \ifthenelse{\x < 11}{\draw ({\sc*(\x-\b) +.5*\sc}, 0) -- ++(0,.03);}{} } \coordinate (c0) at ({\sc*(4.15-\b)},0); \coordinate (c1) at ({\sc*(4.672222-\b)},0); \coordinate (c2) at ({\sc*(5.716667-\b)},0); \coordinate (c3) at ({\sc*(6.116667-\b)},0); \coordinate (c4) at ({\sc*(6.233333-\b)},0); \coordinate (c5) at ({\sc*(6.744444-\b)},0); \coordinate (c6) at ({\sc*(7.105556-\b)},0); \coordinate (c7) at ({\sc*(7.127778-\b)},0); \coordinate (c8) at ({\sc*(7.311111-\b)},0); \coordinate (c9) at ({\sc*(8.111111-\b)},0); \coordinate (c10) at ({\sc*(8.688889-\b)},0); \coordinate (c11) at ({\sc*(9.038889-\b)},0); \coordinate (c12) at ({\sc*(9.983333-\b)},0); \node (l0) at (c0) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWE$^{r}$}; \node (l1) at (c1) [above right=.1cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny EWS$^{r}$}; \node (l2) at (c2) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EW$^{r}$}; \node (l3) at (c3) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SES$^{r}$}; \node (l4) at (c4) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SES$^{l}$}; \node (l5) at (c5) [above right=0.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SEE$^{l}$}; \node (l6) at (c6) [above right=.6cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny EWS$^{l}$}; \node (l7) at (c7) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SEE$^{r}$}; \node (l8) at (c8) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SE$^{l}$}; \node (l9) at (c9) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWE$^{l}$}; \node (l10) at (c10) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SE$^{r}$}; \node (l11) at (c11) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EW$^{l}$}; \node (l12) at (c12) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{ALRV}}; \fill[fill=gray,fill opacity=0.5] ({\sc*(4.175-\b)},-0.15) rectangle ({\sc*(4.175 + 1.7539-\b)},0.15); \foreach \x in {0,...,12} { \draw (l\x) -| (c\x); }; \end{tikzpicture} \end{subfigure}\vspace*{-0.25cm}\subcaption{AHT}} \vspace*{0.35cm} {\begin{subfigure}{\textwidth} \begin{tikzpicture} \pgfmathsetmacro{\sc}{1.925} \pgfmathsetmacro{\b}{3} \draw (0,0) -- ({\sc*(12-\b)},0); \foreach \x in {3,4,5,6,7,8,9,10,11,12} { \draw ({\sc*(\x-\b)}, 0) -- ++(0,.1) node [below=0.15cm,scale=1.25] {\tiny \x}; \ifthenelse{\x < 12}{\draw ({\sc*(\x-\b) +.5*\sc}, 0) -- ++(0,.03);}{} } \coordinate (c0) at ({\sc*(3.783333-\b)},0); \coordinate (c1) at ({\sc*(4.277778-\b)},0); \coordinate (c2) at ({\sc*(4.288889-\b)},0); \coordinate (c3) at ({\sc*(5.822222-\b)},0); \coordinate (c4) at ({\sc*(6.005556-\b)},0); \coordinate (c5) at ({\sc*(6.861111-\b)},0); \coordinate (c6) at ({\sc*(6.883333-\b)},0); \coordinate (c7) at ({\sc*(6.966667-\b)},0); \coordinate (c8) at ({\sc*(7.288889-\b)},0); \coordinate (c9) at ({\sc*(8.827778-\b)},0); \coordinate (c10) at ({\sc*(9.394444-\b)},0); \coordinate (c11) at ({\sc*(9.833333-\b)},0); \coordinate (c12) at ({\sc*(10.766667-\b)},0); \node (l0) at (c0) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SE$^{r}$}; \node (l1) at (c1) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SES$^{r}$}; \node (l2) at (c2) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SEE$^{r}$}; \node (l3) at (c3) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny EWE$^{r}$}; \node (l4) at (c4) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWS$^{r}$}; \node (l5) at (c5) [above right=.85cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SES$^{l}$}; \node (l6) at (c6) [above right=.6cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SEE$^{l}$}; \node (l7) at (c7) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SE$^{l}$}; \node (l8) at (c8) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EW$^{r}$}; \node (l9) at (c9) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWS$^{l}$}; \node (l10) at (c10) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWE$^{l}$}; \node (l11) at (c11) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{ALRV}}; \node (l12) at (c12) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EW$^{l}$}; \fill[fill=gray,fill opacity=0.5] ({\sc*(3.85-\b)},-0.15) rectangle ({\sc*(3.85 + 1.9581-\b},0.15); \foreach \x in {0,...,12} { \draw (l\x) -| (c\x); }; \end{tikzpicture} \end{subfigure}\vspace*{-0.25cm}\subcaption{SGD}} \vspace*{0.35cm} {\begin{subfigure}{\textwidth} \begin{tikzpicture} \pgfmathsetmacro{\sc}{2.89} \pgfmathsetmacro{\b}{5} \draw (0,0) -- ({\sc*(11-\b)},0); \foreach \x in {5,6,7,8,9,10,11} { \ifthenelse{\x > 4}{\draw ({\sc*(\x-\b)}, 0) -- ++(0,.1) node [below=0.15cm,scale=1.25] {\tiny \x};}{} \ifthenelse{\x < 11}{\draw ({\sc*(\x-\b) +.5*\sc}, 0) -- ++(0,.03);}{} } \coordinate (c0) at ({\sc*(4.986111-\b)},0); \coordinate (c1) at ({\sc*(5.2555555-\b)},0); \coordinate (c2) at ({\sc*(5.338889-\b)},0); \coordinate (c3) at ({\sc*(5.7083335-\b)},0); \coordinate (c4) at ({\sc*(6.236111-\b)},0); \coordinate (c5) at ({\sc*(6.488889-\b)},0); \coordinate (c6) at ({\sc*(6.502778-\b)},0); \coordinate (c7) at ({\sc*(6.8138885-\b)},0); \coordinate (c8) at ({\sc*(7.138889-\b)},0); \coordinate (c9) at ({\sc*(7.966667-\b)},0); \coordinate (c10) at ({\sc*(8.7527775-\b)},0); \coordinate (c11) at ({\sc*(9.902778-\b)},0); \coordinate (c12) at ({\sc*(9.908333-\b)},0); \node (l0) at (c0) [above right=.6cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWE$^{r}$}; \node (l1) at (c1) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SES$^{r}$}; \node (l2) at (c2) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWS$^{r}$}; \node (l3) at (c3) [above right=.1cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SEE$^{r}$}; \node (l4) at (c4) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SE$^{r}$}; \node (l5) at (c5) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SES$^{l}$}; \node (l6) at (c6) [above right=.1cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny EW$^{r}$}; \node (l7) at (c7) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny SEE$^{l}$}; \node (l8) at (c8) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny SE$^{l}$}; \node (l9) at (c9) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWS$^{l}$}; \node (l10) at (c10) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EWE$^{l}$}; \node (l11) at (c11) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny EW$^{l}$}; \node (l12) at (c12) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{ALRV}}; \fill[fill=gray,fill opacity=0.5] ({\sc*(5.03-\b)},-0.15) rectangle ({\sc*(5.03 + 1.856-\b)},0.15); \foreach \x in {0,...,12} { \draw (l\x) -| (c\x); }; \end{tikzpicture} \end{subfigure}\vspace*{-0.25cm}\subcaption{Average}} \caption{Bonferroni-Dunn test for different strategies on real data streams.} \label{fig:bonferroni_in} \end{figure} \begin{figure}[H] \centering \small {\begin{subfigure}{\textwidth} \begin{tikzpicture} \pgfmathsetmacro{\sc}{1.74} \pgfmathsetmacro{\b}{4} \draw (0,0) -- ({\sc*(14-\b)},0); \foreach \x in {4,5,6,7,8,9,10,11,12,13,14} { \draw ({\sc*(\x-\b)}, 0) -- ++(0,.1) node [below=0.15cm,scale=1.25] {\tiny \x}; \ifthenelse{\x < 14}{\draw ({\sc*(\x-\b) +.5*\sc}, 0) -- ++(0,.03);}{} } \coordinate (c0) at ({\sc*(4.427778-\b)},0); \coordinate (c1) at ({\sc*(4.855556-\b)},0); \coordinate (c2) at ({\sc*(5.344444-\b)},0); \coordinate (c3) at ({\sc*(5.85-\b)},0); \coordinate (c4) at ({\sc*(6.238889-\b)},0); \coordinate (c5) at ({\sc*(6.311111-\b)},0); \coordinate (c6) at ({\sc*(7.111111-\b)},0); \coordinate (c7) at ({\sc*(7.188889-\b)},0); \coordinate (c8) at ({\sc*(8.872222-\b)},0); \coordinate (c9) at ({\sc*(9.155556-\b)},0); \coordinate (c10) at ({\sc*(9.355556-\b)},0); \coordinate (c11) at ({\sc*(9.888889-\b)},0); \coordinate (c12) at ({\sc*(10.255556-\b)},0); \coordinate (c13) at ({\sc*(11.833333-\b)},0); \coordinate (c14) at ({\sc*(13.311111-\b)},0); \node (l0) at (c0) [above right=1.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EWE$^{\mathbf{r}}$}}; \node (l1) at (c1) [above right=1.1cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EWS$^{\mathbf{r}}$}}; \node (l2) at (c2) [above right=.85cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ABAG}; \node (l3) at (c3) [above right=.6cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EW$^{\mathbf{r}}$}}; \node (l4) at (c4) [above right=0.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SES$^{\mathbf{r}}$}}; \node (l5) at (c5) [above right=.1cm and .05cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny DWM}; \node (l6) at (c6) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SEE$^{\mathbf{r}}$}}; \node (l7) at (c7) [above right=.1cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny OBAG$^{\,}$}; \node (l8) at (c8) [above right=1.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SE$^{\mathbf{r}}$}}; \node (l9) at (c9) [above right=.85cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALR}; \node (l10) at (c10) [above right=.6cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALRV}; \node (l11) at (c11) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALS}; \node (l12) at (c12) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny AUC}; \node (l13) at (c13) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ADOB}; \node (l14) at (c14) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny LNSE}; \fill[fill=gray,fill opacity=0.5] ({\sc*(4.5-\b)},-0.15) rectangle ({\sc*(4.5+2.0237-\b)},0.15); \foreach \x in {0,...,14} { \draw (l\x) -| (c\x); }; \end{tikzpicture} \end{subfigure}\vspace*{-0.25cm}\subcaption{AHT}} \vspace*{0.35cm} {\begin{subfigure}{\textwidth} \begin{tikzpicture} \pgfmathsetmacro{\sc}{1.74} \pgfmathsetmacro{\b}{4} \draw (0,0) -- ({\sc*(14-\b)},0); \foreach \x in {4,5,6,7,8,9,10,11,12,13,14} { \draw ({\sc*(\x-\b)}, 0) -- ++(0,.1) node [below=0.15cm,scale=1.25] {\tiny \x}; \ifthenelse{\x < 14}{\draw ({\sc*(\x-\b) +.5*\sc}, 0) -- ++(0,.03);}{} } \coordinate (c0) at ({\sc*(4.222222-\b)},0); \coordinate (c1) at ({\sc*(4.572222-\b)},0); \coordinate (c2) at ({\sc*(4.716667-\b)},0); \coordinate (c3) at ({\sc*(6.238889-\b)},0); \coordinate (c4) at ({\sc*(6.366667-\b)},0); \coordinate (c5) at ({\sc*(6.55-\b)},0); \coordinate (c6) at ({\sc*(7.588889-\b)},0); \coordinate (c7) at ({\sc*(7.988889-\b)},0); \coordinate (c8) at ({\sc*(8.25-\b)},0); \coordinate (c9) at ({\sc*(9.016667-\b)},0); \coordinate (c10) at ({\sc*(9.683333-\b)},0); \coordinate (c11) at ({\sc*(10.111111-\b)},0); \coordinate (c12) at ({\sc*(10.155556-\b)},0); \coordinate (c13) at ({\sc*(11.922222-\b)},0); \coordinate (c14) at ({\sc*(12.616667-\b)},0); \node (l0) at (c0) [above right=.6cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SE$^{\mathbf{r}}$}}; \node (l1) at (c1) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SES$^{\mathbf{r}}$}}; \node (l2) at (c2) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SEE$^{\mathbf{r}}$}}; \node (l3) at (c3) [above right=.6cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EWE$^{\mathbf{r}}$}}; \node (l4) at (c4) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EWS$^{\mathbf{r}}$}}; \node (l5) at (c5) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ADOB}; \node (l6) at (c6) [above right=.6cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EW$^{\mathbf{r}}$}}; \node (l7) at (c7) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny ABAG}; \node (l8) at (c8) [above right=.1cm and .05cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny DWM}; \node (l9) at (c9) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny OBAG}; \node (l10) at (c10) [above right=.6cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALRV}; \node (l11) at (c11) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALS}; \node (l12) at (c12) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALR}; \node (l13) at (c13) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny AWE}; \node (l14) at (c14) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny LNSE}; \fill[fill=gray,fill opacity=0.5] ({\sc*(4.29-\b)},-0.15) rectangle ({\sc*(4.29+2.1716-\b)},0.15); \foreach \x in {0,...,14} { \draw (l\x) -| (c\x); }; \end{tikzpicture} \end{subfigure}\vspace*{-0.25cm}\subcaption{SGD}} \vspace*{0.35cm} {\begin{subfigure}{\textwidth} \begin{tikzpicture} \pgfmathsetmacro{\sc}{1.925} \pgfmathsetmacro{\b}{5} \draw (0,0) -- ({\sc*(14-\b)},0); \foreach \x in {5,6,7,8,9,10,11,12,13,14} { \draw ({\sc*(\x-\b)}, 0) -- ++(0,.1) node [below=0.15cm,scale=1.25] {\tiny \x}; \ifthenelse{\x < 14}{\draw ({\sc*(\x-\b) +.5*\sc}, 0) -- ++(0,.03);}{} } \coordinate (c0) at ({\sc*(5.3333335-\b)},0); \coordinate (c1) at ({\sc*(5.4055555-\b)},0); \coordinate (c2) at ({\sc*(5.6111115-\b)},0); \coordinate (c3) at ({\sc*(5.913889-\b)},0); \coordinate (c4) at ({\sc*(6.547222-\b)},0); \coordinate (c5) at ({\sc*(6.6666665-\b)},0); \coordinate (c6) at ({\sc*(6.7194445-\b)},0); \coordinate (c7) at ({\sc*(7.2805555-\b)},0); \coordinate (c8) at ({\sc*(8.102778-\b)},0); \coordinate (c9) at ({\sc*(9.1916665-\b)},0); \coordinate (c10) at ({\sc*(9.5194445-\b)},0); \coordinate (c11) at ({\sc*(9.655556-\b)},0); \coordinate (c12) at ({\sc*(10-\b)},0); \coordinate (c13) at ({\sc*(11.088889-\b)},0); \coordinate (c14) at ({\sc*(12.963889-\b)},0); \node (l0) at (c0) [above right=.85cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EWE$^{\mathbf{r}}$}}; \node (l1) at (c1) [above right=.6cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SES$^{\mathbf{r}}$}}; \node (l2) at (c2) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EWS$^{\mathbf{r}}$}}; \node (l3) at (c3) [above right=.1cm and .02cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SEE$^{\mathbf{r}}$}}; \node (l4) at (c4) [above right=0.85cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{SE$^{\mathbf{r}}$}}; \node (l5) at (c5) [above right=.6cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ABAG}; \node (l6) at (c6) [above right=.35cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny \textbf{EW$^{\mathbf{r}}$}}; \node (l7) at (c7) [above right=.1cm and .1cm, align=center, scale=1.15] {\hspace*{-.075cm}\tiny DWM}; \node (l8) at (c8) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny OBAG}; \node (l9) at (c9) [above right=.85cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ADOB}; \node (l10) at (c10) [above right=.6cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALRV}; \node (l11) at (c11) [above right=.35cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALR}; \node (l12) at (c12) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny ALS}; \node (l13) at (c13) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny AUC/AWE}; \node (l14) at (c14) [above right=.1cm and .1cm, align=left, scale=1.15] {\hspace*{-.075cm}\tiny LNSE}; \fill[fill=gray,fill opacity=0.5] ({\sc*(5.37-\b)},-0.15) rectangle ({\sc*(5.37+2.0976-\b)},0.15); \foreach \x in {0,...,14} { \draw (l\x) -| (c\x); }; \end{tikzpicture} \end{subfigure}\vspace*{-0.25cm}\subcaption{Average}} \caption{Bonferroni-Dunn test for different strategies and other classifiers on real data streams.} \label{fig:bonferroni_ext} \end{figure} As the final part of our experimental study, we compared our best strategies (the risky ones) with some state-of-the-art classifiers, including models supported by different active learning strategies and popular ensembles. Based on the results in Tab. \ref{tab:final} and the statistical tests in Fig. \ref{fig:bonferroni_ext}, we can claim that our best strategies (in bold in the latter) are capable of significantly improving upon all baseline models using only active learning and upon most of the considered ensembles. We can distinguish EWE$^r$, EWS$^r$ and SES$^r$ methods. They outperformed all other classifiers on average, except for ABAG and DWM, which were significantly competitive, especially for AHT, even under strictly limited supervision. It exhibits their generally good resilience to such limitations. The EW-based ensembles provided the best results with AHT, while the SE-based ones dominated the highest ranks with SGD. This shows that our ensembles are able not only to improve upon single-classifier models without instance exploitation, but also to compete with state-of-the-art ensembles designed for data streams. One should also keep in mind, that while all the other committees use at least 10 base learners, our ensemble utilizes only two of them. The complementary results presented in Fig. \ref{fig:ranks} show the frequencies of occupied ranks for each of the considered methods given high ($B\geq20\%$) and low budgets ($B\leq10\%$). Unsurprisingly, we can see that the best strategies were most frequently the best ones (green bars), while very rarely ending up as the worst ones (red bars), regardless of the available supervision. One interesting observation is that our ensembles were able to maintain safer lower bounds also for the presented ranks -- they very efficiently reduced the number of lowest ranks compared with their simpler counterparts (SE$^r$, EW$^r$), bringing them down to zero for the best strategies (EWS$^r$ and EWE$^r$ for AHT, SES$^r$ and SEE$^r$ for SGD). It is important if someone cares about the worst possible scenario. \begin{figure}[h] \centering \leftskip15pt\begin{subfigure}{.49\textwidth} \begin{tikzpicture} \begin{axis}[ title={AHT / HIGH}, title style={yshift=-1.5ex}, width=\textwidth, height=0.7\textwidth, font=\scriptsize, xbar stacked, xmin=0, xmax=1, xmajorgrids=true, xlabel style={font=\tiny}, xtick style={draw=none}, grid style={dashed,white!90!black}, table/header=false, table/row sep=\\, ylabel style={font=\tiny}, ytick=data, yticklabels from table={ ALS\\ALR\\LNSE\\ALRV\\ADOB\\AUC\\OBAG\\DWM\\ABAG\\SEE$^{r}$\\SE$^{r}$\\EW$^{r}$\\SES$^{r}$\\EWS$^{r}$\\EWE$^{r}$\\ }{[index]0}, ] \addplot [ xbar, bar width=4pt, fill=green2, draw=green2, ] table[y expr=\coordindex,x index=0]{ 0.000000\\0.000000\\0.023810\\0.023810\\0.071429\\0.119048\\0.119048\\0.190476\\0.238095\\0.333333\\0.357143\\0.357143\\0.380952\\0.404762\\0.428571\\}; \addplot [ xbar, bar width=4pt, fill=green3, draw=green3, ] table[y expr=\coordindex,x index=0]{ 0.000000\\0.047619\\0.000000\\0.047619\\0.000000\\0.071429\\0.190476\\0.238095\\0.357143\\0.214286\\0.142857\\0.261905\\0.261905\\0.357143\\0.357143\\}; \addplot [ xbar, bar width=4pt, fill=blue1, draw=blue1, ] table[y expr=\coordindex,x index=0]{ 0.047619\\0.000000\\0.095238\\0.071429\\0.047619\\0.166667\\0.166667\\0.285714\\0.333333\\0.119048\\0.071429\\0.071429\\0.047619\\0.142857\\0.095238\\}; \addplot [ xbar, bar width=4pt, fill=blue2, draw=blue2, ] table[y expr=\coordindex,x index=0]{ 0.095238\\0.023810\\0.119048\\0.095238\\0.023810\\0.071429\\0.309524\\0.071429\\0.071429\\0.023810\\0.071429\\0.071429\\0.190476\\0.095238\\0.095238\\}; \addplot [ xbar, bar width=4pt, fill=blue3, draw=blue3, ] table[y expr=\coordindex,x index=0]{ 0.238095\\0.023810\\0.238095\\0.190476\\0.023810\\0.047619\\0.214286\\0.071429\\0.023810\\0.142857\\0.047619\\0.071429\\0.095238\\0.071429\\0.071429\\}; \addplot [ xbar, bar width=4pt, fill=red2, draw=red2, ] table[y expr=\coordindex,x index=0]{ 0.619048\\0.000000\\0.571429\\0.452381\\0.071429\\0.071429\\0.071429\\0.095238\\0.047619\\0.238095\\0.142857\\0.071429\\0.071429\\0.000000\\0.023810\\}; \addplot [ xbar, bar width=4pt, fill=red3, draw=red3, ] table[y expr=\coordindex,x index=0]{ 0.071429\\0.976190\\0.023810\\0.190476\\0.833333\\0.523810\\0.000000\\0.119048\\0.000000\\0.000000\\0.238095\\0.166667\\0.023810\\0.000000\\0.000000\\}; \end{axis} \end{tikzpicture}% \hspace*{0.1cm} \begin{tikzpicture} \begin{axis}[ title={AHT / LOW}, title style={yshift=-1.5ex}, width=\textwidth, height=0.7\textwidth, font=\scriptsize, xbar stacked, xmin=0, xmax=1, xmajorgrids=true, xlabel style={font=\tiny}, xtick style={draw=none}, grid style={dashed,white!90!black}, table/header=false, table/row sep=\\, ylabel style={font=\tiny}, ytick=data, yticklabels from table={ ALS\\LNSE\\ALRV\\ALR\\ADOB\\OBAG\\AUC\\DWM\\ABAG\\SEE$^{r}$\\SE$^{r}$\\SES$^{r}$\\EWE$^{r}$\\EW$^{r}$\\EWS$^{r}$\\ }{[index]0}, ] \addplot [ xbar, bar width=4pt, fill=green2, draw=green2, ] table[y expr=\coordindex,x index=0]{ 0.000000\\0.000000\\0.023810\\0.047619\\0.095238\\0.119048\\0.142857\\0.214286\\0.238095\\0.238095\\0.285714\\0.309524\\0.404762\\0.428571\\0.428571\\}; \addplot [ xbar, bar width=4pt, fill=green3, draw=green3, ] table[y expr=\coordindex,x index=0]{ 0.000000\\0.071429\\0.095238\\0.000000\\0.000000\\0.190476\\0.023810\\0.261905\\0.380952\\0.238095\\0.095238\\0.190476\\0.333333\\0.238095\\0.357143\\}; \addplot [ xbar, bar width=4pt, fill=blue1, draw=blue1, ] table[y expr=\coordindex,x index=0]{ 0.095238\\0.023810\\0.095238\\0.095238\\0.047619\\0.142857\\0.142857\\0.261905\\0.309524\\0.142857\\0.071429\\0.095238\\0.095238\\0.023810\\0.119048\\}; \addplot [ xbar, bar width=4pt, fill=blue2, draw=blue2, ] table[y expr=\coordindex,x index=0]{ 0.190476\\0.023810\\0.095238\\0.238095\\0.023810\\0.285714\\0.071429\\0.023810\\0.023810\\0.023810\\0.047619\\0.142857\\0.119048\\0.095238\\0.071429\\}; \addplot [ xbar, bar width=4pt, fill=blue3, draw=blue3, ] table[y expr=\coordindex,x index=0]{ 0.190476\\0.047619\\0.261905\\0.142857\\0.047619\\0.238095\\0.071429\\0.119048\\0.071429\\0.166667\\0.047619\\0.095238\\0.095238\\0.047619\\0.095238\\}; \addplot [ xbar, bar width=4pt, fill=red2, draw=red2, ] table[y expr=\coordindex,x index=0]{ 0.500000\\0.023810\\0.357143\\0.476190\\0.071429\\0.095238\\0.071429\\0.095238\\0.047619\\0.238095\\0.166667\\0.214286\\0.023810\\0.119048\\0.000000\\}; \addplot [ xbar, bar width=4pt, fill=red3, draw=red3, ] table[y expr=\coordindex,x index=0]{ 0.095238\\0.880952\\0.142857\\0.071429\\0.785714\\0.000000\\0.547619\\0.095238\\0.000000\\0.023810\\0.357143\\0.023810\\0.000000\\0.119048\\0.000000\\}; \end{axis} \end{tikzpicture} \vspace*{0.5cm} \begin{tikzpicture} \begin{axis}[ title={SGD / HIGH}, title style={yshift=-1.5ex}, width=\textwidth, height=0.7\textwidth, font=\scriptsize, xbar stacked, xmin=0, xmax=1, xmajorgrids=true, xlabel style={font=\tiny}, xtick style={draw=none}, grid style={dashed,white!90!black}, table/header=false, table/row sep=\\, ylabel style={font=\tiny}, ytick=data, yticklabels from table={ ALS\\ALRV\\ALR\\LNSE\\DWM\\AWE\\OBAG\\EW$^{r}$\\ABAG\\EWS$^{r}$\\ADOB\\EWE$^{r}$\\SEE$^{r}$\\SES$^{r}$\\SE$^{r}$\\ }{[index]0}, ] \addplot [ xbar, bar width=4pt, fill=green2, draw=green2, ] table[y expr=\coordindex,x index=0]{ 0.000000\\0.000000\\0.023810\\0.047619\\0.071429\\0.095238\\0.119048\\0.166667\\0.214286\\0.238095\\0.261905\\0.285714\\0.380952\\0.452381\\0.619048\\}; \addplot [ xbar, bar width=4pt, fill=green3, draw=green3, ] table[y expr=\coordindex,x index=0]{ 0.047619\\0.119048\\0.000000\\0.023810\\0.071429\\0.071429\\0.095238\\0.404762\\0.000000\\0.238095\\0.380952\\0.190476\\0.357143\\0.214286\\0.190476\\}; \addplot [ xbar, bar width=4pt, fill=blue1, draw=blue1, ] table[y expr=\coordindex,x index=0]{ 0.071429\\0.023810\\0.095238\\0.023810\\0.142857\\0.071429\\0.047619\\0.095238\\0.119048\\0.238095\\0.095238\\0.166667\\0.166667\\0.261905\\0.047619\\}; \addplot [ xbar, bar width=4pt, fill=blue2, draw=blue2, ] table[y expr=\coordindex,x index=0]{ 0.142857\\0.047619\\0.166667\\0.023810\\0.166667\\0.023810\\0.190476\\0.023810\\0.142857\\0.119048\\0.119048\\0.023810\\0.095238\\0.095238\\0.023810\\}; \addplot [ xbar, bar width=4pt, fill=blue3, draw=blue3, ] table[y expr=\coordindex,x index=0]{ 0.214286\\0.261905\\0.285714\\0.047619\\0.404762\\0.000000\\0.119048\\0.023810\\0.285714\\0.142857\\0.166667\\0.071429\\0.047619\\0.047619\\0.071429\\}; \addplot [ xbar, bar width=4pt, fill=red2, draw=red2, ] table[y expr=\coordindex,x index=0]{ 0.452381\\0.404762\\0.380952\\0.095238\\0.119048\\0.071429\\0.166667\\0.166667\\0.214286\\0.095238\\0.047619\\0.119048\\0.023810\\0.000000\\0.071429\\}; \addplot [ xbar, bar width=4pt, fill=red3, draw=red3, ] table[y expr=\coordindex,x index=0]{ 0.142857\\0.214286\\0.119048\\0.809524\\0.095238\\0.738095\\0.333333\\0.190476\\0.095238\\0.000000\\0.000000\\0.214286\\0.000000\\0.000000\\0.047619\\}; \end{axis} \end{tikzpicture}% \hspace*{0.1cm} \begin{tikzpicture} \begin{axis}[ title={SGD / LOW}, title style={yshift=-1.5ex}, width=\textwidth, height=0.7\textwidth, font=\scriptsize, xbar stacked, xmin=0, xmax=1, xmajorgrids=true, xlabel style={font=\tiny}, xtick style={draw=none}, grid style={dashed,white!90!black}, table/header=false, table/row sep=\\, ylabel style={font=\tiny}, ytick=data, yticklabels from table={ ALS\\ALRV\\ALR\\LNSE\\DWM\\AWE\\EW$^{r}$\\OBAG\\EWS$^{r}$\\ABAG\\EWE$^{r}$\\ADOB\\SEE$^{r}$\\SES$^{r}$\\SE$^{r}$\\ }{[index]0}, ] \addplot [ xbar, bar width=4pt, fill=green2, draw=green2, ] table[y expr=\coordindex,x index=0]{ 0.000000\\0.023810\\0.047619\\0.047619\\0.071429\\0.095238\\0.119048\\0.142857\\0.190476\\0.214286\\0.238095\\0.309524\\0.404762\\0.404762\\0.571429\\}; \addplot [ xbar, bar width=4pt, fill=green3, draw=green3, ] table[y expr=\coordindex,x index=0]{ 0.095238\\0.142857\\0.000000\\0.023810\\0.023810\\0.071429\\0.452381\\0.071429\\0.238095\\0.000000\\0.380952\\0.190476\\0.333333\\0.214286\\0.214286\\}; \addplot [ xbar, bar width=4pt, fill=blue1, draw=blue1, ] table[y expr=\coordindex,x index=0]{ 0.071429\\0.023810\\0.047619\\0.047619\\0.119048\\0.071429\\0.119048\\0.047619\\0.261905\\0.142857\\0.142857\\0.166667\\0.166667\\0.261905\\0.095238\\}; \addplot [ xbar, bar width=4pt, fill=blue2, draw=blue2, ] table[y expr=\coordindex,x index=0]{ 0.166667\\0.119048\\0.142857\\0.023810\\0.238095\\0.023810\\0.047619\\0.238095\\0.095238\\0.142857\\0.095238\\0.047619\\0.071429\\0.119048\\0.047619\\}; \addplot [ xbar, bar width=4pt, fill=blue3, draw=blue3, ] table[y expr=\coordindex,x index=0]{ 0.261905\\0.261905\\0.214286\\0.071429\\0.380952\\0.000000\\0.000000\\0.071429\\0.190476\\0.238095\\0.119048\\0.047619\\0.071429\\0.071429\\0.047619\\}; \addplot [ xbar, bar width=4pt, fill=red2, draw=red2, ] table[y expr=\coordindex,x index=0]{ 0.357143\\0.357143\\0.404762\\0.095238\\0.142857\\0.142857\\0.119048\\0.119048\\0.095238\\0.214286\\0.095238\\0.095238\\0.023810\\0.000000\\0.023810\\}; \addplot [ xbar, bar width=4pt, fill=red3, draw=red3, ] table[y expr=\coordindex,x index=0]{ 0.119048\\0.142857\\0.214286\\0.761905\\0.095238\\0.666667\\0.214286\\0.380952\\0.000000\\0.119048\\0.000000\\0.214286\\0.000000\\0.000000\\0.071429\\}; \end{axis} \end{tikzpicture} \end{subfigure} \vspace*{-5mm} \caption{Ranks for AHT and SGD using different strategies compared with other classifiers on real data streams.} \label{fig:ranks} \end{figure} In order to provide the reader with some specific examples of how our methods work in practice, in Fig.\ref{fig:aht_series} and Fig.\ref{fig:sgd_series} we presented accuracy series (instead of kappa for readability) registered for all real streams when the budget was reasonably limited to $B=10\%$. The best exploiting strategy, the best baseline using active learning and the best other ensemble were chosen for each stream separately. For most of the streams, we can easily notice that instance exploitation (green) was able to elevate the temporal performance of standard models that were reliant solely on active learning (red). The improvements may have diverse character. For example, our strategies were able to provide overall a more stable, saturated and higher level of predictive performance for Activity-Raw, Covertype, EGG, Sensor or Weather, among others, for both AHT and SGD. For other streams, the enhanced adaption meant that instance exploitation was able to alleviate severe temporal drops in accuracy, most likely due to concept drifts, for example, for Gas, Poker or Spam. There were very few exceptions when none of our strategies was able to provide improvements, like Airlines and DJ30, or Crimes for SGD. Finally, when compared with the considered state-of-the-art ensembles (blue), we can also see that our strategies were, in most cases, competitive in improving adaptation in the same way as against the baseline models. \begin{figure}[H] \centering \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_activity.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_activity_raw.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_airlines.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_connect4.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_covertype.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_crimes.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_dj30.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_eeg.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_elec.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_gas.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_poker.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_power.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_sensor.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_spam.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/aht-series/aht_weather.pdf} \end{subfigure}\\ \caption{Accuracy series for AHT given $B=10\%$: the best strategy vs. the best AL and the best (not our) ensemble.} \label{fig:aht_series} \end{figure} \begin{figure}[H] \centering \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_activity.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_activity_raw.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_airlines.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_connect4.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_covertype.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_crimes.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_dj30.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_eeg.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_elec.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_gas.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_poker.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_power.pdf} \end{subfigure}\\ \vspace*{8pt} \hspace*{-8pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_sensor.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_spam.pdf} \end{subfigure} \hspace*{2pt} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[width=\linewidth]{img/sgd-series/sgd_weather.pdf} \end{subfigure}\\ \caption{Accuracy series for SGD given $B=10\%$: the best strategy vs. the best AL and the best (not our) ensemble.} \label{fig:sgd_series} \end{figure} \subsubsection{Conclusions} \smallskip To summarize all the presented results and observations, we finalize our study with a list of the most important conclusions. Primarily, they address the research questions introduced at the beginning of the experimental study. \smallskip \begin{itemize} \item \textbf{Instance exploitation improves learning from drifting streams on a budget (RQ1).} In most of the considered cases, almost all strategies provided significant improvements over the baseline using only active learning and adapting in a conservative way. Without more intensive learning, the base classifiers were not able to deal with strict supervision limitations and drifts at the same time, even if supported by a more strategic label query. They struggled with providing reactive up-to-date models for dynamic temporary concepts and end up with unresolved and severe underfitting. Our method addressed this problem by forcing the classifiers to take the risk of exploiting only the labeled instances they could use and enhancing the adaptation process as a result. The improvements were more impactful for real streams. With the abundance of positive examples collected from diverse measurements and statistical tests, and supported by the fact that generally higher intensity of exploitation was preferred, we prove that the problem of underfitting is critical for realistic streaming scenarios and that risking overfitting by using instance exploitation is more reasonable in practice. \item \textbf{No free lunch theorem for strategies and settings (RQ2).} We were not able to explicitly select one of the three strategies (UW/EW, SE) as the best one. While EW$^r$ worked best with AHT, SGD exhibited the best synergy with SE$^r$. Furthermore, although all the strategies generally worked better with the more risky settings using higher values of intensity $\lambda_{max}$, we were forced to distinguish different values of this parameter for different classifiers. Also, AHT preferred larger sliding windows than SGD. The distinction was caused by the fact that some algorithms may be more reactive to changes (AHT) than others (SGD), therefore, they may need different amounts of instance exploitation. \item \textbf{Dynamic control comes with a reasonable trade-off (RQ2).} The heuristics for controlling intensity and window size in a dynamic way do not provide improvements in predictive performance in most cases, even impairing it to some limited extent. On the other hand, they are able to reduce running time and memory consumption, respectively. For the latter, adjusting the window size based on ADWIN is a contradictory exception from the observations -- this algorithm provides the best quality of classification for AHT and reliable one for SGD, while requiring more memory than most of the other windows. We would recommend using fixed intensity $\lambda_{max}$ and dynamic window size based on ADWIN ($\omega_{max}=\omega_{ADW}$), if someone does not have problems with utilization of resources. Otherwise, we suggest using dynamic intensity (Eq. \ref{eq:lambda}) and dynamic window (Eq. \ref{eq:omega}) with a limited size $\omega_{max}=1000$, while utilizing ADWIN-based error as a control signal $\epsilon=\epsilon_{ADW}$. \item \textbf{Switching and elevating alleviates the risk of overfitting (RQ3).} The ensemble-based techniques for avoiding turning one problem (underfitting) into another (overfitting) provided the assumed improvements. The methods are able to guarantee a more reliable lower bound on performance. Since we can efficiently track errors even under limited supervision, the ensembles can correctly determine a temporarily better approach. As a consequence in a prevalent number of cases (except for SGD using SE$^r$) they are at least as good as the standard or risky learner, providing additional enhancements in many scenarios. One should, however, keep in mind that the advantage of using the ensembles is usually on the brink of significance. Furthermore, we did not observed a significant difference between switching and elevating, therefore, since the latter requires very time-consuming model replacements, we recommend using switching. Finally, taking into account all considered factors, we can distinguish EWS and SES as the best methods on average. \item \textbf{Proposed strategies are competitive against other streaming classifiers (RQ4).} The final comparison revealed that our algorithms, mainly committees, not only improve upon the baseline using only active learning, but that they can also be at least competitive against some of the state-of-the-art streaming ensembles, including bagging and boosting, and outperform them in many cases. At the same time, while other ensembles utilize 10 base learners, ours use only two of them. Finally, although we could extend this comparison to more ensembles, one should notice that this study was not entirely focused on the ensemble-based methods. In fact, there is a lot of potential for further improvements in this direction. We conducted only the limited comparison to place our algorithms in some recognizable context. \end{itemize} \end{document}
{'timestamp': '2020-09-22T02:15:01', 'yymm': '2009', 'arxiv_id': '2009.09382', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09382'}
arxiv
\section{Introduction} Person re-identification (re-ID) aims at retrieving images of a person of interest captured by different cameras. It is known as an \emph{open-set problem} because identities (i.e., classes) seen at test time are different from those at training time. Effective representations must be learned in order to discriminate people (i.e., classes) never seen during training. Convolutional Neural Networks (CNNs) have achieved excellent performance on various re-ID datasets, due to their capacity to learn camera invariant and identity discriminative representations robust to appearance changes \cite{luo2019bag}. In practice, one may want to deploy a re-ID system on a different set of cameras than those used for training data, i.e. on a test set from a different distribution (brightness, colorimetry and angle of the cameras, background...). In this context of \emph{cross-dataset} testing, we observe in practice a sharp drop in re-ID performance due to the \emph{domain gap} \cite{deng2018image}. A solution may be the annotation of larger scale re-ID datasets or the target dataset itself so that a new better performing model can be trained on the target domain. To avoid these costly manual annotations, the research community focused on designing Unsupervised Domain Adaptation (UDA) algorithms. UDA aims at learning an efficient model on the target domain. It only requires labeled training samples from one or multiple domains (source domains) and unlabeled samples from the domain of interest (target domain) on which the model is tested. While extensive research is conducted for classification UDA, the open-set nature of the re-ID task makes it impossible or inefficient to directly apply closed-set approaches designed for classification \cite{panareda2017open}. Therefore, a part of computer vision researchers focuses on the peculiarities of re-ID being an open-set retrieval problem. In this setting, pseudo-labeling approaches have proven to be the best UDA methods to learn ID-discriminative features for the target domain \cite{ge2020mutual}. These ID pseudo-labels are initially predicted by clustering the target data embedded in an ID-discriminative feature space learned on source data. To do so, pseudo-labeling UDA algorithms alternate between training phases and uour baselinetes of pseudo-labels with the lastly trained model to refine them to a certain extent. Through this iterative process, the source data is not reused beyond the initialization step of the model. It can be assumed that this choice not to integrate the labeled source data aims at not biasing the learning of ID-discriminative features on target data. One could think that using source data to constrain the training would decrease adaptability to target domain and would degrade the re-ID performance on target domain. We believe that it is possible to subtly exploit the source data and their ground-truth labels to improve the representation on the target domain, while reducing the potential undesirable effects of the domain gap between the source and target data. Our contribution can be summarized as follows. \begin{itemize} \item We propose a \emph{source-guided pseudo-labeling} framework to solve \emph{cross-dataset re-ID}. It leverages the labeled source data during pseudo-labeling scheme of all training phases. \item The key element of this framework is a two-branch architecture that simultaneously optimizes classification and triplet-based metric learning in both source and target domains, in order to allow \emph{adaptability to the target domain} (high-level parameters of target branch optimized with pseudo-labels) while ensuring \emph{robustness to noisy pseudo-labels} (shared low and mid-level parameters constrained by supervised learning with source labels). \item The proposed framework is simple enough to be easily combined with existing pseudo-labeling UDA approaches. Experiments show that it is particularly effective when the base method has no special mechanism to deal with pseudo-label noise. It also improves the stability of re-ID performance with relation to the tricky choice of clustering parameters. \item Our framework combined with MMT method outperforms the state-of-the-art on the challenging cross-domain scenario of MSMT dataset. \end{itemize} In Section~\ref{related}, we review the related work. Then, we detail our proposed framework in Section~\ref{sec:framework}. The experiment settings are given in Section~\ref{exp} and results are presented in Section~\ref{Results}. \section{Related Work} \label{related} The state of the art contributions for UDA re-ID can be divided into 3 families which leverage the source data differently. \subsection{Image-to-Image translation}Image-to-Image translation methods \cite{wei2018person} \cite{deng2018image} \cite{qi2019novel} \cite{zhong2018generalizing} are based on learning how to transform images from one domain to another, preserving class information. The majority of these approaches use a CycleGAN \cite{zhu2017unpaired} model to transfer the style of the target images to the source images, while constraining the person's appearance preservation after transfer. The target-style source images are then used to learn in a supervised way a re-ID model for the target domain. Although these methods fully exploit the source images (in the target style) and their labels, they depend on the quality of image generation and the preservation of identity information after transfer. In practice, the performance obtained by these methods shows that the source images in the target style are not sufficiently representative of the target domain. \subsection{Domain invariant feature learning} Domain invariant feature learning methods look for a domain invariant discriminative feature space \cite{chang2019disjoint} \cite{lin2018multi} \cite{li2018adaptation} \cite{li2019cross}. In addition to the supervised ID discriminative loss on source samples, these approaches seek to align the source and target domain feature distributions by penalizing an unsupervised domain discrepancy loss term \cite{chang2019disjoint} \cite{lin2018multi} or learn domain invariant space by domain feature disentanglement \cite{li2018adaptation} \cite{li2019cross} sometimes with auxiliary information for supervision (semantic attribute labels, pose labels...) \cite{wang2018transferable}. As with methods that operate at the pixel level, domain invariant feature learning makes full use of source data and their labels. While they can outperform Image-to-image translation approaches \cite{chang2019disjoint} \cite{chang2019disjoint}, these methods cannot learn efficient target specific features because of domain invariance constraints and the presence of discriminative information (labels) only for the source data. \subsection{Pseudo-labeling} Pseudo-labeling methods exploit a source-trained model to initialize pseudo-identity labels for target data by clustering their feature representation by this model \cite{yu2019unsupervised} \cite{zhong19enc}. Most of pseudo-labeling UDA methods are based on an iterative paradigm which alternates between optimizing and pseudo-label refinery by uour baselinetes with the lastly optimized model on target images \cite{song2020unsupervised} \cite{zhang2019self} \cite{fu2019self} \cite{tang2019unsupervised}. However, the source biased representation and the clustering introduce some errors that can persist through iterations, be over-fitted by the model and thus degrade the pseudo-label refinery process. To avoid over-fitting the noise of these generated labels, recent work focused on improving Pseudo-labeling methods by improving their robustness to noisy labels using asymmetric co-teaching \cite{yang2019asymmetric} or mutual mean teaching with soft target labels \cite{ge2020mutual}. Even though recent Pseudo-labeling methods achieved near supervised training performance on some re-ID adaptation tasks, they still suffer from sensitivity to clustering or additional hyperparameters which can't be easily estimated in the UDA setting where no labeled target validation set is available. \cite{ge2020mutual} Moreover, we believe that they under-exploit the labeled source dataset since it is discarded after the initialization phase. While UDAP method \cite{song2020unsupervised} uses an additional weight ratio term between source and target to measure feature similarity, it is only used during the pseudo-label predictions by clustering. Moreover, their ablation studies show negligible performance gain and the source samples are still discarded from the optimization iterations. Our contribution focuses on these pseudo-label iterative methods. In contrast to the existing pseudo-labeling approaches mentioned above, we propose to better leverage the labeled source samples, beyond the initialization phase, in order to further improve their target discriminative features. Contrary to UDAP \cite{song2020unsupervised}, we leverage the source samples as well as their labels directly during the optimization phases of the iterative training. \section{Proposed framework} \label{sec:framework} \begin{figure*}[!t] \centering \includegraphics[width=1.5\columnwidth]{figs/framework.png} \caption{Unlike existing pseudo-labeling strategies (1), our framework is a source-guided (3) as it leverages the labeled source dataset during pseudo-label training. It is composed of a shared encoder $E^C$ and two domain-specific branches $E^S$ and $E^T$. The numbers of shared layers and specific layers can vary. Configuration (2) represents the extreme case when all layers are shared and there is no domain-specific branch.} \label{fig:framework} \end{figure*} In this section, we describe our source-guided pseudo label framework. As other pseudo-labeling UDA frameworks, it is composed of two distinct parts:\\ - the supervised training of the initialization model on source: we follow the supervised training guideline from used \cite{luo2019bag} by most pseudo-labeling UDA re-ID \cite{ge2020mutual} \cite{yang2019asymmetric} \\ - our source guided pseudo-label iterative training to efficiently leverage the source samples \subsection{Supervised training on source domain for initialization} Let $D^S = \{ (x^S_k,y^S_k)_{1 \leq k \leq N^S} \}$ be the labeled source training set of $N^S$ samples from $M_{S}$ different people, where $x_{k}$ represents the k-th person image and $y_{k}$ its one-hot identity label. Similarly let $D^T = \{ (x^T_k)_{1 \leq k \leq N^T} \}$ the unlabaled target training set of $N^T$ samples. $E$ denotes a learnable feature encoder. \subsubsection{Triplet Loss} To learn re-ID discriminative features, we use the batch hard Tiplet Loss \cite{hermans2017defense} to pull the same ID sample features closer to each other than other ID ones. In a batch of $N$ samples $\{ (x_k,y_k)_{1 \leq k \leq N^S} \}$, it is given by: \begin{equation} \begin{split} L_{tri} = \sum_{i=1}^{N} \max(0, \left \| E(x_{i}) - E(x_{p(i)}) \right \|_{2} \\ - \left \| E(x_{i}) - E(x_{n(i)}) \right \|_{2} + m) \label{triplet} \end{split} \end{equation} where $m$ is a fixed margin, $x_{p(i)}$ and $x_{n(i)}$ are resp. the hardest positive (the farthest batch feature sample to $x_{i}$ for the L2 distance) to and negative (the closest) samples in the batch for $x_{i}$.\\ \subsubsection{Cross-Entropy Loss} To further improve the ID discriminativeness of features, we use the classification of ID labels with the Cross-Entropy Loss. For this, we consider a classification layer given by the parameters $W = [ W_1,...,W_{M} ]$ where $M$ is the number of ID in the training set. We use the Softmax classification loss given by: \begin{equation} L_{cls} = - \sum_{i=1}^{N}y_i \log(p_i) \label{cls} \end{equation} where $ p_i = \frac{exp({W_{y_i}E(x_i)})}{\sum_{k=1}^{M}exp(W_{k}E(x_i))}$. \\ \subsubsection{Initialization phase loss} By considering a source domain classification layer $W^S = [ W^S_1,...,W^S_{M} ] $, we can define the softmax cross-entropy loss and the triplet for the source labeled training dataset as described in Eq. \ref{triplet} and \ref{cls}. Then, we train $E$ by optimizing the total loss function on source domain $L^S$ given by: \begin{equation} L^S = L_{cls}^S + L_{tri}^S \label{source_loss} \end{equation} \subsection{Source-guided pseudo-labeling UDA} \subsubsection{Noisy label regularization} In order to further exploit the source data and their labels, we propose the learning of source identity discriminative features by the feature encoder. This auxiliary task is added to the main task of learning target identity discriminative features with pseudo-labels. Since the source labels are ground-truth, this source-based auxiliary task is expected to guide the training in order to reduce the negative impact of over-fitting on erroneous target pseudo-labels, by reducting the amount of noisy data in this total (source + target) training set compared to the commonly-used target only set. \subsubsection{Two-branch architecture} To avoid biasing the model and thus the discriminative power of the target re-ID features with the source data, we choose a two-branch neural network architecture for the feature encoders as illustrated on Fig~\ref{fig:framework}. It is composed of a domain-shared encoder $E^C$ for low and mid-level features and two domain-specific encoders $E^S$ and $E_{T}$ resp. for source and target high level features. Our choice of modeling is supported by work that shows that features specialize for tasks in the top layers of the network. Our feature encoder learns two separate domain-specific feature spaces given by $E^S \circ E^C$ for the source and $E_{T} \circ E^C$ for the target. \subsubsection{Domain-specific batch-normalization} Common neural network architectures for re-ID contain batch normalization to improve the training convergence. Experiments from the paper \cite{zajkac2019split} shows that domain shift in data can reduce performance if the statistics of batch normalization layers are not computed separately for each domain. Since we learn with data from two different domains, we follow the paper suggestion in our pipeline and compute statistics separately for source and target data. \subsubsection{Our source-guided optimization criterion} Similarly to the previous section, we define for the target pseudo-labeled data, a target domain classifier $W^T$ and then analogously $L^T$ \ref{source_loss} for the target samples by considering the pseudo-labels as ground-truth labels. The optimization criterion of our Source-Guided Pseudo-labeling domain adaptation framework is given by: \begin{equation} L = L^S + L^{T} \label{loss} \end{equation} We can note that we do not introduce any additional hyperparameter pondering the source and target term. Besides the difficulty of hyperparameter estimation in the UDA setting as mentioned earlier, our framework gives positive experimental results as it is on various datasets \ref{exp}. The complete optimization procedure of our framework is detailed in the general Algorithm \ref{algo}, where we highlight in \textbf{bold} how our source-guided baseline differentiates from the classical target-only pseudo-labeling UDA. \begin{algorithm} \caption{Source-guided Pseudo-label Domain Adaptation} \begin{algorithmic}[1] \REQUIRE{Labeled source data $D^S = (X^S,Y^S)$, unlabeled target data $D^T = X^T$, clustering algorithm C, a source re-ID loss function $L^S$, a target re-ID loss function $L^T$, number of training epochs $N_{epoch}$, number of pseudo-labeling iterations $N_{iter}$, an initial encoder $E^{(0)}$, a \textbf{two-branch} encoder $E$} \STATE Train the initial encoder $E^{(0)}$ on $D^S$ by optimizing $L^S(E(X^S),Y^S)$ \STATE Initialize \textbf{two-branch} $E$ such that $\mathbf{E^S \circ E^C = E^{(0)}}$ and $E^T \circ E^C = E^{(0)}$ \FOR{$t=1$ to $N_{iter}$} \STATE Compute target features: $F^T \leftarrow E(X^T)$ \STATE Compute pairwise target feature distances: $d(F^T) \leftarrow d(F^T_i,F^T_j)_{1 \leq i,j \leq N_{T}}$ \STATE Pseudo-label some/all target samples by clustering: $ (X^T,\hat{Y^T}) \leftarrow C(d(F^T),D^T)$ \STATE Train E during $N_{epoch}$ by optimizing $\mathbf{L^S((E^S \circ E^C)(X^S), Y^S) +} L^{T}((E^T \circ E^C)(X^T), \hat{Y}^T)$ \ENDFOR \STATE Return $E^T \circ E^C$ \end{algorithmic} \label{algo} \end{algorithm} \section{Experiments} \label{exp} \subsection{Datasets} We evaluate our framework on three commonly-used re-ID datasets: Market-1501 (Market) \cite{zheng2015scalable}, DukeMTMC-re-ID (Duke) \cite{ristani2016performance} and MSMT17 (MSMT) \cite{wei2018person}. Market-1501 and DukeMTMC-re-ID are the most commonly-used datasets for re-ID evaluation. Each of them defines a domain.\\ \indent Market-1501 is composed of 32,668 labeled images from 1501 people captured by 6 outdoor cameras. It is divided into a training set of 12,936 images of 751 identities and a test set with 19,732 images of 750 identities different from the training ones.\\ \indent DukeMTMC-re-ID contains 36,411 labeled images of 702 IDs taken by 8 outdoor cameras. It is split into a training set with 6,522 images of 702 identities and 19,889 images of 702 other identities for the test set.\\ \indent MSMT17 is a larger dataset, with 126,441 labeled images of 4,101 identities collected by 15 indoor and outdoor cameras. The training set contains 32,621 images of 1,041 identities and the testing set 93,820 images of 3,060 other identities. It is worth noticing that MSMT17 is a much more challenging dataset than the other two: due to the size of its test set, its number of identities and cameras, MSMT17 is the closest dataset to the conditions of a large-scale re-ID system deployment. Therefore, re-ID UDA from Market or Duke to a larger-scale dataset such as MSMT is more difficult but also more interesting since in practice we often have few labeled data and a lot of unlaballed data.\\ \indent We evaluate our framework on the commonly tested Duke-to-Market (Duke being the labeled source and Market the unlabeled target dataset) and Market-to-Duke UDA tasks. Besides, we test our approach on the more challenging adaptation tasks Market-to-MSMT and Duke-to-MSMT UDA tasks. Mean average precision (mAP) and CMC top-1 accuracy are reported to measure our framework's performance. \subsection{Experimental settings} \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{figs/mmt_layers.png} \caption{Impact on mAP (in $\%$) of the number of shared layers used in the shared encoder $E^C$ of baseline+SG, on Duke-to-Market and Market-to-Duke.} \label{layers} \end{figure} \subsubsection{Tested models} To show that our guideline can easily be added and contribute to various pseudo-labeling UDA approaches, we choose to integrate it into two target-only frameworks: \begin{itemize} \item Our baseline: The classical pseudo-labeling UDA algorithm based on the UDAP approach \cite{song2020unsupervised} which is not designed to be robust to overfiting pseudo-labels'errors. It corresponds to the MMT \cite{ge2020mutual} framework without Mutual Mean Teaching and k-means replaced by DBSCAN clustering algorithm on the pairwise matrix of k-reciprocal encoding distances \cite{zhong2017re} of the target training features. \item Our baseline+MMT \cite{ge2020mutual} framework: actually the best state-of-the-art pseudo-labeling UDA method which mitigates for bad effects due to pseudo-label errors. It uses k-means as the clusterer in the feature space to predict target pseudo-labels based on the parirwise L2 distance matrix of the target training set features, as well as the mutual-mean teaching strategy described in their paper for pseudo-label error robustness. \end{itemize} \subsubsection{Implementation details} \label{impl} \textbf{Initialization phase.} We follow the guidelines for supervised training from the paper \cite{luo2019bag} adopted by MMT \cite{ge2020mutual}.For fair comparison, we choose the ResNet-50 \cite{he2016deep} initialized on the pretrained ImageNet weights \cite{deng2009imagenet} as our feature extractor. We use batch of 64 images composed of 16 identities and 4 shots per identity. Images are randomly flipped and resized to 256x128. Random Erasing Data augmentation \cite{zhong2017random} is not used during the initialization phase since it may reduce transferability of the source model features to the target domain thus generating more errors in pseudo-labels after UDA initialization \cite{luo2019bag}. We use ADAM as the optimizer and a weight decay of $5 \cdot 10^{-4}$. The initial learning rate is set to 0.00035 and is decreased to 1/10 of its previous value on the 40th and 70th epoch in a total of 80 epochs.\\ \indent \textbf{Pseudo-labeling phase.} Unless otherwise specified, we use as a common encoder all but the layers from the last convolutional block and after (4 first blocs of layers), as motivated by our parameter analysis \ref{layers}. We use the same initialization phase preprocessing with two batches of 64 images, adding Random Erasing Data augmentation \cite{zhong2017random}: one for source images and another one for target. We feed separately the network with the source and target batches to ensure domain-specific batch normalization statistics as explained in Section \ref{sec:framework}. For our baseline, after each uour baselinete phase of the pseudo-labels, the pseudo-ID and their number can change. Therefore we initialize randomly a new classification layer for target after each pseudo-labels our baseline. Other hyperparameters (clusterer parameter, triplet loss margin, number of iterations for pseudo-labeling,...) used after the initialization phase are kept the same as the UDA paper's ones (resp MMT's ones): they correspond to the best hyperparameters found after validation on the target test set in their papers.\\ \indent \textbf{Source-Guided (SG) versions.} For the baseline+SG framework, it is the direct application of our source-guided Algorithm \ref{algo}. For our baseline+MMT+SG, the two-branch architecture is adopted for the two models (mean teacher and student) that train mutually in their baseline. It implies that we do not modify the soft and hard label loss weighting and we directly add the source term (on hard labels) as described in Eq. \ref{loss}. \section{Results} \label{Results} In this part, we conduct parameter analysis and comparison with existing state-of-the-art re-ID UDA methods. \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/p_d2m.png} \caption{Robustness of our baseline+SG to $p$ parameter's changes ($p$ controls DBSCAN neighborhood distance parameter) compared to the target-only framework our baseline on Duke-to-Market.} \label{p_d2m} \end{figure} \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{figs/p_m2d.png} \caption{Robustness of our baseline+SG to $p$ parameter's changes ($p$ controls DBSCAN neighborhood distance parameter) compared to the target-only framework our baseline on Market-to-Duke.} \label{p_m2d} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtm2d.png} \caption{Robustness of our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Market-to-Duke.} \label{mmt_m2d} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtd2m.png} \caption{Robustness of our our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Duke-to-Market.} \label{mmt_d2m} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtd2msmt.png} \caption{Robustness of our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Duke-to-MSMT.} \label{p_d2msmt} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtm2msmt.png} \caption{Robustness of our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Market-to-MSMT.} \label{p_m2msmt} \end{figure} \subsection{Parameter analysis.} \subsubsection{Do the source domain help the model to learn better target features ?} As explained and motivated in Section \ref{sec:framework}, we propose a two-branch architecture to learn domain-specific high level ID discriminative features based on low and mid level domain-shared features learned with labeled source data and pseudo-labeled target data. We can wonder if our two-branch encoder manages to leverage the source samples to improve the target features. Furthermore, we would like to know how many layers we should share to take advantage from the labeled source data without negatively biasing the target features.\\ To answer these two questions, we vary the number of ResNet-50 layers shared between source and target domain through the $E^C$ encoder of our Source-Guided baseline. The ResNet-50 architecture can be divided into $5$ convolutional blocks of layers defined in the ResNet paper \cite{he2016deep} to which we refer to vary the number of shared layers. Case "$0$ shared layer" corresponds to the classical target-only pseudo-labeling methods (Figure \ref{fig:framework}(1)) which corresponds to our baseline, where case "$5$ shared layers" to sharing the whole ResNet50 between source and target domain. \indent Experiments show on Fig.\ref{layers} increasing performances when the number shared layers increase. More precisely, the best mAP is reached for $4$ shared block of layers: $59.1\%$ mAP for Duke-to-Market and $55.6\%$ mAP for Market-to-Duke, increasing resp. the performances by $4.8 p.p.$ and $5.5 p.p.$ compared to the target only model. Our source-guided baseline outperforms the classical target-only pseudo-labeling baseline and our partially-shared strategy gives the best results for Duke-to-Market and Market-to-Duke. Moreover, we also notice that the slight drop of performances for a fully-shared model may highlight a trade-off between: \begin{itemize} \item Sharing the highest level (specifically the last one) layers which can benefit the most from the auxiliary source re-ID task regularization \item Biasing the highest level feature space which is directly used for re-ID on target domain. \end{itemize} \subsubsection{Efficiency of Specific Batch Normalization} \begin{table}[t] \caption{Impact of domain-specific batch-normalization on domain adaptation performance (mAP in $\%$) .} \label{batchnorm} \begin{tabular}{|c|c|c|} \hline \multirow{2}{*}{Methods} & Market-to-Duke & Duke-to-Market \\ \cline{2-3} & mAP & mAP \\ \hline baseline & 50.1 & 54.3 \\ Domain-Shared BatchNorm baseline+SG & 36.7 & 43.1 \\ Domain-Specific BatchNorm baseline+SG & \textbf{55.6} & \textbf{59.1} \\ \hline \end{tabular} \end{table} We study the effectiveness of domain-specific batch nornmalization as motivated in Section \ref{sec:framework}. \. To do so, we compare our baseline+SG framework to a version that shares the batch normalization between domains (Domain Shared BatchNorm baseline+SG). From Table \ref{batchnorm}, we notice that sharing the batch normalization deteriorates the performance on both couples of Market-to-Duke and Duke-to-Market adaptation datasets. mAP drop more than $-10$ p.p. below the model using only the target data (our baseline). Only the addition of domain-specific batch normalization increases the performances of our framework above the our baseline model. These experiments therefore show that the use of domain-specific batch normalization is an essential key of our framework in order not to deteriorate the learning of discriminative target features by biasing the batch normalization statistics. \subsubsection{Is our strategy of using source samples robust to clustering parameters changes ?} \indent In the UDA setting, choosing or tuning hyperparameter is a tricky task due to the absence of a labeled validation set for the target domain. It is therefore important in practice to design UDA methods robust to hyperparameter changes. In particular, pseudo-labeling UDA methods \cite{song2020unsupervised} \cite{ge2020mutual} give experimental evidences that performance can be very sensible to clustering parameters changes. That's why we would like to focus in this part on the performance of our source-guided frameworks when these clustering parameters change. For the baseline+SG baseline, we study the $p$ parameter of DBSCAN as defined and studied in UDAP paper \cite{song2020unsupervised} and for our baseline+MMT+SG we focus on the $k$ paremeter of k-means as in the MMT paper \cite{ge2020mutual}. We compare our two frameworks to their target-only versions. \indent The $p$ parameter directly controls the DBSCAN neighborhood distance parameter in our baseline and baseline+SG: it determines the percentage of the smallest distances to be used to define clusters in the feature space. We vary $p$ in the same interval of the UDAP paper \cite{song2020unsupervised}. By doing so, we notice that for Duke-to-Market in Figure \ref{p_d2m} and Market-to-Duke in Figure \ref{p_m2d}, in baseline+SG the source benefits the domain adaptation by pseudo-labeling: we go from $50.6\%$ to $55.9\%$ on Market-to-Duke and from $54.6\%$ to $59.4\%$ by comparison to the target only version. For every parameter value $p$, there is an improvement in performance for baseline+SG ranging from at least $3.4$ p.p. for Market-to-Duke and $4$ p.p. for Duke-to-Market in comparison to the target only baseline our baseline: *** our framework seems to be robust to the change of parameters $p$. \indent The $k$ parameter determines the number of clusters in the MMT frameworks. We choose the same interval of values as in the MMT paper \cite{ge2020mutual} for varying the $k$ parameter. For Maket-to-Duke and Duke-to-Market in Figures \ref{mmt_m2d} and \ref{mmt_d2m}, the addition of the source term with our baseline+MMT+SG does not seem to increase the maximum performance, which is reached by the classical target-only MMT model. Nevertheless, there are quite different performance curve trends between MMT and our baseline+MMT+SG. our baseline+MMT+SG seems to be more robust for $k$ values above 800 (Market and Duke containing 751 and 702 identities respectively), i.e. when a number of clusters is chosen above the actual number of identities. While MMT already proposes a strategy of resistance to pseudo-label noise, which can explain the non improvement of the best mAP, the addition of the source-guidance in our baseline+MMT+SG seems to confer more stability to the clusterer parameter variations. Numerically, this stability can be observed by calculating the standard deviation (std) of the mAPs over $k$: using the source, we go from $2.5$ p.p. to $1.2$ p.p. on Duke-to-Market and from $1.6$ p.p. to $0.9$ p.p. on Market-to-Duke, with on average equivalent performance for the two pairs of data sets. This stability conferred by the source is interesting given that we not know the number of identities of the training set target, which can only be estimated at best. We believe that the number of ground-truth ID for the source dataset might help to reduce the impact on training of the cluster surplus of the target set.\\ \indent In the more challenging cases where MSMT is the target dataset, there is a clear contribution from the source. We can see in Figures \ref{p_m2msmt} and \ref{p_d2msmt} that it is stable to the change in $k$ and allowed to increase the maximum performance: from $23.5$\% to $27.5$\% for Duke-to-MSMT and from $22.9$\% to $23.5$\% for Market-to-MSMT. There is also a higher source contribution at high $k$ values. It can be assumed that our baseline+MMT+SG works better in this more challenging case of adaptation because of the presence of more noisy labels during the transfer of the source model for initialization of pseudo-labeling: adding our strategy of exploiting source data therefore presents less redundancy with the one already implemented in the MMT framework, and even more if we "over-estimate" the number of clusters. \subsection{Comparison with state-of-the-art methods} \label{sec:sota} \begin{table}[t] \begin{center} \caption{Comparison with state-of-the-art methods.} \label{table^Sota} \begin{tabular}{ccccc} \hline \multicolumn{1}{|c|}{\multirow{2}{*}{Methods}} & \multicolumn{2}{c|}{Market-to-Duke} & \multicolumn{2}{c|}{Duke-to-Market} \\ \cline{2-5} \multicolumn{1}{|c|}{} & mAP & \multicolumn{1}{c|}{top-1} & mAP & \multicolumn{1}{c|}{top-1} \\ \hline \multicolumn{1}{|c|}{SPGAN \cite{deng2018image}} & 22.3 & \multicolumn{1}{c|}{41.1} & 22.8 & \multicolumn{1}{c|}{51.5} \\ \multicolumn{1}{|c|}{TJ-AIDL \cite{wang2018transferable}} & 23.0 & \multicolumn{1}{c|}{44.3} & 26.5 & \multicolumn{1}{c|}{58.2} \\ \multicolumn{1}{|c|}{MMFA \cite{lin2018multi}} & 24.7 & \multicolumn{1}{c|}{45.3} & 38.3 & \multicolumn{1}{c|}{66.2} \\ \multicolumn{1}{|c|}{HHL \cite{zhong2018generalizing}} & 27.2 & \multicolumn{1}{c|}{46.9} & 31.4 & \multicolumn{1}{c|}{62.2} \\ \multicolumn{1}{|c|}{CFSM \cite{chang2019disjoint}} & 27.3 & \multicolumn{1}{c|}{49.8} & 28.3 & \multicolumn{1}{c|}{61.2} \\ \multicolumn{1}{|c|}{UCDA-CCE \cite{qi2019novel}} & 31.0 & \multicolumn{1}{c|}{47.7} & 30.9 & \multicolumn{1}{c|}{60.4} \\ \multicolumn{1}{|c|}{ARN \cite{li2018adaptation}} & 33.4 & \multicolumn{1}{c|}{60.2} & 39.4 & \multicolumn{1}{c|}{70.3} \\ \multicolumn{1}{|c|}{ECN \cite{zhong19enc}} & 40.4 & \multicolumn{1}{c|}{63.3} & 43.0 & \multicolumn{1}{c|}{75.1} \\ \multicolumn{1}{|c|}{PoseDA-Net \cite{li2019cross}} & 45.1 & \multicolumn{1}{c|}{63.2} & 47.6 & \multicolumn{1}{c|}{75.2} \\ \multicolumn{1}{|c|}{UDAP \cite{song2020unsupervised}} & 49.0 & \multicolumn{1}{c|}{68.4} & 53.7 & \multicolumn{1}{c|}{75.8} \\ \multicolumn{1}{|c|}{SSG \cite{fu2019self}} & 53.4 & \multicolumn{1}{c|}{73.0} & 58.3 & \multicolumn{1}{c|}{80.0} \\ \multicolumn{1}{|c|}{ISSDA-re-ID \cite{tang2019unsupervised}} & 54.1 & \multicolumn{1}{c|}{72.8} & 63.1 & \multicolumn{1}{c|}{81.3} \\ \multicolumn{1}{|c|}{PCB-PAST \cite{zhang2019self}} & 54.3 & \multicolumn{1}{c|}{72.4} & 54.6 & \multicolumn{1}{c|}{78.4} \\ \multicolumn{1}{|c|}{ACT \cite{yang2019asymmetric}} & 54.5 & \multicolumn{1}{c|}{72.4} & 60.6 & \multicolumn{1}{c|}{80.5} \\ \multicolumn{1}{|c|}{MMT \cite{ge2020mutual}} & \textbf{65.1} & \multicolumn{1}{c|}{78.0} & \textbf{71.2} & \multicolumn{1}{c|}{87.7} \\ \multicolumn{1}{|c|}{Our (target-only) baseline} & 50.1 & \multicolumn{1}{c|}{70.1} & 54.3 & \multicolumn{1}{c|}{73.5} \\ \hline \multicolumn{1}{|c|}{Our baseline+SG} & 55.6 & \multicolumn{1}{c|}{73.2} & 59.1 & \multicolumn{1}{c|}{80.8} \\ \multicolumn{1}{|c|}{Our baseline+MMT+SG} & 64.8 & \multicolumn{1}{c|}{\textbf{78.5}} & 70.5 & \multicolumn{1}{c|}{\textbf{88.1}} \\ \hline \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\ \hline \multicolumn{1}{|c|}{\multirow{2}{*}{Methods}} & \multicolumn{2}{c|}{Market-to-MSMT} & \multicolumn{2}{c|}{Duke-to-MSMT} \\ \cline{2-5} \multicolumn{1}{|c|}{} & mAP & \multicolumn{1}{c|}{top-1} & mAP & \multicolumn{1}{c|}{top-1} \\ \hline \multicolumn{1}{|c|}{PTGAN \cite{wei2018person}} & 2.9 & \multicolumn{1}{c|}{10.2} & 3.3 & \multicolumn{1}{c|}{11.8} \\ \multicolumn{1}{|c|}{ECN \cite{qi2019novel}} & 8.5 & \multicolumn{1}{c|}{25.3} & 10.2 & \multicolumn{1}{c|}{30.2} \\ \multicolumn{1}{|c|}{UDAP \cite{song2020unsupervised}} & 12.0 & \multicolumn{1}{c|}{30.5} & 16.0 & \multicolumn{1}{c|}{39.2} \\ \multicolumn{1}{|c|}{SSG \cite{fu2019self}} & 13.2 & \multicolumn{1}{c|}{49.6} & 13.3 & \multicolumn{1}{c|}{32.2} \\ \multicolumn{1}{|c|}{MMT \cite{ge2020mutual}} & 22.9 & \multicolumn{1}{c|}{49.2} & 23.5 & \multicolumn{1}{c|}{50.1} \\ \multicolumn{1}{|c|}{Our (target-only) baseline} & 11.6 & \multicolumn{1}{c|}{29.8} & 14.8 & \multicolumn{1}{c|}{36.1} \\ \hline \multicolumn{1}{|c|}{Our baseline+SG} & 14.9 & \multicolumn{1}{c|}{35.4} & 19.3 & \multicolumn{1}{c|}{45.6} \\ \multicolumn{1}{|c|}{Our baseline+MMT+SG} & \textbf{23.5} & \multicolumn{1}{c|}{\textbf{50.2}} & \textbf{27.5} & \multicolumn{1}{c|}{\textbf{56.1}} \\ \hline \end{tabular} \end{center} \end{table} \indent We compare in Table~\ref{table^Sota} our two source-guided frameworks with the state of the art on Duke-to-Market, Market-to-Duke, Market-to-MSMT and Duke-to-MSMT.\\ \indent On Market-to-Duke and Duke-to-Market, our two frameworks far exceed those that do not use pseudo-labels at all. Our frameworks outperform all state of the art methods except MMT on Market-to-Duke and Duke-to-Market. Specifically, baseline+SG outperforms similar Pseudo-labeling methods that do not exploit the labeled source data after pseudo-label initialization: UDAP and PCB-PAST, but also those that integrate noise resistance or error filtering strategies in pseudo-labels such as ISSDA-re-ID, SSG and ACT on Maket-to-Duke. On Duke-to-Market, ISSDA-re-ID surpasses baseline+SG, even if baseline+SG has the advantage of simple integration in any framework and needs few additional parameters (no need to train a CycleGAN or a second model for asymmetric co-teaching).\\ Even if our baseline+MMT+SG, has a slightly lower maximum mAP than MMT, it offers the advantage of a better stability on the parameter of the number of clusters (estimated) as seen in the parameter analysis part, which is a major asset in domain adaptation.\\ \indent On Market-to-MSMT and Duke-to-MSMT, our baseline+SG framework exceeds all methods except MMT. In particular, it exceeds SSG by $+1.7$ p.p. mAP on Market-to-MSMT and UDAP by $+3.3$ p.p. on Duke-to-MSMT. The our baseline+MMT+SG framework exceeds the state of the art on these two pairs of data sets: on Market-to-MSMT and Duke-to-MSMT, our baseline+MMT+SG resp. increases performance by $+0.6$ p.p. and by $+4$ p.p. on Duke-to-MSMT. \section{Conclusion} In this paper, we propose a guideline to leverage the commonly under-used ground-truth labeled source samples during pseudo-labeling domain adaptation. It consists of guiding the target pseudo-label training stage with an auxiliary ID-discriminative source feature learning task, while preventing the source samples from biasing the training by using domain-specific batch normalization and an architecture with two domain-specific branches. Experiments on combining our framework with two state-of-the-art methods are carried out on different datasets. They show that leveraging the source samples brings more stability with relation to the choice of clustering parameters and improves performance on particularly challenging adaptation settings. \printbibliography \end{document} \section{Introduction} Person re-identification (re-ID) aims at retrieving images of a person of interest captured by different cameras. It is known as an \emph{open-set problem} because identities (i.e., classes) seen at test time are different from those at training time. Effective representations must be learned in order to discriminate people (i.e., classes) never seen during training. Convolutional Neural Networks (CNNs) have achieved excellent performance on various re-ID datasets, due to their capacity to learn camera invariant and identity discriminative representations robust to appearance changes \cite{luo2019bag}. In practice, one may want to deploy a re-ID system on a different set of cameras than those used for training data, i.e. on a test set from a different distribution (brightness, colorimetry and angle of the cameras, background...). In this context of \emph{cross-dataset} testing, we observe in practice a sharp drop in re-ID performance due to the \emph{domain gap} \cite{deng2018image}. A solution may be the annotation of larger scale re-ID datasets or the target dataset itself so that a new better performing model can be trained on the target domain. To avoid these costly manual annotations, the research community focused on designing Unsupervised Domain Adaptation (UDA) algorithms. UDA aims at learning an efficient model on the target domain. It only requires labeled training samples from one or multiple domains (source domains) and unlabeled samples from the domain of interest (target domain) on which the model is tested. While extensive research is conducted for classification UDA, the open-set nature of the re-ID task makes it impossible or inefficient to directly apply closed-set approaches designed for classification \cite{panareda2017open}. Therefore, a part of computer vision researchers focuses on the peculiarities of re-ID being an open-set retrieval problem. In this setting, pseudo-labeling approaches have proven to be the best UDA methods to learn ID-discriminative features for the target domain \cite{ge2020mutual}. These ID pseudo-labels are initially predicted by clustering the target data embedded in an ID-discriminative feature space learned on source data. To do so, pseudo-labeling UDA algorithms alternate between training phases and uour baselinetes of pseudo-labels with the lastly trained model to refine them to a certain extent. Through this iterative process, the source data is not reused beyond the initialization step of the model. It can be assumed that this choice not to integrate the labeled source data aims at not biasing the learning of ID-discriminative features on target data. One could think that using source data to constrain the training would decrease adaptability to target domain and would degrade the re-ID performance on target domain. We believe that it is possible to subtly exploit the source data and their ground-truth labels to improve the representation on the target domain, while reducing the potential undesirable effects of the domain gap between the source and target data. Our contribution can be summarized as follows. \begin{itemize} \item We propose a \emph{source-guided pseudo-labeling} framework to solve \emph{cross-dataset re-ID}. It leverages the labeled source data during pseudo-labeling scheme of all training phases. \item The key element of this framework is a two-branch architecture that simultaneously optimizes classification and triplet-based metric learning in both source and target domains, in order to allow \emph{adaptability to the target domain} (high-level parameters of target branch optimized with pseudo-labels) while ensuring \emph{robustness to noisy pseudo-labels} (shared low and mid-level parameters constrained by supervised learning with source labels). \item The proposed framework is simple enough to be easily combined with existing pseudo-labeling UDA approaches. Experiments show that it is particularly effective when the base method has no special mechanism to deal with pseudo-label noise. It also improves the stability of re-ID performance with relation to the tricky choice of clustering parameters. \item Our framework combined with MMT method outperforms the state-of-the-art on the challenging cross-domain scenario of MSMT dataset. \end{itemize} In Section~\ref{related}, we review the related work. Then, we detail our proposed framework in Section~\ref{sec:framework}. The experiment settings are given in Section~\ref{exp} and results are presented in Section~\ref{Results}. \section{Related Work} \label{related} The state of the art contributions for UDA re-ID can be divided into 3 families which leverage the source data differently. \subsection{Image-to-Image translation}Image-to-Image translation methods \cite{wei2018person} \cite{deng2018image} \cite{qi2019novel} \cite{zhong2018generalizing} are based on learning how to transform images from one domain to another, preserving class information. The majority of these approaches use a CycleGAN \cite{zhu2017unpaired} model to transfer the style of the target images to the source images, while constraining the person's appearance preservation after transfer. The target-style source images are then used to learn in a supervised way a re-ID model for the target domain. Although these methods fully exploit the source images (in the target style) and their labels, they depend on the quality of image generation and the preservation of identity information after transfer. In practice, the performance obtained by these methods shows that the source images in the target style are not sufficiently representative of the target domain. \subsection{Domain invariant feature learning} Domain invariant feature learning methods look for a domain invariant discriminative feature space \cite{chang2019disjoint} \cite{lin2018multi} \cite{li2018adaptation} \cite{li2019cross}. In addition to the supervised ID discriminative loss on source samples, these approaches seek to align the source and target domain feature distributions by penalizing an unsupervised domain discrepancy loss term \cite{chang2019disjoint} \cite{lin2018multi} or learn domain invariant space by domain feature disentanglement \cite{li2018adaptation} \cite{li2019cross} sometimes with auxiliary information for supervision (semantic attribute labels, pose labels...) \cite{wang2018transferable}. As with methods that operate at the pixel level, domain invariant feature learning makes full use of source data and their labels. While they can outperform Image-to-image translation approaches \cite{chang2019disjoint} \cite{chang2019disjoint}, these methods cannot learn efficient target specific features because of domain invariance constraints and the presence of discriminative information (labels) only for the source data. \subsection{Pseudo-labeling} Pseudo-labeling methods exploit a source-trained model to initialize pseudo-identity labels for target data by clustering their feature representation by this model \cite{yu2019unsupervised} \cite{zhong19enc}. Most of pseudo-labeling UDA methods are based on an iterative paradigm which alternates between optimizing and pseudo-label refinery by uour baselinetes with the lastly optimized model on target images \cite{song2020unsupervised} \cite{zhang2019self} \cite{fu2019self} \cite{tang2019unsupervised}. However, the source biased representation and the clustering introduce some errors that can persist through iterations, be over-fitted by the model and thus degrade the pseudo-label refinery process. To avoid over-fitting the noise of these generated labels, recent work focused on improving Pseudo-labeling methods by improving their robustness to noisy labels using asymmetric co-teaching \cite{yang2019asymmetric} or mutual mean teaching with soft target labels \cite{ge2020mutual}. Even though recent Pseudo-labeling methods achieved near supervised training performance on some re-ID adaptation tasks, they still suffer from sensitivity to clustering or additional hyperparameters which can't be easily estimated in the UDA setting where no labeled target validation set is available. \cite{ge2020mutual} Moreover, we believe that they under-exploit the labeled source dataset since it is discarded after the initialization phase. While UDAP method \cite{song2020unsupervised} uses an additional weight ratio term between source and target to measure feature similarity, it is only used during the pseudo-label predictions by clustering. Moreover, their ablation studies show negligible performance gain and the source samples are still discarded from the optimization iterations. Our contribution focuses on these pseudo-label iterative methods. In contrast to the existing pseudo-labeling approaches mentioned above, we propose to better leverage the labeled source samples, beyond the initialization phase, in order to further improve their target discriminative features. Contrary to UDAP \cite{song2020unsupervised}, we leverage the source samples as well as their labels directly during the optimization phases of the iterative training. \section{Proposed framework} \label{sec:framework} \begin{figure*}[!t] \centering \includegraphics[width=1.5\columnwidth]{figs/framework.png} \caption{Unlike existing pseudo-labeling strategies (1), our framework is a source-guided (3) as it leverages the labeled source dataset during pseudo-label training. It is composed of a shared encoder $E^C$ and two domain-specific branches $E^S$ and $E^T$. The numbers of shared layers and specific layers can vary. Configuration (2) represents the extreme case when all layers are shared and there is no domain-specific branch.} \label{fig:framework} \end{figure*} In this section, we describe our source-guided pseudo label framework. As other pseudo-labeling UDA frameworks, it is composed of two distinct parts:\\ - the supervised training of the initialization model on source: we follow the supervised training guideline from used \cite{luo2019bag} by most pseudo-labeling UDA re-ID \cite{ge2020mutual} \cite{yang2019asymmetric} \\ - our source guided pseudo-label iterative training to efficiently leverage the source samples \subsection{Supervised training on source domain for initialization} Let $D^S = \{ (x^S_k,y^S_k)_{1 \leq k \leq N^S} \}$ be the labeled source training set of $N^S$ samples from $M_{S}$ different people, where $x_{k}$ represents the k-th person image and $y_{k}$ its one-hot identity label. Similarly let $D^T = \{ (x^T_k)_{1 \leq k \leq N^T} \}$ the unlabaled target training set of $N^T$ samples. $E$ denotes a learnable feature encoder. \subsubsection{Triplet Loss} To learn re-ID discriminative features, we use the batch hard Tiplet Loss \cite{hermans2017defense} to pull the same ID sample features closer to each other than other ID ones. In a batch of $N$ samples $\{ (x_k,y_k)_{1 \leq k \leq N^S} \}$, it is given by: \begin{equation} \begin{split} L_{tri} = \sum_{i=1}^{N} \max(0, \left \| E(x_{i}) - E(x_{p(i)}) \right \|_{2} \\ - \left \| E(x_{i}) - E(x_{n(i)}) \right \|_{2} + m) \label{triplet} \end{split} \end{equation} where $m$ is a fixed margin, $x_{p(i)}$ and $x_{n(i)}$ are resp. the hardest positive (the farthest batch feature sample to $x_{i}$ for the L2 distance) to and negative (the closest) samples in the batch for $x_{i}$.\\ \subsubsection{Cross-Entropy Loss} To further improve the ID discriminativeness of features, we use the classification of ID labels with the Cross-Entropy Loss. For this, we consider a classification layer given by the parameters $W = [ W_1,...,W_{M} ]$ where $M$ is the number of ID in the training set. We use the Softmax classification loss given by: \begin{equation} L_{cls} = - \sum_{i=1}^{N}y_i \log(p_i) \label{cls} \end{equation} where $ p_i = \frac{exp({W_{y_i}E(x_i)})}{\sum_{k=1}^{M}exp(W_{k}E(x_i))}$. \\ \subsubsection{Initialization phase loss} By considering a source domain classification layer $W^S = [ W^S_1,...,W^S_{M} ] $, we can define the softmax cross-entropy loss and the triplet for the source labeled training dataset as described in Eq. \ref{triplet} and \ref{cls}. Then, we train $E$ by optimizing the total loss function on source domain $L^S$ given by: \begin{equation} L^S = L_{cls}^S + L_{tri}^S \label{source_loss} \end{equation} \subsection{Source-guided pseudo-labeling UDA} \subsubsection{Noisy label regularization} In order to further exploit the source data and their labels, we propose the learning of source identity discriminative features by the feature encoder. This auxiliary task is added to the main task of learning target identity discriminative features with pseudo-labels. Since the source labels are ground-truth, this source-based auxiliary task is expected to guide the training in order to reduce the negative impact of over-fitting on erroneous target pseudo-labels, by reducting the amount of noisy data in this total (source + target) training set compared to the commonly-used target only set. \subsubsection{Two-branch architecture} To avoid biasing the model and thus the discriminative power of the target re-ID features with the source data, we choose a two-branch neural network architecture for the feature encoders as illustrated on Fig~\ref{fig:framework}. It is composed of a domain-shared encoder $E^C$ for low and mid-level features and two domain-specific encoders $E^S$ and $E_{T}$ resp. for source and target high level features. Our choice of modeling is supported by work that shows that features specialize for tasks in the top layers of the network. Our feature encoder learns two separate domain-specific feature spaces given by $E^S \circ E^C$ for the source and $E_{T} \circ E^C$ for the target. \subsubsection{Domain-specific batch-normalization} Common neural network architectures for re-ID contain batch normalization to improve the training convergence. Experiments from the paper \cite{zajkac2019split} shows that domain shift in data can reduce performance if the statistics of batch normalization layers are not computed separately for each domain. Since we learn with data from two different domains, we follow the paper suggestion in our pipeline and compute statistics separately for source and target data. \subsubsection{Our source-guided optimization criterion} Similarly to the previous section, we define for the target pseudo-labeled data, a target domain classifier $W^T$ and then analogously $L^T$ \ref{source_loss} for the target samples by considering the pseudo-labels as ground-truth labels. The optimization criterion of our Source-Guided Pseudo-labeling domain adaptation framework is given by: \begin{equation} L = L^S + L^{T} \label{loss} \end{equation} We can note that we do not introduce any additional hyperparameter pondering the source and target term. Besides the difficulty of hyperparameter estimation in the UDA setting as mentioned earlier, our framework gives positive experimental results as it is on various datasets \ref{exp}. The complete optimization procedure of our framework is detailed in the general Algorithm \ref{algo}, where we highlight in \textbf{bold} how our source-guided baseline differentiates from the classical target-only pseudo-labeling UDA. \begin{algorithm} \caption{Source-guided Pseudo-label Domain Adaptation} \begin{algorithmic}[1] \REQUIRE{Labeled source data $D^S = (X^S,Y^S)$, unlabeled target data $D^T = X^T$, clustering algorithm C, a source re-ID loss function $L^S$, a target re-ID loss function $L^T$, number of training epochs $N_{epoch}$, number of pseudo-labeling iterations $N_{iter}$, an initial encoder $E^{(0)}$, a \textbf{two-branch} encoder $E$} \STATE Train the initial encoder $E^{(0)}$ on $D^S$ by optimizing $L^S(E(X^S),Y^S)$ \STATE Initialize \textbf{two-branch} $E$ such that $\mathbf{E^S \circ E^C = E^{(0)}}$ and $E^T \circ E^C = E^{(0)}$ \FOR{$t=1$ to $N_{iter}$} \STATE Compute target features: $F^T \leftarrow E(X^T)$ \STATE Compute pairwise target feature distances: $d(F^T) \leftarrow d(F^T_i,F^T_j)_{1 \leq i,j \leq N_{T}}$ \STATE Pseudo-label some/all target samples by clustering: $ (X^T,\hat{Y^T}) \leftarrow C(d(F^T),D^T)$ \STATE Train E during $N_{epoch}$ by optimizing $\mathbf{L^S((E^S \circ E^C)(X^S), Y^S) +} L^{T}((E^T \circ E^C)(X^T), \hat{Y}^T)$ \ENDFOR \STATE Return $E^T \circ E^C$ \end{algorithmic} \label{algo} \end{algorithm} \section{Experiments} \label{exp} \subsection{Datasets} We evaluate our framework on three commonly-used re-ID datasets: Market-1501 (Market) \cite{zheng2015scalable}, DukeMTMC-re-ID (Duke) \cite{ristani2016performance} and MSMT17 (MSMT) \cite{wei2018person}. Market-1501 and DukeMTMC-re-ID are the most commonly-used datasets for re-ID evaluation. Each of them defines a domain.\\ \indent Market-1501 is composed of 32,668 labeled images from 1501 people captured by 6 outdoor cameras. It is divided into a training set of 12,936 images of 751 identities and a test set with 19,732 images of 750 identities different from the training ones.\\ \indent DukeMTMC-re-ID contains 36,411 labeled images of 702 IDs taken by 8 outdoor cameras. It is split into a training set with 6,522 images of 702 identities and 19,889 images of 702 other identities for the test set.\\ \indent MSMT17 is a larger dataset, with 126,441 labeled images of 4,101 identities collected by 15 indoor and outdoor cameras. The training set contains 32,621 images of 1,041 identities and the testing set 93,820 images of 3,060 other identities. It is worth noticing that MSMT17 is a much more challenging dataset than the other two: due to the size of its test set, its number of identities and cameras, MSMT17 is the closest dataset to the conditions of a large-scale re-ID system deployment. Therefore, re-ID UDA from Market or Duke to a larger-scale dataset such as MSMT is more difficult but also more interesting since in practice we often have few labeled data and a lot of unlaballed data.\\ \indent We evaluate our framework on the commonly tested Duke-to-Market (Duke being the labeled source and Market the unlabeled target dataset) and Market-to-Duke UDA tasks. Besides, we test our approach on the more challenging adaptation tasks Market-to-MSMT and Duke-to-MSMT UDA tasks. Mean average precision (mAP) and CMC top-1 accuracy are reported to measure our framework's performance. \subsection{Experimental settings} \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{figs/mmt_layers.png} \caption{Impact on mAP (in $\%$) of the number of shared layers used in the shared encoder $E^C$ of baseline+SG, on Duke-to-Market and Market-to-Duke.} \label{layers} \end{figure} \subsubsection{Tested models} To show that our guideline can easily be added and contribute to various pseudo-labeling UDA approaches, we choose to integrate it into two target-only frameworks: \begin{itemize} \item Our baseline: The classical pseudo-labeling UDA algorithm based on the UDAP approach \cite{song2020unsupervised} which is not designed to be robust to overfiting pseudo-labels'errors. It corresponds to the MMT \cite{ge2020mutual} framework without Mutual Mean Teaching and k-means replaced by DBSCAN clustering algorithm on the pairwise matrix of k-reciprocal encoding distances \cite{zhong2017re} of the target training features. \item Our baseline+MMT \cite{ge2020mutual} framework: actually the best state-of-the-art pseudo-labeling UDA method which mitigates for bad effects due to pseudo-label errors. It uses k-means as the clusterer in the feature space to predict target pseudo-labels based on the parirwise L2 distance matrix of the target training set features, as well as the mutual-mean teaching strategy described in their paper for pseudo-label error robustness. \end{itemize} \\ \subsubsection{Implementation details} \\ \label{impl} \textbf{Initialization phase.} We follow the guidelines for supervised training from the paper \cite{luo2019bag} adopted by MMT \cite{ge2020mutual}.For fair comparison, we choose the ResNet-50 \cite{he2016deep} initialized on the pretrained ImageNet weights \cite{deng2009imagenet} as our feature extractor. We use batch of 64 images composed of 16 identities and 4 shots per identity. Images are randomly flipped and resized to 256x128. Random Erasing Data augmentation \cite{zhong2017random} is not used during the initialization phase since it may reduce transferability of the source model features to the target domain thus generating more errors in pseudo-labels after UDA initialization \cite{luo2019bag}. We use ADAM as the optimizer and a weight decay of $5 \cdot 10^{-4}$. The initial learning rate is set to 0.00035 and is decreased to 1/10 of its previous value on the 40th and 70th epoch in a total of 80 epochs.\\ \indent \textbf{Pseudo-labeling phase.} Unless otherwise specified, we use as a common encoder all but the layers from the last convolutional block and after (4 first blocs of layers), as motivated by our parameter analysis \ref{layers}. We use the same initialization phase preprocessing with two batches of 64 images, adding Random Erasing Data augmentation \cite{zhong2017random}: one for source images and another one for target. We feed separately the network with the source and target batches to ensure domain-specific batch normalization statistics as explained in Section \ref{sec:framework}. For our baseline, after each uour baselinete phase of the pseudo-labels, the pseudo-ID and their number can change. Therefore we initialize randomly a new classification layer for target after each pseudo-labels our baseline. Other hyperparameters (clusterer parameter, triplet loss margin, number of iterations for pseudo-labeling,...) used after the initialization phase are kept the same as the UDA paper's ones (resp MMT's ones): they correspond to the best hyperparameters found after validation on the target test set in their papers.\\ \indent \textbf{Source-Guided (SG) versions.} For the baseline+SG framework, it is the direct application of our source-guided Algorithm \ref{algo}. For our baseline+MMT+SG, the two-branch architecture is adopted for the two models (mean teacher and student) that train mutually in their baseline. It implies that we do not modify the soft and hard label loss weighting and we directly add the source term (on hard labels) as described in Eq. \ref{loss}. \section{Results} \label{Results} In this part, we conduct parameter analysis and comparison with existing state-of-the-art re-ID UDA methods. \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/p_d2m.png} \caption{Robustness of our baseline+SG to $p$ parameter's changes ($p$ controls DBSCAN neighborhood distance parameter) compared to the target-only framework our baseline on Duke-to-Market.} \label{p_d2m} \end{figure} \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{figs/p_m2d.png} \caption{Robustness of our baseline+SG to $p$ parameter's changes ($p$ controls DBSCAN neighborhood distance parameter) compared to the target-only framework our baseline on Market-to-Duke.} \label{p_m2d} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtm2d.png} \caption{Robustness of our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Market-to-Duke.} \label{mmt_m2d} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtd2m.png} \caption{Robustness of our our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Duke-to-Market.} \label{mmt_d2m} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtd2msmt.png} \caption{Robustness of our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Duke-to-MSMT.} \label{p_d2msmt} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=\columnwidth]{figs/mmtm2msmt.png} \caption{Robustness of our baseline+MMT+SG to $k$ parameter's changes ($k$ controls k-means number of clusters) compared to the target-only framework MMT on Market-to-MSMT.} \label{p_m2msmt} \end{figure} \subsection{Parameter analysis.} \subsubsection{Do the source domain help the model to learn better target features ?} As explained and motivated in Section \ref{sec:framework}, we propose a two-branch architecture to learn domain-specific high level ID discriminative features based on low and mid level domain-shared features learned with labeled source data and pseudo-labeled target data. We can wonder if our two-branch encoder manages to leverage the source samples to improve the target features. Furthermore, we would like to know how many layers we should share to take advantage from the labeled source data without negatively biasing the target features.\\ To answer these two questions, we vary the number of ResNet-50 layers shared between source and target domain through the $E^C$ encoder of our Source-Guided baseline. The ResNet-50 architecture can be divided into $5$ convolutional blocks of layers defined in the ResNet paper \cite{he2016deep} to which we refer to vary the number of shared layers. Case "$0$ shared layer" corresponds to the classical target-only pseudo-labeling methods (\cf Figure \ref{fig:framework}(1)) which corresponds to our baseline, where case "$5$ shared layers" to sharing the whole ResNet50 between source and target domain. \indent Experiments show on Fig.\ref{layers} increasing performances when the number shared layers increase. More precisely, the best mAP is reached for $4$ shared block of layers: $59.1\%$ mAP for Duke-to-Market and $55.6\%$ mAP for Market-to-Duke, increasing resp. the performances by $4.8 p.p.$ and $5.5 p.p.$ compared to the target only model. Our source-guided baseline outperforms the classical target-only pseudo-labeling baseline and our partially-shared strategy gives the best results for Duke-to-Market and Market-to-Duke. Moreover, we also notice that the slight drop of performances for a fully-shared model may highlight a trade-off between: \begin{itemize} \item Sharing the highest level (specifically the last one) layers which can benefit the most from the auxiliary source re-ID task regularization \item Biasing the highest level feature space which is directly used for re-ID on target domain. \end{itemize} \\ \subsubsection{Efficiency of Specific Batch Normalization} \begin{table}[t] \caption{Impact of domain-specific batch-normalization on domain adaptation performance (mAP in $\%$) .} \label{batchnorm} \begin{tabular}{|c|c|c|} \hline \multirow{2}{*}{Methods} & Market-to-Duke & Duke-to-Market \\ \cline{2-3} & mAP & mAP \\ \hline baseline & 50.1 & 54.3 \\ Domain-Shared BatchNorm baseline+SG & 36.7 & 43.1 \\ Domain-Specific BatchNorm baseline+SG & \textbf{55.6} & \textbf{59.1} \\ \hline \end{tabular} \end{table} We study the effectiveness of domain-specific batch nornmalization as motivated in Section \ref{sec:framework}. \. To do so, we compare our baseline+SG framework to a version that shares the batch normalization between domains (Domain Shared BatchNorm baseline+SG). From Table \ref{batchnorm}, we notice that sharing the batch normalization deteriorates the performance on both couples of Market-to-Duke and Duke-to-Market adaptation datasets. mAP drop more than $-10$ p.p. below the model using only the target data (our baseline). Only the addition of domain-specific batch normalization increases the performances of our framework above the our baseline model. These experiments therefore show that the use of domain-specific batch normalization is an essential key of our framework in order not to deteriorate the learning of discriminative target features by biasing the batch normalization statistics. \subsubsection{Is our strategy of using source samples robust to clustering parameters changes ?} \indent In the UDA setting, choosing or tuning hyperparameter is a tricky task due to the absence of a labeled validation set for the target domain. It is therefore important in practice to design UDA methods robust to hyperparameter changes. In particular, pseudo-labeling UDA methods \cite{song2020unsupervised} \cite{ge2020mutual} give experimental evidences that performance can be very sensible to clustering parameters changes. That's why we would like to focus in this part on the performance of our source-guided frameworks when these clustering parameters change. For the baseline+SG baseline, we study the $p$ parameter of DBSCAN as defined and studied in UDAP paper \cite{song2020unsupervised} and for our baseline+MMT+SG we focus on the $k$ paremeter of k-means as in the MMT paper \cite{ge2020mutual}. We compare our two frameworks to their target-only versions. \indent The $p$ parameter directly controls the DBSCAN neighborhood distance parameter in our baseline and baseline+SG: it determines the percentage of the smallest distances to be used to define clusters in the feature space. We vary $p$ in the same interval of the UDAP paper \cite{song2020unsupervised}. By doing so, we notice that for Duke-to-Market in Figure \ref{p_d2m} and Market-to-Duke in Figure \ref{p_m2d}, in baseline+SG the source benefits the domain adaptation by pseudo-labeling: we go from $50.6\%$ to $55.9\%$ on Market-to-Duke and from $54.6\%$ to $59.4\%$ by comparison to the target only version. For every parameter value $p$, there is an improvement in performance for baseline+SG ranging from at least $3.4$ p.p. for Market-to-Duke and $4$ p.p. for Duke-to-Market in comparison to the target only baseline our baseline: *** our framework seems to be robust to the change of parameters $p$. \indent The $k$ parameter determines the number of clusters in the MMT frameworks. We choose the same interval of values as in the MMT paper \cite{ge2020mutual} for varying the $k$ parameter. For Maket-to-Duke and Duke-to-Market in Figures \ref{mmt_m2d} and \ref{mmt_d2m}, the addition of the source term with our baseline+MMT+SG does not seem to increase the maximum performance, which is reached by the classical target-only MMT model. Nevertheless, there are quite different performance curve trends between MMT and our baseline+MMT+SG. our baseline+MMT+SG seems to be more robust for $k$ values above 800 (Market and Duke containing 751 and 702 identities respectively), i.e. when a number of clusters is chosen above the actual number of identities. While MMT already proposes a strategy of resistance to pseudo-label noise, which can explain the non improvement of the best mAP, the addition of the source-guidance in our baseline+MMT+SG seems to confer more stability to the clusterer parameter variations. Numerically, this stability can be observed by calculating the standard deviation (std) of the mAPs over $k$: using the source, we go from $2.5$ p.p. to $1.2$ p.p. on Duke-to-Market and from $1.6$ p.p. to $0.9$ p.p. on Market-to-Duke, with on average equivalent performance for the two pairs of data sets. This stability conferred by the source is interesting given that we not know the number of identities of the training set target, which can only be estimated at best. We believe that the number of ground-truth ID for the source dataset might help to reduce the impact on training of the cluster surplus of the target set.\\ \indent In the more challenging cases where MSMT is the target dataset, there is a clear contribution from the source. We can see in Figures \ref{p_m2msmt} and \ref{p_d2msmt} that it is stable to the change in $k$ and allowed to increase the maximum performance: from $23.5$\% to $27.5$\% for Duke-to-MSMT and from $22.9$\% to $23.5$\% for Market-to-MSMT. There is also a higher source contribution at high $k$ values. It can be assumed that our baseline+MMT+SG works better in this more challenging case of adaptation because of the presence of more noisy labels during the transfer of the source model for initialization of pseudo-labeling: adding our strategy of exploiting source data therefore presents less redundancy with the one already implemented in the MMT framework, and even more if we "over-estimate" the number of clusters. \subsection{Comparison with state-of-the-art methods} \label{sec:sota} \begin{table}[t] \begin{center} \caption{Comparison with state-of-the-art methods.} \label{table^Sota} \begin{tabular}{ccccc} \hline \multicolumn{1}{|c|}{\multirow{2}{*}{Methods}} & \multicolumn{2}{c|}{Market-to-Duke} & \multicolumn{2}{c|}{Duke-to-Market} \\ \cline{2-5} \multicolumn{1}{|c|}{} & mAP & \multicolumn{1}{c|}{top-1} & mAP & \multicolumn{1}{c|}{top-1} \\ \hline \multicolumn{1}{|c|}{SPGAN \cite{deng2018image}} & 22.3 & \multicolumn{1}{c|}{41.1} & 22.8 & \multicolumn{1}{c|}{51.5} \\ \multicolumn{1}{|c|}{TJ-AIDL \cite{wang2018transferable}} & 23.0 & \multicolumn{1}{c|}{44.3} & 26.5 & \multicolumn{1}{c|}{58.2} \\ \multicolumn{1}{|c|}{MMFA \cite{lin2018multi}} & 24.7 & \multicolumn{1}{c|}{45.3} & 38.3 & \multicolumn{1}{c|}{66.2} \\ \multicolumn{1}{|c|}{HHL \cite{zhong2018generalizing}} & 27.2 & \multicolumn{1}{c|}{46.9} & 31.4 & \multicolumn{1}{c|}{62.2} \\ \multicolumn{1}{|c|}{CFSM \cite{chang2019disjoint}} & 27.3 & \multicolumn{1}{c|}{49.8} & 28.3 & \multicolumn{1}{c|}{61.2} \\ \multicolumn{1}{|c|}{UCDA-CCE \cite{qi2019novel}} & 31.0 & \multicolumn{1}{c|}{47.7} & 30.9 & \multicolumn{1}{c|}{60.4} \\ \multicolumn{1}{|c|}{ARN \cite{li2018adaptation}} & 33.4 & \multicolumn{1}{c|}{60.2} & 39.4 & \multicolumn{1}{c|}{70.3} \\ \multicolumn{1}{|c|}{ECN \cite{zhong19enc}} & 40.4 & \multicolumn{1}{c|}{63.3} & 43.0 & \multicolumn{1}{c|}{75.1} \\ \multicolumn{1}{|c|}{PoseDA-Net \cite{li2019cross}} & 45.1 & \multicolumn{1}{c|}{63.2} & 47.6 & \multicolumn{1}{c|}{75.2} \\ \multicolumn{1}{|c|}{UDAP \cite{song2020unsupervised}} & 49.0 & \multicolumn{1}{c|}{68.4} & 53.7 & \multicolumn{1}{c|}{75.8} \\ \multicolumn{1}{|c|}{SSG \cite{fu2019self}} & 53.4 & \multicolumn{1}{c|}{73.0} & 58.3 & \multicolumn{1}{c|}{80.0} \\ \multicolumn{1}{|c|}{ISSDA-re-ID \cite{tang2019unsupervised}} & 54.1 & \multicolumn{1}{c|}{72.8} & 63.1 & \multicolumn{1}{c|}{81.3} \\ \multicolumn{1}{|c|}{PCB-PAST \cite{zhang2019self}} & 54.3 & \multicolumn{1}{c|}{72.4} & 54.6 & \multicolumn{1}{c|}{78.4} \\ \multicolumn{1}{|c|}{ACT \cite{yang2019asymmetric}} & 54.5 & \multicolumn{1}{c|}{72.4} & 60.6 & \multicolumn{1}{c|}{80.5} \\ \multicolumn{1}{|c|}{MMT \cite{ge2020mutual}} & \textbf{65.1} & \multicolumn{1}{c|}{78.0} & \textbf{71.2} & \multicolumn{1}{c|}{87.7} \\ \multicolumn{1}{|c|}{Our (target-only) baseline} & 50.1 & \multicolumn{1}{c|}{70.1} & 54.3 & \multicolumn{1}{c|}{73.5} \\ \hline \multicolumn{1}{|c|}{Our baseline+SG} & 55.6 & \multicolumn{1}{c|}{73.2} & 59.1 & \multicolumn{1}{c|}{80.8} \\ \multicolumn{1}{|c|}{Our baseline+MMT+SG} & 64.8 & \multicolumn{1}{c|}{\textbf{78.5}} & 70.5 & \multicolumn{1}{c|}{\textbf{88.1}} \\ \hline \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\ \hline \multicolumn{1}{|c|}{\multirow{2}{*}{Methods}} & \multicolumn{2}{c|}{Market-to-MSMT} & \multicolumn{2}{c|}{Duke-to-MSMT} \\ \cline{2-5} \multicolumn{1}{|c|}{} & mAP & \multicolumn{1}{c|}{top-1} & mAP & \multicolumn{1}{c|}{top-1} \\ \hline \multicolumn{1}{|c|}{PTGAN \cite{wei2018person}} & 2.9 & \multicolumn{1}{c|}{10.2} & 3.3 & \multicolumn{1}{c|}{11.8} \\ \multicolumn{1}{|c|}{ECN \cite{qi2019novel}} & 8.5 & \multicolumn{1}{c|}{25.3} & 10.2 & \multicolumn{1}{c|}{30.2} \\ \multicolumn{1}{|c|}{UDAP \cite{song2020unsupervised}} & 12.0 & \multicolumn{1}{c|}{30.5} & 16.0 & \multicolumn{1}{c|}{39.2} \\ \multicolumn{1}{|c|}{SSG \cite{fu2019self}} & 13.2 & \multicolumn{1}{c|}{49.6} & 13.3 & \multicolumn{1}{c|}{32.2} \\ \multicolumn{1}{|c|}{MMT \cite{ge2020mutual}} & 22.9 & \multicolumn{1}{c|}{49.2} & 23.5 & \multicolumn{1}{c|}{50.1} \\ \multicolumn{1}{|c|}{Our (target-only) baseline} & 11.6 & \multicolumn{1}{c|}{29.8} & 14.8 & \multicolumn{1}{c|}{36.1} \\ \hline \multicolumn{1}{|c|}{Our baseline+SG} & 14.9 & \multicolumn{1}{c|}{35.4} & 19.3 & \multicolumn{1}{c|}{45.6} \\ \multicolumn{1}{|c|}{Our baseline+MMT+SG} & \textbf{23.5} & \multicolumn{1}{c|}{\textbf{50.2}} & \textbf{27.5} & \multicolumn{1}{c|}{\textbf{56.1}} \\ \hline \end{tabular} \end{center} \end{table} \indent We compare in Table~\ref{table^Sota} our two source-guided frameworks with the state of the art on Duke-to-Market, Market-to-Duke, Market-to-MSMT and Duke-to-MSMT.\\ \indent On Market-to-Duke and Duke-to-Market, our two frameworks far exceed those that do not use pseudo-labels at all. Our frameworks outperform all state of the art methods except MMT on Market-to-Duke and Duke-to-Market. Specifically, baseline+SG outperforms similar Pseudo-labeling methods that do not exploit the labeled source data after pseudo-label initialization: UDAP and PCB-PAST, but also those that integrate noise resistance or error filtering strategies in pseudo-labels such as ISSDA-re-ID, SSG and ACT on Maket-to-Duke. On Duke-to-Market, ISSDA-re-ID surpasses baseline+SG, even if baseline+SG has the advantage of simple integration in any framework and needs few additional parameters (no need to train a CycleGAN or a second model for asymmetric co-teaching).\\ Even if our baseline+MMT+SG, has a slightly lower maximum mAP than MMT, it offers the advantage of a better stability on the parameter of the number of clusters (estimated) as seen in the parameter analysis part, which is a major asset in domain adaptation.\\ \indent On Market-to-MSMT and Duke-to-MSMT, our baseline+SG framework exceeds all methods except MMT. In particular, it exceeds SSG by $+1.7$ p.p. mAP on Market-to-MSMT and UDAP by $+3.3$ p.p. on Duke-to-MSMT. The our baseline+MMT+SG framework exceeds the state of the art on these two pairs of data sets: on Market-to-MSMT and Duke-to-MSMT, our baseline+MMT+SG resp. increases performance by $+0.6$ p.p. and by $+4$ p.p. on Duke-to-MSMT. \section{Conclusion} In this paper, we propose a guideline to leverage the commonly under-used ground-truth labeled source samples during pseudo-labeling domain adaptation. It consists of guiding the target pseudo-label training stage with an auxiliary ID-discriminative source feature learning task, while preventing the source samples from biasing the training by using domain-specific batch normalization and an architecture with two domain-specific branches. Experiments on combining our framework with two state-of-the-art methods are carried out on different datasets. They show that leveraging the source samples brings more stability with relation to the choice of clustering parameters and improves performance on particularly challenging adaptation settings. \bibliographystyle{IEEEtran}
{'timestamp': '2020-09-22T02:17:20', 'yymm': '2009', 'arxiv_id': '2009.09445', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09445'}
arxiv
\section{Proof of \texorpdfstring{\eqref{overallsnrpdf}}{}} \newcommand{\RNum}[1]{\MakeUppercase{\romannumeral#1}} \hyphenation{op-tical net-works semi-conduc-tor} \begin{document} \title{Physical-Layer Security for Two-Hop Air-to-Underwater Communication Systems With Fixed-Gain Amplify-and-Forward Relaying} \author{ Yi~Lou,~\IEEEmembership{Member,~IEEE,} Ruofan~Sun,~\IEEEmembership{Student Member,~IEEE,} Julian~Cheng,~\IEEEmembership{Senior~Member,~IEEE,} Songzuo~Liu,~\IEEEmembership{Member,~IEEE,} Feng~Zhou,~\IEEEmembership{Member,~IEEE,} and~Gang Qiao,~\IEEEmembership{Member,~IEEE} \thanks{Yi Lou, Ruofan Sun, Songzuo Liu, Feng Zhou, and Gang Qiao are with the Acoustic Science and Technology Laboratory, Harbin Engineering University, Harbin 150001, China, and also with the Key Laboratory of Marine Information Acquisition and Security (Harbin Engineering University), Ministry of Industry and Information Technology, Harbin 150001, China (e-mail: \{louyi,sunruofan,liusongzuo,zhoufeng,qiaogang\}@hrbeu.edu.cn).} \thanks{Julian Cheng is with the School of Engineering, The University of British Columbia, Kelowna, BC, Canada (e-mail: [email protected]).} } \maketitle \begin{abstract} We analyze a secure two-hop mixed radio frequency (RF) and underwater wireless optical communication (UWOC) system using a fixed-gain amplify-and-forward (AF) relay. The UWOC channel is modeled using a unified mixture exponential-generalized Gamma distribution to consider the combined effects of air bubbles and temperature gradients on transmission characteristics. Both legitimate and eavesdropping RF channels are modeled using flexible $\alpha-\mu$ distributions. Specifically, we first derive both the probability density function (PDF) and cumulative distribution function (CDF) of the received signal-to-noise ratio (SNR) of the mixed RF and UWOC system. Based on the PDF and CDF expressions, we derive the closed-form expressions for the tight lower bound of the secrecy outage probability (SOP) and the probability of non-zero secrecy capacity (PNZ), which are both expressed in terms bivariate Fox's $H$-function. To utilize these analytical expressions, we derive asymptotic expressions of SOP and PNZ using only elementary functions. Also, we use asymptotic expressions to determine the optimal transmitting power to maximize energy efficiency. Further, we thoroughly investigate the effect of levels of air bubbles and temperature gradients in the UWOC channel, and study nonlinear characteristics of the transmission medium and the number of multipath clusters of the RF channel on the secrecy performance. Finally, all analyses are validated using Monte Carlo simulation. \end{abstract} \begin{IEEEkeywords} Amplify-and-forward (AF), $\alpha$-$\mu$ distribution, non-zero capacity (PNZ), performance analysis, underwater wireless optical communication (UWOC), secrecy outage probability (SOP). \end{IEEEkeywords} \IEEEpeerreviewmaketitle \section{Introduction} \IEEEPARstart{T}{he} rise of the underwater Internet of Things requires the support of a high-performance underwater communication network with high data rates, low latency, and long communication range. Underwater wireless optical communication (UWOC) is one of the essential technologies for this communication network. Unlike radio frequency (RF) and acoustic technologies, UWOC technology can achieve ultra-high data rates of Gpbs over a moderate communication range when selecting blue or green light with wavelengths located in the transmission window \cite{zengSurveyUnderwaterOptical2017}. Further, a light-emitting diode or laser diode as a light source provides the versatility to switch between maximizing the communication range or the coverage area within the constraints of the range-beamwidth tradeoff to meet the needs of a specific application scenario. Using relay technology to construct a communication system in a multi-hop fashion is one of the primary techniques to extend the communication range. Based on the modality of processing and forwarding signals, relays can be divided into two main categories: decode-and-forward relays (DF) and amplify-and-forward (AF) relays. In DF relaying systems, the relay down-converts the received signals to the baseband, decodes, re-encodes, and up-converts them to the RF band, which are then forwarded to the destination node. In AF relaying systems, the relay amplifies the received signals directly in the passband based on the amplification factor, then forwards them directly in the RF band. Since AF scheme does not require time-consuming decoding and spectral shifting, it can significantly reduce complexity while still providing good performance \cite{dohlerCooperativeCommunicationsHardware2010}. Depending on the different CSI information required by the AF relay, AF relaying can be divided into the variable gain AF (VG) one and fixed-gain AF (FG) one. In a VG scheme, the relay requires instantaneous channel state information (CSI) of the source-to-relay link, whereas in an FG scheme, only statistical CSI of the SR link is required \cite{shinMRCAnalysisCooperative2008}. Therefore, from an engineering standpoint, the FG scheme is more attractive because of its low implementation complexity. To maximize the utilization of the different transmission environments of each hop and thus improve the overall performance of the multi-hop relaying system, mixed communication systems using different communication technologies have been proposed. For example, the mixed communication system using both RF and free space optical (FSO) technologies is proposed to take advantage of the robustness of the RF links and the high bandwidth characteristics of the FSO links. Further, RF sub-systems offer low-cost and non-line-of-sight communication capabilities, while FSO sub-systems offer low transmission latency and ultra-high transmission rates. Therefore, a mixed RF/FSO system is a cost-effective solution to the last-mile problem in wireless communication networks, where the high-bandwidth FSO sub-system of a mixed RF/FSO system is used to connect seamlessly the fiber backbone and RF sub-system access networks \cite{upadhyaEffectInterferenceMisalignment2020,leiSecrecyOutageAnalysis2018a,zediniPerformanceAnalysisDualHop2016,djordjevicMixedRFFSO2015}. In the past, achieving ultra-high-speed communication between underwater and airborne nodes or land-based stations across the sea surface medium has been a challenge due to the low data rate of underwater acoustic communications. To solve this problem, using an ocean buoy or a marine ship as a relay node, the mixed RF/UWOC system is proposed, in which the high-speed UWOC is used instead of underwater acoustic communication, to achieve higher overall communication rates \cite{leiPerformanceAnalysisDualHop2020,illiPhysicalLayerSecurity2020,illiDualHopMixedRFUOW2018,christopoulouOutageProbabilityMultisensor2019,xingAdaptiveEnergyEfficientAlgorithm2018}. Accurate modeling of the UWOC channel, including absorption, scattering, and turbulence, is a prerequisite for proper performance analysis and algorithm development of the UWOC system \cite{l.johnsonSurveyChannelModels21,zediniNewSimpleModel04}. Absorption and scattering have been extensively studied \cite{jaruwatanadilokUnderwaterWirelessOptical2008,cochenourTemporalResponseUnderwater2013, nabaviEmpiricalModelingAnalysis2019}, where absorption limits the transmission distance of underwater light, while scattering diffuses the receiving radius of underwater light transmission and deflects the transmission path, thus reducing the received optical power. Due to changes in the random refractive index variation, turbulence can cause fluctuations in the received irradiance, i.e., scintillation, which can limit the performance and affect the stability of the UWOC system \cite{zengSurveyUnderwaterOptical2017}. In early research, UWOC turbulence was modeled by borrowing models of atmospheric turbulence, e.g., weak turbulence is modeled by the Lognormal distribution \cite{jamaliPerformanceAnalysisMultiHop2017,jamaliPerformanceStudiesUnderwater2017,nezamalhosseiniOptimalPowerAllocation2020,jiangPerformanceSpatialDiversity2020}, and moderate-to-strong turbulence is modeled by the Gamma-Gamma distribution \cite{luanScintillationIndexOptical2019,boucouvalasUnderwaterOpticalWireless2016,shinStatisticalModelingImpact2020,elamassieVerticalUnderwaterVisible2020}. However, the statistical distributions used to model atmospheric turbulence cannot accurately characterize UWOC systems due to the fundamental differences between aqueous and atmospheric mediums. Recently, based on experimental data, the mixed exponential-lognormal distribution has been proposed to model moderate to strong UWOC turbulence in the presence of air bubbles in both fresh water and salty water \cite{jamaliStatisticalStudiesFading2018}. Later, the mixture exponential-generalized Gamma (EGG) distribution was proposed to model turbulence in the presence of air bubbles and temperature gradients in either fresh or salt water \cite{zediniUnifiedStatisticalChannel2019}. The EGG distribution not only can model turbulence of various intensities, but also has an analytically tractable mathematical form. Therefore, useful system performance metrics, such as ergodic capacity, outage probability, and BER, can be easily obtained. Due to the broadcast nature of RF signals, secrecy performance has always been one of the most important considerations for the mixed RF/FSO communication systems \cite{hamamrehClassificationsApplicationsPhysical2019,leiSecrecyPerformanceMixed2017,leiSecrecyOutageAnalysis2018,yangPhysicalLayerSecurityMixed2018,leiSecrecyOutageAnalysis2018a,leiSecureMixedRFFSO2020}. In \cite{leiSecrecyPerformanceMixed2017}, the expressions of the lower bound of the secrecy outage probability (SOP) and average secrecy capacity (ASC) for mixed RF/FSO systems using VG or FG relaying schemes, were both derived in closed-form, where the RF and FSO links are modeled by the Nakagami-$m$ and GG distributions, respectively. The authors in \cite{leiSecrecyOutageAnalysis2018} used Rayleigh and GG distributions to model RF and FSO links, respectively. Considering the impact of imperfect channel state information (CSI), both the exact and asymptotic expressions of the lower bound for SOP of a mixed RF/FSO system using VG or FG relay are derived. The same authors then extended the analysis to multiple-input and multiple-output configuration and analyzed the impact of different transmit antenna selection schemes on the secrecy performance of the mixed RF/FSO system using a DF relay, where RF and FSO links are modeled by the Nakagami-$m$ and $\mathcal{M}$-distributions, respectively. Assuming the CSI of the FSO and RF links are imprecise and outdated, the authors derived the bound and asymptotic expressions of the effective secrecy throughput of the system. In \cite{yangPhysicalLayerSecurityMixed2018}, using more generalized $\eta$-$\mu$ and $\mathcal{M}$-distributions to model RF and FSO links, respectively, and assuming that the eavesdropper is only at the relay location, the authors derived the analytical results for the SOP and the average secrecy rate of the mixed RF/FSO system using the FG or VG relaying scheme. To quantify the impact of the energy harvesting operation on the system secrecy performance, the authors in \cite{leiSecrecyOutageAnalysis2018a} derived exact closed-form and asymptotic expressions for the SOP of the downlink simultaneous wireless information and power transfer system using DF relaying scheme, under the assumption that RF and FSO links are modeled using the Nakagami-$m$ and GG distributions, respectively. However, research on the secrecy performance of mixed RF/UWOC systems is still in its infancy despite the growing number of underwater communication applications. The authors in \cite{illiDualHopMixedRFUOW2018} investigated the secrecy performance of a two-hop mixed RF/UWOC system using a VG or FG multiple-antennas relay and maximal ratio combining scheme, where RF and UWOC links are modeled by Nakagami-$m$ and the mixed exponential-Gamma (EG) distributions, respectively. Assuming that only the source-to-relay link receives eavesdropping from unauthorized users, the authors in \cite{illiDualHopMixedRFUOW2018} derived the exact closed expressions of the ASC and SOP of the mixed RF/UWOC systems. Later, based on the same channel model as in \cite{illiDualHopMixedRFUOW2018}, the same authors extended the analysis to the mixed RF/UWOC system using a multi-antennas DF relay with the selection combining scheme \cite{illiPhysicalLayerSecurity2020}. Both the exact closed-form and asymptotic expressions of the SOP were derived. However, while the EG distribution is suitable for modeling turbulence of various intensities in both fresh water and salty water, this distribution fails to model the effects of air bubbles and temperature gradients on UWOC turbulence \cite{zediniUnifiedStatisticalChannel2019}. Further, the Nakagami-$m$ distribution is only applicable to certain specific scenarios and cannot accurately characterize the effects of the properties of the transmission medium and multipath clusters on channel fading. It is shown that the impact of the medium on the signal propagation is mainly determined by the nonlinearity characteristics of the medium \cite{yacoubAmDistributionPhysical2007}. The $\alpha-\mu$ distribution is a more general, flexible, and mathematically tractable model of channel fading whose parameters $\alpha$ and $\mu$ are correlated with the nonlinearity of the propagation medium and the number of clusters of multipath transmission, respectively. Further, by setting $\alpha$ and $\mu$ to specific values, the $\alpha-\mu$ distribution can be reduced to several classical channel fading models, including Nakagami-$m$, Gamma, one-sided Gaussian, Rayleigh, and Weibull distributions. Recently, the secrecy performance of a two-hop mixed RF/UWOC system using DF relaying has been analyzed in \cite{louSecrecyOutageAnalysis2020}; however, only the lower bound and asymptotic expressions of the SOP are derived. Furthermore, the overall end-to-end latency of the mixed RF/UWOC communication system is increased by the decoding and forwarding and spectral shifting operations required by DF relaying. However, to the best of the authors' knowledge, this is the first comprehensive secrecy performance analysis of the mixed RF/UWOC communications system using a low-complexity FG relaying scheme. Unlike previous UWOC channel models that do not adequately characterize the underwater optical propagation and RF channel models that use various simplifying assumptions, we model the RF channels and the UWOC channel using the more general and accurate $\alpha-\mu$ and EGG distributions, respectively, to analyze the effects of a variety of real channel physics phenomena, such as different temperature gradients and levels of air bubbles of UWOC channels and different grades of medium nonlinearity, and the number of multipath clusters of the RF channels on the secrecy performance of the mixed RF/UWOC communication systems. We propose a novel analytical framework to derive the closed-form expressions of the SOP and the non-zero secrecy capacity (PNZ) metrics by the bivariate Fox’s $H$-function. Moreover, our secrecy performance study provides a generalized framework for several fading models for both RF and UWOC channels, such as Rayleigh, Weibull for RF channels and EG and Generalized Gamma for UWOC channels. We first derive the probability density function (PDF) and cumulative distribution function (CDF) of the end-to-end SNR for the mixed RF/UWOC communication system in exact closed-form in terms of bivariate $H$-function. Depending on these expressions, we derive the exact closed-form expressions of the lower bound of the SOP and the PNZ. Furthermore, we also derive asymptotic expressions for both SOP and PNZ containing only simple functions at high SNRs. Also, based on the asymptotic expressions for SOP and PNZ, we provide a straightforward approach to determine the optimal source transmission power to maximize energy efficiency for given performance goals of both SOP and PNZ. Finally, we use Monte Carlo simulation to validate all the derived analytical expressions and theoretical analyses. The rest of this paper is organized as follows. In Section \RNum{2}, the channel and system models are presented. In Section \RNum{3}, the end-to-end statistics are studied. Both exact and asymptotic expressions for the SOP and PNZ are derived in Section \RNum{4}. The numerical results and discussions are discussed in Section \RNum{5}, which is followed by the conclusion in Section \RNum{6}. \section{System and Channel Models} A mixed RF/UWOC system is considered in Fig. 1 where the source node (S) in the air transmits its private data to the legitimate destination node (D) located underwater via a trusted relay node (R), which can be a buoy or a surface ship. The RF channel from S to R and underwater optical channel from the R to the D node is assumed to follow $\alpha-\mu$ and EGG distributions, respectively. During transmission, one unauthorized receiver (E) attempts to eavesdrop on RF signals received by the R. In this paper, we consider a VG AF relay where the relay amplifies the received signal by a fixed factor and then forwards the amplified message to the destination node. \begin{figure}[!t] \includegraphics[width=.45\textwidth]{visio.pdf} \centering \caption{A mixed RF/UWOC two-hop communication system using an FG relaying scheme with one legitimate receiver in the presence of eavesdropping.} \label{fig: 1} \end{figure} \subsection{RF Channel Model} The RF SR link is modeled by $\alpha$-$\mu$ flat fading models, where the PDF of the received SNR, denoted by $\gamma_1$, can be expressed as \begin{IEEEeqnarray*}{rcl} f_{\gamma _1}\left(\gamma _1\right)&=&\frac{\alpha }{2\Gamma (\mu )}\frac{\mu ^{\mu }}{\left(\bar{\gamma }_1\right)^{\frac{\alpha \mu }{2}}}\gamma _1^{\frac{\alpha \mu }{2}-1}\thinspace\text{exp}\left(-\mu \left(\frac{\gamma _1}{\bar{\gamma }_1}\right)^{\frac{\alpha }{2}}\right)\IEEEyesnumber \label{ampdf} \end{IEEEeqnarray*} where $\gamma_1 \geq 0$, $\mu \geq 0$, $\alpha \geq 0$, and $\Gamma(\cdot)$ denotes the gamma function. The fading model parameters $\alpha$ and $\mu$ are associated with the non-linearity and multi-path propagation of the channel. Further, the PDF of the received SNR at the eavesdropping node E, denoted by $f_{\gamma _e}(\gamma _e)$, also follows $\alpha$-$\mu$ with parameters $\alpha_e$ and $\mu_e$. Based on the definition of the $H$-function, the CDF of $\gamma_1$, which is defined as $F_{\gamma_1}(\gamma_1)=\int_{0}^{\gamma_1} f_{\gamma_1}(\gamma_1) d \gamma_1$, can be expressed as \begin{IEEEeqnarray*}{rcl} F_{\gamma _1}\left(\gamma _1\right)&\overset{(a)}{=}&\kappa \int _0^{\gamma } H_{0,1}^{1,0}\left[\gamma \Lambda \left|\begin{array}{c} \\ \left(-\frac{1}{\alpha }+\mu ,\frac{1}{\alpha }\right) \\\end{array}\right.\right]d\gamma \\ &=&-\frac{i \kappa }{2 \pi }\int _{\mathcal{L}}^s\!\!\Lambda ^{-s} \Gamma \left(\frac{s}{\alpha }+\mu -\frac{1}{\alpha }\right) \!\!\int _0^{\gamma }\!\!\gamma^{-s}d\gamma ds \\ &=&\frac{i \kappa }{2 \pi }\int _{\mathcal{L}}^s\frac{\gamma ^{1-s} \Lambda ^{-s} }{s-1}\Gamma \left(\frac{s}{\alpha }+\mu -\frac{1}{\alpha }\right)ds\\ &=&\frac{\kappa }{\Lambda }H_{1,2}^{1,1}\left[\gamma \Lambda \left|\begin{array}{c} (1,1) \\ \left(\mu ,\frac{1}{\alpha }\right),(0,1) \\\end{array}\right.\right] \IEEEyesnumber \label{amcdfform2} \end{IEEEeqnarray*} where we use \cite[Eq. (1.60)]{mathaiHFunctionTheoryApplications2010} and \cite[Eq. (1.125)]{mathaiHFunctionTheoryApplications2010} to express $f_{\gamma_1}(\gamma_1)$ in the right side of equity (a) into the form of $H$-function, where $H_{\cdot ,\cdot }^{\cdot ,\cdot }[\cdot|\cdot]$ is the $H$-Function \cite[Eq. (1.2)]{mathaiHFunctionTheoryApplications2010}, $\kappa = \frac{\beta }{\Gamma (\mu )\bar{\gamma }}$, $ \Lambda = \frac{\beta }{\bar{\gamma }}$, and $\beta = \frac{\Gamma \left(\frac{1}{\alpha }+\mu \right)}{\Gamma (\mu )} $. Note that, the present form of $F_{\gamma _1}\left(\gamma _1\right)$ in \eqref{amcdfform2} is more suitable for deriving secrecy performance of a two-hop mixed RF/UWOC than the form proposed in \cite[Eq. (2)]{kongHighlyAccurateAsymptotic2018} for the point-to-point system over single-input multiple-output $\alpha-\mu$ channels. \subsection{UWOC channel model} To characterize the combined effects of different levels of air bubbles and temperature gradients on the light intensity received at underwater node D, we model the UWOC channel from R to D using the EGG distribution \cite{zediniUnifiedStatisticalChannel2019}, where the PDF of the received SNR, defined as $\gamma_2=\left(\eta I\right)^{r} / N_{0}$, has been derived in closed-form in terms of Meijer-$G$ functions \cite[Eq. (3)]{zediniPerformanceAnalysisDualHop2020}. Based on \cite[Eq. (1.112)]{mathaiHFunctionTheoryApplications2010}, we can re-write the PDF of $\gamma_2$ using $H$-functions as \begin{IEEEeqnarray*}{rcl} f_{\gamma _2}(\gamma _2)&=&\frac{c (1-\omega ) }{\gamma r \Gamma (a)}H_{0,1}^{1,0}\!\!\left[b^{-c}\left(\frac{\gamma _2}{\mu _r}\right)^{\frac{c}{r}}\middle|\!\!\!\begin{array}{c} \\ (a,1) \\\end{array}\!\!\!\right]\\ &&+\frac{\omega }{\gamma_2 r}H_{0,1}^{1,0}\!\!\left[\frac{1}{\lambda }\left(\frac{\gamma _2}{\mu _r}\right)^{\frac{1}{r}}\middle|\!\!\!\begin{array}{c} \\ (1,1) \\\end{array}\!\!\!\right] \IEEEyesnumber \end{IEEEeqnarray*} where the parameters $\omega$, a, b and c can be estimated using the maximum likelihood criterion with expectation maximization algorithm. The parameter $\omega$ is the mixed weight of the distribution; $\lambda$ is the parameter related to the exponential distribution; parameters $a$, $b$, and $c$ are related to the exponential distribution; $r$ is a parameter dependent on the detection scheme, specifically, $r=1$ for heterodyne detection and $r=2$ for intensity modulation and direct detection \cite[Eq. (31)]{lapidothCapacityFreeSpaceOptical2009a}. The EGG distribution can provide the best fit with the measured data form laboratory water tank experiments in the presence of temperature gradients and air bubbles \cite{zediniPerformanceAnalysisDualHop2020}. Therefore, by using the EGG distribution to model the UWOC link, we can gain more insight into the relationship between characteristics of the UWOC link and the secrecy performance of the mixed RF/UWOC communication system. Using the definition of CCDF, i.e., $\bar{F}_{\gamma_2}(\gamma_1)=\int_{0}^{\gamma_1} f_{\gamma_1}(\gamma_1) d \gamma_1$, and an approach similar to that used to derive \eqref{amcdfform2}, we can derive the CCDF of $\gamma_2$ as \begin{IEEEeqnarray*}{rcl} \bar{F}_{\gamma _2}\left(\gamma _2\right)&=&-\frac{i (1-\omega )}{2 \pi \Gamma (a)}\int _{\mathcal{L}}^s\!\!\Gamma \left(a+\frac{r s}{c}\right) b^{rs}\mu _r^s \int _{\gamma }^{\infty }\!\!\gamma ^{-s-1}d\gamma ds\\ &&-\frac{i \omega }{2 \pi }\int _{\mathcal{L}}^s\Gamma (r s+1) \lambda ^{rs}\mu _r^s \int _{\gamma }^{\infty }\gamma ^{-s-1}d\gamma ds \\ &=&-\frac{i (1-\omega ) }{2 \pi \Gamma (a)}\int _{\mathcal{L}}^s\frac{\gamma ^{-s} }{s}\Gamma \left(a+\frac{r s}{c}\right) \left(b^r \mu _r\right)^sds\\ &&-\frac{i\omega }{2 \pi }\int _{\mathcal{L}}^s\frac{\gamma ^{-s}}{s}\Gamma (r s+1) \left(\lambda ^r \mu _r\right)^sds \\ &=&\frac{(1-\omega ) }{\Gamma (a)}H_{1,2}^{2,0}\!\!\left[\frac{b^{-r} \gamma }{\mu _r}\middle|\!\!\!\begin{array}{c} (1,1) \\ (0,1),(a,\frac{r}{c}) \\\end{array}\!\!\!\right]\\ &&+ r \omega H_{0,1}^{1,0}\!\!\left[\frac{\gamma \lambda ^{-r}}{\mu _r}\middle|\!\!\!\begin{array}{c} \\ (0,r) \\\end{array}\!\!\!\right]. \IEEEyesnumber \label{eggccdf} \end{IEEEeqnarray*} It is worth to mention that the newly derived expression in \eqref{eggccdf} is useful to derive the closed-form CDF expression of the end-to-end SNR of the mixed RF/UWOC communication system. \section{End-To-End SNR} In this section, we derive the exact closed-form expressions for PDF and CDF of the end-to-end SNR of mixed RF/UWOC communication system. We then use these expressions to derive closed-form and asymptotic expressions for the system secrecy metrics in the following section. The end-to-end instantaneous SNR of the mixed RF/UWOC system using the FG relaying scheme is given as \begin{IEEEeqnarray*}{rcl} \gamma_{e q}=\frac{\gamma_{1} \gamma_{2}}{\gamma_{2}+C}\IEEEyesnumber \label{gammaeq1} \end{IEEEeqnarray*} where $C$ denotes the FG amplifying constant and is inversely proportional to the square of the relay transmitting power, and this constant is defined as $C=1 /\left(G^{2} N_{0}\right)$, where the FG amplifying factor $G$ is defined as \begin{IEEEeqnarray*}{rcl} G=\sqrt{\frac{P_{2}}{P_{1} |h_1|^{2}+N_{1}}}.\IEEEyesnumber \end{IEEEeqnarray*} Using the definition of $H$-function, we can express $G$ in terms of the $H$-functions \begin{IEEEeqnarray*}{rcl} G=\kappa H_{1,2}^{2,1}\left[\Lambda \left|\begin{array}{c} (0,1) \\ (0,1),(-\frac{1}{\alpha }+\mu ,\frac{1}{\alpha }) \\\end{array}\right.\right].\IEEEyesnumber \label{G} \end{IEEEeqnarray*} \begin{theorem} The CDF of the end-to-end SNR of the mixed RF/UWOC communcation system using the FG relaying scheme $F_{\gamma_{e q}}(\gamma_{e q})$, defined in \eqref{gammaeq1}, can be obtained in exact closed-form as shown in \eqref{gammaeqcdf} in terms of bivariate $H$-functions, where $H_{\cdot,\cdot:\cdot,\cdot;\cdot,\cdot}^{\cdot,\cdot:\cdot,\cdot;\cdot,\cdot}[\cdot|\cdot]$ is the bivariate $H$-Function defined as \cite[Eq. (2.55)]{mathaiHFunctionTheoryApplications2010} \end{theorem} \begin{proof} See Appendix A. \end{proof} Note that the current implementation of bivariate $H$-function for numerical computation is mature and efficient, including GPU-accelerated versions, and has been implemented using the most popular software, including MATLAB$^\circledR$ \cite{cherguiRicianKfactorbasedAnalysis2018}, Mathematica$^\circledR$ \cite{almeidagarciaCACFARDetectionPerformance2019}, and Python \cite{alhennawiClosedFormExactAsymptotic2016}. Also, the exact-closed expression for the CDF in \eqref{gammaeqcdf} is a key analytical tool to derive the SOP metric of the mixed RF/UWOC system. \begin{figure*}[!bht] \begin{IEEEeqnarray*}{rcl} F_{\gamma _{eq}}(\gamma _{eq})&=&1-\frac{\gamma \kappa (1-\omega ) }{\Gamma (a)}H_{1,0:0,2;1,1}^{0,1:2,0;0,1}\!\!\left[\begin{array}{c} \frac{b^{-r} C}{\mu _r} \\ \frac{1}{\gamma \Lambda } \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & & ; & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ & : & (0,1),(a,\frac{r}{c}) & ; & (1,1) \\\end{array}\!\!\!\right]\\ &&-\gamma \kappa r \omega H_{1,0:0,2;1,1}^{0,1:2,0;0,1}\!\!\left[\begin{array}{c} \frac{C \lambda ^{-r}}{\mu _r} \\ \frac{1}{\gamma \Lambda } \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & & ; & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ & : & (1,1),(0,r) & ; & (1,1) \\\end{array}\!\!\!\right].\IEEEyesnumber \label{gammaeqcdf} \end{IEEEeqnarray*} \hrule \begin{IEEEeqnarray*}{rcl} f_{\gamma _{eq}}(\gamma _{eq})&=&\frac{\kappa (1-\omega ) }{\Gamma (a)}H_{1,0:1,1;0,2}^{0,1:0,1;2,0}\!\!\left[\begin{array}{c} \frac{1}{\gamma \Lambda } \\ \frac{b^{-r} C}{\mu _r} \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) & ; & \\ & : & (2,1) & ; & (0,1),(a,\frac{r}{c}) \\\end{array}\!\!\!\right]\\ &&+\kappa r \omega H_{1,0:1,1;0,2}^{0,1:0,1;2,0}\!\!\left[\begin{array}{c} \frac{1}{\gamma \Lambda } \\ \frac{C \lambda ^{-r}}{\mu _r} \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) & ; & \\ & : & (2,1) & ; & (1,1),(0,r) \\\end{array}\!\!\!\right].\IEEEyesnumber\label{gammaeqpdf} \end{IEEEeqnarray*} \hrule \begin{IEEEeqnarray*}{rcl} \text{SOP}_L&=&1-\frac{\Theta \kappa (1-\omega ) \kappa _e }{\Gamma (a) \Lambda _e^2}H_{1,0:1,2;0,2}^{0,1:1,1;2,0}\!\!\left[\begin{array}{c} \frac{\Lambda _e}{\Theta \Lambda } \\ \frac{b^{-r} C}{\mu _r} \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) & ; & \\ & : & \left(\frac{1+\alpha _e \mu _e}{\alpha _e},\frac{1}{\alpha _e}\right),(1,1) & ; & (0,1),(a,\frac{r}{c}) \\\end{array}\!\!\!\right] \\ &&-\frac{\Theta \kappa r \omega \kappa _e }{\Lambda _e^2}H_{1,0:1,2;0,2}^{0,1:1,1;2,0}\!\!\left[\begin{array}{c} \frac{\Lambda _e}{\Theta \Lambda } \\ \frac{C \lambda ^{-r}}{\mu _r} \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) & ; & \\ & : & \left(\frac{1+\alpha _e \mu _e}{\alpha _e},\frac{1}{\alpha _e}\right),(1,1) & ; & (1,1),(0,r) \\\end{array}\!\!\!\right]. \IEEEyesnumber \label{soplb} \end{IEEEeqnarray*} \hrule \begin{IEEEeqnarray*}{rcl} \text{SOP}_a=1-\frac{\kappa (1-\omega ) \kappa _e }{\Lambda \Gamma (a) \Lambda _e}H_{3,2}^{1,3}\!\!\left[\frac{b^r \Lambda _e \mu _r}{C \Theta \Lambda }\middle|\!\!\!\begin{array}{c} (1,1),(1-a,\frac{r}{c}),(1-\mu ,\frac{1}{\alpha }) \\ \left(\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\\end{array}\!\!\!\right]-\frac{\kappa r \omega \kappa _e }{\Lambda \Lambda _e}H_{2,1}^{1,2}\!\!\left[\frac{\lambda ^r \Lambda _e \mu _r}{C \Theta \Lambda }\middle|\!\!\!\begin{array}{c} (1,r),(1-\mu ,\frac{1}{\alpha }) \\ \left(\mu _e,\frac{1}{\alpha _e}\right) \\\end{array}\!\!\!\right].\IEEEyesnumber\label{sopa} \end{IEEEeqnarray*} \hrule \begin{IEEEeqnarray*}{rcl} \text{SOP}_{\text{ae}}&=&1-\frac{(1-\omega ) \alpha _e}{\Gamma (a) \Gamma (\mu ) \Gamma \left(\mu _e\right) \Gamma \left(\alpha _e \mu _e+1\right)}\Gamma\left(\mu +\frac{\alpha _e \mu _e}{\alpha }\right) \left(\frac{\Lambda _e}{\Theta \Lambda }\right)^{\alpha _e \mu _e} H_{2,1}^{1,2}\!\!\left[\frac{b^r\mu _r}{C}\middle|\!\!\!\begin{array}{c} (1,1),(1-a,\frac{r}{c}) \\ \left(\alpha _e \mu _e,1\right) \\\end{array}\!\!\!\right]\\ &&-\frac{r \omega \alpha _e}{\Gamma (\mu ) \Gamma \left(\mu _e\right) \Gamma \left(\alpha _e \mu _e+1\right)}\Gamma \left(\mu +\frac{\alpha_e \mu _e}{\alpha }\right) \left(\frac{\Lambda _e}{\Theta \Lambda }\right)^{\alpha _e \mu _e} H_{2,1}^{1,2}\!\!\left[\frac{\lambda ^r \mu _r}{C}\middle|\!\!\!\begin{array}{c} (0,1),(1,r) \\ \left(\alpha _e \mu _e,1\right) \\\end{array}\!\!\!\right].\IEEEyesnumber\label{sopae} \end{IEEEeqnarray*} \hrule \end{figure*} \begin{theorem} The PDF of the end-to-end SNR, which is defined in \eqref{gammaeq1}, of the mixed RF/UWOC communication system using the FG relaying scheme, denoted by $f_{\gamma_{e q}}(\gamma_{e q})$, can be obtained in exact closed-form as shown in \eqref{gammaeqpdf}. \end{theorem} \begin{proof} See Appendix B. \end{proof} It is worth noting that the PDF expression in \eqref{gammaeqpdf} is the most critical step required to evaluate the PNZ performance metric, as will be shown in the next section. \section{PERFORMANCE METRICS} This section presents analytical expressions for the critical secrecy performance metrics of a mixed RF/UWOC communication system, including both SOP and PNZ, in the presence of air bubbles and temperature gradients in the UWOC channel and medium nonlinearity in the RF channel. \subsection{SOP} SOP is defined as the probability that the secrecy capacity $C_s$ falls below a target rate of confidential information $R_s$ and it can be expressed as \begin{IEEEeqnarray*}{rcl} S O P\left(R_{s}\right)&=&\operatorname{Pr}\left\{\log _{2}\left(\frac{1+\gamma_{eq}}{1+\gamma_{e}}\right)<R_{s}\right\} \\ &=&\operatorname{Pr}\left\{\gamma_{eq} \leq \Theta \gamma_{e}+\Theta-1\right\} \\ &=&\int_{0}^{\infty} \!\!\!F_{eq}\left(\Theta \gamma_{e}+\Theta-1\right) f_{e}\left(\gamma_{e}\right) d \gamma_{e}\IEEEyesnumber \end{IEEEeqnarray*} where $\Theta=e^{R_{s}}$. \subsubsection{Lower bound} Referring to \cite{leiSecrecyCapacityAnalysis2017,kongPhysicalLayerSecurity2019}, a tight lower bound for the SOP can be given as derived as \begin{IEEEeqnarray*}{rcl} S O P_{L}=\int_{0}^{\infty} F_{\gamma_{e q}}(\Theta \gamma) f_{\gamma_{e}}(\gamma) d \gamma.\IEEEyesnumber\label{soplb1} \end{IEEEeqnarray*} \begin{theorem} The lower bound for the SOP of the mixed RF/UWOC communication system using the FG relaying scheme defined in \eqref{soplb1} can be obtained in exact closed-form as shown in \eqref{soplb}. \end{theorem} \begin{proof} See Appendix C. \end{proof} \subsubsection{Asymptotic results} To gain more insight into the SOP performance and the dependency between the link quality of both RF and UWOC channels, we now derive asymptotic expressions for SOP. We consider two scenarios, namely $\gamma_1 \to \infty$ and $\gamma_e \to \infty$. \begin{corollary} For scenarios $\gamma_1 \to \infty$ and $\gamma_e \to \infty$, the asymptotic expressions of SOP of a mixed RF/UWOC communication system using FG relaying scheme can be given as \eqref{sopa} and \eqref{sopae} in terms of $H$-functions, respectively. \end{corollary} \begin{proof} See Appendix D. \end{proof} Note that in contrast to the closed expression of the lower bound of the SOP in \eqref{soplb} in terms of bivariate $H$-functions, which requires numerical evaluation of double line integrals, the asymptotic expressions in \eqref{sopa} and \eqref{sopae} only require numerical calculation of single line integrals, thus reducing the complexity of the calculations. Furthermore, as shown in Section \RNum{5}, for a target SOP performance, the asymptotic expressions in \eqref{sopa} and \eqref{sopae} can be used to determine rapidly the optimal transmitting power to maximize energy efficiency. In the special case of a two-hop mixed RF/UWOC communication system over Rayleigh RF links and a thermally uniform UWOC channel, we can further simplify the asymptotic expressions in \eqref{sopa} and \eqref{sopae} by setting $c=1$, $\alpha=\alpha_e=1$, $\mu=\mu_e=1$. For example, eq. \eqref{sopa} can be simplified into \begin{IEEEeqnarray*}{rcl} \text{SOP}_a&=&\frac{\kappa \kappa _e}{\lambda \Lambda \Lambda _e^2 \mu _r}\bBigg@{3}(\!-a \lambda (1-\omega ) \Lambda _e \mu _r \thinspace\text{exp}\left(\frac{C \Theta \Lambda}{b \Lambda _e \mu _r}\right)\\ &&\times E_{a+1}\left(\frac{C \Theta \Lambda }{b \Lambda _e \mu _r}\right)-C \Theta \Lambda \omega \thinspace\text{exp}\left(\frac{C \Theta \Lambda}{\lambda \Lambda _e \mu _r}\right) \\ &&\times E_i\left(-\frac{C \Theta \Lambda }{\lambda \Lambda _e \mu _r}\right)\bBigg@{3})+\frac{\Lambda \Lambda _e-\kappa \omega \kappa _e}{\Lambda \Lambda _e}\IEEEyesnumber \end{IEEEeqnarray*} where $E_i(x)$ and $E_n(x)$ both denote the exponential integral \cite[Eq. (8.211.1)]{i.s.gradshteynTableIntegralsSeries2007} \subsection{PNZ} PNZ is another critical metric for to evaluate the secrecy performance of a communication system, which is defined as $\operatorname{Pr}\left(C_{s}>0\right)$, where $C_s$ is the secrecy capacity. PNZ is generally related to channel conditions of all the channels in the mixed RF/UWOC systems. In this section, we derive the exact closed-form and asymptotic expressions for PNZ and analyze the relationship between channel parameters and PNZ performance. \subsubsection{Exact results} According to \cite{kongPhysicalLayerSecurity2019}, PNZ can be reformed as \begin{IEEEeqnarray*}{rcl} \mathcal{P}_{n z}=\operatorname{Pr}\left(\gamma_{eq}>\gamma_{e}\right)=\int_{0}^{\infty} f_{eq}\left(\gamma_{eq}\right) F_{e}\left(\gamma_{eq}\right) d \gamma_{eq}. \IEEEyesnumber \label{pnz1} \end{IEEEeqnarray*} \begin{theorem} The exact PNZ of the mixed RF/UWOC communication system using the FG relaying scheme defined in \eqref{pnz1} can be obtained in exact closed-form as shown in \eqref{pnz}. \end{theorem} \begin{proof} See Appendix E. \end{proof} \subsubsection{Asymptotic results} To gain more insight into the PNZ performance and the dependency between the link quality of both RF and UWOC channels, we now derive asymptotic expressions for PNZ. We consider two scenarios, namely $\gamma_1 \to \infty$ and $\gamma_e \to \infty$. \begin{corollary} For scenarios $\gamma_1 \to \infty$ and $\gamma_e \to \infty$, the asymptotic expressions of PNZ of a mixed RF/UWOC communication system using the FG relaying scheme are given as \eqref{pnza} and \eqref{pnzae} in terms of $H$-functions, respectively. \end{corollary} \begin{proof} Observing that the expressions for the lower bound of the SOP in \eqref{soplb} and exact PNZ in \eqref{pnz} have a similar structure; therefore, eqs. \eqref{pnza} and \eqref{pnzae} can be easily obtained using the same techniques as those used for deriving \eqref{sopa} and \eqref{sopae}, and the proof is complete. \end{proof} Note that, similar to the asymptotic expressions of the SOP in \eqref{sopa} and \eqref{sopae}, for a target PNZ performance, the asymptotic expressions of PNZ in \eqref{pnza} and \eqref{pnzae} are also suitable for fast numerical calculations and useful to determine the optimal transmitting power to maximize energy efficiency. \begin{figure*}[!bht] \begin{IEEEeqnarray*}{rcl} \mathcal{P}_{n z}&=&\frac{\kappa (1-\omega ) \kappa _e }{\Gamma (a) \Lambda _e^2}H_{1,0:0,2;1,2}^{0,1:2,0;1,1}\!\!\left[\begin{array}{c} \frac{b^{-r} C}{\mu _r} \\ \frac{\Lambda _e}{\Lambda } \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & & ; & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ & : & (0,1),(a,\frac{r}{c}) & ; & \left(\frac{1+\alpha _e \mu _e}{\alpha _e},\frac{1}{\alpha _e}\right),(1,1) \\\end{array}\!\!\!\right]\\ &&+\frac{\kappa r \omega \kappa _e }{\Lambda _e^2}H_{1,0:0,2;1,2}^{0,1:2,0;1,1}\!\!\left[\begin{array}{c} \frac{C \lambda ^{-r}}{\mu _r} \\ \frac{\Lambda _e}{\Lambda } \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) & : & & ; & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ & : & (1,1),(0,r) & ; & \left(\frac{1+\alpha _e \mu _e}{\alpha _e},\frac{1}{\alpha _e}\right),(1,1) \\\end{array}\!\!\!\right].\IEEEyesnumber \label{pnz} \end{IEEEeqnarray*} \hrule \begin{IEEEeqnarray*}{rcl} \mathcal{P}_{n z a}&=&\frac{\kappa r \omega \kappa _e }{\Lambda \Lambda _e}H_{2,1}^{1,2}\!\!\left[\frac{\lambda ^r \Lambda _e \mu _r}{C \Lambda }\middle|\!\!\!\begin{array}{c} (1,r),(1-\mu ,\frac{1}{\alpha }) \\ \left(\mu _e,\frac{1}{\alpha _e}\right) \\\end{array}\!\!\!\right]+\frac{\kappa (1-\omega ) \kappa _e }{\Lambda \Gamma (a) \Lambda _e}H_{3,2}^{1,3}\!\!\left[\frac{b^r \Lambda _e \mu _r}{C \Lambda }\middle|\!\!\!\begin{array}{c} (1,1),(1-a,\frac{r}{c}),(1-\mu ,\frac{1}{\alpha }) \\ \left(\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\\end{array}\!\!\!\right].\IEEEyesnumber \label{pnza} \end{IEEEeqnarray*} \hrule \begin{IEEEeqnarray*}{rcl} \mathcal{P}_{n z a e}&=&\frac{\kappa r \omega \alpha _e \kappa _e \Lambda ^{-\alpha _e \mu _e-1} \Lambda _e^{\alpha _e \mu _e-1} \Gamma \left(\mu +\frac{\alpha _e \mu_e}{\alpha }\right) }{\Gamma \left(\alpha _e \mu _e+1\right)}H_{2,1}^{1,2}\!\!\left[\frac{\lambda ^r \mu _r}{C}\middle|\!\!\!\begin{array}{c} (0,1),(1,r) \\ \left(\alpha _e \mu _e,1\right) \\\end{array}\!\!\!\right]\\ &&+\frac{\kappa (1-\omega ) \alpha _e \kappa _e \Lambda ^{-\alpha _e \mu _e-1} \Lambda _e^{\alpha _e \mu _e-1} \Gamma \left(\mu +\frac{\alpha_e \mu _e}{\alpha }\right) }{\Gamma (a) \Gamma \left(\alpha _e \mu _e+1\right)}H_{2,1}^{1,2}\!\!\left[\frac{b^r \mu _r}{C}\middle|\!\!\!\begin{array}{c} (1,1),(1-a,\frac{r}{c}) \\ \left(\alpha _e \mu _e,1\right) \\\end{array}\!\!\!\right].\IEEEyesnumber \label{pnzae} \end{IEEEeqnarray*} \hrule \end{figure*} \section{Numerical Results And Discussion} In this section, we provide some numerical results to verify the analytic and asymptotic expressions of SOP and PNZ derived in Section \RNum{4}, and thoroughly investigate the combined effect of the channel quality of both RF and UWOC channels on the secrecy performance of the two-hop mixed RF/UWOC communication system. All practical environmental physical factors that can affect channel quality, including levels of air bubbles, temperature gradients, and salinity of the UWOC channel, as well as the medium nonlinearity and multipath cluster characteristics of the RF channel, are taken into account. For brevity, we use $[\cdot, \cdot]$ to denote the value set of $[\text{air bubbles level}, \text{temperature gradient}]$ in this section. In Fig. \ref{fig.2} -- Fig. \ref{fig.6}, we investigate the combined effect of the channel quality of both RF and UWOC channels on the SOP metric of the two-hop mixed RF/UWOC communication system. \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure2.pdf} \caption{SOP versus $\bar{\gamma}_1$ with various fading parameters when $\alpha=\alpha_e=1.6$, $\mu=\mu_e=1.5$, $R_s=0.01$, and $\bar{\gamma}_e=\bar{\gamma}_2 =10$ dB} \label{fig.2} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure3.pdf} \caption{SOP versus $\bar{\gamma}_1$ with various fading parameters when $\alpha=\alpha_e=1.6$, $\mu=\mu_e=1.5$, $R_s=0.01$, and $\bar{\gamma}_2=0$ dB} \label{fig.3} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure4.pdf} \caption{SOP versus $\bar{\gamma}_1$ with various fading parameters $R_s=0.01$, $\bar{\gamma}_2=\bar{\gamma}_e=10$ dB, and UWOC channel parameter is [2.4,0.05]} \label{fig.4} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure5.pdf} \caption{SOP versus $\bar{\gamma}_e$ with various fading parameters when $\alpha=\alpha_e=1.6$, $\mu=\mu_e=1.5$, $R_s=0.01$, and $\bar{\gamma}_1=\bar{\gamma}_2=10$ dB} \label{fig.5} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure6.pdf} \caption{SOP versus $\bar{\gamma}_e$ with various fading parameters when $\alpha=\alpha_e=1.6$, $\mu=\mu_e=1.5$, $R_s=0.01$, and $\bar{\gamma}_2=20$ dB} \label{fig.6} \end{figure} Figure \ref{fig.2} shows the lower bound and the asymptotic SOP with average SNR of the SR link $\gamma_1$ for a mixed two-hop RF/UWOC system under different quality scenarios of UWOC channel. Both RF SR and SE links follow the $\alpha$-$\mu$ distribution and have the same parameters, where $\alpha=\alpha_e=1.6$, $\mu=\mu_e=1.5$. The average SNR of the SE and RD links are both set as $\bar{\gamma}_2=\bar{\gamma}_e=10$ dB. As shown in Fig. \ref{fig.2}, the exact theoretical results are almost identical to the simulation results, and both closely agree with the derived lower bound. Asymptotic results are tight when the average SNR is greater than 30 dB. Further, when the average SNR increases from 0 to 30 dB, SOP rapidly decreases. Also, SOP tends to saturate when the average SNR is between 30 and 40 dB. Given the cost of the relay battery replacement and engineering difficulties, the communication system should guarantee the SOP while cutting down on energy consumption. In practice, one should therefore select the optimal transmission power corresponding to the saturation starting point. Figure \ref{fig.3} depicts the SOP variation versus the SR average SNR $\gamma_1$ for the mixed two-hop RF/UWOC system under three different eavesdropper interference levels, i.e., $\bar{\gamma}_e=3,0,-3$ dB. Parameters in Fig. \ref{fig.3} are set as follows: $\alpha=\alpha_e=1.6$, $\mu=\mu_e=1.5$, UWOC channel parameter is [2.4,0.05], and $\bar{\gamma}_2=0$ dB. It can be observed that the lower bounds closely match the exact results in the whole SNR region. The asymptotic result curve gradually coincides with the exact result curve when $\bar{\gamma}_1$ takes higher values starting from 20 dB. We can also observe that the SOP is monotonically increasing with $\bar{\gamma}_1$, assuming that the SNR of the SE link is a fixed value. Holding the other parameters constant, the larger the $\bar{\gamma}_e$, the lower the system SOP. In short, as the quality of the eavesdropping channel improves, the SOP performance of the system deteriorates. Figure \ref{fig.4} indicates the effect of the variation in average SNR of the SR link on the SOP metric of a two-hop mixed RF/UWOC, with three different RF channel qualities. Evidently, SOP monotonically decreases with the increase of $\bar{\gamma}_1$, and SOP tends to saturate when $\bar{\gamma}_1 \geq$ 30 dB. Besides, Fig. \ref{fig.4} depicts that as the $\alpha-\mu$ value increases, the two-hop mixed RF/UWOC system secrecy performance worsens, and vice versa. This is because of the phenomena of severe nonlinearity and sparse clustering when the signals are propagating in a high $\alpha-\mu$ value RF channel, and poor RF channel quality makes it easier for eavesdroppers to intercept signals. As shown in Fig. \ref{fig.5}, as the $\bar{\gamma}_e$ progressively increases, the SOP value increases, the information intercepted by the eavesdropper increases, and the system's secrecy performance gradually decreases. Moreover, the asymptotic result is more accurate at $\bar{\gamma}_e$ greater than 15 dB. In Fig. \ref{fig.6}, we set the same channel parameters as in Fig. \ref{fig.3}, except for setting the UWOC average SNR, i.e., $\bar{\gamma}_2=20$ dB. Fig. \ref{fig.6} shows that SOP increases with $\bar{\gamma}_e$ when the other parameters remain unchanged. The same interpretation of Fig. \ref{fig.5} can also be applied to Fig. \ref{fig.6}. Additionally, the rate at which the asymptotic results approach exact results varies for different SR average SNR. For $\bar{\gamma}_1=20$ dB, the asymptotic results begin to match the exact result starting at $\bar{\gamma}_e=5$ dB. Besides, the close match of the lower bound and the exact results demonstrates the robustness and accuracy of \eqref{soplb}. In Fig. \ref{fig.7} -- Fig. \ref{fig.10}, We investigate the combined effect of the channel quality of both RF and UWOC channels on the PNZ metric of the two-hop mixed RF/UWOC communication system. \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure7.pdf} \caption{$\mathcal{P}_{n z}$ versus $\bar{\gamma}_1$ with various fading parameters when $\alpha=\alpha_e=2.1$, $\mu=\mu_e=1.4$ and $\bar{\gamma}_e=\bar{\gamma}_2=0$ dB} \label{fig.7} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure8.pdf} \caption{$\mathcal{P}_{n z}$ versus $\bar{\gamma}_1$ with various fading parameters when $\alpha=\alpha_e=1.5$, $\mu=\mu_e=0.8$ and $\bar{\gamma}_2=0$ dB} \label{fig.8} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure9.pdf} \caption{$\mathcal{P}_{n z}$ versus $\bar{\gamma}_e$ with various fading parameters when $\alpha=\alpha_e=2.1$, $\mu=\mu_e=1.4$ and $\bar{\gamma}_1=\bar{\gamma}_2=20$ dB} \label{fig.9} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=3.45in]{figure10.pdf} \caption{$\mathcal{P}_{n z}$ versus $\bar{\gamma}_e$ with various fading parameters when $\alpha=\alpha_e=1.5$, $\mu=\mu_e=0.8$ and $\bar{\gamma}_2=20$ dB} \label{fig.10} \end{figure} Figure \ref{fig.7} shows the effect of the SR link average SNR $\bar{\gamma}_1$ on the PNZ of the mixed RF/UWOC for different UWOC channel parameters. PNZ increases incrementally as $\bar{\gamma}_1$ increases, which indicates an increase in secrecy performance. It can be observed that PNZ decreases as the degree of turbulence increases, i.e., the higher the level of air bubbles and the larger the temperature gradient, the worse the secrecy performance in the system. Additionally, we depict the effects of salinity on UWOC performance in Fig. \ref{fig.7}. The salinity affects the system secrecy performance to a much lesser extent than the level of air bubble and temperature gradient. This is because the generation and break-up of the air bubbles in the UWOC channels causes dramatic and random fluctuations of the underwater optical signals, which can significantly deteriorate the secrecy performance of the system. Fig. \ref{fig.7} shows that eavesdroppers may benefit from a low UWOC channel quality. On the contrary, in a high quality UWOC channel, the likelihood of an eavesdropper successfully eavesdropping is greatly reduced. Therefore, in practical applications, increasing the channel quality can increase the system transmission capacity and thus improve the system secrecy performance. Fig. \ref{fig.7} also shows that asymptotic results can quickly approach the exact result for poorer channels. For example, for a UWOC channel with channel parameters of [16.5,0], the asymptotic result can achieve a match with the exact value at $\bar{\gamma}_1\geq 20$ dB. When the channel parameter set is [2.4, 0.05], the asymptotic result can only be accurate at $\bar{\gamma}_1 >25$ dB. The remaining parameters are set as follows, $\bar{\gamma}_e=\bar{\gamma}_2=0$ dB, $\alpha=\alpha_e=2.1$, $\mu=\mu_e=1.4$. In Fig. \ref{fig.8}, the RF channel parameters are $\alpha=\alpha_e=1.5$, $\mu=\mu_e=0.8$, and the UWOC channel parameters are [2.4,0.05]. We can explain the curves in Fig. \ref{fig.8} using a principle similar to Fig. \ref{fig.7}. Furthermore, in the case where $\bar{\gamma}_1$ remains unchanged, the smaller the $\bar{\gamma}_e$, the worse is the quality of the eavesdropping channel; therefore, leading to a PNZ performance degradation. In addition to Fig. \ref{fig.8}, we analyzed the effect of the average SNR $\bar{\gamma}_1$ on the PNZ, as shown by Fig. \ref{fig.9} and Fig.\ref{fig.10}. The difference is that in Fig. \ref{fig.9} $\alpha=\alpha_e=2.1$, $\mu=\mu_e=1.4$ and $\bar{\gamma}_1=\bar{\gamma}_2=20$ dB. whereas the RF channel parameters in Fig. \ref{fig.10} are $\alpha=\alpha_e=1.5$ and $\mu=\mu_e=0.8$. It can be inferred from Fig. \ref{fig.9} and Fig. \ref{fig.10} that the asymptotic result only matches the exact value when $\bar{\gamma}_e$ is large, and the PNZ gradually decreases until it reaches zero. \section{Conclusion} We investigated the secrecy performance of a two-hop mixed RF/UWOC communication system using fixed-gain AF relaying. To allow the results to be more generic and applicable to more realistic physical scenarios, we model RF channels using the $\alpha$-$\mu$ distribution, which considers both the nonlinear of the transmission medium and multipath cluster characteristics, and model UWOC channels using the laboratory EGG distribution, which can account for different levels of air bubbles, temperature gradients, and salinity. Closed-form expressions for the PDF and the CDF of the two-hop end-to-end SNR were both derived in terms of the bivariate $H$-function. Based on these results, we obtained a tight closed-form expression of the lower bound of the SOP and the exact closed-form expression of the PNZ. Furthermore, we also derived asymptotic expressions in simple functions for both SOP and PNZ to allow rapid numerical evaluation. Moreover, based on the asymptotic results, we presented an approach to determine the optimal transmitting power to maximize the energy efficiency, for given target performance of both SOP and PNZ. We fully investigated the effects of various existing phenomena of both RF and UWOC channels on the secrecy performance of the mixed RF/UWOC communication system. Also, our generalized theoretical framework is also applicable to various classical RF and underwater optical channel models including Rayleigh and Nakagami for RF channels and EG and Generalized Gamma for UWOC channels. Our results can be used in practical mixed security RF/UWOC communication systems design. The interesting topics for future work include: (i) to investigate the secrecy performance of a mixed RF/UWOC communication system using a energy-harvesting enabled relay with the aim of improving the system life time; (ii) to investigate the secrecy performance of a mixed RF/UWOC communication system using multiple relays with appropriate relaying selection algorithms. \appendices \renewcommand{\theequation}{\thesection.\arabic{equation}} \section{Proof of THEOREM 1} \setcounter{equation}{0} Using \eqref{gammaeq1}, we write the CDF of the end-to-end SNR in the following form \begin{IEEEeqnarray*}{rcl} F_{\gamma_{eq}}(\gamma_{eq}) &=&\int_{0}^{\infty} \operatorname{Pr}\left[\frac{\gamma_{1} \gamma_{2}}{\gamma_{2}+C} \leq \gamma \mid \gamma_{2}\right] f_{\gamma_{2}}\left(\gamma_{2}\right) d \gamma_{2} \\ &=&1\!\!-\!\!\int_{\gamma}^{\infty} \bar{F}_{\gamma_{2}}\left(\frac{C \gamma}{x-\gamma}\right) f_{\gamma_{1}}(x) d x.\IEEEyesnumber \label{appcdfgammaeq} \end{IEEEeqnarray*} Substituting \eqref{ampdf} and \eqref{eggccdf} into \eqref{appcdfgammaeq} and replacing the integral variable $x$ with $z=x+\gamma$, after some simplifications, we can express \eqref{appcdfgammaeq} as \begin{IEEEeqnarray*}{rcl} F_{\gamma _{eq}}\left(\gamma _{eq}\right)=1+I_1+I_2\IEEEyesnumber \label{appcdfgammaeq1} \end{IEEEeqnarray*} where \begin{IEEEeqnarray*}{rcl} I_1&=&-\frac{\kappa (1-\omega )}{\Gamma (a)}\int _0^{\infty }\!\!H_{0,1}^{1,0}\left[(z+\gamma ) \Lambda\left|\!\!\!\begin{array}{c} \\ \left(-\frac{1}{\alpha }+\mu ,\frac{1}{\alpha }\right) \\\end{array}\right.\!\!\!\!\right] \\ &&\times H_{1,2}^{2,0}\!\!\left[\frac{b^{-r} C \gamma }{z \mu _r}\middle|\!\!\!\begin{array}{c} (1,1) \\ (0,1),(a,\frac{r}{c}) \\\end{array}\!\!\!\right]dz\IEEEyesnumber\label{i11} \end{IEEEeqnarray*} and \begin{IEEEeqnarray*}{rcl} I_2&=&-\kappa r \omega \int _0^{\infty }H_{0,1}^{1,0}\!\!\left[\frac{C \gamma \lambda ^{-r}}{z \mu _r}\middle|\!\!\!\begin{array}{c} \\ (0,r) \\\end{array}\!\!\!\right] \\ &&\times H_{0,1}^{1,0}\left[(z+\gamma ) \Lambda \left|\begin{array}{c} \\ \left(-\frac{1}{\alpha }+\mu ,\frac{1}{\alpha }\right) \\\end{array}\right.\right]dz.\IEEEyesnumber\label{i21} \end{IEEEeqnarray*} To solve \eqref{i11}, we convert all the $H$-functions in \eqref{i11} into a line integral, and place the integral with respect to $x$ in the innermost part by rearranging the order of multiple integrals. Then, we have \begin{IEEEeqnarray*}{rcl} I_1&=&\frac{\kappa (1-\omega )}{4 \pi ^2 \Gamma (a)}\int _{\mathcal{L}}^t\frac{\Gamma (t)}{\Gamma (t+1)}\Gamma \left(a+\frac{r t}{c}\right)\left(\frac{b^r\mu _r}{C \gamma }\right)^t\\ &&\times\!\!\! \int _{\mathcal{L}}^s\!\!\!\Lambda ^{-s} \Gamma \!\!\left(\frac{s}{\alpha }+\mu -\frac{1}{\alpha }\right) \!\!\!\int _0^{\infty }\!\!\!\!\!z^t(z+\gamma )^{-s}\!dzdsdt.\IEEEyesnumber \end{IEEEeqnarray*} By utilizing \cite[Eq. (3.197/1)]{i.s.gradshteynTableIntegralsSeries2007} to solve the integration of $z$, after some simplifications and using the definition of the bivariate $H$-function \cite[Eq. (2.57)]{mathaiHFunctionTheoryApplications2010}, we can finally express $I_1$ in \eqref{i11} in the following form \begin{IEEEeqnarray*}{rcl} &&I_1= -\frac{\gamma \kappa (1-\omega ) }{\Gamma (a)}\\ &&\times H_{1,0:0,2;1,1}^{0,1:2,0;0,1}\!\!\left[\!\!\!\begin{array}{c} \frac{b^{-r} C}{\mu _r} \\ \frac{1}{\gamma \Lambda } \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) &\!\!\!\!\!\! :\!\!\!\!\!\! & &\!\!\!\!\!\! ;\!\!\!\!\!\! & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ &\!\! \!\!\!\!: \!\!\!\!\!\!& (0,1),(a,\frac{r}{c}) &\!\!\!\!\!\! ;\!\!\!\!\!\! & (1,1) \\\end{array}\!\!\!\!\right].\\ \IEEEyesnumber \label{i12} \end{IEEEeqnarray*} We can solve \eqref{i21} in a similar way as we have solved \eqref{i11}. All $H$-functions are converted to the form of the line integrals and by rearranging the multiple integrals, the integral regarding $z$ is placed in the innermost part of the expression. Then, we have \begin{IEEEeqnarray*}{rcl} I_2&=&\frac{\kappa r \omega }{4 \pi ^2}\int _{\mathcal{L}}^s\Gamma (r s) \left(\frac{\lambda ^r \mu _r}{C \gamma }\right)^s \int _{\mathcal{L}}^t\Lambda^{-t} \Gamma \left(\frac{t}{\alpha }+\mu -\frac{1}{\alpha }\right) \\ &&\times\int _0^{\infty }z^s (z+\gamma )^{-t}dzdtds.\IEEEyesnumber \end{IEEEeqnarray*} Again, we use \cite[Eq. (3.197/1)]{i.s.gradshteynTableIntegralsSeries2007} to solve the integration regarding $z$. Then use \cite[Eq. (2.57)]{mathaiHFunctionTheoryApplications2010} and some simplification, we obtain the following expression \begin{IEEEeqnarray*}{rcl} &&I_2=-\gamma \kappa r \omega \\ &&\times H_{1,0:0,2;1,1}^{0,1:2,0;0,1}\!\!\left[\!\!\!\begin{array}{c} \frac{C \lambda ^{-r}}{\mu _r} \\ \frac{1}{\gamma \Lambda } \\\end{array}\middle|\!\!\!\begin{array}{ccccc} (2,1,1) &\!\!\!\!\!\! :\!\!\!\!\!\! & \!\!\!&\!\!\! ; &\!\!\! \!\!\!\left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ &\!\!\!\!\!\! : \!\!\!\!\!\!& (1,1),(0,r)\!\!\! &\!\!\! ; &\!\!\!\!\!\! (1,1) \\\end{array}\!\!\!\right].\\ \IEEEyesnumber \label{i22} \end{IEEEeqnarray*} Substituting \eqref{i12} and \eqref{i22} into \eqref{appcdfgammaeq1}, we obtian the exact closed-form expression for the CDF as shown by \eqref{gammaeqcdf}. \section{Proof of THEOREM 2} \setcounter{equation}{0} The PDF of the end-to-end SNR can be obtained by using \begin{IEEEeqnarray*}{rcl} f(\gamma_{eq})=\frac{d F(\gamma_{eq})}{d \gamma_{eq}}.\IEEEyesnumber \label{apppdfgammaeq} \end{IEEEeqnarray*} Substituting \eqref{gammaeqcdf} into \eqref{apppdfgammaeq}, after some simplifications, we have \begin{IEEEeqnarray*}{rcl} f_{\gamma_{eq}}(\gamma_{eq}) &=& \frac{\mathrm{d} J_1}{\mathrm{d} \gamma_{eq}}+\frac{\mathrm{d} J_2}{\mathrm{d} \gamma_{eq}}\IEEEyesnumber\label{appgammaeqpdf} \end{IEEEeqnarray*} where \begin{IEEEeqnarray*}{rcl} J_1&=&\frac{\gamma_{eq} \kappa (1-\omega )}{4 \pi ^2 \Gamma (a)}\int _{\mathcal{L}}^t\int _{\mathcal{L}}^s\frac{1}{\Gamma (t)}\left(\frac{1}{\gamma_{eq} \Lambda}\right)^t \Gamma (-s) \Gamma \left(a-\frac{r s}{c}\right) \\ &&\times\Gamma (s+t-1) \Gamma \left(\frac{t}{\alpha }+\mu -\frac{1}{\alpha }\right) \left(\frac{b^{-r}C}{\mu _r}\right)^s\!dsdt\IEEEyesnumber \end{IEEEeqnarray*} and \begin{IEEEeqnarray*}{rcl} J_2&=&\frac{\gamma_{eq} \kappa r \omega }{4 \pi ^2}\!\!\int _{\mathcal{L}}^t\!\int _{\mathcal{L}}^s\!\frac{1}{\Gamma (t)}\left(\frac{1}{\gamma_{eq} \Lambda }\right)^t\!\!\!\!\Gamma (1\!-\!s) \Gamma (-r s)\Gamma (s+t-1) \\ &&\times\Gamma \left(\frac{t}{\alpha }+\mu -\frac{1}{\alpha }\right) \left(\frac{C \lambda ^{-r}}{\mu _r}\right)^sdsdt.\IEEEyesnumber \end{IEEEeqnarray*} By enabling the differential operation in \eqref{appgammaeqpdf}, after some rearrangements, we can represent the first and the second terms on the right of the equation \eqref{appgammaeqpdf} as \begin{IEEEeqnarray*}{rcl} \frac{\mathrm{d} J_1}{\mathrm{d} \gamma_{eq}}&=&\frac{\kappa(1-\omega)}{4\pi^2\Gamma(a)}\int _{\mathcal{L}}^t\int _{\mathcal{L}}^s\!\!\!\frac{ (1-t)}{ \Gamma (t)} C^s \Gamma (-s) (\gamma_{eq}\Lambda) ^{-t} b^{-r s}\mu _r^{-s} \\ &&\times\Gamma (s+t-1) \Gamma\!\! \left(\frac{t}{\alpha }+\mu -\frac{1}{\alpha }\right) \!\!\Gamma\!\! \left(a-\frac{r s}{c}\right)\!dsdt\IEEEyesnumber\label{appd1} \end{IEEEeqnarray*} and \begin{IEEEeqnarray*}{rcl} \frac{\mathrm{d} J_2}{\mathrm{d} \gamma_{eq}}&=&\frac{\kappa r\omega}{4\pi^{2}}\int _{\mathcal{L}}^t\int _{\mathcal{L}}^s\frac{1}{ \Gamma (t)} (1-t) C^s \Gamma (1-s) (\gamma_{eq} \Lambda)^{-t} \lambda^{-r s} \\ &&\times\mu _r^{-s} \Gamma (-r s) \Gamma (s+t-1) \Gamma \!\!\left(\frac{t}{\alpha }\!+\mu \!-\frac{1}{\alpha }\right)\!dsdt,\IEEEyesnumber \label{appd2} \end{IEEEeqnarray*} respectively. After substitute \eqref{appd1} and \eqref{appd2} to \eqref{appgammaeqpdf}, and use the definition of bivariate $H$-function, we can derive the exact closed-form expression of PDF as shown in \eqref{gammaeqpdf}. \section{Proof of THEOREM 3} \setcounter{equation}{0} Substituting \eqref{ampdf} and \eqref{gammaeqcdf} into \eqref{soplb1}, after some rearrangements, we have \begin{IEEEeqnarray*}{rcl} \text{SOP}_L=1+Q_1+Q_2\IEEEyesnumber \label{appsoplb} \end{IEEEeqnarray*} where \begin{IEEEeqnarray*}{rcl} &&Q_1=-\frac{ \Theta \kappa (1-\omega ) \kappa _e}{\Gamma (a)}\int _0^{\infty }\gamma H_{0,1}^{1,0}\!\!\left[\gamma \Lambda _e\middle|\!\!\!\begin{array}{c} \\ \left(-\frac{1}{\alpha _e}+\mu _e,\frac{1}{\alpha _e}\right) \\\end{array}\!\!\!\right]\\ &&\times H_{1,0:0,2;1,1}^{0,1:2,0;0,1}\!\!\left[\!\!\!\begin{array}{c} \frac{b^{-r} C}{\mu _r} \\ \frac{1}{\gamma \Theta \Lambda } \\\end{array}\!\!\middle|\!\!\!\begin{array}{ccccc} (2,1,1) &\!\!\!\!\!\! : &\!\!\!\!\! &\!\!\!\!\!\! ; \!\!\!\!\!\!& \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ &\!\!\!\!\!\! : & \!\!\!\!\!(0,1),(a,\frac{r}{c}) &\!\!\!\!\!\! ;\!\!\!\!\!\! & (1,1) \\\end{array}\!\!\!\!\right]\!\!d\gamma\\ \IEEEyesnumber\label{Q11} \end{IEEEeqnarray*} and \begin{IEEEeqnarray*}{rcl} &&Q_2=-r \gamma \Theta \kappa \omega \kappa _e\int _0^{\infty }\gamma H_{0,1}^{1,0}\!\!\left[\gamma \Lambda _e\middle|\!\begin{array}{c} \\ \left(-\frac{1}{\alpha _e}+\mu _e,\frac{1}{\alpha _e}\right) \\\end{array}\!\!\!\right] \\ &&\times H_{1,0:0,2;1,1}^{0,1:2,0;0,1}\!\!\left[\!\!\!\begin{array}{c} \frac{C \lambda ^{-r}}{\mu _r} \\ \frac{1}{\gamma \Theta \Lambda } \\\end{array}\!\!\!\!\middle|\!\!\!\begin{array}{ccccc} (2,1,1)\!\!\! & \!\!\!: \!\!\!&\!\! \!\!\!\!\!\!& ; \!\!& \!\!\!\left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \\ \!\!\!&\!\!\! : \!\!\!& \!\!(1,1),\!(0,r) \!\!\!\!\!& ; \!\!& \!\!\!(1,1) \\\end{array}\!\!\!\!\right]\!\!d\gamma.\\ \IEEEyesnumber\label{Q21} \end{IEEEeqnarray*} To simplify \eqref{Q11} further, we first express the bivariate $H$-functions in \eqref{Q11} into the form of a double line integral, and then place the curve integral regarding $\gamma$ to the innermost level by rearranging \eqref{Q11}, we have \begin{IEEEeqnarray*}{rcl} Q_1&=&\frac{\Theta \kappa (1-\omega ) \kappa _e}{4 \pi ^2 \Gamma (a)}\int _{\mathcal{L}}^t\frac{(\Theta \Lambda )^{-t} }{\Gamma (t)}\Gamma \left(\frac{t}{\alpha}+\mu -\frac{1}{\alpha }\right)\\ &&\times\int _{\mathcal{L}}^s\Gamma (-s) \Gamma \left(a-\frac{r s}{c}\right) \Gamma (s+t-1) \left(\frac{b^{-r}C}{\mu _r}\right)^s \\ &&\times\int _0^{\infty }\!\!\!\!\gamma ^{1-t} H_{0,1}^{1,0}\!\!\left[\gamma \Lambda _e\middle|\!\!\!\begin{array}{c} \\ \left(-\frac{1}{\alpha _e}+\mu _e,\frac{1}{\alpha _e}\right) \\\end{array}\!\!\!\right]\!d\gamma dsdt.\IEEEyesnumber \label{Q12} \end{IEEEeqnarray*} Then, using \cite[Eq. 2.25.2/1]{vermaIntegralsInvolvingMeijer1966}, we can transform \eqref{Q12} into \begin{IEEEeqnarray*}{rcl} Q_1&=&\frac{\Theta \kappa (1-\omega ) \kappa _e}{4 \pi ^2 \Gamma (a)}\int _{\mathcal{L}}^t\frac{(\Theta \Lambda )^{-t} }{\Gamma (t)}\Gamma \left(\frac{t}{\alpha}+\mu -\frac{1}{\alpha }\right) \\ &&\times\int _{\mathcal{L}}^s\Gamma (-s) \Gamma \left(a-\frac{r s}{c}\right) \Gamma (s+t-1) \\ &&\times\Gamma \!\left(\frac{2-t}{\alpha_e}+\mu _e-\frac{1}{\alpha _e}\right) \Lambda _e^{t-2} \left(\frac{b^{-r} C}{\mu _r}\right)^s\!\!dsdt.\IEEEyesnumber \label{Q13} \end{IEEEeqnarray*} Finally, converting the double curve integral into bivariate $H$-function using \cite[Eq. (2.57)]{mathaiHFunctionTheoryApplications2010}, after some simplifications, we obtain from \eqref{Q13} in an exact closed-form as \begin{IEEEeqnarray*}{rcl} &&Q_1=-\frac{\Theta \kappa (1-\omega ) \kappa _e }{\Gamma (a) \Lambda _e^2}\\ &&\times\! H_{1,0:1,2;0,2}^{0,1:1,1;2,0}\!\!\!\left[\!\!\!\!\begin{array}{c} \frac{\Lambda _e}{\Theta \Lambda } \\ \frac{b^{-r} C}{\mu _r} \\\end{array}\!\!\!\middle|\!\!\!\begin{array}{ccccc} (2,\!1,\!1)\!\!\!\!\!\!& :\!\!\!\!\!\!\!& \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right)\!\! &\!\!\!\!\!\! ;\!\!\!\!\!\! & \\ \!\!\!\!\!\!\!\!& :\!\!\!\!\!\!& \left(\frac{1+\alpha _e \mu _e}{\alpha _e},\!\frac{1}{\alpha _e}\right)\!,(1,\!1)& \!\!\!\!\!\!;\! \!\!\!\!\!& (0,1),(a,\frac{r}{c}) \\\end{array}\!\!\!\!\right].\\ \IEEEyesnumber \label{Q14} \end{IEEEeqnarray*} To process \eqref{Q21} further, we first convert the bivariate $H$-function in \eqref{Q21} into the form of one double curve integral using \cite[Eq. (2.55)]{mathaiHFunctionTheoryApplications2010}. After placing the line integral of $\gamma$ into the innermost layer, we can transform \eqref{Q21} into \begin{IEEEeqnarray*}{rcl} Q_2&=&\frac{\Theta \kappa r \omega \kappa _e}{4 \pi ^2}\int _{\mathcal{L}}^t\frac{(\Theta \Lambda )^{-t} }{\Gamma (t)}\Gamma \left(\frac{t}{\alpha }+\mu -\frac{1}{\alpha}\right)\\ &&\times\int _{\mathcal{L}}^s\Gamma (1-s) \Gamma (-r s) \Gamma (s+t-1) \left(\frac{C \lambda ^{-r}}{\mu _r}\right)^s\\ &&\times\int _0^{\infty}\!\!\!\!\gamma ^{1-t} H_{0,1}^{1,0}\!\!\left[\gamma \Lambda _e\middle|\!\!\!\!\begin{array}{c} \\ \left(-\frac{1}{\alpha _e}+\mu _e,\frac{1}{\alpha _e}\right) \\\end{array}\!\!\!\!\right]\!\!d\gamma dsdt.\IEEEyesnumber \label{Q22} \end{IEEEeqnarray*} Subsequently, using \cite[Eq. 2.25.2/1]{vermaIntegralsInvolvingMeijer1966}, we express the innermost curve integral in \eqref{Q22} in the form of the product of Gamma functions. Then, we can write \eqref{Q22} as \begin{IEEEeqnarray*}{rcl} Q_2&=&\frac{\Theta \kappa r \omega \kappa _e}{4 \pi ^2}\int _{\mathcal{L}}^t\frac{(\Theta \Lambda )^{-t} }{\Gamma (t)}\Gamma \left(\frac{t}{\alpha }+\mu -\frac{1}{\alpha}\right)\\ &&\times\int _{\mathcal{L}}^s\Gamma (1-s) \Gamma (-r s) \Gamma (s+t-1) \\ &&\times\Gamma \!\left(\frac{2-t}{\alpha _e}+\mu _e-\frac{1}{\alpha _e}\right)\Lambda _e^{t-2}\! \left(\frac{C \lambda ^{-r}}{\mu _r}\right)^s\!\!\!dsdt.\IEEEyesnumber \label{Q23} \end{IEEEeqnarray*} Subsequently, based on the same steps as for the derivation of \eqref{Q14}, eq. \eqref{Q23} can be expressed in exact closed-form as \begin{IEEEeqnarray*}{rcl} &&Q_2=-\frac{\Theta \kappa r \omega \kappa _e }{\Lambda _e^2}\\ &&\times H_{1,0:1,2;0,2}^{0,1:1,1;2,0}\!\!\left[\!\!\!\!\begin{array}{c} \frac{\Lambda _e}{\Theta \Lambda } \\ \frac{C \lambda ^{-r}}{\mu _r} \\\end{array}\!\!\!\!\middle|\!\!\!\!\begin{array}{ccccc} (2,\!1,\!1)\!\!\!\!\!\! & : &\!\!\!\!\! \!\!\left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right)\!\! \!\!\!\!\!\!& ;\!\!\!\!\!\! & \! \\ \!\!\!\!\!\!\!\!\!& : & \!\!\!\!\!\!\!\left(\frac{1+\alpha _e \mu _e}{\alpha _e},\frac{1}{\alpha _e}\right)\!,\!(1,1) \!\!\!\!\!\!& ;\!\! \!\!\!\!& (1,1),\!(0,r) \\\end{array}\!\!\!\!\right].\\ \IEEEyesnumber \label{Q24} \end{IEEEeqnarray*} After substituting \eqref{Q14} and \eqref{Q24} into \eqref{appsoplb}, we can finally obtain the closed-form expression of $\text{SOP}_L$ in \eqref{soplb}. \section{Proof of Corollary 3.1} \setcounter{equation}{0} To derive the asymptotic expression of $\text{SOP}$, we need to derive the asymptotic expressions of the first and the second bivariate $H$-function on the right-hand side of \eqref{soplb}, which are denoted by $O_1$ and $O_2$, respectively. We consider two cases: (a) $\gamma_1 \to \infty$ and (b) $\gamma_e \to \infty$. \subsection{Case \texorpdfstring{$\gamma_1 \to \infty$}{}} For the case $\gamma_1 \to \infty$, we first focus on deriving asymptotic expression for $O_1$. Observe that as $\gamma_1$ tends to infinity, $\frac{\theta \Lambda}{\Lambda e}$ tends to zero. Thus, we first express the bivariate $H$-function in the form of one double curve integral, and express the curve integral containing $\frac{\theta \Lambda}{\Lambda e}$ in the form of an $H$- function. Then, we have \begin{IEEEeqnarray*}{rcl} O_1&=&\frac{i \Theta \kappa (1-\omega ) \kappa _e}{2 \pi \Gamma (a) \Lambda _e^2}\int _{\mathcal{L}}^t \Gamma (-t) \Gamma \left(a-\frac{r t}{c}\right)\left(\frac{b^{-r} C}{\mu _r}\right)^t \\ &&\times H_{2,2}^{2,1}\!\!\left[\frac{\Theta \Lambda }{\Lambda _e}\middle|\!\!\!\begin{array}{c} \left(1-\frac{1}{\alpha _e}-\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\ (-1+t,1),(-\frac{1}{\alpha }+\mu ,\frac{1}{\alpha }) \\\end{array}\!\!\!\right]dt.\IEEEyesnumber \label{O11} \end{IEEEeqnarray*} It is easy to observe that the $H$-function in \eqref{O11} contains two poles: $(1-t)$ and $(1-\alpha\mu)$. According to \cite{alhennawiClosedFormExactAsymptotic2016}, when the argument tends to zero, the asymptotic value of the $H$-function can be expressed as the residue of the closest pole to the left of the integration path $l$. Therefore, by utilizing \cite[Eq. (1.8.4)]{kilbasHtransformsTheoryApplications2004}, we can express \eqref{O11} as \begin{IEEEeqnarray*}{rcl} O_1&=&\frac{i \kappa (1-\omega ) \kappa _e}{2 \pi \Lambda \Gamma (a) \Lambda _e}\int _{\mathcal{L}}^t\frac{\Gamma (-t) }{\Gamma(1-t)}\Gamma \left(a-\frac{r t}{c}\right)\Gamma \left(\mu -\frac{t}{\alpha }\right) \\ &&\times\Gamma \left(\frac{t}{\alpha _e}+\mu _e\right) \left(\frac{b^{-r} C \Theta \Lambda }{\Lambda _e \mu _r}\right)^tdt.\IEEEyesnumber \label{O12} \end{IEEEeqnarray*} Following some simplifications, and using the definition of the $H$-function, we can transform \eqref{O12} into the following form \begin{IEEEeqnarray*}{rcl} O_1\!\!=\!\!-\frac{\kappa (1-\omega ) \kappa _e }{\Lambda \Gamma (a) \Lambda _e}H_{3,2}^{1,3}\!\!\left[\!\frac{b^r \Lambda _e \mu _r}{C \Theta \Lambda }\!\!\middle|\!\!\!\begin{array}{c} (1,\!1),\!(1-a,\frac{r}{c}),(1-\mu ,\frac{1}{\alpha }) \\ \!\!\left(\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\\end{array}\!\!\!\!\right].\\ \IEEEyesnumber \label{O13} \end{IEEEeqnarray*} Next, we derive the asymptotic expression for $O_2$. Observing that $O_2$ and $O_1$ have a similar structure, we can readily transform $O_2$ into the following form \begin{IEEEeqnarray*}{rcl} O_2&=&-\frac{i \Theta \kappa r \omega \kappa _e}{2 \pi \Lambda _e^2}\int _{\mathcal{L}}^t \Gamma (1-t) \Gamma (-r t) \left(\frac{C \lambda ^{-r}}{\mu_r}\right)^t\\ &&\times H_{2,2}^{2,1}\!\!\left[\frac{\Theta \Lambda }{\Lambda _e}\middle|\!\!\!\begin{array}{c} \left(1-\frac{1}{\alpha _e}-\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\ (-1+t,1),(-\frac{1}{\alpha }+\mu ,\frac{1}{\alpha }) \\\end{array}\!\!\!\right]dt.\\ \IEEEyesnumber \label{O21} \end{IEEEeqnarray*} Similarly, we again use the residue of the pole $(1-t)$ to represent the asymptotic value of the $H$-function in \eqref{O21} as the argument tends to zero. Then, we have \begin{IEEEeqnarray*}{rcl} O_2&=&\frac{i \kappa r \omega \kappa _e}{2 \pi \Lambda \Lambda _e}\int _{\mathcal{L}}^t\Gamma (-r t) \Gamma \left(\mu -\frac{t}{\alpha }\right) \Gamma\left(\frac{t}{\alpha _e}+\mu _e\right)\\ &&\times \left(\frac{C \Theta \lambda ^{-r} \Lambda }{\Lambda _e \mu _r}\right)^tdt.\IEEEyesnumber\label{O22} \end{IEEEeqnarray*} By using the definition of the $H$-function, we can transform \eqref{O22} into the following form \begin{IEEEeqnarray*}{rcl} O_2=-\frac{\kappa r \omega \kappa _e }{\Lambda \Lambda _e}H_{2,1}^{1,2}\!\!\left[\frac{\lambda ^r \Lambda _e \mu _r}{C \Theta \Lambda }\middle|\!\!\!\begin{array}{c} (1,r),(1-\mu ,\frac{1}{\alpha }) \\ \left(\mu _e,\frac{1}{\alpha _e}\right) \\\end{array}\!\!\!\right].\IEEEyesnumber \label{O23} \end{IEEEeqnarray*} Substituting \eqref{O13} and \eqref{O23} into \eqref{soplb}, we obtain the asymptotic expression for SOP for the case $\gamma_1 \to \infty$ as shown in \eqref{sopa}. \subsection{Case \texorpdfstring{$\gamma_e \to \infty$}{}} Now, we focus on the case $\gamma_e \to \infty$. Obviously, as $\gamma_e$ tends to infinity, $\frac{\theta \Lambda}{\Lambda e}$ tends to infinity. Thus, using \cite[Eq. (1.5.9)]{kilbasHtransformsTheoryApplications2004} and a similar approach to that used in case $\gamma_1 \to \infty$, we can easily obtain closed-form expressions for $O_1$ and $O_2$ for case $\gamma_e \to \infty$, as \begin{IEEEeqnarray*}{rcl} O_1&=&-\frac{(1-\omega ) \alpha _e}{\Gamma (a) \Gamma (\mu ) \Gamma \left(\mu _e\right) \Gamma \left(\alpha _e \mu _e+1\right)}\Gamma\left(\mu +\frac{\alpha _e \mu _e}{\alpha }\right) \\ &&\times\left(\frac{\Lambda _e}{\Theta \Lambda }\right)^{\alpha _e \mu _e} H_{2,1}^{1,2}\!\!\left[\frac{b^r\mu _r}{C}\middle|\!\!\!\begin{array}{c} (1,1),(1-a,\frac{r}{c}) \\ \left(\alpha _e \mu _e,1\right) \\\end{array}\!\!\!\right] \label{Oe13} \end{IEEEeqnarray*} and \begin{IEEEeqnarray*}{rcl} O_2&=&-\frac{r \omega \alpha _e}{\Gamma (\mu ) \Gamma \left(\mu _e\right) \Gamma \left(\alpha _e \mu _e+1\right)}\Gamma \left(\mu +\frac{\alpha_e \mu _e}{\alpha }\right) \\ &&\times\left(\frac{\Lambda _e}{\Theta \Lambda }\right)^{\alpha _e \mu _e} H_{2,1}^{1,2}\!\!\left[\frac{\lambda ^r \mu _r}{C}\middle|\!\!\!\begin{array}{c} (0,1),(1,r) \\ \left(\alpha _e \mu _e,1\right) \\\end{array}\!\!\!\right] \label{Oe23} \end{IEEEeqnarray*} respectively. Substituting \eqref{Oe13} and \eqref{Oe23} into \eqref{soplb}, we obtain the asymptotic expression for SOP for the case $\gamma_e \to \infty$ as shown in \eqref{sopae}. \section{Proof of THEOREM 4} \setcounter{equation}{0} Substituting \eqref{amcdfform2} and \eqref{gammaeqpdf} into \eqref{pnz1}, after some simplifications, we can transform the PNZ expression in \eqref{pnz1} to \begin{IEEEeqnarray*}{rcl} \mathcal{P}_{n z}=T_1+T_2\IEEEyesnumber \end{IEEEeqnarray*} where \begin{IEEEeqnarray*}{rcl} &&T_1=\int _0^{\infty }\frac{\kappa (1-\omega ) \kappa _e}{\Gamma (a) \Lambda _e}H_{1,2}^{1,1}\!\!\left[\gamma \Lambda _e\middle|\!\!\!\begin{array}{c} (1,1) \\ \left(\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\\end{array}\!\!\!\right]\\ &&\times H_{1,0:1,1;0,2}^{0,1:0,1;2,0}\!\!\left[\!\!\!\!\begin{array}{c} \frac{1}{\gamma \Lambda } \\ \frac{b^{-r} C}{\mu _r} \\\end{array}\!\!\middle|\!\!\!\begin{array}{ccccc} (2,1,1)\!\!\!\!\!\! & : \!\!\!\!\!\!& \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \!\!\!\!\!& ; & \!\!\!\!\!\! \\ \!\!\!\!\!\! & :\!\!\!\!\!\! & (2,1)\!\!\!\!\! & ; &\!\!\!\!\! (0,1),\!(a,\frac{r}{c}) \\\end{array}\!\!\!\!\right]\!\!d\gamma\\ \IEEEyesnumber\label{t11} \end{IEEEeqnarray*} and \begin{IEEEeqnarray*}{rcl} &&T_2=\int _0^{\infty }\frac{r \kappa \omega \kappa _e}{\Lambda _e}H_{1,2}^{1,1}\!\!\left[\gamma \Lambda _e\middle|\!\!\!\begin{array}{c} (1,1) \\ \left(\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\\end{array}\!\!\!\right] \\ &&\times H_{1,0:1,1;0,2}^{0,1:0,1;2,0}\!\!\left[\!\!\!\!\begin{array}{c} \frac{1}{\gamma \Lambda } \\ \frac{C \lambda ^{-r}}{\mu _r} \\\end{array}\!\!\middle|\!\!\!\begin{array}{ccccc} (2,1,1)\!\!\!\!\!\! & :\!\!\!\!\!\! & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \!\!\!\!\!\!& ; &\!\!\!\!\! \\ \!\!\!\!\!\!& :\!\!\!\!\!\! & (2,1)\!\!\!\!\!\! & ; &\!\!\!\!\! (1,1),(0,r) \\\end{array}\!\!\!\!\right]\!\!d\gamma.\\ \IEEEyesnumber\label{t21} \end{IEEEeqnarray*} Representing the bivariate $H$-function into the form of one double line integral and moving the line integral regarding $\gamma$ to the innermost level, we can re-write \eqref{t11} as \begin{IEEEeqnarray*}{rcl} T_1&=&-\frac{\kappa (1-\omega ) \kappa _e}{4 \pi ^2 \Gamma (a) \Lambda _e}\int _{\mathcal{L}}^t\Gamma (-t) \Gamma \left(a-\frac{r t}{c}\right) \left(\frac{b^{-r}C}{\mu _r}\right)^{t}\\ &&\times\int _{\mathcal{L}}^s\frac{\Lambda ^{-s} }{\Gamma(s-1)}\Gamma (s+t-1) \Gamma \left(\frac{s}{\alpha }+\mu -\frac{1}{\alpha }\right)\\ &&\times\int _0^{\infty }\!\!\gamma ^{-s} H_{1,2}^{1,1}\!\!\left[\gamma \Lambda _e\middle|\!\!\!\begin{array}{c} (1,1) \\ \left(\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\\end{array}\!\!\!\right]\!d\gamma dsdt.\IEEEyesnumber \label{t12} \end{IEEEeqnarray*} Afterwards, using the same technique as that used for deducing \eqref{Q14} and \eqref{Q24}, we can express \eqref{t12} as \begin{IEEEeqnarray*}{rcl} &&T_1=\frac{\kappa (1-\omega ) \kappa _e }{\Gamma (a) \Lambda _e^2}\\ &&\times \!H_{1,0:0,2;1,2}^{0,1:2,0;1,1}\!\!\left[\!\!\!\!\begin{array}{c} \frac{b^{-r} C}{\mu _r} \\ \frac{\Lambda _e}{\Lambda } \\\end{array}\!\!\!\middle|\!\!\!\begin{array}{ccccc} (2,\!1,\!1) \!\!\!\!\!\!& : &\!\!\!\!\!\! &\!\!\!\!\!\! ;\!\!\!\!\!\! & \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right) \!\!\!\\ \!\!\!\!\!\!\!\!& : &\!\!\!\!\! (0,\!1),\!(a,\!\frac{r}{c}) &\!\!\!\!\! ;\!\!\!\!\!\! & \left(\frac{1+\alpha _e \mu _e}{\alpha _e},\frac{1}{\alpha _e}\right)\!,\!(1,\!1) \\\end{array}\!\!\!\!\right].\\ \IEEEyesnumber \end{IEEEeqnarray*} Similarly, $T_2$ in \eqref{t21} can be transformed into \begin{IEEEeqnarray*}{rcl} T_2&=&-\frac{\kappa r \omega \kappa _e}{4 \pi ^2 \Lambda _e}\int _{\mathcal{L}}^t\Gamma (1-t) \Gamma (-r t) \left(\frac{C \lambda ^{-r}}{\mu _r}\right)^t\\ &&\times\int _{\mathcal{L}}^s\frac{\Lambda ^{-s} }{\Gamma (s-1)}\Gamma (s+t-1) \Gamma \left(\frac{s}{\alpha }+\mu -\frac{1}{\alpha }\right)\\ &&\times\int _0^{\infty}\!\!\!\!\gamma ^{-s} H_{1,2}^{1,1}\!\!\left[\gamma \Lambda _e\middle|\!\!\!\begin{array}{c} (1,1) \\ \left(\mu _e,\frac{1}{\alpha _e}\right),(0,1) \\\end{array}\!\!\!\right]\!d\gamma dsdt\IEEEyesnumber \end{IEEEeqnarray*} which is then expressed as \begin{IEEEeqnarray*}{rcl} &&T_2=\frac{\kappa r \omega \kappa _e }{\Lambda _e^2}\\ &&\times H_{1,0:0,2;1,2}^{0,1:2,0;1,1}\!\!\left[\!\!\!\!\begin{array}{c} \frac{C \lambda ^{-r}}{\mu _r} \\ \frac{\Lambda _e}{\Lambda } \\\end{array}\!\!\!\!\middle|\!\!\!\begin{array}{ccccc} (2,\!1,\!1)\!\!\!\!\! & : &\!\!\!\! \!\!\!\!\!\!\!\! & ; \!\!\!\!\!& \left(1+\frac{1}{\alpha }-\mu ,\frac{1}{\alpha }\right)\!\!\! \\ \!\!\!\!\!\!\! & : &\!\!\!\!\! (1,\!1),\!(0,r) \!\!\!\!\!& ; \!\!\!\!\!& \left(\frac{1+\alpha _e \mu _e}{\alpha _e},\frac{1}{\alpha _e}\right)\!,\!(1,\!1) \\\end{array}\!\!\!\!\right]\\ \IEEEyesnumber \end{IEEEeqnarray*} using \cite[Eq. 2.25.2/1]{vermaIntegralsInvolvingMeijer1966}. \bibliographystyle{IEEEtran}
{'timestamp': '2020-09-22T02:21:08', 'yymm': '2009', 'arxiv_id': '2009.09550', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09550'}
arxiv
\subsubsection*{Acknowledgements} \end{document} \section{Brief description of the OpenABM model}\label{app:OpenABM} \input{supplement_files/model_description} \section{Mean-Field Inference of Risk}\label{app:MFdetails} \input{supplement_files/MF_description} \section{Belief Propagation Inference of Risk}\label{app:BPdetails} \input{supplement_files/BP_description} \section{Additional Results} \label{app:AdditionalResults} \input{supplement_files/Additional_Results} \subsection{Graphical model setting} Each pair $i,j$ of individuals will be in mutual contact in a finite set of instants $X_{ij}\subset\mathbb{R_{\infty}}=\mathbb{R}\cup\left\{ +\infty\right\} $. For reasons that will become clear in the following, we will always assume $\infty\in X_{ij}$. As time advances, instantaneous contagion will happen with probability $\lambda$ at time $s_{ij}\in X_{ij}$ if $i$ is infected and $j$ is susceptible. We will assume $\lambda=\lambda_{ij,}^{s_{ij},t_{i}}$ to possibly depend both on the specific (absolute) contact time $s_{ij}$, on the direction of the contact and on the time $t_{i}$ of infection of individual $i$. Individual $i$ can thus become infected in one instant in the set $X_{i}=\cup_{j\in\partial i}X_{ij}$. We will denote by $t_{i}\in X_{i},r_{i}\in\mathbb{R}$ respectively the times of infection and recovery of individual $i$, with $t_{i}=\infty$ (resp. $r_{i}=\infty$) if the individual did not become infected (resp. recovered) within the time-frame. We will assume the recovery delay $r_{i}-t_{i}$ of node $i$ to be distributed with a continuous distribution with pdf $p_{R,i}\left(r_{i}-t_{i}\right)$. We will assume a set of factorized, site-dependent observations $p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)$. Model parameters will be hidden for the moment inside functions $p_{R,i}$, $\lambda_{ij}^{s,t}$, and $p_{O,i}$ and we will include them only later to avoid cluttering the notation. The standard SIR model can be obtained by setting $p_{R,i}\left(r_{i}-t_{i}\right)=\mu e^{-\mu\left(r_{i}-t_{i}\right)}$, $\lambda_{ij}^{s,t}\equiv\lambda$. In this setup, the model is memory-less (Markov) on the state of infection variables $x_{i}^{t}\in\left\{ S,I,R\right\} $. In the following we will always assume that $t_{i}\in X_{i}$ and $s_{ij},s_{ji}\in X_{ij}$. Given the times of infection and recovery $t_{i}$ and $r_{i}$, the transmission delay $s_{ij}$ has ``truncated'' generalized geometric distribution \begin{eqnarray} S_{ij}\left(s_{ij}|t_{i},r_{i}\right) & =\mathbb{I}\left[t_{i}<s_{ij}<r_{i}\right] & \lambda_{ij}^{s_{ij},t_{i}}\prod_{t_{i}<s<s_{ij}}\left(1-\lambda_{ij}^{s,t_{i}}\right)+\mathbb{I}\left[s_{ij}=\infty\right]\prod_{s\geq r_{i}}\left(1-\lambda_{ij}^{s,t_{i}}\right) \end{eqnarray} because $i$ will be infectious in the open time interval $\left(t_{i},r_{i}\right)$ and will possibly (i.e. if $j$ is susceptible at the time) transmit the disease at some time $s_{ij}$ in that interval if he did not transmit it before. If time $r_{i}$ arrives and he did not transmit the disease, the individual will recover and never transmit the disease through that link; then transmission time on that link will be nominally $s_{ij}=\infty$. Special attention must be taken for auto-infections (otherwise, no infection can enter into the closed system). By adding a contact with an additional extra always-infected virtual neighbor $i^{t*}$ to node $i$ at time instant $t\in X_{i}$ with probability $p_{t}\left(s_{i^{t*}i}=t\right)=\gamma_{i}^{t}$ (typically small), $p_{t}\left(s_{i^{t*}i}=\infty\right)=1-\gamma_{i}^{t}$, $i$ will spontaneously self-infect at time $t$ with probability $\gamma_{i}^{t}$ (if it is susceptible at that time\footnote{A particularly interesting case is with $\gamma_{i}^{0}=\gamma\to0$ and $\gamma_{i}^{t}=0$ for $t>0$: in this case individuals can be self-infected only at time $0$, representing a closed system with a single unknown seed at time $t=0$.}). Let us define~$A_{i}\left(\boldsymbol{s}_{i^{*}}\right)=A_{i}\left(\left\{ s_{i^{t*}i}\right\} _{t\in X_{i}}\right)=\prod_{t\in X_{i}\setminus\left\{ \infty\right\} }p_{t}\left(s_{i^{t*}i}\right)$. For convenience, let us define $\partial^{*}i$ the enlarged neighborhood of $i$ including all extra nodes $\left\{ i^{t*}\right\} _{t\in X_{i}}.$ Given $\left\{ s_{ki}\right\} $ for $k\in\partial^{*}i$, the infection time $t_{i}$ satisfies, in a deterministic way: \begin{eqnarray} t_{i} & = & \min_{k\in\partial^{*}i}s_{ki}, \end{eqnarray} We can now write the joint pdf of discrete variables $\boldsymbol{t},\boldsymbol{s}$ and continuous variables~$\boldsymbol{r}$ as \begin{eqnarray} p\left(\boldsymbol{t},\boldsymbol{r},\boldsymbol{s}\right) & \propto & \prod_{i}\delta\big(t_{i},\min_{k\in\partial^{*}i}s_{ki}\big)A_{i}\left(\boldsymbol{s}_{i^{*}}\right)R_{i}\left(r_{i}-t_{i}\right)\prod_{\left(ij\right)}S_{ij}\left(s_{ij}|t_{i},r_{i}\right) \end{eqnarray} so then as $p\left(\boldsymbol{t},\boldsymbol{r},\boldsymbol{s}|\mathcal{O}\right)\propto p\left(\mathcal{O}|\boldsymbol{t},\boldsymbol{r}\right)p\left(\boldsymbol{t},\boldsymbol{r},\boldsymbol{s}\right)$, we get \begin{eqnarray} p\left(\boldsymbol{t},\boldsymbol{r},\boldsymbol{s}|\mathcal{O}\right) & \propto & \prod_{i}\delta\big(t_{i},\min_{k\in\partial^{*}i}s_{ki}\big)A_{i}\left(\boldsymbol{s}_{i^{*}}\right)R_{i}\left(r_{i}-t_{i}\right)p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)\prod_{\left(ij\right)}S_{ij}\left(s_{ij}|t_{i},r_{i}\right)\label{eq:boltzman} \end{eqnarray} A note about $r_{i}$s: all terms in \eqref{eq:boltzman} except $R_{i}$ are constant as functions of $r_{i}$ in any interval $\left(\hat{r}_{i},\hat{r}_{i}'\right)$ of consecutive times in $X_{i}$. We will exploit this fact and write $r_{i}=\hat{r}_{i}+u_{i}$, where $\hat{r}_{i}=\max\left\{ r\in X_{i}:r<r_{i}\right\} $. Integrating away the $u_{i}$ variables in \eqref{eq:boltzman}, we obtain an all-discrete model for variables $\boldsymbol{t},\boldsymbol{s},\boldsymbol{\hat{r}},$ with an identical expression to \eqref{eq:boltzman} but in which $r_{i}$ has been replaced by $\hat{r}_{i}$ and $R_{i}\left(r_{i}-t_{i}\right)$ by $\hat{R}_{i}\left(\hat{r}_{i}-t_{i}\right)=\int_{\hat{r}_{i}-t_{i}}^{\hat{r}_{i}'-t_{i}}p_{R,i}\left(u\right)du.$ For simplicity of notation, we will drop the $\hat{}$ symbols in the following. \subsection{Belief propagation equations} A naive interpretation of \eqref{eq:boltzman} as a graphical model would introduces many unneeded short cycles that were not present in the original contact network. For example, pairs $\left(t_{i},s_{ji}\right),\left(t_{i},s_{ij}\right),\left(t_{j},s_{ij}\right),\left(t_{j},s_{ji}\right)$ share respectively factors with indices $i,\left(ij\right),j,\left(ji\right)$ , effectively forming a small cycle. A simple solution consists in regrouping factors as in \eqref{eq:fg} and considering $\left(s_{ij},s_{ji}\right)$ as a single variable: \begin{eqnarray} \Psi_{i}\left(t_{i},r_{i},\left\{ s_{ki},s_{ik}\right\} _{k\in\partial i}\right) & = & \delta\big(t_{i},\min_{k\in\partial^{*}i}s_{ki}\big)A_{i}\left(\boldsymbol{s}_{i^{*}}\right)R_{i}\left(r_{i}-t_{i}\right)\prod_{j\in\partial i}S_{ij}\left(s_{ij}|t_{i},r_{i}\right)\label{eq:fg} \end{eqnarray} which results in a factor graph for \eqref{eq:boltzman} in which variables $\left(s_{ij},s_{ji}\right)$ have degree two and live in the middle of the original edges, and vars $t_{i},r_{i}$ have degree $1$, i.e. a topology that closely follows the one of the original contact network: \begin{eqnarray} p\left(\boldsymbol{t},\boldsymbol{r},\boldsymbol{s}|\mathcal{O}\right) & = & \frac{1}{Z}\prod_{i}\Psi_{i}\label{eq:gmodel} \end{eqnarray} The corresponding BP equations for $\Psi_{i}$ are \begin{eqnarray} m_{ij}\left(s_{ij},s_{ji}\right) & \propto & \sum_{t_{i}}\sum_{r_{i}}p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)A_{i}\left(\boldsymbol{s}_{i^{*}}\right)R_{i}\left(r_{i}-t_{i}\right)S_{ij}\left(s_{ij}|t_{i},r_{i}\right)\times\label{eq:mij}\\ & & \times\sum_{\left\{ s_{ki}\right\} }\delta\big(t_{i},\min_{k\in\partial^{*}i}s_{ki}\big)\prod_{k\in\partial^{*}i\setminus j}S_{ik}\left(s_{ik}|t_{i},r_{i}\right)m_{ki}\left(s_{ki},s_{ik}\right)\nonumber \end{eqnarray} and marginals for $t_{i}$ are \begin{eqnarray} b_{i}\left(t_{i}\right) & \propto & \sum_{r_{i}}p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)A_{i}\left(\boldsymbol{s}_{i^{*}}\right)R_{i}\left(r_{i}-t_{i}\right)S_{ij}\left(s_{ij}|t_{i},r_{i}\right)\times\label{eq:marginal}\\ & & \times\sum_{\left\{ s_{ki}\right\} }\delta\big(t_{i},\min_{k\in\partial^{*}i}s_{ki}\big)\prod_{k\in\partial^{*}i}S_{ik}\left(s_{ik}|t_{i},r_{i}\right)m_{ki}\left(s_{ki},s_{ik}\right) \end{eqnarray} and similarly for $r_{i}.$ A more efficient computation of the equations can be achieved by defining: \begin{align*} G_{k}^{0}\left(t_{i},r_{i}\right) & =\sum_{\substack{s_{ki}\geq t_{i}\\ s_{ik}>t_{i} } }S_{ik}\left(s_{ik}|t_{i},r_{i}\right)m_{ki}\left(s_{ki},s_{ik}\right)\\ G_{k}^{1}\left(t_{i},r_{i}\right) & =\sum_{\substack{s_{ki}>t_{i}\\ s_{ik}>t_{i} } }S_{ik}\left(s_{ik}|t_{i},r_{i}\right)m_{ki}\left(s_{ki},s_{ik}\right) \end{align*} and substituting the extra neighbor message \[ m_{i^{*t}i}\left(s_{i^{*t}i},s_{ii^{*t}}\right)=\begin{cases} \gamma_{i}^{t} & s_{i^{*t}i}=t,s_{ii^{*t}}=\infty\\ 1-\gamma_{i}^{t} & s_{i^{*t}i}=\infty,s_{ii^{*t}}=\infty \end{cases} \] Equations \eqref{eq:mij}, \eqref{eq:marginal} can be then rewritten as \begin{align} m_{ij}\left(s_{ij},s_{ji}\right)\propto & \sum_{t_{i}}\sum_{r_{i}}p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)A_{i}\left(\boldsymbol{s}_{i^{*}}\right)R_{i}\left(r_{i}-t_{i}\right)S_{ij}\left(s_{ij}|t_{i},r_{i}\right)\times\label{eq:bpeff}\\ & \times\sum_{\left\{ s_{ki}\right\} }\left(\prod_{j\in\partial^{*}i}\mathbb{I}\left[s_{ki}\geq t_{i}\right]-\prod_{j\in\partial^{*}i}\mathbb{I}\left[s_{ki}>t_{i}\right]\right)\prod_{k\in\partial^{*}i\setminus j}S_{ik}\left(s_{ik}|t_{i},r_{i}\right)m_{ki}\left(s_{ki},s_{ik}\right)\nonumber \\ \propto & \sum_{t_{i}<s_{ji}}\sum_{r_{i}\geq t_{i}}p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)R_{i}\left(r_{i}-t_{i}\right)S_{ij}\left(s_{ij}|t_{i},r_{i}\right)\times\\ &\times\bigg\{\prod_{k\in\partial i\setminus j}G_{k}^{0}\left(t_{i},r_{i}\right)-\left(1-\gamma_{i}^{t_{i}}\right)\prod_{k\in\partial i\setminus j}G_{k}^{1}\left(t_{i},r_{i}\right)\bigg\}\nonumber + \\ & +\sum_{r_{i}\geq s_{ji}}p_{O,i}\left(\mathcal{O}_{i}|s_{ji},r_{i}\right)R_{i}\left(r_{i}-s_{ji}\right)\prod_{k\in\partial i\setminus j}G_{k}^{0}\left(s_{ji},r_{i}\right)\nonumber \\ b_{i}\left(t_{i}\right)\propto & \sum_{r_{i}}p_{R,i}\left(r_{i}-t_{i}\right)p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)\times\\ & \bigg\{\prod_{k\in\partial i}G_{k}^{0}\left(t_{i},r_{i}\right)-\left(1-\gamma_{i}^{t_{i}}\right)\prod_{k\in\partial i}G_{k}^{1}\left(t_{i},r_{i}\right)\bigg\}\nonumber \\ b_{i}\left(r_{i}\right)\propto & \sum_{t_{i}}p_{R,i}\left(r_{i}-t_{i}\right)p_{O,i}\left(\mathcal{O}_{i}|t_{i},r_{i}\right)\times\\ & \bigg\{\prod_{k\in\partial i}G_{k}^{0}\left(t_{i},r_{i}\right)-\left(1-\gamma_{i}^{t_{i}}\right)\prod_{k\in\partial i}G_{k}^{1}\left(t_{i},r_{i}\right)\bigg\}\nonumber \end{align} Note that products $\prod_{k\in\partial i\setminus j}G_{k}$ can be computed simultaneously for $j\in\partial i$ in time $O\left(\left|\partial i\right|\right)$ (either by computing it as the fraction $G_{j}^{-1}\prod_{k\in\partial i}G_{k}$, or by first recursively computing $\prod_{\ell=1}^{\ell'}G_{k_{\ell}}$ and $\prod_{\ell=\ell'}^{\left|\partial i\right|}G_{k_{\ell}}$ for $\ell'=1,\dots,\left|\partial i\right|$ and then $\prod_{\ell\neq\ell'}G_{k_{\ell}}=\prod_{\ell=1}^{\ell'-1}G_{k_{\ell}}$$\prod_{\ell=\ell'+1}^{\left|\partial i\right|}G_{k_{\ell}}$, a method that does not involve divisions and is thus numerically more stable). The resulting implementation of the update of all messages in factor $\Psi_{i}$ has complexity $O\left(\left|X_{i}\right|\sum_{j\in\partial i}\left(\left|X_{i}\right|+\left|X_{ij}\right|^{2}\right)\right)$ . \subsection{Finite-window approximation} In the BP-based epidemic tracing scheme, exchanged messages between two individuals grow quadratically with the number of temporal contacts occurred between them. However, only recent contacts are important to determine marginal probabilities at present time, therefore keeping only a short time window (about two or three weeks) is sufficient to obtain quasi-optimal results. For better accuracy, information about contacts and observations at the dropped times is included approximately as simple factorized priors applied at the start of the window. This prior contains the posterior probability at the first non-dropped time computed only using contacts and observations at the dropped time (and the prior computed in the previous step). All simulations have been performed using a $21$ days time window. \subsection{Algorithm Parameters}\label{subsec:BPparams} For the OpenABM model, we chose to use Gamma distributions for the recovery density $p_{R.i}=p_R$ and a rescaled Gamma for the infection transmissivity $\lambda_{ij}^{s_{ij},t_i}=p_I(s_{ij}-t_i)$. The five parameters were fitted from experimental data produced by the model (parameters could in principle be also learned or adjusted online during the process through an approximate maximum likelihood procedure \cite{altarelli_patient-zero_2014}, but we leave this for future work). Note that the model used for inference with BP is still much simplified with respect to OpenABM itself, in particular having only three states (against 11 in OpenABM). As a consequence, results are only weakly sensitive to the parameters. The used values were Gamma($k$ = 10, $\mu = 0.57$) for $p_R$ and Gamma($k$=5.76, $\mu=0.96$), with a scale of 0.25 (multiplied by 2 for intra-household contacts as with MF inference) for $\lambda$. The self-infection probability was chosen to be $p_{seed}=1/N$ at time $t=0$ ($k/N$ where $k$ is the number of patient zeros would bring slightly better results, but would use inaccessible information) and 0 for $t>0$ except for the case with partial adoption, in which we allowed a small probability of self-infections at times $t>0$ to avoid plain incompatibility between the inference model and observations due to undetected transmissions). The parameter $\delta_{rank}$ for the computation of the ranking was chosen to be 10 days. \label{app:BPparameters}
{'timestamp': '2020-09-22T02:16:11', 'yymm': '2009', 'arxiv_id': '2009.09422', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09422'}
arxiv
\section{Introduction}\label{sec:intro} Regression models for spatially referenced data use spatial random effects to capture residual spatial correlation that cannot be explained by the covariates in the model. While such models are an effective tool for predictions of the response variable, as first noted by \citet{clayton1993}, they can be problematic when estimation of individual covariate effects are of interest. So-called spatial confounding arises because spatial effects may have elements of collinearity with spatially dependent covariates and therefore interfere with their effect estimates. \citet{reich2006} analysed the issue using an example modelling the effect of socio-economic status on stomach cancer incidence in the municipalities of Slovenia. When spatial effects are added to the model, the covariate effect disappears, suggesting the spatial effects have taken over a disproportionate part of the explanatory power. While in this example, the spatial effects take the form of an Intrinsic Conditional Auto-Regressive (ICAR) random effect, spatial confounding is widely acknowledged as an issue that affects spatial models in general \citep[see e.g.][]{hodges2010,paciorek}. In this paper we model data from the Terrestrial Crown Condition Inventory (TCCI) forest health monitoring survey which has been carried out yearly since 1983 by the Forest Research Institute Baden-W\"urttemberg. Crown defoliation (an indicator of poor tree health) has generally been worsening over time, and there is growing interest in understanding the effects of climate change in order to decide on forest management strategies for mitigation. Here, using a linear regression model, we consider the effect of temperature on crown defoliation. However, our results are highly dependent on whether or not we include spatial random effects in the model. As illustrated in Figure \ref{fig:intro}, in the null model (with no spatial effects), the estimated covariate effect is positive but not significant, whereas in the corresponding spatial model, the covariate effect is significant and the effect size more than triples. This behaviour suggests there is spatial confounding and makes reliable inference difficult. \begin{figure} \centerline{ \includegraphics[width=0.32\textwidth]{term_plot_null.pdf} \includegraphics[width=0.32\textwidth]{term_plot.pdf} \includegraphics[width=0.32\textwidth]{spatial_smooth.pdf} } \caption{Forestry example. Estimated effect of minimum temperature in May on crown defoliation in the null model (left) and the spatial model (middle), where for each model the plot shows the contribution of the centered covariate to the predicted response (with two times standard error bands). Estimated spatial effect in the spatial model (right) with the border of Baden-W\"urttemberg outlined and dots showing the data locations.} \label{fig:intro} \end{figure} A commonly used method for dealing with spatial confounding is restricted spatial regression (RSR), introduced by \citet{reich2006} for the ICAR model, and further developed by \citet{hoeting} for continuous space models. In RSR the spatial random effects are restricted to the orthogonal complement of the covariates while keeping the overall column space of the model matrix in the regression unchanged. RSR directly eliminates collinearity and is designed to preserve the covariate effect estimates of the null model. However, it is a general misconception that the estimates in the null model (and thus, RSR) are unbiased. In fact, each covariate effect estimate includes, not only the effect of the covariate, but also any unmeasured spatial effects with the same spatial pattern \citep[see e.g.][]{hoeting}. Therefore, unless the unmeasured effects are independent of the covariates (a rather strong assumption), RSR introduces bias by construction. Other methods for avoiding spatial confounding bias are limited, and with theoretical derivations often intractable, methodology tends to rely on simulations alone. Recently, \citet{thaden2018} proposed the geoadditive structural equations model (gSEM) based on the structural equations framework commonly used for causal inference problems. In this approach, spatial dependence is regressed away from both the response and the covariates, and a regression involving the residuals only is used to identify the original covariate effects. In a simulation study, Thaden and Kneib show that the gSEM approach appears to give unbiased estimates while the original spatial model gives biased results in some scenarios. However, it is not immediately clear why the method works, and in examples such as ours, where the variables of interest are naturally spatially dependent, it seems undesirable to eliminate all spatial information from the modelling. Here, we propose a novel approach, the spatial+ model, and using asymptotic analysis as well as a simulation study, we show that the estimates in this model avoid the bias problems of the spatial model. Spatial+ is a simple modification of the spatial model where the covariates are replaced by their residuals after spatial dependence has been regressed away. Thus, spatial+ retains the column space of the model matrix but reduces collinearity between covariate and spatial effects. A practical advantage over gSEM is that, as the response variable is unchanged from the spatial model, standard model selection criteria can be used for comparisons with the spatial and null models. Moreover, while the main properties of spatial+ are studied for models with a Gaussian response variable, we show that the method generalises naturally to any response distribution from the exponential family of distributions. Key to our analysis is that we formulate the spatial model as a partial thin plate spline model where spatial correlation is modelled by imposing a smoothing penalty on the spatial effects in the fitting process. We can then recognise spatial confounding as a smoothing-induced bias identified by \citet{rice1986} for partial spline models (i.e.\ models where the domain of the spline, here the spatial domain, is one-dimensional). Spatial+ is a higher-dimensional version of a model introduced by \citet{chen_shiau1991} to overcome this type of bias in the one-dimensional case. Intuitively, as smoothing is only applied to the spatial part of the model, by making covariate effect estimates broadly independent of the spatial effects, they avoid this bias. For one-dimensional models, Rice, Chen and Shiau derived results for the asymptotic behaviour of estimates as the number of fitted data points $n\rightarrow\infty$. Due to results by \citet{utreras1988}, we are able to extend these derivations to models of arbitrary spatial dimension. We confirm that, as is the case in dimension one, the bias in the covariate effect estimates in the spatial model can become disproportionately large, while in the spatial+ model, the bias converges to $0$ strictly faster than the standard deviation. Using the thin plate spline model formulation, we also see that, in the one-dimensional case, the gSEM estimates are in fact the same as the partial residual estimates introduced by Denby (1986) and independently by \citet{speckman1988}. Like the spatial+ estimates, the partial residual estimates (in dimension one) are shown by \citet{chen_shiau1991} to avoid the disproportionate smoothing-induced bias identified by \citet{rice1986}, and we can once again use \citet{utreras1988} to generalise this result to arbitrary spatial dimensions. For completeness, these derivations are included in Appendix D. Finally, we note that, although our results are derived in the thin plate spline context, the methodology of spatial+, namely, the modification of the model matrix, can be directly applied to other commonly used spatial models, including, for example, Gaussian Markov random field (GMRF) models and the (discrete space) ICAR model. In fact, it can be shown that modelling spatial random effects through the use of a smoothing penalty is equivalent to a Bayesian model formulation in which the spatial correlation structure is determined by a prior distribution. This equivalence is explained, for example, in \citet{kimeldorf1970}, Section 6.1 of \citet{silverman1985}, pages 239-240 of \citet{wood2017} and \citet{fahrmeir2004}. Thus, while different spatial models correspond to different smoothing penalties, the underlying idea of reducing collinearity in this way to keep covariate effect estimates unaffected by spatial smoothing would apply in general. This paper is structured as follows. In Section \ref{sec:method}, we introduce the spatial and spatial+ models that form the basis of our analysis. Section \ref{sec:asym} summarises the main theoretical results which show that the covariate effect estimates in the spatial model can become disproportionately biased due to spatial smoothing, while in the spatial+ model, bias is negligible. In Section \ref{sec:sim}, we illustrate these results in a simulation study which also compares spatial+ with RSR and the gSEM. In Section \ref{sec:app}, we demonstrate how spatial+ can be implemented by applying it to our forestry example. Finally, in Section \ref{sec:glm}, we generalise the spatial+ methodology to non-Gaussian response distributions and confirm that the method works in simulations for three different distributions. \section{Method}\label{sec:method} \subsection{Spatial model}\label{sec:ps} Our starting point is a spatial model formulated as a partial thin plate spline model \citep[see e.g.][]{wahba1990} of the form \begin{equation}\label{eqn:spatial} y_i=\beta x_i+f(\ensuremath{\mathbf{t}}_i)+\epsilon_i, \quad \epsilon_i\underset{\textrm{iid}}\sim N(0,\sigma^2) \end{equation} where $\yb=(y_1,\ldots,y_n)^T$ is the response, $\xb=(x_1,\ldots,x_n)^T$ an observed covariate with unknown effect $\beta$ and $f\in H^m(\Omega)$ an unknown bounded function defined on an open bounded domain $\Omega\subset\RR^d$ which includes the known values $\ensuremath{\mathbf{t}}_1,\ldots,\ensuremath{\mathbf{t}}_n$. In the spatial context, $\ensuremath{\mathbf{t}}_1,\ldots,\ensuremath{\mathbf{t}}_n$ are the spatial locations of the observations. The estimates $\ensuremath{\hat{\beta}}$ and $\hat{f}$ in this model (known as the partial thin plate spline estimates of order $m > d/2$) are obtained as the minimisers of \[ \frac{1}{n}\sum_{i=1}^n (y_i-\beta x_i-f(\ensuremath{\mathbf{t}}_i))^2+\lambda \sum_{i_1,\ldots,i_m}\int_{\RR^d} \big\vert \frac{\partial^m f(\ensuremath{\mathbf{t}})}{\partial t_{i_1}\cdots \partial t_{i_m}}\big\vert^2 d\ensuremath{\mathbf{t}} \] where $\lambda>0$ is an unknown smoothing parameter. Minimisation here is over all $\beta\in \RR$ and functions $f\in H^m(\RR^d)$ with $\frac{\partial^m f}{\partial t_{i_1}\cdots \partial t_{i_m}}\in L^2(\RR^d)$ for all subsets $i_1,\ldots,i_m$ of $1,\ldots,n$. The first term encourages fitted values that are close to the data while the second term induces smoothing by penalising the wiggliness of the function $f$. \citet{duchon1977} showed that the estimate of $f$ can be obtained by estimating its coefficients in a basis known as the natural thin plate spline basis. This basis spans a finite-dimensional subspace in the space of functions defined on $\RR^d$ and has dimension $N=M+n$ where $M={{m+d-1}\choose{d}}$. Using this basis, the partial thin plate spline estimates $\ensuremath{\hat{\beta}}$ and $\ensuremath{\mathbf{\hat{f}}}=(\hat{f}(\ensuremath{\mathbf{t}}_1),\ldots,\hat{f}(\ensuremath{\mathbf{t}}_n))^T$ are the minimisers of \begin{equation}\label{eqn:ps_min} \Vert\yb-\beta\xb-\ensuremath{\mathbf{f}}\Vert^2+n\lambda\ensuremath{\mathbf{f}}^T\boldsymbol{\boldsymbol{\Gamma}}\ensuremath{\mathbf{f}} \end{equation} with $\boldsymbol{\Gamma}$ an $n\times n$ penalty matrix. Solving the resulting normal equations, we see that \begin{equation}\label{eqn:ps_estimates} \ensuremath{\hat{\beta}}=\left(\xb^T(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda}})\xb\right)^{-1}\xb^T(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda}})\yb,\quad \ensuremath{\mathbf{\hat{f}}}=\ensuremath{\mathbf{S}_{\lambda}}(\yb-\ensuremath{\hat{\beta}}\xb) \end{equation} where $\ensuremath{\mathbf{S}_{\lambda}}=(\ensuremath{\mathbf{I}}+n\lambda\boldsymbol{\Gamma})^{-1}$ is known as the smoother matrix. $\ensuremath{\mathbf{S}_{\lambda}}$ is the influence matrix for the model (\ref{eqn:spatial}) with no covariate term, and $\ensuremath{\mathbf{S}_{\lambda}}\yb$ is the thin plate spline fitted to the data $\yb$. \subsection{Spatial+ model}\label{sec:ts} Starting with the model (\ref{eqn:spatial}), in line with \citet{rice1986}, we assume the covariate $\xb$ has the form \begin{equation}\label{eqn:co_model} x_i=f^x(\ensuremath{\mathbf{t}}_i)+\epsilon^x_i,\quad \epsilon^x_i\underset{\textrm{iid}}\sim N(0,\sigma_x^2) \end{equation} where $f^x\in H^m(\Omega)$ is bounded. This means that $\xb$ is correlated with the smooth term $f$ through the component $f^x$. Extending the two-stage smoothing spline model defined in \citet{chen_shiau1991} to models of dimension $d\ge 1$, we define the spatial+ model as follows. Let $\ensuremath{\mathbf{\hat{f}}}^x=\ensuremath{\mathbf{S}_{\lambda_x}}\xb$ and $\ensuremath{\mathbf{r}}^x=(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda_x}})\xb$ be the fitted values and residuals in the thin plate spline regression (\ref{eqn:co_model}) with smoothing parameter $\lambda_x>0$. The spatial+ model is then the partial thin plate spline model \begin{equation}\label{eqn:spatial+} y_i=\beta r^x_i+f^+(\ensuremath{\mathbf{t}}_i)+\epsilon_i, \quad \epsilon_i\underset{\textrm{iid}}\sim N(0,\sigma^2) \end{equation} where $\beta$ is the unknown effect of $\ensuremath{\mathbf{r}}^x=(r^x_1,\ldots,r^x_n)^T$ and $f^+$ models the combined effect $f+\beta f^x$ in the original model (\ref{eqn:spatial}). The spatial+ estimate $\ensuremath{\hat{\beta}^+}$ of $\beta$ is its partial thin plate spline estimate in this model, i.e.\ \begin{align*} &\ensuremath{\hat{\beta}^+}=\big((\ensuremath{\mathbf{r}}^x)^T(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda}})\ensuremath{\mathbf{r}}^x\big)^{-1}(\ensuremath{\mathbf{r}}^x)^T(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda}})\yb&\\ &=\big(\xb^T(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda_x}})(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda}})(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda_x}})\xb\big)^{-1}\!\xb^T(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda_x}})(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda}})\yb,&\nonumber \end{align*} and the spatial+ estimate $\ensuremath{\mathbf{\hat{f}}^+}$ of $\ensuremath{\mathbf{f}}=(f(\ensuremath{\mathbf{t}}_1),\ldots,f(\ensuremath{\mathbf{t}}_n))^T$ is given by \[ \ensuremath{\mathbf{\hat{f}}^+}=\widehat{\ensuremath{\mathbf{f}}^+}-\ensuremath{\hat{\beta}^+} \ensuremath{\mathbf{\hat{f}}}^x=\ensuremath{\mathbf{S}_{\lambda}}(\yb-\ensuremath{\hat{\beta}^+}\xb)-(\ensuremath{\mathbf{I}}-\ensuremath{\mathbf{S}_{\lambda}})\ensuremath{\mathbf{S}_{\lambda_x}}\ensuremath{\hat{\beta}^+}\xb \] where $\widehat{\ensuremath{\mathbf{f}}^+}$ denotes the partial thin plate spline estimate of $\ensuremath{\mathbf{f}}^+=(f^+(\ensuremath{\mathbf{t}}_1),\ldots,f^+(\ensuremath{\mathbf{t}}_n))^T$ in (\ref{eqn:spatial+}). \subsection{Smoothness selection} Smoothing penalties introduce bias in estimates but reduce variance. The smoothing parameters $\lambda$ and $\lambda_x$ are usually estimated based on a separate smoothness selection criterion, that balances this bias-variance trade-off. For the analysis in Section \ref{sec:asym}, in line with \citet{rice1986, chen_shiau1991}, we choose the value of the smoothing parameter that minimises the average mean squared error (AMSE) of the estimated spatial effect. The AMSE for an estimated effect $\ensuremath{\hat{\mathbf{f}}}=(\hat{f}_1,\ldots,\hat{f}_n)^T$ of the function $f$ evaluated at data points is defined as \[ \ensuremath{\mathrm{AMSE}}(\ensuremath{\hat{\mathbf{f}}})=\frac{1}{n}\sum_{i=1}^n \ensuremath{\mathrm{E}}\left[(\hat{f}_i-f(\ensuremath{\mathbf{t}}_i))^2\right] =B^2(f,\lambda)+V(f,\lambda) \] where $B^2(f,\lambda)=\frac{1}{n}\sum_{i=1}^n \big(\ensuremath{\mathrm{E}}(\hat{f}_i)-f(\ensuremath{\mathbf{t}}_i)\big)^2$ and $V(f,\lambda)=\frac{1}{n}\sum_{i=1}^n\ensuremath{\mathrm{Var}}(\hat{f}_i)$ are the average squared bias and the average variance, respectively. For the simulations in Section \ref{sec:sim} and the example in Section \ref{sec:app} we use the generalized cross validation (GCV) criterion, which is the default option in the \texttt{R}-package \texttt{mgcv} used for implementation. Asymptotically (as the sample size $n\rightarrow\infty$), GCV selects the optimal smoothing parameter for minimising prediction error. Thus, GCV is not dissimilar to the criterion used for the theoretical derivations. Indeed, \citet{chen_shiau1994} show that their asymptotic results in \citet{chen_shiau1991} for one-dimensional models also hold for GCV and Mallows' $C_L$. In practice, the restricted maximum likelihood (REML) criterion is often used instead of GCV as, for finite samples, GCV usually has more uncertain estimates than REML and tends to undersmooth (i.e.\ overfit) the data (\citet{wood2017} p. 266-267). Repeating the simulations and the data example using REML gave similar results to GCV. \section{Asymptotic results}\label{sec:asym} In Sections \ref{sec:asym_ps} and \ref{sec:asym_ts} we derive asymptotic results for the models defined in Sections \ref{sec:ps} and \ref{sec:ts} with proofs provided in Appendix C. These results are based on a number of technical lemmas and assumptions, details of which are provided in Appendices A and B. For dimension $d=1$, \citet{rice1986}, \citet{chen_shiau1991} use the Demmler-Reinsch basis for natural splines to diagonalise the smoother matrix $\ensuremath{\mathbf{S}_{\lambda}}$. This enables them to explicitly study the asymptotic behaviour of model estimates. Our generalisation to dimensions $d\ge 1$ is fascilitated by \citet{utreras1988} who shows how the asymptotic properties of the Demmler-Reinsch basis generalise to higher dimensions (see Lemma 1 in Appendix A). Using this, we are able to prove results in a similar way to Rice, Chen and Shiau. Where possible, we have simplified the derivations and notation, particularly, we have adapted the structure of Rice's proofs to be more in line with the approach used by \citet{chen_shiau1991}. For the rest of this paper, we assume that $m> d/2$ and that the domain $\Omega$ and data locations $\ensuremath{\mathbf{t}}_1,\ldots,\ensuremath{\mathbf{t}}_n$ satisfy the conditions of Lemma 1 in Appendix A. We use the notation $a(n)\approx b(n)$ to mean that $a(n)/b(n)$ is bounded away from zero and infinity as $n\rightarrow \infty$. \subsection{Asymptotic results for the spatial model}\label{sec:asym_ps} In the model (\ref{eqn:spatial}), spatial correlation is modelled through smoothing of the term $f$. Without the smoothing penalty, the model is an ordinary linear model in which all effect estimates are unbiased. Therefore, bias in the covariate effect estimate arises as a direct result of smoothing. \citet{rice1986} showed for dimension $d=1$ that, while this bias is asymptotically $0$ as $n\rightarrow\infty$, the rate of convergence may be slow. More specifically, we cannot ensure that the bias converges faster than the standard deviation if the smoothing parameter $\lambda$ converges at the optimal rate (minimising the AMSE of the estimated spatial effect). Therefore, the bias can in practice become disproportionately large. Here, we generalise Rice's results and see that the problem of potentially excessive bias in $\ensuremath{\hat{\beta}}$ persists in models where the spatial domain has dimension $d\ge 1$. As an aside, we note that, as in the $d=1$ case, the rate of convergence of the variance of $\ensuremath{\hat{\beta}}$, is the same as that in a model with no smoothing penalty. \begin{theorem}\label{thm:ps_est} Suppose $\lambda\approx n^{-\delta}$ for some $0<\delta<1$, $f, f^x\in H^m(\Omega)$ are bounded and $m\ge d$. Then for the partial thin plate spline estimate of $\beta$ we have that \begin{description} \item[(a)] $\ensuremath{\mathrm{E}}(\ensuremath{\hat{\beta}})-\beta=\ensuremath{o}(n^{-1/2})+\ensuremath{\mathcal{O}}(\lambda^{1/2})$, \item[(b)] $n\ensuremath{\mathrm{Var}}(\ensuremath{\hat{\beta}})\rightarrow \sigma^2/\sigma_x^2$ as $n\rightarrow\infty$. \end{description} In particular, $\ensuremath{\mathrm{Var}}(\ensuremath{\hat{\beta}})=\ensuremath{\mathcal{O}}(n^{-1})$ and we need $\lambda=\ensuremath{o}(n^{-1})$ to ensure that the bias converges faster than the standard deviation of $\ensuremath{\hat{\beta}}$. \end{theorem} \begin{theorem}\label{thm:ps_lambda} Suppose $\lambda\approx n^{-\delta}$ for some $0<\delta<1$, $f, f^x\in H^m(\Omega)$ are bounded and $m\ge d$. Then the average squared bias $\ensuremath{B^2}(f,\lambda)$ and average variance $\ensuremath{V}(f,\lambda)$ of the partial thin plate spline estimate of $f$ satisfy \begin{description} \item[(a)] $\ensuremath{B^2}(f,\lambda)=n^{-1}\sum_i (\ensuremath{\mathrm{E}}(\ensuremath{\hat{f}_i})-f(\ensuremath{\mathbf{t}}_i))^2=\ensuremath{\mathcal{O}}(\lambda)$, \item[(b)] $\ensuremath{V}(f,\lambda)=n^{-1}\sum_i\ensuremath{\mathrm{Var}} (\ensuremath{\hat{f}_i})=\ensuremath{\mathcal{O}}(n^{-1}\lambda^{-d/2m})$. \end{description} In particular, the optimal rate for $\lambda$ in terms of minimising $\ensuremath{\mathrm{AMSE}}(\ensuremath{\mathbf{\hat{f}}})$ is $\lambda=\ensuremath{\mathcal{O}}(n^{-2m/(2m+d)})$, and when $\lambda$ converges at this optimal rate, $\ensuremath{\mathrm{AMSE}}(\ensuremath{\mathbf{\hat{f}}})=\ensuremath{\mathcal{O}}(n^{-2m/(2m+d)})$. \end{theorem} We have therefore proved the following result which shows that we cannot avoid the potential for excessive bias in $\ensuremath{\hat{\beta}}$, unless $\lambda$ converges at a rate slower than the optimal rate of convergence, i.e.\ unless the smooth term is undersmoothed. \begin{corollary}\label{cor:ps} Suppose $\lambda\approx n^{-\delta}$ for some $0<\delta<1$, $f, f^x\in H^m(\Omega)$ are bounded and $m\ge d$. The optimal rate of convergence for $\lambda$ in terms of minimising $\ensuremath{\mathrm{AMSE}}(\ensuremath{\mathbf{\hat{f}}})$ is slower than the required rate of $\ensuremath{o}(n^{-1})$ for ensuring that the bias of $\ensuremath{\hat{\beta}}$ converges faster than the standard deviation of the estimate. \end{corollary} \subsection{Asymptotic results for the spatial+ model}\label{sec:asym_ts} In dimension $d=1$, \citet{chen_shiau1991} show that for the model (\ref{eqn:spatial+}), the problems identified by Rice disappear. That is, when the parameters $\lambda$ and $\lambda_x$ converge at the optimal rate (for minimising the AMSE of the estimated spatial effect), the bias of the covariate effect estimate $\ensuremath{\hat{\beta}^+}$ converges to $0$ faster than the standard deviation and, therefore, does not become disproportionately large. We now generalise these results to dimensions $d\ge 1$. \begin{theorem}\label{thm:ts_est} Suppose $\lambda\approx n^{-\delta}, \lambda_x\approx n^{-\delta_x}$ for some $0<\delta,\delta_x<1$, $f, f^x\in H^m(\Omega)$ are bounded and $m\ge d$. Then for the spatial+ estimate of $\beta$ we have that \begin{description} \item[(a)] $\ensuremath{\mathrm{E}}(\ensuremath{\hat{\beta}^+})-\beta=\ensuremath{o}(n^{-1/2})+\ensuremath{\mathcal{O}}((\lambda\lambda_x)^{1/2})$, \item[(b)] $n\ensuremath{\mathrm{Var}}(\ensuremath{\hat{\beta}^+})\rightarrow\sigma^2/\sigma_x^2$ as $n\rightarrow\infty$. \end{description} In particular, $\ensuremath{\mathrm{Var}}(\ensuremath{\hat{\beta}^+})=\ensuremath{\mathcal{O}}(n^{-1})$ and we need $\lambda\lambda_x=\ensuremath{o}(n^{-1})$ to ensure that the bias converges faster than the standard deviation of $\ensuremath{\hat{\beta}^+}$. \end{theorem} \begin{theorem}\label{thm:ts_lambda} Suppose $\lambda\approx n^{-\delta}, \lambda_x\approx n^{-\delta_x}$ for some $0<\delta,\delta_x<1$, $f, f^x\in H^m(\Omega)$ are bounded and $m\ge d$. Then the average squared bias $\ensuremath{B_+^2}(f,\lambda,\lambda_x)$ and average variance $\ensuremath{V_+}(f,\lambda,\lambda_x)$ of the spatial+ estimate of $f$ satisfy \begin{description} \item[(a)] $\ensuremath{B_+^2}(f,\lambda,\lambda_x)=n^{-1}\sum_i (\ensuremath{\mathrm{E}}(\ensuremath{\hat{f}^+_i})-f(\ensuremath{\mathbf{t}}_i))^2=\ensuremath{\mathcal{O}}(\lambda)+\ensuremath{\mathcal{O}}(n^{-1}\lambda_x^{-d/2m}\log^2 n)$, \item[(b)] $\ensuremath{V_+}(f,\lambda,\lambda_x)=n^{-1}\sum_i\ensuremath{\mathrm{Var}} (\ensuremath{\hat{f}^+_i})=\ensuremath{\mathcal{O}}(n^{-1}\lambda^{-d/2m})$. \end{description} In particular, the optimal rates for $\lambda$ and $\lambda_x$ in terms of minimising $\ensuremath{\mathrm{AMSE}}(\ensuremath{\mathbf{\hat{f}}^+})$ are given by $\lambda=\ensuremath{\mathcal{O}}(n^{-2m/(2m+d)})$ and $\lambda_x=\ensuremath{\mathcal{O}}(n^{-2m/(2m+d)}(\log n)^{4m/d})$, assuming the convergence rates for $\ensuremath{B_+^2}(f,\lambda,\lambda)$ and $\ensuremath{V_+}(f,\lambda,\lambda_x)$ are equal. When $\lambda$ and $\lambda_x$ converge at these rates, $\ensuremath{\mathrm{AMSE}}(\ensuremath{\mathbf{\hat{f}}^+})=\ensuremath{\mathcal{O}}(n^{-2m/(2m+d)})$. \end{theorem} From this we obtain the following result which shows that, unlike $\ensuremath{\hat{\beta}}$, the estimate $\ensuremath{\hat{\beta}^+}$ does not need undersmoothing to avoid excessive bias. \begin{corollary}\label{cor:ts} Suppose $\lambda\approx n^{-\delta}, \lambda_x\approx n^{-\delta_x}$ for some $0<\delta,\delta_x<1$, $f, f^x\in H^m(\Omega)$ are bounded and $m\ge d$. If $\lambda$ and $\lambda_x$ converge at the optimal rates in terms of minimising $\ensuremath{\mathrm{AMSE}}(\ensuremath{\mathbf{\hat{f}}^+})$, then $\lambda\lambda_x=\ensuremath{o}(n^{-1})$. In particular, the optimal rates for $\lambda$ and $\lambda_x$ ensure that the bias of the spatial+ estimate $\ensuremath{\hat{\beta}^+}$ converges faster than the standard deviation of the estimate. \end{corollary} \section{Simulation}\label{sec:sim} Partial thin plate spline models can be implemented in the $\texttt{R}$-package $\texttt{mgcv}$ using the computationally efficient reduced rank approximation known as thin plate regression splines. We use this implementation (with GCV as the smoothness selection criterion) to compare the results of models fitted to simulated data for which we know the true underlying covariate and spatial dependence. \subsection{Data}\label{sec:sim_data} We generate 100 independent replicates of covariate data $\xb=(x_1,\ldots,x_n)^T$ and response data $\yb=(y_1,\ldots,y_n)^T$, observed at $n=1000$ randomly selected locations in the spatial domain $[0,10]\times[0,10]$ in $\RR^2$ (using a $50\times50$ grid), as follows. Let $\zb=(z_1,\ldots,z_n)^T$ and $\zb'=(z'_1,\ldots,z'_n)^T$ denote observations at the selected locations of independently generated Gaussian spatial fields with an exponential and a spherical covariance structure, respectively. That is, each spatial field is sampled from a multivariate normal distribution centered at $\boldsymbol{0}$ with covariance structure defined by $C(h)=\exp(-(h/R)^p)$ with $R=5$ and $p=1$ for the exponential field and $C(h)=-1-1.5h/R+0.5(h/R)^3$ for $h\le R$, $C(h)=0$ for $h>R$ with $R=1$ for the spherical field (where $h$ denotes Euclidean distance). To ensure that the fields lie in the span of the spatial basis vectors used for the models in Section \ref{sec:sim_models}, each is replaced by the fitted values of a spatial thin plate regression spline fitted to them. We then let \begin{eqnarray*} \xb&=&0.5\zb +\ensuremath{\boldsymbol{\epsilon}}^x\textrm{ where }\ensuremath{\boldsymbol{\epsilon}}^x\sim N(\boldsymbol{0},\sigma_x^2\ensuremath{\mathbf{I}}),\\ \yb&=&\beta\xb+\ensuremath{\mathbf{f}} +\ensuremath{\boldsymbol{\epsilon}}^y\textrm{ where }\ensuremath{\boldsymbol{\epsilon}}^y\sim N(\boldsymbol{0},\sigma_y^2\ensuremath{\mathbf{I}}), \end{eqnarray*} with true covariate effect $\beta=3$, true residual spatial effect $\ensuremath{\mathbf{f}}=-\zb-\zb'$ and $\sigma_y=1$, $\sigma_x=0.1$. Thus, $\ensuremath{\mathbf{f}}$ is directly correlated with the spatial pattern $0.5\zb$ of the covariate. This approach is similar to \citet{thaden2018}, except we have added the component $-\zb'$ so that $\ensuremath{\mathbf{f}}$ could represent, for example, the combined effect of an unobserved covariate (with a similar spatial pattern to that of $\xb$) as well as an independent short-range spatial process. Also, rather than treating the spatial fields as fixed, we generate new fields for each replicate in the simulation. Finally, we have chosen $\sigma_x$ relatively small (such that the model matrix for the spatial model has nearly collinear columns) and $\sigma_y$ relatively large (to encourage smoothing). This is the situation in which we would expect spatial confounding issues to arise which is also confirmed by the simulations in \citet{thaden2018}. \subsection{Models}\label{sec:sim_models} To each replicate of simulated response data $\yb$ and covariate data $\xb$, we fit the following models (with basis size $k=300$ for the thin plate regression splines). Models 2 - 5 are fitted twice: once with and once without smoothing penalties applied. In \texttt{mgcv}, smoothing penalties are applied by default but can be removed using the option \texttt{fx=TRUE}. \begin{enumerate} \item[1.] Null model: The model with no spatial effects given by \begin{equation}\label{eqn:mod_null} y_i=\beta x_i +\epsilon_i,\quad \ensuremath{\boldsymbol{\epsilon}}\sim N(\boldsymbol{0},\sigma^2\ensuremath{\mathbf{I}}) \end{equation} where $\beta$ and $\sigma^2$ are estimated parameters. \item[2.] Spatial model: The model given by \begin{equation}\label{eqn:mod} y_i=\beta x_i +f(\ensuremath{\mathbf{t}}_i)+\epsilon_i,\quad \ensuremath{\boldsymbol{\epsilon}}\sim N(\boldsymbol{0},\sigma^2\ensuremath{\mathbf{I}}) \end{equation} where $\beta$ and $\sigma^2$ are estimated parameters and $f$ a thin plate regression spline with $\ensuremath{\mathbf{t}}_1,\ldots,\ensuremath{\mathbf{t}}_n$ the observed data locations. \item[3.] RSR model: Let $\ensuremath{\mathbf{B}_{\mathrm{sp}}}$ be the matrix whose columns are the spatial basis vectors in the model matrix from (\ref{eqn:mod}) (i.e.\ the thin plate regression spline basis functions evaluated at the data locations) and let $\ensuremath{\widetilde{\mathbf{B}}_{\mathrm{sp}}}=(\ensuremath{\mathbf{I}}-\xb(\xb^T\xb)^{-1}\xb^T)\ensuremath{\mathbf{B}_{\mathrm{sp}}}$ be the projection of this onto the orthogonal compliment of $\xb$. The RSR model is given by \begin{equation}\label{eqn:mod_rsr} y_i=\beta x_i +\tilde{f}_i+\epsilon_i,\quad \ensuremath{\boldsymbol{\epsilon}}\sim N(\boldsymbol{0},\sigma^2\ensuremath{\mathbf{I}}) \end{equation} where $\beta$ and $\sigma^2$ are estimated parameters and $\tilde{\ensuremath{\mathbf{f}}}=(\tilde{f}_1,\ldots,\tilde{f}_n)^T$ is modelled the same way as the spatial effect in (\ref{eqn:mod}) but with $\ensuremath{\mathbf{B}_{\mathrm{sp}}}$ replaced by $\ensuremath{\widetilde{\mathbf{B}}_{\mathrm{sp}}}$ in the model matrix. \item[4.] gSEM: Let $\ensuremath{\mathbf{r}}^x=(r_1^x,\ldots,r_n^x)^T$ and $\ensuremath{\mathbf{r}}^y=(r_1^y,\ldots,r_n^y)^T$ denote the spatial residuals of $\xb$ and $\yb$, that is, $\ensuremath{\mathbf{r}}^x=\xb-\hat{\ensuremath{\mathbf{f}}}^x$ where $\hat{\ensuremath{\mathbf{f}}}^x$ are the fitted values in the regression \begin{equation}\label{eqn:mod_gsem1} x_i=f^x(\ensuremath{\mathbf{t}}_i) +\epsilon^x_i,\quad \ensuremath{\boldsymbol{\epsilon}}^x\sim N(\boldsymbol{0},\sigma_x^2\ensuremath{\mathbf{I}}) \end{equation} where $\sigma_x^2$ is estimated and $f^x$ a thin plate regression spline, and $\ensuremath{\mathbf{r}}^y$ is the same but replacing $\xb$ by $\yb$. The gSEM model is then the linear model given by \begin{equation}\label{eqn:mod_gsem2} r^y_i=\beta r^x_i +\epsilon_i,\quad \ensuremath{\boldsymbol{\epsilon}}\sim N(\boldsymbol{0},\sigma^2\ensuremath{\mathbf{I}}), \end{equation} where $\beta$ and $\sigma^2$ are estimated. \item[5.] Spatial+: Let $\ensuremath{\mathbf{r}}^x$ denote the spatial residuals of $\xb$ as above. The spatial+ model is then \begin{equation}\label{eqn:mod_plus} y_i=\beta r^x_i +f^+(\ensuremath{\mathbf{t}}_i)+\epsilon_i,\quad \ensuremath{\boldsymbol{\epsilon}}\sim N(\boldsymbol{0},\sigma^2\ensuremath{\mathbf{I}}) \end{equation} where $\beta$ and $\sigma^2$ are estimated parameters and $f^+$ a thin plate regression spline. \end{enumerate} \subsection{Results}\label{sec:sim_results} The results of the simulation are summarised in Figure \ref{fig:sim_results}. For each data replicate, the output is the estimated covariate effect and the mean squared error (MSE) of fitted values for each model fit. For ease of notation, in this section, we use $\ensuremath{\hat{\beta}}$ to mean the estimated covariate effect in any of the fitted models (rather than the partial thin plate spline estimate alone). The MSE of fitted values is calculated as $\Vert\hat{\yb}-(\beta\xb+\ensuremath{\mathbf{f}})\Vert^2$ where for models 1, 2, 3 and 5, $\hat{\yb}$ is the fitted values in the regressions (\ref{eqn:mod_null}), (\ref{eqn:mod}), (\ref{eqn:mod_rsr}) and (\ref{eqn:mod_plus}), respectively, and for model 4, $\hat{\yb}=\ensuremath{\hat{\mathbf{f}}}^y+\hat{\ensuremath{\mathbf{r}}}^y$ where $\ensuremath{\hat{\mathbf{f}}}^y$ and $\hat{\ensuremath{\mathbf{r}}}^y$ are the fitted values in the regressions (\ref{eqn:mod_gsem1}) and (\ref{eqn:mod_gsem2}). Here $\beta=3$ and $\ensuremath{\mathbf{f}}=-\zb-\zb'$ are the true values of the estimated effects with $\beta\xb+\ensuremath{\mathbf{f}}$ the true mean of $\yb$. \begin{figure} \begin{tabular}{cc} \includegraphics[width=0.48\textwidth]{box_plot_01.pdf}& \includegraphics[width=0.48\textwidth]{box_plot_02.pdf} \end{tabular} \bigskip \caption{Estimated covariate effect $\hat{\beta}$ (left) and MSE of fitted values (right) for each model fitted to 100 data replicates, where the true covariate effect is $\beta=3$. Subscript \texttt{fx} refers to a model in which no smoothing penalties were applied whereas no subscript models were smoothed. Results in grey are the three models that correspond to those used in Thaden and Kneib's simulation study.}\label{fig:sim_results} \end{figure} In the null model and the RSR model, the estimated covariate effect is the same and has a noticeably larger bias than the estimates in the other models. This is expected as for these models, $\ensuremath{\hat{\beta}}=(\xb^T\xb)^{-1}\xb^T\yb$ is the ordinary least squares estimate, which, in addition to the true effect $\beta$, includes a contribution from the part of $\ensuremath{\mathbf{f}}$ that is correlated with $\xb$. The fitted values in RSR, however, differ from those of the null model as the larger model matrix explains a part of $\yb$ that is treated as random noise in the null model. In fact, the column space of the model matrix is the same as that of the spatial model, and it is therefore not surprising that the fitted values in these two models are similar. If no smoothing penalty is applied, models 2, 4 and 5 are essentially the same: they have the same fitted values and the same unbiased estimate for the covariate effect. This illustrates that spatial confounding bias is due to the combined effect of collinearity and smoothing, rather than collinearity alone. The spatial model is, in this case, an ordinary linear model where the columns in the model matrix are the covariate $\xb$ and the spatial basis vectors $\ensuremath{\mathbf{B}_{\mathrm{sp}}}$. This is the model from which the data is generated and, therefore, it is not surprising that the spatial model is able to recapture the true effects. The spatial+ model is a reparametrisation of the spatial model which preserves the overall column space, and simple linear model theory shows that the covariate effect estimate is preserved. Similarly, it is straightforward to show that the gSEM covariate effect estimate agrees with the spatial model in this case. (Derivations are included in Appendix E). In the unsmoothed versions of models 2 - 5, the fitted values are all the same. When smoothing is applied, the MSE of fitted values reduces, indeed, this is the intended purpose of the smoothing penalty. Looking at the covariate effect estimate, in the RSR model, the (biased) ordinary least squares estimate is unaffected by smoothing. For the remaining three models, while the unsmoothed versions of the models give unbiased estimates of $\beta$, we see that smoothing introduces varying degrees of bias. In the spatial model, the bias is quite large illustrating our results in Section \ref{sec:asym_ps}. In contrast, while the covariate effect estimate is no longer the same in the gSEM and the spatial+ model, for both models, the bias is still negligible. This behaviour is therefore also consistent with what we would expect from our theoretical results. Note that our analysis gives some intuition for why spatial+ works. If no smoothing penalty is applied, we saw that spatial+ has the same unbiased estimate for the covariate effect as the spatial model. In fact, any decomposition $\xb=\ensuremath{\mathbf{v}}+\ensuremath{\mathbf{r}}$ with $\ensuremath{\mathbf{v}}$ in the column space of the spatial basis vectors $\ensuremath{\mathbf{B}_{\mathrm{sp}}}$ gives a reparametrisation (replacing $\xb$ by $\ensuremath{\mathbf{r}}$) in which $\ensuremath{\mathbf{r}}$ captures the original covariate effect. However, by choosing $\ensuremath{\mathbf{r}}$ to be broadly orthogonal to the column space of $\ensuremath{\mathbf{B}_{\mathrm{sp}}}$ (as it is in the spatial+ model), the estimates of the covariate and spatial effects are broadly decorrelated. Thus, the covariate effect estimate is largely unaffected when smoothing is applied to the spatial term and thereby remains broadly unbiased. \section{Application}\label{sec:app} We illustrate how the spatial+ model can be used in practice by applying it to our forestry example. Details of the data can be found in \citet{augustin2009, eichhorn2016}. We consider here the data for spruce for a single observation year, namely, 2013 which has measurements from $n=186$ locations. We are interested in assessing the effect of the climate variable $\texttt{tminmay}$ (minimum temperature in May) on the response variable \texttt{ratio} (crown defoliation expressed as a proportion). We expect a high minimum temperature in May to be indicative of a warmer and drier year in general which, in turn, is likely to lead to higher levels of tree defoliation (measured later in summer). We also expect older trees to have significantly more defoliation than younger trees and have therefore included the variable \texttt{age} (age of trees) as an additional covariate in the models. Scatterplots of the data (not shown here) indicate the relationships between the covariates and the response variable are broadly as expected. \subsection{Models} A natural starting point is the null model \begin{equation}\label{eqn:defol_null} \texttt{ratio}_i=\alpha+\beta_1\texttt{age}_i+\beta_2\texttt{tminmay}_i+\epsilon_i, \end{equation} where $\epsilon_i\sim N(0,\sigma^2)$ is iid noise and $\alpha,\beta_1,\beta_2$ and $\sigma$ are estimated parameters. However, numerous spatially dependent predictors have not been included in the model, for example, soil characteristics such as soil depth and base saturation; other climatic variables such as those related to radiation and precipitation; water budget of the trees etc. Therefore, we would expect residual spatial correlation in the response variable, and a more appropriate model may therefore be a spatial model, which we define as \[ \texttt{ratio}_i=\alpha+\beta_1\texttt{age}_i+\beta_2\texttt{tminmay}_i+f(\ensuremath{\mathbf{t}}_i)+\epsilon_i, \] where $\epsilon_i\sim N(0,\sigma^2)$ is iid noise, $\alpha,\beta_1,\beta_2$ and $\sigma$ are estimated parameters and $f$ a thin plate regression spline (with basis size $k=100$) with $\ensuremath{\mathbf{t}}_1,\ldots,\ensuremath{\mathbf{t}}_n$ the observed data locations. The covariate effects of interest are $\beta_1$ and $\beta_2$ but, as the results of Sections \ref{sec:asym_ps} and \ref{sec:sim} show, the estimates of these effects may be highly biased in both the null model and the spatial model. This disproportionate bias is avoided in the spatial+ model. Let $\ensuremath{\mathbf{r}}^1=(r_1^{1},\ldots,r_n^{1})^T$ and $\ensuremath{\mathbf{r}}^2=(r_1^{2},\ldots,r_n^{2})^T$ be the residuals when a thin plate regression spline (with basis size $k=100$) is fitted to $\texttt{age}$ and $\texttt{tminmay}$, respectively. The spatial+ model is then \[ \texttt{ratio}_i=\alpha+\beta_1r^{1}_i+\beta_2r^{2}_i+f^+(\ensuremath{\mathbf{t}}_i)+\epsilon_i, \] where $\epsilon_i\sim N(0,\sigma^2)$ is iid noise, $\alpha,\beta_1,\beta_2$ and $\sigma$ are estimated parameters and $f^+$ a thin plate regression spline (with basis size $k=100$) with $\ensuremath{\mathbf{t}}_1,\ldots,\ensuremath{\mathbf{t}}_n$ the observed data locations. Finally, for comparison, we fit the gSEM as an alternative method for avoiding spatial confounding bias. Let $\ensuremath{\mathbf{r}}^{y}=(r_1^{y},\ldots,r_n^{y})^T$ be the residuals when a thin plate regression spline (with basis size $k=100$) is fitted to the response variable $\texttt{ratio}$. The gSEM is then \[ r^{y}_i=\beta_1r^{1}_i+\beta_2r^{2}_i+\epsilon_i, \] where $\epsilon_i\sim N(0,\sigma^2)$ is iid noise and $\beta_1,\beta_2$ and $\sigma$ are estimated parameters. \subsection{Results} The results of fitting the above four models to the data are summarised in Table \ref{tab:defol_res}. \begin{table} \scriptsize \setlength{\tabcolsep}{5pt} \renewcommand{\arraystretch}{1.2} \begin{tabular}{|l|rrr|rrr|rrr|rrr|} \hline& \multicolumn{3}{|c|}{\texttt{age}}& \multicolumn{3}{|c|}{\texttt{tminmay}}& \multicolumn{3}{|c|}{\texttt{s(x,y)}}&Dev&&\\ & $\ensuremath{\hat{\beta}}$ & p-value & & $\ensuremath{\hat{\beta}}$ & p-value & & edf & p-value & & expl & $\hat{\sigma}$ & AIC \\ \hline Null & 0.00247 & $ <10^{-16}$ & *** & 0.0042 & 0.5049 & & & & & 0.490 & 0.00940 & -335 \\ Spatial & 0.00237 & $ <10^{-16}$ & *** & 0.0149 & 0.0307 & * & 14.2 & 0.0243 & * & 0.605 & 0.00789 & -355 \\ Spatial+ & 0.00237 & $ <10^{-16}$ & *** & 0.0316 & 0.0073 & ** & 12.0 & 3.32e-05 & *** & 0.598 & 0.00793 & -356 \\ gSEM & 0.00232 & $ <10^{-16}$ & *** & 0.0317 & 0.0058 & ** & & & & & & \\ \hline \end{tabular} \caption{Forestry example: results of fitting models to the data. For each covariate: the estimate of the covariate effect $\beta$ and its p-value. $\texttt{s(x,y)}$ refers to the thin plate regression splines fitted to $f$ in the spatial model and $f^+$ in the spatial+ model. For each of these: the effective degrees of freedom (edf) and the p-value. For each significant p-value we write ‘***’ if it is $<0.001$, ‘**’ if $<0.01$ and ‘*’ if $<0.05$. Note that in the gSEM, deviance explained, estimated standard deviation and AIC do not compare directly with the other models as the response variable is different.}\label{tab:defol_res} \end{table} The spatial term in the spatial model is significant, which confirms there is residual spatial correlation in the data as expected. Furthermore, as the spatial term allows for more of the residual variation to be explained, the deviance explained is higher and the estimated standard deviation is lower than in the null model. As the AIC is also lower, we conclude that the spatial model is an overall better fitting model than the null model for this data. However, while the spatial model may be appropriate for overall predictions of the response variable, the estimate of any individual covariate effect may be biased. Using the spatial+ model, we expect to obtain similar fitted values as the spatial model but with covariate effect estimates that have only negligible bias. Indeed, in terms of overall fit, we see that the deviance explained, estimated standard deviation and AIC in the spatial+ model are similar to those of the spatial model. For completeness, we have also included the gSEM. Note, however, that in the gSEM, since the response variable in the regression differs from that of the other three models, the deviance explained, estimated standard deviation and AIC cannot be directly compared to the other models. The covariate \texttt{age} is highly significant and has a positive effect as expected. This covariate does not appear to be affected by spatial confounding as the estimated effect and its p-value are largely robust to the choice of model. This happens, for example, if a covariate is independent of the true underlying residual spatial effect. Also, in the case of \texttt{age}, not only is this a covariate that is not very well explained by spatial location (a spatial smooth fitted to this variable has deviance explained of only $13\%$), but its estimated spatial pattern looks dominated by linear spatial basis functions which are unpenalised in the spatial model. Therefore, penalisation of the spatial term $f$ in the spatial model is less likely to interfere with the covariate effect estimate (see \citet{rice1986} Proposition D). In contrast, the estimated effect of the covariate $\texttt{tminmay}$ is not significant in the null model but is significant in the spatial model and is even more significant in the spatial+ model. Furthermore, while in all models the effect estimate is positive as expected (i.e.\ higher temperature in May leads to more defoliation later in summer), the size of the estimate more than triples when a spatial effect is added to the null model and the estimate in the spatial+ model is more than double of that in the spatial model. This shows that, if we were to use the spatial model for our inference, the effect of temperature on crown defoliation would likely be underestimated in both size and significance due to spatial confounding. Note that, as expected, the gSEM gives similar results to spatial+. \section{Non-Gaussian response data}\label{sec:glm} A distribution is in the exponential family of distributions if its probability density function $p$ can be written in the form \[ p(y)=\exp \big[ \{y\theta-b(\theta)\}/a(\phi)+c(y,\phi)\big] \] where $\theta$ and $\phi$ are parameters of the distribution and $a,b$ and $c$ are functions. This family includes a large number of commonly used distributions in applied statistics, e.g.\ Gaussian, Poisson, exponential and binomial. \subsection{Spatial model}\label{sec:glm_spatial} Suppose we have response data $\yb=(y_1,\ldots,y_n)^T$ where each $y_i$ is assumed to be an observation of a random variable $Y_i$ whose distribution is from the exponential family with $\ensuremath{\mathrm{E}}(Y_i)=\mu_i$, and suppose $\xb=(x_1,\ldots,x_n)^T$ and $\ensuremath{\mathbf{t}}_1,\ldots,\ensuremath{\mathbf{t}}_n$ are covariate observations and spatial locations as before. A generalised version of (\ref{eqn:spatial}) can then be formulated as \begin{equation}\label{eqn:spatial_glm} g(\mu_i)=\beta x_i+f(\ensuremath{\mathbf{t}}_i) \end{equation} where $\beta$ is an unknown parameter, $f$ a thin plate spline and $g:\RR\rightarrow\RR$ a link function (i.e.\ a monotonic smooth function which ensures $g(\mu_i)$ is in the domain of the response variable). The partial thin plate spline estimates of $\beta$ and $\ensuremath{\mathbf{f}}=(f(\ensuremath{\mathbf{t}}_1),\ldots,f(\ensuremath{\mathbf{t}}_n))^T$ are found using a penalised iterative re-weighted least squares (PIRLS) algorithm. Initialising the algorithm with $\ensuremath{\hat{\mu}}_i=y_i$ and $\ensuremath{\hat{\eta}}_i=g(\ensuremath{\hat{\mu}}_i)$, we define so-called pseudodata as $z_i=g'(\ensuremath{\hat{\mu}}_i)(y_i-\ensuremath{\hat{\mu}}_i)+\ensuremath{\hat{\eta}}_i$ and iterative weights $w_i=1/(g'(\ensuremath{\hat{\mu}}_i)^2V(\ensuremath{\hat{\mu}}_i))$ where $V(\mu_i)=\ensuremath{\mathrm{Var}}(Y_i)\phi=b_i''(\theta)a_i(\phi)/\phi$ is the variance function for the distribution of $Y_i$. Let $\ensuremath{\hat{\beta}}$ and $\ensuremath{\hat{\mathbf{f}}}$ be the minimisers of \begin{equation}\label{eqn:glm_min} \Vert\sqrt{\ensuremath{\mathbf{W}}}(\zb-\beta\xb-\ensuremath{\mathbf{f}})\Vert^2+n\phi\lambda\ensuremath{\mathbf{f}}^T\boldsymbol{\Gamma}\ensuremath{\mathbf{f}} \end{equation} where $\ensuremath{\mathbf{W}}=\textrm{diag}(w_1,\ldots,w_n)$ is the weights matrix, $\zb=(z_1,\ldots,z_n)^T$, and $\lambda>0$ and $\boldsymbol{\Gamma}$ are as in (\ref{eqn:ps_min}). Now redefining $\ensuremath{\hat{\eta}}_i=\ensuremath{\hat{\beta}}\xb+\ensuremath{\hat{\mathbf{f}}}$ and $\ensuremath{\hat{\mu}}_i=g^{-1}(\ensuremath{\hat{\eta}}_i)$, the algorithm is reiterated until convergence and the partial thin plate spline estimates $\ensuremath{\hat{\beta}}$ and $\ensuremath{\mathbf{\hat{f}}}$ are then the minimisers of (\ref{eqn:glm_min}) in the final iteration. Note that, if no smoothing is applied, $\ensuremath{\hat{\beta}}$ and $\ensuremath{\mathbf{\hat{f}}}$ are the maximum likelihood estimates in a generalized linear model (GLM), which are asymptotically unbiased. \subsection{Spatial+ model}\label{sec:spatial_plus_glm} Starting with the model (\ref{eqn:spatial_glm}), let $\ensuremath{\mathbf{W}}$ and $\zb$ denote the weights matrix and pseudodata at convergence of the PIRLS algorithm. We then define the corresponding spatial+ model as follows. Let $\ensuremath{\hat{\mathbf{f}}}^x$ and $\ensuremath{\mathbf{r}}^x=\xb-\ensuremath{\hat{\mathbf{f}}}^x=(r_1^x,\ldots,r_n^x)^T$ denote the fitted values and residuals in the weighted thin plate regression (\ref{eqn:co_model}) with weights $\ensuremath{\mathbf{W}}$, i.e.\ $\ensuremath{\hat{\mathbf{f}}}^x$ is the minimiser of $\Vert\sqrt{\ensuremath{\mathbf{W}}}(\xb-\ensuremath{\mathbf{f}}^x)\Vert^2+n\lambda_x\ensuremath{\mathbf{f}}^{xT}\boldsymbol{\Gamma}\ensuremath{\mathbf{f}}^x$ with smoothing parameter $\lambda_x>0$ and $\boldsymbol{\Gamma}$ defined as before. The spatial+ model is then the partial thin plate spline model defined by \begin{equation}\label{eqn:spatial_plus_glm} g(\mu_i)=\beta r_i^x+f^+(\ensuremath{\mathbf{t}}_i) \end{equation} where $\beta$ and $f^+$ are estimated as described in Section \ref{sec:glm_spatial}. From Section \ref{sec:glm_spatial} we see that the estimates $\ensuremath{\hat{\beta}}$ and $\ensuremath{\mathbf{\hat{f}}}$ in the spatial model (\ref{eqn:spatial_glm}) are obtained as the minimisers of (\ref{eqn:ps_min}) if we replace $\yb,\xb,\ensuremath{\mathbf{f}},\boldsymbol{\Gamma}$ and $\lambda$ by $\tilde{\yb}=\sqrt{\ensuremath{\mathbf{W}}}\zb$, $\tilde{\xb}=\sqrt{\ensuremath{\mathbf{W}}}\xb$, $\tilde{\ensuremath{\mathbf{f}}}=\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\mathbf{f}}$, $\tilde{\boldsymbol{\Gamma}}=\sqrt{\ensuremath{\mathbf{W}}}^{-1}\boldsymbol{\Gamma}\sqrt{\ensuremath{\mathbf{W}}}^{-1}$ and $\tilde{\lambda}=\phi\lambda$. Thus, at convergence of the PIRLS algorithm, estimation corresponds to that of a Gaussian model for which the model matrix has columns $\tilde{\xb}$ and $\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\mathbf{B}_{\mathrm{sp}}}$. From our comment at the end of Section \ref{sec:sim_results}, the decorrelation trick that we used in Section \ref{sec:ts} would therefore work if we replace $\tilde{\xb}$ by $\tilde{\ensuremath{\mathbf{r}}}$, obtained from a decomposition $\tilde{\xb}=\tilde{\ensuremath{\mathbf{v}}}+\tilde{\ensuremath{\mathbf{r}}}$ in which $\tilde{\ensuremath{\mathbf{v}}}$ is in the column space of $\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\mathbf{B}_{\mathrm{sp}}}$ and $\tilde{\ensuremath{\mathbf{r}}}$ is broadly orthogonal to the columns of $\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\mathbf{B}_{\mathrm{sp}}}$. By the properties of weighted thin plate spline regressions, $\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\mathbf{r}}^x$ is broadly orthogonal to $\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\mathbf{B}_{\mathrm{sp}}}$. Therefore, letting $\tilde{\ensuremath{\mathbf{v}}}=\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\hat{\mathbf{f}}}^x$ and $\tilde{\ensuremath{\mathbf{r}}}=\sqrt{\ensuremath{\mathbf{W}}}\ensuremath{\mathbf{r}}^x$, the required decorrelation is achieved. Finally, replacing $\tilde{\xb}$ by $\tilde{\ensuremath{\mathbf{r}}}$ is equivalent to replacing $\xb$ by $\ensuremath{\mathbf{r}}^x$ in the spatial model, leading to the model (\ref{eqn:spatial_plus_glm}). \subsection{Simulations} The models (\ref{eqn:spatial_glm}) and (\ref{eqn:spatial_plus_glm}) can once again be implemented using thin plate regression splines in \texttt{mgcv}. To test the performance of the spatial+ model (\ref{eqn:spatial_plus_glm}), we repeat the simulations from Section \ref{sec:sim} for three different response distributions, namely, the Poisson distribution with canonical link function $g(\mu)=\log(\mu)$, the exponential distribution with (non-canonical) link function $g(\mu)=\log(\mu)$ and the binomial distribution with size parameter $n_{\textrm{bin}}=10$ and canonical link function $g(\mu)=\log(\mu/(n_{\textrm{bin}}-\mu))$. For each response distribution, we simulate 100 replicates of the response data $\yb=(y_1,\ldots,y_n)^T$ by independently sampling each $y_i$ from the given distribution with mean $\mu_i=g^{-1}(\eta_i)$ where $\eta_i=\beta x_i+f_i$ with $\xb=(x_1,\ldots,x_n)^T$ simulated as in Section \ref{sec:sim_data}, $\sigma_x=0.1$, and true effects $\beta=3$, $\ensuremath{\mathbf{f}}=(f_1,\ldots,f_n)^T=-\zb-\zb'$ as before. The results of fitting the models (\ref{eqn:spatial_glm}) and (\ref{eqn:spatial_plus_glm}) are summarised in Figure \ref{fig:sim_results_glm}. For comparison we have also included the results of fitting the corresponding null model (i.e.\ the GLM defined by $g(\mu_i)=\beta x_i$) and the models (\ref{eqn:spatial_glm}) and (\ref{eqn:spatial_plus_glm}) with no smoothing penalty applied. Finally, we have fitted a generalised version of the RSR model (for details see Appendix E). Note that we have not included the gSEM here as it is not immediately clear how to generalise this model to non-Gaussian response distributions. We see that for all three response distributions, the overall behaviour of the models is similar to what we saw in the Gaussian case. As before, the null model and RSR model both have highly biased covariate effect estimates, however, note that unlike the Gaussian case, the estimate is not the same in the two models. This is because, while in both models the estimate is given by $\ensuremath{\hat{\beta}}=(\xb^T\ensuremath{\mathbf{W}}\xb)^{-1}\xb^T\ensuremath{\mathbf{W}}\zb$, the fitted values, and hence the weights and pseudodata at convergence, differ. Without smoothing, as expected, the spatial and spatial+ models give the same results, however, while the covariate effect estimate looks unbiased for the Poisson and exponential response distributions, it looks slightly biased for the binomial distribution, though not materially. This is not surprising as GLMs are only asymptotically unbiased and may have some bias in practice, particularly, when the number of estimated parameters is relatively large as it is in this case \citep{cox1968}. When smoothing is applied, MSE reduces as intended, but the covariate effect estimate in the spatial model becomes significantly biased while it remains broadly unbiased in the spatial+ model. \begin{figure} \begin{tabular}{cc} \includegraphics[width=0.45\textwidth]{box_plot_poi_1_01.pdf}& \includegraphics[width=0.45\textwidth]{box_plot_poi_1_02.pdf}\\ \includegraphics[width=0.45\textwidth]{box_plot_exp_1_01.pdf}& \includegraphics[width=0.45\textwidth]{box_plot_exp_1_02.pdf}\\ \includegraphics[width=0.45\textwidth]{box_plot_bin_1_01.pdf}& \includegraphics[width=0.45\textwidth]{box_plot_bin_1_02.pdf}\\ \end{tabular} \bigskip \caption{For each of the distributions Poisson (top), exponential (middle), binomial (bottom): the estimated covariate effect $\hat{\beta}$ (left) and log(MSE) of fitted values (right) for each model fitted to 100 data replicates, where the true covariate effect is $\beta=3$. Subscript \texttt{fx} refers to a model in which no smoothing penalties were applied.}\label{fig:sim_results_glm} \end{figure} \section{Discussion} We have shown that the proposed spatial+ model can be used to avoid unreliable covariate effect estimates in spatial regression with clear advantages over existing methods. Our analysis also gives a clearer understanding of why spatial confounding happens. Spatial models, whether formulated in terms of spatially induced prior distributions or smoothing penalties, usually apply some form of spatial smoothing to reflect spatial correlation in the data and avoid overfitting. However, from the model formulation (\ref{eqn:spatial}), we see that it is exactly this smoothing that causes spatial confounding bias. If spatial location is highly explanatory for a covariate in the model, the model matrix has nearly collinear columns, and therefore the smoothing penalty can heavily influence the way in which the "total covariate spatial effect" (i.e.\ the observed effect of the covariate spatial pattern, including any unmeasured effects) is split between the covariate term and the spatial term. As we have seen, this can lead to significantly biased results. The excessive smoothing-induced bias is avoided in both spatial+ and the gSEM. If no smoothing penalty is applied, both models give the same unbiased covariate effect estimates as the unsmoothed spatial model. Spatial+ reparametrises the spatial model so that, rather than splitting the total covariate spatial effect into two separate terms, it is fully contained in the term $f^+$. This makes fixed effect estimates broadly independent of the spatial effects, in particular, they remain largely unbiased under spatial smoothing. The idea of decorrelating covariate and spatial terms is also used in RSR. But in RSR, as it is achieved by restricting the spatial effects, it is the covariate effect estimates that contain the total covariate spatial effects, leading to bias by construction. In the gSEM, the elimination of all spatial information means that fixed effect estimates are once again decorrelated from the spatial effects and thereby protected from spatial smoothing. The resulting model of residuals only, however, seems less intuitive than spatial+ and, the change in response variable means that standard model selection criteria cannot be used for comparisons with the other models. A major advantage of spatial+ is also that the method generalises easily to models with non-Gaussian response distributions and our simulations illustrate that the method still works well here. Our above discussion shows that the decorrelation of effect estimates is the underlying reason why the spatial+ approach works. As mentioned in Section \ref{sec:intro}, the modification of the model matrix that achieves this is easily transferable to other spatial model formulations, and we would therefore expect the method to work well in general. However, as our theoretical derivations are specific to thin plate spline estimates, similar derivations or simulations could be done to confirm our results in other settings. One limitation to the spatial+ approach is that the covariate effects in the model must be linear. This assumption is needed for the spatial residuals to capture the true covariate effects. The spatial model (\ref{eqn:spatial}) is easily extended, using the generalized additive model (GAM) framework, to include non-linear covariate terms in the form of smooths (i.e.\ unknown functions of the covariates estimated from the data). It would be interesting to see if any of the ideas of spatial+, as well as our increased understanding of spatial confounding, can be used to develop methods for avoiding spatial confounding in this context. Finally, applying spatial+ to the forestry example, we see that the effect of temperature on crown defoliation appears to be positive and significant as expected, and that this effect would likely be underestimated in both size and significance in the spatial model (and even more so in the null model). The other covariate, age of trees, in this example also illustrates that, if a covariate is not spatially confounded, this can be confirmed by showing that its effect estimate in the spatial and spatial+ models agree. It is possible that this idea could be used to develop a diagnostic or test that practitioners could use to identify spatial confounding in applications. \section*{Acknowledgements} Emiko Dupont is supported by a scholarship from the EPSRC Centre for Doctoral Training in Statistical Applied Mathematics at Bath (SAMBa), under the project EP/L015684/1. We thank The Forest Institute Baden-W\"urttemberg (Germany) for making the 2013 Terrestrial Crown Condition Inventory (TCCI) forest health monitoring survey data available.
{'timestamp': '2020-09-22T02:16:09', 'yymm': '2009', 'arxiv_id': '2009.09420', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09420'}
arxiv
\section{Introduction} \label{sec:intro} Future 5G networks will support applications that require ultra-reliable communication among massive Internet-of-things (IoT) devices~\cite{IEEEhowto:00}. Achieving low-cost and reliable communication with bounded delay is challenging in these networks. Moreover, the number of IoT devices in future ubiquitous networks will eventually surpass the number of connected user devices~\cite{IEEEhowto:01}, making it more difficult to satisfy the application-specific requirements of data rate and latency. \begin{figure}[!t] \begin{center} \resizebox{3.3 in}{1.8 in}{\includegraphics{fig1}} \caption{\em Long Range Wide Area Network (LoRaWAN) Architecture} \label{jpg1} \end{center} \end{figure} A new suite of long-range IoT technologies have emerged, including long term evolution for machines (LTE-M), narrow-band IoT (NBIoT), SigFox, Ingenu, and long range (LoRa)~\cite{IEEEhowto:22}. These technologies target low rates, small power, and wide area coverage for a massive number of devices. Among these, LoRa provides low cost, low power, and long range IoT solution, targeting various network devices such as wearables, smart meters, and remote sensors. This technology uses the LoRa modulation scheme over its physical layer. LoRa radio transmission requires setting up of the following five configurable parameters with respective limits: transmission power (2 dBm to 20 dBm), frequency (860 MHz to 1020 MHz), spreading factor (SF) (7 to 12), channel bandwidth (125kHz, 250 kHz, or 500 kHz), and coding rate (4/5 to 4/8)~\cite{IEEEhowto:18}. LoRaWAN is the medium access layer (MAC) protocol used by LoRa devices to transmit their data over the wireless channel. So far, LoRaWANv1.1 has defined the operation of three device classes, namely Class A (sensors), Class B (actuators), and Class C (all time active) in a LoRa network~\cite{IEEEhowto:11}. Class A and B devices perform energy efficient network operation in the uplink (UL) and downlink (DL) respectively. All LoRaWAN devices must support the Class A UL operation, which forms the basis of LoRaWAN operation and is the focus of this work. Fig.~\ref{jpg1} presents the LoRaWAN network architecture consisting of end devices, gateways, and a network server. The network server is connected to the end devices over the MAC layer running LoRaWAN, whereas the LoRa gateways are just traffic forwarding elements. The server is the main component of the LoRa network that handles traffic coming via all gateways. LoRaWAN devices support two different types of frames transmissions, namely \emph{confirmed} and \emph{unconfirmed}. The confirmed frames require an acknowledgement (ACK) back to the end device, whereas the unconfirmed frames do not need any ACK. This work focuses on the UL communication through the confirmed frames transmissions. Achieving reliable and low-cost data delivery in future IoT networks is important. Current practice in exploring the design space for LoRa networks mostly relies on simulations, with some early testing efforts. Simulations can be time-consuming and limiting due to their iterative nature, while physical experimentation is costly, tedious, and labour-intensive. Thus, there is a clear need for a mathematical model to more effectively explore the design space and highlight performance tradeoffs in different scenarios. We propose an analytical model to calculate the amount of resources consumed for the UL delivery of confirmed data frames. Empirical experiments based on a small scale LoRaWAN testbed, as well as larger scale ns-3 simulations, are used to evaluate our model in terms of the resources consumed by each end-device for an UL confirmed transmission. Our findings confirm that the proposed model can be used to estimate the consumed energy and delay experienced by an end device for reliable UL transmission. Next, we further evaluate our Markov-chain based analytical model, by exploring different values for the maximum number of allowed retransmissions, the choice of receive slot for ACK transmissions, and the network load. Our model shows how transmission delay and energy depend on these parameters. In the rest of this paper, the next section provides a background on the basic LoRaWAN operation. Section III discusses the model assumptions and explains the complete Markov-chain based model and its associated state transition probabilities. In Section IV we show the results attained through our proposed model, from a small scale test-bed, as well as using the ns-3 LoRaWAN module based simulations. Section V presents and discusses the evaluation results of different use case scenarios based on our proposed analytical model. Section VI briefly outlines the relevant related work, and Section VII concludes the paper. \section{Background} \label{sec:back} \begin{figure}[t!] \begin{center} \resizebox{3.2 in}{3.8 in}{\includegraphics{fig2ab_1}} \caption{\em Confirmed UL Transmission in LoRaWANv1.1: (a) General scenario, (b) Case 1, and (c) Case 2 for confirmed UL frame with maximum transmissions N = 2. } \label{jpg2} \end{center} \end{figure} This section briefly describes the basic working of LoRaWAN. In LoRaWANv1.1, a Class A device performs UL transmission following the pure ALOHA access method, while respecting the region-specific regulatory duty cycle (RDC) restriction over the specific sub-band. Various sub-bands are supported in LoRaWAN, some consist of only main channels and are used for normal data transmission, some are used by devices to send join requests, while others are reserved for sending DL responses from the gateway. For each UL transmission, the device switches to transmit mode and picks a spreading factor (SF), channel, bandwidth, coding rate (as advised from the network server), and sends the data for the transmit duration based on the frame length. After the UL transmission, the end device opens two consecutive receive slots as shown in Fig.~\ref{jpg2}a, to wait for DL data transmission. The two receive slots recommends offset value of 1 and 2 seconds respectively. As shown in Fig.~\ref{jpg2}a, after the~\emph{receive delay} expiration, in receive slot 1 ($RS_1$) the device listens for any DL frames over the same channel with a rate which is a function of the UL data rate. If it hears nothing, the device wait for another second and again listens for the DL data in receive slot 2 ($RS_2$) over a reserved channel with minimum rate. If the device does not get any ACK during $RS_2$ duration (equal to preamble air-time with minimum rate), it waits for an ACK-TIMEOUT duration, to make sure that the device has nothing to send until the air-time of a valid frame. After the time expires, the same confirmed frame $CF_{0}$ (with frame counter zero) can be retransmitted following the RDC, similar to any other UL transmission, as shown in the case of $CF_{0}$ in Fig.~\ref{jpg2}a. From Fig.~\ref{jpg2}a, note that the LoRaWAN operation results in two transmission opportunities from the gateway as a result of an UL transmission from a device. This is to save the battery powered devices resources, in contrast to the gateway which is often mains powered, or has otherwise a less restricted power source. A device will continue to re-transmit frame following the RDC, as long as it does not get any DL data from the gateway. The maximum number of confirmed frame retransmissions is a configurable value, with a recommended limit of seven\footnote{i.e. if N is the maximum number of retransmissions including the first transmission, then N $=$ 8 as defined in the LoRaWANv1.1~\cite{IEEEhowto:11}.}. The device moves to the next frame once the current frame gets acknowledged, or the limit $N$ is reached. Furthermore, for each received data frame (with unique frame counter), the gateway must send the ACK frame only once~\cite{IEEEhowto:11}, as seen from the operation depicted in Fig.~\ref{jpg2}b, i.e. Case 1. However, to enhance the network performance, most LoRaWAN applications support re-sending of ACK frames, as shown by the process in Fig.~\ref{jpg2}c, i.e. Case 2. Moreover, Fig.~\ref{jpg2}b,c show three different conditions of ACK transmission in the case of a confirmed data frame (with $N$ = 2). In the first, the ACK frame is immediately received by the end device in $RS_1$. In the second case, the ACK frame is lost during the first transmission attempt, whereas in the last one the frame could not be successfully ACK'd. If after all the $N$ attempts no ACK for the confirmed frame has arrived, the device will drop the frame immediately after the ACK timeout. Note further in Event 3 of Fig.~\ref{jpg2}b,c, after the UL frame reception in the first transmission attempt, the gateway can send the ACK in one of the two receive slots. After the ACK from the gateway is lost, the device will assume that the transmission was not successful and will resend the frame after the ACK-TIMEOUT. Finally, when the device PHY layer does not get any ACK after $N$ attempts, it will drop the frame and will notify the loss to the higher layer. \section{System Model} \begin{figure*}[t!] \begin{center} \resizebox{5.5 in}{2.4 in}{\includegraphics{fig32}} \caption{\em Proposed Markov-Chain Model for Confirmed UL Transmission in LoRaWAN.} \label{jpg3} \end{center} \end{figure*} In this section, we develop an analytical model for the UL confirmed data frame transmission of class A devices in a LoRaWAN network. For a given traffic load over a device and in the presence of a given number of devices, our goal is to estimate the average time it takes for the successful reception of a data frame sent by an arbitrary end device. Also given a maximum transmissions limit, our model can be used to find the worst case delay and energy consumption. The notation and symbols used in this section are listed with their definitions in Table~\ref{table1:symbolsmeaning}. \subsection{Assumptions} We make the following assumptions for our model, \begin{enumerate} \item Only class A type LoRaWAN devices are present. Hence, an ACK does not contain any piggybacked data and has a fixed size comprising the preamble and the MAC frame header with a set ACK flag. \item For the proposed analytical model, we consider that overlapping transmissions from multiple devices over the same channel with the same LoRaWAN transmission parameters (i.e. bandwidth, SF, code rate) will be lost. In other words, we ignore the capture effect. \item All UL transmissions respect the RDC of the given sub-band. For $RS_2$, our model assumes that the reserved channels used for DL ACK transmission by the gateway has no duty cycle restriction. This is valid~\footnote{ETSI regulations~\cite{IEEEhowto:21} allows a device to use channel either by respecting the RDC or following listen before talk adaptive frequency agility.}, as only the gateway can use these reserved channels. \item All network devices have uniform traffic intensities. \end{enumerate} \subsection{Proposed Analytical Model} Fig.~\ref{jpg3} shows our proposed Markov-chain model for the confirmed UL transmission, where devices perform data transmission based on the region specific RDC restrictions~\cite{IEEEhowto:12}, and the data frame availability. In our model, for each new data frame all available channels have a uniform probability to be selected for transmission. Whenever an end-device PHY has a frame ready to send, it switches to the~\emph{Send Frame} state $S_1$ (where n=1, for the first transmission attempt of a confirmed UL data frame.), and remains there until the end of the frame transmission. Then the device wait in the receive slot $RS_1$ in state ($R^1$, n) to detect DL data over the same channel with the same rate that was used for the UL frame transmission. As shown in Fig.~\ref{jpg3}~\footnote{The arrows for transition between states with only non-zero state transition probabilities are shown in the Fig.~\ref{jpg3}.}, the states for the data reception in the first receive slot, i.e. ($R^1$, n), ($P^1$, n), and ($C^1$, n) are defined by $r^1_n$, $p^1_n$, and $c^1_n$. These are referred to as the detection of preamble ($r^1_n$), checking the preamble ($p^1_n$), and checking the ACK data frame ($c^1_n$), in $RS_1$, respectively. Note that here, $n$ refers to the $n^{th}$ transmission attempt of the given confirmed UL frame. Thus, n=1 is the first transmission, while n=2, 3, ... , N represent the later UL retransmissions of the same confirmed frame, until the ACK is received. Similar to $RS_1$, for every successive UL transmission, $RS_2$ also has three 2-dimensional states for checking the preamble and the corresponding frame data, namely ($R^2$, n), ($P^2$, n), and ($C^2$, n), represented by $r^2_n$, $p^2_n$, and $c^2_n$, as shown in Fig.~\ref{jpg3}. \begin{table}[t!] \caption{Symbols and their Definition}\centering \label{table1:symbolsmeaning} \begin{tabular}{|c|c|} \hline Symbols & Definition \\ \hline $A$ &Total network devices\\ \hline $n$=1,2,...,$N$ &($n$) frame tx., ($N$) max. possible tx. \\ \hline $t_I$ &Traffic intensity \\ \hline $\Delta$ &Duty cycle of sub-band for UL tx. \\ \hline $m_c$ &Channels available for UL tx. \\ \hline $\alpha$ &Channel quality\\ \hline $\gamma_n$ &Slot use by gateway for ACK tx.\\ \hline $P_{s_n, r^1_n}$ &Transition probability from $s_n$ to $r^1_n$\\ \hline $x_a(/y_a)$ &Probability of device $a$ tx. (/not tx.)\\ \hline $D_{s_n}$ &Delay observed in state $s_n$\\ \hline $E_{s_n}$ &Energy consumed in state $s_n$\\ \hline $t^{TX}_{n}$, $t^{PR}_{n}$, $t^{ACK}_{n}$&Data, preamble, ACK frames air-time\\ \hline \end{tabular} \end{table} \textbf{\underline{Model Description}:} We assume a LoRaWAN network with available sub-bands, comprising of $m_{c}$ channels available for UL data transmission. $\Delta$ is the maximum percentage of air-time a device can use sub-bands for data frame transmission, and it is called as the RDC constraint. With this restriction, a device can only transmit a constant number of fixed size UL packets to the gateway. We call it the packet transmission rate of an end-device. If the frame arrival rate to an end-device application is greater than or equal to its frame transmission rate (regulated by $\Delta$), the network is considered to be fully loaded. We use $t_I$ to represent the ratio of the frame arrival rate and frame transmission rate from a particular device. In other words, $t_I$ ($0$ $\leq$ $t_I$ $\leq$ $1$) defines the traffic intensity. From here on, we use $t_I$ $=$ $1$, i.e. all devices in the network are fully loaded. Also, as seen from Table~\ref{table1:symbolsmeaning}, $\gamma_n$ is the choice of receive slot used by gateway for sending ACK in response to the $n^{th}$ data frame transmission. $\gamma_n$ if one and zero implies that the $RS_{1}$ and $RS_{2}$ is chosen, respectively. The overall traffic generation probability over the sub-band is given by $\Delta$ $\cdot$ $A$. For a device $a$, the probability of sending frame within the duty cycle over a channel will be, \begin{equation}\label{eq03} x_a = \frac{\Delta}{m_c}, \end{equation} As in~\cite{IEEEhowto:06}, the probability that an active device will not send data over a channel is defined through $y_a$ as 1 - $\frac{\Delta}{m_c}$. From LoRaWAN specifications~\cite{IEEEhowto:11}, during retransmission the device must not use the same channel that was used in the last transmission. Hence with $m_c$ available channels for the first transmission, the available channels will reduce by one in the following retransmission. Therefore the probability that an end device is not using a given channel during retransmission is, \begin{equation}\label{eq05} y'_a = 1 - \frac{\Delta}{m_c - 1}, \end{equation} The formulation of the state transition matrix $\mathbf{P}$ for our model is added in the Appendix. A detailed version with all relevant explanation is available at~\cite{IEEEhowto:24}. To find the expected delay and energy consumed using the Markov-chain model of Fig.~\ref{jpg3}, we use the resulting state transition matrix $\mathbf{P}$ of length (8 $\cdot$ N + 1) $\times$ (8 $\cdot$ N + 1). Using $J^{0}$ as the row vector of length 1 $\times$ (8 $\cdot$ N + 1), with initial value for the state $S_1$ as 1. The probability of a device residing in a particular state can be determined after each K period as, $J^{(K)}$ $=$ $J^{0}$ $\cdot$ ${\mathbf{P}}^{K}$. Using the Markov-chain property as $K$ approaches to infinity, the probabilities for each state in $J^{(K)}$ approaches to some steady state. Based on these steady state probabilities ($J^{(K)}$ for very large $K$) we can find the average delay and energy consumed as a device moves from the send state ($S_1$) to the $ACK$ state, using the delay and energy values for each state. \textbf{\underline{Delay vector}:} The delay in each state is given by the column vector $\mathbf{D}$ (of length 8 $\cdot$ N + 1) defined by [$D_{s_n}$, $D_{r^1_n}$, $D_{p^1_n}$, $D_{c^1_n}$, $D_{r^2_n}$, $D_{p^2_n}$, $D_{c^2_n}$, $D_{w_n}$, $D_a$], where $n$ corresponds to the $n^{th}$ transmission of the current data frame. Here, $D_{s_n}$ comprises the delay due to the $n^{th}$ data frame transmission by the user device until the time the end device waits for $RS_1$ (1 + $t^{TX}_{n}$). $D_{r^1_n}$ is the time a device spends in $RS_1$ to receive/decode the DL preamble during $n^{th}$ frame transmission ($t^{PR}_{n}$). $D_{p^1_n}$ is the time delay for checking the received preamble and it is assumed as negligible ($\approx$ 0). $D_{c^1_n}$ is the delay in receiving the entire DL ACK frame of 12 bytes ($t^{ACK}_{n}$). It has two components, the first component corresponds to the case when the UL frame gets ACK'd successfully in the state $RS_1$. The second is the case when the frame gets lost due to poor channel quality (low $\alpha$) and the device wait for 1 - $t^{ACK}_{n}$ seconds until it gets to $RS_2$. Thus $D_{c^1_n}$ for n=1 will be, \begin{equation}\label{eq19} D_{c^1_1} = \gamma_1 {y_a}^{2 A} \alpha \cdot ((t^{ACK}_{1} - t^{PR}_{1}) + max(1 - t^{ACK}_{1}, 0)), \end{equation} Note that, for n $\geq$ 2 the variable $y_a$ will be replaced by $y'_a$. Similarly, the states ($R^2$, n), ($P^2$, n), and ($C^2$, n) are the same states for receiving and preamble checking, and the payload data corresponds to $RS_2$. The delay for receiving the ACK preamble in $RS_2$, i.e. state ($R^2$, n), is the same as for $t^{PR}_{n}$, $D_{p^2_n}$ and $D_a$ are very small ($\approx$ 0), and $D_{c^2_n}$ is $t^{ACK}_{n}$ - $t^{PR}_{n}$. Finally, the delay in the wait state $D_{w_n}$ is calculated as the average time the sub-band becomes unavailable after the UL transmission, as a device moves from different states to the corresponding wait state in the $n^{th}$ transmission attempt \textbf{\underline{Energy vector}:} Similar to delay column vector, the energy in each state is given by the energy column vector, defined as [$E_{s_n}$, $E_{r^1_n}$, $E_{p^1_n}$, $E_{c^1_n}$, $E_{r^2_n}$, $E_{p^2_n}$, $E_{c^2_n}$, $E_{w_n}$, $E_a$]. Here, $E_{s_n}$ is the energy spent by the end-device from the start of the $n^{th}$ UL frame transmission until it opens $RS_1$. $E_{r^1_n}$ and $E_{r^2_n}$ are the energy spent during the DL preamble reception time in $RS_1$ and $RS_2$ respectively, after the $n^{th}$ transmission attempt of the UL data frame. Consequently, $E_{c^2_n}$ is the energy consumed by the device during the rest of the ACK frame reception. Similar to $D_{c^1_n}$, $E_{c^1_n}$ consists of the energy used for receiving the ACK frame plus that spent in idle mode waiting for $RS_2$, after the respective UL transmission. From $D_{p^1_n}$, $D_{p^2_n}$ and $D_a$, the corresponding energy used for checking the preamble ($E_{p^1_n}$ and $E_{p^2_n}$), and after the detection of an ACK frame in the ACK state ($E_a$) will all be zero. $E_{w_n}$ is the energy consumed in the wait state when the device is idle, after using the sub-band during the $n^{th}$ transmission. \section{Model Evaluation} In this section, we show the delay and consumed energy per successful UL transmission results achieved through our analytical model, using a real network setup, as well as from the ns-3 based LoRaWAN module~\cite{IEEEhowto:09}. \subsection{LoRaWAN test-bed Experiments} \subsubsection{Network Setup} For a real network environment, we use a MultiConnect Conduit~\footnote{http://www.multitech.net} gateway and mDots as the end devices in its coverage area. Our setup (Fig.~\ref{jpg41}) shows the gateway with 5 devices used in our experiments. The LoRaWAN transmission parameters settings are the same as highlighted in Table~\ref{table2:parameters}. The mDot device performs over-the-air (OTA) activation to join the LoRaWAN network. A device records the time before each UL data frame transmission. Similarly, the time is also recorded immediately after the device receives the corresponding ACK frame. The difference of these two times gives the successful frame transmission to ACK delay. In the same way, the device maintains a transmission counter that shows the number of attempt needed until the successful transmission of the specific frame. An mDot is programmed to send the delay of each subsequent UL confirmed frame and the transmission counter value as a payload in the next data frame. Consequently, all UL frames from different network devices are collected at the network server, containing within their payloads the delay and transmission attempt information for each previous UL frame. Due to the limited number of available physical devices, we focus on a scenario where the UL duty cycle of each mDot is increased beyond the normal RDC limit (of 1\%). This is done to achieve a higher network load, and to evaluate the proposed analytical model as the network gets saturated. Hence, we increased the duty cycle from 1\% to 16\% in the presence of 5 devices as shown in Fig.~\ref{jpg41}. Thus 5 devices with 16\% duty cycle in real setup shows the performance that is comparable to 80 devices (each with 1\% duty cycle) using the proposed analytical model. For each duty cycle value, the setup runs over a duration of 2 hours. \begin{figure}[t!] \begin{center} \resizebox{3.1 in}{1.5 in}{\includegraphics{fig43}} \caption{\em LoRaWAN real network setup with mDots and Multi-tech conduit.} \label{jpg41} \end{center} \end{figure} \subsubsection{Evaluation Results} The test-bed results of the average ACK delay are shown in Fig.~\ref{jpg411} with 5 devices with the increasing UL operation duty cycle per device. As we can see, with a larger duty cycle, the resulting delay increase becomes quite significant compared to the smaller duty cycle. The results from our approximated values via the analytical model achieved using the same network parameters with an almost perfect channel ($\alpha$=0.95) also show a similar trend with the increasing duty cycle. It is important to note that with higher duty cycle (replicating the operation of large number of network devices) a difference is observed between real network and our analytical model average ACK delay results. This is expected since with more simultaneous transmissions (larger duty cycle), accurate analytical estimation of channel conditions is non-trivial. Also note that from assumption 3 (in Section III A), the model does not consider the RDC limit over the reserved channels. Hence with larger duty cycle the network performance degrades which increases the overall observed average ACK delay. \begin{figure}[!ht] \begin{center} \resizebox{3.0 in}{2.1 in}{\includegraphics{fig412.pdf}} \caption{\em Analytical model evaluation with real network setup of A = 5, N = 8, $m_C$ = 7.} \label{jpg411} \end{center} \end{figure} \subsection{ns-3 Simulation Experiments} \subsubsection{ns-3 LoRaWAN Module} The ns-3 based LoRaWAN module is an extension of the ns-3 module for low power wide area network (LPWAN)~\cite{IEEEhowto:19}. The PHY layer of each device interacts with that of the respective gateway via the ns-3 Spectrum PHY module, implementing the device's air interface and channel specific parameters based on the path loss model. On each channel in a sub-band, a gateway can simultaneously receive signals with different spreading factors. Note that, in the module the LoRa PHY uses the error model drawn from the baseband implementation of the PHY layer in MATLAB based on an AWGN channel, as described in~\cite{IEEEhowto:09} We modified the functionality of the LoRaWAN module based on the LoRaWANv1.1 standard specifications. All end devices select a new channel among the available channels in a pseudo-random manner for each new UL frame transmission. In each retransmission, the device changes its channel by randomly picking a channel among the set of available channels, excluding the one used in the last transmission attempt. Then, after every two consecutive transmissions of an UL data frame (with the same counter value), the device reduces its rate by changing DR (/SF) by one step. The collision model used in the ns-3 LoRaWAN module considers both the impact of interference and the capture effect on the resulting bit error rate. Compared to this, our LoRaWAN analytical model uses a simple collision model based on simultaneous transmissions over the same channel. In order to account for the difference (due to capture effect) and reduce its impact, we restricted our evaluation experiments to scenarios with a relatively limited number of devices and with all devices in a distance of 5km from the gateway. While in our further evaluations (next section), the analytical model is used with even more number of devices. Similar to real network, in the ns-3 LoRaWAN module, a network server can acknowledge a device in $RS_1$, following RDC restrictions provided that the MAC is in idle state. If this is not the case, the gateway will choose $RS_2$. \subsubsection{Evaluation Settings and Environment} \begin{table}[t!] \centering \caption{Default Parameters} \label{table2:parameters} \begin{tabular}{|c|c|} \hline Parameters & Value \\ \hline \texttt{$t_I$} & 1 \\ \hline UL tx. power & 14dBm \\ \hline Gateway coverage radius & 5km \\ \hline Spreading factor (SF) & DR0/SF12 \\ \hline Preamble length & 12.25 symbols (8 bytes) \\ \hline Confirmed PHY Payload & 21 bytes \\ \hline ACK payload & 12 bytes \\ \hline Code rate & $\frac{4}{7}$ \\ \hline $\Delta$ & 1\% \\ \hline $RS_1$ DR offset & 0 \\ \hline Channel bandwidth & 125 kHz \\ \hline Path loss model & LogDistancePropagationLoss \\ \hline \end{tabular} \end{table} The evaluation of our analytical model uses the default parameters defined in Table~\ref{table2:parameters}, unless stated otherwise. For the calculation of the number of symbols, we assume that header compression is enabled while the data rate optimization feature is disabled. A perfect channel (i.e. $\alpha$=1) implying no channel losses is used in a network with a gateway and randomly distributed devices. There is no dwell time limit for the frame transmission duration (as in LoRaWAN specification~\cite{IEEEhowto:12}). Each UL data frame include 8 bytes of application payload, with 13 bytes PHY payload, which makes a total size of 21 bytes. The ACK payload frames from the gateway are considered without the optional FPort field, resulting in a size of 12 bytes. To make a reasonable comparison, no duty cycle restriction is imposed over the reserved channel, as assumed in our analytical model. An UL confirmed frame transmission is performed following a pseudo-random channel hopping pattern, with each time picking one of the 7 available channels uniformly randomly. The experimental results of ACK delay and consumed energy using ns-3 are collected from 100 simulation runs, and the average is calculated. For the consumed energy resources, we use the specification of the Semtech SX1272/73 device~\cite{IEEEhowto:20} with PA-Boost-ON state and a voltage of 1.5V. The transmit current at RFOP 17 dBm is 90mA. The idle (sleep) mode current (with transceiver off) is 0.1$\mu$A, the normal idle mode current is 1.5$\mu$A, and the receive mode current is 10.8mA. \subsubsection{ns-3 Evaluation Results} \begin{figure}[t!] \begin{center} \resizebox{3.5 in}{2.3 in}{\includegraphics{fig1617_1}} \caption{\em Analytical model evaluation of UL delay and energy via ns-3 simulations when $N$=8, $m_c$=7, and $\alpha$=1. } \label{jpg1617} \end{center} \end{figure} In this section, we use the system-level implementation of ns-3 based LoRaWAN module to evaluate the average delay and consumed energy per ACK'd UL frame results of the proposed analytical model for case 2, as defined in Fig.~\ref{jpg2}c. From Fig.~\ref{jpg1617}a, the results show that increasing the network load, by increasing the number of devices, significantly increases the average ACK delay for UL confirmed frame. Intuitively, the delay using $RS_1$ should be smaller compared to $RS_2$. However, in the worst case scenario the use of only $RS_1$ (when $\gamma_n$=1) for ACK transmission increases the delay and energy due to high interference from other transmissions and the possible collisions as the channel used in $RS_1$ is shared among all devices. In contrast to that, the channel used in $RS_2$ is reserved. Thus, as shown in Fig.~\ref{jpg1617}, the delay (/energy consumed) using $RS_2$ is small compared to $RS_1$, and it even surpasses the difference in their transmission times (of one second). Also, as with an increasing number of devices the collision probability increases, the difference in the delay and energy consumed using $RS_1$/$RS_2$ also increases. Furthermore, using our ns-3 based simulation experiments, we can see that the average ACK delay and energy confirms the validity of our analytical model. When the load is low, the ns-3 LoRaWAN results show a small delay and amount of energy consumed, as there are not many collisions, and ACKs can also be sent via $RS_2$. When the load becomes high, the average delay and energy consumed in ns-3 results increases, due to packet loss and retransmissions, caused by collisions and interference. Also due to the opportunistic use of $RS_2$ in our ns-3 LoRaWAN results, the resulting average delay and energy per successful ACK increases, but is still less compared to using only $RS_1$ ($\gamma_n$=1) slot for all ACK transmissions. From the results in Fig.~\ref{jpg1617} (a, b), it is important to note that the consumed resources depend heavily on the choice of receive slot (1 or 2). To get information about the choice of receive slot in each successive ($n^{th}$) transmission, we carried out multiple simulation runs in ns-3 with each set of devices (in Fig.~\ref{jpg1617}). The results give us the probabilities for the selection of the respective receive slots (1 and 2) by the gateway for ACK transmission, in response to a transmission attempt from a device. In other words, for each set of sub-band load we finds the probabilities of receive slots (1 and 2) selection in each of the $n^{th}$ transmission attempts. As expected, we found that with increasing load (network devices) the probability of receive slot selection in higher transmission attempts increases. We then used these probabilities of the choice of receive slot for ACK transmission and the expected delay (/energy) values from our analytical model to estimate the consumed resources when both slots (1 and 2) are available. The approximate results (represented as delay approx. and consumed energy approx.) in Fig.~\ref{jpg1617} shows that our model is able to accurately estimate the delay and consumed energy of LoRaWAN devices performing confirmed UL transmissions. \section{Model Application Use Cases} This section demonstrate the application of our analytical model in different network scenarios. Here, we consider a channel quality ($\alpha$) of 0.9. For the cases where these parameters are not varied, we use the maximum number of retransmissions, including the first transmission as $N=2$. Three channels are available for UL data transmission ($m_c$=3) in a network with total 50 devices ($A$=50). All other parameters are shown in Table~\ref{table2:parameters}. Further we evaluate the results using both cases 1 and 2, as discussed in Section~\ref{sec:back}. \subsection{Number of Devices ($A$)} Results in Fig.~\ref{jpg67}a and Fig.~\ref{jpg67}b show the consumed resources with the increasing number of devices, i.e. load. As can be seen, increasing the number of devices also increases the resource consumption for an UL confirmed delivery. The trend in delay and consumed energy for the case of only $RS_1$ (i.e. $\gamma_n$=1) shows an exponential increase due to an increase in collisions. In contrast, with the use of only $RS_2$ for ACK transmissions, the average delay and consumed energy increases only slightly with respect to the network load. This is because the reserved channel is only used by the gateway in $RS_2$, and the end device is not experiencing interference from the neighboring gateways. Hence, with high network load more devices can be served in a smaller amount of time, and the corresponding delay and energy per device for achieving a successful UL transmission is relatively small. Similarly, due to the small maximum transmission limit ($N$=2), a slight difference in delay and consumed energy results can be observed between the two cases with increasing network devices. \begin{figure}[t!] \begin{center} \resizebox{3.5 in}{2.1 in}{\includegraphics{fig67_1.pdf}} \caption{\em Expected delay and energy results per ACK'd transmission when $N$=2, $m_c$=3, and $\alpha$=0.9 for different values of $\gamma_n$ with respect to number of network devices.} \label{jpg67} \end{center} \end{figure} \subsection{Maximum Transmissions ($N$) Per Device} In the next scenario, we increase the maximum number of allowed transmissions $N$ of a frame, and evaluate the impact on the delay and consumed energy per ACK with 50 devices. Overall, in case 1 the results of Fig.~\ref{jpg1011}a and Fig.~\ref{jpg1011}b show an increasing trend of both delay and energy consumption with an increasing value of $N$, whereas the increase is minor for case 2. In case 1, when the ACK transmission is done using $RS_2$, we can see that the consumed resources increases with a smaller slope than using $RS_1$. This is because the use of reserved channel for DL ACK transmission eliminates the possibility of collisions. As a consequence, the probability of required retransmissions also reduces significantly, especially when the gateway is serving large number of devices. However, when only $RS_1$ is used to transmit ACK, the probability of a collision and subsequent retransmission increases. Finally, a considerable difference in average ACK delay and consumed energy can be noticed among the two cases (1 and 2), as the maximum transmissions ($N$) approaches 8. This further shows that when an ACK frame is lost, a higher limit non-uniformly increases the delay and consumed energy, especially when the ACK retransmission is not done. \begin{figure}[t!] \begin{center} \resizebox{3.5 in}{2.2 in}{\includegraphics{fig1011_1.pdf}} \caption{\em Expected delay and energy per ACK'd transmission when $A$=50, $m_c$=3, and $\alpha$=0.9 for different values of $\gamma_n$ with respect to maximum transmissions ($N$). } \label{jpg1011} \end{center} \end{figure} \section{Related Work} Recently, several efforts have been made to improve the performance of long range IoT technologies. The work in~\cite{IEEEhowto:03} gives a brief survey, comparing the LoRa and narrowband IoT (NBIoT) in terms of the cost, QoS, coverage, latency, and energy consumption. While the LoRa network can achieve low cost, prolonged battery life, and enhanced coverage, it does not provide any QoS. This is because the asynchronous nature of the LoRaWAN operation reduces the network server control over the delay and the data rate. An in-depth study and evaluation of LoRa and LoRaWAN technology is carried out in~\cite{IEEEhowto:08}. Using the physical LoRa testbed, the authors study the average throughput, collision rate, and channel utility in various network load conditions. The results show that with unconfirmed and confirmed transmissions the network achieves maximum channel occupancy when the load is 48\% and 25\%, respectively. The work presented in \cite{IEEEhowto:16} and~\cite{ IEEEhowto:08} shows that the RDC constraints limit the performance of Class A LoRaWAN devices. Especially for confirmed UL transmissions, this badly affects the LoRaWAN performance as the transmission of ACKs by the gateway increases the problem. Thus, as shown in~\cite{IEEEhowto:16}, the packet reception rate decreases due to a higher number of collisions when either the number of devices becomes too high, or their packet generation rate goes beyond a threshold. For these reasons, modifying the existing ALOHA-based channel access, investigating efficient channel hopping mechanisms, and devising new ways to minimize the number of ACKs emerge as new challenges in LoRaWAN. The LoRaWAN performance highly depends on the appropriate selection of different transmission parameters (such as power, SF, coding rate, etc.) for each end-device. In~\cite{IEEEhowto:23}, the authors suggest a passive probing approach that chooses a suitable transmission power and UL rate to save device energy. The results shows that a significant amount of power can be saved using this method. However, it can take quite some time to collect enough probing measurements for an effective decision. Also, if the above parameters are not chosen well, it can increase the consumed energy, as well as a more delay due to the RDC limit. Therefore, an analytical model, such as presented in this paper, can be a useful tool for the exploration of LoRaWAN, and in particular the optimal choice of network and protocol parameters. The works in~\cite{IEEEhowto:04},~\cite{IEEEhowto:05},~\cite{IEEEhowto:06}, and~\cite{IEEEhowto:07} model resource consumption for various aspects of LoRaWAN. In~\cite{IEEEhowto:04} and~\cite{IEEEhowto:07}, the authors present models to compute the energy and delay consumption for UL LoRaWAN transmissions. Specifically, the authors show how the frame collision rate and the respective device bit error rate (BER) changes under the given network conditions. In~\cite{IEEEhowto:04}, results show that a LoRa device with a 2400mAh battery can last up to 1 year when sending data frames every 5 minutes. The Markov-chain based queuing model presented in~\cite{IEEEhowto:07} is used to estimate the network transmission latency based on the traffic intensity. However, the model is not suitable for the case of retransmissions and does not consider confirmed devices~\cite{IEEEhowto:14} and~\cite{IEEEhowto:18}. The work presented in~\cite{IEEEhowto:05} models the behavior of the Class B DL transmissions using Markov-chain to calculate the data delivery delay to the end-device. The results show the delay with respect to load, available channels, and the used UL rates. As in the case of Class B devices, the gateway is continuously sending beacon frames (with 128s interval) for synchronization over the DL. The work considers that the gateway can only deliver the DL data either via ping slots or during one of the receive slots that opens after an UL transmission. Thus, the DL frame delay mainly depends on the number of ping-periods in a beacon interval. However, the work did not investigate how many ping periods per beacon interval are enough for efficient DL data delivery. One of the key contribution related to analytical modeling of LoRaWAN is presented in~\cite{IEEEhowto:06}. It models the resource consumption during the activation of devices in a network comprised of non-active and active devices. The results show that the activation delay and energy resources increases when more devices are going through the activation procedure. Similar to~\cite{IEEEhowto:05,IEEEhowto:06} our work is also based on a Markov-chain model, however it focuses on reliable transmissions and addresses the following limitations of previous works: \begin{itemize} \item It does not investigate both delay and energy consumption for confirmed UL transmissions in different cases. \item It does not study retransmissions and their impact on the resource consumption and network performance. \item None of the previous works evaluate results using both a real network and its system-level simulator. \end{itemize} \section{Conclusions} This paper proposes and evaluates an analytical model for reliable UL transmissions in a LoRaWAN network. The model is able to quantify the resources required for achieving a successful transmission. Our test-bed and simulation based results show that the model can be use to estimate the delay and energy resources consumed in different use cases. Further the model also gives us the upper limit on the ACK delay and consumed energy when only $RS_1$ (i.e. $\gamma_n$=1) is use for ACK transmission. The proposed model can also be evaluated for different channel quality values, number of available channels, and the DR offsets used for sending ACKs in $RS_1$.
{'timestamp': '2020-09-22T02:15:33', 'yymm': '2009', 'arxiv_id': '2009.09397', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09397'}
arxiv
\section{Introduction} The long-standing debate about the role of statistical significance in research \cite{rozeboom1960fallacy}, \cite{meehl1978theoretical} has recently intensified \cite{wasserstein2016asa},\cite{benjamin2018redefine},\cite{wasserstein2019moving},\cite{mcshane2019abandon},\cite{amrhein2018remove} and \cite{ioannidis2019importance}. Looking back to the beginning, we find that Ronald Fisher wrote in 1926 \cite{fisher1992arrangement}: \begin{quote} ``Personally, the writer prefers to set a low standard of significance at the 5 per cent point, and ignore entirely all results which fail to reach this level.'' \end{quote} In other words, Fisher considered the familiar 5\% level to be quite liberal and recommended that results that fail to reach even that level can be safely ignored. Now, more than 90 years later, Fisher's advice to apply the ``significance filter'' is widely followed. Recently, Barnett and Wren \cite{barnett2019examination} collected over 968,000 confidence intervals extracted from abstracts and over 350,000 intervals extracted from the full-text of papers published in Medline (PubMed) from 1976 to 2019. We converted these to $z$-values and their distribution is shown in Figure \ref{fig:z}. The under-representation of $z$-values between -2 and 2 is striking. \begin{figure}[htp] \centering{ \includegraphics[scale=0.8]{barnett_z.pdf} \caption{The distribution of more than one million $z$-values from Medline (1976--2019).}\label{fig:z} } \end{figure} As time and resources are always limited, it certainly makes sense to focus on significant results to avoid chasing noise. However, there is a problematic side-effect; considering only results that have reached statistical significance leads to overestimation \cite{ioannidis2008most}. This is sometimes called the ``winner's curse''. Moreover, it has been demonstrated informally, i.e.\ by simulation, that the winner's curse is especially severe when the power is low \cite{ioannidis2008most},\cite{gelman2014beyond}. Here, we provide the first formal proof of this important fact. As it turns out, low power is very common in the biomedical sciences \cite{button2013power},\cite{dumas2017low}. In particular, so-called pilot studies often have extremely low power. When such a study yields a significant result, the effect is likely grossly overestimated. Unfortunately, effect estimates from significant pilot studies are often used to inform the sample size calculation of a larger trial \cite{leon2011role},\cite{gelman2014beyond}. Low power also occurs when some correction is used to adjust for multiple comparisons. Such corrections are especially severe in genomics research, and the resulting overestimation of effects is well known \cite{goring2001large}. The recent suggestion to lower the significance level to improve reproducibility \cite{benjamin2018redefine} also reduces power, and therefore may backfire by aggravating the winner's curse \cite{mcshane2019abandon}. While the winner's curse is a relatively well known phenomenon, mathematical results are lacking. In the first part of this paper, we study the winner's curse both the frequentist point of view. We prove that the relative bias in the magnitude is a decreasing function of the power. We also examine the effect of the significance filter on the coverage of confidence intervals and find it results in undercoverage when the power is less than 50\%. In the second part of the paper, we study the significance filter from the Bayesian perspective. We conclude that it is necessary to apply shrinkage. We end the paper with a short discussion. \section{The frequentist perspective} Suppose that $b$ is a normally distributed, unbiased estimator of $\beta$ with standard error $\se>0$. We have in mind that $\beta$ is some regression coefficient such as a difference of means, a slope, a log odds ratio or log hazard ratio, and we shall sometimes refer to $\beta$ as the ``effect''. \subsection{Bias of the magnitude} By Jensen's inequality, $|b|$ is positively biased for $|\beta|$. Indeed, given $\beta$, $|b|$ has the folded normal distribution with mean \begin{equation} \E( |b| \mid \se, \beta)= |\beta| + \sqrt{\frac{2}{\pi}} \se\ e^{-\beta^2/2\se^2} - 2 |\beta| \Phi\left( - \frac{|\beta|} {\se} \right). \end{equation} \begin{proposition}\label{prop:bias} The bias $\E( |b| \mid \se, \beta) - |\beta|$ is positive for all $\se$ and $\beta$. Moreover, it is decreasing in $|\beta|$ and increasing in $\se$. \end{proposition} \noindent The proposition asserts that in low powered studies (small effects and large standard errors), the magnitude of the effect tends to be overestimated. For fixed $\se$, the bias $\E( |b| \mid \se, \beta) - |\beta|$ is maximal at $\beta=0$ where it is equal to $\sqrt{2/\pi}\, \se \approx 0.8\, \se$. Importantly, the bias in the magnitude becomes even larger if we condition on $|b|$ exceeding some threshold. This ``significance filter'' happens when journals preferentially accept results that are statistically significant (i.e.\ $|b|>1.96 \se$) but {\em also} when authors or readers choose to focus on such promising results as per Fisher's advice. We have the following extension of Proposition 1. \begin{theorem} The conditional bias $\E( |b| \mid \se, \beta, |b|/\se>c) - |\beta|$ is positive for all $\se$ and $\beta$. Moreover, it is decreasing in $|\beta|$ and increasing in $\se$ and $c$. \end{theorem} \noindent We define the {\it relative} conditional bias as $$\frac{\E( |b| \mid \se, \beta, |b|/\se>c) - |\beta|}{|\beta|}$$ and the exaggeration ratio or type M error \cite{gelman2014beyond} as $\E( |b| \mid \se, \beta, |b|>c) /|\beta|$. \begin{corollary} The relative conditional bias is positive and and the exaggeration factor is greater than 1. Both depend on $\beta$ and $\se$ only through the signal-to-noise ratio (SNR) $|\beta|/\se$. Both quantities are decreasing in the SNR and increasing in $c$. \end{corollary} We illustrate this result in Figure \ref{fig:m}. Now the power for two-sided testing of $H_0:\beta=0$ at level 5\% is $$P(|b|>1.96\, \se \mid \beta,\se) = \Phi(\SNR-1.96) + 1 - \Phi(\SNR+1.96),$$ which is a strictly increasing function of the SNR. Hence, the relative conditional bias and the exaggeration factor are decreasing functions of the power, as was already noted on the basis of simulation in \cite{ioannidis2008most} and \cite{gelman2014beyond}. \begin{figure}[htp] \centering{ \includegraphics[scale=0.8]{exaggeration.pdf} \caption{The exaggeration factor as a function of the SNR and the power, when conditioning on significance at the 5\% level ($c=1.96$).}\label{fig:m} } \end{figure} \subsection{Coverage} The significance filter also has consequences for the coverage of confidence intervals. We start by recalling their definition. Suppose a random variable $X$ is distributed according to some distribution $f_\theta$. A $(1-\alpha) \times 100\%$ confidence set $S(X)$ is a random subset of the parameter space such that $$P(\theta \in S(X) \mid \theta)=1-\alpha,$$ for all $\theta$ \cite{lehmann2006testing}. A negatively biased semi-relevant (or recognizable) set $R$ is a subset of the sample space such that $$P(\theta \in S(X) \mid \theta, X \in R)<1-\alpha,$$ for all $\theta$ . It is quite problematic if such a set $R$ exists, for is it still reasonable to report $S(X)$ with $(1-\alpha) \times 100\%$ confidence, after the event $X \in R$ has been observed? Semi-relevant sets have been constructed in various situations, most notably in case of the standard one-sample $t$-interval \cite{lehmann2006testing}. Lehmann \cite{lehmann2006testing} called the existence of certain relevant sets ``an embarrassment to confidence theory''. Now suppose $b$ is normally distributed with mean $\beta$ and known standard deviation $\se$. If we define $$S(b)=\{ \beta : |b-\beta|/\se < z_{1-\alpha/2} \}$$ where $z_{1-\alpha/2}$ is the $1-\alpha/2$ quantile of the standard normal distribution, then we have the following confidence statement $$P(\beta \in S(b) \mid \beta,\se) = P(|b-\beta|/\se < z_{1-\alpha/2} \mid \beta,\se)=1-\alpha,$$ for all $0 < \alpha < 1$, $\beta$ and $\se>0$. Lehmann \cite{lehmann2006testing} shows that in this particular setting, there do not exist any negatively biased semi-relevant sets. This is certainly reassuring. However, we if $c>0$, then the conditional coverage $$P(|b-\beta|/ \se < z_{1-\alpha/2} \mid \beta, \se, |b|/\se>c)$$ depends on $\beta$ and $\se$. This dependence is not simple. For instance, it is {\em not} monotone in $\beta$. We do have the following Theorem. \begin{theorem} Suppose $b$ is normally distributed with mean $\beta$ and standard deviation $\se$. If the SNR $|\beta|/\se$ is less than $z=z_{1-\alpha/2}$ then \begin{equation} P(|b-\beta| / \se< z \mid \beta, \se, |b|/\se>z) < P(|b-\beta| / \se< z \mid \beta, \se) =1-\alpha. \end{equation} \end{theorem} Note that if the SNR is equal to $z_{1-\alpha/2}$, then the power for testing $H_0 : \beta = 0$ at level $\alpha$ is slightly more than 50\%. So the Theorem implies that if we have a significant result while the power is 50\% or less, then the confidence interval will not reach its nominal coverage. The result is quite sharp. By inspecting the proof, we can see that if the SNR is slightly larger than $z_{1-\alpha/2}$ then the conditional coverage {\em exceeds} the nominal (unconditional) coverage. \section{The Bayesian Perspective} Bayesian inference is valid conditionally on the data, and so the significance filter should not pose any difficulties. On the other hand, Bayesian estimators are naturally biased. In this section we compare the performance of the unbiased estimator $b$ and the Bayes estimator. Let us assume that $\beta$ has a normal prior distribution with mean 0 and known standard deviation $\tau >0$. The conditional distribution of $\beta$ given $b$ is normal with mean $b^*=\tau^2 b/(\se^2 + \tau^2)$ and variance $v=\se^2\tau^2/(\se^2 + \tau^2)$. We will write $s=\sqrt{v}$. Note that $b^*$ is the Bayes estimator (under squared error loss) of $\beta$. Clearly, $|b^*|<|b|$ and for that reason $b^*$ is called a shrinkage estimator. We can evaluate $b$ and $b^*$ as estimators of $\beta$ conditionally on the parameter and averaged over the distribution of the data, which is the frequentist point of view. Alternatively, we can condition on the data and average over the distribution of the parameter, which is the Bayesian point of view. We have the following nicely symmetric situation, where we consider $\se$ and $\tau$ to be fixed and known. \begin{align} \E(b - \beta \mid \beta) &= 0 &\text{and}\quad \E(b^* - \beta \mid \beta) &= -\frac{\se^2}{\se^2 + \tau^2} \beta \\ \E(b - \beta \mid b) &= \frac{\se^2}{\se^2 + \tau^2}b &\text{and} \quad \E(b^* - \beta \mid b) &= 0 \end{align} So, from the frequentist point of view, $b$ is unbiased for $\beta$ and $b^*$ is biased. However, from the Bayesian point of view, it is the other way around! \subsection{Bias of the magnitude} Now, if we are interested in the magnitude of $\beta$, then we could take the posterior mean of $|\beta|$ as an estimator. However, it is still relevant to evaluate the performance of $|b^*|$ as an estimator of $|\beta|$ from the Bayesian point of view. Conditionally on $s$ and $b^*$, $\beta$ has the normal distribution with mean $b^*$ and standard deviation $s$ and hence $|\beta|$ has the folded normal distribution. Similarly to Proposition 1, we have the following. \begin{proposition} The difference $\E( |\beta| \mid s, b^*) - |b^*|$ is positive. It is decreasing in $|b^*|$ and increasing in $s$. Moreover, the difference vanishes as $|b^*|$ tends to infinity. \end{proposition} \noindent So, conditionally on the data, $|b^*|$ underestimates $|\beta|$ on average, but the difference disappears if we focus on large or significant effects. So now the significance filter actually {\em reduces} the bias in the magnitude! In other words, shrinkage lifts the winner's curse. \bigskip \noindent So far, we have conditioned either on the parameter or the data, and averaged over the other. However, in practice we do not keep the parameter fixed and repeat the experiment many times. We also do not keep the data fixed and vary the parameter. So, it is also relevant to consider the performance of $b$ and $b^*$ on average over the distribution of {\em both} the parameter {\em and} the data. If the distribution of the parameter represents some field of research, then this averaging will provide insight into how our statistical procedures perform when used repeatedly in that field. Under our simple model, the marginal distribution of $b$ is normal with mean zero and variance $\se^2+\tau^2$ and the marginal distribution of $b^*$ is normal with mean zero and variance $\tau^4/(\se^2+\tau^2)$. So, trivially, $\E(b)=\E(b^*)=\E(\beta)=0$. Moreover, it is easy to see that the variance of $b^*$ is less than the variance of $b$. Marginally, $|\beta|$, $|b|$ and $|b^*|$ have half-normal distributions with means \begin{equation} \E \left| b^* \right| =\frac{\tau^2}{\sqrt{\se^2 + \tau^2}} \sqrt{\frac{2}{\pi}}, \quad \E|\beta| = \tau \sqrt{\frac{2}{\pi}}, \quad \E|b| = \sqrt{\se^2 + \tau^2} \sqrt{\frac{2}{\pi}} \end{equation} It is easy to see that \begin{equation} \E \left| b^* \right| < \E |\beta| < \E|b|. \end{equation} Negative bias is more conservative than positive bias, and that may be preferable in many situations. It is interesting to note that the factor by which $|b|$ {\em over}estimates $|\beta|$ is the same as the factor by which $|b^*|$ {\em under}estimates it. That is, \begin{equation} \frac{\E|b|}{ \E|\beta|} = \frac{ \E|\beta|}{\E|b^*|} = \frac{\sqrt{\se^2 + \tau^2}}{\tau} . \end{equation} Moreover, the following proposition says that the bias of $|b^*|$ is smaller (on average) than the bias of $|b|$. \begin{proposition} Suppose $\beta$ has a normal prior distribution with mean 0 and standard deviation $\tau >0$. Suppose that conditionally on $\beta$, $b$ is normally distributed with mean $\beta$ standard error $\se>0$. Let $b^*=\E(\beta \mid b)$, then \begin{equation} \E( |b| - |\beta|) > \E(|\beta| - |b^*|). \end{equation} \end{proposition} \noindent Most importantly, however, while the bias of $|b|$ increases as we condition on $|b|$ exceeding some threshold, the bias of $|b^*|$ vanishes! \begin{theorem} As $c$ goes to infinity, $\E(|b^*| -|\beta| \mid |b|>c)$ vanishes. \end{theorem} \subsection{Coverage} We now return to the coverage issue we discussed in section 2.2. It might seem that Theorem 2 is not much of a problem in practice because conditional on a significant result, the power is unlikely to be small. But such an argument would depend on the (prior) distribution of the signal-to-noise ratio $|\beta|/\se$. We have the following result. \begin{theorem} Suppose $\beta$ and $\se$ are distributed such that the SNR $|\beta|/\se$ has a decreasing density and $|\beta|/\se$ and $\se$ are independent. Also suppose that conditionally on $\beta$ and $\se$, $b$ is normally distributed with mean $\beta$ and standard deviation $\se$. For every $0<\alpha < 1$ \begin{equation} P(|b-\beta| < z_{1-\alpha/2}\se \mid |b|/\se>c) < 1-\alpha. \end{equation} \end{theorem} This result suggest that across research fields where of the SNR has a decreasing density, confidence interval undercover on average. But how realistic is it to assume such a decreasing density? Clearly, it would imply a decreasing density of the absolute $z$-value, and this is certainly not the case in Figure \ref{fig:z}. However we believe that this is due to selective reporting. We have made an effort to collect an unselected sample of $z$-values as follows. It is a fairly common practice in the life sciences to build multivariate regression models by ``univariable screening''. First, the researchers run a number of univariable regressions for all predictors that they believe could have an important effect. Next, those predictors with a $p$-value below some threshold are selected for the multivariate model. While this approach is statistically unsound, we believe that the univariable regressions should be largely unaffected by selection on significance, simply because that selection is still to be done. For further details, we refer to \cite{van2019default}. We do note that in that article, we discarded $p$-values below 0.001, but these are included here. We have collected 732 absolute $z$-values from 51 recent articles from Medline. We show the distribution in Figure \ref{fig:z2} which suggest a decreasing distribution of the absolute $z$-values, which implies a that the distribution of the SNR is decreasing as well. \begin{figure}[htp] \centering{ \includegraphics[scale=0.8]{medline_z.pdf} \caption{The distribution of 732 absolute $z$-values from Medline. Here we made an effort to avoid the significance filter.}\label{fig:z2} } \end{figure} \section{Discussion} In this paper we have considered the generic situation where we have an unbiased, normally distributed estimator $b$ of a parameter $\beta$, with known standard error $\se$. Frequentist properties, such as the unbiasedness of $b$ and the coverage of the confidence interval are only meaningful before the data have been observed. Once the data are in, they become meaningless since $b$ is just some fixed number and the confidence interval either covers $\beta$ or it does not. Nothing more can be said without specifying a (prior) distribution for $\beta$. However, suppose we condition not on $(b,\se)$ but only on the event $|b|>1.96\, \se$. That is, we condition on statistical significance at the 5\% level. Now $b$ is still random and we can talk about bias and coverage. Conditionally on significance, $b$ is biased away from zero. This tendency to overestimate the magnitude of significant effects is sometimes called the ``winner's curse''. It is especially severe when the signal-to-noise ratio $|\beta|/\se$ is low. Also, if the SNR is low, then conditionally on significance the confidence interval will undercover. By providing mathematical proofs of these facts, we hope to contribute to the awareness of these very serious problems. The goal of hypothesis testing is to try to avoid chasing noise, which is perfectly reasonable. However, the consequence of focusing on significant results is that all the nice frequentist properties no longer hold. Many proposals have been made to address this issue. From a frequentist point of view, one could condition throughout on statistical significance. See, for example, \cite{ghosh2008estimating} and references therein. Alternatively, one can take a Bayesian approach, such as proposed by \cite{xu2011bayesian} and ourselves \cite{van2019default}. Of course, the Bayesian approach relies on correct specification of the prior. Shrinkage is often viewed as a method to achieve a lower mean squared error by reducing the variance at the expense of increasing the bias. Our most important point is that it is necessary to apply shrinkage to {\em reduce} the bias that results from focusing on interesting results.
{'timestamp': '2020-09-22T02:17:00', 'yymm': '2009', 'arxiv_id': '2009.09440', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09440'}
arxiv
\section{Introduction} \label{sec:introduction} Knowledge-grounded conversation generation aims at generating informative responses based on both discourse context and external knowledge \cite{ghazvininejad2018knowledge,zhou-2018-commensense}, where selecting appropriate knowledge is critical to the success of the task. Existing knowledge selection models generally fall into two types. One type is solely based on the context \cite{postks-ijcai,zhang-2019-improving,meng-2020-refnet,ren-2020-glks}, which we call \textbf{non-sequential selection} because knowledge selection at different turns is independent. The other type sequentially selects knowledge additionally conditioned on previously selected knowledge \cite{Kim2020Sequential}, which we call \textbf{sequential selection}. As shown in \citet{Kim2020Sequential}, such a sequential way can better simulate a multi-turn dialog and facilitate knowledge selection in later turns. \begin{figure}[t] \centering \includegraphics[width=0.9\linewidth]{intro_example.pdf} \caption{An example of difference-aware knowledge selection. The {\color{blue} \textbf{blue} $\bm{\triangle}$} denotes that the corresponding knowledge has little difference from or is identical to the previously selected one, and selecting it may lead to \textit{repetitive} responses. The {\color{red} \textbf{red} $\bm{\times}$} denotes that the difference is too large, and selecting it could make the response \textit{incoherent} with the context. } \label{fig:intro_example} \end{figure} However, the \textbf{difference} between selected knowledge at different turns has been largely neglected in prior studies, while it usually provides potential clues to knowledge selection. Figure \ref{fig:intro_example} illustrates an example, where the dialog system selects one from candidate knowledge sentences (all relevant to the context) at the 2$^\text{nd}$ turn. Selecting the knowledge that has little difference from or even is identical to the previously selected one (like the 1$^\text{st}$ knowledge) may lead to generating \textit{repetitive} responses, while too large difference (like the 3$^\text{rd}$ knowledge) would make the response \textit{incoherent} with the context. As a result, the dialog system should avoid the knowledge which differs from the previously selected ones either too little or too largely, and instead select an appropriate knowledge sentence (the 2$^\text{nd}$ one) which can make the conversation flow smoothly and naturally. We thus propose DiffKS, a novel \textbf{Diff}erence-aware \textbf{K}nowledge \textbf{S}election method for knowledge-grounded conversation generation. It first computes the difference between the candidate knowledge sentences provided at the current turn and the previously selected knowledge. Then, in the two models we devise, the differential information is fused with or disentangled from the contextual information to facilitate final knowledge selection. Automatic and human evaluation on two widely-used benchmarks shows that our method is significantly superior over the state-of-the-art baselines and it can select knowledge more accurately and generate more informative responses. Our contributions are summarized as follows: \begin{itemize} \item We propose to explicitly model and utilize the differential information between selected knowledge in multi-turn knowledge-grounded conversation for knowledge selection. We further devise two variants where the differential information is fused with or disentangled from the context information during knowledge selection. \item Automatic, human observational, and human interactive evaluations show that our method significantly outperforms strong baselines in terms of knowledge selection and can generate more informative responses. \end{itemize} \section{Related Work} \label{sec:related_work} \subsection{Knowledge-grounded Dialog Generation} Recently, a variety of neural models have been proposed to facilitate knowledge-grounded conversation generation \cite{zhu2017flexible,young-2018-aaai,zhou-2018-commensense,liu-etal-2018-knowledge}. The research topic is also greatly advanced by many corpora \cite{zhou-etal-2018-dataset,moghe-etal-2018-towards,dinan2018wizard,Gopalakrishnan2019,moon-etal-2019-opendialkg,tuan-etal-2019-dykgchat,wu-etal-2019-proactive,zhou-etal-2020-kdconv}. As surveyed in \citet{huang-etal-2019-challenges}, existing studies have been mainly devoted to addressing two research problems: (1) \textit{\textbf{knowledge selection}}: selecting appropriate knowledge given the dialog context and previously selected knowledge \cite{postks-ijcai,zhang-2019-improving,meng-2020-refnet,ren-2020-glks,Kim2020Sequential}; and (2) \textit{\textbf{knowledge-aware generation}}: injecting the required knowledge to generate meaningful and informative responses \cite{ghazvininejad2018knowledge,zhou-2018-commensense,li-etal-2019-incremental,qin-etal-2019-conversing,yavuz-etal-2019-deepcopy,Zhao2020Low-Resource}. Since selecting the appropriate knowledge is a precursor to the success of knowledge grounded dialog systems, we focus on the \textit{\textbf{knowledge selection}} problem in this paper. \subsection{Non-sequential Knowledge Selection} The non-sequential selection models capture the relationship between the current context and background knowledge \cite{postks-ijcai,zhang-2019-improving,meng-2020-refnet,ren-2020-glks}. For instance, PostKS \cite{postks-ijcai} estimates a posterior distribution over candidate knowledge sentences, which is based on both the context and the golden response, and only uses the context to estimate a prior distribution as an approximation of the posterior during inference. Besides, \citet{zhang-2019-improving,meng-2020-refnet,ren-2020-glks} also belong to non-sequential selection models. Different from our work and \citet{postks-ijcai,Kim2020Sequential} that select knowledge from \textit{candidate knowledge sentences}, their methods are devised for selecting important text spans or fragments from the \textit{background knowledge document} that will be used in generation. Therefore these works have a different task setting from ours. \subsection{Sequential Knowledge Selection} The sequential selection models additionally make use of previously selected knowledge to facilitate knowledge selection \cite{Kim2020Sequential}. For instance, \citet{Kim2020Sequential} propose a Sequential Latent Knowledge Selection (SLKS) model. It keeps track of the hidden states of dialog history and previously selected knowledge sentences. Our method is parallel to SLKS because we also utilize the previously selected knowledge. However, we explicitly compute the difference between knowledge selected at different turns, while SLKS only encodes the already selected knowledge in an implicit way. In addition, recently there emerge a number of works that propose RL-based models to select a path in \textit{structured knowledge graph (KG)} \cite{xu-2020-aaai,xu-2020-acl}, which also select knowledge in a sequential way. While our method is designed to ground the conversation to \textit{unstructured knowledge text}, we will leave as future work the application of our method to such KG-grounded dialog generation tasks \cite{wu-etal-2019-proactive,moon-etal-2019-opendialkg,zhou-etal-2020-kdconv}. \section{Methodology} \subsection{Task Formulation} In a multi-turn dialogue, given a post and a sequence of knowledge sentences at each turn, our goal is to select appropriate knowledge and generate a proper response to the current context. Formally, the post at the $\tau$-th turn is a sequence of tokens $\mathrm{x}^{\tau} = \left( \mathrm{x}^{\tau}_1, \dots, \mathrm{x}^{\tau}_{\left| \mathrm{x}^{\tau} \right|} \right)$, and the response to be generated is $\mathrm{y}^{\tau} = \left( \mathrm{y}^{\tau}_1, \dots, \mathrm{y}^{\tau}_{\left| \mathrm{y}^{\tau} \right|} \right)$. The background knowledge $\mathrm{k}^{\tau} = \left( \mathrm{k}^{\tau}_1, \dots, \mathrm{k}^{\tau}_{\left| \mathrm{k}^{\tau} \right|} \right) $ contains a sequence of knowledge sentences provided at the $\tau$-th turn. For each $i$, $\mathrm{k}^{\tau}_{i} = \left( \mathrm{k}^{\tau}_{i,1}, \dots, \mathrm{k}^{\tau}_{i,\left| \mathrm{k}_{i}^{\tau} \right|} \right) $ is a sequence of tokens in the $i$-th sentence. Note that under the setting of multi-turn dialogue, we use $\mathrm{c}^{\tau} \triangleq \left[ \mathrm{x}^{\tau-1}; \mathrm{y}^{\tau-1}; \mathrm{x}^{\tau} \right]$ as the given context at the $\tau$-th turn, where $[\cdot; \cdot]$ denotes concatenation. In Section \ref{sec:encoder} and \ref{sec:decoder}, we will omit the superscript $\tau$ for simplicity. \subsection{Encoders} \label{sec:encoder} The context is encoded with a bidirectional GRU \cite{cho-etal-2014-learning}: \begin{align} \left({\bm{h}}_{c,1}, \dots, {\bm{h}}_{c,\left| \mathrm{c} \right|} \right) = {\bm{BiGRU}}_c \left( \mathrm{c} \right), \end{align} where ${\bm{h}}_{c,i} = \left[ \overrightarrow{\bm{h}}_{c,i}; \overleftarrow{\bm{h}}_{c,i} \right]$. We use $\bm{h}_{c} \triangleq \left[ \overrightarrow{\bm{h}}_{c,\left| \mathrm{c} \right|} ; \overleftarrow{\bm{h}}_{c,1} \right]$ as the context representation. Similarly, the knowledge sentences are encoded with another BiGRU: \begin{align} \left(\bm{h}_{k,i,1}, \dots, \bm{h}_{k,i,\left|\mathrm{k}_{i}\right|} \right) = {\bm{BiGRU}}_{k} \left( \mathrm{k}_{i} \right). \end{align} We use $\bm{h}_{k,i} \triangleq \left[ \overrightarrow{\bm{h}}_{k,i,\left|\mathrm{k}_{i}\right|} ; \overleftarrow{\bm{h}}_{k,i,1} \right]$ as the representation of $\mathrm{k}_{i}$. Specifically, we add an empty sentence $\mathrm{k}_0$ that indicates \textit{no knowledge being used}. \subsection{Difference-aware Knowledge Selection} In order to select proper knowledge, our model gets aware of the difference between the current candidate knowledge sentences and the previously selected knowledge. To make full use of the contextual dependency and relevance between the knowledge sentences\footnote{ For example, the knowledge sentences may be extracted from a document in order, or about the same topic like in Wizard of Wikipedia \cite{dinan2018wizard}. }, our model first compares candidate knowledge sentences to explore their correlations, where the comparison is conducted using BiGRU: \begin{align} \left({\bm{r}}^{\tau}_{0}, \dots, {\bm{r}}^{\tau}_{ \left| {\mathrm{k}}^{\tau} \right| } \right)\! =\! \bm{BiGRU}\! \left( { \bm{h}}^{\tau}_{k,0}, \dots, { \bm{h}}^{\tau}_{k, \left| {\mathrm{k}}^{\tau} \right| } \right)\!, \end{align} \begin{figure}[t] \centering \includegraphics[width=\linewidth]{model_figure.pdf} \caption{An overview of model structure. } \label{model_figure} \end{figure} Then, the model computes the difference of each knowledge sentence $\bm{r}^{\tau}_i$ from the knowledge selected in the previous $M$ turns $\left\{ \bm{h}_{k}^{\tau-m} \right\}_{m=1}^{M}$: \begin{align} \bm{o}^{\tau}_i &= \sum_{m=1}^M \lambda_m \bm{Diff} \left( \bm{h}_{k}^{\tau-m}, \bm{r}^{\tau}_i \right), \label{equ:diff_M} \\ & \sum_{m=1}^M \lambda_m = 1,\ \ \forall m,\lambda_m \ge 0 \end{align} Inspired by \citet{wang-etal-2018-co}, we define the difference as follow: \begin{align} \bm{Diff} \left( \bm{x}, \bm{y} \right) \triangleq \bm{F}\left( \left[ \bm{x} - \bm{y} ; \bm{x} \odot \bm{y} \right] \right), \end{align} where $\bm{F}$ is a fully connected layer activated with $\mathrm{tanh}$. Note that at the first turn, we set $\bm{o}^{1}_i$ to a zero vector because there is no differential information to be obtained. For that intuitively the knowledge selected in the previous turn has the largest impact and most clues for the current selection, we studied the simplest case where $M=1$, saying $\bm{o}^{\tau}_i = \bm{Diff} \left( \bm{h}_{k}^{\tau-1}, \bm{r}^{\tau}_i \right)$, in the main experiments for simplicity. Next, we introduce two variants where the differential information $\left\{\bm{o}^{\tau}_i\right\}_{i=0}^{\left| {\mathrm{k}}^{\tau} \right|}$ is fused with or disentangled from the contextual information during knowledge selection. \subsubsection{Fused Selection} \label{sec:fused_selection} \begin{figure}[ht] \centering \includegraphics[width=0.7\linewidth]{fused.pdf} \caption{Fused Selection module. The contextual information and the differential information are \textit{fused} together to calculate the final knowledge selection distribution.} \label{fig:fused_selection} \end{figure} The Fused Selection module is shown in Figure \ref{fig:fused_selection}. Directly taking $\bm{o}^{\tau}_i$ as an extra feature of $\mathrm{k}^{\tau}_i$, it uses the context $\bm{h}_{c}^{\tau}$ to query the difference-enhanced knowledge sentences: \begin{align} \beta^{\tau}_{i}\! =\! \bm{v}^\mathrm{T}\tanh\left(\bm{W}_{\mathrm{que}} \bm{h}_{c}^{\tau}\! +\! \bm{W}_{\mathrm{key}} \left[ \bm{h}_{k,i}^{\tau} ; \bm{o}^{\tau}_i \right] \right)\!, \end{align} where $\bm{v}$, $\bm{W}_{\mathrm{que}}$ and $\bm{W}_{\mathrm{key}}$ are trainable parameters. However, it is difficult to distinguish the respective contributions of contextual and differential information to knowledge selection in the above fused variant. We thus devise the disentangled variant as following, where the roles of two types of information are separated, which makes it feasible to conduct ablation study. \subsubsection{Disentangled Selection} \begin{figure}[ht] \centering \includegraphics[width=\linewidth]{disentangled.pdf} \caption{Disentangled Selection module. The contextual information and the differential information are \textit{disentangled} to calculate two separate knowledge selection distributions in two independent selectors.} \label{fig:disentangled_selection} \end{figure} Figure \ref{fig:disentangled_selection} gives an overview of the Disentangled Selection module. It has two independent selectors. The \textbf{Contextual Selector} simply looks for the knowledge sentence that has high relevance to the context, just like most existing knowledge selection models do. It only takes advantage of the context $\bm{h}_{c}^{\tau}$ to match each knowledge sentence itself $\bm{h}_{k,i}^{\tau}$, obtaining a context-aware selection distribution: \begin{align} \beta^{\tau}_{\mathrm{Ctx},i} = \left( \bm{h}_{c}^{\tau} \right)^{\mathrm{T}} \bm{h}_{k,i}^{\tau}. \end{align} In contrast, the \textbf{Differential Selector} focuses on predicting the next knowledge to be selected conditioned on the previously selected knowledge and differential information, which reveals the process of knowledge transition. Without the access to the contextual information, the Differential Selector views the previously selected knowledge $\bm{h}_{k}^{\tau-1}$ as query, and the knowledge sentence $\bm{r}^{\tau}_i$ with its differential information $\bm{o}^{\tau}_i$ as key, to estimate a difference-aware selection distribution: \begin{align} \beta^{\tau}_{\mathrm{Diff}, i} = \bm{v}^\mathrm{T}\tanh\left(\bm{W}_{\mathrm{que}} \bm{h}_{k}^{\tau-1} + \bm{W}_{\mathrm{key}} \left[ \bm{r}_i^{\tau} ; \bm{o}^{\tau}_i \right] \right), \end{align} where $\bm{v}$, $\bm{W}_{\mathrm{que}}$ and $\bm{W}_{\mathrm{key}}$ are trainable parameters. The final selection distribution is the summation of the distributions of two selectors: \begin{align} \beta^{\tau}_i = \beta^{\tau}_{\mathrm{Ctx}, i} + \beta^{\tau}_{\mathrm{Diff}, i}. \label{equ:addition} \end{align} Note that the Differential Selector relies on the previously selected knowledge, thus at the first turn, we set $\beta^{\tau}_{\mathrm{Diff}, i}$ to 0 for each $i$. \subsubsection{Selecting Knowledge} Finally, either adopting the Fused or Disentangled Selection module, the model selects the knowledge sentence with the highest attention score, and uses its representation for further generation\footnote{The model is trained with teacher forcing, where the golden selected knowledge $\bm{h}^{\tau}_{k,{i^{\tau}}^*}$ is used during training.}: \begin{align} \alpha^{\tau}_i & = \mathrm{softmax}_i \left( \beta^{\tau}_i \right), \\ \widehat{i}^{\tau} = & \mathop{\arg\max}_i \alpha^{\tau}_i ,\ \bm{h}_{k}^{\tau} \triangleq \bm{h}^{\tau}_{k,\widehat{i}^{\tau}}. \end{align} \subsection{Decoder} \label{sec:decoder} The decoding state is updated by a GRU: \begin{align} \bm{s}_t = \bm{GRU}_D &\left( \bm{s}_{t-1}, \left[ \bm{e}\left(\mathrm{y}_{t-1}\right); \bm{h}_{k} \right] \right), \\ \bm{s}_0 = \bm{W}_D & \left[ \bm{h}_{c}; \bm{h}_{k} \right]+\bm{b}_D, \end{align} where $\bm{W}_D$ and $\bm{b}_D$ are trainable parameters, and $\bm{e}\left(\mathrm{y}_{t-1}\right)$ denotes the embedding of the word $\mathrm{y}_{t-1}$ generated in the last time step. Then, the decoder outputs the generation probability over the vocabulary (without normalization): \begin{align} {\phi}^G({y}_t=\mathrm{w}) = \mathbf{w}^\mathrm{T}\left(\bm{W}_G\bm{s}_t + \bm{b}_G\right), \end{align} where $\bm{W}_G$ and $\bm{b}_G$ are trainable parameters, and $\mathbf{w}$ is the one-hot vector of the word $\mathrm{w}$. Meanwhile, a copy mechanism \cite{gu-etal-2016-incorporating} is adopted to output additional copy probability of the words in the selected knowledge sentence $\mathrm{k}_{\widehat{i}}$ (without normalization): \begin{align} \phi^C \left( {y}_t = \mathrm{w} \right) = \sum_{ j: \mathrm{k}_{\widehat{i},j} = \mathrm{w} } \left( \bm{s}_t \right)^\mathrm{T} \bm{H} \left( \bm{h}_{k,\widehat{i}, j} \right), \end{align} where $\bm{H}$ is a fully connected layer activated with $\mathrm{tanh}$. The final probability distribution is computed as follows: \begin{align} \mathcal{P}\left( {y}_t\! =\! \mathrm{w} \right)\! =\! \frac{1}{Z} \left( \mathrm{e}^{ \phi^G \left( {y}_t = \mathrm{w} \right) }\! +\! \mathrm{e}^{ \phi^C \left( {y}_t = \mathrm{w} \right) } \right)\!, \end{align} where $Z$ is the normalization term. Then we select the word from vocabulary with the highest probability, saying: $\mathrm{y}_t = \mathop{\arg\max}_{\mathrm{w}} \mathcal{P}({y}_t = \mathrm{w})$. \subsection{Loss} The negative log likelihood loss is adopted: \begin{align} \mathcal{L}_\mathrm{NLL} = - \sum_{\tau=1}^{T} \sum_{t=1}^{ \left| \mathrm{y}^{\tau} \right|} \log \mathcal{P} \left( {\mathrm{y}^{\tau}_{t}}^* \right), \end{align} where ${\mathrm{y}^{\tau}_{t}}^*$ denotes the $t$-th word in the golden response at the $\tau$-th turn and $T$ is the length of turns in the whole dialogue. We also add supervision on the final knowledge selection distribution: \begin{align} \mathcal{L}_\mathrm{KS} = - \sum_{\tau=1}^{T} \log \alpha^{\tau}_{{i^{\tau}}^*}, \end{align} where ${i^{\tau}}^*$ denotes the index of the golden selected knowledge sentence at the $\tau$-th turn. The total loss is their summation: \begin{align} \mathcal{L} = \mathcal{L}_\mathrm{NLL} + \lambda \mathcal{L}_\mathrm{KS}. \end{align} where we set $\lambda=1$ in our experiments. \section{Experiments} \subsection{Datasets} \label{sec:datasets} We evaluated our method on two widely used benchmarks: Wizard of Wikipedia (WoW) \cite{dinan2018wizard}, and Holl-E \cite{moghe-etal-2018-towards}. WoW \cite{dinan2018wizard} contains multi-turn knowledge-grounded conversations, collected by wizard-apprentice mode. Each utterance of the wizard is grounded to a selected knowledge sentence, or indicated by that no knowledge is used. The dialogues are split into 18,430/1,948/965/968 for Train/Dev/Test Seen/Test Unseen respectively, with 4 turns per dialogue and 61 provided knowledge sentences per turn on average. Note that the test data is split into \textit{Test Seen} (in-domain) and \textit{Test Unseen} (out-of-domain), where Test Unseen contains topics that are never seen in Train or Dev. Holl-E \cite{moghe-etal-2018-towards} contains conversations in which one speaker is strictly instructed to give utterances by copying or modifying sentences from the given background document. Similarly, each utterance is annotated regarding the selected knowledge. Following \citet{Kim2020Sequential}, we tokenized the background document into sentences, and meanwhile ensured that the annotated span is included in a whole sentence. The dialogues are split into 7,211/930/913 for Train/Dev/Test respectively, with 5 turns per dialogue and 60 provided knowledge sentences per turn on average. \subsection{Baselines} We compared our models with the following typical knowledge selection baselines: \noindent \textbf{MemNet} \cite{ghazvininejad2018knowledge} stores knowledge sentences in its memory units, which are attentively read during decoding. We also evaluated a variant (\textbf{MemNet+}) where knowledge selection is supervised by the same $\mathcal{L}_{\mathrm{KS}}$ as our models do. \noindent \textbf{PostKS} \cite{postks-ijcai} estimates two knowledge selection distributions, where the prior distribution is based on only the context and the posterior one on both the context and the golden response, and their KL divergence is minimized during training. The knowledge selection of PostKS is supervised by a BOW loss. We also evaluated two variants, where one uses ${\mathcal{L}_{\mathrm{KS}}}$ instead of the BOW loss to supervise knowledge selection (\textbf{PostKS+}), and the other is further equipped with copy mechanism (\textbf{PostKS++}). \noindent \textbf{SLKS} \cite{Kim2020Sequential} improves PostKS by using two separate GRUs to update the states of dialog history and previously selected knowledge sentences respectively. For fair comparison, we replaced the pretrained BERT \cite{devlin-etal-2019-bert} encoder and the Transformer \cite{transformer} decoder in SLKS with BiGRU and GRU respectively, and adopted the same copy mechanism in SLKS as in our models. \begin{table}[t] \centering \scalebox{0.8}{ \begin{tabular}{l|cccc} \toprule \textbf{Models} & \textbf{ACC} & \multicolumn{2}{c}{\textbf{BLEU-2/4}} & \textbf{ROUGE-2} \\ \midrule \multicolumn{5}{c}{\textbf{WoW Seen}} \\ \midrule \textbf{MemNet} & 13.2** & 6.6** & 1.8** & 3.2** \\ {\ \ \ \textbf{+}$\bm{\mathcal{L}_\mathrm{KS}}$} & 18.4** & 7.2** & 1.9** & 3.3** \\ \textbf{PostKS} & 13.8** & 6.9** & 1.8** & 3.2** \\ {\ \ \ \textbf{+}$\bm{\mathcal{L}_\mathrm{KS}}$} & 22.5** & 7.5** & 2.3** & 3.7** \\ {\ \ \ \ \ \ \textbf{+Copy}} & 21.9** & 9.9** & 4.5** & 5.6** \\ \textbf{SLKS} & 23.4** & 11.3 & 5.5 & 6.5 \\ \cmidrule{1-5} \textbf{DiffKS$_\text{Fus}$} & \textbf{25.5} & \textbf{11.6} & \textbf{5.7} & \textbf{6.8} \\ \textbf{DiffKS$_\text{Dis}$} & 24.7 & 11.3 & \textbf{5.7} & \textbf{6.8} \\ \midrule \multicolumn{5}{c}{\textbf{WoW Uneen}} \\ \midrule \textbf{MemNet} & 12.8** & 5.7** & 1.2** & 2.3** \\ {\ \ \ \textbf{+}$\bm{\mathcal{L}_\mathrm{KS}}$} & 15.9** & 5.9** & 1.3** & 2.3** \\ \textbf{PostKS} & 13.6** & 5.5** & 1.2** & 2.1** \\ {\ \ \ \textbf{+}$\bm{\mathcal{L}_\mathrm{KS}}$} & 15.8** & 6.6** & 1.5** & 2.6** \\ {\ \ \ \ \ \ \textbf{+Copy}} & 14.9** & 7.9** & 3.2** & 3.9** \\ \textbf{SLKS} & 14.7** & 8.7** & 3.7** & 4.6** \\ \cmidrule{1-5} \textbf{DiffKS$_\text{Fus}$} & \textbf{19.7} & \textbf{10.0} & \textbf{4.7} & \textbf{5.6} \\ \textbf{DiffKS$_\text{Dis}$} & 18.3* & 9.6 & 4.5 & 5.3 \\ \midrule \multicolumn{5}{c}{\textbf{Holl-E}} \\ \midrule \textbf{MemNet} & 5.1** & 8.0** & 4.5** & 8.9** \\ {\ \ \ \textbf{+}$\bm{\mathcal{L}_\mathrm{KS}}$} & 25.1** & 7.7** & 4.3** & 9.0** \\ \textbf{PostKS} & 6.1** & 6.9** & 3.9** & 8.6** \\ {\ \ \ \textbf{+}$\bm{\mathcal{L}_\mathrm{KS}}$} & 29.5** & 15.9** & 8.2** & 13.1** \\ {\ \ \ \ \ \ \textbf{+Copy}} & 28.0** & 26.5** & 22.4** & 23.1** \\ \textbf{SLKS} & 28.6** & 28.5** & 24.5** & 24.9* \\ \cmidrule{1-5} \textbf{DiffKS$_\text{Fus}$} & 33.0 & 29.5 & 25.5 & 25.9 \\ \textbf{DiffKS$_\text{Dis}$} & \textbf{33.5} & \textbf{29.9} & \textbf{25.9} & \textbf{26.4} \\ \bottomrule \end{tabular}% } \caption{Automatic evaluation results. The best results are in \textbf{bold}. Significance tests were conducted between the best results and other competitors, with sign test for ACC, bootstrap resampling \cite{koehn-2004-statistical} for BLEU, and Student’s t-test for ROUGE. */** indicate $p$-value $<$ 0.05/0.005 respectively.} \label{tab:automatic}% \end{table}% \subsection{Implementation Details} All the models were implemented with PyTorch \cite{paszke2017automatic}. The sentences were tokenized with NLTK \cite{bird-loper-2004-nltk}. We set the vocabulary size to 20K for WoW and 16K for Holl-E and used the 300-dimensional word embeddings initialized by GloVe \cite{pennington-etal-2014-glove} or from a standard normal distribution $\mathcal{N}(0,1)$. We applied a dropout rate of 0.5 on word embeddings. The hidden sizes were set to 200 for the encoders (totally 400 for two directions) and to 400 for the decoder. We adopted the ADAM \cite{kingma2015adam} optimizer with the initial learning rate set to 0.0005. The batch size was set to 8 dialogues. {All the models share the same hyperparameter setting} and were trained for 20 epochs on {one NVIDIA Titan Xp GPU}. The checkpoints of our reported results were selected according to BLEU-4 on the Dev sets. \subsection{Automatic Evaluation} We used several automatic metrics: \textit{\textbf{ACC}}, the accuracy of knowledge selection on the whole test set, corpus-level \textit{\textbf{BLEU-2/4}} \cite{papineni-etal-2002-bleu}, and \textit{\textbf{ROUGE-2}} \cite{lin-2004-rouge}. As shown in Table \ref{tab:automatic}\footnote{ We found in \citet{Kim2020Sequential} that BERT usually gives rise to a gain of 2-5 points in ACC, thus our results without using BERT as encoder are within a reasonable range comparing with those in the original reference. }, our method outperforms significantly all the baselines in all the metrics on three test sets (except BLEU and ROUGE on WoW Seen compared with SLKS), which indicates its superiority in selecting proper knowledge and generating informative responses. Compared to the baseline models, our models also demonstrate a stronger ability of generalization from in-domain (WoW Seen) to out-of-domain data (WoW Unseen). It is worth noting that on WoW Unseen, our DiffKS$_\text{Fus}$ obtains a higher accuracy (19.7) of knowledge selection even than the BERT-enhanced SLKS in their original paper (18.3). We also observed that DiffKS$_\text{Fus}$ performs a bit better on WoW while DiffKS$_\text{Dis}$ on Holl-E. We conjecture that it is because in Holl-E, the golden selected knowledge among different turns usually has high contextual dependency (for example, they may be continuous sentences in the document), which makes it feasible to predict the next selected knowledge simply conditioned on the differential information. \begin{table}[t] \centering \scalebox{0.75}{ \begin{tabular}{l|ccc|ccc} \toprule \multicolumn{1}{c|}{} & \multicolumn{3}{c|}{\textbf{Naturalness}} & \multicolumn{3}{c}{\textbf{Appropriateness}} \\ \multicolumn{1}{c|}{\textbf{A vs. B}} & \textbf{Win} & \textbf{Lose} & $\bm{\kappa}$ & \textbf{Win} & \textbf{Lose} & $\bm{\kappa}$ \\ \midrule \multicolumn{7}{c}{\textbf{WoW Seen}} \\ \midrule \textbf{Fus / PostKS++} & \textbf{50.3*} & 42.5 & .47 & 4\textbf{9.2*} & 43.1 & .40 \\ \textbf{Fus / SLKS} & 44.5 & 43.3 & .50 & \textbf{44.0*} & 38.7 & .48 \\ \textbf{Dis / PostKS++} & \textbf{50.6*} & 44.9 & .42 & \textbf{50.5*} & 44.4 & .38 \\ \textbf{Dis / SLKS} & 42.7 & 43.8 & .41 & 46.4 & 41.4 & .47 \\ \textbf{Fus / Dis} & 43.2 & 42.8 & .49 & 39.3 & 40.9 & .57 \\ \midrule \multicolumn{7}{c}{\textbf{WoW Unseen}} \\ \midrule \textbf{Fus / PostKS++} & \textbf{48.8*} & 43.2 & .57 & \textbf{49.3**} & 40.5 & .60 \\ \textbf{Fus / SLKS} & \textbf{47.9*} & 41.8 & .44 & \textbf{47.3*} & 40.9 & .47 \\ \textbf{Dis / PostKS++} & \textbf{52.0**} & 36.4 & .46 & \textbf{46.8*} & 39.9 & .49 \\ \textbf{Dis / SLKS} & \textbf{46.5*} & 39.7 & .45 & \textbf{47.8*} & 42.3 & .47 \\ \textbf{Fus / Dis} & 39.8 & 42.4 & .52 & 41.5 & 37.8 & .53 \\ \bottomrule \end{tabular}% } \caption{Human observational evaluation results. Ties are not shown. Significance tests were conducted with sign test. ${\kappa}$ denotes the Fleiss' Kappa which measures annotation agreement.} \label{tab:manual}% \end{table}% \subsection{Human Observational Evaluation} We conducted human observational evaluation with pair-wise comparison, where our two models were compared with PostKS++ and SLKS. 100 dialogues were respectively sampled from WoW Seen/Unseen. For each pair of dialogues generated from two models (suppose with $T$ turns), annotators from Amazon Mechanical Turk were hired to give preferences (win, lose, or tie) for each response pair of all the $T$ turns in terms of different metrics. Each pair-wise comparison of dialogues was judged by 3 curators. We adopted the following two metrics: \textit{\textbf{Naturalness}} evaluates the fluency and readability of a response. \textit{\textbf{Appropriateness}} evaluates the relevance to the context and whether a response contains appropriate knowledge information to the context. Results are shown in Table \ref{tab:manual}, where the Fleiss' Kappa \cite{fleiss1971measuring} values show almost moderate agreements ($0.4<\kappa<0.6$). Our models significantly outperform PostKS++ in both metrics, and also generally outperform SLKS in terms of Appropriateness. Again, the advantage of our models on WoW Unseen is more evident than on WoW Seen. \begin{table}[t] \centering \scalebox{0.8}{ \begin{tabular}{l|cc} \toprule \textbf{Models} & \textbf{WoW Seen} & \textbf{WoW Uneen} \\ \midrule \textbf{Human}$^{\dagger}$ & 4.13 (1.08) & 4.34 (0.98) \\ \cmidrule{1-3} \textbf{PostKS++} & 2.30 (1.06) & 2.13 (1.10) \\ \textbf{SLKS} & 2.32 (1.11) & 2.22 (1.15) \\ \textbf{DiffKS$_\text{Fus}$} & \textbf{2.43} (0.96) & \textbf{2.39} (1.16) \\ \textbf{DiffKS$_\text{Dis}$} & 2.39 (1.17) & 2.38 (1.19) \\ \bottomrule \end{tabular}% } \caption{Human interactive evaluation results. The standard deviation is marked in parentheses. The results of human$^{\dagger}$ are from \citet{dinan2018wizard,Kim2020Sequential}. } \label{tab:interactive}% \end{table}% \subsection{Human Interactive Evaluation} We further conducted human interactive evaluation where real humans converse with one model about a specific topic. We compared PostKS++ and SLKS with our two models. The workers from Amazon Mechanical Turk were asked to first select one topic from 2-3 provided candidate topics, and then converse with one of the models for 3-5 dialogue turns. After conversation, they were required to rate the dialog model with a 5-star scale in terms of the fluency and informativeness of the utterances and the coherence of the whole dialog. Following \citet{dinan2018wizard,Kim2020Sequential}, the interactive evaluation was implemented with ParlAI \cite{miller2017parlai}. For each model, we averaged the scores from 150 collected conversations on each test set of WoW. We also reported the results of human-human dialog from \citet{dinan2018wizard,Kim2020Sequential}, where each worker converses with another human and the latter has access to knowledge sentences just like the models do. Results are shown in Table \ref{tab:interactive}\footnote{We found in \citet{dinan2018wizard,Kim2020Sequential} that the stddev values of dialog models are usually between 1.0 and 1.4, thus our results are within a reasonable range.}, where DiffKS$_\text{Fus}$ gains the highest scores and our models both outperform the other two state-of-the-art baselines, indicating that our models are favorably preferred by human annotators. \begin{table}[t] \centering \scalebox{0.8}{ \begin{tabular}{l|cccc} \toprule \multicolumn{1}{l|}{\textbf{Models}} & \multicolumn{1}{c}{\textbf{ACC}} & \multicolumn{2}{c}{\textbf{BLEU-2/4}} & \multicolumn{1}{c}{\textbf{ROUGE-2}} \\ \midrule \multicolumn{5}{c}{\textbf{WoW Seen}} \\ \midrule \textbf{DiffKS$_\text{Dis}$} & 24.7 & 11.3 & 5.7 & 6.8 \\ w/o DiffSel & \underline{22.3**} & \underline{10.6**} & \underline{4.9**} & \underline{5.9**} \\ w/o CtxSel & 24.6 & 10.9 & 5.3* & 6.5 \\ \midrule \multicolumn{5}{c}{\textbf{WoW Unseen}} \\ \midrule \textbf{DiffKS$_\text{Dis}$} & 18.3 & 9.6 & 4.5 & 5.3 \\ w/o DiffSel & \underline{15.5**} & \underline{8.8**} & \underline{3.8**} & \underline{4.4**} \\ w/o CtxSel & 18.4 & 9.1* & 4.1* & 5.0 \\ \midrule \multicolumn{5}{c}{\textbf{Holl-E}} \\ \midrule \textbf{DiffKS$_\text{Dis}$} & 33.5 & 29.9 & 25.9 & 26.4 \\ w/o DiffSel & \underline{29.1**} & \underline{27.9**} & \underline{23.8**} & 25.1 \\ w/o CtxSel & 31.6** & 28.4** & 24.7** & \underline{24.8*} \\ \bottomrule \end{tabular}% } \caption{Ablation tests. The larger performance drops between the two ablation models are underlined. The significance tests are conducted between the ablation models and the complete model DiffKS$_\text{Dis}$. } \label{tab:ablation}% \end{table} \subsection{Ablation Test} \label{sec:ablation} In order to verify the effectiveness of the differential information in knowledge selection, we conducted ablation tests, which were specifically based on the disentangled variant DiffKS$_\text{Dis}$. In DiffKS$_\text{Dis}$, we removed either the Differential Selector (DiffSel) or the Contextual Selector (CtxSel), and trained the model with only one of the two selectors. Results are shown in Table \ref{tab:ablation}. Without the differential selector, the model performance is remarkably impaired in all the metrics on three test sets, indicating the importance of utilizing differential information. In comparison, removing the contextual selector is less influential (with less performance drop). We conjecture that this may result from the characteristics of datasets. For instance, in WoW, the apprentice (without access to knowledge) usually reacts passively to the wizard (having access to knowledge). Thus the apprentice posts (contextual information) have limited influence in driving the conversation, which is instead affected or controlled by the wizard. In this case, our differential information that can predict the process of knowledge transition has more influence than the contextual information. In addition, same as \citet{Kim2020Sequential}, the knowledge sentences in Holl-E are obtained by segmenting a long document into single sentences, which implies that there exists the relevance or contextual dependency between knowledge sentences. Consequently, the differential information is still able to provide considerable clues for knowledge selection even without access to the new user post (the context). \begin{table}[t] \centering \scalebox{0.8}{ \begin{tabular}{lc|cccc} \toprule \textbf{Models} & $\bm{M}$ & \textbf{ACC} & \multicolumn{2}{c}{\textbf{BLEU-2/4}} & \textbf{ROUGE-2} \\ \midrule \multicolumn{6}{c}{\textbf{WoW Seen}} \\ \midrule \multirow{3}{*}{\textbf{DiffKS$_\text{Fus}$}} & \textbf{1} & 25.5 & 11.6 & 5.7 & 6.8 \\ & \textbf{2} & \textbf{26.3} & \textbf{11.7} & 5.8 & 7.0 \\ & \textbf{3} & 26.1 & 11.6 & 5.7 & 6.9 \\ \cmidrule{1-6} \multirow{3}{*}{\textbf{DiffKS$_\text{Dis}$}} & \textbf{1} & 24.7 & 11.3 & 5.7 & 6.8 \\ & \textbf{2} & 26.1 & \textbf{11.7} & \textbf{6.0} & \textbf{7.1} \\ & \textbf{3} & 25.0 & 11.1 & 5.7 & 6.7 \\ \midrule \multicolumn{6}{c}{\textbf{WoW Uneen}} \\ \midrule \multirow{3}{*}{\textbf{DiffKS$_\text{Fus}$}} & \textbf{1} & 19.7 & 10.0 & 4.7 & 5.6 \\ & \textbf{2} & \textbf{20.4} & \textbf{10.6} & \textbf{5.2} & \textbf{6.0} \\ & \textbf{3} & 19.5 & 9.8 & 4.8 & 5.6 \\ \cmidrule{1-6} \multirow{3}{*}{\textbf{DiffKS$_\text{Dis}$}} & \textbf{1} & 18.3 & 9.6 & 4.5 & 5.3 \\ & \textbf{2} & 19.4 & 9.9 & 4.6 & 5.3 \\ & \textbf{3} & 19.1 & 9.9 & 4.5 & 5.2 \\ \midrule \multicolumn{6}{c}{\textbf{Holl-E}} \\ \midrule \multirow{3}{*}{\textbf{DiffKS$_\text{Fus}$}} & \textbf{1} & 33.0 & 29.5 & 25.5 & 25.9 \\ & \textbf{2} & 33.2 & 30.1 & 26.1 & 26.2 \\ & \textbf{3} & 33.1 & 30.0 & 26.3 & 26.3 \\ \cmidrule{1-6} \multirow{3}{*}{\textbf{DiffKS$_\text{Dis}$}} & \textbf{1} & 33.5 & 29.9 & 25.9 & 26.4 \\ & \textbf{2} & \textbf{33.9} & 31.2 & \textbf{27.2} & \textbf{26.9} \\ & \textbf{3} & 33.8 & \textbf{31.3} & 26.8 & 26.7 \\ \bottomrule \end{tabular}% } \caption{Comparison between results with different $M$.} \label{tab:auto_M}% \end{table}% Furthermore, after removing DiffSel, DiffKS$_\text{Dis}$ reduces to a vanilla knowledge selection model where the supervision $\mathcal{L}_\mathrm{KS}$ was directly applied on the `prior' selection distribution. Nevertheless, the performance of the ablated model is sometimes competitive to the baselines (for instance, in terms of ACC, DiffKS$_\text{Dis}$ w/o DiffSel obtains 22.3/15.5/29.1 vs. 21.9/14.9/28.0 of PostKS++). It may result from the gap between training and inference caused by the prior-posterior framework adopted in PostKS and SLKS, which may be not superior over directly training the prior selection distribution\footnote{ The prior-posterior framework is first proposed by PostKS without direct supervision $\mathcal{L}_\mathrm{KS}$ on knowledge selection. While in this paper and \citet{Kim2020Sequential} the supervision $\mathcal{L}_{\mathrm{KS}}$ is available, the prior-posterior framework may not be superior any more. }. \section{Discussion} \subsection{Difference From More Turns} To investigate the impact of increasing the turns of differential information (the $M$ in Equ.\ref{equ:diff_M}), we additionally experimented with $M=2,3$, and took the arithmetic average for simplicity in Equ.\ref{equ:diff_M}, saying $\forall i, \lambda_i=1/M$. Results are shown in Table \ref{tab:auto_M}. We can find that $M=2$ generally achieves the best performance compared with $M=1,3$ for both DiffKS$_\text{Fus}$ and DiffKS$_\text{Dis}$ (while $M=3$ is still better than $M=1$). It further turns out the effectiveness of explicitly modeling differential information. We also conjecture that the model performance would be further improved by assigning the nearest/farthest difference with the largest/smallest weight in Equ.\ref{equ:diff_M}, saying $\lambda_1 > \lambda_2 > \dots > \lambda_M$, which is more reasonable than the simplified arithmetic average. \begin{table}[t] \centering \scalebox{0.8}{ \begin{tabular}{l|ccccc} \toprule \textbf{Models} & \textbf{1$^\text{st}$} & \textbf{2$^\text{nd}$} & \textbf{3$^\text{rd}$} & \textbf{4$^\text{th}$} & \textbf{5$^\text{th}$} \\ \midrule \multicolumn{6}{c}{\textbf{WoW Seen}} \\ \midrule \textbf{PostKS++} & 56.8 & 15.6 & 9.6 & 6.2 & 4.1 \\ \textbf{SLKS} & \textbf{57.4} & 18.4 & 10.1 & 8.9 & 5.4 \\ \textbf{DiffKS$_\text{Fus}$} & \textbf{57.4} & \textbf{22.5} & \textbf{12.8} & 9.8 & 7.4 \\ \textbf{DiffKS$_\text{Dis}$} & 56.6 & 21.5 & 11.2 & \textbf{10.2} & \textbf{7.9} \\ \midrule \multicolumn{6}{c}{\textbf{WoW Uneen}} \\ \midrule \textbf{PostKS++} & 42.8 & 8.5 & 4.1 & 4.8 & 4.6 \\ \textbf{SLKS} & \textbf{43.0} & 6.1 & 5.2 & 4.9 & 5.0 \\ \textbf{DiffKS$_\text{Fus}$} & 40.9 & \textbf{21.2} & \textbf{10.5} & \textbf{7.7} & 4.6 \\ \textbf{DiffKS$_\text{Dis}$} & 40.2 & 16.1 & 10.3 & \textbf{7.7} & \textbf{6.1} \\ \midrule \multicolumn{6}{c}{\textbf{Holl-E}} \\ \midrule \textbf{PostKS++} & 62.8 & 17.9 & 18.8 & 20.0 & 23.2 \\ \textbf{SLKS} & 65.2 & 18.4 & 19.2 & 21.3 & 19.6 \\ \textbf{DiffKS$_\text{Fus}$} & \textbf{65.8} & 22.3 & 22.1 & 25.5 & 25.8 \\ \textbf{DiffKS$_\text{Dis}$} & 63.9 & \textbf{23.0} & \textbf{23.4} & \textbf{26.0} & \textbf{28.3} \\ \bottomrule \end{tabular}% } \caption{Knowledge selection accuracy over turns.} \label{tab:acc_over_turn}% \end{table}% \subsection{Accuracy Over Turns} \label{sec:acc_over_turn} To verify whether the sequential knowledge selection facilitates knowledge selection in later turns, we evaluated the accuracy of knowledge selection at different turns. The statistics are shown in Table \ref{tab:acc_over_turn}. Our two models have the highest accuracy from the 2$^\text{nd}$ to 5$^\text{th}$ turns and outperform SLKS and PostKS++ (and SLKS also generally outperforms PostKS++). The results show that our models can select more accurate knowledge consistently over different turns. \subsection{Case Study} \begin{figure}[ht] \centering \includegraphics[width=\linewidth]{case_study.pdf} \caption{Case study. We marked the selected knowledge sentence in parentheses before each response. The knowledge k1-k5 are about the topic \textit{Georgia (U.S. state)}, while k6 is about \textit{History of Australia}. The {\color{blue} \textbf{blue} $\bm{\triangle}$} denotes duplicate responses resulting from repetitive knowledge selection. The {\color{red} \textbf{red} $\bm{\times}$} denotes incoherent responses resulting from selecting a far different knowledge from previous turns. } \label{fig:case_study} \end{figure} We show a case from WoW Seen in Figure \ref{fig:case_study}, which compares the responses generated by PostKS++, SLKS and our two models. At the 2$^\text{nd}$ turn, PostKS++ generates almost the same responses as at the 1$^\text{st}$ turn due to the repetitive knowledge selection. Similar cases occur for SLKS at the 2$^\text{nd}$ and the 3$^\text{rd}$ turns. Moreover, PostKS++ selects a quite different knowledge sentence at the 3$^\text{rd}$ turn from those at previous turns, which is about the topic \textit{History of Australia} but not \textit{Georgia (U.S. state)}. As a result, PostKS++ generates a response which is not coherent to the previous context at the 3$^\text{rd}$ turn. In contrast, our two models select both diverse and appropriate knowledge sentences at all the turns, thereby generating informative responses and making the dialog coherent and natural. \section{Conclusion} We present a novel difference-aware knowledge selection method for multi-turn knowledge-grounded conversation generation. Our method first compares the candidate knowledge provided at the current turn with the previously selected knowledge, and then selects appropriate knowledge to be used in generation. Experimental results show that our method is able to select knowledge more accurately and to generate more informative responses, outperforming significantly the state-of-the-art baselines. \section*{Acknowledgments} This work was jointly supported by the NSFC projects (Key project with No. 61936010 and regular project with No. 61876096), and the Guoqiang Institute of Tsinghua University, with Grant No. 2019GQG1. We thank THUNUS NExT Joint-Lab for the support.
{'timestamp': '2020-09-22T02:14:49', 'yymm': '2009', 'arxiv_id': '2009.09378', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09378'}
arxiv
\section{Introduction} Open-domain dialogue systems have attracted much research attention ~\cite{shum2018,huang2019}, thanks to the success of neural generation models trained with large-scale data. Existing research has been endeavored to address various aspects in dialogue systems, such as modeling persona~\cite{qian2018assigning,zheng2019personalized,Zhang2018Personalizing}, expressing emotion~\cite{zhou2018emotional}, or generating knowledge-grounded dialogues~\cite{ghazvininejad2018knowledge,zhou2018commonsense,zhou-etal-2020-kdconv}. In general, training neural open-domain dialogue models requires a large amount of high-quality \emph{paired data}, e.g., post-response pairs, which are usually labor-intensive and time consuming to collect. A feasible solution to this data dilemma is to use data augmentation techniques, which are popular in various research areas such as computer vision~\cite{cubuk2018autoaugment} or machine translation~\cite{sennrich2015improving}. Nevertheless, this technique is rarely investigated in the study of open-domain dialogues, and few existing approaches are specifically designed for either the generation-based dialogue models~\cite{li2019insufficient} or the retrieval-based dialogue models~\cite{du2018data}. Moreover, existing data augmentation approaches only take a set of paired data as input without considering to utilize unpaired data. \begin{figure}[t] \centering \includegraphics[width=220px]{figure/fig1.pdf} \caption{Process of constructing augmented post-response pairs. The sentence in blue rectangle is used to match the anchor pair and the corresponding response is then used to retrieve similar sentences in unpaired data. Each augmented pair contains two sentences both from unpaired data.} \label{fig:aug_with_unpaired} \end{figure} As a matter of fact, high-quality \emph{unpaired data}, i.e., non-conversational texts, are generally easier to collect compared to high-quality dialogue pairs. Specifically, these unpaired data provide us a rich bank of alternative expressions for different contents. It is thus feasible to augment the training dialogue pairs utilizing sentences extracted from the unpaired data. As shown in Figure~\ref{fig:aug_with_unpaired}, we can extract various sentences from the unpaired data that are similar to a given post-response pair (i.e., anchor pair). Augmented pairs that carry richer expressions can be then constructed by combining these extracted sentences. To the best of our knowledge, there are no previous studies for open-domain dialogues that try to construct augmented dialogue pairs by utilizing retrieved unpaired data. In this paper, we propose a novel data augmentation method ``\textbf{Dialogue Distillation}'' to improve the performance of open-domain dialogue models by utilizing unpaired data. Our method involves two phases of distillation. The first phase is at the data level as it constructs (i.e., distills) post-response pairs by matching sentences retrieved from a set of unpaired data. Specifically, given a set of training pairs $\{\langle x_i,y_i \rangle\}$, a randomly selected sentence $s$ is firstly used as a query to retrieve the most similar $x_i$, and then the corresponding $y_i$ are used as queries to retrieve similar $s_i$ from the unpaired data. Augmented pairs $\langle s,s_i \rangle$ are then constructed and filtered using a ranking module. Note that different from previous approaches, \textit{the post and response sentences that constitute an augmented pair are both from the unpaired data}, which are human written and thereby fluent and content-rich. The second phase is at the model-level as it distills a teacher model using the augmented data. Specifically, we borrow the idea of knowledge distillation~\cite{hinton2015distilling} to first train a teacher model on a set of high-quality dialogue pairs, and then distill the dialogue model by mimicking the distribution produced by the teacher model on the augmented data to prevent the final dialogue models from being affected by the noise in the augmented data. Automatic and manual evaluation results indicate that our data-level distillation process can produce high-quality post-response pairs that are content-rich, and our model-level distillation process can better utilize these augmented data to improve the performance of both retrieval-based and generation-based open-domain dialogue models. Our contributions are summarized as follows: \textbf{1)} We propose a data-level and model-level distillation method for open-domain dialogue models. The data-level distillation constructs new post-response pairs where both post and response are retrieved from unpaired data, and the model-level distillation distills a teacher model trained on high quality paired data to augmented pairs. To the best of our knowledge, this is the first attempt to augment open-domain dialogue pairs by utilizing the retrieved unpaired data. \textbf{2)} Automatic and manual evaluation shows that the augmented pairs produced by our method are content-rich, and these augmented data can be used to improve the performance of both generation-based and retrieval-based dialogue models. \section{Related Work} There are two major categories of open-domain dialogue models: 1) retrieval-based models, which retrieve the best matching response from the pre-collected dialogues~\cite{lu2013deep}; and 2) generation-based models, which decode responses from a learned distribution~\cite{sutskever2014sequence,vinyals2015neural}. Recent advances in these two categories all focus on DNN-based data-driven methods~\cite{huang2019}. Data augmentation is an effective approach to boost the performance of neural models. It has been explored in various NLP tasks, such as text classification~\cite{wei2019eda,zheng2020ood}, machine reading comprehension~\cite{yu2018qanet} and machine translation~\cite{sennrich2015improving}. Although proved to be effective, this technique is rarely investigated in open-domain dialogue models. Few existing approaches are restricted to only take the dialogue pairs as their inputs~\cite{li2019insufficient,zhao2017generative,cai-etal-2020-data}, whereas unpaired texts, i.e., sentences without replies, are not utilized. Note that the pre-training based methods~\cite{devlin2018bert,radford2019language,golovanov2019large,zheng2019pre} share a similar motivation with our study, i.e., to boost the performance of neural NLP models utilizing unlabeled (i.e., unpaired) texts. Nevertheless, the data augmentation method proposed in our study can be regarded as a supplement to these pre-training approaches. Experiments demonstrate that our method can be used to improve the performance of dialogue models even if these models are initialized with strong pre-trained models. Our study is also related to the knowledge distillation method~\cite{hinton2015distilling}, which also employs a teacher model and tries to minimize the KL divergence between the teacher distribution and the model distribution. The most related work in this branch compared to ours was done by \citet{kim2016sequence}. However, their methods do not utilize unpaired data, and the augmented data are decoded from a probability model using beam search. Whereas our method tries to utilize the unpaired data, and the augmented data are generated by aligning human produced sentences. There are also works that try to utilize retrieved non-conversational texts to improve the diversity of the dialogue model \cite{wu2019response,cai2019skeleton,zhu2019retrieval,su2020diversifying}. However, most of these studies focus on extracting templates from these non-conversational texts rather than generating augmented pairs, and they typically use specifically designed model structures. Nevertheless, the data augmentation method proposed in our study can be used in combination with any dialogue models to improve the performance. \section{Data-level Distillation} \begin{figure}[t] \centering \setlength{\belowcaptionskip}{-0.1cm} \includegraphics[width=210px]{figure/fig2.pdf} \caption{Framework of data-level distillation. (1) The sentence $S$ is randomly selected in the unpaired data $\mathcal{D}_u$. (2) A set of posts $X_1, \dots, X_n$ that are similar to $S$ are retrieved from the paired data $\mathcal{D}_p$. (3) Each corresponding response $Y_i$ is then used to retrieve $m$ sentences $S_{i1}, \dots, S_{im}$ that are similar to $Y_i$ from $\mathcal{D}_u$. (4) Then $n \times m$ candidate pairs can be formed by grouping $S$ with each sentence: $\langle S, S_{ij} \rangle$, ($i=1,\dots,n$, $j=1,\dots,m$). (5) A ranking module is used to rank these candidate pairs.} \label{fig:model_arch} \end{figure} The data-level distillation in our method aims at constructing a set of new post-response pairs $\mathcal{D}_a$ by matching non-parallel sentences retrieved from unpaired data $\mathcal{D}_u$. Specifically, $\mathcal{D}_p$ consists of $N$ post-response pairs: $\mathcal{D}_p=\{\langle X_i,Y_i \rangle\}_{i=1}^N$, in which $X_i$ and $Y_i$ is the post and response, respectively, and $\mathcal{D}_u$ consists of $M$ non-parallel sentences: $\mathcal{D}_u=\{S_i\}_{i=1}^M$. Note that $M$ is usually much larger than $N$ because non-parallel sentences are generally easier to collect. Further, the output of our data-level distillation process is a set of augmented post-response pairs: $\mathcal{D}_a=\{\langle X'_i, Y'_i \rangle \}_{i=1}^{K}$, in which both the post and response come from the unpaired dataset $\mathcal{D}_u$, i.e., $X'_i \in \mathcal{D}_u$ and $Y'_i \in \mathcal{D}_u$ for $i=1, \dots, K$. The data-level distillation involves two major processes: 1) constructing candidate pairs and 2) filtering low-quality candidates. The whole framework is shown in Figure~\ref{fig:model_arch} and detailed below. \subsection{Constructing Candidate Pairs}\label{sec:construct_fp} We first construct candidate dialogue pairs with the help of some post-response pairs $\langle X_i, Y_i \rangle$ selected from $\mathcal{D}_p$. The basic intuition is that sentences that are similar to post $X_i$ can usually be responded with sentences that are similar to the corresponding response $Y_i$. Candidate dialogue pairs can be then constructed by anchoring sentences in $\mathcal{D}_u$ using $\langle X_i, Y_i \rangle$. The construction of candidate pairs starts by randomly selecting a sentence $S$ from the unpaired dataset $\mathcal{D}_u$. We then treat $S$ as a candidate post, and it is used to retrieve $n$ posts $X_i$ ($1 \leq i \leq n$) that are similar to $S$ from the paired data $\mathcal{D}_p$. In this study, the sentence retrieval process is implemented based on the Okapi BM25 algorithm, which scores the similarity of input sentences using bag-of-words features. Then the corresponding $n$ post-response pairs $\langle X_i, Y_i \rangle$ ($1 \leq i \leq n$) are extracted from $\mathcal{D}_p$. For each response $Y_i$, we further retrieve $m$ sentences $S_{ij}$ ($1 \leq j \leq m$) that are similar to $Y_i$ from the unpaired dataset $\mathcal{D}_u$. These sentences $S_{ij}$ can then serve as candidate responses to the original sentence $S$, and therefore $n \times m$ candidate pairs $\langle S, S_{ij} \rangle$, ($ 1 \leq i \leq n$, $ 1 \leq j \leq m$) are generated. Moreover, for each candidate pair $\langle S, S_{ij} \rangle$, we name the post-response pair $\langle X_i, Y_i \rangle$ in $\mathcal{D}_p$ that are used to produce $\langle S, S_{ij} \rangle$ as its \emph{``anchor pair''} since it anchors the sentences $S$ and $S_{ij}$ from $\mathcal{D}_u$. Note that we have explored other variants of the above process, such as treating the initial sentence $S$ as a candidate response rather than a candidate post or utilizing more advanced text retrieval methods to extract similar sentences. However, we notice little difference in neither the quality of the final augmented pairs nor the performance improvement brought to the dialogue models. \subsection{Filtering Candidate Pairs}\label{sec:cand_filter} In order to enhance the quality of the augmented data, we propose to filter out low-quality pairs using a ranking module, which calculates a score for each candidate pair obtained above. Specifically, high-quality pairs that are fluent and coherent are expected to receive high scores. In this study, we implement the score function as a text matching model, which is built by fine-tuning a pre-trained BERT model on the paired dataset $\mathcal{D}_p$. Negative samples are constructed by replacing the original responses using randomly sampled sentences from $\mathcal{D}_p$. The ranking score for each input pair is calculated as the matching score produced by the matching model. In this study, we follow a quite rigorous policy to select the final augmented pairs in $\mathcal{D}_a$. For each sample sentence $S$ from $\mathcal{D}_u$, we only extract the top-1 scored pair $\langle S, S_{ij} \rangle$ among all its $n \times m$ candidate pairs, and $\langle S, S_{ij} \rangle$ is added to $\mathcal{D}_a$ only when its matching score exceeds a certain threshold $\eta (0.9 \leq \eta)$. We repeat the above procedures with newly sampled sentences from $\mathcal{D}_u$ until a desired number of augmented pairs in $\mathcal{D}_a$ are obtained. The whole data-level distillation process in our method is summarized in Algorithm~\ref{alg:process}. Note that the matching model used in the ranking process can also be directly used to align sentences from the unpaired dataset $\mathcal{D}_u$. Specifically, for a sampled sentence $S$ from $\mathcal{D}_u$, we can treat all other sentences in $\mathcal{D}_u$ as its candidate response and select an augmented pair by ranking all these candidates. Although theoretically possible, this approach is practically infeasible considering the large amount of sentences in $\mathcal{D}_u$ and the tremendous computational load to rank these candidates. Note that previous works on effective ranking (such as \citet{henderson2017efficient,henderson2020convert}) can not be directly adapted to this study because our ranking model does not use dot-product scoring function. \begin{algorithm}[tb] \small \caption{Data-level distillation process} \label{alg:process} \hangindent 3em \textbf{Input}: A set of unpaired data $\mathcal{D}_u$=$\{S_i\}_{i=1}^M$, a set of paired data $\mathcal{D}_p$=$\{\langle X_i,Y_i \rangle \}_{i=1}^N$, a threshold $\eta$. \textbf{Output}: Augmented dialogue pairs $\mathcal{D}_a$=$\{\langle X'_i, Y'_i \rangle\}_{i=1}^{K}$. \begin{algorithmic}[1] \STATE $\mathcal{D}_a$ $\leftarrow$ Empty set \WHILE{$|\mathcal{D}_a| < K$} \STATE $\widetilde{\mathcal{D}}_a$ $\leftarrow$ Empty set \STATE Sample a sentence $S \sim \mathcal{D}_u$. \STATE Retrieve $n$ posts $\{X_i\}_{i=1}^{n}$ that are similar to $S$ in $\mathcal{D}_p$. \STATE Get the responses $\{Y_i\}_{i=1}^{n}$ for $\{X_i\}_{i=1}^{n}$ from $\mathcal{D}_p$. \FOR{each $Y_i$} \STATE Retrieve $m$ sentences $\{S_{ij}\}_{j=1}^{m}$ that are similar to $Y_i$ in $\mathcal{D}_u$. \STATE $\widetilde{\mathcal{D}}_a$ $\leftarrow$ $\widetilde{\mathcal{D}}_a \bigcup \{\langle S, S_{ij}\rangle\}_{j=1}^m$ \ENDFOR \STATE Calculate the ranking score for each pair in $\widetilde{\mathcal{D}}_a$. \STATE Extract the top-1 scored pair $\langle S, S_{ij} \rangle$ from $\widetilde{\mathcal{D}}_a$. \IF{The ranking score of $\langle S, S_{ij} \rangle$ exceeds $\eta$} \STATE $\mathcal{D}_a$ $\leftarrow$ $\mathcal{D}_a \bigcup \{\langle S, S_{ij}\rangle\}$ \ENDIF \ENDWHILE \end{algorithmic} \end{algorithm} \section{Model-level Distillation}\label{sec:train_with_teacher} A straightforward way to improve a dialogue model with the augmented dialogue data is to directly merge the original paired data $\mathcal{D}_p$ with $\mathcal{D}_a$. However, this naive approach may lead to sub-optimal performance since the augmented pairs in $\mathcal{D}_a$ might not be as high-quality as these human-crafted pairs in $\mathcal{D}_p$. In this study, we apply the model-level distillation in the training process to prevent the dialogue models from being affected by the noise in $\mathcal{D}_a$. This approach can be used in both retrieval-based and generation-based dialogue models. \subsection{Retrieval-based Dialogue Model}\label{sec:retrieval_model} A retrieval-based dialogue model produces responses by retrieving a best matching sentence from the pre-collected dialogue dataset. Its key component is a matching function $\mathcal{P}_{\theta}(l|X, Y)$ that predicts whether a response $Y$ matches a given post $X$. Specifically, $l \in \{0,1\}$ is a matching label, where $l=1$ means $Y$ is a proper response for $X$ and $l=0$ otherwise. The model parameters $\theta$ can be learned by optimizing a negative log likelihood (NLL) loss defined as \begin{equation} \begin{split} \mathcal{L}_{m-nll}(\theta)=&-(1-l) {\rm log}\mathcal{P}_{\theta}(0|X,Y) \\ &- l {\rm log} \mathcal{P}_{\theta}(1|X,Y) \end{split} \label{eq:match_nll} \end{equation} In this study, we formalize the matching function using the BERT model~\cite{devlin2018bert,Whang2020Effective}. A teacher model $\mathcal{P}_{\theta_t}(l|X, Y)$ is first obtained by optimizing the NLL loss $\mathcal{L}_{m-nll}(\theta_t)$ on the paired dataset $\mathcal{D}_p$. After the training is completed, the teacher model is fixed and used to compute a knowledge distillation (KD) loss~\cite{kim2016sequence} as \begin{equation} \mathcal{L}_{m-kd}(\theta)= - \sum_{i=0}^1 \mathcal{P}_{\theta_t}(i|X,Y) \cdot {\rm log}\mathcal{P}_{\theta}(i|X,Y). \label{eq:matching_kd_loss} \end{equation} The final matching model is trained on the following loss: \begin{equation} \mathcal{L}_{M}(\theta)=\mathcal{L}_{m-nll}(\theta) + \alpha_m \mathcal{L}_{m-kd}(\theta), \label{eq:matching_total_loss} \end{equation} where the loss $\mathcal{L}_{M}(\theta)$ is evaluated using $\mathcal{D}_p \bigcup \mathcal{D}_a$ and $\alpha_m$ is used to balance these two losses. \subsection{Generation-based Dialogue Model}\label{sec:generation_model} A generation-based dialogue model tries to capture the distribution of the response sentences $Y$ given the post sentence $X$, i.e., $\mathcal{P}_\phi(Y|X)$, which can be formalized as \begin{equation} \mathcal{P}_{\phi}(Y|X)=\prod_{i=1}^{|Y|} P_{\phi}(y_i|y_{<i},X), \end{equation} where $|Y|$ is the length of $Y$, $y_{<i}=y_1\cdots y_{i-1}$ is the token sequence before $y_i$. The model parameters $\phi$ can be learned by optimizing the NLL loss: \begin{equation} \mathcal{L}_{g-nll}(\phi)=- \sum_{i=1}^{|Y|} {\rm log}P_{\phi}(y_i|y_{<i},X). \label{eq:g_nll} \end{equation} In this study, we parameterize the dialogue generation model using the Transformer-based encoder-decoder framework~\cite{vaswani2017attention,golovanov2019large,zheng2019pre}. Similar to the retrieval-based approach, a teacher model is first obtained by optimizing the NLL loss $\mathcal{L}_{g-nll}$ on the paired dataset $\mathcal{D}_p$ and the trained teacher model is used to compute a KD loss as \begin{equation} \begin{split} \mathcal{L}_{g-kd}(\phi)=- &\sum_{i=1}^{|Y|} \sum_{j=1}^{|\mathcal{V}|} P_{\phi_t}(y_i=j|y_{<i},X) \\ &\times {\rm log}P_{\phi}(y_i=j|y_{<i},X), \end{split} \label{eq:g_kd} \end{equation} where $|\mathcal{V}|$ denotes the size of the vocabulary and $\phi_t$ is the parameter of the teacher model, which is fixed. The final loss for the generation model is: \begin{equation} \mathcal{L}_{G}(\phi)=\mathcal{L}_{g-nll}(\phi) + \alpha_g \mathcal{L}_{g-kd}(\phi), \label{eq:generation_total_loss} \end{equation} where the loss $\mathcal{L}_{G}(\theta)$ is evaluated using $\mathcal{D}_p \bigcup \mathcal{D}_a$ and $\alpha_g$ is used to balance these two losses. \section{Experiment}\label{sec:exp} \subsection{Dataset} The evaluation of our method is performed on a corpus collected from Weibo\footnote{https://www.weibo.com}. Specifically, the paired data $\mathcal{D}_p$ contains 300K post-response pairs, which are made up of Weibo posts and their following replies. All these pairs are manually filtered with annotators by removing ungrammatical sentences and incoherent dialogues. The unpaired data $\mathcal{D}_u$ contains about 2 million posts on Weibo that do not have replies. Non-fluent sentences in $\mathcal{D}_u$ are filtered out using a set of heuristic rules. Further, two additional sets of paired data are also prepared to validate and test the dialogue models, with 10K and 5K pairs respectively. These dialogue pairs are collected and manually filtered using the same criterion as $\mathcal{D}_p$. \subsection{Implementation Details} \textbf{Data-level Distillation:} We implement the retrieval module in Section~\ref{sec:construct_fp} using the Lucene library \footnote{https://lucene.apache.org/core/}, and set the value of both $n$ and $m$ to 5. The matching model used in Section~\ref{sec:cand_filter} is fine-tuned with $\mathcal{D}_p$ for three epochs based on the pretrained BERT-base model~\cite{devlin2018bert}. The hyper-parameter setting of the matching model follows the work of \citet{devlin2018bert}. \textbf{Model-level Distillation:} For the \emph{retrieval-based dialogue model}, the matching model used in Section~\ref{sec:cand_filter} is directly used as the teacher model to calculate the KD loss (Eq.~\ref{eq:matching_kd_loss}). The final retrieval-based dialogue model is initialized with the pre-trained BERT-base weights and fine-tuned using the loss in Eq.~\ref{eq:matching_total_loss} for 2 epochs on $\mathcal{D}_p \bigcup \mathcal{D}_a$. The value of $\alpha_m$ in Eq.~\ref{eq:matching_total_loss} is set to 1. For the \emph{generation-based dialogue model}, the encoder and decoder share the same set of parameters, which is initialized using a pretrained GPT model~\cite{wang2020chinese}. The teacher model uses the same architecture and it is fine-tuned using the paired dataset $\mathcal{D}_p$ for 15 epochs on the NLL loss (Eq.~\ref{eq:g_nll}). The final generative dialogue model is first initialized using the pre-trained GPT weights and fine-tuned using the loss in Eq.~\ref{eq:generation_total_loss} for 50 epochs on $\mathcal{D}_p$ and $\mathcal{D}_a$. The value of $\alpha_g$ in Eq.~\ref{eq:generation_total_loss} is set to 1. Moreover, the GPT model used in the initialization phase is trained on a corpus collected from various Chinese novels. This corpus contains about 0.5 billion tokens and a character-level vocabulary of size 13,084. See Appendix \ref{sec:appendix} for more details of the model setting and reproduction guidance. The data and code for all experiments can be downloaded from the link\footnote{\url{https://github.com/njuzrs/dialogue\_distillation}}. \begin{table*}[ht] \setlength\tabcolsep{2.1pt} \centering \setlength\tabcolsep{6pt} \setlength{\belowcaptionskip}{-0.2cm} \begin{tabular}{p{60pt}p{26pt}p{26pt}p{26pt}p{26pt}|p{26pt}p{26pt}p{26pt}p{26pt}|p{26pt}p{26pt}} \toprule Model & \multicolumn{4}{c}{Distinct-1,2,3,4} & \multicolumn{4}{c}{Novelty-1,2,3,4} & Flu. & Coh. \\ \midrule CVAE & $0.178^\ddag$ & $09.40^\ddag$ & $34.54^\ddag$ & $60.73^\ddag$ &$00.25^\ddag$ & $08.47^\ddag$ & $25.45^\ddag$ & $40.62^\ddag$ & $1.529^\ddag$ & $0.862^\ddag$ \\ BT & $0.193^\ddag$ & $12.42^\ddag$ & $43.43^\ddag$ & $70.38^\ddag$ &$03.07^\ddag$ & $21.66^\ddag$ & $35.28^\ddag$ & $45.18^\ddag$ & $1.771^\ddag$ & $\underline{1.408}^\dag$ \\ SP & \textbf{0.228}& $11.56^\ddag$ & $37.76^\ddag$ & $57.73^\ddag$ &$18.48^\ddag$ & $46.65^\ddag$ & $73.56^\ddag$ & $87.79^\ddag$ & $1.839^\ddag$ & $0.777^\ddag$ \\ \midrule DL $\eta$=0.90 & $\underline{0.226}^\ddag$ & \textbf{13.72} & \textbf{48.24} & \textbf{76.21} & \textbf{23.76} & \textbf{55.95} & \textbf{80.64} & \textbf{92.10} & $1.835^\ddag$ & $1.183^\ddag$ \\ DL $\eta$=0.95 & $0.224^\ddag$ & $\underline{13.44}^\ddag$ & $\underline{47.51}^\ddag$ & $\underline{75.55}^\ddag$ & $\underline{22.81}^\ddag$ & $\underline{55.51}^\ddag$ & $\underline{80.37}^\ddag$ & $\underline{91.97}^\ddag$ & $\underline{1.856}^\dag$ & $1.358^\ddag$ \\ DL $\eta$=0.99 & $0.213^\ddag$ & $12.61^\ddag$ & $45.06^\ddag$ & $72.87^\ddag$ & $21.59^\ddag$ & $54.40^\ddag$ & $79.69^\ddag$ & $91.62^\ddag$ & \textbf{1.877} & \textbf{1.428} \\ \midrule $\mathcal{D}_p$(human) & 0.199& 13.51 & 47.70 & 75.52 & \multicolumn{4}{c|}{N/A} & 1.868 & 1.617 \\ \bottomrule \end{tabular} \caption{Automatic and manual evaluation on the quality of augmented pairs produced by different methods. The bottom row corresponds to the human filtered dialogue pairs in $\mathcal{D}_p$. The best results are in \textbf{bold}, and the second best results are \underline{underlined} (except ``human''). Significant tests between the best model and others were performed using t-test. $\dag$ and $\ddag$ indicates $p$-value \textless~0.01 and 0.001, respectively.} \label{tab:eval_augmented} \end{table*} \subsection{Evaluating Augmented Dialogue Pairs} \subsubsection{Baselines}\label{sec:augment_baseline} We first evaluate the quality of the augmented pairs generated by our \underline{D}ata-\underline{L}evel (\textbf{DL}) distillation process. Three different matching thresholds $\eta$ in Algorithm~\ref{alg:process} are tested, i.e., $\eta$ = 0.90, 0.95, 0.99. Several strong baselines are also compared: \textbf{CVAE}: A \underline{CVAE}-based model as proposed by \citet{li2019insufficient} is trained on the paired data $\mathcal{D}_p$. Augmented pairs are generated by sampling different latent codes. \textbf{BT}: Augmented pairs are generated by \underline{B}ack \underline{T}ranslating (i.e., translate Chinese to English and then translate back to Chinese) the post sentences of the dialogue pairs in $\mathcal{D}_p$. The translation is done via the Google Translate API. \textbf{SP}: A variant of our method is implemented by first \underline{S}ampling a post-response \underline{P}air $\langle X,Y \rangle$ from $\mathcal{D}_p$, and then retrieving a best-matching post and response from the unpaired data $\mathcal{D}_u$ using $X$ and $Y$ as the query, respectively. An augmented pair is constructed by pairing the retrieved post and response sentence without the ranking process. Note that there are two major differences between the baseline SP and our data-level distillation process: 1) the baseline SP starts with a dialogue pair $\langle X,Y \rangle$ sampled from $\mathcal{D}_p$ rather than a candidate post sampled from $\mathcal{D}_u$; 2) The ranking process is not used in the baseline SP to further filter the candidate pairs. \subsubsection{Metrics}\label{sec:ap_human_metric} The automatic evaluation of augmented dialogue pairs uses the following metrics: 1) \emph{\textbf{Distinct}}~\cite{li2015diversity} is used to measure the proportion of unique n-grams in the augmented dialogue pairs ($n$=1,2,3,4); 2) \emph{\textbf{Novelty}}~\cite{wang2018sentigan} is used to measure the proportion of new n-grams in the augmented dialogue pairs ($n$=1,2,3,4), i.e., n-grams that are covered by the augmented dialogue pairs but are not shown in the paired dataset $\mathcal{D}_p$. A higher novelty score means the augmented dialogue pairs contain more ``novel'' contents. Manual evaluation is also used to evaluate the quality of augmented dialogue pairs. Three annotators are employed to rate these pairs from two aspects: 1) \emph{Fluency} (\textbf{Flu.}): whether the augmented pairs are fluent; 2) \emph{Coherency} (\textbf{Coh.}): whether the response is coherent with the post so that they make a plausible dialogue pair. The rating scale for each measure is of (0, 1, 2), in which 0 means worst and 2 best. \subsubsection{Results} Each data augmentation method introduced above are used to generate 300K augmented dialogue pairs, and on which automatic evaluation is performed. Further, manual evaluation is carried out on 200 dialogue pairs that are randomly sampled from these augmented data, and the inter-rater agreement between annotators is measured using the Fleiss's kappa $\kappa$~\cite{randolph2005free}. The $\kappa$ value for \emph{Fluency} and \emph{Coherency} is 0.69 (substantial agreement), and 0.42 (moderate agreement), respectively. Note that this evaluation is purely regarding the augmented dialogue data, without considering any dialogue model training. The evaluation results in Table~\ref{tab:eval_augmented} demonstrate that the augmented dialogue data produced by our method outperform all the baselines in almost all the metrics. We can further observe that: \textbf{1}) Our method obtains similar scores on all the metrics compared to these human-produced and filtered dialogue pairs in $\mathcal{D}_p$. This indicates that the augmented dialogue pairs generated by our method are of high quality. We present some examples of the augmented pairs together with their associated anchor pairs in Table~\ref{tab:example_pair}. \textbf{2}) The matching threshold $\eta$ can be used to trade off between the coherency and diversity of the augmented dialogue pairs. Specifically, a higher $\eta$ value improves Fluency and Coherency scores but hurts Distinct and Novelty scores of the augmented pairs. \begin{table*}[ht] \small \centering \setlength\tabcolsep{2pt} \begin{tabular}{lll} \toprule & \multicolumn{1}{c}{Augmented pairs} & \multicolumn{1}{c}{Associated anchor pairs from $\mathcal{D}_p$}\\ \midrule {Post} & I'm almost moved to cry \small{(我已经快感动地哭了)} & I am so moved today! \small{(今天感动得快哭了!)}\\ {Resp} & What happened there? \small{(发生什么事情呢?)} & What happen \small{(发生什么事)} \\ \midrule Post & I like it, men should be like this \small{(这话我喜欢。男人就该这样)} & I like this types of man \small{(喜欢这样的男人)} \\ Resp & I like it too, just as you do \small{(我也喜欢。跟你一样)} & Your taste is just like mine \small{(怎么跟我喜欢的一样)} \\ \midrule Post & I liked to play it when I was young \small{(小时候很喜欢玩)} & My favorite toy in kindergarten \small{(幼儿园最喜欢玩的)}\\ Resp & I have also played, it's so cute \small{(表示有幸玩过,很萌哒)} & I have also played, lol \small{(我也玩过哒)} \\ \bottomrule \end{tabular} \caption{Example pairs produced by the proposed data augmentation method. The associated anchor pairs are also shown. More examples are shown in Appendix \ref{appendix:examples}} \label{tab:example_pair} \end{table*} \subsection{Evaluating Dialogue Models} \subsubsection{Baselines} We evaluate the benefit of the augmented dialogue data in both retrieval-based and generation-based dialogue models. Specifically, 300K augmented dialogue pairs are generated using these three baselines introduced in Section~\ref{sec:augment_baseline}, and the model-level distillation process as introduced in Section~\ref{sec:train_with_teacher} is used to train the dialogue models. We denote these three dialogue model baselines as \textbf{CVAE+ML}, \textbf{BT+ML}, and \textbf{SP+ML}, respectively. Note that the notation ``ML'' means that the \underline{M}odel-\underline{L}evel distillation is used. Moreover, besides comparing to different data augmented methods as introduced in Section~\ref{sec:augment_baseline}, several other competitive dialogue model baselines are also tested: \textbf{Teacher}: Training the dialogue models on the paired data $\mathcal{D}_p$ with the NLL loss. Note that this setting produces the teacher models used in Section~\ref{sec:train_with_teacher}. \textbf{AP}: Training dialogue models only on the \underline{A}ugmented \underline{P}airs $\mathcal{D}_a$ with the NLL loss. \textbf{UP+PreT}: First fine-tuning the pre-trained GPT (with the NLL loss in Eq.~\ref{eq:g_nll}) or BERT-base model (with the MLM loss~\cite{devlin2018bert}) on the \underline{U}n\underline{P}aired Data $\mathcal{D}_u$, and then using these fine-tuned weights to initialize the dialogue models, which are further fine-tuned on $\mathcal{D}_p$ with the NLL loss. \textbf{NP+ML}: Sampling 300K pairs from a set of Weibo dialogues that are not manually filtered and use these ``\underline{N}oisy \underline{P}airs'' as the augmented pairs. The model-level distillation process introduced in Section~\ref{sec:train_with_teacher} is used to train this baseline. We denote our method as \textbf{DL+ML} since it trains the dialogue model using both the data-level and model-level distillation. The threshold $\eta$ in Algorithm~\ref{alg:process} is set to 0.95 for a better trade-off between the coherency and diversity of the augmented data. Further, we also test another method to work with data-level distillation (i.e., utilizing $\mathcal{D}_a \bigcup \mathcal{D}_p$): \textbf{DL+PreT}, i.e., first pre-train the dialogue model on $\mathcal{D}_a$ and then fine-tune on $\mathcal{D}_p$ with the NLL loss. Further, we also performed several ablation tests on our method to validate the effect of each component: 1) training dialogue models on $\mathcal{D}_p \bigcup \mathcal{D}_a$ using only the NLL loss, i.e., without the model-level distillation (\textbf{w/o ML}); 2) training dialogue models only on the paired data $\mathcal{D}_p$ using $\mathcal{L}_M(\theta)$ or $\mathcal{L}_G(\phi)$, i.e., the data-level distillation are not used (\textbf{w/o DL}); 3) training dialogue models on the augmented data $\mathcal{D}_a$ using $\mathcal{L}_M(\theta)$ or $\mathcal{L}_G(\phi)$, i.e., the paired data $\mathcal{D}_p$ are not used (\textbf{w/o PD}); 4) generating $\mathcal{D}_a$ without the ranking module (\textbf{w/o Ranking}), i.e., the candidate pairs are used as the augmented data without filtering. Note that all the baselines and ablation models are initialized with pre-trained GPT or BERT-base weights. \subsubsection{Metrics} The retrieval-based dialogue models are evaluated using the following metrics: 1) \emph{Mean Average Precision} (\textbf{MAP}): the average rank of the reference responses; 2) \emph{$\bm{R_{10}@k}$}: the recall of the reference response being in the top-$k$ ranked candidates ($k$=1,2,5) when given 10 candidates in total. The generation-based dialogue models are evaluated both automatically and manually. Specifically, the following automatic metrics are used: 1) \emph{Perplexity} (\textbf{PPL}) which measures how the model fits the test data; 2) \emph{\textbf{BLEU}} which evaluates the overlap of n-grams (n=1,2) between the generated and reference responses; 3) \emph{Distinct} (\textbf{Dist.}) measures the proportion of unique n-grams in the generated responses (n=1,2). Manual evaluation is also performed for the generated dialogue responses following the same protocol as introduced in Section~\ref{sec:ap_human_metric}. \begin{table}[!tbh] \centering \setlength\tabcolsep{2pt} \begin{tabular}{lccccc} \toprule Model & MAP & $R_{10}@1$ & $R_{10}@2$ & $R_{10}@5$ \\ \midrule Teacher & 80.2 & 69.7 & 82.1 & 95.1 \\ AP & 76.5 & 65.1 & 78.0 & 92.1 \\ UP+PreT & 80.6 & 70.3 & 82.6 & \textbf{95.3} \\ NP+ML & 80.8 & 70.5 & 82.9 & 95.2 \\ CVAE+ML & 80.3 & 69.8 & 82.5 & 94.9 \\ BT+ML & 80.3 & 69.8 & 82.0 & 95.2 \\ SP+ML & 80.4 & 70.0 & 82.0 & 95.2 \\ \midrule DL+PreT & 80.7 & 70.2 & 82.7 & \textbf{95.3} \\ DL+ML & \textbf{81.0} & \textbf{70.8} & \textbf{83.1} & \textbf{95.3} \\ \midrule w/o ML & 80.4 & 69.9 & 82.5 & 95.0 \\ w/o DL & 80.5 & 70.1 & 82.3 & 95.1 \\ w/o PD & 79.5 & 68.9 & 81.3 & 94.1 \\ w/o Ranking & 80.5 & 70.1 & 82.5 & 95.2 \\ \bottomrule \end{tabular} \caption{Automatic evaluation for retrieval-based dialogue models with different training and data augmentation methods.} \label{tab:retrival_res} \end{table} \begin{table}[!tbh] \setlength{\belowcaptionskip}{-0.3cm} \setlength\tabcolsep{2.1pt} \centering \setlength\tabcolsep{2pt} \begin{tabular}{p{62pt}p{25pt}p{30pt}p{25pt}p{25pt}p{30pt}} \toprule Model & PPL & \multicolumn{2}{c}{BLEU-1,2} & \multicolumn{2}{c}{Dist.-1,2} \\ \midrule Teacher & $23.9^\ddag$ & $12.25^\ddag$&$6.61^\ddag$ & $3.83^\ddag$&$29.69^\ddag$ \\ AP & $50.0^\ddag$ & $10.86^\ddag$&$5.52^\ddag$ & $3.29^\ddag$&$23.37^\ddag$ \\ UP+PreT & $24.0^\ddag$ & 12.60&$6.81^\dag$ & $3.99^\ddag$&$30.50^\ddag$ \\ NP+ML & $23.1^\ddag$ & $11.63^\ddag$&$6.25^\ddag$ & $3.99^\ddag$&$28.47^\ddag$ \\ CVAE+ML & $23.9^\ddag$ & $12.27^\ddag$&$6.59^\ddag$ & $3.73^\ddag$&$26.75^\ddag$ \\ BT+ML & $23.8^\ddag$ & $11.93^\ddag$&$6.48^\ddag$ & $3.84^\ddag$&$27.38^\ddag$ \\ SP+ML & $23.6^\ddag$ & $12.47^\ddag$&$6.74^\ddag$ & 4.04&$30.66^\ddag$ \\ \midrule DL+PreT & $23.7^\ddag$ & \textbf{12.66} &6.92 & $3.95^\ddag$&$30.30^\ddag$ \\ DL+ML & \textbf{22.6} & $12.42^\ddag$&\textbf{6.93} & \textbf{4.13}&\textbf{31.39} \\ \midrule w/o ML & $23.3^\ddag$ & $12.30^\ddag$&$6.65^\ddag$ & 4.06&$30.89^\ddag$ \\ w/o DL & $23.5^\ddag$ & $12.54^\dag$ &6.88 & $3.96^\ddag$&$29.79^\ddag$ \\ w/o PD & $26.7^\ddag$ & $11.08^\ddag$&$5.86^\ddag$ & $3.48^\ddag$&$26.84^\ddag$ \\ w/o Ranking & $22.8^\ddag$ & $12.54^\ddag$&$6.78^\ddag$ & $3.90^\ddag$&$28.93^\ddag$ \\ \bottomrule \end{tabular} \caption{Automatic evaluation results for generation-based dialogue models with different training and data augmentation methods. Significance tests between the best model and others were performed using t-test with booststrap resampling \cite{koehn-2004-statistical}. $\dag$ and $\ddag$ indicates $p$-value \textless~0.005 and 0.001, respectively.} \label{tab:generation_res} \end{table} \subsubsection{Results} Automatic evaluation for each dialogue model is performed on 5K test data (see Table~\ref{tab:retrival_res} and Table~\ref{tab:generation_res} for the results), and manual evaluation is performed using 200 pairs that are randomly sampled from these test data (see Table~\ref{tab:gen_human_res} for the results). The $\kappa$ value for the \emph{Fluency} and \emph{Coherency} annotation is 0.9 (substantial agreement) and 0.56 (moderate agreement), respectively. Our method outperforms all the baselines in almost all the metrics for both retrieval-based and generation-based dialogue models. We can further observe that: \textbf{1}) The dialogue models that utilize unpaired data $\mathcal{D}_u$ (e.g. DL+ML, DL+PreT, UP+PreT) generally outperform the models that are only trained on $\mathcal{D}_p$ (e.g., Teacher, CVAE+ML). This demonstrates that utilizing unpaired data is more effective at improving the performance of dialogue models; \textbf{2}) Training the dialogue models on the merged data $\mathcal{D}_p \bigcup \mathcal{D}_a$ without utilizing the model-level distillation (i.e., w/o ML) brings little or no performance improvements compared to directly training on $\mathcal{D}_p$ (i.e., Teacher). This verifies the effectiveness of the model-level distillation process proposed in our method; \textbf{3}) When the model-level distillation is employed, the augmented data produced by our data-level distillation process (i.e., DL+ML) can better improve the performance of dialogue models compared to the augmented data produced by other data augmentation methods (e.g. CVAE+ML, NP+ML, SP+ML, BT+ML). This verifies the effectiveness of the data-level distillation process proposed in our study. \begin{table}[!tbh] \setlength{\abovecaptionskip}{0.25cm} \setlength{\belowcaptionskip}{-0.3cm} \centering \begin{tabular}{llllll} \toprule Model & Flu. & Coh. \\ \midrule Teacher & $1.968^\ddag$ & $1.432^\ddag$ \\ AP & 1.985 & $1.417^\ddag$ \\ UP+PreT & $1.957^\ddag$ & 1.500 \\ NP+ML & $1.967^\ddag$ & $1.473^\dag$ \\ CVAE+ML & $1.977^\dag$ & $1.475^\dag$ \\ BT+ML & $1.957^\ddag$ & 1.503 \\ SP+ML & $1.973^\dag$ & $1.453^\ddag$ \\ \midrule DL+PreT & 1.975 & $1.492^\dag$ \\ DL+ML & \textbf{1.993} & \textbf{1.518}\\ \bottomrule \end{tabular} \caption{Manual evaluation for generation-based dialogue models. Significant tests between the best model and others were performed using t-test. $\dag$ and $\ddag$ indicate $p$-value \textless~0.05 and 0.01, respectively.} \label{tab:gen_human_res} \end{table} \section{Conclusion} This paper presents a novel dialogue distillation method that consists of two processes, i.e., 1) a data augmentation process to construct new post-response pairs from unpaired data and 2) a model distillation process that distills a teacher model trained on the original data to the augmented data. Automatic and manual evaluation shows that our method can produce high-quality post-response pairs that are both coherent and content-rich, which can be further used to improve the performance of competitive baselines. Our method may inspire other research in low-resource NLP tasks. \section*{Acknowledgments} This work was jointly supported by the NSFC projects (Key project with No. 61936010 and regular project with No. 61876096), and the Guoqiang Institute of Tsinghua University, with Grant No. 2019GQG1. We thank THUNUS NExT Joint-Lab for the support.
{'timestamp': '2020-11-11T02:14:23', 'yymm': '2009', 'arxiv_id': '2009.09427', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09427'}
arxiv
\section{Existence of PROPx} We start with some simple properties of $\text{PROPm}$ comparing it to other versions of fairness. \begin{lemma} If an allocation $X$ satisfies EFx then $X$ is $\text{PROPm}$. \end{lemma} \begin{proof} If an allocation $X$ satisfies EFx then $\val{i}{i} >\val{i}{j}-\minIn{i}{j} \ \forall j\in N$. Thus $\val{i}{i}>\frac{1}{n-1}\sum_{j\in N, j\neq i}(\val{i}{j}-\minIn{i}{j})> \frac{1}{n-1}\sum_{j\in N, j\neq i}(\val{i}{j}-d_{i}(X))$ \end{proof} \begin{corollary}\label{noEFx=Propx} If an agent $i$ does not EFx envy any other agents then $i$ is $\text{PROPm}$. \end{corollary} \begin{lemma}\label{adjVal1} If for an allocation $X$, $\adjVal{i}\geq 1$ then $i$ is $\text{PROPm}$ in $X$. \end{lemma} \begin{proof} $i$ is satisfied by $\text{PROPm}$ if \begin{equation}\label{propXCondition} \val{i}{i} > \frac{1}{n-1}\sum_{j\in N}\val{i}{j}-d_{i}(X) \end{equation} We have \begin{align*} \adjVal{i}=\val{i}{i}+\frac{n-1}{n}d_{i}(X) \geq 1 \Rightarrow \val{i}{i} > 1 - \frac{n-1}{n}d_{i}(X) \end{align*} Hence we get \begin{align*} \sum_{j\in N, j\neq i}\val{i}{j} < n - 1 +\frac{n-1}{n}d_{i}(X) \Rightarrow \frac{1}{n-1}\sum_{j\in N, j\neq i}\val{i}{j} - d_{i}(X) < 1 + \frac{1-n}{n}d_{i}(X) \end{align*} Thus we get $\val{i}{i} \ge 1 \ge \frac{1}{n-1}\sum_{j\in N, j\neq i}\val{i}{j} - d_{i}(X)$ and are done. \end{proof} \begin{corollary}\label{val1} If for an allocation $X$, $\val{i}{i}>1-\frac{n-1}{n}m_{i}(M\setminus X_{i})$ then $i$ is $\text{PROPm}$ in $X$. \end{corollary} One tool we use extensively is the leximin ordering over all the allocations as defined previously. Here we list some basic observations on it. \subsection{The Leximin Ordering} \begin{theorem} The leximin ordering defined according to $R\preceq S$ if $min_{i\in N}\tilde{v}_{i}(R)\le \tilde{v}_{i}(S)$ creates a total ordering over all possible allocations. \end{theorem} \begin{proof} To prove our ordering is a total ordering we must prove that for allocations $Q,R,S \subset 3^M$, \begin{enumerate} \item $Q \prec Q$ is false \item If $Q\preceq R$ and $R\preceq S$ then $Q\preceq S$. \end{enumerate} (1): Start by ordering the adjusted values of all the agents according to their allocation in $Q$. Making 2 copies of this list shows that there are no differences between the agents' adjusted values so $Q=Q$ and $Q \prec Q$ is false. (2): If $Q\preceq R$ then $min_{i\in N}\tilde{v}_{i}(Q)\le min_{i\in N}\tilde{v}_{i}(R)$ for some $i$. If $R\preceq S$ then $min_{j\in N}\tilde{v}_{j}(R)\le min_{j\in N}\tilde{v}_{j}(S)$ for some $j$. If $i=j$ we are done as that means $Q$ and $S$ have the same adjusted values for all agents before $i$ and then $\tilde{v_{i}}(Q_{i})\le \tilde{v_{i}}(S_{i})$ making $Q\preceq S$. If $j\neq i$ then $R$ and $S$ must have had the same adjusted values for agents upto $j$. Thus $\tilde{v_{i}}(S_{i})=\tilde{v_{i}}(R_{i})\ge \tilde{v_{i}}(Q_{i})$ implying that $Q\preceq S$. \end{proof} \begin{corollary} Since there are a finite amount of allocations, there exists a maximum allocation in the leximin ordering. \end{corollary} \begin{lemma}\label{EFxCycleTrade} If $X$ is the maximum allocation in the leximin ordering, then no cycles exist in $X$'s EFx envy graph. \end{lemma} \begin{proof} Assume a cycle does exist in the EFx envy graph. We now show agents can trade bundles across the cycle for a leximin improvement. Call the allocation after swapping across the cycle $X^{\prime}$ Start by considering the agents outside of the cycle. They do not care who owns which bundle as long as the contents of the bundles stay the same. Thus their adjusted value remains constant throughout the swap. Now consider the agents inside the swap. WLOG consider agent $i$ who EFx envies $j$ giving away $X_{i}$ to recieve $X_{j}$ in the cycle swap. We look to show that \begin{equation}\label{leximinImprovement} \val{i}{j}+\frac{n-1}{n}d_{i}(X^{\prime})>\val{i}{i}+\frac{n-1}{n}d_{i}(X) \end{equation} There are 2 cases depending on whether $i$ is pointing towards $j$ in the $\text{PROPm}$ graph of $X.\newline$ Case 1: $d_{i}(X)$ is not defined by $X_{j}$ In this case $d_{i}(X)=d_{i}(X^{\prime})$. Thus all we need to show is that $\val{i}{j}>\val{i}{i}$. This is clear from the fact that $i$ EFx envied $j$. Thus $i$ sees a leximin improvement from the swap.$\newline$ Case 2: $d_{i}(X)$ is defined by $X_{j}$ In this case $d_{i}(X^{\prime})$ could equal 0, so we need to show that $\val{i}{j}>\val{i}{i}+\frac{n-1}{n}d_{i}(X)$. Since $i$ EFx envies $j$, we know that $\val{i}{j}-\minIn{i}{j}>\val{i}{i}$. Furthermore, since $d_{i}(X)$ is defined by $X_{j}$, $\minIn{i}{j}=d_{i}(X)$, so the previous inequality becomes $\val{i}{j}>\val{i}{i}+d_{i}(X)>\val{i}{i}+\frac{n-1}{n}d_{i}(X).\newline$ Since we arbitrarily chose $i$, every agent that is part of the swap saw a leximin improvement from swapping across the cycle. This contradicts the initial assumption that $X$ was already the maximum allocation in the leximin ordering, thus there must not be any cycles in the EFx envy graph. \end{proof} Note that trading across cycles in the EF graph does not necessarily create a leximin improvement. This is because the values for $d_{i}(X)$ might be hurt more than an agent gains. From here, we move onto sufficient conditions for a $\text{PROPm}$ allocation to exist. \subsection{Sufficient Conditions} \begin{theorem}\label{lessThan1} If there exists an agent $i$ and a good $g$ such that $v_{i}(g)\ge 1$, then a $\text{PROPm}$ allocation exists. \end{theorem} \begin{proof} Assume otherwise. Then give the agent $i$ for which $v_{i}(g) \geq 1$ g. Now run the 2-Agent EFx algorithm on the other 2 agents over the remaining item. The agent who recieves the 1 item is satisfied by $\text{PROPm}$ since their adjusted value is above 1. Then the other 2 agents are satisfied since they don't EFx envy anyone. They don't EFx envy each other due to their bundles being allocated by the EFx algorithm, and they don't EFx envy the agent with 1 item since they remove that 1 item and see that agent as having 0 value. \end{proof} We can extend this argument to larger bundles of goods as well. \begin{theorem} If there exists a bundle $B$ such that $v_{i}(B) > 1 - \frac{2}{3}m_{i}(M\setminus B)$ and $v_{j}(B) - m_{j}(B)< \frac{v_j(M\setminus B)}{3} \ \forall j \neq i$ then a $\text{PROPm}$ solution exists. \end{theorem} \begin{proof} Without loss of generality assume that agent $i$ is agent A, and we show that a $\text{PROPm}$ allocation exists using a constructive argument. We let $X_A=B$, i.e., we give agent 1 the bundle $B$, and we define $X_B$ and $X_C$ by computing an EFx allocation of the remaining items among agents B and C, i.e., an allocation such that $\val{B}{B}\geq \val{B}{C}-\minIn{B}{B}$ and $\val{C}{C}\geq \val{C}{B}-\minIn{C}{B}$. From Corollary ~\ref{val1}, we know that $A$ is satisfied by $\text{PROPm}$. In the rest of the proof, we show that the allocation described above also leads to a $\text{PROPm}$ allocation for agent B; symmetric arguments can be used to prove that the same is true for agent C as well. Formally, we prove the following inequality. \begin{equation}\label{ineq:PROPx} v_B(X_B) \ge \frac{\val{B}{A}+\val{B}{C}-2d_{B}(X)}{2} ~~\Longleftrightarrow~~ 2 v_B(X_B) \ge \val{B}{A}+\val{B}{C}-2d_{B}(X) . \end{equation} First, we use the fact, ${v}_B(B)-m_{B}(B)\le \frac{v_B(M\setminus B)}{3}$ and, thus, ${v}_B(X_A)-\minIn{B}{A}\le \frac{v_B(M\setminus X_A)}{3} = \frac{\val{B}{B}+\val{B}{C}}{3}$. Second, we use that $\val{B}{B}\geq \val{B}{C}-\minIn{B}{C}$, due to the fact that $X_B$ and $X_C$ were computed using an EFx algorithm, as discussed above. These two facts, along with $d_{B}(X)=\max(\minIn{B}{A},\minIn{B}{C})$, reduce proving Inequality~\eqref{ineq:PROPx} to satisfying \begin{equation}\label{ineq:PROPx2} 2 \val{B}{B} \ge \frac{\val{B}{B}+\val{B}{C}}{3}+\val{B}{B} ~~\Longleftrightarrow~~ \val{B}{B} \ge \frac{\val{B}{C}}{2}. \end{equation} Therefore, if $\val{B}{B} \ge \frac{\val{B}{C}}{2}$, then this allocation is PROPx. Also, note that if $X_A$ contains less than two items, then $\val{B}{A}-\minIn{B}{A}=0$ and Inequality~\eqref{ineq:PROPx} becomes $2 v_B(X_B) \ge v_B(X_C)-\minIn{B}{C}$, which is clearly satisfied since $v_B(X_B) \ge v_B(X_C)-\minIn{B}{C}$ by EFx between agents 2 and 3. To conclude the proof, we focus on instances where $X_A$ contains at least two items and we show that Inequality~\eqref{ineq:PROPx2} is true for all such instances with valuations $v_{i}(g)< 1$. Which is the case or else we are done by Theorem ~\ref{lessThan1}. In order to do so, we first observe that, since $X_A$ contains at least two items, $v_B(X_A)\leq 2v_B(X_A)-\minIn{B}{A}$, due to the fact that the least valuable item in $X_A$ from the perspective of agent 2 cannot have more than half of the total value in $X_A$, i.e., $\minIn{B}{A}\leq v_B(X_A)/2$. Combined with the fact that ${v}_B(X_A)-\minIn{B}{A}\le \frac{v_B(M\setminus X_A)}{3}$ (according to the theorem statement) and the fact that $v_B(X_A)+v_B(X_B)+v_B(X_C)=3$, this implies that \begin{equation*} v_B(X_B)+v_B(X_C) = 3-v_B(X_A) \geq 3 - 2\frac{v_B(M\setminus X_A)}{3} = 3 - 2\frac{v_B(X_B)+v_B(X_C)}{3} ~~\Longrightarrow~~ v_B(X_B)+v_B(X_C) \geq \frac{9}{5}. \end{equation*} If Inequality~\eqref{ineq:PROPx2} is not satisfied, i.e., if $v_B(X_B) < \frac{v_B(X_C)}{2}$, then the fact that $v_B(X_B)+v_B(X_C) \geq \frac{9}{5}$ implies that $v_B(X_C)>\frac{2}{3}\cdot \frac{9}{5}=\frac{6}{5}$. Then $X_C$ must contain at least two items, otherwise its single item would have a value larger than 1. Since $X_C$ contains at least two items, then $\minIn{B}{C}\leq v_B(X_C)/2$, i.e., the value of agent 2 for his least favorite item in $X_C$ can be no more than half of his value for all of $X_C$. This implies that the adjusted value of agent 2 for $X_C$ is at least half of his actual value for it, i.e., $\val{B}{C}-\minIn{B}{C}\geq v_B(X_C)/2$. But, since $v_B(X_B)\geq {v}_B(X_C)-\minIn{B}{C}$, due to the EFx property between agents 2 and 3, these two inequalities imply the desired $v_B(X_B) \ge \frac{v_B(X_C)}{2}$. \end{proof} \begin{theorem} If there exists a bundle $B$ such that $v_{i}(B) > 1 - \frac{2}{3}m_i(M\setminus B)$ , and $v_{j}(B) < 1-\frac{p}{3} \ \forall j \neq i \in N$, where $v_{j}(g) < p \ \forall g \in M/B \ \forall j \neq i$ then a $\text{PROPm}$ solution exists. \end{theorem} \begin{proof} Just as the previous theorem, we construct a $\text{PROPm}$ allocation. WLOG assume the agent $i$ is $A$. Give $A$ $B$, and then run the 2-agent EFx algorithm to allocate the remaining items to $B$ and $C$. We know $A$ is satisfied by Lemma ~\ref{val1}. It remains to show that $B$ and $C$ are satisfied by $\text{PROPm}$. We prove $B$ is satisfied, with the same argument following symmetrically for $C$. The theorem statement and our construction give us the following inequalities \begin{equation}\label{bundleThmEq1} v_{B}(B)\le 1- \frac{p}{3} \end{equation} \begin{equation}\label{bundleThmEq2} \val{B}{B}+\val{B}{C}=3-v_j(B) \end{equation} \begin{equation}\label{bundleThmEq3} \val{B}{B}\ge \val{B}{C}-p \end{equation} We can then combine ~\eqref{bundleThmEq1} and ~\eqref{bundleThmEq2} to get \begin{equation} \val{B}{B}+\val{B}{C}\ge 2 +\frac{p}{3} \Rightarrow 2\val{B}{B}\ge 2-\frac{2p}{3} \Rightarrow \val{B}{B}\ge 1-\frac{p}{3} \end{equation} Thus $\val{B}{B} \ge \val{B}{A}-\minIn{B}{A}$ and $\val{B}{C} \ge \val{B}{A}-\minIn{B}{C}$. So $B$ does not EFx envy anyone and is hence satisfied by $\text{PROPm}$. \end{proof} \begin{corollary} If there exists a bundle $B$ such that $v_{i}(B) > 1 - \frac{2}{3}m_i(M\setminus B)$ , and if $v_{j}(B)-m_{j}(B) < 1-\frac{p+\sigma}{3} \ \forall j \neq i \in N$, where $v_{j}(g) < p \ \forall g \in M/B \ \forall j \neq i$, and $v_{j}(g) \leq \sigma \ \forall g \in B \ \forall j \neq i$ then a $\text{PROPm}$ solution exists. \end{corollary} \begin{proof} The proof follows exactly the same as the previous theorem, just adding in a $\sigma$ and subtracting $m_{j}(B)$ wherever applicable. \end{proof} \section{Introduction} \input{introduction} \section{Additional Related Work} \input{related_work} \section{Our Results} \input{ourResults} \section{Preliminaries} \input{preliminaries} \section{Initial Observations}\label{sec:observations} \input{initialobservations} \section{PROPm Allocations for 4-Agent Instances} \input{propX_4agents} \section{PROPm Allocations for 5-Agent Instances} \input{propX_5agents} \section{Extensions and Average EFx} \input{futurework} \section{Conclusion}\label{sec:conclusion} \input{conclusion} \bibliographystyle{plainnat}
{'timestamp': '2021-01-15T02:21:56', 'yymm': '2009', 'arxiv_id': '2009.09508', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09508'}
arxiv
\section{Introduction} Significant amounts of individual information are being collected and analyzed today through a wide variety of applications across different industries~\cite{aarons2012dynamic}. Differential privacy has been widely recognized as the de facto standard notion~\cite{Dwork08differentialprivacy:,10.1007/11681878_14} in protecting individuals' privacy during such data collection and analysis. On the other hand, since the privacy constraints (e.g., the degree of randomization) imposed by differential privacy may render the released data less useful for analysis, the fundamental trade-off between privacy and utility (i.e., analysis accuracy) has attracted significant attention in various settings~\cite{10.1007/11681878_14,erlingsson2014rappor,lee2013pibox,NissimRS07,RastogiN10,DworkNRRV09}. In this context, a key issue is to identify the optimal randomization mechanisms (i.e., distributions and their parameters)~\cite{Ghosh1,Gupte1,6875258,DBLP:journals/jstsp/GengKOV15,DBLP:conf/icml/BalleW18,DBLP:journals/corr/abs-1809-10224, Hardt:2010:GDP:1806689.1806786,5670945}). While optimizing the parameters of a given distribution can be easily automated, identifying the optimal distribution for different utility metrics is more challenging, and typically requires manual analysis to examine the search space of all distributions. In fact, recent studies~\cite{Ghosh1,Gupte1,6875258,DBLP:journals/jstsp/GengKOV15,DBLP:conf/icml/BalleW18,DBLP:journals/corr/abs-1809-10224, Hardt:2010:GDP:1806689.1806786,5670945} have only identified the optimal randomization mechanisms for a limited number of cases with specific utility metrics and queries. For instance, Ghosh et al.~\cite{Ghosh1,Gupte1} showed that an optimal randomization mechanism (adding a specific class of \textit{geometric noise}) can be used to preserve differential privacy under the class of negative expected loss utility metrics for a single counting query. Subsequently, Geng et al.~\cite{6875258} showed that, under the $\ell_1$ and $\ell_2$ norms, the widely used standard Laplace mechanism is asymptotically optimal as $\epsilon \rightarrow 0$, whereas the Staircase mechanism (which can be viewed as a geometric mixture of uniform probability distributions) performs exponentially better than the Laplace mechanism in case of weaker privacy guarantees (a comprehensive literature review will be given in Section~\ref{rel}). However, this has left the optimal distributions of many other utility metrics as open problems, e.g., usefulness (for machine learning applications~\cite{Blum:2008:LTA:1374376.1374464}), entropy-based measures (for signal processing applications~\cite{cohen1993majorization,cdcc}, and semi-supervised learning~\cite{grandvalet2005semi}), and graph distance metrics (for social network applications~\cite{10.1007/978-3-642-36594-2_26}). As shown in the works of Ghosh et al.~\cite{Ghosh1,Gupte1} and Geng et al.~\cite{6875258}, different utility metrics will likely lead to different optimal distributions. Moreover, since those existing works mostly rely on manual analysis to examine the search space of all distributions, it would be an expensive process to repeat such efforts for each utility metric. Consequently, many existing works simply employ a well-known distribution (e.g., Laplace noise with constant scale parameter or Gaussian noise with constant variance) without worrying about its optimality. Unfortunately, as our experimental results will show (Section~\ref{exp:sec}), choosing a non-optimal distribution (even with its parameters optimized) may lead to rather poor utility. \vspace{-0.1in} \begin{figure}[ht] \centering \includegraphics[width=1\linewidth,viewport=82 2 920 563,clip]{overview1.pdf} \vspace{-0.05in} \caption{R$^2$DP can automatically optimize different utility metrics which have no known optimal distributions.}\vspace{-0.1in} \label{Fig:2} \end{figure} \subsection{R$^2$DP: A Universal Framework} Our key observation is the following. To build a universal framework that can automatically find the optimal distribution in the search space of all distributions, we would need a formulation to link the differential privacy guarantee to the parameters of different distributions (e.g., in Laplace mechanism, $\epsilon$ is proportionally related to the inverse of variance). However, it is a known fact that such a formulation varies for each distribution, which explains why existing works have to rely on manual efforts to cover the search space of all distributions, and it also becomes the main obstacle to finding a universal solution that works for all utility metrics employed in different applications. As depicted in Figure~\ref{Fig:2}, our key idea is that, although it is not possible to directly cover the search space of all distributions in an automated fashion, we can indirectly do so based on the following known fact in probability theory, i.e., a two-fold randomization over the exponential class of distributions may yield many other distributions to approximately cover the search space~\cite{Charalambides:2005:CMD:1196346}. Since this class of distributions are all originated from one of the exponential family distributions, their differential privacy guarantee will become a unique function of the parameters of the second fold distribution. Therefore, these parameters can be used to automatically optimize utility w.r.t. different utility metrics through a universal framework, namely, \emph{r}andomizing the \emph{r}andomization mechanism in \emph{d}ifferential \emph{p}rivacy (R$^2$DP). Furthermore, the two-fold distribution introduces an added degree of freedom, which allows R$^2$DP to incorporate the requirements of both data owners and data recipients. \subsection{Contributions} Specifically, we make the following contributions: \begin{enumerate} \item We define the R$^2$DP framework with several unique benefits. First, it provides the first universal solution that is applicable to different utility metrics, which makes it an appealing solution for applications whose utility metrics have no known optimal distributions (e.g., ~\cite{Blum:2008:LTA:1374376.1374464,cohen1993majorization,cdcc,10.1007/978-3-642-36594-2_26}). Second, unlike most existing works which rely on manual analysis~\cite{Ghosh1,Gupte1}, R$^2$DP can automatically identify a distribution that yields near-optimal utility, and hence is more practical for emerging applications. Third, R$^2$DP can incorporate the requirements of both data owners and data recipients, which addresses a practical limitation of most existing approaches, i.e., only the privacy budget $\epsilon$ is considered in designing the differentially private mechanisms. \item We formally benchmark R$^2$DP under the well-studied Laplace mechanism. We tackle several key challenges related to the two-fold distribution in R$^2$DP. We then show that this mechanism yields a class of log-convex distributions for which the differential privacy guarantee can globally be given in terms of the PDFs' parameters. We also show that it can generate near-optimal results w.r.t. a variety of utility metrics whose optimality is known, e.g., Staircase-shape distribution for large $\epsilon$ and Laplace itself for small $\epsilon$ \cite{6875258}. \item We evaluate R$^2$DP using six different utility metrics, both numerically and experimentally on real data, using both statistical queries (e.g., count and average), and data analytics applications (e.g., machine learning and social network). The experimental results demonstrate that R$^2$DP can significantly increase the utility for those utility metrics with no known optimal distributions (compared to the baseline Laplace distribution). We also evaluate the optimality of R$^2$DP using utility metrics whose optimal distributions are known (e.g., Staircase-shape for $\ell_1$ and $\ell_2$ norms \cite{6875258}) and our results confirm that R$^2$DP can generate near-optimal results. \item We discuss the potential of adapting R$^2$DP to improve a variety of other applications related to differential privacy. \end{enumerate} The rest of the paper is organized as follows. Section~\ref{sec:model} provides some related background. Section~\ref{sec4} defines the R$^2$DP framework. Section~\ref{sec5} formally studies the differential privacy guarantee and the utility of R$^2$DP. Section~\ref{exp:sec} presents the experiments. Section~\ref{relat} reviews the related work, and Section~\ref{sec:conclusion} concludes the paper. \input{overview} \input{RPDPmodel} \input{UtilityRPDP.tex} \section{Experimental Evaluations} \label{exp:sec} \input{Exp} \section{Related Work} \label{rel} \input{rel} \section{Conclusion} \label{sec:conclusion} This paper has proposed the R$^2$DP framework as a universal solution for optimizing a variety of utility metrics requested in different applications. It can automatically identify a distribution that yields near-optimal utility, and hence is more practical for emerging applications. Specifically, we have shown that a differentially private mechanism could be defined based on a random variable which is itself distributed according to some parameterized distributions. We have also shown that such a mechanism could explicitly take into account both the privacy requirements and the utility requirements specified by the data owner and data recipient, respectively. We have formally analyzed the privacy guarantee of R$^2$DP based on the well-known Laplace mechanism and formally proved the improvement of utility over the baseline Laplace mechanism. Furthermore, we discuss the potential of applying R$^2$DP to advanced algorithms. Finally, our experimental results based on six different utility metrics for statistical queries, machine learning and social network, as well as one privacy metric, have demonstrated that R$^2$DP could significantly improve the utility of differentially private solutions for a wide range of applications. \section{Acknowledgements} We thank the anonymous reviewers for their valuable comments and suggestions. This work is partially supported by the Natural Sciences and Engineering Research Council of Canada and Ericsson Canada under the Industrial Research Chair (IRC) in SDN/NFV Security. It is also partially supported by the National Science Foundation under Grant No. CNS-1745894. \section*{Appendix} \section{Demonstration of Theorem~\ref{thm: RPLap mech}} \label{demonst} A Laplace distribution is of a $(\propto x\cdot e^{x\cdot t})$ order, where $x$ is the inverse of the scale parameter. Second, since $x\cdot e^{x\cdot t}=\diff{e^{x\cdot t}}{t}$, the cumulative distribution function (CDF) resulted from randomizing $x$ can be expressed in terms of the expectation $\mathbb E(e^{x\cdot t})$. We note that from now on, we will simply refer to R$^2$DP with Laplace distribution as the first fold PDF as \textit{the R$^2$DP mechanism}. \begin{figure}[!h] \centering \includegraphics[width=0.9\linewidth]{newfig/mo.pdf} \caption{The term in the parenthesis is the derivative of $\mathbb E(e^{\frac{1}{b}\cdot -|w|})$ w.r.t. $-|w|$, and hence the above probability can be expressed in terms of the expectation} \label{Fig:moment} \end{figure} \begin{exmp} \label{exmp1} Following Example~\ref{exmprpdp}, for a Bernoulli distributed scale parameter $b$, Figure~\ref{Fig:moment} illustrates the above finding (see Appendix~\ref{proofexamp} for proof). It can be verified that the term inside the braces is the derivative of $\mathbb {E}(e^{\frac{1}{b}\cdot -|w|})$ w.r.t. $-|w|$, and hence the above probability can be expressed in terms of the expectation. \end{exmp} \section{Case Study PDFs} \label{cases} \subsubsection{Discrete Probability Distributions} First, we consider two different mixture Laplace distributions that can be applied for constructing R$^2$DP with discrete probability distribution $f_b$. \vspace{0.05in} (1) \textbf{Degenerate distribution.} A degenerate distribution is a probability distribution in a (discrete or continuous) space with support only in a space of lower dimension~\cite{bremermann1965distributions}. If the degenerate distribution is uni-variate (involving only a single random variable), it will be a deterministic distribution and takes only a single value. Therefore, the degenerate distribution is identical to the baseline Laplace mechanism as it also assigns the mechanism one single scale parameter $b_0$. Specifically, the probability mass function of the uni-variate degenerate distribution is: \[ f_{\delta,k_0}(x)= \begin{cases} 1 & x= k_0 \\ 0 & x\neq k_0 \end{cases} \] The MGF for the degenerate distribution $\delta_{k_0}$ is given by $M_k(t)=e^{t\cdot k_0}$~\cite{bulmer1979principles}. Using Equation~\ref{simple DPeq}, Theorem~\ref{degenerateDP} gives the same DP guarantee as the baseline Laplace mechanism. \begin{thm} \label{degenerateDP} The R$^2$DP mechanism $M_q(d,\epsilon)$, $\epsilon \sim f_{\delta,\frac{1}{b_0}}(\epsilon)$, is $\frac{\Delta q}{b_0}$-differentially private. \end{thm} Obviously, this distribution does not improve the bound in Theorem~\ref{thm: RPLap mechut} but shows the soundness of our findings. \vspace{0.05in} (2) \textbf{Bernoulli distribution.} The probability mass function of this distribution, over possible outcomes $k$, is \[ f_{B}(k;p)=\begin{cases}p&{\text{if }}k=1,\\1-p&{\text{if }}k=0.\end{cases}\] Note that the binary outcomes $k=0$ and $k=1$ can be mapped to any two outcomes $X_0$ and $X_1$, respectively. Therefore, we consider the following Bernoulli outcomes \[ f_{B,X_0, X_1}(X;p)=\begin{cases}p&{\text{if }}X=X_1,\\1-p&{\text{if }}X=X_0.\end{cases}\] The MGF for Bernoulli distribution $f_{B,X_0, X_1}(X;p)$ is $M_X(t)=p\cdot e^{t\cdot X_0}+(1-p)\cdot e^{t\cdot X_1}$~\cite{bulmer1979principles}. We now derive the precise differential privacy guarantee of an R$^2$DP mechanism with its scale parameter randomized according to a Bernoulli distribution. \begin{thm} \label{bernoulidp} The R$^2$DP mechanism $M_q(d,\epsilon)$, $\epsilon\sim f_{B,\frac{1}{b_0},\frac{1}{b_1}}(\epsilon;p)$, satisfies $\ln [p\cdot e^{\frac{\Delta q}{b_0}}+(1-p)\cdot e^{\frac{\Delta q}{b_1}}]$ differential privacy. \end{thm} This bound is exactly the mean of $e^{\epsilon(b)}$ given in Theorem~\ref{thm: RPLap mechut}. \subsubsection{Continuous Probability Distributions} We now investigate three compound Laplace distributions. \vspace{0.05in} (1) \textbf{Gamma distribution.} The gamma distribution is a two-parameter family of continuous probability distributions with a shape parameter $k>0$ and a scale parameter $\theta$. Besides the generality, the gamma distribution is the maximum entropy probability distribution (both w.r.t. a uniform base measure and w.r.t. a $1/x$ base measure) for a random variable $X$ for which $\mathbb E (X) = k \theta = \alpha/\beta$ is fixed and greater than zero, and $\mathbb E[\ln(X)] = \psi(k) + \ln(\theta) = \psi(\alpha)-\ln(\beta)$ is fixed ($\psi$ is the digamma function). Therefore, it may provide a relatively higher privacy-utility trade-off in comparison to the other candidates~\cite{zwillinger2002crc,jambunathan1954some}. A random variable $X$ that is gamma-distributed with shape $\alpha$ and rate $\beta$ is denoted by $X\sim \Gamma(k,\theta)$ and the corresponding PDF is \begin{equation*} f_{\Gamma}(X;k,\theta) {\displaystyle={\frac {x^{k -1}e^{-\frac{x}{\theta}}}{\Gamma (k)\cdot \theta^k}}\quad {\text{ for }}X>0{\text{ and }}k ,\theta >0,} \end{equation*} where $\Gamma ( \alpha )$ is the gamma function. We now investigate the differential privacy guarantee provided by assuming that the reciprocal of the scale parameter $b$ in Laplace mechanism is distributed according to the gamma distribution (see Appendix~\ref{proofgama} for the proof). \begin{thm} \label{gamadist} The R$^2$DP mechanism $M_q(d,\epsilon)$, $\epsilon \sim f_{\Gamma}(\epsilon;k,\theta)$, satisfies $\big((k+1)\cdot \ln (1+\Delta q \cdot \theta)\big)$ differential privacy. \end{thm} We now apply the necessary condition given in Equation~\ref{necc} (see Appendix~\ref{lemgama} for the proof). \begin{lem} \label{necsgama} R$^2$DP using Gamma distribution can satisfy the necessary condition in Equation~\ref{necc}. \end{lem} Therefore, Gamma distribution may improve over the baseline, and this can be computed by optimizing the privacy-utility trade-off using the Lagrange multiplier function in Equation~\ref{lagrange1}. Also, our numerical results show that, this distribution is more effective for large $\epsilon$ (weaker privacy guarantees). \vspace{0.05in} (2) \textbf{Uniform distribution.} In probability theory and statistics, the continuous uniform distribution or rectangular distribution is a family of symmetric probability distributions such that for each member of the family, all intervals of the same length on the support of the distribution are equally probable. The support is defined by the two parameters, $a$ and $b$, which are the minimum and maximum values. The distribution is often abbreviated as $U(a,b)$, which is the maximum entropy probability distribution for a random variable $X$ under no constraint; other than that, it is contained in the distribution's support~\cite{zwillinger2002crc,jambunathan1954some}. The MGF for $U(a,b)$ is \[ M_X(t)=\begin{cases}\frac{e^{tb}-e^{ta}}{t(b-a)}&{\text{for }}t\neq 0,\\1&{\text{for }}{\text{for }}t=0.\end{cases}\] Using Theorem~\ref{simple DP}, we now drive the precise differential privacy guarantee of an R$^2$DP mechanism for uniform distribution $U(a,b)$. \begin{thm} \label{uniformdist} The R$^2$DP mechanism $M_q(d,\epsilon)$, $\epsilon \sim f_{U(a,b)}(\epsilon)$, is $\ln \big[\frac{\alpha^2-\beta^2}{2((1+\beta)e^{-\beta}-(1+\alpha)e^{-\alpha})} \big]$-differentially private, where $\alpha=a\cdot \Delta q$ and $\beta=b\cdot \Delta q$. \end{thm} We now apply the necessary condition given in Equation~\ref{necc}. One can easily verify that the inequality holds for an infinite number of settings, e.g., $a=0.5$, $b=9$ and $\Delta q=1.2$. \begin{lem} \label{necsuniform} R$^2$DP using uniform distribution can satisfy the necessary condition in Equation~\ref{necc}. \end{lem} Therefore, R$^2$DP using uniform distribution may improve over the baseline, and this can be computed by optimizing the privacy-utility trade-off using the Lagrange multiplier function in Equation~\ref{lagrange1}. Also, our numerical results show that, this distribution can also be effective for both small and large $\epsilon$. \vspace{0.05in} (3) \textbf{Truncated Gaussian distribution.} The last distribution we consider is the Truncated Gaussian distribution. This distribution is derived from that of a normally distributed random variable by bounding the random variable from either below or above (or both). Therefore, we can benefit from the numerous useful properties of Gaussian distribution, by truncating the negative region of the Gaussian distribution. Suppose $X\sim \mathcal N(\mu ,\sigma ^{2})$ has a Gaussian distribution and lies within the interval $X\in (a,b),\;-\infty \leq a<b\leq \infty$. Then, $X$ conditional on $a<X<b$ has a truncated Gaussian distribution with the following probability density function \vspace{-0.15in} \begin{equation*} f_{\mathcal N^T}(X;\mu ,\sigma,a,b) {\displaystyle={\frac {\phi(\frac{X-\mu}{\sigma})}{\sigma\cdot \big(\Phi(\frac{b-\mu}{\sigma})-\Phi(\frac{a-\mu}{\sigma})\big)}}\quad {\text{for }}a\leq x\leq b} \end{equation*} and by $f_{\mathcal N^T}=0$ otherwise. Here, $\phi(x)=\frac{1}{\sqrt{2\pi}\cdot} e^{-\frac{x^2}{2}}$ and $\Phi(x)=1-Q(x)$ are PDF and CDF of the standard Gaussian distribution, respectively. Next, using Theorem~\ref{simple DP}, we give the differential privacy guarantee provided by the mechanism assuming that the reciprocal of $b$ is distributed according to the truncated Gaussian distribution. \begin{thm} \label{truncateddist} The R$^2$DP mechanism $\mathcal M_q(d,\epsilon)$, $\epsilon \sim f_{\mathcal N^T}(\epsilon;\mu ,\sigma,a,b)$, satisfies $\epsilon_{N^T}$- differential privacy, where \begin{align} \epsilon_{N^T}=\ln\left[\cfrac{\mu+\cfrac{\sigma\cdot(\phi(\alpha)-\phi(\beta))}{(\Phi(\beta)-\Phi(\alpha))}}{\diff{M_{N^T}(t)}{t}|_t=-\Delta q}\right] \end{align} in which $\phi(\cdot)$ is the probability density function of the standard normal distribution, $\phi(\cdot)$ is its cumulative distribution function and $\alpha=\frac{a-\mu}{\sigma}$ and $\beta=\frac{b-\mu}{\sigma}$. \end{thm} \begin{lem}[see Appendix~\ref{label:trunclem} for the proof] \label{necstrunc} R$^2$DP using truncated Gaussian distribution can satisfy the necessary condition in Equation~\ref{necc}. \end{lem} Therefore, truncated Gaussian distribution may improve over the baseline, and this can be computed by optimizing the privacy-utility trade-off using the Lagrange multiplier function in Equation~\ref{lagrange1}. In particular, our numerical results show that, this distribution can also be effective for smaller $\epsilon$ (stronger privacy guarantees). \section{Proofs} \label{proofsec} \begin{proof}[Example~\ref{exmp1}] \label{proofexamp} Following Example~\ref{exmprpdp}, for a Bernoulli distributed scale parameter $b$, we have \begin{eqnarray*} \label{eqn10} &\hspace{-2cm}\mathbb P(\mathcal M_q(d,b)\in S)\nonumber\\ &\hspace{-0.5cm}= \displaystyle\int_{\mathbb R} \frac{p}{2b_1} \cdot \mathds{1}_S\{q(d)+w\} e^{\frac{-|w|}{b_1}} +\frac{1-p}{2b_2} \cdot \mathds {1}_S\{q(d)+w\} e^{\frac{-|w|}{b_2}}dw \nonumber \\ &\hspace{-0.5cm}= \displaystyle\int_{\mathbb R} \big(\frac{p}{2b_1} \cdot e^{\frac{-|w|}{b_1}} +\frac{1-p}{2b_2} \cdot e^{\frac{-|w|}{b_2}} \big) \mathds{1}_S\{q(d)+w\}dw \nonumber \\ \end{eqnarray*} where $\mathds{1}_{\{\cdot\}}$ denotes the indicator function. It can be verified that the term in the braces is the derivative of $\mathbb E(e^{\frac{1}{b}\cdot -|w|})$ w.r.t. $-|w|$, and hence the above probability can be expressed in terms of the expectation. \end{proof} \begin{proof}[Theorem~\ref{thm: RPLap mech}] \label{thm3.1} For an R$^2$DP Laplace mechanism and $\forall S\subset \mathbb R$ measurable and dataset $d$ in $\mathsf D$, we have \begin{eqnarray} \label{eqn11} &\mathbb P(\mathcal M_q(d,b)\in S)\nonumber\\ &=\displaystyle \int_{\mathbb R_{\geq 0}} f(b) \frac{1}{2b} \displaystyle \int_{\mathbb R} \mathds{1}_S\{q(d)+w\} e^{\frac{-|w|}{b}} \ dw \ db \nonumber \\ &=\displaystyle \int_{\mathbb R_{\geq 0}} g(u) \frac{u}{2} \int_{\mathbb R} \mathds{1}_S\{q(d)+w\} e^{-|w|\cdot u} \ dw \ du \nonumber \\ &= \displaystyle \int_{\mathbb R} \mathds{1}_S\{q(d)+w\} \int_{\mathbb R_{\geq 0}} g(u) \frac{u}{2} e^{-|w|\cdot u} \ du \ dw \nonumber \\ &= \displaystyle \int_{\mathbb R} \mathds{1}_S\{q(d)+w\} \frac{1}{2} \frac{d M_u(t)}{dt}|_{t=-|w|} \ dw \nonumber \\ &= \frac{1}{2} \displaystyle \int_{S} \frac{d M_u(t)}{dt}|_{t=-|x-q(d)|} dx \end{eqnarray} \begin{eqnarray} \label{lR$^2$DPlap1} &\hspace{-0.4cm}=\frac{1}{2} \cdot \Big[-M_u(-|x-q(d)|)|_{S_{\geq q(d)}}+M_u(-|x-q(d)|)|_{S_{< q(d)}}\Big] \end{eqnarray} where $u=b^{-1}$, is reciprocal of random variable $b$ and $g(u)=\frac{1}{u^2}\cdot f(\frac{1}{u})$. Note that $M_u(t)$ is the MGF of random variable $u$ which is identical with $M_{\frac{1}{b}}(t)$. \end{proof} \begin{proof}[Theorem~\ref{simple DP}] To prove this theorem, we first need to give two lemmas on the properties of R$^2$DP Laplace mechanism and MGFs. \begin{lem}\label{thm: RPLap mechDP} The R$^2$DP mechanism $\mathcal M_q(d,b)$, is \begin{equation} \label{eqeps0} \ln \left[\max \limits_{\forall x\in\mathbb R} \left\{ \cfrac{\diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d)|}}{\diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d')|}} \right\}\right]\text{-differentially private.} \end{equation} \end{lem} \begin{proof} \label{proofthm: RPLap mechDP} According to Equation~\ref{eqn11}, \begin{eqnarray*} \label{eq13} &\mathbb P(\mathcal M_q(d,b) \in S)= \frac{1}{2} \displaystyle \int_{S} \diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d)|} dx \\ &= \frac{1}{2} \displaystyle \int_{S} \cfrac{\diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d)|}}{\diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d')|}} \cdot \diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d')|} dx \nonumber \end{eqnarray*} Denote by \begin{eqnarray*} & e^\epsilon =\sup{\left\{ \cfrac{\diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d)|}}{\diff{M_{\frac{1}{b}}(t)}{t}|_{t=-|x-q(d')|}} ,\forall x\in S \right\}}, \\ &\Rightarrow \mathbb P(\mathcal M_q(d,b) \in S) \leq e^\epsilon \cdot \mathbb P(\mathcal M_q(d',b) \in S) \end{eqnarray*} and the choice of $S=\mathbb R$ concludes the proof. \end{proof} Next, we show the log-convexity property of the first derivative of moment generating functions. \begin{lem} First derivative of a moment generating function defined by $\diff{M(t)}{t}=\mathbb E(z\cdot e^{zt})$ is log-convex. \end{lem} \begin{proof} For real- or complex-valued random variables $X$ and $Y$, H\"{o}lder's inequality~\cite{trove.nla.gov.au/people/850680} reads; $\mathbb E(|XY|)\leq (\mathbb E(|X|)^p)^{1/p} \cdot (\mathbb E(|Y|)^q)^{1/q}$ for any $1<p,q<\infty$ with $1/p+1/q=1$. Next, for all $\theta \in (0,1)$ and $0\leq x_1,x_2 <\infty$, define $X=z ^\theta \cdot e^{\theta x_1 z}$, $Y=z ^{1-\theta} \cdot e^{(1-\theta) x_2 z}$ and $p=1/\theta$, $q=1/(1-\theta)$. Therefore, we have \begin{equation*} \mathbb E(z\cdot e^{(\theta x_1 +(1-\theta) x_2 z})\leq \mathbb E(z\cdot e^{x_1 z})^{\theta} \cdot \mathbb E(z\cdot e^{x_2 z})^{1-\theta} \end{equation*} which shows the definition of log-convexity holds for $M'(t)$. \end{proof} Back to the original proof, following the DP guarantee in Lemma~\ref{thm: RPLap mechDP}, and using triangle inequality, we have \begin{eqnarray*} &e^{\epsilon}= \max \limits_{\forall x\in\mathbb R} \left\{ \frac{\mathbb E(\epsilon\cdot e^{(-|x-q(d)|\cdot \epsilon)})}{\mathbb E(\epsilon\cdot e^{(-|x-q(d')|\cdot \epsilon)})} \right\}\leq \max \limits_{\forall t\in\mathbb R_{\leq 0}} \left\{\frac{\mathbb E(\epsilon \cdot e^{( t\cdot \epsilon)})}{\mathbb E(\epsilon\cdot e^{((t-\Delta q)\cdot \epsilon)})}\right\}\\ \end{eqnarray*} Next, we show that $f(t)=\frac{\mathbb E(\epsilon \cdot e^{( t\cdot \epsilon)})}{\mathbb E(\epsilon\cdot e^{((t-\Delta q)\cdot \epsilon)})}$ is non-decreasing w.r.t. $t$. For this purpose, we must show that \begin{equation*} f'(t)=\frac{M''(t)\cdot M'(t-\Delta q) -M'(t)\cdot M''(t-\Delta q)}{M'^2(t-\Delta q)} \end{equation*} is non-negative. However, this is equivalent to show that $\frac{M''(t)}{M'(t)} \geq \frac{M''(t-\Delta q)}{M'(t-\Delta q)}$ or more generally $\frac{M''(t)}{M'(t)}$ is not-decreasing. However, following the log-convexity of first $M'(t)$, the logarithmic derivative of $M'(t)$ denoted by $\frac{M''(t)}{M'(t)}$ is non-decreasing. Thus, for all $t<0$, $f(t)\leq f(0)$, and evaluating $e^{\epsilon(t)}$ at $ t=0$, concludes our proof. \end{proof} \begin{proof}[Theorem~\ref{thm: RPLap mechut}] \label{necescond} Following Theorem~\ref{thmuselap}, an $\epsilon$-DP Laplace mechanism is $(\gamma,e^{\frac{-\gamma}{b(\epsilon)}})$-useful for all $\gamma \geq 0$, where $b(\epsilon)=\frac{\Delta q}{\epsilon}$. Therefore, for the usefulness of the baseline Laplace mechanism at $\epsilon=\ln [ \mathbb E_{\frac{1}{b}}( e^{\epsilon(b)} ) ]$, we have \begin{eqnarray*} e^{\frac{-\gamma\cdot\ln [ \mathbb E_{\frac{1}{b}} ( e^{\epsilon(b)} ) ]}{\Delta q}}=\big(\mathbb E_{\frac{1}{b}} ( e^{\epsilon(b)} ) \big)^{\frac{-\gamma}{\Delta q}}= \big(\mathbb E_{\frac{1}{b}} ( e^\frac{\Delta q}{b} ) \big)^{\frac{-\gamma}{\Delta q}} \leq \mathbb E_{\frac{1}{b}} \big(e^{\frac{-\gamma}{b}} \big) \end{eqnarray*} where the last inequality relation is verified by Jensen inequality~\cite{jensen1906fonctions} as $g(x)=x^{\frac{-\gamma}{b}}$ is a convex function. Recall the following Jensen inequality: Let $(\Omega ,\mathfrak {F},\operatorname {P})$ be a probability space, $X$ an integrable real-valued random variable and $g$ a convex function. Then \begin{equation*} g(\mathbb E(X))\leq \mathbb E(g(X)) \end{equation*} Therefore, \begin{eqnarray*} 1-e^{\frac{-\gamma\cdot\ln [ \mathbb E_{\frac{1}{b}} ( e^{\epsilon(b)} ) ]}{\Delta q}}\geq 1- \mathbb E_{\frac{1}{b}} \big(e^{\frac{-\gamma}{b}} \big) =U(\ln [ \mathbb E_{\frac{1}{b}} ( e^{\epsilon(b)} ) ],\Delta q,\gamma) \end{eqnarray*} This completes the proof. \end{proof} \begin{proof}[Theorem~\ref{degenerateDP}] For $\frac{1}{b}\sim f_{\delta,\frac{1}{b_0}}(\frac{1}{b})$, the MGF is given by $M_{\frac{1}{b}}(t)=e^{\frac{t}{b_0}}$. Following Theorem~\ref{thm: RPLap mechDP}, one can write \begin{eqnarray*} &e^{\epsilon}= \max\limits_{\forall x \in \mathbb R}\left\{\frac{\frac{1}{b_0} \cdot e^{\frac{-|x-q(d)|}{ b_0}}}{\frac{1}{b_0} \cdot e^{\frac{-|x-q(d')|}{b_0}}}\right\}=\max\limits_{\forall x \in \mathbb R} \left\{e^{\frac{|x-q(d')|-|x-q(d)|}{ b_0}} \right\}\\ & \leq \max\limits_{\forall x \in \mathbb R} \left\{e^{\frac{|q(d)-q(d')|}{ b_0}} \right\}=e^{\frac{\Delta q}{ b_0}} \end{eqnarray*} where the last inequality is from triangle inequality. \end{proof} \begin{proof}[Theorem~\ref{bernoulidp}] The R$^2$DP Laplace mechanism $\mathcal M_q(d,b)$, $\frac{1}{b} \sim f_{B,\frac{1}{b_0},\frac{1}{b_1}}(\frac{1}{b};p)$ returns with probability $p$, a Laplace mechanism with scale parameter $b_1$, and with probability $1-p$ another Laplace mechanism with scale parameter $b_2$. To this end, we are looking for \begin{eqnarray*} &e^{\epsilon}= \max\limits_{\forall x \in \mathbb R}\left\{\frac{\frac{p}{b_0}\cdot e^{\frac{-|x-q(d)|}{b_0}}+\frac{1-p}{b_1}\cdot e^{\frac{-|x-q(d)|}{b_1}}}{\frac{p}{b_0}\cdot e^{\frac{-|x-q(d')|}{b_0}}+\frac{1-p}{b_1}\cdot e^{\frac{-|x-q(d')|}{b_1}}}\right\} \end{eqnarray*} Therefore, using triangle inequality, we have \begin{eqnarray*} &e^{\epsilon_1}=\max\limits_{\forall S \in \mathbb R}\left\{\frac{p\cdot e^{\frac{-|x-q(d)|}{b_0}}+(1-p)\cdot e^{\frac{-|x-q(d)|}{b_1}}}{p\cdot e^{\frac{-|x-q(d')|}{b_0}}+(1-p)\cdot e^{\frac{-|x-q(d')|}{b_1}}} \right\}\\ & \leq \max\limits_{\forall x \geq q(d)}\left\{\frac{p\cdot e^{\frac{\Delta q-|x-q(d')|}{b_0}}+(1-p)\cdot e^{\frac{\Delta q+-|x-q(d')|}{b_1}}}{p\cdot e^{\frac{-|x-q(d')|}{b_0}}+(1-p)\cdot e^{\frac{-|x-q(d')|}{b_1}}} \right \} \end{eqnarray*} Let us make the substitutions $X=e^{\frac{-|x-q(d')|}{b_0}}$, $a=e^{\frac{\Delta q}{b_0}}$ and k=$\frac{b_0}{b_1} >1$. Hence, we have \begin{eqnarray*} & e^{\epsilon}\leq \max\limits_{\forall X \in (0,1)}\left\{\frac{p\cdot a \cdot X+(1-p)\cdot (a\cdot X)^k}{p\cdot X+(1-p)\cdot X^k} \right\} \end{eqnarray*} To obtain $e^{\epsilon}$, we need to find all the critical points of $e^{\epsilon_1}(X)=\frac{p\cdot a \cdot X+(1-p)\cdot (a\cdot X)^k}{p\cdot X+(1-p)\cdot X^k}$. However, the critical points of a fractional function are the roots of the numerator of its derivative. Hence, suppose \begin{equation*} \diff{e^{\epsilon}(X)}{X}=\frac{N(X)}{D(X)} \end{equation*} then \begin{eqnarray*} & \Rightarrow N(X)= \big(p\cdot a +(1-p)\cdot k \cdot a \cdot (a\cdot X)^{k-1} \big)\\ & \cdot \big( p\cdot X+(1-p)\cdot X^k\big) - \big( p+(1-p)\cdot k \cdot X^{k-1}\big) \\& \cdot \big(p\cdot a \cdot X+(1-p)\cdot (a\cdot X)^k \big)\\& =p \cdot (1-p) \cdot (k-1) \cdot (a^{k-1} -1) \cdot X^k \end{eqnarray*} However, all the terms in the last expression are strictly positive. Therefore, the only critical points are $X=0$ and $X=1$ and as the function is strictly increasing, \begin{eqnarray*} & e^{\epsilon}\leq e^{\epsilon}(1)=p\cdot a +(1-p)\cdot (a)^k\\ &=p\cdot e^{\frac{\Delta q}{b_0}}+(1-p)\cdot e^{\frac{\Delta q}{b_1}} \end{eqnarray*} which is the bound in the Theorem. \end{proof} \begin{proof}[Theorem~\ref{gamadist}] \label{proofgama} For a Gamma distribution with shape parameters $k$ and scale parameters $\theta$, the MGF at point $t$ is given as $(1-\theta\cdot t)^{-k}$. Since $\frac{1}{b} \sim f_{\Gamma}(\frac{1}{b};k,\theta)$, following Theorem~\ref{thm: RPLap mechDP}, one can write \begin{eqnarray*} &e^{\epsilon}= \max\limits_{\forall x \in \mathbb R}\left\{\frac{k \cdot \theta \cdot (1+\theta\cdot |x-q(d)|)^{-k-1}}{k \cdot \theta \cdot (1+\theta\cdot |x-q(d')|)^{-k-1}}\right\}\\ &\Rightarrow \epsilon= \max\limits_{\forall x \in \mathbb R} \ \left\{ (k+1) \cdot \ln \left[ \frac{(1+\theta\cdot |x-q(d')|)}{(1+\theta\cdot |x-q(d)|)} \right] \right \} \\ \end{eqnarray*} to find the maximum of the $\ln$ term, denote by $X=1+\theta\cdot |x-q(d)|)$. Moreover, since $|x-q(d')|\leq |x-q(d)|+ \Delta q$, we have \begin{eqnarray*} \Rightarrow \epsilon \leq \max\limits_{\forall X \geq 1} \left\{\frac{X+\Delta q \cdot \theta}{X}\right\} \end{eqnarray*} However, since \begin{eqnarray*} \forall X \geq 1, \ \frac{X+\Delta q \cdot \theta}{X} \end{eqnarray*} is strictly decreasing, we have \begin{eqnarray*} &\Rightarrow \epsilon=(k+1) \cdot \ln \big[ 1+\theta\cdot \Delta q \big] \end{eqnarray*} This completes the proof. \end{proof} \begin{proof}[Lemma~\ref{necsgama}] \label{lemgama} We need to show that there exist $k$ and $\theta$ such that $(k+1)\cdot \ln (1+\Delta q \cdot \theta) < -k \cdot \ln (1-\Delta q \cdot \theta)$ , $\theta< \frac{1}{\Delta q}$. Given $\theta = \frac{1}{2 \Delta q}$, we need to show that $\exists k, k \cdot \ln (2)> (k+1) \cdot \ln (1.5)$, which always holds for all $k>1.4094$. \end{proof} \begin{proof}[Lemma~\ref{necstrunc}] \label{label:trunclem} Using exhaustive search, suppose $\mu = 0.5223$,$ \sigma=1.5454$, $a= 0.5223$ and for $\epsilon=1.1703$ and $\Delta q=0.6$, we will get $\ln(M_{\mathcal{N}^T}(\Delta q))=1.2417$. \end{proof} \section{Lagrange Multiplier Function} \label{sec:lag} The Lagrange Multiplier Function (all possible linear combinations of the Gamma, uniform and truncated Gaussian distributions) is: \begin{eqnarray} \label{objboth} &\hspace{-2cm}\mathcal{L} (a_1,a_2,a_3,k, \theta,a_u,b_u,\mu,\sigma,a_{\mathcal N^T}, b_{\mathcal N^T}, \Lambda) \\ &\hspace{-2cm}= M_{\Gamma(k,\theta)}(-a_1\gamma) \cdot M_{U(a_u,b_u)}(-a_2\gamma) \nonumber\\ &\cdot M_{\mathcal{N}^T(\mu,\sigma,a_{\mathcal N^T}, b_{\mathcal N^T})}(-a_3\gamma) +\Lambda \cdot (\ln \Bigg[\cfrac{\mathsf{N}}{\mathsf{D}}\Bigg]-\epsilon) \nonumber \end{eqnarray} where the numerator and the denominator $\mathsf{N, \ D}$ are \begin{eqnarray*} &\hspace{-7.5cm}\mathsf{N}=\\&(a_1 \cdot k \cdot \theta)+ (a_2 \cdot \frac{a+b}{2})+(a_3 \cdot (\mu+(\cfrac{\sigma\cdot\phi(\alpha)-\phi(\beta))}{(\Phi(\beta)-\Phi(\alpha))})) \end{eqnarray*} \begin{eqnarray*} &\hspace{-0.7cm}\mathsf{D}=a_1 \cdot M'_{\Gamma(k,\theta)}(-a_1\cdot \Delta q) \cdot M_{U(a_u,b_u)}(-a_2 \cdot\Delta q) \\ &\cdot M_{\mathcal{N}^T(\mu,\sigma,a_{\mathcal N^T}, b_{\mathcal N^T})}(-a_3\cdot \Delta q)\\& +a_2 \cdot M_{\Gamma(k,\theta)}(-a_1\cdot \Delta q) \cdot M'_{U(a_u,b_u)}(-a_2 \cdot\Delta q) \\ &\cdot M_{\mathcal{N}^T(\mu,\sigma,a_{\mathcal N^T}, b_{\mathcal N^T})}(-a_3\cdot \Delta q)\\& +a_3\cdot M_{\Gamma(k,\theta)}(-a_1\cdot \Delta q) \cdot M_{U(a_u,b_u)}(-a_2 \cdot\Delta q) \\ &\cdot M'_{\mathcal{N}^T(\mu,\sigma,a_{\mathcal N^T}, b_{\mathcal N^T})}(-a_3\cdot \Delta q) \end{eqnarray*} \begin{figure*}[!t] \includegraphics[width=0.9\linewidth]{newfig/Bothnew1.pdf} \centering \caption{The R$^2$DP mechanism significantly outperforms the competing Laplace and the staircase mechanisms in maximizing the usefulness metric (an example of a utility metric with no known optimal PDF).} \label{fig:both} \end{figure*} \section{Numerical Analysis} \label{numericsec} We also demonstrate the effectiveness of R$^2$DP through numerical results based on Algorithm~\ref{alg:analyst-actions1} (the ensemble R$^2$DP algorithm). In particular, Figure~\ref{fig:both} depicts the corresponding usefulness (the probability of the results to be within a pre-specified error bound) of the R$^2$DP, the Laplace and the Staircase mechanisms. Figure~\ref{fig:both} clearly demonstrates the fact that the R$^2$DP mechanism can significantly improve both already considered to be competing mechanisms. In particular, we observe the power of the R$^2$DP mechanism in generating very high utility results, e.g., results with more than $0.8$ probability fallen inside only $\gamma=0.1$ error-bound, owing to automatically searching a large search space of PDFs. \section{R\texorpdfstring{$^2$}{2}DP and Other DP Mechanisms} \label{sec:Gauss} In this section we briefly discuss the application of the R$^{2}$DP framework in two other well-known baseline DP mechanisms. \subsection{R\texorpdfstring{$^2$}{2}DP Exponential Mechanism} \label{sec:exponential} The exponential mechanism was designed for situations in which we wish to choose the “best” response but adding noise directly to the computed quantity can completely destroy its value, such as setting a price in an auction, where the goal is to maximize revenue, and adding a small amount of positive noise to the optimal price (in order to protect the privacy of a bid) could dramatically reduce the resulting revenue~\cite{10.1561/0400000042}. The exponential mechanism is the natural building block for answering queries with arbitrary utilities (and arbitrary non-numeric range), while preserving differential privacy. Given some arbitrary range $\mathcal R$, the exponential mechanism is defined with respect to some utility function $u : \mathbb{N}^{|\mathcal X|} \times \mathcal R \rightarrow \mathbb R$, which maps database/output pairs to utility scores. Intuitively, for a fixed database $x$, the user prefers that the mechanism outputs some element of $\mathcal R$ with the maximum possible utility score. Note that when we talk about the sensitivity of the utility score $u : \mathbb{N}^{|\mathcal X|} \times \mathcal R \rightarrow \mathbb R$, we care only about the sensitivity of $u$ with respect to its database argument; it can be arbitrarily sensitive in its range argument: \begin{equation*} \Delta u \equiv \max\limits_{r\in \mathcal R} \max\limits_{x,y: \norm{x-y} \leq 1} |u(x,r)-u(y,r)|. \end{equation*} The intuition behind the exponential mechanism is to output each possible $r\in \mathcal R$ with probability proportional to exp($\epsilon u(x, r)/\Delta u$) and so the privacy loss is approximately: \begin{equation} \ln \Big(\cfrac{exp(\epsilon u(x, r)/ \Delta u)}{exp(\epsilon u(y, r)/\Delta u)}\Big)= \epsilon [u(x,r)-u(y,r)/ \Delta u] \leq \epsilon \end{equation} The exponential mechanism is a canonical $\epsilon$-DP mechanism, meaning that it describes a class of mechanisms that includes all possible differentially private mechanisms. However, the exponential mechanism can define a complex distribution over a large arbitrary domain, and so it may not be possible to implement the exponential mechanism efficiently when the range of $u$ is super-polynomially large in the natural parameters of the problem~\cite{10.1561/0400000042}. This is the main restrictive aspect of the exponential mechanism against leveraging different accuracy metrics. However, the exponential mechanism can benefit from the additional randomization of privacy budget, to handle the complexity (excessive sharpness) of the defined probability distribution. In particular, as we mentioned earlier, compound (or mixture) distributions arise naturally where a statistical population contains two or more sub-population which is the case for the exponential mechanism. Thus, we motivate the application of the R$^2$DP framework in designing exponential mechanisms with rather smooth but accurate distributions around each element in the range of $u$. However, further discussion on R$^2$DP exponential mechanism requires formal analysis, e.g., deriving the DP guarantee of such a mechanism. \subsection{R\texorpdfstring{$^2$}{2}DP and Differential Privacy Relaxations} \label{sec:relaxed} R$^2$DP can also be studied under various relaxations of differential privacy, e.g., $(\epsilon,\delta)$-differential privacy or R\'enyi Differential Privacy~\cite{mironov2017renyi} which is a privacy notion based on the R\'enyi divergence~\cite{van2014renyi}. These relaxations allow suppressing the long tails of the mechanism's distribution where pure $\epsilon$-differential privacy guarantees may not hold. Instead, they offer asymptotically smaller cumulative loss under composition and allow greater flexibility in the selection of privacy preserving mechanisms~\cite{mironov2017renyi}. In the following, we briefly discuss the application of R$^2$DP in two of such relaxed notions of the differential privacy . \subsubsection{R\texorpdfstring{$^2$}{2}DP Gaussian Mechanism} A relaxation of $\epsilon$-differential privacy allows an additional bound $\delta$ in its defining inequality: \begin{defn}[($\epsilon, \delta$)-differential privacy~\cite{Dwork06_DPgaussian}]\label{def: differential} A randomized mechanism $M: \mathsf D \times \Omega \to \mathsf R$ is $(\epsilon, \delta)$-differentially private if for all adjacent $d,d' \in \mathsf D$, we have \begin{align} \label{eq: stand} \mathbb P(M(d) \in S) \leq e^{\epsilon} \mathbb P(M(d') \in S) + \delta, \;\; \forall S \subset \mathsf R. \end{align} \end{defn} This definition quantifies the allowed deviation ($\delta$) for the output distribution of a $\epsilon$-differentially private mechanism, when a single individual is added or removed from a dataset. A differentially private mechanism proposed in~\cite{Dwork06_DPgaussian} modifies an answer to a numerical query by adding the independent and identically distributed zero-mean Gaussian noise. Given the definition of the $\mathcal Q$-function $ \mathcal Q(x) := \frac{1}{\sqrt{2 \pi}} \int_x^{\infty} e^{-\frac{u^2}{2}} du $, we have the following theorem~\cite{Dwork06_DPgaussian, LeNyDP2012_journalVersion}. \begin{thm} \label{thm: Gaussian mech} Let $q: \mathsf D \to \mathbb R$ be a query and $\epsilon>0$. Then the Laplace mechanism $ \mathcal M_q: \mathsf D \times \Omega \to \mathbb R$ defined by $\mathcal M_q(d) = q(d) + w$, with $w \sim \mathcal N\left(0,\sigma^2 \right)$, where $\sigma \geq \frac{\Delta q}{2 \epsilon}(K + \sqrt{K^2+2\epsilon})$ and $K = \mathcal Q^{-1}(\delta)$, satisfies $(\epsilon,\delta)$-DP. \end{thm} We define $\kappa_{\delta,\epsilon} = \frac{1}{2 \epsilon} (K+\sqrt{K^2+2\epsilon})$, then the standard deviation $\sigma$ in Theorem \ref{thm: Gaussian mech} can be written as $\sigma(\delta,\epsilon) = \kappa_{\delta,\epsilon} \Delta q$. It can be shown that $\kappa_{\delta,\epsilon}$ behaves roughly as $O(\ln(1/\delta))^{1/2}/\epsilon$. For example, to ensure $(\epsilon,\delta)$-differential privacy with $\epsilon = \ln(2)$ and $\delta = 0.05$, the standard deviation of the injected Gaussian noise should be about $2.65$ times the $\ell_1$-sensitivity of $q$. \begin{thm} \label{gausut} The Gaussian Mechanism in Theorem~\ref{thm: Gaussian mech} is $(\gamma,2\cdot \mathcal Q \big(\frac{ \gamma}{\sigma(\delta,\epsilon)}\big))$-useful. \end{thm} Similar to our R$^2$DP Laplace mechanism, we can formulate an optimization problem for the R$^2$DP model using Gaussian mechanism. Therefore, using Theorems~\ref{thm: Gaussian mech} and \ref{gausut}, we have the following. \begin{coro} \label{co2} Denote by $u$, the set of parameters for a probability distribution $f_{\sigma}$. Then, the optimal usefulness of an R$^2$DP Gaussian mechanism utilizing $f_{\sigma}$, at each quadruplet $(\epsilon, \delta, \Delta q, \gamma)$ is \begin{eqnarray} \small \label{gen:gaus} &\hspace{-0.5cm} U_f(\epsilon, \delta, \Delta q, \gamma)=\max\limits_{u\in \mathbb{R}^{|u|}} \big (1- 2\cdot \mathbb{E}_{\sigma}(Q \big(\frac{\gamma}{\sigma(\delta,\epsilon)}\big) \big)) \nonumber\\ & \text{subject to } \\ & \max \limits_{\forall S \in \mathsf R} \left\{\frac{\mathbb P(\mathcal M_q(d,\sigma)\in S)}{\mathbb P(\mathcal M_q(d',\sigma)\in S)}\right\}=\epsilon, \nonumber\\ & \mathbb{E}_{\sigma}(Q(\epsilon \sigma -\frac{1}{2\sigma}))=\delta \nonumber \end{eqnarray} \end{coro} \subsubsection{R\texorpdfstring{$^2$}{2}DP and R\'enyi Differential Privacy} \label{renyiDPsec} Despite its notable advantages in numerous applications, the definition of ($\epsilon,\delta$)-differential privacy has the following two limitations. First, $(\epsilon, \delta)$-differential privacy was applied to the analysis of the Gaussian mechanism~\cite{Dwork06_DPgaussian}. In contrast to the Laplace mechanism (whose privacy guarantee is characterized tightly and accurately by $\epsilon$-differential privacy), a single Gaussian mechanism satisfies a curve of $(\epsilon(\delta), \delta)$-differential privacy definitions~\cite{Dwork06_DPgaussian}. Picking any one point on this curve may leave out important information about the mechanism's actual behavior \cite{mironov2017renyi}. Second, $(\epsilon, \delta)$-differential privacy also has limitations on the composition of differential privacy \cite{McSherry09}. By relaxing the guarantee to $(\epsilon, \delta)$-differential privacy, advanced composition allows tighter analyses for compositions of (pure) differentially private mechanisms. Iterating this process, however, quickly leads to a combinatorial explosion of parameters, as each application of an advanced composition theorem leads to a wide selection of possibilities for $(\epsilon(\delta), \delta)$-differentially private guarantees. To address these shortcomings, R\'enyi differential privacy was proposed as a natural relaxation of differential privacy in~\cite{mironov2017renyi}. \begin{defn}[($\alpha, \epsilon$)-RDP] A randomized mechanism $M: \mathsf D \times \Omega \to \mathsf R$ is said to have $\epsilon$-R\'enyi differential privacy of order $\alpha$, or ($\alpha$, $\epsilon$)-RDP for short, if for if for all adjacent $d,d' \in \mathsf D$, we have $D_{\alpha} (M(d)||M(d')) \leq \epsilon$, where $D_{\alpha}(\cdot)$ is the (parameterized) R\'enyi divergence~\cite{van2014renyi}. \end{defn} Compared to $(\epsilon, \delta)$-differential privacy, R\'enyi differential privacy is a strictly stronger privacy definition. It offers an operationally convenient and quantitatively accurate way of tracking cumulative privacy loss throughout execution of a standalone differentially private mechanism and across many such mechanisms~\cite{mironov2017renyi}. Next, we give the R\'enyi differential privacy guarantee of our R$^2$DP mechanism and show that the privacy loss of R$^2$DP under R\'enyi DP can significantly (asymptotically for small $\alpha$) outperform Laplace, Gaussian and Random Response mechanisms. \begin{thm} \label{thmss} If real-valued query $q$ has sensitivity $1$, then the R$^2$DP mechanism $\mathcal{M}_q$, leveraging MGF $M$, satisfies \[ \begin{cases} (\alpha, \frac{1}{\alpha-1} \log \left [ \frac{\alpha M(\alpha-1)+(\alpha-1) M(-\alpha)}{2\alpha-1} \right])\text{-RDP}. &\quad if \ \alpha >1\\ (1, M'(0)+M(-1)-1)\text{-RDP}. &if \ \alpha =1 \\ \end{cases} \] \end{thm} \begin{proof} The above RDP guarantee follows Corollary 2 in~\cite{mironov2017renyi} on the RDP guarantee of the classic Laplace mechanism. In particular, the above equations are derived using the following substitutions $exp(t/b) \rightarrow M(t)$ and $1/b \rightarrow M'(0)$ due to the second-fold randomization of $b$. \end{proof} \section{Other Applications of R\texorpdfstring{$^2$}{2}DP} \label{sec:RPDP as a Patch to Existing Work1} R$^2$DP represents a very general concept which could potentially be applied in a broader range of contexts. In general, applying R$^2$DP to design more application-aware mechanisms may further improve the utility of many existing solutions \cite{NissimRS07}. We now briefly discuss some of the potential applications as follows. \vspace{0.05in} \noindent\textbf{R$^2$DP and Query-Workload Answering} \cite{LiMHMR15}. Given a workload (aka. a batch of queries), the matrix mechanism generates a different set of queries, called \textit{strategy queries}, which are answered using a standard Laplace or Gaussian mechanism. The noisy answers to the workload queries can then be derived from the noisy answers to the strategy queries~\cite{li2010optimizing}. This two-stage process can result in a correlated noise distribution that preserves differential privacy and also increases utility. Given a triplet ($\epsilon$, query, metric), R$^2$DP can be applied to replace the Laplace or Gaussian mechanism for answering the strategy queries of the matrix mechanism. As a result, R$^2$DP will provide additional improvement in utility (in terms of the TotalError as defined in \cite{li2010optimizing}) over the improvement already provided by the matrix mechanism. More specifically, we compare the total errors of Laplace and R$^2$DP mechanisms in Table~\ref{tablematrix} for specific workloads of interest (similar to those considered in~\cite{li2010optimizing}). These two workloads were analyzed in \cite{li2010optimizing} using two $n$-sized query strategies, each of which can be envisioned as a recursive partitioning of the domain based on the Haar wavelet~\cite{xiao2010differential}. We denote by $f(\epsilon,\Delta q)$ the improvement in the TotalError for applying an R$^2$DP noise instead of a Laplace noise in the matrix mechanism. For instance, leveraging the results of R$^2$DP (w.r.t. $\ell_1$ or $\ell_2$) shown in Section~\ref{secl1l2}, for a workload of size $n=6$, at $\epsilon=2.3$, the improvement for range queries ($\Delta q= 36$) and predicate queries ($\Delta q= 64$) are $\sim$20\% and $\sim$10\%, respectively. \begin{table}[ht] \caption{Total error of matrix mechanisms comparison (with R$^2$DP vs. Laplace) -- two workloads and two query strategies} \centering \begin{adjustbox}{width=0.48\textwidth,center} \begin{tabular}{|c|c|c|c|} \hline \multicolumn{2}{|c|}{TotalError}& \multicolumn{2}{|c|}{Matrix Strategies} \\ \hline Mechanisms & Workload Queries &Binary Hierarchy of Sums & Matrix of the Haar Wavelet \\ \hline \multirow{2}{*}{Laplace}& Range Queries & $\Theta (n^2\log^3(n)/ \epsilon^2) $& $\Theta (n^2 \log^3(n)/ \epsilon^2 )$ \\ \cline{2-4} & Predicate Queries & $\Theta (n 2^n \log^2(n)/ \epsilon^2)$& $\Theta (n 2^n\log^2(n)/ \epsilon^2)$ \\ \hline \multirow{2}{*}{R$^2$DP}& Range Queries & $\Theta (f(\epsilon,n^2) n^2\log^3(n)/ \epsilon^2) $& $\Theta (f(\epsilon,n^2) n^2 \epsilon^2 \log^3(n))$ \\ \cline{2-4} & Predicate Queries & $\Theta ( f(\epsilon, 2^n) n 2^n \log^2(n)/ \epsilon^2)$& $\Theta (f(\epsilon, 2^n) n 2^n\log^2(n)/ \epsilon^2)$ \\ \hline \end{tabular} \end{adjustbox} \label{tablematrix} \end{table} \noindent\textbf{R$^2$DP and Composition}. R$^2$DP may be applied for reducing the privacy leakage due to sequential or parallel querying over a dataset, of which the objective will be to maximize the number of compositions under a specified $\epsilon$-differential privacy constraint. \vspace{0.05in} \noindent\textbf{R$^2$DP and Local Differential Privacy}. In this context, R$^2$DP can be regarded as a new randomized response model. In particular, the randomized response scheme presented in~\cite{Wang2016UsingRR} can be produced using R$^2$DP for the Bernoulli distribution when $b_0 \rightarrow 0$ and $b_1 \rightarrow \infty$. Therefore, designing more efficient local differential privacy schemes using R$^2$DP is an interesting future direction. \vspace{0.05in} \noindent\textbf{R$^2$DP for Continual Observation Applications}. Providing differential privacy guarantees on data streams represents another important future direction for R$^2$DP. As an example, the multi-input multi-output (MIMO) systems process streams of signals originated from many sensors capturing privacy-sensitive events about individuals, and statistics of interest need to be continuously published in real time~\cite{Dwork:2010:DPU:1806689.1806787, LeNyDP2012_journalVersion}, e.g., privacy-preserving traffic monitoring over multi-lane roads~\cite{Brown:2013:HPR:2525314.2525323}. In this context, R$^2$DP can leverage the constraint related to the number of inputs and the number of outputs (e.g., the sensitivity of the output of MIMO filter $G$ with $m$ inputs and $p$ outputs is proportional to the $\mathcal{H}_2$ norm of $G$ which itself is an increasing function of $m$ and $p$ ~\cite{7944526}) into its model to build more efficient differentially private mechanisms for the MIMO scenarios. \subsection{Experimental Setting} We perform all the experiments and comparisons on the Privacy Integrated Queries (PINQ) platform \cite{McSherry09}. Besides basic statistical queries, two applications in the current suite (\emph{machine learning} and \emph{social network analysis}) are employed to evaluate the accuracy of R$^2$DP and compare it to Laplace and Staircase mechanisms. \subsubsection{Statistical Queries} In the first set of our experiments, we examine the benefits of R$^2$DP using basic statistical functions, i.e., count and average. The dataset comes from a sensor network experiment carried out in the Mitsubishi Electric Research Laboratories (MERL) and described in~\cite{Wren:2007:MMD:1352922.1352926}. MERL has collected motion sensor data from a network of over 200 sensors for a year and the dataset contains over 30 million raw motion records. To illustrate the query performance with different sensitivities, we create the queries based on a subset of the data including aggregated events that are recorded by closely located sensors over 5-minute intervals. We formed in this way $10$ input signals corresponding to $10$ spatial zones (each zone is covered by a group of sensors). Since each individual can activate several sensors and travel through different zones, we define moving average functions with arbitrary sensitivity values, e.g., $\Delta q \in [0.1,5]$. For instance, we could be interested in the summation of the moving averages over the past 30 min for zones 1 to 4. We apply R$^2$DP w.r.t. usefulness, $\ell_1$, $\ell_2$, entropy, and R\'enyi metrics, respectively. \subsubsection{Social Network} Social network degree distribution is performed on a Facebook dataset~\cite{snapnets}. They consist of ``circles'' and ``friends lists'' from Facebook by representing different individuals as nodes (47,538 nodes) and friend connections as edges (222,887 edges). Recall that the Mallows metric is frequently used for social network (graph-based) applications \cite{10.1007/978-3-642-36594-2_26}. We thus apply R$^2$DP w.r.t. the Mallows metric in this group of experiments. \subsubsection{Machine Learning} Naive Bayes classification is performed on two datasets: Adult dataset (in the UCI ML Repository) \cite{Kohavi96scalingup} and KDDCup99 dataset \cite{821515}. First, the Adult dataset includes the demographic information of 48,842 different adults in the US (14 features). It can be utilized to train a Naive Bayes classifier to predict if any adult's annual salary is greater than 50k or not. Second, the KDD competition dataset was utilized to build a network intrusion detector (given 24 training attack types) by classifying ``bad'' connections and ``good'' connections. Recall that the usefulness metric is commonly used for machine learning \cite{Blum:2008:LTA:1374376.1374464}. We thus apply R$^2$DP w.r.t. the usefulness in this group of experiments. \subsection{Basic Statistical Queries} We validate the effectiveness of R$^2$DP using two basic statistical queries: count (sensitivity=1) and moving average with different window sizes, e.g., sensitivity $\in[0.1,2]$ to comprehensively study the performance of R$^2$DP by benchmarking with Laplace and Staircase mechanisms. We have the following observations. \begin{figure*}[!tb] \label{fig:newcnt1} \centering \subfigure[$\ell_1, \Delta q=0.1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l1-0.pdf} }\hspace{-0.25in} \subfigure[$\ell_1, \Delta q=0.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l1-1.pdf} }\hspace{-0.25in} \subfigure[$\ell_1, \Delta q=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l1-2.pdf} }\hspace{-0.25in} \subfigure[$\ell_1, \Delta q=1.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l1-3.pdf} }\hspace{-0.3in} \subfigure[$\ell_2, \Delta q=0.1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l2-0.pdf} }\hspace{-0.25in} \subfigure[$\ell_2, \Delta q=0.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l2-1.pdf} }\hspace{-0.25in} \subfigure[$\ell_2, \Delta q=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l2-2.pdf} }\hspace{-0.25in} \subfigure[$\ell_2, \Delta q=1.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/l2-3.pdf} } \caption[Optional caption for list of figures] {$\ell_1$ and $\ell_2$ metrics: R$^2$DP compared to Laplace and Staircase mechanisms for statistical queries (with five PDFs, i.e., Gamma, Uniform, Truncated Gaussian, Noncentral Chi-squared and Rayleigh distributions).} \label{fig:newld} \end{figure*} \subsubsection{Usefulness Metric} We compare R$^2$DP with the baseline Laplace and two classes of Staircase mechanisms proposed in~\cite{Gupte1} w.r.t. $\ell_1$ and $\ell_2$ metrics, by varying the privacy budget $\epsilon$, four error bounds $\gamma\in\{0.1, 0.4, 0.6, 0.9\}$ and two different sensitivities (Section \ref{numericsec} additionally shows numerical results to provide a more comprehensive evaluation for the usefulness metric). As shown in Figure \ref{fig:newcnt}, R$^2$DP generates strictly better results w.r.t. the usefulness metric, and the ratio of improvement depends on values of $\epsilon$, $\Delta q$ and $\gamma$. In particular, we observe that the improvement is relatively larger for a larger error bound and smaller sensitivity (Figure~\ref{fig:newcnt} (a,b,e,f) vs. (c,d,g,h)). One important factor determining the improvement is the ratio between $\gamma$ and $\Delta q$, since it exponentially affects the search space of the R$^2$DP mechanism. Furthermore, we observe that the Laplace and the staircase mechanisms are not optimal (w.r.t. usefulness) for very small and large values of $\epsilon$, respectively, even though they are known to be optimal under other utility metrics (e.g., \cite{7353177}). \begin{figure*}[!tb] \centering \subfigure[$\Delta q=0.1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/entropy-1.pdf} \label{entropy1} }\hspace{-0.25in} \subfigure[$\Delta q=0.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/entropy-2.pdf} \label{entropy2}}\hspace{-0.25in} \subfigure[$\Delta q=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/entropy-3.pdf} }\hspace{-0.25in} \subfigure[$\Delta q=1.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/entropy-4.pdf} } \caption[Optional caption for list of figures] {KL Divergence (Relative entropy metric): R$^2$DP (with five PDFs, i.e., Gamma, Uniform, Truncated Gaussian, Noncentral Chi-squared and Rayleigh distributions) compared to Laplace and Staircase mechanisms.}\vspace{0.05in} \label{fig:KLentropy_2} \end{figure*} \begin{figure*}[!tb] \centering \subfigure[$\alpha=2, \Delta q=0.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi3-1.pdf} }\hspace{-0.25in} \subfigure[$\alpha=2, \Delta q=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi3-2.pdf} }\hspace{-0.25in} \subfigure[$\alpha=3, \Delta q=0.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi3-3.pdf} }\hspace{-0.25in} \subfigure[$\alpha=2, \Delta q=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi3-4} } \caption[Optional caption for list of figures] {R\'enyi Divergence (Relative entropy metric): R$^2$DP (with five PDFs, i.e., Gamma, Uniform, Truncated Gaussian, Noncentral Chi-squared and Rayleigh distributions) compared to Laplace and Staircase mechanisms.} \label{fig:Renentropy_11} \end{figure*} \begin{figure*}[!tb] \centering \subfigure[$\alpha=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi2-1.pdf} }\hspace{-0.25in} \subfigure[$\alpha=3$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi2-2.pdf} }\hspace{-0.25in} \subfigure[$\alpha=4$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi2-3.pdf} }\hspace{-0.25in} \subfigure[$\alpha=5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi2-4} }\hspace{-0.25in} \subfigure[$\alpha=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi1-1.pdf} }\hspace{-0.25in} \subfigure[$\alpha=3$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi1-2.pdf} }\hspace{-0.25in} \subfigure[$\alpha=4$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi1-3.pdf} }\hspace{-0.25in} \subfigure[$\alpha=5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/renyi1-4.pdf}} \caption[Optional caption for list of figures] {R\'enyi Differential Privacy: (a-d) R$^2$DP compared to Laplace and Random Response mechanisms, and (e-h) R$^2$DP compared to Gaussian mechanism.} \label{fig:RenyiDP} \end{figure*} \subsubsection{$\ell_1$ and $\ell_2$ Metrics} \label{secl1l2} We compare R$^2$DP with the baseline Laplace and Staircase mechanisms~\cite{Gupte1}, by varying the privacy budget $\epsilon$ and for four different sensitivities $\Delta q\in \{0.1, 0.5, 1, 1.5\}$. Our results validate the findings of Geng et al.~\cite{7353177}, i.e., in the low privacy regime ($\epsilon\rightarrow \infty$), the Staircase mechanism is optimal while in the high privacy regime ($\epsilon\rightarrow 0$), the Laplace mechanism is optimal. More importantly, our evaluations show that, for medium regime of privacy budgets (which could be more desirable in practice), the class of optimal noise can be totally different. In fact, as shown in Geng et al.~\cite{7353177}, the lower-bound of $\epsilon$ at which the Staircase distribution performs better than the Laplace distribution is somewhere around $\epsilon=3$ for both $\ell_1$ and $\ell_2$ metrics. As illustrated in Figure~\ref{fig:newld}, in contrast to $\ell_1$ metric (for which the results of laplace and staircase are relatively tight), R$^2$DP can find a class of noises with significantly improved $\ell_2$ metric for $\epsilon<3$ (a logarithmic X axis is used to illustrate the performance in this region). The PDF of this class of noises is mostly two-fold distributions with Laplace distribution as the first fold, and Gamma distribution as the second fold. This finding is in line with the optimal class of noise proposed by Koufogiannis et al.~\cite{koufogiannis2015optimality}, i.e., $f(v)=\cfrac{\epsilon^n \Gamma (\frac{n}{2}+1)}{\pi^{\frac{n}{2}}\Gamma (n+1)} e^{-\epsilon ||v||_2 }$. Furthermore, our results suggest different classes of optimal noises (than those found in the literature) for different parameters, sensitivity, $\epsilon$ and $p$ (index of $\ell$ norm). In particular, a larger $p$ tends to provide larger search spaces for R$^2$DP optimization, which results in further improved results for $\epsilon<3$ (Figure~\ref{fig:newld} (a,b,e,f) vs. (c,d,g,h)). \subsubsection{Relative Entropy Metric} As Wang et al~\cite{7039713} has already shown that the output entropy of $\epsilon$-DP randomization mechanisms is lower bounded by $1-\ln(\epsilon/2)$ (for count queries) and the optimal result is achieved with Laplace mechanism, we focus our entropy metric evaluation on relative entropy metrics, i.e., KL and R\'enyi divergences. To define the prior distribution for this group of experiments, we have created a histogram with $50$ bins of our data and calculated the probability mass function (pmf) of the bins. \footnote{2 millions records fall into 50 bins (e.g., equal range for each bin). Then, any counting and moving average query (with different sensitivities) can be performed within each of the 50 bins to generate the distribution. Finally, the distance between the original and noisy distributions can be measured using the relative entropy metrics.} As illustrated in Figure~\ref{fig:KLentropy_2}, we can draw similar observations for the KL entropy metric. In particular, we observe that R$^2$DP performs better for smaller sensitivity due to the larger search space of PDFs used in optimization. Similarly the R\'enyi entropy depicted in Figure~\ref{fig:Renentropy_11} shows a similar trend with different $\alpha$ (the index of the divergence). \subhead{Summary} The R$^2$DP mechanism can generate better results than most of the well-known distributions for utility metrics without known optimal distributions (e.g., usefulness), and our results asymptotically approach to the optimal for utility metrics with known optimal distributions (e.g., $\ell_1$ and $\ell_2$). In particular, even though R$^2$DP is not specifically designed to optimize $\ell_1$ and $\ell_2$ metrics, we observe very similar performance between the R$^2$DP results and the optimal Staircase results, e.g., the multiplicative gain compared to the Laplace results. We note that using a larger number of independent RVs drawn from different PDFs as the search space generator may further improve the results. \subsection{Tightness of R$^2$DP under R\'enyi DP} R\'enyi differential privacy ~\cite{mironov2017renyi} is a recently proposed as a relaxed notion of DP which effectively quantifies the bad outcomes in ($\epsilon,\delta$)-DP mechanisms and consequently evaluates how such mechanisms behave under sequential compositions (see Appendix~\ref{renyiDPsec} for details on R\'enyi DP). We now evaluate how the privacy loss of R$^2$DP behaves under R\'enyi DP. Specifically, this group of experiments are conducted to provide insights about the privacy loss of R$^2$DP and other well-known mechanisms. In particular, Figure~\ref{fig:RenyiDP} (a-d) depicts the R\'enyi differential privacy of the R$^2$DP and two basic mechanisms for counting queries: random response and Laplace mechanisms. These results are based on the privacy guarantees depicted in Table~\ref{tablerenyi}. Our results demonstrate that fine tuning R$^2$DP can generate strictly more private results compared to the other two $\epsilon$-DP mechanisms when the definition of the privacy notion is relaxed. Furthermore, the level of such tightness depends on the R\'enyi differential privacy index where a smaller value of $\alpha$ pertains to a relatively tighter R$^2$DP mechanism. On the other hand, all three mechanisms behave more similarly as $\alpha$ increases. Ultimately, at $\alpha \rightarrow \infty$, where R\'enyi differential privacy becomes equivalent to the classic notion of $\epsilon$-DP, all three mechanisms' privacy guarantees converge to $\epsilon$. \begin{figure*}[!tb] \centering \subfigure[$p=1, \Delta q=0.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/mallow-1.pdf} }\hspace{-0.25in} \subfigure[$p=1, \Delta q=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/mallow-2.pdf} }\hspace{-0.25in} \subfigure[$p=2, \Delta q=0.5$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/mallow-3.pdf} }\hspace{-0.25in} \subfigure[$p=2, \Delta q=1$]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/mallow-4.pdf}} \caption[Optional caption for list of figures] {Mallows metric: R$^2$DP compared to Laplace and Staircase mechanisms for degree distribution (Facebook dataset).} \label{fig:mall} \end{figure*} \begin{figure*}[ht] \centering \subfigure[Precision vs. $\epsilon$ (UCI Adult)] {\includegraphics[angle=0, width=0.25\linewidth]{fig/adult-1.pdf} \label{fig:pre_eps} }\hspace{-0.25in} \subfigure[Recall vs. $\epsilon$ (UCI Adult)]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/adult-2.pdf} \hspace{-0.25in} \label{fig:pre_eps1}} \subfigure[Precision vs. $\epsilon$ (KDDCup99)]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/kdd-1.pdf} \label{kdd1} }\hspace{-0.25in} \subfigure[Recall vs. $\epsilon$ (KDDCup99)]{ \includegraphics[angle=0, width=0.25\linewidth]{fig/kdd-2.pdf} \label{kdd2} } \caption[Optional caption for list of figures] {Accuracy evaluation for classification (UCI Adult dataset and KDDCup99 dataset)} \label{fig:acc_size} \end{figure*} \begin{table}[!h] \caption{Summary of R\'enyi DP parameters for four mechanisms based on Theorem~\ref{thmss}} \centering \begin{adjustbox}{width=0.5\textwidth,center} \begin{tabular}{|c|c|c|} \hline \bf{Mechanism} & \bf{Differential Privacy} & \bf{R\'enyi Differential Privacy for $\alpha$} \\ \hline \multirow{2}{*}{Laplace} & \multirow{2}{*}{$\frac{1}{b}$}& $\alpha >1:\frac{1}{\alpha-1} \log \left [ \frac{\alpha\cdot exp(\frac{\alpha-1}{b})+(\alpha-1) \cdot exp(\frac{-\alpha}{b})}{2\alpha-1} \right]$\\ & & $\alpha =1:\frac{1}{b}+exp(\frac{-1}{b})-1$\\ \hline \multirow{2}{*}{Random Response} & \multirow{2}{*}{$|\log \frac{p}{1-p}|$}& $\alpha >1: \frac{1}{\alpha-1} \log \left [ p^\alpha (1-p)^{1-\alpha} + p^{1-\alpha} (1-p)^{\alpha} \right]$\\ & &$\alpha =1:(2p-1)\log \frac{p}{1-p}$\\ \hline \multirow{2}{*}{R$^2$DP}& \multirow{2}{*}{$M'_{\frac{1}{b}}(0)/M'_{\frac{1}{b}}(-1)$}&$\alpha >1:\frac{1}{\alpha-1} \log \left [ \frac{\alpha M_{\frac{1}{b}}(\alpha-1)+(\alpha-1) M_{\frac{1}{b}}(-\alpha)}{2\alpha-1} \right]$\\ & & $\alpha =1:M_{\frac{1}{b}}'(0)+M_{\frac{1}{b}}(-1)-1$\\ \hline Gaussian & $\infty$& $\cfrac{\alpha}{2\sigma^2}$ \\ \hline \end{tabular} \end{adjustbox} \label{tablerenyi} \end{table} In the next set of experiments, we compare the R$^2$DP mechanism and Gaussian mechanism in terms of privacy guarantee to understand how exactly the bad outcomes probability ($\delta$) affects the privacy robustness of a privatized mechanism. Figure~\ref{fig:RenyiDP} (e-h) gives such a comparison. Specifically, since R\'enyi differential privacy at each $\alpha$ can be seen as higher-order moments as a way of bounding the tails of the privacy loss variable~\cite{mironov2017renyi}, we observe that each value of $\alpha$ reveals a snapshot of such a privacy loss. As a tangible observation, we conclude that the class of optimal $\epsilon$-differential privacy mechanisms benefits from a very smaller privacy loss at smaller moments (which are more decisive in overall protection) and larger privacy loss at bigger moments. \subsection{Social Network Analysis} We conduct experiments to compare the performance of R$^2$DP, Laplace and two staircase mechanisms based on PINQ queries in social network analysis. Figure~\ref{fig:mall} compares the degree distribution for a real Facebook dataset using Mallows metric (the prior, i.e.,$n=47,538$ nodes, and $p=1$ or $2$ for computing the distribution distance using Mallows metric). Again, our results confirm that R$^2$DP can effectively generate PDFs to maximize this utility metric suitable for social networking analysis. Note that, since the definition of this metric is similar to $\ell_p$ metric (Mallows is more empirical, depending on the number of nodes in the dataset), the results for this metric display a similar pattern to those for $\ell_p$ metric depicted in Figure~\ref{fig:newld}. \subsection{Machine Learning} We obtain our baseline results by applying the Naive Bayes classifier on the Adult dataset (45K training records and 5K testing records), the precision and recall results are derived as 0.814 and 0.825, respectively. Then, we evaluate the precision and recall of R$^2$DP and Laplace-based naive classification \cite{VaidyaSBH13} by varying the privacy budget for each PINQ query $\epsilon\in[0.1, 10]$ (sensitivity=1) where two different error bounds $\gamma=0.05, 0.1$ are specified for R$^2$DP. We have the following observations: \begin{itemize} \item As shown in Figure \ref{fig:pre_eps} and \ref{fig:pre_eps1}, the R$^2$DP-based classification is more accurate than the Laplace and staircase mechanisms with the same total privacy budget for all the PINQ queries $\epsilon$. As the privacy budget $\epsilon$ increases, following our statistical query experiments, R$^2$DP offers a far better precision/recall compared to the Laplace-based classification (close to the results without privacy consideration) since it approaches to the optimal PDF. \item Among the precision/recall results derived with two different $\gamma$ in R$^2$DP-based classification, for each $\epsilon$, one out of the two specified error bounds (e.g., $\gamma=5\%$) may reach the highest accuracy (not necessarily the result with the smaller $\gamma$). \item As shown in Figure \ref{kdd1} and \ref{kdd2}, we can draw similar observations from the KDDCup99 dataset. \end{itemize} The above experimental results have validated the effectiveness of integrating R$^2$DP to improve the output utility for classification while ensuring $\epsilon$-differential privacy. In summary, all the experiments conducted in both statistical queries and real-world applications have validated the practicality of the R$^2$DP framework. \section{Preliminaries} \label{sec:model} We review some background on differential privacy for the theoretical foundations of the R$^2$DP framework. \subsection{Differential Privacy}\label{section: DP def} \label{def: differential privacy original} We follow the standard definitions of $\epsilon$-differential privacy ~\cite{DworkNRRV09,NissimRS07}. Let $\mathsf D$ be a dataset of interest and $d$, $d'$ be two adjacent subsets of $\mathsf D$ meaning that we can obtain $d'$ from $d$ simply by adding or subtracting the data of one individual. A randomization mechanism $\mathcal M: \mathsf D \times \Omega \to \mathsf R$ which is $\epsilon$-differentially private, necessarily randomizes its output in such a way that for all $S \subset \mathsf R$, \begin{align}\label{eq: standard def approximate DP original} \mathbb P(\mathcal M(d) \in S) \leq e^{\epsilon} \mathbb P(\mathcal M(d') \in S) \;\; \end{align} If the inequality fails, then a leakage ($\epsilon$ breach) takes place, which means the difference between the prior distribution and posterior one is tangible. We recall below a basic mechanism that can be used to answer queries in an $\epsilon$-differentially private way. We will only be concerned with queries that return numerical answers, i.e., a query is a mapping $q: \mathsf D \to \mathbb R$, where $\mathbb R$ is a set of real numbers. The following sensitivity concept plays an important role in the design of differentially private mechanisms~\cite{10.1007/11681878_14}. \begin{defn} \label{defn: sensitivity} The sensitivity of a query $q: \mathsf D \to \mathsf R$ is defined as $\Delta q= \max_{d,d':\text{Adj}(d,d')} |q(d) - q(d')|$~\cite{DworkNRRV09,NissimRS07}. \end{defn} \label{section: basic mech} \subsection{Laplace Mechanism} The Laplace mechanism~\cite{10.1007/11681878_14} modifies a numerical query result by adding zero-mean noise (denoted as $Lap(b)$) distributed according to a Laplace distribution with mean zero and scale parameter $b$. It has density $p(x;b)=\frac{1}{2b}exp(-\frac{|x|}{b})$ and variance $2b^2$. \begin{thm} \label{thm: Lap mech} Let $q: \mathsf D \to \mathbb R$ be a query , $\epsilon>0$. Then the mechanism $\mathcal M_q: \mathsf D \times \Omega \to \mathbb R$ defined by $\mathcal M_q(d) = q(d) + w$, with $w \sim Lap(b)$, where $b \geq \frac{\Delta q}{\epsilon}$, is $\epsilon$-differentially private~\cite{10.1007/11681878_14}. \end{thm} \subsection{Utility Metrics} \label{sec:metric} \subhead{$\ell_p$ Metrics} In penalized regression, ``$\ell_p$ penalty'' refer to penalizing the $\ell_p$ norm of a solution's vector of parameter values (i.e., the sum of its absolute values, or its Euclidean length)~\cite{10.5555/21713}. In our privacy-utility setting, the $\ell_p$ utility metric is defined as follows. \begin{defn}($\ell_p$). \label{defn:lp} For a database mechanism $\mathcal M_q(D)$ the $\ell_p$ utility metric is defined as $\mathbb E(|\mathcal M_q(D)-q(D)|^p)^{1/p}$. \end{defn} \subhead{Usefulness} Following Blum et al.~\cite{Blum:2008:LTA:1374376.1374464}, the following utility metric is commonly used for machine learning. \begin{defn}(Usefulness). \label{defn:useful} A mechanism $\mathcal M_q$ is ($\gamma, \zeta$)-useful if, with probability $1 - \zeta$, for any dataset $d \subseteq \mathsf D$, $|\mathcal M_q(d)- q(d)| \leq \gamma$. \end{defn} \begin{thm} \label{thmuselap} The Laplace Mechanism is $(\frac{\Delta q}{\epsilon} \ln \frac{1}{\zeta},\zeta)$-useful, or equivalently, the Laplace Mechanism is $(\gamma,e^{\frac{-\gamma}{b(\epsilon)}})$-useful~\cite{Chan:2011:PCR:2043621.2043626}. \end{thm} \subhead{Mallows Metric} The Mallows metric has been applied for evaluating the private estimation of the degree distribution of a social network~\cite{Hay:2009:AED:1674659.1677046}. It is defined to test if two samples are drawn from the same distribution. Given two random variables $X$ and $Y$, we have $Mallows(X,Y)=\frac{1}{n}\sum_{i=1}^{n} (|X_i-Y_i|^p)^{1/p}$ (similar to $p$-norm). \subhead{Relative Entropy (R\'enyi Entropy)} The relative entropy, also known as the \textit{Kullback-Leibler (KL)} divergence, measures the distance between two probability distributions ~\cite{cohen1993majorization}. Formally, given two probability distributions $p(x)$ and $q(x)$ over a discrete random variable $x$, the relative entropy given by $D(p||q)$ is defined as follows: $D(p||q) = \sum_{x\in\mathcal{X}} p(x) \log \frac{p(x)}{q(x)} $. Further generalization came from R\'enyi~\cite{renyi1961measures,gil2011renyi}, who introduced an indexed family of generalized information and divergence measures akin to the Shannon entropy and KL divergence. R\'enyi introduced the entropy of order $\alpha$ as $I_{\alpha}(p||q) = \frac{1}{\alpha-1} \log (\sum_{x\in\mathcal{X}} p(x)^\alpha q(x)^{1-\alpha})$ , $\alpha>0$ and $\alpha \neq 1$. \section{The R$^2$DP framework} \label{sec4} \begin{figure*}[ht] \includegraphics[width=0.95\linewidth]{newfig/ov.pdf} \centering \vspace{-0.15in} \caption{The high level overview of the R$^2$DP framework.} \label{figoverview} \end{figure*} In this section, we define the R$^2$DP framework and its main building block which is the \textit{Utility-maximized PDF} finder. \subsection{Notions and Notations} \label{subsec4} In probability and statistics, a random variable (RV) that is distributed according to some parameterized PDFs, with (some of) the parameters of that PDFs themselves being random variables, is known as a \emph{mixture} distribution~\cite{Charalambides:2005:CMD:1196346} when the underlying RV is discrete (or a \emph{compound} distribution when the RV is continuous). Compound (or mixture) distributions have been applied in many contexts in the literature~\cite{panjer_1981} and arise naturally where a statistical population contains two or more sub-populations. \begin{defn} Let ($\Omega,\mathcal F, \mathbb P$) be a probability space and let $X$ be a RV that is distributed according to some parameterized distribution $f(\theta) \in\mathcal F$ with an unknown parameter $\theta$ that is again distributed according to some other distribution $g$. The resulting distribution $h$ is said to be the distribution that results from compounding $f$ with $g$, \begin{equation} h(X)= \int_{\mathbb R} f(X|\theta) g(\theta)\operatorname d\theta \end{equation} Then for any Borel subset $B$ of $\mathbb R$, \begin{equation} \label{probcomp} \mathbb P(X \in B)= \int_{B} \int_{\mathbb{R}} f(X|\theta) g(\theta)\operatorname d\theta dX \end{equation} \end{defn} In general, we call any differentially private query answering mechanisms that leverage two-fold probability distribution functions in their randomization, an \emph{R$^2$DP mechanism}. \begin{defn}(\textit{R$^2$DP Mechanism}). \label{Def:RPm} Let $\mathcal M_q(d,u) = q(d) \bigoplus \omega(u)$ be a mechanism randomizing the answer of a query $q$ using a random oracle $\omega(u)$, where $u$ is the set of parameters (mean, variance, etc.) of the PDF of $\omega$ and $\bigoplus$ stands for the corresponding operator. Denote by $\mathcal F$ the space of PDFs, we call $\mathcal M_q(d,u)$ an \textit{R$^2$DP mechanism} if at least one of the parameters $u_i\in u$, $( i\leq |u|)$ is/are chosen randomly w.r.t. a specified probability distribution $f_{u_i} \in \mathcal F$. \end{defn} \vspace{0.05in} In particular, the \emph{R{$^2$}DP Laplace mechanism} will modify the answer to a numerical query by adding zero-mean noise distributed according to a compound Laplace distribution with the scale parameter $b$ itself distributed according to some distribution $f_b$. \begin{exmp} \label{exmprpdp} Suppose that the scale parameter $b$ in a Laplace mechanism is randomized as follows: \[ b=\begin{cases}b_1&{\text{w.p.}} \ \ \ p ,\\b_2&{\text{w.p.}} \ \ \ 1-p .\end{cases}\] Then, the perturbed result $q(D)+Lap(b)$ is an example R$^2$DP Laplace mechanism using a Bernoulli distribution. \end{exmp} \begin{defn} Let $q: \mathsf D \to \mathbb R$ be a query and suppose $f_{b} \in \mathcal F$ is a probability density function of the scale parameter $b$. Then, the mechanism $\mathcal M_q: \mathsf D \times \Omega \to \mathbb R$, defined by $\mathcal M_q(d,b) = q(d) + Lap(b)$ is an R$^2$DP Laplace mechanism that utilizes PDF $f_{b}$. \end{defn} \subsection{The Framework} \label{subsec:Overview} As shown in Figure~\ref{figoverview}, R$^2$DP framework include the following steps. \vspace{0.05in} \noindent\textbf{R$^2$DP Computation:} \begin{itemize} \item \textbf{Step 1}: The data owner specifies the differential privacy budget $\epsilon$ and the data recipient specifies his/her query of interest together with its required utility metric. \item \textbf{Step 2}: Given the input triplets ($\epsilon,\text{query},\text{metric}$), the \emph{utility-maximized PDF computing module} computes the provably optimal probability density function and its parameters for the variance of the additive noise. For example, in Figure~\ref{figoverview}, the PDF computing module returns a lower tail truncated Gaussian distribution for the specified inputs. \item \textbf{Step 3}: The \emph{variance sampler} module randomly samples (w.r.t. the PDF found in Step 2) one standard deviation $\sigma_i$ of the noise to be eventually added. \end{itemize} \noindent\textbf{Baseline DP Randomization:} \begin{itemize} \item \textbf{Step 4}: Next, the computed standard deviation $\sigma_i$ is used to generate a noise $\omega(\sigma_4)$ for the baseline DP mechanism, which is a DP mechanism of exponential order, e.g ., Laplace, Gaussian and exponential mechanisms. \item \textbf{Step 5}: The computed noise $\omega(\sigma_i)$ is added to the query result $q(D)$ to provide a utility-maximized DP result to the data recipient. \end{itemize} The most important module of the R$^2$DP framework is the \emph{utility-maximized PDF computing module} (Step 2) which will be described in more details in the following. Furthermore, to make our discussions more concrete, we instantiate the R$^2$DP framework based on the well studied Laplace mechanism, namely, \textit{the R$^2$DP Laplace mechanism}, where other baseline DP mechanisms will be discussed in Appendix~\ref{sec:Gauss} due to space limitation (from now on, we will simply refer to the R$^2$DP Laplace mechanism as R$^2$DP). Particularly, we show that, with a two-fold Laplace distribution, an infinite-size class of log-convex distributions can be identified. This class of distributions pertains a differential privacy guarantee which can globally be given in terms of the PDFs' parameters, and hence is automatically optimizable under the differential privacy constraint. \vspace{0.05in} \subsection{Computing Utility-Maximized PDF} \label{secsearc} In Figure~\ref{figoverview}, to compute the utility-maximized PDF (Step 2), a key challenge is to establish the search space of automatically optimizable PDFs, from which the utility-maximized PDF is computed. Ideally, the search space of an R$^2$DP mechanism can be defined as the collection of all two-fold distributions, e.g., with Laplace and exponential as the first and second fold distributions, respectively. However, the key challenge here is that a mixture of distributions is itself a distribution which does not necessarily provide a global differential privacy guarantee in terms of the resulting PDFs' parameters (automatically optimizable under the differential privacy constraint). To address this issue, the \emph{Moment Generating Function (MGF)}~\cite{fisz2018probability} of the second fold distribution could be utilized, e.g., given the first fold as Laplace distribution. Specifically, MGF of a random variable is an alternative specification of its probability distribution, and hence provides the basis of an alternative route to analytical results compared with directly using probability density functions or cumulative distribution functions~\cite{fisz2018probability}. In particular, the MGF of a random variable is a log-convex function of its probability distribution which can provide a global differential privacy guarantee~\cite{fisz2018probability} (see Theorem~\ref{simple DP}). \begin{defn}(\textit{Moment Generating Function}~\cite{fisz2018probability}). The moment-generating function of a random variable $x$ is $M_{X}(t):=\mathbb E \left[e^{tX}\right], t\in \mathbb {R}$ wherever this expectation exists. The moment-generating function is the expectation of the random variable $e^{tX}$. \end{defn} \begin{thm} \label{thm: RPLap mech} We can write the CDF of the output of an R$^2$DP mechanism in terms of the \emph{Moment Generating Function (MGF)}~\cite{fisz2018probability} of the probability distribution $f_{\frac{1}{b}}$, where $b$ is the randomized scale parameter (see Appendix~\ref{demonst} and~\ref{thm3.1} for the details and the proof). \end{thm} Thus, for a PDF with non-negative support (since scale parameter is always non-negative), the R$^2$DP mechanism outputs another PDF using the MGF (where CDF is the moment and PDF is its derivative, as shown in Equation~\ref{eqn11} in Appendix \ref{proofsec}) . Moreover, since MGF is a bijective function~\cite{feller2008introduction}, the R$^2$DP mechanism can in fact generate a search space as large as the space of all PDFs with non-negative support and an existing MGF. However, the next challenge is that not all random variables have moment generating functions (MGFs), e.g., Cauchy distribution~\cite{bulmer1979principles}. Fortunately, MGFs possess an appealing composability property between independent probability distributions~\cite{Charalambides:2005:CMD:1196346}, which can be used to provide a search space of all linear combinations of a set of popular distributions with known MGFs (infinite number of RVs). \begin{thm}[MGF of Linear Combination of RVs] \label{thm:lin} If $x_1, \cdots, x_n$ are $n$ independent RVs with MGFs $M_{x_i}(t)=\mathbb E (e^{t x_i})$ for $i = 1,\cdots , n$, then the MGF of the linear combination $Y=\sum\limits_{i=1}^{n}a_ix_i$ is $\prod \limits_{i=1}^{n} M_{x_i} (a_it)$. \end{thm} Consequently, we define the search space of the R$^2$DP mechanism as all possible linear combinations of a set of independent RVs with existing MGF (Section~\ref{pdffind} will provide more details on how to choose the set of independent RVs). Although this search space is only a subset of all two-fold distributions, we will show through both numerical results (in Section~\ref{numericsec}) and experiments with real data (Section~\ref{exp:sec}) that this search space is indeed sufficient to generate near-optimal utility w.r.t. all utility metrics (universality). \section{Privacy and Utility} \label{sec5} In this section, we analyze the privacy and utility of the R$^2$DP, and then discuss extensions for improving and implementing R$^2$DP. \subsection{Privacy Analysis} \label{subsec:privacy} We now show the R$^2$DP mechanism provides differential privacy guarantee. By Theorem~\ref{thm: RPLap mech}, the DP bound of the R$^2$DP is \vspace{-0.1in} \begin{eqnarray*} \label{DPlapexmp1} &\hspace{-.4cm} e^{\epsilon}= \max\limits_{\forall S \in \mathsf R} \left\{\frac{-M_{\frac{1}{b}}(-|x-q(d)|)|_{S_{\geq q(d)}}+M_{\frac{1}{b}}(-|x-q(d)|)|_{S_{< q(d)}}}{-M_{\frac{1}{b}}(-|x-q(d')|)|_{S_{\geq q(d')}}+M_{\frac{1}{b}}(-|x-q(d')|)|_{S_{< q(d')}}}\right\} \end{eqnarray*} Hence, the value of $e^{\epsilon}$ only depends on the distribution of reciprocal of the scale parameter $b$, i.e., $f_{\frac{1}{b}}$. Moreover, an MGF is positive and log-convex~\cite{fisz2018probability} where the latter property is desirable in defining various natural logarithm upper bounds, e.g., DP bound. In the following theorem, our MGF-based formula for the probability $\mathbb P(\{q(d)+Lap(b)\}\in S)$ can be easily applied to calculate the differential privacy guarantee (see Appendix~\ref{proofsec} for the proof). \begin{thm} \label{simple DP} The R$^2$DP mechanism $\mathcal M_q(d,b)$ is \vspace{-0.15in} \begin{equation} \label{simple DPeq} \ln \left[ \cfrac{ \mathbb E(\frac{1}{b})} {\diff{M_{\frac{1}{b}}(t)}{t}|_{t=- \Delta q}} \right]\text{-differentially private.} \end{equation} \end{thm} Moreover, Theorem~\ref{thm:lin} can be directly applied to calculate the differential privacy guarantee of any RV from the search space defined in Section~\ref{secsearc} (i.e., all linear combinations of a set of independent RVs with known MGFs). \begin{coro} [Differential Privacy of Combined PDFs] \label{thm:mgffin} If $x_1, \cdots, x_n$ are $n$ independent random variables with respective MGFs $M_{x_i}(t)=\mathbb E (e^{t x_i})$ for $i = 1, \cdots, n$, then the R$^2$DP mechanism $\mathcal M_q(d,b)$ where $\frac{1}{b}$ is defined as the linear combination $\frac{1}{b}=\sum\limits_{i=1}^{n}a_ix_i$ is $\epsilon$-differentially private, where \vspace{-0.2cm} \begin{eqnarray} \scriptsize \label{mgfdp} \epsilon=\ln\left[\cfrac{\sum \limits_{j=1}^{n} a_j\cdot E_{x_j}(\frac{1}{b})}{\sum \limits_{j=1}^{n} a_j\cdot M'_{x_j}(-a_j\cdot \Delta q) \cdot \prod \limits_{\substack{i=1 \\ i\neq j}}^{n} M_{x_i} (-a_i\cdot \Delta q)}\right] \end{eqnarray} \end{coro} Therefore, we have established a search space of probability distributions with a universal formulation for their differential privacy guarantees, which is the key enabler for the universality of R$^2$DP. Next, we characterize the utility of R$^2$DP mechanisms. \subsection{Utility Analysis} We now characterize the utility of the R$^2$DP mechanism. To make concrete discussions, we focus on the usefulness metric (see Section~\ref{sec:metric}), and a similar logic can also be applied to other metrics. \subsubsection{Characterizing the Utility} Denote by $U(\epsilon, \Delta q, \gamma)$ the usefulness of an R$^2$DP mechanism for all $ \epsilon>0$, sensitivity $\Delta q$ and error bound $\gamma$. The optimal usefulness is then given as the answer of the following optimization problem over the search space of PDFs. \vspace{-0.1cm} \begin{eqnarray} \label{multi-obj1} &\hspace{-0.5cm} \max\limits_{f_{\frac{1}{b}}\in F} \big\{U(\epsilon, \Delta q, \gamma) \big\}=\max\limits_{f_{\frac{1}{b}}\in F} \bigg \{\frac{1}{2} \cdot \Big[-M_{\frac{1}{b}}(-|x-q(d)|)|_{q(d)}^{q(d)+\gamma}\nonumber\\ &\hspace{3.5cm}+M_{\frac{1}{b}}(-|x-q(d)|)|_{q(d)-\gamma}^{q(d)}\Big] \bigg \}, \nonumber\\ & \text{subject to } \ \ \ \epsilon=\ln \left[ \cfrac{ \mathbb E(\frac{1}{b})} {\diff{M_{\frac{1}{b}}(t)}{t}|_{t=- \Delta q}} \right] \nonumber \end{eqnarray} where the utility function is the probability of generating $\epsilon$-DP query results within a distance of $\gamma$-error (using Theorem~\ref{thm: RPLap mech}). Note that $\epsilon$ and $\Delta q$ do not directly impact the usefulness but they do so indirectly through the differential privacy constraint. Furthermore, as shown in Theorem~\ref{simple DP}, the differential privacy guarantee $\epsilon$ over the established search space is a unique function of the parameters of the second-fold distribution. \begin{coro} \label{co1} Denote by $u$, the set of parameters for a probability distribution $f_{\frac{1}{b}}$, and by $M_{f(u)}$ its MGF. Then, the optimal usefulness of an R$^2$DP mechanism utilizing $f_{\frac{1}{b}}$, at each triplet $(\epsilon, \Delta q, \gamma)$ is \begin{eqnarray} \small \label{gen:conddelt} &\hspace{-0.5cm} U_f(\epsilon, \Delta q, \gamma)=\max\limits_{u\in \mathbb{R}^{|u|}} \bigg \{\frac{1}{2} \cdot \Big[-M_{f(u)}(-|x-q(d)|)|_{q(d)}^{q(d)+\gamma}\nonumber\\ &\hspace{3.5cm}+M_{f(u)}(-|x-q(d)|)|_{q(d)-\gamma}^{q(d)}\Big] \bigg \}, \nonumber\\ & \text{subject to } \ \ \ \epsilon=\ln \left[ \cfrac{ \mathbb E(\frac{1}{b})} {\diff{M_{\frac{1}{b}}(t)}{t}|_{t=- \Delta q}} \right] \nonumber \end{eqnarray} \end{coro} Since MGFs are positive and log-convex, with $M(0)=1$, we have $U_f(\epsilon, \Delta q, \gamma)=1-\min\limits_{u\in \mathbb{R}^{|u|}} M_{f(u)}(-\gamma)$. Thus, for usefulness metric, the optimal distribution for $\epsilon$ is the one with the minimum MGF evaluated at $\gamma$. In particular, for a set of privacy/utility parameters, we can find the optimal PDF using the \textit{Lagrange multiplier}~\cite{bertsekas2014constrained}. i.e., \begin{eqnarray} \label{lagrange1} \mathcal{L} (u,\lambda)= M_{f(u)}(-\gamma)+ \lambda \cdot (\ln \left[ \cfrac{ \mathbb E(\frac{1}{b})} {\diff{M_{\frac{1}{b}}(t)}{t}|_{t=- \Delta q}} \right]-\epsilon) \end{eqnarray} Moreover, Theorem~\ref{thm:lin} can be directly applied to design a utility-maximizing R$^2$DP mechanism with a sufficiently large search space (with an infinite number of different random variables). \begin{coro} [Optimal Utility for Combined RVs] \label{thm:mgff} If $ \ x_1, x_2,$ $ \cdots, x_n$ are $n$ independent random variables with respective MGFs $M_{x_i}(t)=\mathbb E (e^{t x_i})$ for $i = 1, 2,\cdots, n$, then for the linear combination $Y=\sum\limits_{i=1}^{n}a_ix_i$, the optimal usefulness (similar relation holds for other metrics) under $\epsilon$-differential privacy constraint is given as \begin{eqnarray} \scriptsize \label{mgffin} &\hspace{-1.5cm} U_{Y}(\epsilon, \Delta q, \gamma)=1-\min\limits_{\mathcal{A,U}} \bigg\{ \prod \limits_{i=1}^{n} M_{x_i} (-a_i\gamma) \bigg\}\\ &\hspace{-7cm} \text{subject to } \nonumber\\ & \hspace{-.3cm} \epsilon= \ln\left[\cfrac{\sum \limits_{j=1}^{n} a_j\cdot E_{x_j}(\frac{1}{b})}{\sum \limits_{j=1}^{n} a_j\cdot M'_{x_j}(a_j\cdot -\Delta q) \cdot \prod \limits_{\substack{i=1 \\ i\neq j}}^{n} M_{x_i} (-a_i\cdot \Delta q)}\right] \nonumber \nonumber \end{eqnarray} where $\mathcal{A}=\{a_1,a_2,\cdots, a_n\}$ is the set of the coefficients and $\mathcal{U}=\{u_1,u_2,\cdots, u_n\}$ is the set of parameters of the probability distributions of RVs $x_i, \ \forall i \leq n$. \end{coro} Similar to the case of a single RV, we can compute the optimal solution for this optimization problem using the Lagrange multiplier function in Equation~\ref{lagrange1}. \subsubsection{Finding Utility-Maximizing Distributions} \label{pdffind} Since not all second-fold probability distributions can boost the utility of the baseline Laplace mechanism, leveraging all RVs into our search space would only result in redundant computation by the utility-maximized PDF computing module. Accordingly, in this section, we first derive a necessary condition on the differential privacy guarantee of R$^2$DP to boost the utility of the baseline Laplace mechanism (refer to Appendix~\ref{proofsec} for the proof). Using this necessary condition, we can easily filter out those probability distributions that cannot deliver any utility improvement. \begin{thm} \label{thm: RPLap mechut} The utility of R$^2$DP with $\epsilon\geq \ln \Big[ \mathbb E_{\frac{1}{b}} \big(e^{\epsilon(b)} \big ) \Big]$ is always upper bounded by the utility of the $\epsilon$-differentially private baseline Laplace mechanism. Equivalently, for an R$^2$DP mechanism to boost the utility, the following relation is necessarily true. \begin{equation} \label{necc} e^\epsilon=\frac{\mathbb E(\frac{1}{b})}{M'_{\frac{1}{b}}(- \Delta q)} < M_{\frac{1}{b}} (\Delta q) \end{equation} \end{thm} We note that $\epsilon= \ln \Big[ \mathbb E_{\frac{1}{b}} \big(e^{\epsilon(b)} \big ) \Big]$ provides a tight upper bound since it gives the overall $e^\epsilon$ of an R$^2$DP mechanism as the average of differential privacy leakage. Next, we examine a set of well-known PDFs as second-fold distribution to identify the distribution that offers a significantly improved utility compared with the bound given in Theorem~\ref{thm: RPLap mechut}. Promisingly, our analytic evaluations for \emph{three} of these distributions, i.e., Gamma, uniform and truncated Gaussian distributions demonstrate such a payoff (Appendix~\ref{cases} theoretically analyzes several case study PDFs). We note that those chosen distributions are general enough to cover many of other probability distributions (e.g., Exponential, Erlang, and Chi-squared distributions are special cases of Gamma distribution). \subsubsection{Deriving Error Bounds} The error bounds of the R$^2$DP mechanism under some well-known utility metrics are shown in Table~\ref{tablemetrics}. The key idea in deriving these results is to calculate the mean of each utility metric over the PDF of RV $1/b$ (which is the linear combination of RVs in multiple PDFs). Specifically, given the error bound $e_L(b)$ for deterministic variance (i.e., Laplace mechanism), the total error bound of an R$^2$DP mechanism will be the mean $\int_0^\infty e_L(b) f_b(b) db$. The results shown in Table~\ref{tablemetrics} can be easily applied to optimize those metrics in corresponding applications (e.g., \textbf{$\ell_1$} for private record matching~\cite{inan2010private}, \textbf{ $\ell_2$} for location privacy~\cite{bordenabe2014optimal}, usefulness for machine learning~\cite{Blum:2008:LTA:1374376.1374464}, Mallows for social network analysis~\cite{Hay:2009:AED:1674659.1677046}, and relative entropy (with a degree $\alpha)$ for semi-supervised learning~\cite{grandvalet2005semi}). \begin{table}[ht] \caption{Error bound of R$^2$DP under different metrics} \centering \begin{adjustbox}{width=0.5\textwidth,center} \begin{tabular}{|c|c|c|} \hline \bf{Metric} & \bf{Dependency to Prior}& \textbf{R$^2$DP Error Bound} \\ \hline \bf{$\ell_1$} & independent& $\int\limits_{0}^\infty M_{\frac{1}{b}}(-x) dx$ \\ \hline \bf{ $\ell_2$}& independent & $\sqrt{2\iint\limits_0^\infty M_{\frac{1}{b}}(-u) du dx}$ \\ \hline Usefulness & independent & $1-M_{\frac{1}{b}}(-\gamma)$\\ \hline Mallows (p) & dependent & $\left([\sum_{i=1}^n |N_i\sim[-M'_{\frac{1}{b}}(-x)/2]|^p]/n\right)^{1/p} $\\ \hline Relative Entropy ($\alpha)$ & dependent & $\frac{\log \sum_{x\in\mathcal{X}}^n p(x)^\alpha q(x)^{1-\alpha}}{\alpha-1} \text{s.t} (q(x)-p(x))\sim -M'_{\frac{1}{b}}(-x)/2$\\ \hline \end{tabular} \end{adjustbox} \label{tablemetrics} \end{table} In this context, the $\ell_1$, $\ell_2$ and usefulness metrics (as defined in Section \ref{sec:metric}) are independent to the prior (i.e., not depending on the distribution of the true results). The metrics will be evaluated based on the deviation between the true and noisy results (which does not change regardless of the prior). On the contrary, some other metrics (e.g., Mallows and relative entropy) depend on the prior distribution of the true results \cite{Hay:2009:AED:1674659.1677046,grandvalet2005semi}. In such cases, the metrics will be evaluated based on the deviation between the true and noisy results w.r.t. the prior in specific experimental settings (we will discuss those specific priors used in the experiments in Section~\ref{exp:sec}). \begin{table*}[ht] \caption{R$^2$DP compared to Laplace w.r.t. error bounds for learning algorithms} \centering \begin{adjustbox}{width=0.9\textwidth,center} \begin{tabular}{|c|c|c|c|c|} \hline &Linear SVM~\cite{ji2014differential} & Bayesian Inference (statistician)~\cite{zhang2016differential} & Robust Linear Regression~\cite{dwork2009differential} & Naive Bayes~\cite{10.1109/WI-IAT.2013.80} \\ \hline Laplace & $O( \frac{\log(1/\beta)}{\alpha^2}+ \frac{1} {\epsilon\alpha} + \frac{\log(1/\beta)} {\alpha \epsilon})$& $O(mn \log(n)) [1-exp(-\frac{n\epsilon}{2|\mathcal{I}|}]$ & $O(n^{-\epsilon log n})$&$O(\frac{1}{n\epsilon})$ \\ \hline R$^2$DP & $O( \frac{\log(1/\beta)}{\alpha^2}+ \mathbb{E}_{\frac{1}{b}}(\frac{b} {\alpha} + \frac{b\log(1/\beta)} {\alpha}))$& $O(mn \log(n)) [1-M_{\frac{1}{b}}(-\frac{n}{2|\mathcal{I}|})]$ & $O(\mathbb{E}_{\frac{1}{b}}(n^{-\frac{log n}{b}}))$&$O(\mathbb{E}_{\frac{1}{b}}({\frac{b}{n}}))$ \\ \hline \end{tabular} \end{adjustbox} \label{tableerror} \end{table*} In addition to the error bounds given in Table~\ref{tablemetrics}, an analyst can derive error bounds for more advanced queries, e.g., those pertaining to learning algorithms \cite{ji2014differential,zhang2016differential,dwork2009differential,10.1109/WI-IAT.2013.80}. Given the error bound of Laplace mechanism in an application (e.g., Linear SVM~\cite{ji2014differential}), the error bound of the R$^2$DP framework for this application can be derived by taking average of the Laplace's result over the PDF of $\frac{1}{b_r}$. In particular, Table~\ref{tableerror} demonstrates the error bounds of R$^2$DP for some learning algorithms (as shown in Section~\ref{exp:sec}, those learning algorithms can benefit from integrating R$^2$DP instead of Laplace). To derive the error bounds shown in Table~\ref{tablemetrics} and Table~\ref{tableerror}, the noise parameter(s) and the PDFs used in R$^2$DP can be released to a downstream analyst. This will not cause any privacy leakage because, similar to other differential privacy mechanisms, the privacy protection of R2DP comes from the (first-fold) randomization (whose generated random noises are never disclosed), which will not be affected even if all the noise parameter(s) and the PDFs are disclosed (see Section~\ref{subsec:privacy} and Appendix~\ref{proofsec} for the formal privacy analysis and proof). We note that, although R$^2$DP replaces the fixed variance of a standard differential privacy mechanism with a random variance, this second-fold randomization is not meant to keep the generated parameters (e.g., the variance) secret, but designed to cover a larger search space (as detailed in Section~\ref{secsearc}). \subsection{R$^2$DP Algorithm} Algorithm~\ref{alg:analyst-actions1} details an instance of the R$^2$DP framework using linear combination of three different PDFs. In particular, the algorithm with $\epsilon$-DP finds the best second-fold distribution using the Lagrange multiplier function (see Appendix~\ref{sec:lag}) that optimizes the utility metric. Then, it randomly generates the noise using the two-fold distribution (e.g., first-fold Laplace) and injects it into the query. \begin{algorithm}[!h] \small \SetKwInOut{Input}{Input} \SetKwInOut{Output}{Output} \Input{Dataset $D$, Privacy budget $\epsilon$, Query $q(\cdot)$, Metric and its parameters (from data recipient)} \Output{Query result $q(D)+Lap(b_r)$, DP guarantee $\epsilon$, Second-fold PDF's parameters} $\Delta q\leftarrow$ Sensitivity ($q(\cdot)$) Find optimal parameters from Lagrange Multiplier $\mathcal{L}(\epsilon, \Delta q,\text{metric})=$ $a_{1}^{opt},a_{2}^{opt}, a_{3}^{opt}, k^{opt}, \theta^{opt},a^{opt}_u,b^{opt}_u,\mu^{opt},\sigma^{opt},a_{\mathcal N^T}^{opt}, b_{\mathcal N^T}^{opt}$ $X_1 \sim \Gamma(k^{opt}, \theta^{opt})$\\ $X_2 \sim U(a^{opt}_u,b^{opt}_u)$ \\ $X_3\sim \mathcal{N}^T(\mu^{opt},\sigma^{opt},a_{\mathcal N^T}^{opt} , b_{\mathcal N^T}^{opt})$ $\frac{1}{b_r} = a_1^{opt} \cdot X_1 + a_2^{opt} \cdot X_2+a_3^{opt} \cdot X_3$ \textbf{return} $q(D)+Lap(b_r)$, $\epsilon$, $\mathcal{L}(\epsilon, \Delta q,\text{metric})$ \caption{The Ensemble R$^2$DP Algorithm} \label{alg:analyst-actions1} \end{algorithm} Some advanced applications (e.g., workload queries) that integrate R$^2$DP to improve their utility are discussed in Appendix \ref{sec:RPDP as a Patch to Existing Work1}.
{'timestamp': '2020-09-25T02:07:37', 'yymm': '2009', 'arxiv_id': '2009.09451', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09451'}
arxiv
\section{Introduction}\label{sec:introduction}} \else \section{Introduction} \label{sec:introduction} \fi Owing to the rapid growth of the scientific literature, majority of the available biological facts remain concealed in the form of scientific literature. Over the last two decades, MEDLINE size has risen at a compounded annual growth pace of ~4.2 percent. MEDLINE currently holds more than $26,000,000$ records from $5639$ publications, which is more than $5$ millions than those indexed in $2014$ alone. This similar trend was also observed in case of the healthcare data. IBM reported that nearly $2.5$ quintillion bytes of the healthcare data are generated globally. Encapsulated within this unstructured text is an enormous amount of significant healthcare and the biomedical data, which are valuable sources of information for the Biomedical Natural Language Processing (BioNLP) domain. As a consequence of the exponential rise \cite{lu2011pubmed,khare2014accessing} and complexity of the biological and clinical information, it is imperative to advance the automatic extraction techniques to assist biologist in detecting, curating and maintaining databases and providing automated decision support systems for the health professional. This has led to a rise in the interest of the BioNLP community to automatically detect and extract information from the scientific literature and clinical records \cite{yadav2016deep,yadav2018feature,yadav2017entity}. \\ \indent Relation extraction is one such task that aims to detect and characterize the semantic relationship between the biological/clinical entities. The relation types could vary depending upon the genres and domains, such as interactions between genes, proteins, drugs, or medical concepts (problems, treatments, or tests).\\ In this paper, we study the relation extraction (RE) on the most popular biomedical and clinical tasks, namely drug-drug interaction (DDI), protein-protein interaction (PPI) and clinical relation. DDI detection is an significant area of patient safety studies as these interactions can become very hazardous and boost the cost of health care. Similarly, the knowledge about interaction among proteins can help in understanding biological processes, complex diseases, and guiding drug discoveries \cite{kann2007protein}. In the clinical domain, the ability to recognize relations among medical concepts (treatments, tests, or problems) allows the automatic processing of clinical texts, resulting in clinical decision-making, clinical trial screening, and pharmacovigilance. \\ In the vast literature on relation extraction, several techniques have been proposed to solve the problem ranging from the semantic-injected kernel model \cite{bunescu2005shortest, airola2008graph} to the machine learning embedded models \cite{thomas2013wbi,liu2015dependency}. In recent past, with the success of deep neural networks, the state-of-the-art models for these tasks have been drifted towards the deep learning frameworks \cite{choi2016extraction,zhao2016protein}. \\ \indent However, there have been a very few attempts in improving the performance of RE system irrespective of the tasks or domains. One potential solution is to model the relation extraction problem in the multi-task learning framework, where a problem together with the other related problem can be learned by leveraging the shared representation. This method of multi-task learning provides advantages in \textbf{(1)} minimizing the number of parameters and \textbf{(2)} reducing the risk of over-fitting. The aim of multi-task learning (MTL) is to enhance the system performance by integrating the other similar tasks \cite{yadav2018multi,yadav2019unified}. When tasks are common and, in particular, when training data is limited, MTL can contribute to better results than a model trained on a single dataset, allowing the learner to capitalize on the commonality among the tasks. This can assist the overall model as dataset can contain information which are complementary to address individual tasks more correctly when trained jointly \cite{Crichton2017}. However, most of the existing methods on multi-task classification tend to divide the feature space of each task into shared and private, depending solely on hard-parameter or soft-parameter sharing. As such, these task-shared features are prone to being contaminated with external noise and task-specific features that often lead the system to suffer from the redundancy of the feature. \\ \indent To combat the contamination issue of task-shared features, in this paper, we propose an adversarial multi-task relation extraction framework. This framework deals with utilizing concept of adversarial learning to inherently disjoint the task-specific and task-invariant feature spaces. In adversarial learning \cite{goodfellow2014generative}, a model is trained to correctly classify both unmodified data and adversarial data through the regularization method. The adversarial learning paradigm provides an assurance that task-shared feature space is not contaminated with task-specific features and contains only task-invariant features. \\ \indent In our study, we use the bi-directional gated recurrent units (Bi-GRU) \cite{cho2014properties} as a learning algorithm which has the capability to learn the features by capturing the long dependency information. Bi-GRU, unlike other Recurrent Neural Networks (RNN), such as Long Short Term Memory (LSTM) is computationally less expensive \cite{hochreiter1997long}. GRU also has the gating mechanism similar to LSTM to control the information flow. But unlike LSTM, GRU has no memory unit and has an update and reset gate. As such, when down-sampling operation is performed on the output of GRU, we extract the optimal features from the entire input sequence covering the complete context information. In the literature, the attention mechanism has shown the promising results in relation extraction by generating the optimal and effective features. In attention mechanism, a simple strategy has been followed by computing a weight vector corresponding to each hidden state of the RNN or CNN. The final hidden states are computed by performing the pooling operation (max, min, average etc.) on the weighted representations of hidden states. However, the computed attention weight focuses on a specific aspect of the input sequence. In this work, we attempt to capture multiple aspects of the input sequence by exploiting the self-attention mechanism. Basically, we learn to generate the multiple attention weight vectors, which eventually generate the multiple final representations of hidden states considering the various aspects of the input sequence. \indent We apply our proposed approach on four popular benchmark datasets namely, AiMED \& BioInfer for PPI \cite{pyysalo2008comparative}, DrugDDI for DDI \cite{segura2013semeval}, and 2010 i2b2/VA NLP challenge dataset for clinical relation extraction (MCR) \cite{uzuner20112010}. Our proposed MTL model obtained the F1-Score points of $77.33$, $76.33$, $72.57$, and $81.65$ for AiMed, BioInfer, DDI and i2b2 relation extraction dataset, respectively. We observe an average 5\% improvement in F-score in comparison to single task learning baseline model and over 3\% improvement on MTL baseline model. Performance on any dataset does not decrease considerably, and performance increases significantly for all the four datasets. These are promising outcomes that set the potential for using the MTL model to solve the issue of biomedical RE. In addition to the baselines, our proposed model outperforms the state-of-the-art methods for all the datasets. This shows that, when we have tasks in common, multi-task can assist over the single-task models. The contributions of our proposed work can be summarized as follows: \begin{enumerate} \item We propose a multi-task learning (MTL) framework for relation extraction that exploits the capabilities of adversarial learning to learn the shared complementary features across the multiple biomedical and clinical datasets. We also exploit the self-attention mechanism which allows the final feature representation to directly access previous Bi-GRU hidden states via the attention summation. Therefore, the Bi-GRU does not need to carry the information from each time step towards its last hidden state. \item Our proposed model is capable of automatically extracting the various relations (such as \textit{Protein-Protein Interaction}, \textit{Drug- Drug interaction: `int', `advice', mechanism, effect}, and relation between \textit{medical problem and treatment}, \textit{test and treatment}, \textit{treatment and treatment}). \item We validate our proposed framework on four popular benchmark datasets (AiMED, BioInfer, SemEval 2013 Drug Interaction task, and i2b2 medical relation shared task dataset) for relation extraction, having different annotation schemes. \item Our unified multi-task model achieves the state-of-the-art performance and outperforms the strong baseline models for all the tasks in the respective datasets. \end{enumerate} \section{Related Works} There has been recent surge in the interest of the BioNLP community to automatically detect and extract information from the scientific literature and clinical records \cite{savery2020chemical,goodwin2020customizable,srivastava2016recurrent,yadav2019information,ekbal2016deep,yadav2020exploring}. In the past decade, there has been tremendous amount of the work on varieties of the relation extraction task such as extracting relationship between the bio-entities (proteins, gene, diseases, etc.) from the biomedical literature. Much previous works are done by using the Kernel-based technique which allows the representation learning of the data in the form of dependency structures and syntactic parse trees. Some of the other prominent techniques for extracting the relationships are based on the pattern-matching technique. Recently, with the success of deep learning technique, several techniques based on the Convolutional Neural Network, Recurrent Neural Network, and Long Short Term Memory network are widely utilized for extracting the relationships from biomedical literature and clinical records. Based on the tasks, we divide the related works in the following three categories: \begin{itemize} \item \textbf{Protein Protein Interaction task:} Several NLP techniques have been proposed to identify the relationships between the protein entities. The preliminary studies \cite{blaschke1999automatic,ono2001automated,bunescu2005comparative} on this task were essentially solved by using pattern-based model, where patterns were extracted from the data based on their syntactic and lexical properties. The main drawback with this approach is the inability to properly handle the complex relationship expressed in coordinating and relational clause. Dependency based approaches \cite{miyao2008evaluating,daraselia2004extracting} are more syntax aware techniques and have broader coverage than naive pattern based approaches. Some of the studies \cite{erkan2007semi} exploring the dependency based techniques incorporate the dependency information as a shortest dependency path between the sentences. Also the technique based on kernel method is often explored in the area of PPI extraction. Some of the prominent kernel-based approaches for extracting the PPI include edit-distance kernel \cite{erkan2007semi}, bag-of-word kernel \cite{saetre2007syntactic}, all-path kernel \cite{airola2008graph}, graph kernel \cite{airola2008all}, and tree-kernel \cite{zhang2006composite}. \cite{kim2010walk} proposed a walk-weighted sub sequence kernel that captures the syntactic structure by matching the e-walk and v-walk on the shortest dependency path. \cite{chang2016pipe} proposed a technique based on convolutional tree kernel by integrating the patterns of protein interaction. \\ \indent Recently, various studies have exploited deep learning based techniques \cite{yadav2018feature1,hsieh2017identifying} which do not require the manual feature engineering unlike the previous techniques based on the kernel, pattern and dependency based methods. \cite{hua2016shortest} first proposed the deep learning technique for extracting the relationship between the protein pairs. They used the CNN as a base learner over the word embedding generated through the Google News corpus. \cite{choi2018extraction} proposed a neural network framework which integrates several lexical, semantic and syntactic level information in the CNN model. Their study shows that integrating these additional information provides very minor improvement overall. \cite{peng2017deep} in their study proposed a two channel CNN technique for high level of feature extraction. In the first channel, they used words with additional syntactic features like part-of-speech, chunking information, dependency information, named entities and the word position information w.r.t the protein entities. In the second channel, they used the parent word information for every word. \cite{zhao2016protein} propose a greedy layer-wise unsupervised technique to extract the PPIs. They utilized the auto encoder on the unlabelled data for the parameter initialization of the deep neural network model and applied the gradient decent method using back propagation to train the whole network. \\ Various studies \cite{hsieh2017identifying} on PPI extraction task have also explored the Recurrent Neural Network framework. \cite{yadav2019feature} proposed a method based on the Bi-directional Long Short Term Memory Network (Bi-LSTM) equipped with the stacked attention mechanism. The input to their model is the shortest dependency path between the entity pairs. Their study shows that providing multiple attentions can assist the model in better capturing the long contextual and structural information. \cite{ahmed2019identifying} proposed a tree RNN with structured attention framework for extracting the PPI information. \item \textbf{Drug Drug Interaction task:} Existing techniques on drug drug interaction can be categorized into one-stage and two-stage classification scheme \cite{SAHU201815}. In the one-stage classification \cite{bobic2013scai,hailu2013ucolorado_som}, the aim of the task is to identify the multiple relationships between the drug pairs, which could be from any of the interacting class or negative class. Several methods have explored the multi-class classifier, to capture the relationship between two target drugs in a sentence. While, in the two-stage classification \cite{bjorne2013uturku,rastegar2013uwm} scheme, there are two steps. The first step determines whether the target drug pair is interacting/non-interacting. In the second step, only the interacting sentences are considered as inputs to the multi-class classifier. These approaches can further be classified into handcrafted feature and latent feature based methods. Techniques \cite{kim2015extracting,bokharaeian2013nil_ucm,chowdhury2013fbk} based on the hand-crafted feature mainly utilize support vector machines (SVMs) as the base learner. These techniques are reliant on several hand-crafted features such as Part-of-Speech, chunk, syntax trees, dependency parsing, and trigger words. These methods are utilized in other biomedical relation extraction tasks, such as adverse drug reactions extraction tasks \cite{harpaz2014text,xu2015large}, protein protein interaction extraction \cite{qian2012tree}, relation extraction between diseases and genes \cite{bravo2015extraction}, and relations between the medical concepts \cite{rink2011automatic}. These techniques have appeared to perform well, however they are very domain-specific and are dependent on other NLP tools. Approaches exploring the latent features, are based on deep learning models, that are proved to be powerful solutions to the feature based models. Below we provide the survey in detail for the above described methods: \begin{itemize} \item \textbf{Linear Methods:} This method utilizes a linear classifier that takes as an input the domain specific or manually designed features. The system proposed by Uturku \cite{bjorne2013uturku} explored Turku event extraction system (TEES) for identifying the drug interaction pairs. TEES utilizes the features of dependency parsing and lexicon derived from MetaMap and Drugbank. \cite{rastegar2013uwm} developed two-stage classification technique based on SVM. They explored several hand-crafted features such as lexical, contextual, semantics and tree structured features. \item \textbf{Kernel Methods:} These techniques are more advanced than linear methods, where they have explored graph based features. All-paths graph kernel \cite{Airola2008} learns a classifier based on the weighting scheme for dependency parse tree feature and surface feature. k-band shortest path spectrum \cite{tikk2010comprehensive} utilizes the shortest dependency path between the entity pairs to build a classifier. It further permits the mismatches for variables and includes all the nodes within k-distance from the shortest path. The shallow linguistic kernel \cite{giuliano2006exploiting}, as the name suggests, captures the shallow linguistic features such as part-of-speech, stem, word and other morphological features that also explore the properties of the surrounding words. \cite{thomas2011relation} proposed an ensemble based DDI extraction system. They explored the various kernel classifiers in addition to the case-based reasoning technique for classifying the drug pairs. \cite{chowdhury2013fbk} also explored various kernel classifier by integrating multiple kernel methods such as SL kernel, mildly extended dependency tree (MEDT) kernel and path-enclosed tree (PET) kernel. PET kernel captures the smallest subtree involving the two entities in a phrase structure parse tree. MEDT kernel uses linguistically motivated expansions to capture the prominent clue words between the entity pairs. The system proposed by \cite{chowdhury2011two} also utilizes several kernels based on the feature and tree kernel methods. Precisely, they explored MEDT, SL, PET, global context and local context kernel. \item \textbf{Deep Learning Technique:} Deep learning technique is based on the neural network approach that utilizes latent features instead of hand-crafted features. This technique encodes the word level representation using neural network for the generation of sentence level features. For the final classification, the network uses the sentence level feature. In the recent past, several deep learning methods have been used to address DDI tasks. SCNN system was proposed by \cite{zhao2016drug}. They have used convolution neural network to capture more dense sentence representation feature. SCNN also utilized some additional features such as PoS and dependency tree based feature. \cite{SAHU201815} advanced the state-of-the-art technique by proposing three different models based on the concept of LSTM and attentive pooling. All of these models takes as an input the word and position embedding and does not rely on any hand-crafted features. Some of the other prominent work that has explored deep learning framework are \cite{zheng2017attention,kavuluru2017extracting,wang2017dependency,asada2017extracting,lim2018drug} \end{itemize} \item \textbf{Medical Concept Relation Extraction task:} Electronic medical records such as patient's discharge summaries and progress notes contains information about the medical concepts and relationship. To aid an advanced patient care, it is required have a technique for automatic processing of the clinical records. To address this issue, Informatics for Integrating Biology \& the Bedside (i2b2) organized a shared task challenge \cite{uzuner20112010} that aims to identify the relationship between medical concepts i.e. problems, treatments, or tests from the EMR document. Identifying the correct relationship between the medical concepts requires the knowledge of the context in which two concepts are discussed. Existing techniques for extracting the relations between the medical concepts can be grouped into semi-supervised and supervised classes. \cite{de2010nrc} explored the semi-supervised method to determine the relationship between a concepts-pairs. They used maximum entropy as an classification algorithm to train separately three classifier for each concept pair i.e. test-problem, treatment-problem, and problem-problem relations. They explored various external features obtained from other NLP pipeline such as cTAKES and MetaMap. Additionally, they also used word-level feature, PoS tags, dependency path based feature, and distance feature that capture minimal, average and maximal tree distances to the common ancestor. To overcome the label imbalance problem in the training data, they computed the relatedness between two medical concepts by using pointwise mutual information in MEDLINE and bootstrapping with unlabeled examples.\\ \begin{figure*}[t] \centering \includegraphics[width=10cm,height=8cm]{TcBB-2.pdf} \label{figure-proposed} \caption{Proposed multi-task model for various biomedical relation extraction tasks.} \end{figure*} Majority of the research work has been carried out on this problem are highly dependent on the supervised approach. In those works \cite{kang2010erasmus,jiang2010hybrid,grouin:hal-00795663}, statistical machine learning classifier (CRF, SVM) is used to identify the relations. As the i2b2 shared task dataset, contained a large portion of concept pairs without any relations, some of the system \cite{roberts2010extraction,jonnalagadda2012enhancing,de2011machine} proposed two stage classification methods, where in the first stage, the concept pair with relation/no relation were classified. In the latter stage, only those concept pair with the relation participate for identifying the given relationship. All of the participating system heavily rely on the hand-crafted features. They exploited semantic, lexical, syntactic, domain-specific ontology feature. The system proposed by \cite{demner2010nlm} used medical knowledge graph (UMLS) concept identifiers and applied feature selection technique to capture more relevant feature. \cite{grouin:hal-00795663} used linguistic feature to complement their machine learning component to extract the medical concept relations. Recently, neural network techniques are widely adopted for the clinical relation extraction task. \cite{sahu2016relation} explored the capabilities of convolutional neural network to capture prominent feature for extracting relations. Another study conducted by \cite{LUO201785} used two variant of RNN-LSTMs network, segment level LSTM and sentence level LSTM for encoding the relation. The experimental results shows that the proposed approach perform comparable w.r.t state-of-the-art system. They also identified that word embedding from clinical text is more beneficial than the general text.\\ Other prominent study was conducted by \cite{rosario2004classifying} to identify the relations among disease and treatment. They used several neural network and graphical models. Furthermore, they utilized other hand-crafted features such as lexical, semantic, and syntactic feature for classification. They conducted their study on very small dataset consisting of biomedical research article. \cite{bundschus2008extraction} applied CRF for extracting relations between disease, treatment and gene. They proposed two step model where in the first step, they identified the entities and in the second step, they extract the relationship. For both the steps, they explored CRF as the base learner. \cite{bravo2015extraction} developed a system for finding the association between disease, drug and target in EU-ADR dataset. They exploited kernel based method that uses the shallow linguistic and dependency kernel for extracting the relations. \cite{ningthoujam2019relation} developed shortest dependency path based deep neural network framework that also utilizes other features like Parts-of-speech information, dependency labels, and the types of the entities. \end{itemize} \section{Materials and methods}\label{material_methods} In this section, we describe the methodology used to extract the relations from various biomedical texts in our proposed multi-task learning framework. We begin by the problem statement followed by the introduction of the Gated Recurrent Unit (GRU) which is used in our models as a base learning algorithm. Following that, we describe the proposed multi-task model in detail that utilizes the concept of adversarial learning. \\ \noindent \textbf{Problem Statement:}\\ Given an input text sequence $S$ consisting of $n$ words, i.e., $S = \{w_1, w_2 \ldots w_n\}$ and a pair of entities \footnote{The entity pair can be the \textit{protein}, \textit{disease}, \textit{problem} name, etc. } $(e_1, e_2)$ where $e_1 \in S$ and $e_2 \in S$. The task is to predict the maximum probable class $\bar{y}$ from the set of class labels, $Y$. Mathematically, \begin{equation} \bar{y}=\argmax_{y \in Y} prob(y |S, e_1, e_2, \theta) \end{equation} where, $\theta$ is the model parameter. Each token $w_i \in S $ of the input sequence $S=\{w_1, w_2, \ldots, w_n\}$ is mapped into $d$ dimensional word embedding sequence $x=\{x_1, x_2, \ldots, x_n\}$, where $x_i \in \mathcal{R}^{d}$. \subsection{Gated Recurrent Units}\label{GRU} \label{bi-gru} In this work, we use GRU\cite{cho2014properties} as the base learner. The GRU is an improved version of the recurrent neural network and being used as variant of the LSTM due to its simpler architecture over the LSTM. Similar to the other RNN, GRU has the capability of internal memory. This internal memory helps them to exhibit temporal dynamic behaviour for a time sequence. Additionally, GRU is able to solve the problem of the vanishing gradient problem which comes with a standard recurrent neural network. Similar to LSTM units, GRU also have the gating mechanism to control the flow of information and produce the effective hidden state representation. GRU has two neural gates, \textit{update} and \textit{reset} gate. The task of \textit{update} gate is to helps the model for determining the amount of information need to be carry forward along to the future. The \textit{reset} gate helps the model to determine the amount of past information need to be forget. Specifically, a GRU network successively reads the input token $x_{i}$, as well as the visible state $h_{i-1}$, and generates the new states $c_{i}$ and $h_{i}$. \begin{equation} \begin{split} {z}_{i}&=\sigma (\mathbf{W}^{z}x_{i}+\mathbf{V}^{z}{h}_{i-1} + \mathbf{b}^{z} ) \\ {r}_{i}&=\sigma (\mathbf{W}^{r}x_{i}+\mathbf{V}^{r}{h}_{i-1} + \mathbf{b}^{r} ) \\ {c}_{i} &=tanh (\mathbf{W}x_{i}+\mathbf{V} ({r}_{i} \odot {h}_{i-1}) + \mathbf{b})\\ {h_i}&=z_{i} \odot {c}_{i} + (1- {z}_{i}) \odot {h}_{i-1} \end{split} \end{equation} where ${z}$ and ${r}$ are the update and reset gates, respectively. The final representation at a given time $t$, from a bi-directional GRU (Bi-GRU), can be computed by concatenating the forward $\overrightarrow{h_t}$ and backward $\overleftarrow{h_t}$ hidden states. From here onward, we will call \texttt{Bi-GRU} as function having the inputs, $x_t$ and $h_{t-1}$ and output $h_t$. \subsection{Relation Extraction Framework} In the relation extraction framework \textbf{(c.f. Figure-1)} the input sequence $x=\{x_1, x_2, \ldots, x_n\}$ with the corresponding entity pair $(e_1, e_2)$ is transformed into the hidden state representation using the Bi-GRU (c.f. section \ref{bi-gru}). In order to emphasize the given entity pair, the corresponding entity word in the input sequence is marked with the special token $ENTITY$ and assigned a fixed word embedding to it. More formally, the hidden state at each time step is calculated as follows: \begin{equation} \label{stl-eq} h_t = \text{Bi-GRU}(x_t, h_{t-1}) \end{equation} Let the hidden state dimension for each Bi-GRU unit be $d_h$. We formulate a hidden state matrix $H \in \mathbb{R}^{n \times d_h}$. \begin{equation} H=\left( \mathbf{h_1}, \mathbf{h_2},\cdots \mathbf{h_n} \right) \end{equation} We compute the effective input sequence encoding $\bar{h}$ using function\footnote{This function is adversarial learning based self-attentive network which computes the effective input sequence encoding.} $fun(\bar{h}; \theta)$ with learning parameter $\theta$. The input sequence encoding $\bar{h}$ is fed to a fully connected softmax layer to generate the probability distribution over the predefined classes. \begin{equation} \label{softmax} \bar{y} = softmax(\bar{h}^T\mathbf{W}+\mathbf{z}) \end{equation} Here, $\mathbf{W}$ and $\mathbf{z}$ are weight matrix and bias vector, respectively. The term $\bar{y}$ denotes the predicted probability distribution. \indent Let us have a training dataset with $N$ samples such that $\{(x_1, y_1), (x_2, y_2), \ldots, (x_n, y_n)\}$. The network parameters are trained to minimize the loss function-- cross entropy of the probability distributions of predicted ($\bar{y}$) and true class ($y$) over the $C$ number of classes. \begin{equation} \label{singleLoss} \mathcal{L_{CE}}(\bar{y}, y)=-\sum_{i=1}^{n}\sum_{j=1}^{C}y_i^j log(\bar{y}_i^j) \end{equation} \subsubsection{Attentive Mechanism: }\label{attention-1} We encode the input sequence with by adopting the self-attentive mechanism\cite{lin2017structured} over the Bi-GRU generated hidden state sequence. The input to the attention mechanism is the Bi-GRU hidden states $H$. The self-attention generate the attention weight vector $v$ computed as follows: \begin{equation} \label{ca-attention} \begin{aligned} \mathbf{p} &= tanh \left({ U }H^T\right) \\ \mathbf{v} &= softmax \left( \mathbf{w} p \right) \end{aligned} \end{equation} Here $U \in \mathbb{R}^{d_a \times d_h}$, and $\mathbf{w} \in \mathbb{R}^{d_a}$ and $d_a$ is a hyperparameter and $d_h$ is the size of hidden state. The final hidden state representation $s$ is computed by the weighted (weight provided by $\mathbf{v}$) sum of the each time step of the Bi-GRU. The major drawbacks of the aforementioned representation is that it focuses on the specific component of the input sequence. The specific component could be a relation between a given entity to other words in the sequence. We call it is a aspect to represent the input sentence. In order to capture the multiple aspects, we required multiple $\mathbf{m}$'s that capture the various notion of the input sequence. Therefore, we extend the attention mechanism from focusing on single aspect to multiple aspects. Let us assume, we want to extract `$a$' number of multiple aspects from the input sequence. To achieve this, we extend the Eq \ref{ca-attention} as follows: \begin{equation} \label{cam-attention} \begin{aligned} \mathbf{p} &= tanh \left({ U }H^T\right) \\ \mathbf{V} &= softmax \left( \mathbf{W} p \right) \end{aligned} \end{equation} Here, $\mathbf{W} \in \mathbb{R}^{a \times d_a}$. Formally, We compute the `$a$' weighted sums by multiplying the matrix $V$ and LSTM hidden states $H$. We obtain a matrix representation $M$ of the input sequence by multiplying the attention weight matrix $V$ and hidden state representation $H$. \begin{equation} \label{attention-equation} M=VH \end{equation} We concatenate each row of the matrix representation to get the final vector representation of the input sequence. \subsection{Multi-task Learning for Relation Extraction}\label{shared-private} In this study, we introduce the novel method for biomedical relation extraction exploiting the adversarial learning in the multi-task deep learning framework. Our model leverages joint modeling of the entities and relations in a single model by exploiting attentive Bi-GRU based recurrent architecture. We propose an adversarial multi-task learning with attention (Ad-MTL) model for relation extraction task. Multi-task learning exploits the correlation present among similar tasks to improve classification by learning the common features of multiple tasks simultaneously. We build a latent feature space that holds the features that are common to various tasks. Specifically in the model, the outputs generated at each time-step of the shared Bi-GRU, are considered to be common latent features. We generate the task-specific feature features for each task by task-specific Bi-GRU network equipped with the self-attentive network discussed in section \ref{attention-1}. We compute the two hidden states at each time step $t$ for a given task $k$, one task-specific hidden state, $h_t^k$, and another shared hidden state, $s_t^k$. The former captures the task dependent features and the latter captures the task invariant features. Both the hidden state representations are computed similar to Eqn. \ref{stl-eq}. \begin{align} s_t^k &= \text{BI-GRU}(x_t^k,s_{t-1}^k, \theta_s) \\ h_t^k &= \text{BI-GRU}(x_t^k,h_{t-1}^k, \theta_h) \end{align} where $\theta_s$ and $\theta_h$ are Bi-GRU's parameters, $x_t^k$ denotes the input at time $t$. We generate the task-specific feature representation by applying self-attention using equation \ref{attention-equation}. We also use a feed-forward network with a hidden layer to project the attentive feature representation to another vector space. We call the final task-specific feature representation as of task $k$ as $TF_k$. Similar to the task-specific feature generation, we use a feed-forward network to project the the shared feature into another vector space and call it is a shared feature $SF$. The concatenation of the shared and task specific features is fed into a fully connected layer followed by the softmax layer. The softmax layer returns the class distributions, $y_{pred}^k$, for the underlying task, $k$. For every task, $k$, with training samples ($x_i^k$,$y_i^k$), both the task specific parameters and shared parameters are optimized to minimize the cross-entropy of the predicted ($\hat{y}_i^k$) and actual probability distributions ($y_i^k$), whose loss is computed as: \begin{equation} \label{shareCrossEnt} \mathcal{L}_{CE}^k = \mathcal{L}_{CE}(\hat{y}_i^k , y_i^k) \end{equation} \noindent where $ \mathcal{L}_{CE}(\hat{y},y)$ is defined as Eq. \eqref{singleLoss}. \subsubsection{Adversarial Training} The above discussed model though intended to separately host the shared and task-specific features, provides no guarantee to behave so, there might be contamination of shared features in the task-specific feature space and vice versa. To handle this, we exploited the principle that a good shared feature space has features that make it impossible to predict the source task of the feature. For achieving the above, a \texttt{Task Discriminator} $D$ is used to map the attention prioritized shared feature to estimate the task of its origin. In our case, \texttt{Task Discriminator} is a fully connected layer using a softmax layer to produce the probability distribution of the shared features belonging to any task. A Bi-GRU works as \texttt{Generator} $(G)$ to generate shared features. This Bi-GRU layer is made to work in an adversarial way, preventing the discriminator from predicting the task and hence preventing contamination in the shared space. The adversarial loss is used to train the model. Similar to \cite{goodfellow2014generative,liu-qiu-huang:2017:Long}, we use the following adversarial loss function \begin{equation} \label{advloss} \mathcal{L}_{adv}=\min_{G}\Big(\max_D \big( \sum_{t=1}^T\sum_{i=1}^{N_t} d_i^tlog\big[D\big(G(x^t))]\big)\Big) \end{equation} where $d_i^t$ is the gold label indicating the type of the current task. The min-max optimization problem is addressed by the gradient reversal layer \cite{ganin2014unsupervised}. The total loss of the network will be as follows: \begin{equation} \label{total-loss} \mathcal{L}_{total}=\alpha \sum_{k=1}^{K} \mathcal{L}_{CE}^{k} + \beta \mathcal{L}_{adv} \end{equation} where $\alpha$ and $\beta$ are the scalar parameters. \section{Experimental Results and Discussion} In this section, we will begin by briefly describing the various tasks and the datasets followed by the experimental results and analysis. In this study, we focus on the following tasks: \subsection{Protein Protein Interaction Extraction (PPI):}The goal of this task is to classify whether or not a sentence containing a proteins pair actually indicates interaction between the pair. Here, we considered the positive instances as the interacted protein-pair and the negative instances as the non-interacted protein pair. If the relationship between the protein pair is not explicitly provided, the pairs were considered to be the negative instances. In order to identify those instances, we extracted all possible proteins pairs from the sentences. \\ We utilize two standard benchmark datasets for PPI tasks, namely AiMed and BioInfer\footnote{http://corpora.informatik.hu-berlin.de/}. AiMed dataset is derived from the $197$ abstracts of the Database of Interacting Proteins (DIP) and contains manually tagged relationship between the protein entities. There are in total $5834$ relationship out of which $1000$ are interacting relation and $4834$ non-interacting relation. \\ BioInfer (Bio Information Extraction Resource) is another manually annotated PPI dataset developed by Turku BioNLP group\footnote{http://bionlp.utu.fi/} that contains over $1100$ sentences. It has $2534$ instances of protein interacting relationship and $7132$ non-interacting relationship. \subsection{Clinical Relation Extraction (MRE): }\label{ssec:cre} This task aims to extract the relation between the clinical entities (\textit{Problem, Treatment,and Test}) from the EMR. For this, we used the benchmark dataset released by i2b2 as a part of i2b2 2010 clinical information challenge \cite{uzuner20112010}. The dataset was collected from three different hospitals, which consists of discharge-summaries and progress notes of the patients those were manually annotated by the medical practitioners for identifying the three major relation types: medical problem–treatment (TrP) relations, medical problem–test (TeP) relations, and medical problem–medical problem (PP) relations. These relations were further fine-grained into $8$ different relation types which were: treatment caused medical problems (TrCP), treatment administered medical problem (TrAP), treatment worsen medical problem (TrWP), treatment improve or cure medical problem (TrIP), treatment was not administered because of medical problem (TrNAP), test reveal medical problem (TeRP), Test conducted to investigate medical problem (TeCP), and Medical problem indicates medical problems (PIP). The exact definition of each of these relation types can be found in \cite{uzuner20112010}. \footnote{While, the actual dataset released during the challenge was having $394$ documents for training and $477$ documents for testing. However, we were able to download only $170$ documents for training and $256$ documents for testing as also pointed out by \cite{sahu2016relation} from i2b2 website.}\\ It is to be noted that since we did not have enough training samples for all relation classes present in the dataset, we have removed following three classes: TrWP, TrIP, and TrNAP. this same strategy was also followed by the \cite{sahu2016relation}. \subsection{Drug Drug Interaction Extraction (DDI):} \label{ssec:ddi} Given a sentence with two pharmacological substances, this task aims to classify if the given drug pair interacts with each other or not. For this task, we utilize the standard benchmark DDI corpus from Semeval 2013 DDIExtraction challenge dataset \cite{segura2013semeval}. The DDIExtraction 2013 task exploits the DDI corpus, which contains MedLine abstracts on drug-drug interactions as well as documents describing drug-drug interactions from the DrugBank database. The corpus consists of total 1,017 abstracts from Medline (233) and DrugBank (784) databases which were manually annotated to obtain 18,491 pharmacological substances and 5,021 drug-drug interactions. Here each interacted drug pair is further classified into one of four types, namely mechanism, advice, effect, and int. It is to be noted that during the challenge, original dataset has 23756 false samples for training and 4737 for testing. But when we obtained the data set from shared task organizers, there were only 22474 false training instances and 4461 testing sample for false class. In the Table-\ref{ddi2013}, we have provided the statistics of the DDI dataset. \begin{figure*}[t] \centering \includegraphics[width=10cm,height=8cm]{TCBB-Baseline-2.pdf} \label{figure-baseline} \caption{Baseline models for various biomedical relation extraction tasks.} \end{figure*} The detailed statistics of all the three datasets are reported in the Table-\ref{binary datasets},\ref{i2b2relxtr},\ref{ddi2013} \begin{table}[h] \centering \begin{tabular}{ccccc} \hline Dataset & Interacting Pairs & Non-interacting pairs \\ \hline \\ AiMed PPI &1000 & 4834 \\ BinInfer PPI & 2534 & 7132 \\ \hline \end{tabular} \caption{Statistics: AiMed and BioInfer Dataset} \label{binary datasets} \end{table} \begin{table}[h] \centering \begin{tabular}{ccc} \hline Label & Relation & No.of Samples\\ \hline 0 & TrIP &203 \\ 1 & TeRP & 3053 \\ 2 & TrAP& 2617 \\ 3 & PIP & 2203 \\ 4 & TeCP & 504 \\ 5 & TrCP & 526 \\ 6 & TrNAP & 174 \\ 7 & TrWP & 133 \\ 8 & NONE & 54530\\ \hline \end{tabular} \caption{Statistics: 2010 i2b2/VA NLP Challenge dataset} \label{i2b2relxtr} \end{table} \begin{table}[h] \centering \begin{tabular}{cccc} \hline Label & Relation & No.of Samples (Train) & No.of Samples (Test) \\ \hline 0 & False &22474 & 4461 \\ 1 & effect & 1685 &360 \\ 2 & mechanism & 1316 &302 \\ 3 & advice & 826 &221 \\ 4 & int & 188 &96 \\ \hline \end{tabular} \caption{Statistics: Semeval 2013 DDIExtraction challenge dataset} \label{ddi2013} \end{table} \begin{table*}[] \centering \resizebox{\textwidth}{!}{% \begin{tabular}{l|c|c|c|c|c|c|c|c|c|c|c|c} \hline \multirow{2}{*}{\textbf{Tasks}} & \multicolumn{3}{c|}{\textbf{Baseline 1}} & \multicolumn{3}{c|}{\textbf{Baseline 2}} & \multicolumn{3}{c|}{\textbf{Baseline 3}} & \multicolumn{3}{l}{\textbf{Proposed Approach (MTL)}} \\ \cline{2-13} & P & R & F & P & R & F & P & R & F & P & R & F \\ \hline \textbf{PPI-AiMED} & 69.61 & 71.16 & 70.37 & 67.75 & 69.65 & 68.69 & 75.85 & 72.74 & 74.27 &78.12 & 76.56 & \textbf{77.33 } \\ \hline \textbf{PPI-BioInfer} & 71.29 &70.95 &71.12 & 68.47 & 69.03 & 68.75 & 75.44 & 73.79 & 74.61 & 76.69 & 75.98 &\textbf{ 76.33 } \\ \hline \textbf{DDI} & 71.99 & 67.26 & 67.46 & 70.24 & 65.15 & 67.60 & 75.82 & 64.50 & 69.71 & 76.52 & 69.01 & \textbf{72.57} \\ \hline \textbf{i2b2-2010 Clinical relation} & 81.72 & 78.52 & 80.09 & 82.28 & 78.96 & 80.59 & 81.06 & 80.36 & 80.71 & 81.92 & 81.37 &\textbf{ 81.65} \\ \hline \end{tabular} } \caption{Evaluation results of proposed MTL model and baselines system. Performance is reported in terms of `P': Precision, `R': Recall, and `F': macro-F1-Score. Baseline 1 is single task learning model based on Bi-GRU. Baseline 2 is STL model with Bi-GRU + word-level attention. Baseline 3 is MTL model with a shared Bi-GRU layer. All the results are statistically significant as \textit{p-value} $<$ $0.05$). } \label{tab:eval-proposed} \end{table*} \begin{table}[h] \begin{tabular}{cc} \hline Hyper-parameters & \thead{Value} \\ \hline \\ Max sentence length & 60 \\ Embedding dimension & 200 \\ GRU Hidden State Dimension & 64 \\ Attention Size ($d_z$) & 350 \\ Attention aspect Size ($a$) & 5 \\ \# of hidden neuron in Feed-forward n/w & 100 \\ Activation & \textit{relu} \\ Dropout rate & 0.3 \\ Output Activation & Soft-max \\ Optimizer & Adam Optimizer \\ Learning Rate & 0.001 \\ $\alpha$ & 1 \\ $\beta $ & 0.05 \\ \hline \end{tabular} \caption{Optimal hyper-paramete values on proposed model} \label{hyperparams} \end{table} \section{Network Training and Hyper-parameters Setting} We train the network by minimizing the total loss of the network (Eq. \ref{total-loss}). In adversarial training, first we pre-trained the discriminator to avoid the instability in the network. To pre-train the discriminator, we use a Bi-GRU network to get the representation of the sentences from the different tasks. We have shown the training process in Algorithm \ref{algo:mt}. The shared feature extractor model $S$ in Algorithm \ref{algo:mt} is a Bi-GRU network followed by self-attention layer and it is being exploited by all the tasks (c.f. Section \ref{shared-private}). In the shared feature extractor, there is an additional adversarial learning component, where feature extractor (Generator) operates adversarially towards a learnable multi-layer perceptron (Discriminator), preventing it from making an accurate prediction about the types of the task the features generated from. For generating the word embedding, we have used pre-trained embedding available at \footnote{http://evexdb.org/pmresources/vec-space-models/}. \begin{table*}[] \resizebox{\textwidth}{!}{% \begin{tabular}{c|ccc|ccc|ccc|ccc} \hline \multirow{2}{*}{\textbf{Model}} & \multicolumn{3}{c|}{\textbf{AiMED}} & \multicolumn{3}{c|}{\textbf{BioInfer}} & \multicolumn{3}{c|}{\textbf{DDI}} & \multicolumn{3}{c}{\textbf{i2b2-RE}} \\ \cline{2-13} & P & R & F1 & P & R & F1 & P & R & F1 & P & R & F1\\ \hline \textbf{\begin{tabular}[c]{@{}c@{}}Proposed Model\\ Multi-task adversarial learning + GRU + self attention\end{tabular}} & 75.06 & 75.10 & 75.08 & 76.15 & 75.05 & 75.59 & 76.99 & 68.09 & 72.27 & 82.16 & 80.79 & 81.47 \\ \hline \textbf{-self attention} & 71.13 & 71.63 & 71.05 & 73.63 & 72.21 & 72.66 & 75.09 & 64.98 & 68.53 & 79.69 & 80.49 & 79.90 \\ \hline \textbf{-adversarial learning} &76.55 &74.10 &75.30 &75.92 &75.34 &75.63 &77.32 &68.28 &72.52 &81.65 &81.06 &81.35 \\ \hline \end{tabular}% } \caption{Ablation study by jointly training all the four dataset together.} \label{ablation} \end{table*} \begin{table*}[] \resizebox{\textwidth}{!}{% \begin{tabular}{c|ccc|ccc|ccc|ccc} \hline \multirow{2}{*}{\textbf{Model}} & \multicolumn{3}{c|}{\textbf{AiMED}} & \multicolumn{3}{c|}{\textbf{BioInfer}} & \multicolumn{3}{c|}{\textbf{DDI}} & \multicolumn{3}{c}{\textbf{i2b2-RE}} \\ \cline{2-13} & P & R & F1 & P & R & F1 & P & R & F1 & P & R & F1\\ \hline \textbf{\begin{tabular}[c]{@{}c@{}}Proposed Model\\ Multi-task adversarial learning + GRU + self attention\end{tabular}} & 78.12 & 76.56 & 77.33 & 76.69 & 75.98 & 76.33 & 76.52 & 69.01 & 72.57 & 81.92 & 81.37 & 81.65 \\ \hline \textbf{-self attention} & 72.96 & 73.21 & 73.09 & 74.91 & 73.98 & 74.44 & 75.34 & 64.92 & 69.74 & 80.74 & 79.16 & 79.94 \\ \hline \textbf{-adversarial learning} &78.26 &75.43 &76.82 &76.57 &75.72 &76.14 &77.92 &67.31 &72.23 &83.68 &81.02 &82.33 \\ \hline \end{tabular}% } \caption{Ablation study by training two similar dataset (AiMed + BioInfer) and (DDI+i2b2-RE) at a time.} \label{ablation-1} \end{table*} \begin{table*}[] \centering \resizebox{\textwidth}{!}{% \begin{tabular}{llcccccc} \hline \multirow{2}{*}{\textbf{System}} & \multicolumn{1}{c}{\multirow{2}{*}{\textbf{Technique}}} & \multicolumn{3}{c}{\textbf{AiMED}} & \multicolumn{3}{c}{\textbf{BioInfer}} \\ \cline{3-8} & \multicolumn{1}{c}{} & \textbf{P} & \textbf{R} & \textbf{F} & \textbf{P} & \textbf{R} & \textbf{F} \\ \hline \textbf{Our System} & \textbf{MTL-Adversarial (Bi-GRU+ self-attention)} & \textbf{78.12} & \textbf{76.56} & \textbf{77.33} & \textbf{76.69} & \textbf{75.98} & \textbf{76.33}\\ \hline \cite{hsieh2017identifying}$^{*}$ & LSTM$_{pre}^{*}$ & 73.12 & 73.02 & 73.07 & 73.81 & 72.69 & 73.24 \\ \cite{hua2016shortest} & sdpCNN (SDP+CNN) & 64.80 & 67.80 & 66.00 & 73.40 & 77.00 & 75.20 \\ \cite{qian2012tree} & Single kernel+ Multiple Parser+SVM & 59.10 & 57.60 & 58.10 & 63.61 & 61.24 & 62.40 \\ \cite{peng2017deep} & \begin{tabular}[c]{@{}l@{}}McDepCNN \end{tabular} & 67.3 & 60.1 & 63.5 & 62.7 & 68.2 & 65.3 \\ \cite{zhao2016protein} & \begin{tabular}[c]{@{}l@{}}Deep neural network\end{tabular} & 51.5 & 63.4 & 56.1 & 53.9 & 72.9 & 61.6 \\ \hline \end{tabular}% } \caption{Comparison with the SOTA techniques for PPI task on AiMed and BioInfer datasets. Performance is reported in terms of `P': Precision, `R': Recall, and `F': F1-Score (macro). \cite{hsieh2017identifying}$^{*}$ denotes the re-implementation of the systems proposed in [32] with the authors reported experimental setups using their publicly available source codes.} \label{results} \end{table*} \subsection{Evaluation Criteria} We evaluate the performance of all our models using macro-averaged precision, macro-averaged recall and macro-averaged F1-Score metrics. Due to the unavailability of separate validation set for AiMED, BioInfer, and i2b2-2010 clinical relation task datasets, we adopt $10$-fold document cross-validation strategy to compute the precision, recall, and F1-score values. We consider the predicted class-label as the correct only if it has the exact match with the ground truth annotation. For the DDI task, we report the performance of the models on the test set. \begin{algorithm}[ht!] \SetAlgoLined Set the max number of epoch: $epoch_{max}$.\\ \For{$t$ in $\{ t_1, t_2, \ldots, t_K \}$ } { \textbf{1.} Pack the dataset $t$ into mini-batch: $D_t$.\\ \textbf{2.} Define task-specific feature extractor model $M_t$ \\ \textbf{3.} Initialize model parameters $\Theta_t$ randomly. \\ } Define shared feature extractor model $S$ and initialize their parameters $\Theta_s$ randomly.\\ Define the discriminator model $D$ and initialize their parameters $\Theta_d$ randomly.\\ Pre-train the discriminator. \\ \For{$epoch$ in $1,2,...,epoch_{max}$}{ \For{$t$ in $\{ t_1, t_2, \ldots, t_K \}$ }{ \For{$batch$ in $D_t$}{ \textbf{1.} TF $\leftarrow$ Generate the task-specific feature for \textit{batch} using model $M_t$\\ \textbf{2.} SF $\leftarrow$ Generate the shared feature for \textit{batch} using model $S$\\ \textbf{3.} $\bar{h}= TF \oplus SF$\\ \textbf{4.} Compute task-specific loss : $\mathcal{L}_{CE}^{t}$ \\ \quad \textit{// using Eq.(6)}\\ \textbf{5.} Compute adversarial loss : $\mathcal{L}_{adv}$ \\ \quad \textit{// using Eq.(13)}\\ \textbf{6.} Update the parameters: \begin{equation} \nonumber \begin{aligned} \Theta_t & = \Theta_t - \eta \frac{\partial \mathcal{L}_{CE}^{t}}{\partial \Theta_t} \\ \quad \Theta_d & = \Theta_d - \eta \frac{\partial \mathcal{L}_{adv}}{\partial \Theta_d} \\ \quad \Theta_s & = \Theta_s - \eta \big( \frac{\partial \mathcal{L}_{CE}}{\partial \Theta_s} - \frac{\partial \mathcal{L}_{adv}}{\partial \Theta_s}\big) \end{aligned} \end{equation} } } } \caption{\label{algo:mt} Training Process} \end{algorithm} \subsection{Results and Analysis} Inspired by the recent success of the deep learning based frameworks in solving the relation extraction task, we develop three strong baselines based on STL and MTL frameworks for the purpose of comparison. Figure-2 provides the architecture for the below described baseline model. \begin{itemize} \item \textbf{Baseline 1:} The first baseline is a STL model constructed by training a Bi-GRU on the features obtained from the embedding layer to capture the long-term dependencies as defined in Subsection-\ref{material_methods}. In our experiment, we build the individual model for each dataset.\\ \item \textbf{Baseline 2:} This single-task learning (STL) model is an advanced version of Baseline 1, where the sentence encoder of this model is also equipped with the word-level attention\cite{yang2016hierarchical}. \item \textbf{Baseline 3:} It is a multi-task model with the shared Bi-GRU followed by word-level attention that acts as a shared feature extractor for all the tasks. \end{itemize} \begin{table*}[h] \centering \begin{tabular}{l|l|l|l|l} \hline \textbf{System} & \textbf{Technique} & \textbf{P} & \textbf{R} & \textbf{F} \\ \hline \hline \textbf{Our System} & \textbf{Multi-task adversarial learning + GRU+attention} & \textbf{76.52} & \textbf{69.01} & \textbf{72.57} \\ \hline Joint AB-LSTM$^{*}$ \cite{sahu2017drug} & Bi-directional LSTM +attention & 71.84 & 66.88 & 68.99 \\ \hline Yi et al.$^{+}$\cite{yi2017drug} & RNN+dynamic WE+ multi-attention & 73.67 & 70.79 & 72.20 \\ \hline Joint AB-LSTM$^{+}$ \cite{sahu2017drug} & Bi-directional LSTM +attention & 73.41 & 69.66 & 71.48 \\ \hline DCNN$^{+}$ \cite{liu2016dependency} & Dependency based CNN & 77.21 & 64.35 & 70.19 \\ \hline Liu et al.$^{+}$ \cite{liu2016drug} & CNN & 75.72 & 64.66 & 69.75 \\ \hline SCNN$^{+}$ \cite{zhao2016drug} & Two stage syntax CNN & 72.5 & 65.1 & 68.6 \\ \hline \end{tabular} \caption{Comparison with the SOTA techniques for DDI task. Performance is reported in terms of `P': Precision, `R': Recall, and `F': F1-Score (macro). $^{*}$ denotes the re-implementations of the systems proposed in [32] with the authors' reported experimental setups using their publicly available source code. $^{+}$ denotes that the reported results may not be directly comparable with our proposed system because of the difference in dataset statistics.} \label{Comp-DDI} \end{table*} The results obtained by our proposed model and the baseline systems for each tasks is reported in Table-\ref{tab:eval-proposed}. The results obtained demonstrate the efficiency of our proposed MTL framework over other models that explore state-of-the-art techniques based on a single task and multi-task neural network. For AiMed dataset, our proposed MTL model outperformed the Baseline $1$ and Baseline $2$ model by $6.96$ and $8.64$ F1-Score points, respectively. Similar trend was also followed for the BioInfer dataset where, we observe the performance improvements of $5.21$ and $7.58$ F1-Score points over Baseline $1$ and Baseline $2$, respectively, by the proposed approach. For DDI dataset, our proposed method attains improvements of $5.11$ and $4.97$ F1-Score points over Baseline $1$ and Baseline $2$, respectively. Lastly, for the i2b2-2010 clinical relation extraction dataset, the proposed method demonstrates the performance improvements of $1.56$ and $1.06$ F1-Score points over Baseline $1$ and Baseline $2$, respectively.\\ We observe that our model outperforms Baseline 3 model, with $3.06$, $1.72$, $2.86$, and $0.94$ F-Score points on AiMED, BioInfer, DDI, and i2b2-2010 clinical relation extraction dataset respectively.\\ Overall, the findings achieved show that using self attention based adversarial multi-task learning to save the present knowledge in a shared layer is helpful for a new task.\\ \textbf{Ablation Study:} To analyze the impact of various component of our model, we perform the ablation study by removing one component from the proposed model and evaluate the performance on all the four tasks. We carried of two set of ablation study: (1) jointly training all the four dataset together (c.f. Table-\ref{ablation}), and (2) training two similar task dataset i.e. AiMed and BioInfer together (since both share characteristics of having protein-interaction information ), DDI and i2b2-RE task together (c.f. Table-\ref{ablation-1}). One possible reason for the i2b2-RE dataset to not be benefited from adversarial learning component is firstly because it is jointly trained with DDI corpus whose origins (clinical notes vs biomedical literature) and characteristics are not very similar to the i2b2-RE dataset in contrary to AiMED and Bionfer that are both protein-interacting datasets. Another reason is the huge difference between the samples in DDI ($5550$) and i2b2-RE ($62254$). In this case when the batches of the DDI dataset finish arriving, model will train only with the i2b2-RE dataset and could lead to the diminishing effect of the adversarial training.\\ Experimental results shows that removing self attention leads to the decrements in the performance of the model across all the task, in both the ablation study scenarios. However, we observe that adversarial learning was not that much effective in the ablation study 1, where we jointly trained all the four dataset together. While for the ablation study 2, when we trained similar task together, there was a drop in the performance across all the dataset. This shows that, adversarial learning is much helpful in the related task where the data distribution is similar. \subsection{Comparative Analysis} In this section, we will conduct the comparative analysis of our proposed method with the state-of-the-art (SOTA) model for all the three tasks. \begin{itemize} \item \textbf{Protein-Protein Interaction:} We used the SOTA methods for both datasets as presented in Table-\ref{results} to compare our proposed model. The results show that the proposed model significantly outperforms the SOTA systems. From this we can conclude that our proposed multi-task model is more potent in extracting interacted protein pairs over the architecture based on CNN established in \cite{hua2016shortest} and LSTM framework \cite{hsieh2017identifying}. Our adversarial MTL model achieves a significant $4.26$ F-score point increment over the LSTM based model \cite{hsieh2017identifying} on AiMed dataset. In case of BioInfer dataset, our proposed model was able to achieve significant performance improvement of $3.09$ F-Score point over \cite{hsieh2017identifying} as shown in Table-\ref{results}. However, in comparison to \cite{hua2016shortest}, we could observe the improvement of $1.13$ F-Score points over the proposed model. This clearly demonstrates the effect of neural self-attention based adversarial learning in multi-task setting. \item \textbf{Drug-Drug Interaction} We compare our proposed model with SOTA DDI extraction techniques as shown in Table-\ref{Comp-DDI}. Since, there was a difference in the dataset statistics, we re-implemented the system proposed by \cite{sahu2017drug} using their publicly available source code on our DDI extraction dataset. Our multi-task adversarial Att-LSTM model obtains the significant performance improvement of $3.58$ F-Score points over the state-of-the-art system \cite{sahu2017drug} that exploited Bi-LSTM with attention mechanism. Also, the obtained experimental results illustrate that the model for the DDI task is benefited from other similar tasks, more specifically from the PPI tasks. It is because of the high semantic similarity between the sentences in DDI and PPI tasks. \item \textbf{Medical Concept Relation} We were unable to make direct comparison of our proposed approach with the systems participated in i2b2-2010 shared task due to the incomplete dataset. We compare our model with \cite{sahu2016relation}, as they also experimented with the same dataset. The results are reeported in Table \ref{i2b2-comp},. We obtain the performance improvements of $12.51$, $9.91$, $5.04$, $11.39$, and $5.65$ F-Score points over \cite{sahu2016relation} (irrespective of the use of additional linguistic features) for TeCP, TrCP, PIP, TrAP, and TeRP classes, respectively. This shows the usefulness of self attention based adversarial learning in multi-task setup which eventually gathers the complimentary features for medical concepts relations and other related tasks and improves the performance of the system. \end{itemize} \begin{table}[!h] \centering \begin{tabular}{l|l|l|l|l} \hline \textbf{System} & \textbf{Sahu et al. \cite{sahu2016relation}} & \multicolumn{3}{l}{\textbf{Proposed Approach}} \\ \hline \textbf{Relation-types} & \textbf{F} & \textbf{P} & \textbf{R} & \textbf{F} \\ \hline \textbf{TeCP} & 50.56 & 62.89 & 63.43 & \textbf{63.07} \\ \hline \textbf{TrCP} & 56.44 & 68.44 &64.52 & \textbf{66.35} \\ \hline \textbf{PIP} & 64.92 & 73.20 & 67.17 & \textbf{69.96} \\ \hline \textbf{TrAP} & 69.23 & 79.10 & 82.28 & \textbf{80.62} \\ \hline \textbf{TeRP} & 81.25 & 87.31 & 86.56 & \textbf{86.90} \\ \hline \end{tabular} \caption{Comparison with the SOTA techniques for i2b2-2010 clinical relation extraction task. For the fair comparison, we have reported the weighted F-Score.} \label{i2b2-comp} \end{table} \begin{figure*}[t!] \centering \begin{subfigure}[t]{0.32\textwidth} \includegraphics[height=1.5in, width=\textwidth]{aimed-weighted-6-pr.png} \caption{PR curve for AiMed} \end{subfigure} \begin{subfigure}[t]{0.32\textwidth} \includegraphics[height=1.5in, width=\textwidth]{bioinfer-macro-1-pr.png} \caption{PR curve for BioInfer} \end{subfigure} \caption{The graphs \textbf{(a)} and \textbf{(b)} demonstrate the Precision-Recall curves for the binary classification dataset, AiMed and BioInfer.} \label{learning-curve} \end{figure*} \begin{figure*}[h] \centering \includegraphics[width=\linewidth, height=3cm]{examples-attention.eps} \caption{Heatmap of the attention weight distributions on the examples of different datasets. The intensity of the colour is increased with the increment in the attention weight.} \label{atten-visual} \end{figure*} \subsection{Error Analysis} Here, we closely examine the various forms of errors with respect to the tasks that cause the mis-classification. \begin{enumerate} \item \textbf{PPI:} In case of the AiMED and BioInfer datasets, we observe that in a sentence with multiple protein mentions, our proposed model fails to identify properly the interacted pair. For example:\\ \textbf{Sentence 1: }``\textit{We screened proteins for interaction with PROTEIN and cloned the full-length cDNA of human PROTEIN which encoded 1225 amino acids.}"\\ Here, the actual label was true but our model predicted this as false. Repetitive mentions of proteins behave like a noise, than can inhibit the model to extract contextually relevant information. We also made an interesting observation that in the presence of the protein interacting words (such as `\textit{bind}', `\textit{interact}'), our model predicts the class label as `\textit{interacting}' (true). For example:\\ \textbf{Sentence 1: }``\textit{PROTEIN binding significantly increased hetero- and homo-oligomerization (except for the BR-II homo-oligomer, which binds ligand poorly in the absence of PROTEIN}"\\ \textbf{Sentence 2: }``\textit{PROTEIN is a muscle-specific HLH protein that binds DNA in vitro as a heterodimer with several widely expressed HLH proteins, such as the PROTEIN gene products E12 and E47.}"\\ This is because these words often occur in the vicinity of the interacting protein mentions. \\ \item \textbf{DDI:} Apart from the highly imbalance dataset issue, our model fails to capture the exact relationship between the DDI pairs, where the lengths of the sentences were long. Another phenomenon that we observed as a source of mis-classification was that the ``\textit{Int}'' type was often predicted as ``\textit{Effect}'' class type. ``\textit{Int}'' class describes the coarse classification, i.e., there exists interaction between two drugs. This implies that there could be a positive or negative outcome which forms the main cause of the system often getting confused between the ``\textit{Int}'' and ``\textit{Effect}'' class labels. For example:\\ \textbf{Sentence 1: }``\textit{Synergistic interaction between DRUGA and DRUGB is sequence dependent in human non small lung cancer with EGFR TKIs resistant mutation.}" \\ We also found that some labels were incorrectly predicted because of class-specific keywords which exist in the sentence but are not related to the concerned entity pair. For example:\\ \textbf{Sentence 1: }``\textit{Interaction study of DRUGA and DRUGB with co administered drugs .}"\\ \textbf{Sentence 2: }``\textit{If in certain cases , an DRUGA is considered necessary , it may be advisable to replace tamoxifen with DRUGB.}"\\ In sentence 1, the model got confused between the class label `Int' and `None', while in the sentence 2, our model incorrectly predicted the class label as `Advice'.\\ \item \textbf{Medical Concept Relation:} We observe that due to close similarity between the class label `\textit{TeRP}' and `\textit{TeCP}', our model was found to be confused between these classes. For example:\\ \textbf{Sentence 1: }``\textit{TEST x-ray revealed no PROBLEM , no congestive heart failure.}"\\ In the given sentence, our model incorrectly predicted it as class `\textit{TeRP}'.\\ We also observed that majority of the misclassification was between `\textit{PIP}' and `\textit{NONE}' class. For example:\\ \textbf{Sentence 1: }``\textit{There was PROBLEM atrophy and PROBLEM encephalomalacia.}" \end{enumerate} \subsection{Visual Analysis:} We have carried out the visual analysis (in Figure \ref{atten-visual}) to get an intuitive understanding of attention weights in multi-task attention model. Each sentence in the figure shows the attention distribution in the form of heatmap for an instance of the corresponding dataset. The highlighted colours indicate the most relevant words in the sentence selected by the attention mechanism. For example in the sentence, ``\textit{co-association of cd26 protein with the protein on the surface of human t lymphocytes}", the model is able to provide more weights to ``\textit{co-association of cd26 protein}", which is relevant to correctly classify the given protein pair as interacted pair. For the binary classification datasets, AiMed and BioInfer, we also plot the Precision-Recall curve (c.f. Figure-\ref{learning-curve}). \section{Conclusion} In this paper, we propose a unified multi-task learning approach that exploits the capabilities of adversarial learning approach for relation extraction from biomedical domain. We first experimented on three benchmark biomedical relation extraction tasks, i.e., protein-protein interaction, drug-drug interaction, and clinical relation extraction. For that, we utilized four popular datasets: AIMed, BioInfer, SemEval 2013 DDI shared task dataset and i2b2-2010 clinical relation dataset. We demonstrated that our model shows superior performance compared to state-of-the-art models for all the tasks. \\ Although our model has shown significant improvements over state-of-the-art methods on all the tasks, it was observed that our supervised model does not generalize well for the class label with the small instances. In future, we would like to develop a zero-shot learning method that could assist the model in the huge class imbalance issue. {\bf Acknowledgement}: Dr. Sriparna Saha gratefully acknowledges the Young Faculty Research Fellowship (YFRF) Award, supported by Visvesvaraya Ph.D. Scheme for Electronics and IT, Ministry of Electronics and Information Technology (MeitY), Government of India, being implemented by Digital India Corporation (formerly Media Lab Asia) for carrying out this research. \bibliographystyle{IEEEtran}
{'timestamp': '2020-09-22T02:19:41', 'yymm': '2009', 'arxiv_id': '2009.09509', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09509'}
arxiv
\section{Introduction} \label{sec:intro} Data anomalies are very common in real world datasets. Some anomalies are generated by errors made in data recording, which occurs often in transactional data in E-commerce. Others could imply fraudulent information on the web which has an adverse impact on people's trust on web applications. Anomalies can sometimes be the indicators of potential risks such as fraudulent transactions in credit card processing \citep{hodge2004survey, domingues2018comparative}, and identifying those would make the digital world a safer and more trustworthy place. In machine learning (ML), anomalies are observations that are distinct from the majority of the data population and are typically generated by sufficiently different generating processes. Machine learning models are often used to detect anomalies by profiling the normal data distribution or data generating processes. To build a trusted ML application, anomaly or outlier detection becomes a key component of the data preparation pipeline. For example, in home-buying, automated home-valuation systems such as the Zestimate\textregistered \cite{zestimate} as shown in \cref{fig:zestimate_example} empower people with information that has fundamentally transformed the real-estate industry. In order to support the biggest transaction in a customer's life with trusted information, it is important to have an unbiased and reliable ML system for predicting home value. The reliability of the transaction data influences the accuracy of such ML system. One approach to identify anomalies is through supervised learning, which would require tremendous efforts of human labeling for any industrial scale databases. It is also not feasible when applications require diverse sources of data that often come in disparate formats. Therefore, Unsupervised techniques are the preferred solution in such scenarios. Moreover, real-world datasets often have high dimensionality and mixed feature types (numerical and categorical), which imposes a challenging task for anomaly detection. For example, US real estate transactional data has non-homogeneous sources for different markets with variable definitions for anomalies. Most of the sources have humans in the loop, and errors such as mistyping the number of zeros or transposing the order of the digits are quite common. Such mistakes not only influence the performance of the ML models, but also cause long lasting real-life impact \citep{desertnews2019}. Anomaly detection techniques play an important role in supporting our decision making with trusted information in the era of big data. \begin{figure}[t] \begin{center} \includegraphics[width=0.8\textwidth]{zestimate_example_small.eps} \caption{Example of Zestimate\textregistered} \label{fig:zestimate_example} \end{center} \end{figure} In this paper, we propose a novel anomaly detection method, that we call Out-of-Bag (OOB) anomaly detection. The proposed method first converts the unsupervised problem into a set of supervised problems, where an ensemble model is trained to model each feature. Next, the method utilizes the OOB predictions of ensemble models to derive important statistics for detecting anomalous data points. More specifically, we developed two important measures for scoring anomalies: an uncertainty-based measure and a disagreement-based measure. Both measures can be combined into an effective anomaly score to identify various types of anomalous data. The OOB anomaly detection method demonstrates the state-of-art performance as demonstrated via an extensive set of experiments on benchmark datasets. In addition, we show that our method significantly improves the accuracy and reliability of the ML model by removing the detected anomalies from our in-house home valuation dataset. The remainder of this paper is structured as follows. After discussing related work in \cref{sec:related}, we present the details of the OOB anomaly detection method in \cref{sec:method}. In \cref{sec:results}, we first show that the proposed method demonstrates the state-of-the-art performance of anomaly detection compared to other competing methods through an extensive set of experiments on benchmark datasets. In addition, it is shown a more effective pre-processing approach to filter out anomalous training data in an in-house ML home valuation application. Finally, we conclude the paper in \cref{sec:conclusion}. \section{Related Work} \label{sec:related} Anomaly detection previouslt has been addressed by several different approaches. The existing techniques roughly fall under 4 categories: (1) distance-based methods, (2) reconstruction based methods, (3) probability-based methods and (4) model-based methods. Distance-based methods use the proximity relationship to other data points to identify anomalous data points. For example, \citep{ramaswamy2000efficient} uses the distance to the k-nearest neighbor as the anomaly score. However, distance-based methods often suffer from the “curse of dimensionality”, as distance between data points in high dimensional space becomes similar. Angle-Based Outlier Detection (ABOD) \citep{kriegel2008angle} is proposed to mitigate the effect of high dimensionality by considering a outlier factor measured by variance of the angles to other data points. Clustering techniques have also been used to detect anomalies as a side effect of cluster discovery in the data. Cluster-Based Local Outlier Factor (CBLOF) \citep{he2003discovering} considers the distance to other data as well as the the size of the clusters in computing anomaly scores. Reconstruction-based methods learn the principle factors in the data and a reconstruction function to reconstruct the data from these principle factors. In this process, anomalous data points can be identified by high reconstruction error. Principal Component Analysis (PCA)-based methods \citep{shyu2006principal} are able to learn the linear relationship between features, while Autoencoder (AE)-based methods \citep{kramer1991nonlinear, kingma2013auto} can handle the non-linear interactions in the data more efficiently. Probability-based approaches fit the normal data by a probability distribution. The distribution can be estimated by parametric models such as Gaussian Mixture Models (GMMs) \citep{dempster1977maximum} or non-parametric models such as the feature histograms used in Histogram-based Outlier Score (HBOS) \citep{goldstein2012histogram}. Anomalies are identified based on the likelihood of occurrence in the estimated distribution which profiles the normal data. Moreover, some Variational Autoencoder (VAE)-based methods \citep{an2015variational, zimmerer2018context} combine probability- with reconstruction-based techniques in scoring anomalies. Model-based methods cover a broad spectrum of methods. In general, models are taught to profile the normal pattern and feature relationship in the data. They often involve a conversion from the original unsupervised setting into a supervised setting so that supervised techniques can be applied. For example, One-Class Support Vector Machine (OC-SVM) \citep{scholkopf2000support} finds a decision boundary that maximizes the distance between data points to the origin in the feature space to differentiate anomalies from the normal data. Isolation Forest (IF) \citep{isolation_forest}, another model-based method, utilizes an ensemble of random trees which partition on random features and values to isolate the anomalies. Anomalies can be identified by a shorter average path length as their infrequent feature values require fewer splits to isolate. As a tree-based method, IF also benefits from the advantage of handling high-dimensional data. An important concept which we use in the proposed approach is Out-of-Bag Models. First introduced by Breiaman \citep{breimanOOB}, bootstrap aggregation of training data in ensemble methods \citep{breimanBagging} results in approximately 33 percent of learners not using specific data point for training. The Out-of-Bag (OOB) models have been used to estimate the generalization error of Random Forest ensemble models \citep{tibshirani1996bias, wolpert1999efficient}. Empirical evidence demonstrates that the OOB estimate of generalized error is accurate and unbiased \citep{breiman2001random}. In our method, we utilize OOB estimates to derive the measure for anomalies. \section{Method} \label{sec:method} In this paper, we propose a novel anomaly detection method which solves the challenging unsupervised problem from a supervised perspective. At a high level, we train a set of ensemble models, and each model is targeted to predict one feature column given the remaining features. The concept of OOB predictions in ensemble models is employed in developing the score for measuring the degree of anomaly. We discuss how we can handle both categorical and numerical features under the proposed framework, and extensively elaborate the intuition behind the proposed method. The notations for the proposed method are summarized in \cref{tab:notations}, and \cref{alg:algorithm} summarizes the proposed method. \subsection{Methodology Overview} \label{sec:method_details} \begin{table}[h!] \begin{center} \caption{Summary of notations} \label{tab:notations} \begin{tabular}{c|c} \textbf{Symbol} & \textbf{ Meaning} \\ \hline $N$ & number of data points \\ $K$ & number of features \\ $T$ & number of models in each ensemble \\ $x_i^k$& the $k$-th feature value of the $i$-th data point\\ $\bold{x}_i = (x_i^1, x_i^2, \ldots, x_i^K)$ & the $i$-th data point (row) \\ $\bold{x}^k = (x_1^k, x_2^k, \ldots, x_N^k)$ & the $k$-th feature (column) \\ $\bold{x}^{-k}$ & feature columns excluding $\bold{x}^k$ \\ $S_i$ & anomaly score for $\bold{x}_i$\\ $S_i^k$ & anomaly score for $x_i^k$ \\ $S_i^k (\textrm{uncertainty})$ & uncertainty measure for $x_i^k$ \\ $S_i^k(\textrm{disagreement})$ & disagreement measure for $x_i^k$ \\ $\bold{M}^k$ & ensemble model: $\bold{x}^{-k} \rightarrow \bold{x}^k$ \\ $T_i^k$ & number of OOB models for $\bold{x}_i$ in $\bold{M}^k$ \\ $ \hat{\bold{x}}_i^k $ & OOB predictions for $x_i^k$ \\ $\hat{x}_i^k(t)$ & the $t$-th OOB prediction for $x_i^k$ \\ $\bar{x}_{i}^k $ & average of OOB predictions $ \hat{\bold{x}}_i^k $ (numerical)\\ $C_k$ & cardinality of $\bold{x}^k$ if categorical \end{tabular} \end{center} \end{table} Let $\{x_i^k \}_{i = 1, \ldots, N; k= 1, \ldots, K}$ represent a dataset with $N$ data points and $K$ features. We use $\bold{x}_i = (x_i^1, x_i^2, \ldots, x_i^K)$ to represent the $i$-th data point (i.e., row or feature vector) each including $K$ features, and $\bold{x}^k = (x_1^k, x_2^k, \ldots, x_N^k)$ to represent the $k$-th feature column of the dataset. In addition, we define $\bold{x}^{-k}$ $=$ $(\bold{x}^1$, \ldots, $\bold{x}^{k-1}, \bold{x}^{k+1}, \ldots, \bold{x}^K)$ to represent the set of feature columns excluding the $k$-th feature. Similarly, for the $i$-th data point, $\bold{x}_i^{-k} = (x_i^1, \ldots, x_i^{k-1}, x_i^{k+1}, \ldots, x_i^K)$ represents the $i$-th feature vector excluding its $k$-th feature. For each data point $\bold{x}_i$, we calculate an anomaly score $S_i$ as the sum over the anomaly score of each of its features denoted by $S_i^k, k = 1, \ldots, K$ (\cref{eq:agg_func_avg}). The higher the score is, the more likely that the data point is an anomaly. \begin{equation}\label{eq:agg_func_avg} S_i = \sum_{k=1}^{K} S_i^k, i = 1, \ldots, N. \end{equation} To calculate $S_i^k$, we train an ensemble model $\bold{M}^k$ with $T$ base learners $\{ M_1^k, M_2^k, \ldots,M_T^k\}$ to predict feature column $\bold{x}^k$ using the remaining feature columns $\bold{x}^{-k}$. Each base learner is trained on a bootstrap sample of the full dataset. Formally speaking, we have \begin{equation} \bold{M}^k: \bold{x}^{-k} \rightarrow \bold{x}^k, k = 1, \ldots, K. \end{equation} We use the Random Forest \cite{breiman2001random} as our ensemble model where a base learner is either a decision tree for a categorical feature or regression tree for a numerical feature. Note that the proposed method is generally applicable to all kinds of classification or regression models. We choose tree-based models for their intrinsic ability to handle high dimensionality and features with disparate types and scales. In an ensemble model, OOB predictions for a data point are defined as the predictions made by the set of base models which do not include that data point as part of the training set due to the bootstrap sampling. We also call these models OOB models for that data point. Let $\bold{\hat{x}} _i^k = \{ \hat{x} _i^k(1), \ldots, \hat{x} _i^k(T_i^k) \} $ represent the OOB predictions from the OOB models with respect to $x_i^k$ , where $T_i^k(<T)$ is the number of such OOB models for the $i$-th data point in the ensemble model $\bold{M}^k$. The anomaly score $S_i^k$ is calculated as a sum of two derived statistics from the OOB predictions (\cref{eq:two_terms}). The first term describes the uncertainty in the OOB predictions, and the second term describes the disagreement between $x_i^k$ and the expected value by consulting the OOB models. \begin{equation} \label{eq:two_terms} S_i^k = S_i^k(\mathrm{uncertainty}) + S_i^k (\mathrm{disagreement}), k = 1, \ldots, K, i = 1, \ldots, N. \end{equation} Below, we discuss in detail how $S_i^k(\mathrm{uncertainty}) $ and $S_i^k (\mathrm{disagreement}) $ are computed from the OOB predictions in the cases of a categorical feature and a numerical feature, respectively. \subsection{Categorical Features} \label{sec:cat_feature} When feature $\bold{x}^k $ is a categorical feature of cardinality $C_k$, each element of the OOB prediction vector $\bold{\hat{x}} _i^k = \{ \hat{x} _i^k(1), \ldots, \hat{x} _i^k(T_i^k)) \} $ points to one of the possible categorical values. A natural choice of the uncertainty measure is entropy: \begin{equation} \label{eq:cat_uncertainty} S_i^k(\textrm{uncertainty}) =\frac{1}{\log C_k} Entropy( \hat{x} _i^k(1), \ldots, \hat{x} _i^k(T_i^k)) ). \end{equation} The scaling factor ($=1/\log C_k$) in \cref{eq:cat_uncertainty} is the maximum entropy for a $C_k$-cardinality distribution. To characterize the disagreement, we simply calculated the difference between 1 and the expected probability of $x_i^k$ judged by the OOB models: \begin{equation} S_i^k(\textrm{disagreement}) = 1 - \frac{\sum_{t=1}^{T_i^k} \bold{I}(x_i^k(t) == x_i^k)}{T_i^k}, \end{equation} where $\bold{I}$ (condition) is a function that outputs 1 if the condition is satisfied and 0 otherwise. \subsection{Numerical Features} \label{sec:num_feature} In cases where $\bold{x}^k$ is a numerical feature, anomaly score can be simply computed as the average squared difference between the OOB predictions and the feature value: \begin{equation} \label{eq:num_anomaly} S_i^k = \frac{1}{T_i^k} \sum_{t=1}^{T_i^k} (\hat{x}_i^k(t) - x_i^k )^2. \end{equation} \Cref{eq:num_anomaly} provides a combined view of uncertainty and disagreement. Let $\bar{x}_{i}^k = \frac{\sum_{t=1}^{T_i^k} x_i^k(t)}{T_i^k}$ represent the average judgement from all OOB models. The right hand side of the equation can be further broken down as follows: \begin{align} \label{eq:num_two_terms} S_i^k & = \frac{1}{T_i^k} \sum_{t=1}^{T_i^k} (\hat{x}_i^k(t) - x_i^k )^2 \nonumber \\ &= \frac{1}{T_i^k} \sum_{t=1}^{T_i^k} (\hat{x}_i^k(t) - \bar{x}_{i}^k + \bar{x}_{i}^k - x_i^k )^2 \nonumber \\ & = \frac{1}{T_i^k} \sum_{t=1}^{T_i^k} (\hat{x}_i^k(t) - \bar{x}_{i}^k ) ^2 \nonumber \\ - &\frac{2}{T_i^k} \sum_{t=1}^{T_i^k} (\hat{x}_i^k(t) - \bar{x}_{i}^k ) (\bar{x}_{i}^k - x_i^k) + (\bar{x}_{i}^k - x_i^k ) ^2. \end{align} The first term, $\frac{1}{T_i^k} \sum_{t=1}^{T_i^k} (\hat{x}_i^k(t) - \bar{x}_{i}^k ) ^2$, is the variance of the predictions of the OOB models, which provides a measure of uncertainty. We can easily show that the middle term is equal to 0 since $\sum_{t=1}^{T_i^k} \hat{x}_i^k(t) $ and $\sum_{t=1}^{T_i^k}\bar{x}_{i}^k $ are equal. The last term represents the disagreement between the average OOB judgement and the actual feature value. Therefore, for a numerical feature, the anomaly can also be measured in aspects of uncertainty and disagreement as follows. \begin{equation} S_i^k(\textrm{uncertainty}) = \frac{1}{T_i^k} \sum_{t=1}^{T_i^k} (\hat{x}_i^k(t) - \bar{x}_{i}^k ) ^2 \end{equation} \begin{equation} S_i^k(\textrm{disagreement}) = (\bar{x}_{i}^k - x_i^k ) ^2 = \left( \frac{\sum_{t=1}^{T_i^k} x_i^k(t)}{T_i^k} - x_i^k\right)^2. \end{equation} \subsection{Score Standardization} Each dataset may consist of both categorical and numerical features, and each feature and its OOB predictions could follow different distributions. As a result, the anomaly scores computed from different features may have different scales. In order to combine the anomaly scores from different features, disregarding their types and distributions, we applied a min-max scaling to each anomaly score before combining them into a final score in \cref{eq:agg_func_avg}. \begin{equation} S^k_{min} = min(S^k_1, \ldots, S^k_N), k = 1, \ldots, K \\ \end{equation} \begin{equation} S^k_{max} = max(S^k_1, \ldots, S^k_N), k = 1, \ldots, K \end{equation} \begin{equation}\label{eq:min_max} S^{k * }_i = \frac{S^k_i - S^k_{min}}{S^k_{max} - S^k_{min}}. \end{equation} \begin{algorithm} \caption{OOB Anomaly Detection} \label{alg:algorithm} \begin{algorithmic}[1] \STATE {\bfseries Input:} Dataset $\{x_i^k \}_{i = 1, \ldots, N, k= 1, \ldots, K}$ consisting of $N$ data points each with $K$ features \STATE {\bfseries Output:} anomaly scores $S_i$ for $i=1,2, \ldots, N$ \FOR{$k=1$ \bfseries{to} $K$} \STATE Train an ensemble model $\bold{M}^k: \bold{x}^{-k} \rightarrow \bold{x}^k$ \STATE With model $\bold{M}^k$, generate OOB predictions $ \hat{\bold{x}}_i^k = \{ \hat{x} _i^k(1), \ldots, \hat{x} _i^k(T_i^k) \} $ for $x_i^k, i = 1, \ldots, N$ \STATE Compute $S_i^k , i=1, \ldots, N$ (\cref{eq:two_terms}) \STATE Perform min-max scaling on $S_i^k$ (\cref{eq:min_max}) \ENDFOR \FOR{$i=1$ \bfseries{to} $N$} \STATE $S_i = \sum_{k=1}^{K} S_i^k$ \ENDFOR \end{algorithmic} \end{algorithm} \subsection{Reasons for uncertainty and disagreement} Here we provide insights into why we consider uncertainty and disagreement two good measures for detecting anomalies. We begin the discussion with two common types of anomaly: The first type of anomaly is \textbf{outlier}, namely the data points that fall outside the the usual patterns of the dataset. Consequently, the OOB models have very little knowledge learnt from the remainder of the dataset on how to correctly predict them and therefore make contradicting predictions. This phenomenon often can be captured by a high uncertainty. The second type is \textbf{mislabelled data}. This situation occurs when only one or very few features out of many were mistakenly recorded but their true value could be easily inferred from the remaining features. In real estate transactions, one example is human error in entering numbers to computer systems that may result in an extra or a missing '0' in the recorded sale price. Another example is a "townhouse" listing being mistakenly recorded as a "single family house". In those cases, the OOB predictions could have low uncertainty but high disagreement with the observed feature value, where the OOB predictions concentrate on a different feature value. We take categorical features as examples for a further visual illustration, but a similar intuition should generalize to numerical features. Fig.~\ref{fig:entropy_sketch_2} depicts the simple case when $C_k$=2, and~\cref{fig:entropy_sketch_n} depicts a more general scenario when $C_k$>2. In both figures, the x-axis represents the probability mass on the observed feature value from the OOB predictions, which we denote as $p =\frac{\sum_{t=1}^{T_i^k} \bold{I}(x_i^k(t) == x_i^k)}{T_i^k}$ for simplicity, and the y-axis represents the entropy-based uncertainty measure. Fig.~\ref{fig:entropy_sketch_n} also sketches out the upper and lower bounds of the uncertainty measure. For a given value of $p$, the lower bound curve on the entropy occurs when one of the remaining $C_k-1$ classes carries all of the remaining mass $1-p$ (\cref{eq:lower_bound}), while the upper bound curve is reached when the remaining mass $1-p$ evenly distributed among the remaining $C_k$ classes (\cref{eq:upper_bound}). In both figures, the red regions are the outlier points which are characterized with high uncertainty in the OOB predictions. The gold regions are occupied by the possible mislabelled data points, where the OOB predictions are concentrated on a different categorical feature value with very little uncertainty. The lower right corner of the figures depicts the characteristics of the strong inliers, where the observed feature value is unsurprising and the OOB models are able to predict them correctly with high confidence: \begin{equation}\label{eq:lower_bound} S_{lower}(\textrm{uncertainty}) =-p\ \text{log}(p) - (1-p)\ \text{log}(1-p), \end{equation} \begin{equation}\label{eq:upper_bound} S_{upper}(\textrm{uncertainty}) =-p\ \text{log}(p) - (1-p)\ \text{log}\left(\frac{1-p}{C_k-1}\right). \end{equation} \begin{figure} \begin{center} \centerline{\includegraphics[width=0.8\textwidth]{entropy_sketch_degenerate_2dim.eps}} \caption{ Possible entropy values in light blue vs. OOB probability of the observed feature value in the case of a 2-cardinality categorical. The red region characterizes outliers while the gold region characterizes the mislabelled data points.} \label{fig:entropy_sketch_2} \end{center} \end{figure} \begin{figure} \begin{center} \centerline{\includegraphics[width=0.8\textwidth]{entropy_sketch_n.eps}} \caption{ Region of possible entropy values in light blue vs. OOB probability of the observed feature value in the case of $C_k$-cardinality categorical feature. The red region characterizes outliers, and the gold region characterizes the mislabelled data points.} \label{fig:entropy_sketch_n} \end{center} \end{figure} \subsection{Computational complexity} \label{subsec:o_n} The main computational cost is the training and scoring of each feature with the ensemble model. Training a random forest model with $T$ trees on a dataset with $K$ feature and $N$ data points is of $O(\sqrt{K} TN \log N)$, and scoring the same size of data will cost $O(TN \log N)$. The algorithm requires such training and scoring process for each of the K features. Therefore, the overall computational complexity is $O(K^{3/2} TN \log N)$, which converges to $O(N\log N)$ when $N \gg K, T$. For real-life applications where important features can be identified by domain knowledge, we could potentially reduce the computational time by focusing the subset of important features instead of all features. \subsection{Hyper-parameters} \label{subsec:hyper_parameters} Our method introduces a few standard parameters during the training of random forest ensemble models. 500 trees are trained for each Random Forest model. As the stopping criterion, the minimum leaf node size is set to be around 4\% of the size of datasets. We apply the categorical feature scoring method in \cref{sec:cat_feature} to the features that have significant smaller unique values than the size of the datasets (< 5\%), and apply the numerical feature scoring method in \cref{sec:num_feature} to the remaining features. \section{Experiments} \label{sec:results} We conducted two set of experiments to demonstrate the effectiveness of our method in anomaly detection across various domains. In the first set of experiments, we evaluated the performance of anomaly detection methods through 10 publicly available datasets from the Outlier Detection Data Sets (ODDS) library \citep{Rayana2016}. All the datasets were originally available in UCI machine learning repository \citep{asuncion2007uci}, but converted for anomaly detection experiments. The anomalous data points are either labelled or defined by the minority label class. In the second experiment, we used our in-house home valuation dataset as a case study to illustrate the benefits of incorporating anomaly detection into a real-world ML system. \subsection{Anomaly Detection on Benchmark Datasets} \begin{table*}[h] \caption{Comparison of 10 anomaly detection methods over 10 benchmark datasets on AUC, average rank of AUC and Wilcoxon signed-rank test} \label{tab:uci_auc} \resizebox{\textwidth}{!}{% \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline Data & \# Samples & \# Dim. & Outlier \% & KNN(5) & KNN(10) & ABOD & HBOS & PCA & VAE & AE & OCSVM & IF & OOB \\ \hline arrhythmia & 452 & 274 & 14.60 & 0.7684 & 0.7746 & 0.7364 & 0.8141 & 0.7748 & 0.7748 & 0.7767 & 0.7737 & 0.8041 & \textbf{0.8196} \\ \hline glass & 214 & 9 & 4.21 & \textbf{0.8325} & 0.8054 & 0.7182 & 0.7057 & 0.6027 & 0.5986 & 0.5718 & 0.5496 & 0.7027 & 0.7927 \\ \hline ionosphere & 351 & 33 & 35.90 & 0.9337 & 0.9292 & 0.9170 & 0.5661 & 0.7947 & 0.7955 & 0.8184 & 0.8510 & 0.8556 & \textbf{0.9455} \\ \hline optdigits & 5216 & 64 & 2.88 & 0.3948 & 0.3724 & 0.5133 & 0.8723 & 0.5137 & 0.5137 & 0.5128 & 0.5071 & 0.7066 & \textbf{0.9484} \\ \hline pima & 768 & 8 & 34.90 & 0.7087 & 0.7134 & 0.6669 & 0.7089 & 0.6322 & 0.6587 & 0.6096 & 0.6237 & 0.6677 & \textbf{0.7161} \\ \hline satellite & 6435 & 36 & 31.64 & 0.6650 & 0.6872 & 0.5489 & \textbf{0.7557} & 0.6012 & 0.6012 & 0.6017 & 0.6636 & 0.7055 & 0.7462 \\ \hline satimage-2 & 5803 & 36 & 1.22 & 0.9318 & 0.9584 & 0.7588 & 0.9767 & 0.9772 & 0.9772 & 0.9772 & 0.9967 & 0.9930 & \textbf{0.9981} \\ \hline shuttle & 49097 & 9 & 7.15 & 0.6342 & 0.6582 & 0.6142 & 0.9843 & 0.9899 & 0.9898 & 0.9898 & 0.9917 & \textbf{0.9968} & 0.9816 \\ \hline vertebral & 240 & 6 & 12.50 & 0.3781 & 0.3537 & 0.3652 & 0.3051 & 0.3776 & 0.3819 & \textbf{0.4684} & 0.4197 & 0.3542 & 0.3977 \\ \hline vowels & 1456 & 12 & 3.43 & \textbf{0.9768} & 0.9694 & 0.9661 & 0.6766 & 0.6062 & 0.6217 & 0.6009 & 0.7784 & 0.7547 & 0.9211 \\ \hline \multicolumn{4}{|c|}{Avg. rank} & 5.3 & 5.2 & 7.0 & 5.1 & 6.4 & 6.7 & 6.7 & 5.8 & 4.4 & 2.4 \\ \hline \multicolumn{4}{|c|}{Wilcoxon signed-rank test $p$ value} & 0.0372 & 0.0297 & 0.0063 & 0.0109 & 0.0035 & 0.0035 & 0.0109 & 0.0109 & 0.0047 & - \\ \hline \end{tabular}% } \end{table*} The 10 ODDS benchmark datasets are good representations of real-world problems from various domains. Their sizes vary from hundreds of data points to hundreds of thousands of data points, and their number of features ranges from 6 to over 270. Given the known labels for anomalies, we used the Area Under the Curve (AUC) of Receiver Operating Characteristics (ROC) to evaluate the performance of the anomaly detection methods. ROC was calculated by sweeping over different thresholds on the anomaly scores, and counting the number of true positives and false negatives, given that anomalies are labelled as positive. In this set of experiments, we consider the following competitors, which cover existing methods in all 4 categories as summarized in \cref{sec:related}: \begin{itemize} \item KNN: K Nearest Neighbors (use the distance to the kth nearest neighbor as the outlier score, with K=5 and 10) \citep{ramaswamy2000efficient} \item ABOD: Angle-Based Outlier Detection \citep{kriegel2008angle} \item HBOS: Histogram-Based Outlier Score \citep{goldstein2012histogram} \item PCA: PCA-based anomaly detection \citep{shyu2006principal} \item AE: AutoEncoder (use reconstruction error as the outlier score) \citep{kramer1991nonlinear} \item VAE: Variational AutoEncoder (use reconstruction error as the outlier score) \citep{kingma2013auto} \item OCSVM: One-Class Support Vector Machine \citep{scholkopf2000support} \item IF: Isolation Forest \citep{isolation_forest} \end{itemize} In our experiments, we used the implementations with default paramters in \citep{zhao2019pyod} for these competitors. For AE and VAE, the encoder hidden layers have 16, 8 and 4 nodes for datasets with more than 16 features and 8, 8 and 4 nodes for the remaining datasets, and the decoders follow a reversed setting. For each method and each dataset, the average AUCs over 10 experiments are reported in \cref{tab:uci_auc} to account for the stochastic processes in the methods. For each dataset, the highest average AUC achieved is highlighted in bold, and we rank the methods from 1 to 10 based on their AUC performance. The average rank for each method across 10 datasets is also reported in \cref{tab:uci_auc}. From \cref{tab:uci_auc}, we observe that the proposed OOB anomaly detection method outperforms all 9 competing methods in 5 out of 10 datasets. Moreover, our method achieves the highest average rank (2.4), while the second best method, IF \citep{isolation_forest}, achieves the average rank of 4.4. In addition, we use Wilcoxon signed-rank test \citep{wilcoxon1992individual} to compare each competing method to our method with significance measurement. AUC metrics from two methods for the same dataset are considered paired observations when computing the test statistics, and the alternative hypothesis is that the AUC performance of OOB method is greater than that of the competing method. Based on the results of the Wilcoxon signed-rank test reported in the final row of \cref{tab:uci_auc}, our proposed method is better than each of the competing methods at significance level 0.05. This set of experiments demonstrates the strong performance of our method across a diverse set of anomaly detection tasks. \subsection{Case Study: Anomaly Detection for Automatic Home Valuation} \label{sec:zillow_data} Motivated by the home valuation application at \textsc{Zillow}, we designed a case study to illustrate how a ML system could benefit from the OOB anomaly detection method. We used an in-house dataset originally constructed to perform a home valuation task as a regression problem. The dataset contains near $2.1 * 10^6$ data points (historical real estate transactions) from a city region with a mixture of categorical, ordinal, and continuous data types. In this experiment, we compare our method with only IF, the strongest competitor based on the experiments on ODDS datasets. Although we don't have ground truth for the anomalies, our goal of integrating anomaly detection as a pre-processing step is to improve the accuracy of the ML models, which determines the following evaluation approach. We first split the data into a training dataset (80\%) and a testing dataset (20\%). We evaluated different anomaly detection methods based on the prediction accuracy of the testing data after cleaning the training data with these methods. More specifically, we first remove a certain percentage of data with the highest anomaly scores provided by an anomaly detection model, then train a home valuation model (based on LightGBM \citep{ke2017lightgbm}) with the cleaned training data after removing these anomalies, and finally evaluate the model performance on the hold-out testing set. The relative mean absolute error (MAE) after removing different percentages of training data points are reported in \cref{fig:zillow_error}. The relative MAE is calculated as the ratio to the original MAE achieved by training on the full training dataset without any anomaly removal. From \cref{fig:zillow_error}, we observe that both IF and OOB are able to reduce the testing error by excluding a small percentage of training data from the training process. This observation highlights the importance of anomaly detection in an ML system. For Zillow, any small error reduction in home valuation can have a great positive impact in business objectives and obtaining customer trust. Furthermore, we observe a consistent advantage of OOB anomaly detection method over IF in this case study, which strongly demonstrates the effectiveness of our method. We also observe a slight bounce of error after removing 1.5\% of training data for both methods, which may be an indicator of removing too much (valid) training data. Therefore, before integrating any anomaly detection methods into a production data processing pipeline, an offline evaluation similar to \cref{fig:zillow_error} should be conducted to determine a proper anomaly score threshold (based on the ``elbow'' points). \begin{figure}[t] \begin{center} \includegraphics[width=0.8\textwidth]{zillow_performance.eps} \caption{Comparison of the proposed method and Isolation Forest (IF) on the case study of home valuation modeling. For each method, a curve shows the relative MAEs as we remove different percentages of training data labelled as anomalies} \label{fig:zillow_error} \end{center} \end{figure} \section{Conclusions and Future Work} \label{sec:conclusion} In this paper, we introduced a novel method for unsupervised anomaly detection, which we called Out-of-Bag anomaly detection. Our method decomposes the unsupervised problem into a set of supervised learning problems and leverages the statistics derived from the OOB estimates. The proposed method is applicable to complex datasets with mixed categorical and numerical features. We demonstrated effectiveness of our anomaly detection method through experiments on standard benchmark datasets and an in-house case study on home valuation. For future research, a possible improvement to our method is combining feature selection or weighting into the current algorithm. An algorithmic way to identify the most important feature for anomaly detection may further improve the effectiveness and efficiency of our method. For example, for a housing dataset, the anomaly score derived from the price feature may be more important than scores from other features. Also, it will be a valuable investigation to explore classification or regression models other than decision trees and regression trees. Although we used tree-based models in this paper, the proposed OOB framework is general enough and could be extended to use other base learners. For future applications, in addition to using our method in data pre-processing as discussed in \cref{sec:zillow_data}, our method can also be used to detect fraudulent listings, which is a very important topic for housing marketplaces like Zillow, Trulia and Redfin as well as for travel websites like Airbnb and Vrbo. In the future, we will also explore how this unsupervised anomaly signal can be leveraged in our ranking and recommendation systems in order to better protect our users. Anomaly detection methods can help ML applications in achieving reliable and robust performance in the domains where customers trust is highly valued. Here at Zillow, adopting anomaly detection early on in ML applications has helped us improve the accuracy of ML models and build a trusted home-related marketplace \citep{zillow_end_game}. We hope our method can also provide values for other customer-centric machine leanring groups. We have made a Python implementation of the OOB anomaly detection algorithm publicly available\footnote{{https://github.com/comorado/OOB\_anomaly\_detection}}, accompanied by an example using the Jupyter notebooks for reproducibility of the results reported in this work. For training OOB models we use \textsc{scikit-learn} library \cite{scikit-learn}. \nocite{*} \bibliographystyle{ACM-Reference-Format}
{'timestamp': '2020-09-22T02:14:17', 'yymm': '2009', 'arxiv_id': '2009.09358', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09358'}
arxiv
\section{Introduction} Portrait images, showing mainly the face and upper body of people, are among the most common and important photographic depictions. We look at them to emotionally connect with friends and family, we use them to best present ourselves in job applications and on social media, they remind us of memorable events with friends, and photographs of faces are omnipresent in advertising. Nowadays, tools to computationally edit and post-process photographs are widely available and heavily used. Professional and hobby photographers use them to bring out the best of portrait and social media photos, as well as of professional imagery used in advertising. Photos are often post-processed with the purpose to change the mood and lighting, to create a specific artistic look and feel, or to correct image defects or composition errors that only become apparent after the photo has been taken. Today, commercial software\footnote{For example: \url{www.adobe.com/Photoshop}} or recent research software \cite{Luan2017DeepPS,Gatys} offers a variety of ways to edit the color or tonal characteristics of photos. Some tools even enable the change of visual style of photos to match certain color schemes \cite{Luan2017DeepPS,Shih14}, or to match a desired painterly and non-photo-realistic style \cite{Gatys,selim16}. In many cases, however, edits to a portrait are needed that require more complex and high-level modifications e.g. modifying head posture, smile or scene illumination after the capture. Enabling such edits from a single photograph is an extremely challenging and underconstrained problem. \new{This is because editing methods need to compute reliable estimates of 3D geometry of the person and lighting in the scene.} Moreover, they need to photo-realistically synthesize modified images of the person and background in a perspectively correct parallax-respecting manner, while inpainting disoccluding regions. For ease of use, editing methods should use semantically meaningful parameterizations, which for the rest of the paper means the following: Head pose, face expression and scene lighting should be expressed as clearly disentangled and intuitive variables akin to computer animation controls, such as coordinates and angles, blendshape weights, or environment map parameterizations. Existing methods to edit human portrait imagery at best achieve parts of these goals. Some model-based methods to realistically edit human expression \cite{thies2019,thies2016face} and head pose \cite{kim2018DeepVideo} fundamentally require video input and do not work on single images. Other editing approaches are image-based and cannot be controlled by intuitive parametric controls~\cite{Geng2018WarpguidedGF,elor2017bringingPortraits,wang2018fewshotvid2vid,fewshot-neuraltalkingheads,Siarohin_2019_NeurIPS}, only enable editing of a single semantic parameter dimension, e.g., scene illumination \cite{Sun19,Meka:2019,Zhou_2019_ICCV}, or do not photo-realistically synthesize some important features such as hair~\cite{pagan}. Recently, generative adversarial neural networks, such as StyleGAN~\cite{Karras2019cvpr}, were trained on community face image collections to learn a manifold of face images. They can be sampled to generate impressive photo-realistic face portraits, even of people not existing in reality. However, their learned parameterization entangles important face attributes (most notably identity, head pose, facial expression, and illumination), which thus cannot be independently and meaningfully controlled in the output. It therefore merely allows control on a coarse style-based level, e.g., to adapt or transfer face styles on certain frequency levels between images. \new{To overcome this limitation, StyleRig~\cite{anoynomous} describes a neural network that maps the parameters of a 3D morphable face model (3DMM) \cite{Blanz1999} to a pretrained StyleGAN for face images.} However, while their results show disentangled control of face images synthesized by a GAN, % they do not allow for editing real portrait photos. \new{On the other hand, some approaches have tried to embed real images in the StyleGAN latent space. \citet{Abdal_2019_ICCV,abdal2019image2stylegan} demonstrate high-quality embedding results, which are used to perform edits such as style or expression transfer between two images, latent space interpolation for morphing, or image inpainting. However, when these embeddings are used to edit the input images using StyleRig~\cite{anoynomous}, the visual quality is not preserved and the results often have artifacts. High-quality parametric control of expression, pose or illumination on real images has not yet been shown to be feasible. } \new{We therefore present the first method for embedding real portrait images in the StyleGAN latent space which allows for photo-realistic editing that combines all the following features: It enables photo-real semantic editing of all these properties --- head pose, facial expression, and scene illumination, given only a single in-the-wild portrait photo as input, see Fig.~\ref{fig:teaser}.} Edits are coherent in the entire scene and not limited to certain face areas. Edits maintain perspectively correct parallax, photo-real occlusions and disocclusions, and illumination on the entire person, without warping artifacts in the unmodeled scene parts, such as hair. The embedding is estimated based on a novel non-linear optimization problem formulation. Semantic editing in parameter space is then achieved based on the pretrained neural network of~\citet{anoynomous}, which maps the control space of a 3D morphable face model to the latent space of StyleGAN. These semantic edits are accessible through a simple user interface similar to established face animation control. We make the following contributions: \begin{itemize} \item \new{We propose a hierarchical optimization approach that embeds a portrait image in the latent space of StyleGAN while ensuring high-fidelity as well as editability.} \item \new{Moreover, in addition to editability of the head pose, facial expression and scene illumination, we introduce an energy that enforces preservation of the facial identity. } \end{itemize} \section{Related Work} We define face editing as the process of changing the head pose, facial expression, or incident illumination in a portrait image or video. Many recent editing techniques are learning-based. We distinguish between person-specific techniques that require a large corpus of images (or a long video) of the person, few-shot techniques that only require a small number of images, and single-shot techniques that only require a single image as input. Our Portrait Image Embedding (PIE) approach is part of the third category and enables intuitive editing of a portrait image by a set of semantic control parameters. In addition to these categories, we will also summarize existing works related to portrait relighting. \subsection{Person-specific Video Editing Techniques} There has been a lot of research on person-specific techniques~\cite{thies2016face,kim2018DeepVideo,Recycle-GAN,thies2019,Kim19NeuralDubbing, Wiles18} that require a large training corpus of the target person as input. These approaches can be classified into model-based~\cite{thies2016face,kim2018DeepVideo,thies2019,Kim19NeuralDubbing} and image-based~\cite{Recycle-GAN} techniques. Model-based techniques employ a parametric face model to represent the head pose, facial expression, and incident scene illumination. The semantic parameter space spanned by the model can be used to either perform intuitive edits or transfer parameters from a source to a target video. On the other end of the spectrum are image-based techniques that can transfer parameters, but do not provide intuitive semantic control. \paragraph{Model-based Video Editing Techniques} Facial reenactment approaches \cite{thies2016face,thies2019} change the facial expressions in a target video to the expressions in a driving source video. These approaches achieve impressive results, but require a video of the target person as input and do not enable editing of the head pose and incident illumination. Kim \etal~\shortcite{kim2018DeepVideo} proposed the first full head reenactment approach that is able to edit the head pose as well as the facial expression. A conditional deep generative model is leveraged as a neural rendering engine. While these approaches \cite{thies2016face,kim2018DeepVideo,thies2019} produce exciting results, they do not preserve the speaking style of the target. In Kim~\etal~\shortcite{Kim19NeuralDubbing}, an approach is proposed for editing the expressions of a target subject while maintaining his/her speaking style. This is made possible by a novel style translation network that learns a cycle-consistent mapping in blendshape space. In contrast to our approach, all these techniques require a long video of the target as input and cannot edit a single image of an arbitrary person. \paragraph{Image-based Video Editing Techniques} Image-based techniques enable to control a target face through a driving video. The approach of Bansal~\etal~\shortcite{Recycle-GAN} allows them to modify the target video while maintaining the speaking style. A novel recycle loss is defined in the spatio-temporal video domain. This approach obtains high-quality results for expressions and pose transfer. In contrast to our approach, image-based approaches do not provide intuitive control via a set of semantic control parameters and have to be trained in a person-specific manner. Thus, they cannot be employed to edit a single given image. \subsection{Few-shot Editing Techniques} Few-shot editing techniques \cite{wang2018fewshotvid2vid,fewshot-neuraltalkingheads,Wiles18} require only a small set of images of the target person as input. Given multiple frames showing a target person, X2Face~\cite{Wiles18} drives a frontalized face embedding by a regressed warp field that is estimated by an encoder-decoder network. The approach can also drive faces based on audio. Wang~\etal~\shortcite{wang2018fewshotvid2vid} presented a few-shot video editing approach and showed its application to driving a target face via a source video. A novel network weight generation module is proposed that is based on an attention mechanism. To animate faces, the network is trained to transfer image sketches to photo-realistic face images. The network is trained on a large multi-identity training corpus and can be applied to new unseen still images. Zakharov~\etal~\shortcite{fewshot-neuraltalkingheads} presented a few-shot technique for animating faces. Their solution has three components: 1) a generator network that translates landmark positions to photo-realistic images, 2) an embedding network that learns an intermediate representation for conditioning the generator, and 3) a discriminator. The network is trained on a large corpus of face images across multiple identities and generalizes to new identities at test time. Impressive results are shown in animating images, including legacy photos and even paintings. The learned models of few-shot techniques \cite{fewshot-neuraltalkingheads,wang2018fewshotvid2vid,Wiles18} can be improved by fine-tuning on a few example images of the target person, e.g., images taken at different view-points or at different time instances. The learned models can also be applied directly to new still images without fine-tuning. \subsection{Single-shot Editing Techniques} Several works~\cite{elor2017bringingPortraits,Geng2018WarpguidedGF,pagan} exist for controlling the expression and head pose given a single image as input. Nagano~\et~\al~\shortcite{pagan} presented \textit{paGAN}, an approach for creating personalized avatars from just a single image of a person. However, the work does not synthesize photo-realistic hair. The approach of Averbuch-Elor~\etal~\shortcite{elor2017bringingPortraits} brings portrait images to life by animating their expression and pose. The target image is animated through a 2D warp that is computed from the movement in the source video. The mouth interior is copied from the source and blended into the warped target image. The approach of Geng~\etal~\shortcite{Geng2018WarpguidedGF} employs deep generative models to synthesize more realistic facial detail and a higher quality mouth interior. First, a dense spatial motion field is used to warp the target image. Afterwards, the first network corrects the warped target image and synthesizes important skin detail. Finally, the second network synthesizes the mouth interior, including realistic teeth. Siarohin~\etal~\shortcite{Siarohin_2019_NeurIPS} proposed a method for animating a single image based on a driving sequence. By detecting keypoints in both the target image and the driving frames, the method uses a neural network to compute a dense warping field, specifying how to translate the driving frames into the target image. Based on this information a second network produces high-quality output frames. Since keypoint extraction is also learned during training, the method is applicable for any category of input, and in particular works for face and full body images. While existing single-shot editing techniques can only be controlled via a driving video, our approach enables intuitive editing of the head pose, facial expression and incident illumination in a portrait image through intuitive parametric control, as well as through a driving video. \subsection{Portrait Relighting} Relighting approaches modify the incident illumination on the face~\cite{Peers07,Shu17b,Zhou_2019_ICCV,Sun19,Meka:2019}. Earlier works~\cite{Peers07,Shu17b} require an exemplar portrait image that has been taken under the target illumination conditions. More recent techniques use deep generative models~\cite{Zhou_2019_ICCV,Sun19,Meka:2019} and can relight images based on an environment map. Zhou~\et~\al~\shortcite{Zhou_2019_ICCV} train a relighting technique based on a large corpus of synthetic images. Relighting is performed in the luminance channel, which simplifies the learning task. Sun~\etal~\shortcite{Sun19} use light stage data to train their relighting approach. At test time, the network produces high quality relighting results, even for in-the-wild images. While training with light stage data leads to high-quality results, their scarcity and careful recording protocol can limit their adaptation. Meka~\etal~\shortcite{Meka:2019} showed that the 4D reflectance field can be estimated from two color gradient images captured in a light stage. This provides more movement flexibility for the subject during recording, and hence takes an important step towards capturing relightable video. \new{ \subsection{Image Editing using SyleGAN} Several recent methods have been proposed to edit StyleGAN generated images.} \new{Most approaches linearly change the StyleGAN latent codes for editing~\cite{anoynomous,shen2020interpreting,hrknen2020ganspace}. Non-linear editing has been shown in \citet{abdal2020styleflow}. Image2StyleGAN~\cite{Abdal_2019_ICCV,abdal2019image2stylegan} is a popular approach for embedding real images into the StyleGAN latent space with very high fidelity. InterFaceGAN~\cite{shen2020interpreting} and StyleFlow~\cite{abdal2020styleflow} demonstrate editing of real images using these embeddings. Very recently, \citet{zhu2020indomain} introduce a domain-guided embedding method which allows for higher-quality editing, compared to Image2StyleGAN. However, they do not demonstrate results at the highest resolution for StyleGAN. In this paper, we design an embedding method which allows for high-quality portrait editing using StyleRig~\cite{anoynomous}.} \section{Semantic Editing of Real Facial Images} We present an approach that allows for semantic editing of real facial images. The key of our approach is to embed a given facial image in the StyleGAN latent space \cite{Karras2019cvpr}, where we pay particular attention to finding a latent encoding that is \emph{suitable for editing the image}. \new{This is crucial, since the parameter space of the StyleGAN architecture is generally under-constrained. For example, it has been shown that a StyleGAN trained for human faces is able to synthesize images that show completely different content with high fidelity, such as images of cat faces~\cite{Abdal_2019_ICCV}} % \new{Our goal is to compute embeddings which can be edited using 3DMM parameters using StyleRig. } \begin{figure*} \includegraphics[width=\textwidth]{figures/pipeline-new.png} \caption{ Given a portrait input image, we optimize for a StyleGAN embedding which allows to faithfully reproduce the image (synthesis and facial recognition terms), editing the image based on semantic parameters such as head pose, expressions and scene illumination (edit and invariance terms), as well as preserving the facial identity during editing (facial recognition term). A novel hierarchical non-linear optimization strategy is used to compute the result. StyleGAN generated images (image with edit parameters) are used to extract the edit parameters during optimization. At ``test time'',~i.e. for performing portrait image editing, the image with edit parameters is not needed. Note that the identity term is not visualized here. Images from~\citet{Shih14}. } \label{fig:pipeline} \end{figure*} \paragraph{Problem Statement} We will refer to the image that we want to make editable as $\mathbf{I}$ (without any subscripts or arguments), which we assume to be a given input. Moreover, we will refer to the StyleGAN code that will make image $\mathbf{I}$ editable as $\mathbf{w}$, which is the desired output of our approach. As such, we will introduce an energy function $E(\mathbf{w})$, which is minimized by solving a numerical optimization problem. This energy function accounts for the high fidelity of the synthesized image based on $\mathbf{w}$ (explained in Sec.~\ref{sec:hfimsyn}), for editing-suitability (described in Sec.~\ref{sec:faceediting}), as well as for consistent face identity before and after the edit (Sec.~\ref{sec:recog}). We emphasize that our approach is based on non-linear optimization techniques, and does not perform any learning of network weights, which in turn means that we do not require any ground truth data of edited facial images. In order to formulate the energy function we will make use of several existing neural networks, where all of them are pretrained and remain fixed throughout the optimization. We will now introduce some technical notations, which will allow us to have an additional layer of abstraction and thereby facilitate a more comprehensive description of the main concepts. \paragraph{Notation} Throughout this paper we will use $\mathbf{w}$ exclusively to refer to the (unknown) StyleGAN embedding that we want to find, and we will use $\mathbf{v}$ (potentially with subscripts) to refer to general StyleGAN embeddings. We note that the StyleGAN embeddings $\mathbf{w}$ and $\mathbf{v}$ can have two different forms, where each form has a different dimension, which we will describe in detail in Sec.~\ref{sec:opt}. StyleGAN can be understood as a function $\operatorname{stylegan}(\cdot)$ that maps a given latent code to a portrait image. To simplify notation, we will use the function notation $\mathbf{I}(\mathbf{v}) := \operatorname{stylegan}(\mathbf{v})$ in order to emphasize that we use the StyleGAN embedding $\mathbf{v}$ to generate the image $\mathbf{I}(\mathbf{v})$. Analogously, we overload $\mathbf{I}(\cdot)$, so that it can also take a 3DMM parameter $\theta$ as input. As such, $\mathbf{I}(\theta)$ refers to an image rendered using the face model that is parameterized by $\theta$ (Sec.~\ref{sec:fmodel}), where differentiable rendering is employed~\cite{tewari17MoFA}. Note that this rendered image is only defined on foreground face pixels as opposed to StyleGAN images. We use the variable $\tau \in \{\phi, \mathbb{\beta}, \gamma \}$ to indicate the user-defined facial semantic variable that is to be edited, which in our case can be the head pose $\phi$, facial expression $\beta$, or illumination $\gamma$. Similarly, we use the complement notation~$\overline{\tau} \subset \{\phi, \rho, \alpha, \delta, \beta, \gamma\}$, to indicate all other variables, i.e., the ones that shall not be modified. With that, we use the notation $\theta^{\tau}$ (or $\theta^{\overline{\tau}}$) to refer to the extraction of the $\tau$-component (or $\overline{\tau}$-components) of $\theta$. Since facial editing is implemented by modifying the $\tau$-component of the 3DMM parameter $\theta$, we write $\theta' = [\theta_1^{\overline{\tau}}, \theta_2^{{\tau}}]$ to indicate that the respective $\tau$-component of $\theta_1$ is replaced by the corresponding component in $\theta_2$. For example, for $\tau = \beta$, \begin{align} \theta_1 &= (\phi_1,\rho_1,\alpha_1,\delta_1,\mathbb{\beta}_1,\gamma_1)\,,\quad\text{and}\\ \theta_2 &= (\phi_2,\rho_2,\alpha_2,\delta_2,\mathbb{\beta}_2,\gamma_2)\,,\quad\text{we have}\\ [\theta_1^{\overline{\tau}}, \theta_2^\tau] &= (\phi_1,\rho_1,\alpha_1,\delta_1,\mathbb{\beta}_2,\gamma_1) \,. \end{align} Moreover, we use the notation $\theta(\mathbf{v})$ to extract the 3DMM parameters from the StyleGAN embedding $\mathbf{v}$. In order to compute this, the embedding $\mathbf{v}$ is first used to synthesize the image $\mathbf{I}(\mathbf{v})$ (using StyleGAN), followed by performing a 3D reconstruction based on the pretrained \emph{Model-based Face Autoencoder} (MoFA) network~\cite{tewari17MoFA}. Hence, for $\operatorname{MoFA}(\cdot)$ being the function that performs 3D reconstruction for a given image by estimating the 3DMM parameters, we define \begin{align} \theta(\mathbf{v}) = \operatorname{MoFA}(\mathbf{I}(\mathbf{v}))\,. \end{align} For any image $\mathbf{I'}$, we use the short-hand notation $\theta(\mathbf{I'}) = \operatorname{MoFA}(\mathbf{I'})$. Similarly as above, we will use % $\theta^{\tau}(\mathbf{v})$ and $\theta^{\tau}(\mathbf{I}')$ to extract only the $\tau$-component from the 3DMM parameters. % Whenever arguments of $\theta(\cdot)$ or $\mathbf{I}(\cdot)$ are fixed, i.e., the arguments are not a variable, we use the short-hand notations $\theta_{\mathbf{v}} = \theta(\mathbf{v})$, $\theta_{\mathbf{I}'} = \theta(\mathbf{I}')$, or $\mathbf{I}_{\mathbf{v}} = \mathbf{I}(\mathbf{v})$. We summarize the most important part of our notations in Table~\ref{table:notation}. \begin{table}[] \caption{Summary of notation.} \begin{tabular}{@{}ll@{}} \toprule \textbf{Symbol} & \textbf{Meaning} \\ \midrule $\mathbf{w}$ & StyleGAN embedding that we want to find \\ $\mathbf{v}$ & other StyleGAN embedding(s) \\ $\mathbf{\theta}$ & 3DMM parameter \\ $\mathbf{\tau}$ & component that is to be edited ($\tau \in \{\phi,\beta,\gamma\}$) \\ $\mathbf{I}$ & input image that we want to edit \\ $\mathbf{I}(\mathbf{v})$ &StyleGAN-synthesized image \\ $\mathbf{I}(\theta)$ & image of 3DMM rendering \\ $\theta^{\tau} $ & extraction of $\tau$-component of $\theta$ \\ $[\theta_1^{\overline{\tau}}, \theta_2^\tau]$ & combine $\overline{\tau}$-components in $\theta_1$ with $\tau$-component in $\theta_2$ \\ $\theta(\mathbf{v}), \theta_{\mathbf{v}}$ & 3D reconstruction of 3DMM parameters from $\mathbf{I}(\mathbf{v})$ \\ $\theta(\mathbf{I'}), \theta_{\mathbf{I'}}$ & 3D reconstruction of 3DMM parameters from $\mathbf{I}'$ \\ \bottomrule \end{tabular} \label{table:notation} \end{table} \paragraph{Objective function} We solve for $\mathbf{w}$ by minimizing the energy function \begin{align} \label{eq:totalenergy} E(\mathbf{w}) = E_{\text{syn}}(\mathbf{w}) + E_{\text{id}}(\mathbf{w}) + E_{\text{edit}}(\mathbf{w}) + E_{\text{inv}}(\mathbf{w}) + E_{\text{recog}}(\mathbf{w}) \,. \end{align} $E_{\text{syn}}$ is a synthesis term enforcing the StyleGAN-synthesized image $\mathbf{I}(\mathbf{w})$ to be close to $\mathbf{I}$ (Sec.~\ref{sec:hfimsyn}). $E_{\text{id}}$, $E_{\text{edit}}$, $E_{\text{inv}}$ are face modification terms (Sec.~\ref{sec:faceediting}) enforcing edits to take place on the modified facial semantics while at the same time ensuring unmodified facial semantics to remain un-edited. $E_{\text{recog}}(\mathbf{w})$ is a face recognition term that will be introduced in Sec.~\ref{sec:recog}. A conceptual illustration of the energy function and the overall pipeline is shown in Fig.~\ref{fig:pipeline}. Next, we will discuss each term in more detail. \subsection{High-Fidelity Image Synthesis} \label{sec:hfimsyn} Similarly to Image2StyleGAN~\cite{Abdal_2019_ICCV}, we use the following energy term that accounts for the StyleGAN-synthesized image $\mathbf{I}(\mathbf{w})$ being close to $\mathbf{I}$: \begin{align} E_{\text{syn}}(\mathbf{w}) & = \lambda_{\ell_2} \|{\mathbf{I}} - \mathbf{I}(\mathbf{w}) \|^2_2 + \lambda_{\text{p}} \| \mathbf{\Phi}({\mathbf{I}})-\mathbf{\Phi}( \mathbf{I}(\mathbf{w}) \|^2_2 \,. \label{eq:energy_synth} \end{align} The first term in the energy $E_{\text{syn}}$ penalizes the discrepancy between $\mathbf{I}$ and the synthesized image in terms of the (squared) $\ell_2$-norm, whereas the second term penalizes discrepancies based on the \emph{perceptual loss}~\cite{Johnson2016Perceptual}. The perceptual loss is estimated \new{on images downsampled by a factor of 4}, based on $\ell_2$-losses over VGG-16 layers \texttt{conv1\_1}, \texttt{conv1\_2}, \texttt{conv3\_2} and \texttt{conv4\_2} \cite{Simonyan15}. The notation $\mathbf{\Phi}(\cdot)$ refers to the function that downsamples a given input image and extracts features. The scalars $\lambda_{\ell_2}$ and $\lambda_{\text{p}}$ are the relative weights of both terms. In principle, we could minimize the energy $E_{\text{syn}}$ in~\eqref{eq:energy_synth} in order to obtain the StyleGAN code $\mathbf{w}$, as done in~\citet{Abdal_2019_ICCV}, and perform editing operations on $\mathbf{w}$. A so-obtained code vector $\mathbf{w}$ allows the use of StyleGAN to obtain a highly accurate synthetic version of the input face, which is even capable of reconstructing backgrounds with high accuracy. However, such a $\mathbf{w}$ is sub-optimal for performing \emph{semantic face editing}, as we later demonstrate in Fig.~\ref{fig:ablative-loss}. \subsection{Face Image Editing} \label{sec:faceediting} \new{We augment the synthesis term with an editing energy that is based on the StyleRig framework~\cite{anoynomous}, which allows us to obtain more accurate semantic editing while preserving the non-edited attributes.} Here, the StyleGAN embedding $\mathbf{w}$ that is to be determined should have the following three properties in order to be suitable for semantic editing: \paragraph{Identity Property} The identity property is phrased in terms of the $\ell_2$-norm of the difference of StyleGAN embeddings and is given by \begin{align} E_{\text{id}}(\mathbf{w}) & = \lambda_{\text{id}}\| \mathbf{w} - \operatorname{rignet}(\mathbf{w}, \theta^\tau(\mathbf{w})) \|_2^2 \,. \end{align} As such, whenever the RigNet is used to modify $\mathbf{w}$ with $\theta^\tau(\mathbf{w})$, i.e., a component of the 3DMM parameter extracted from $\mathbf{w}$, the embedding $\mathbf{w}$ should not be modified. \paragraph{Edit Property} In order to get around the obstacle of defining a suitable metric for 3DMM parameter vectors, whose components may be of significantly different scale, and the relative relevance of the individual components is not easily determined, we phrase the edit property in image space, \new{as in StyleRig~\cite{anoynomous}}. As such, a facial edit is implicitly specified in image space via the StyleGAN embedding $\mathbf{v}$, where the $\tau$-component of the respective 3DMM parameters of $\mathbf{v}$, i.e. $\theta^{\tau}_{\mathbf{v}}$, specifies the edit operation. The image-space version of the edit property reads \begin{align} \forall ~\mathbf{v}:\quad \mathbf{I}_{\mathbf{v}} = \mathbf{I}( [\theta_{\mathbf{v}}^{\overline{\tau}}, \theta^{\tau}(\operatorname{rignet}(\mathbf{w}, \theta_{\mathbf{v}}^\tau)) ]) \,. \end{align} Note that this true equality cannot hold in practice, since the two images are from different domains (real image and a mesh rendering). We are interested in minimimzing the difference between these terms. This equation is best fulfilled whenever the $\tau$-component of the edited 3DMM parameters $\theta^\tau(\operatorname{rignet}(\mathbf{w}, \theta_{\mathbf{v}}^\tau))$ is equal to $\theta_{\mathbf{v}}^\tau$, i.e. the edit has been successfully applied. Since computationally we cannot evaluate all choices of $\mathbf{v}$, we sample StyleGAN embeddings $\mathbf{v}$ as done in~\citet{anoynomous}, and then use the expected value as loss. For integrating this property into our optimization framework we use a combination of a photometric term and a landmark term, which is defined as \begin{align} \ell(\mathbf{I}', \theta) = \lambda_{\text{ph}} \| \mathbf{I}' - \mathbf{I}(\theta)\|_{\text{\smiley{}}}^2 + \lambda_{\text{lm}} \| \mathcal{L}_{\mathbf{I}'} - \mathcal{L}(\theta)\|_F^2 \,. \end{align} The norm $\| \cdot \|_{\smiley{}}$ computes the $\ell_2$-norm of all \emph{foreground} pixels (the facial part of the image), whereas $\|\cdot\|_F$ is the Frobenius norm. By $\mathcal{L}_{\mathbf{I}'} \in \mathbb{R}^{66 \times 2}$ we denote the matrix of 2D facial landmarks extracted from the image $\mathbf{I}$ (based on~\citet{Saragih2011}), and $\mathcal{L}(\theta) \in \mathbb{R}^{66 \times 2}$ refers to the corresponding landmarks of the 3DMM after they have been projected onto the image plane. With that, the edit property energy reads \begin{align} E_{\text{edit}}(\mathbf{w}) & = \lambda_{\text{e}} \, \mathbb{E}_{\mathbf{v}}[\ell( \mathbf{I}_{\mathbf{v}}, [\theta_{\mathbf{v}}^{\overline{\tau}}, \theta^{\tau}(\operatorname{rignet}(\mathbf{w}, \theta_{\mathbf{v}}^\tau))])] \,. \label{eq:edit} \end{align} \paragraph{Invariance Property} Similarly as the edit property we phrase the invariance property also in image space as% \begin{align} \forall ~\mathbf{v}:\quad \mathbf{I} = \mathbf{I}( [\theta^{\overline{\tau}}(\operatorname{rignet}(\mathbf{w}, \theta^\tau_{\mathbf{v}})) , \theta^{\tau}_{\mathbf{I}}]) \,. \end{align} While the edit property imposes that the $\tau$-component of the edited 3DMM parameter $\theta^\tau(\operatorname{rignet}(\mathbf{w}, \theta^\tau_{\mathbf{v}}))$ is modified as desired, the invariance property takes care of all $\overline{\tau}$. It is fulfilled whenever it holds that $\theta^{\overline{\tau}}(\operatorname{rignet}(\mathbf{w}, \theta^\tau_{\mathbf{v}})) = \theta^{\overline{\tau}}_{\mathbf{I}}$, i.e. the components $\overline{\tau}$ that are not to be edited are maintained from the input image $\mathbf{I}$. Analogously to the edit property, we base the respective energy on the combination of a photometric term and a landmark term as implemented by $\ell(\cdot)$, so that we obtain \begin{align} E_{\text{inv}}(\mathbf{w}) & = \lambda_{\text{inv}} \, \mathbb{E}_{\mathbf{v}}[\ell(\mathbf{I}, [\theta^{\overline{\tau}}(\operatorname{rignet}(\mathbf{w}, \theta^\tau_{\mathbf{v}})), \theta^{\tau}_{\mathbf{I}}])] \,. \end{align} \subsection{Face Recognition Consistency}\label{sec:recog} \new{In addition to the synthesis and editing terms, we incorporate two face recognition consistency terms to preserve the facial integrity while editing.} On the one hand, it is desirable that the synthesized image $\mathbf{I}(\mathbf{w})$ is recognized to depict the same person as shown in the given input image $\mathbf{I}$. On the other hand, the edited image, $\operatorname{stylegan}(\operatorname{rignet}(\mathbf{w}, \theta^{\tau}_{\mathbf{v}}))$ should also depict the same person as shown in the input $\mathbf{I}$. In order to do so, we use VGG-Face~\cite{Parkhi15} to extract \emph{face recognition features}, where we use the notation $\mathbf{\Psi}(\cdot)$ to refer to the function that extracts such features from a given input image. We define the recognition loss \begin{align} \ell_{\text{recog}}(\mathbf{I}', \mathbf{v}) = \|\mathbf{\Psi}(\mathbf{I}') - \mathbf{\Psi}(\mathbf{I}(\mathbf{v})) \|_F^2 \,, \end{align} which is then used to phrase the recognition energy term as \begin{align} \label{eq:recog} E_{\text{recog}}(\mathbf{w}) = \lambda_{\text{r}_{\mathbf{w}}} \,\ell_{\text{recog}}(\mathbf{I}, \mathbf{w}) + \lambda_{\text{r}_{\hat{\mathbf{w}}}} \,\mathbb{E}_{\mathbf{v}}[\ell_{\text{recog}}(\mathbf{I}, \operatorname{rignet}(\mathbf{w}, \theta^{\tau}_{\mathbf{v}}))] \,. \end{align} \begin{figure*} \includegraphics[width=\textwidth]{figures/pose-main-rev.jpg} \vspace{-0.6cm} \caption{ \new{Pose Editing. Our approach can handle a large variety of head pose modifications including out-of-plane rotations in a realistic manner. Image2StyleGAN~\cite{Abdal_2019_ICCV} embeddings often lead to artifacts when edited using StyleRig. Images from~\citet{shen2016deep}.} % } \label{fig:pos-main} \end{figure*} \begin{figure*} \includegraphics[width=\textwidth]{figures/light-main-rev.jpg} \vspace{-0.6cm} \caption{ \new{Illumination Editing. Our approach can realistically relight portrait images. Each edited image corresponds to changing a different Spherical Harmonics coefficient, while all other coefficients are kept fixed. The environment maps are visualized in the inset. Image2StyleGAN~\cite{Abdal_2019_ICCV} embeddings often lead to artifacts when edited using StyleRig. Images from~\citet{shen2016deep}.} } \label{fig:light-main-ne} \end{figure*} \begin{figure} \includegraphics[width=0.48\textwidth]{figures/exp-main-rev.jpg} \vspace{-0.6cm} \caption{ \new{Expression Editing. Our approach can also be used to edit the facial expressions in a portrait image in a realistic manner. We obtain more plausible results, compared to Image2StyleGAN~\cite{Abdal_2019_ICCV} embeddings. Images from~\citet{shen2016deep} and~\citet{Shih14}.} } \label{fig:exp-main} \end{figure} \subsection{Optimization} \label{sec:opt} Our energy function $E(\cdot)$ in \eqref{eq:totalenergy} depends on a range of highly non-linear functions, such as $\operatorname{stylegan}(\cdot)$, $\operatorname{MoFA}(\cdot)$, $\Phi(\cdot)$ and $\Psi(\cdot)$, which are implemented in terms of (pretrained) neural networks. We implement our energy minimization within TensorFlow~\cite{tensorflow2015-whitepaper} using ADADELTA optimization~\cite{zeiler2012adadelta}. In each iteration we stochastically sample a different $\mathbf{v}$. The optimization uses a hierarchical approach that we describe next. \paragraph{Hierarchical Optimization} StyleGAN is based on a hierarchy of latent spaces, where a stage-one embedding $Z$ with $|Z|=512$ is randomly sampled first. This is then fed into a mapping network that produces $W$ as output, where $|W|=512$. Subsequently, $W$ is extended to $W^+$, where $|W^+| =18 \times 512$, and used as input to $18$ network layers. It has been shown that $W^+$ is the most expressive space for fitting to real images~\cite{Abdal_2019_ICCV}. However, we found that a direct optimization over this space leads to lower-quality editing results with severe artifacts. This is because the optimized variable can be far from the prior distribution of StyleGAN. To address this, we first optimize for the embedding in the $W$-space, meaning that in the first stage of our optimization the variable $\mathbf{w}$ is understood as an embedding in the $W$-space. We optimize in $W$-space for $2000$ iterations. We then transfer the result to $W^+$-space, initialize the variable $\mathbf{w}$ respectively, and continue optimizing in the $W^+$-space for another $1000$ iterations. Optimizing in this hierarchical way allows us to represent the coarse version of the image in the $W$-space, which is less expressive and thereby closer to the prior distribution. Finetuning on the $W^+$ space then allows us to fit the fine-scale details, while preserving editing quality. \section{Rigging StyleGAN-generated images} StyleGAN~\cite{Karras2019cvpr} can synthesize human faces at an unprecedented level of photorealism. However, their edits are defined in terms of three main facial levels (coarse, medium and fine), with no semantic meaning attached to them. StyleRig~\cite{anoynomous} attaches a semantic control for a StyleGAN embedding, allowing edits for head pose, illumination and expressions. The control is defined through a 3D Morphable Face Model (3DMM)~\cite{Blanz1999}. \subsection{StyleRig in more detail} \label{sec:fmodel} Faces are represented by a 3DMM model with $m = \text{257}$ parameters \begin{equation} \label{eq:parameters} \theta = (\phi,\rho,\alpha,\delta,\beta,\gamma) \in \mathbb{R}^{257} \,. \end{equation} Here, $(\phi,\rho)\in \mathbb{R}^{6}$ are the rotation and translation parameters of the head pose, where rotation is defined using Euler angles. The vector $\alpha \in \mathbb{R}^{80}$ represents the geometry of the facial identity, while $\beta \in \mathbb{R}^{64}$ are the expression parameters. Skin reflectance is defined by $\delta \in \mathbb{R}^{80}$ and the scene illumination by $\gamma \in \mathbb{R}^{27}$. The basis vectors of the geometry and reflectance models are learned from 200 facial 3D scans \cite{Blanz1999}. The expression model is learned from FaceWarehouse \cite{Cao2014b} and the Digital Emily project \cite{alexander2010digital}. Principal Components Analysis (PCA) is used to compress the original over-complete blendshapes to a subspace of 64 parameters. Faces are assumed to be Lambertian, where illumination is modeled using second-order spherical harmonics (SH) \cite{Ramamoorthi2001b}. StyleRig~\cite{anoynomous} allows one to semantically edit synthetic StyleGAN images. To this end, StyleRig trains a neural network, called \emph{RigNet}, which can be understood as a function $\operatorname{rignet}(\cdot,\cdot)$ that maps a pair of StyleGAN code $\mathbf{v}$ and subset of 3DMM parameters $\theta^{\tau}$ to a new StyleGAN code $\hat{\mathbf{v}}$, i.e. $\hat{\mathbf{v}} = \operatorname{rignet}(\mathbf{v},\theta^{\tau})$. In practice, the 3DMM parameters are first transformed before being used in the network. Please refer to the supplemental document for details. With that, $\mathbf{I}_{\hat{\mathbf{v}}}$ shows the face of $\mathbf{I}_{\mathbf{v}}$ modified according to $\theta^{\tau}$ (i.e. with edited head pose, scene lighting, or facial expression), \new{where $\mathbf{I}_{\mathbf{v}}$ is the StyleGAN image generated using the latent code $\mathbf{v}$}. Thus, editing a synthetic image $\mathbf{I}_{\mathbf{v}}$ amounts to modifying the component $\tau$ in the parameter $\theta$, and then obtaining the edited image as $\mathbf{I}_{\hat{\mathbf{v}}} = \mathbf{I}(\operatorname{rignet}(\mathbf{v},\theta^{\tau}))$. Multiple RigNet models are trained, each to deal with just one mode of control (pose, expression, lighting). Although RigNet allows for editing of facial images, it has the major shortcoming that only \emph{synthetic} images can be manipulated, rather than real images. This is in contrast to this work, where we are able to perform semantic editing of \emph{real} images. \new{Different from the original RigNet design where a differentiable face reconstruction network regresses the 3DMM parameters from a StyleGAN code, we use a model-based face autoencoder~\cite{tewari17MoFA} which takes an image as an input. This change is necessary, as we initially do not have the StyleGAN code for the real image we want to edit. } \section{Results} In the following, we demonstrate the high-quality results of our method, analyze its different components, as well as compare to several state-of-the-art approaches for portrait image editing. \paragraph{Implementation Details} We use the following weights for our energy terms: $\lambda_{\ell_2} = 10^{-6}$, $\lambda_{\text{p}} = 10^{-6}$, $\lambda_{\text{id}} = 1.0$, $\lambda_{\text{ph}} = 0.001$, $\lambda_{\text{lm}} = 0.2$, $\lambda_{\text{e}} = 10.0$, $\lambda_{\text{inv}} = 10.0$, $\lambda_{\text{r}_{\mathbf{w}}} = 0.1$, $\lambda_{\text{r}_{\hat{\mathbf{w}}}} = 0.1$. We use a starting step size of $50$ when optimizing over embeddings in $W$ space, and $10$ in $W^+$ space. The step size is then exponentially decayed by a factor of $0.1$ every $2000$ steps. Optimization takes approximately $10$ minutes for $3000$ iterations per image on an NVIDIA V100 GPU. Once the embedding is obtained, the portrait image can be edited at an interactive speed. \new{\paragraph{Feedback} \label{sec:feedback} We noticed that a simple feedback loop allows us to get more accurate editing results. We update the parameters used as input to RigNet in order to correct for the editing inaccuracies in the output. Given target 3DMM parameters $\mathbf{\theta}$, we first obtain the embedding for the edited image, $\operatorname{rignet}(\mathbf{w}, \theta^\tau)$. We then estimate the 3DMM parameters from the edited embedding, $\theta_{\text{est}} = \theta(\operatorname{rignet}(\mathbf{w}, \theta^{\tau}))$. % The final embedding is computed as $\operatorname{rignet}(\mathbf{w}, \theta_{\text{new}}^\tau)$ with $\theta_{\text{new}} = \mathbf{\theta} + (\mathbf{\theta} - \mathbf{\theta_{\text{est}}})$. } \subsection{High-Fidelity Semantic Editing} We evaluate our approach on a large variety of portrait images taken from~\citet{shen2016deep} and~\citet{Shih14}. The images are preprocessed as in StyleGAN~\cite{Karras2019cvpr}. Figs.~\ref{fig:pos-main},~\ref{fig:light-main-ne},~\ref{fig:exp-main} show results of controlling the head pose, scene illumination, and facial expressions, respectively. \new{The projections onto the StyleGAN space are detailed, preserving the facial identity.} Our approach also produces photo-realistic edits. Fig.~\ref{fig:pos-main} shows that our approach can handle a large variety of head pose modifications, including out-of-plane rotations. It also automatically inpaints uncovered background regions in a photo-realistic manner. Fig.~\ref{fig:light-main-ne} demonstrates our relighting results. Our approach can handle complex light material interactions, resulting in high photo-realism. The relighting effects are not restricted to just the face region, with hair and even eyes being relit. Our approach also allows for editing facial expressions, see Fig.~\ref{fig:exp-main}. For smooth temporal editing results of portrait images, please refer to the supplementary video. \begin{figure*}[t] \includegraphics[width=\textwidth]{figures/ablative-loss-rev.jpg} \vspace{-0.6cm} \caption{ Ablative analysis of the different loss functions. \emph{Modification} refers to the edit, invariance and identity terms simultaneously. The left block shows results for editing the head pose and the right block shows results for editing scene illumination. All losses are required to obtain high-fidelity edits. Images from~\citet{shen2016deep}. } \label{fig:ablative-loss} \end{figure*} \begin{figure*} \includegraphics[width=\textwidth]{figures/ablative-Wjpg-rev.jpg} \vspace{-0.6cm} \caption{ Ablative analysis with and without hierarchical optimization. The left block shows the results for pose editing and the right block for illumination editing. Without our hierarchical optimization, the obtained embedding cannot be easily edited and artifacts appear in the modified images. Images from~\citet{shen2016deep}. } \label{fig:ablative-opt} \end{figure*} \begin{table*}[] \caption{ We compare different settings quantitatively using several metrics for pose editing. \new{All numbers are averaged over more than $2500$ pose editing results. We measure the quality of the fit by comparing them to the input image using PSNR and SSIM metrics. Editing error is measured as the angular difference between the desired and achieved face poses. Recognition error measures the value of the facial recognition error for the edited images. There is usually a trade-off between the quality and accuracy of editing, as lower recognition errors correspond to higher editing errors. We also compare to Image2StyleGAN~\cite{Abdal_2019_ICCV} embeddings using these metrics. While it achieves the highest quality fitting, the editing results do not preserve the facial identity well. } } \begin{tabular}{@{}lcccccc} \cmidrule(r){1-7} & \multicolumn{1}{c}{synthesis} & \begin{tabular}{@{}c@{}}synthesis + \\ recognition\end{tabular} & \begin{tabular}{@{}c@{}}synthesis + \\ modification\end{tabular} & \begin{tabular}[c]{@{}c@{}}all terms (PIE)\end{tabular} & \begin{tabular}[c]{@{}c@{}}all terms (direct opt.)\end{tabular} & Image2StyleGAN \\ \cmidrule(r){1-7} PSNR (dB) $\uparrow$ / SSIM $\uparrow$ & 30.15 / 0.70 & 29.84 / 0.69 & 30.15 / 0.70 & 29.96 / 0.70 & 29.76 / 0.69 & \textbf{31.21} / \textbf{0.75} \\ Editing Error (rad) $\downarrow$ & 0.06 & 0.11 & \textbf{0.036} & 0.08 & 0.037 & 0.07 \\ Recognition Error $\downarrow$ & 95.76 & 43.64 & 90.10 & \textbf{42.82} & 51.65 & 275.40 \\ \bottomrule \end{tabular} \label{tab:ablative} \end{table*} \subsection{Ablation Studies} Here, we evaluate the importance of the different proposed loss functions, and also evaluate the hierarchical optimization strategy. Please refer to the supplemental document for the evaluation of the feedback strategy. \paragraph{Loss Functions} Fig.~\ref{fig:ablative-loss} shows qualitative ablative analysis for the different loss functions. We group the edit, invariance and identity terms as \emph{modification terms}. Adding face recognition consistency without the modification terms lead to incorrect editing in some cases. Adding the modification terms without face recognition consistency leads to the method being able to accurately change the specified semantic property, but the identity of the person in the image is not preserved. Using all terms together leads to results with photorealistic edits with preservation of identity. We do not evaluate the importance of the individual components of the modification terms, as it was already evaluated in \citet{anoynomous}. \paragraph{Hierarchical Optimization} Hierarchical optimization is an important component of our approach. Fig.~\ref{fig:ablative-opt} shows results with and without this component. Without hierarchical optimization, the method directly optimizes for $\mathbf{w} \in W^+$. While this leads to high-quality fits, the obtained embedding can be far from the training distribution of StyleRig. Thus, the quality of edits is poor. For example in Fig.~\ref{fig:ablative-opt} (top), the StyleGAN network interprets the ears as background, which leads to undesirable distortions. With hierarchical optimization, the results do not suffer from artifacts. \paragraph{Quantitative Analysis} We also analyze the effect of different design choices quantitatively, see Tab.~\ref{tab:ablative}. We look at three properties, the quality of recostruction (measured using \new{PSNR and SSIM between the projected image and the input)}, the accuracy of edits \new{(measured as the angular distance between the desired and estimated head poses)}, and idenity preservation under edits \new{(measured using the second term in Eq.~\ref{eq:recog})} during editing. The numbers reported are averaged over more than \new{$2500$} pose editing results. We can see that removing the recognition term changes the identity of the face during editing, and removing the modification loss increases the editing and recognition error. Hierarchical optimization also leads to better facial identity preservation, compared to direct optimization. This is expected, since the results with direct optimization often have artifacts. Note that the artifacts outside of the face region (hair, ears) would not increase the recognition errors significantly. \new{The recognition term introduces a clear trade-off between the quality of identity preservation under edits and the accuracy of edits. The modification terms allow for slight improvements in both identity preservation as well as the accuracy of the edits. } \subsection{Comparison to the State of the Art} \begin{figure*} \includegraphics[width=\textwidth]{figures/comparisons_new.jpg} \vspace{-0.3cm} \caption{ Comparison of head pose editing for self-reenactment (first two rows) and cross-identity reenactment (last two rows). We compare our approach to Wiles~\etal~\shortcite{Wiles18}, Wang~\etal~\shortcite{wang2018vid2vid}, Siarohin~\etal~\shortcite{Siarohin_2019_NeurIPS} and Geng~\etal~\shortcite{Geng2018WarpguidedGF}. The pose from the reference images is transferred to the input. Our approach obtains higher quality head pose editing results, specially in the case of cross-identity transfer. All approaches other than ours are incapable of \emph{disentangled} edits, i.e., they cannot transfer the pose without also changing the expressions. The implementation of Geng~\etal~\shortcite{Geng2018WarpguidedGF} does not handle cross-identity reenactment. Note that while the three competing approaches require a reference image in order to generate the results, we allow for explicit control over the pose parameters. Image from~\citet{shen2016deep}. } \label{fig:pose-comparison} \end{figure*} \begin{figure} \includegraphics[width=0.49\textwidth]{figures/light-comparison-new.jpg} \vspace{-0.6cm} \caption{ Comparison of our relighting results with \citet{Zhou_2019_ICCV}. The illumination in the reference image is transferred to the input. Our results are more natural and achieve more accurate relighting. We can edit colored illumination while \citet{Zhou_2019_ICCV} can only edit monochrome light. In addition, we can also edit the head pose and facial expressions, while~\citet{Zhou_2019_ICCV} is trained only for relighting. Images from~\citet{Shih14}. } \label{fig:light-comparison} \end{figure} \subsubsection{Image2StyleGAN} \new{Image2StyleGAN~\cite{Abdal_2019_ICCV} also projects real images to the StyleGAN latent space, and is thus a closely related approach. The source code of Image2StyleGAN was kindly provided by the authors. We show editing results using Image2StyleGAN embeddings in Figs.~\ref{fig:teaser},~\ref{fig:pos-main},~\ref{fig:light-main-ne} and ~\ref{fig:exp-main}. Since these embeddings are optimized only using the synthesis terms and without using hierarchical optimization, the results are often implausible, as is most evident when editing the head pose and scene illumination. However, Image2StyleGAN projections are more detailed than ours.} \new{We also quantitatively compare to Image2StyleGAN in Tab.~\ref{tab:ablative}. Image2StyleGAN obtains the highest quality projections in terms of PSNR and SSIM. When combined with StyleRig, it also leads to low editing errors. However, the recognition errors are very high due to the artifacts in the results, as shown in the qualitative results. } \subsubsection{Other Aproaches} We \new{also} compare our approach to a number of related techniques, X2Face~\cite{Wiles18}, \citet{Geng2018WarpguidedGF} and \citet{Siarohin_2019_NeurIPS}. We compare our relighting capabilities to the single-image relighting approach of~\citet{Zhou_2019_ICCV}. The source codes of \new{these} techniques are publicly available. For Geng~\etal~\shortcite{Geng2018WarpguidedGF}, we estimated the landmarks using the dlib tracker~\cite{dlib09} as suggested by the authors. We also trained the few shot video-to-video translation method of~\citet{wang2018fewshotvid2vid} for portrait image editing. We trained on 700 videos from the FaceForensics dataset~\cite{roessler2019faceforensics++}. Landmarks were extracted using the dlib tracker as recommended by the authors. The approaches of~\citet{Geng2018WarpguidedGF},~\citet{Wiles18} ,~\citet{wang2018fewshotvid2vid} and \citet{Siarohin_2019_NeurIPS} are trained on a video corpus. \new{In contrast, our method does not use any direct supervision of the edited images.} We compare to these methods in two different settings, self-reenactment and cross-identity reenactment. \paragraph{Self-Reenactment} For self-reenactment, we capture several images of a person in different poses. We pick the first image and use the other images of the person as reference to edit the head pose. We captured $9$ people in different poses, resulting in $31$ images in the test set. Fig.~\ref{fig:pose-comparison} shows some qualitative results. \citet{Geng2018WarpguidedGF} use a warp-guided algorithm. While this enables expression changes and in-plane head motion, out-of-plane motion cannot be handled as shown in Fig.~\ref{fig:pose-comparison}. We also compare to X2Face~\cite{Wiles18}, which samples a learned embedded face in order to synthesize portrait images with different poses and expressions. As such, it shares its limitations with~\citet{Geng2018WarpguidedGF} and produces artifacts for strong pose changes. \begin{table}[] \caption{Evaluation of pose edits: We measure landmark alignment errors for same-subject reenactment on 31 images, and facial recognition distances for cross-subject reenactment on 49 images. Existing landmark detection~\cite{Saragih2009} and facial recognition~\cite{dlib09} often fail on images from competing methods, implying higher realism of our results. } \begin{tabular}{@{}lll@{}} \toprule & \begin{tabular}[c]{@{}l@{}}Landmark Alignment \\ (number of images)\end{tabular} & \begin{tabular}[c]{@{}l@{}}Recognition \\ (number of images)\end{tabular} \\ \midrule \citet{Wiles18} & \textbf{10.9 (22)} & 0.52 (42) \\ \citet{wang2018fewshotvid2vid} & 28.19 (24) & 0.49 (45) \\ \citet{Siarohin_2019_NeurIPS} & 11.97 (31) & 0.51 (46) \\ Ours & 20.12 (31) & \textbf{0.40 (49)} \\ \bottomrule \end{tabular} \label{tab:pose} \end{table} All approaches do not share the same cropping method, which makes it difficult to quantitatively evaluate the results. In addition, translation of the head during capture can lead to different illumination conditions. Thus, instead of directly computing errors in the image space, we first detect $66$ facial landmarks~\cite{Saragih2009} on all results, as well as the reference images. We then compute the landmark alignment error, which is the averaged $\ell_2$-distance between the landmarks after 2D Procrustes alignment (including scale). The implementation of ~\citet{Geng2018WarpguidedGF} often fails to generate such large pose edits, so we do not consider this approach in the quantitative evaluation. Due to artifacts, the landmark detector fails on $29$\% images for the approach of~\citet{Wiles18} and on ~$23$\% for~\citet{wang2018fewshotvid2vid}. All our results, as well as those of~\citet{Siarohin_2019_NeurIPS} pass through the detector. This can be considered as a pseudo-metric of realism, since the landmark detector is trained on real portrait images, implying that our results are better than those of~\citet{Wiles18} and~\citet{wang2018fewshotvid2vid}, and on par with~\citet{Siarohin_2019_NeurIPS}. Table~\ref{tab:pose} shows the errors for different methods. The low errors for ~\citet{Wiles18} are possibly due to the landmark detector failing in challenging cases. We obtain only slightly worse results compared to ~\citet{Siarohin_2019_NeurIPS}, even though our method does not have access to ground truth during training. ~\citet{Siarohin_2019_NeurIPS} train on videos allowing for supervised learning. In addition, their edits are at a lower resolution of $256 \times 256$, compared to our image resolutions of $1024 \times 1024$. \paragraph{Cross-identity Reenactment} We also compare to others in cross-identity reenactment, which is closer to our setting of semantically disentangled editing. Here, the image being edited and the reference image have different identities. Fig.~\ref{fig:pose-comparison} shows some qualitative results. The implementation of~\citet{Geng2018WarpguidedGF} does not support this setting. ~\citet{Wiles18} and ~\citet{wang2018fewshotvid2vid} result in similar artifacts as discussed before. Unlike other approaches,~\citet{Siarohin_2019_NeurIPS} uses two driving images in order to edit the input image, where they use the deformations between the two images as input. In the case of self-reenactment, we provide the input image as the first driving image. We do the same here, which leads to the two driving images with different identities. This significantly alters the facial identity in the output image. We also quantitatively evaluate the extent of identity preservation for different methods using a facial recognition tool~\cite{dlib09}, see Table.~\ref{tab:pose}. All methods other than ours do not support semantically disentangled editing. As can be seen in Fig.~\ref{fig:pose-comparison} (bottom), other methods simultaneously change the expressions in addition to the head pose. \paragraph{Interactive User Interface} While all existing approaches need a driving image(s) for editing, we allow for explicit editing, using intuitive controls. We developed an interactive user interface to edit images, see supplemental video. The user can change the head pose using a trackball mouse interface. Spherical harmonic coefficients and blendshape coefficients are changed using keyboard controls. All editing results run at around 5fps on a TITAN X Pascal GPU. \paragraph{Relighting} We compare our relighting results to the single-image relighting approach of~\citet{Zhou_2019_ICCV}, see Fig.~\ref{fig:light-comparison}. Our approach allows for colored illumination changes, as shown in Fig.~\ref{fig:light-main-ne}. Our approach produces higher-quality and more realistic output images. We also quantitatively compare the relighting quality of these approaches in an illumination transfer setting, where the illumination in a reference image is transferred to a given input image. Since we do not have ground truth data available, we compare the results using a network which predicts the illumination from the reference and the relighted results. We use a model-based face autoencoder~\cite{tewari17MoFA}, trained on the VoxCeleb dataset~\cite{Chung18b}. This network predicts a $27$ dimensional spherical harmonics coefficients. We compare the predictions using a scale-invariant $\ell_2$-loss. We obtain higher quality ($0.34$), compared to \citet{Zhou_2019_ICCV} ($0.36$). The numbers are averaged over $100$ relighting results. While the method of~\citet{Zhou_2019_ICCV} is only trained for relighting, our method allows us to also edit the head pose and facial expressions. \new{ \subsection{Generality of the embeddings} \begin{figure}[t] \includegraphics[width=0.5\textwidth]{figures/sequential.jpg} \vspace{-0.6cm} \caption{\new{PIE also allows for sequential editing. We optimize for the StyleGAN embedding using the pose RigNet. We can then use the edited pose results with the RigNets for other semantic components for sequential editing. Images from~\citet{shen2016deep}.} } \label{fig:sequential} \end{figure} \begin{figure}[t] \includegraphics[width=0.5\textwidth]{figures/interfacegan.jpg} \vspace{-0.6cm} \caption{\new{Our embeddings obtain similar quality editing results with the InterFaceGAN~\cite{shen2020interpreting} editing approach. We also notice similar improvements over Image2StyleGAN~ \cite{Abdal_2019_ICCV} embeddings. Images from~\citet{shen2016deep}. }} \label{fig:interfacegan} \end{figure} \paragraph{Sequential Editing} Our method also allows for sequential editing of the different semantic parameters, see Fig.~\ref{fig:sequential}. Here, we optimize for the embedding using the pose RigNet network. After editing the pose, we can use the new embedding as input to the illumination and expression RigNets. Since all three versions of RigNet were trained on the same training data, this still produces plausible results.} \new{ \paragraph{Other StyleGAN editing methods} Our approach obtains a StyleGAN embedding which can be edited using StyleRig. In order to test the generality of these embeddings, we attempt to edit them using InterFaceGAN~\cite{shen2020interpreting}, see Fig.~\ref{fig:interfacegan}. Our improvements over Image2StyleGAN generalize to InterFaceGAN editings. We better preserve the facial identity and produce fewer artifacts. The editing results with InterFaceGAN are of a similar quality to those obtained using StyleRig. However, InterFaceGAN cannot change the scene illumination. } \section{Limitations} \label{sec:limitation} \begin{figure} \includegraphics[width=0.49\textwidth]{figures/limitations-rev.jpg} \vspace{-0.6cm} \caption{ Limitations: Large edits can lead to artifacts. High-frequency texture on the foreground or background is difficult to fit. Our method also cannot handle cluttered backgrounds or occlusions. Images from~\citet{shen2016deep}. } \label{fig:limitations} \end{figure} \begin{figure}[t] \includegraphics[width=0.5\textwidth]{figures/large_edits.png} \vspace{-0.6cm} \caption{\new{Scatterplot of the editing (left) and recognition errors (right), with respect to the magnitude of the desired pose edits for over $2500$ pose editing results. Larger edits lead to both higher editing and recognition errors. } } \label{fig:large} \end{figure} Even though we have demonstrated a large variety of compelling portrait image editing results, there is still room for further improvement of our approach: (1) At the moment, our approach has a limited expressivity, i.e., it does not allow the artifact-free exploration of the whole parameter space of the underlying 3D morphable face model. For example, we cannot change the in-plane rotation of the face or arbitrarily change the lighting conditions. The main limiting factor is the training corpus (FFHQ \cite{Karras2019cvpr}) that has been used to pretrain the StyleGAN-generator, since it does not contain such variations. Due to the same reason, our approach is also not yet suitable for video-based facial reenactment, since the variety of facial expressions in the training corpus is severely limited. This problem could be alleviated by pretraining the generator on a larger and less biased training corpus that covers all dimensions well. (2) Our method only allows for independent control over the semantic parameters, which is important for editing applications. \new{While sequential control is possible, simultaneous control is a more challenging problem.} (3) Our approach does not provide explicit control over the synthesized background. At the moment, the background changes during the edits and does not remain static as it should, since the network has learned correlations between the face and the background. This could potentially be alleviated by learning an explicit foreground-background segmentation and having a consistency loss on the static background region. (4) In challenging cases with large deformations, cluttered backgrounds or occlusions and high-frequency textures, our method can fail to faithfully fit to the input image and preserve editing properties at the same time, see Fig.~\ref{fig:limitations}. In addition, 3D face reconstruction also often fails under occlusions which would lead to incorrect data for our approach. \new{ (5) Larger edits generally correspond to worse results, and can often lead to artifacts, as shown in Fig.~\ref{fig:limitations}. This can also be seen in Fig.~\ref{fig:large}, where larger pose edits correlate with higher editing and facial recognition errors. } (6) Similar to StyleGAN, our approach also sometimes shows droplet-like artifacts. This could be alleviated by switching to a higher quality generator architecture, such as StyleGAN2 \cite{Karras2019stylegan2}, which has been shown to solve this problem. \new{ (7) While we show results for people of different ethnicities, genders and ages, we did not extensively study the biases present in the method. Some of the components used, such as the 3DMM are known to have racial biases~\cite{tewari2017self}. } (8) Our results are not guaranteed to be temporally consistent. While we show temporal editing results (in the supplemental video), our results could be made even more consistent by employing a temporal network architecture and space-time versions of our losses. Nevertheless, our approach, already now, enables the intuitive editing of portrait images at interactive frame rates. \section{Conclusion} \new{We have presented the first approach for embedding portrait photos in the latent space of StyleGAN, which allows for intuitive editing of the head pose, facial expression, and scene illumination}. To this end, we devised a hierarchical optimization scheme that embeds a real portrait image in the latent space of a generative adversarial network, while ensuring the editability of the recovered latent code. Semantic editing is achieved by mapping the control space of a 3D morphable face model to the latent space of the generator. In addition, a novel identity preservation loss enables to better preserve the facial identity. Our approach is a first step towards intuitive and interactive editing of portrait images using a semantic control space akin to computer animation controls. In addition, our approach provides more insights into the inner workings of GANs, since it allows the intuitive and interactive exploration of the space of face images. This can shed light on the biases the model has learned from the employed training corpus. By using high-quality 3D face models, approaches such as StyleRig would produce better quality with more fine-grained control, and thus would further improve our results. Our paper brings the two different domains of 2D and 3D face models together, thus opening the road towards even more interesting edits.
{'timestamp': '2020-09-22T02:18:52', 'yymm': '2009', 'arxiv_id': '2009.09485', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09485'}
arxiv
\subsection*{Supplementary Tables on Experimental Results} \begin{table*}[h!] \caption{30-minute prediction error. The best two results are highlighted in bold, and the top one result is marked with `*'. (TC: Temporal Closeness; TM: Multi-Temporal Factors; SP: Spatial Proximity; SM: Multi-Spatial Factors; SD: Data-driven Spatial Knowledge Extraction)} \label{tab:result-all-30} \begin{center} \resizebox{\textwidth}{!}{ \begin{tabular}{lcccccccccccccc} \toprule & \multicolumn{3}{c}{\textbf{Bikesharing}} & \multicolumn{4}{c}{\textbf{Ridesharing}} & \multicolumn{2}{c}{\textbf{Metro}} & \textbf{EV} & \multicolumn{2}{c}{\textbf{Speed}}& \multicolumn{2}{c}{\textbf{Overall}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-8} \cmidrule(lr){9-10} \cmidrule(lr){11-11} \cmidrule(lr){12-13} \cmidrule(lr){14-15} & \textit{NYC} & \textit{CHI} & \textit{DC} & \textit{XA-gr.} & \textit{CD-gr.} & \textit{XA-di.} & \textit{CD-di.} & \textit{SH} & \textit{CQ} & \textit{BJ} & \textit{LA} & \textit{Bay} & \textit{AvgNRMSE} &\textit{WstNRMSE} \\ \midrule \textbf{Temporal} &&&&&&&&&&&&&&\\ \emph{HM (TC)} & 3.206 & 2.458 & 2.304 & 5.280 & 6.969 & 19.893 & 32.098 & 269.16 & 221.39 & 0.768 & 9.471 & 4.155 & 1.865 & 1.909 \\ \emph{ARIMA (TC)} & 3.178 & 2.428 & 2.228 & 5.035 & 6.618 & 19.253 & 26.131 & 212.01 & 180.53 & 0.755 & 9.230 &3.936 & 1.667 & 3.687 \\ \emph{LSTM (TC) } & 3.018 & 2.493 & 2.212 & 4.950 & 6.444 & 18.150 & 23.075& 195.60 & 104.61 & 0.755 & 7.866 &3.683 & 1.463 & 2.596 \\ \emph{HM (TM)} & 2.686 & 2.230 & 1.956 & 4.239 & 4.851 & 16.281 & 17.264 & 108.59 & 74.55 & 0.864 & 9.560 &3.965 & 1.235 & 1.523 \\ \emph{XGBoost (TM)} & 2.704 & 2.376 & 1.956 & 4.172 & 4.915 & 15.040 & 16.766 &81.82 & 69.50 & 0.686 & 8.298 &3.253 & 1.134& 1.420 \\ \emph{GBRT (TM)} & 2.682 & 2.355 & 1.928 & 4.135 & 4.873 & 16.202 & \textbf{14.924*} & 83.94 & 72.99 & 0.689 & 8.269 &3.370 & 1.139 & 1.491 \\ \emph{TMeta-LSTM-GAL (TM)} & 2.511 & \textbf{2.133*} & 1.927 & 3.847 & 4.678 & \textbf{12.687} & 15.324 &85.19 & 53.18 & 0.686 & 7.436 &3.231 & 1.047 & 1.130 \\ \midrule \textbf{Temporal \& Spatial} &&&&&&&&&&&& \\ \emph{DCRNN (TC+SP)} & 2.618 & 2.246 & 2.118 & 4.529 & 6.258 & 19.487 & 22.945 & 116.15 & 65.72 & 0.757& 8.562 &6.198 & 1.350 & 2.051 \\ \emph{STGCN (TC+SP)} & 2.841 & 2.482 & 2.067 & 3.992 & 5.051 & 14.139 & 17.777 & 91.29 & 58.34 & 0.694 & 7.871 & 3.136 & 1.130 & 1.211 \\ \emph{GMAN (TC+SP)} & 2.792 & 2.336 & \textbf{1.836*} & 4.026 & 5.293 & 13.994 & 20.157 & 97.58 & 51.37 & 0.764 & 7.276& 3.688 & 1.142 & 1.351 \\ \emph{Graph-WaveNet (TC+SP+SD)} & 2.666 & 2.158 & 1.874 & 3.986 & 5.097 & 13.682 & 17.170 & 92.88 & 52.52 & 0.719 & \textbf{6.809*}& 3.589 & 1.092 & 1.232 \\ \emph{ST-ResNet (TM+SP)} & --- & --- & --- & 3.903 & 4.673 & --- & --- & --- &--- & --- & --- & --- & --- & ---\\ \emph{ST-MGCN (TM+SM)}& 2.513 & 2.177 & 1.903 & 3.886 & 4.732 &13.107 & 15.404 & 88.76 & 50.96 & 0.691 & 8.079 &\textbf{3.042} & 1.056 & 1.186 \\ \emph{AGCRN-CDW (TM+SD)} & 2.830 & 2.565 & 2.074 & 3.958 & 4.753 & 16.921 & 17.982 & 238.99 & 131.55 & 0.688 & 8.575& \textbf{3.022*} & 1.440 & 3.171 \\ \emph{STMeta-GCL-GAL (TM+SM)} & \textbf{2.410*} & 2.170 & 1.856 & \textbf{3.808} & 4.650 & \textbf{12.679*} &15.307 & \textbf{75.36*} & \textbf{49.47} & \textbf{0.670}& 7.156 &3.116 & \textbf{1.014*} & \textbf{1.051*} \\ \emph{STMeta-GCL-CON (TM+SM)} & \textbf{2.411} & \textbf{2.133*} & 1.859 & \textbf{3.772*} & \textbf{4.613*} & 12.737 & \textbf{15.227} & 80.69 & 50.01 & \textbf{0.667*}& \textbf{6.889*} &3.204 & \textbf{1.017} & 1.071 \\ \emph{STMeta-DCG-GAL (TM+SM)} & \textbf{2.411} & 2.182 & \textbf{1.852} & 3.833 & \textbf{4.635} & 12.703 & 15.398 & \textbf{77.49} & \textbf{48.96*} & \textbf{0.670}& 7.184 &3.187 & 1.019 & \textbf{1.055} \\ \bottomrule \end{tabular}} \end{center} \end{table*} \begin{table*}[h!] \caption{15-minute prediction error. The best two results are highlighted in bold, and the top one result is marked with `*'. EV dataset is collected in a 30-minute frequency, so we do not have its results for 15-minute. (TC: Temporal Closeness; TM: Multi-Temporal Factors; SP: Spatial Proximity; SM: Multi-Spatial Factors; SD: Data-driven Spatial Knowledge Extraction)} \label{tab:result-all-15} \begin{center} \resizebox{1\textwidth}{!}{ \begin{tabular}{lccccccccccccc} \toprule & \multicolumn{3}{c}{\textbf{Bikesharing}} & \multicolumn{4}{c}{\textbf{Ridesharing}} & \multicolumn{2}{c}{\textbf{Metro}} & \multicolumn{2}{c}{\textbf{Speed}} & \multicolumn{2}{c}{\textbf{Overall}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-8} \cmidrule(lr){9-10} \cmidrule(lr){11-12} \cmidrule(lr){13-14} & \textit{NYC} & \textit{CHI} & \textit{DC} & \textit{XA-gr.} & \textit{CD-gr.} & \textit{XA-di.} & \textit{CD-di.} & \textit{SH} & \textit{CQ} & \textit{LA} & \textit{Bay} & \textit{AvgNRMSE} &\textit{WstNRMSE} \\ \midrule \textbf{Temporal} &&&&&&&&&&&&&\\ \emph{HM (TC)} & 1.903 & 1.756 & 1.655 & 3.155 & 4.050 & 10.022 & 13.530 &93.81 & 76.67 & 7.150 & 2.967 & 1.461 & 2.443 \\ \emph{ARIMA (TC)} & 1.874 & 1.784 & 1.689 & 3.088 & 3.948 & 9.664 & 13.138 &83.54 & 67.11 & 7.028 & 2.869 & 1.394 & 2.138 \\ \emph{LSTM (TC) } & 1.989 & 1.802 & 1.678 & 3.051 & 3.888 & 9.640 & 12.367 & 80.40 & 55.37 & 6.380 & 2.690 & 1.332 & 1.964 \\ \emph{HM (TM)} & 1.892 & 1.668 & 1.555 & 2.828 & 3.347 & 8.883& 10.650 & 49.75 & 45.26 & 8.934 & 3.690 & 1.246 & 1.695 \\ \emph{XGBoost (TM)} & 1.712 & 1.672 & 1.559 & 2.799 & 3.430 & 8.444 & 10.368 & 47.89 & 35.70 & 6.443 & 2.623 & 1.115 & 1.223 \\ \emph{GBRT (TM)} & 1.708 & 1.667 & 1.552 & 2.775 & 3.363 & 8.511 & 10.310 & 44.55 & 33.29 & 6.371 & 2.645 & 1.097 & 1.209 \\ \emph{TMeta-LSTM-GAL (TM)} & 1.818 & 1.623 & 1.540 & 2.917 & 3.286 & 7.932 & 9.815 & 45.88 & 33.34 & 6.156 & 2.544 & 1.086 & \textbf{1.168} \\ \midrule \textbf{Temporal \& Spatial} &&&&&&&&&&&&& \\ \emph{DCRNN (TC+SP)} & 1.712 & 1.718 & 1.594 & 2.889 & 3.743 & 9.584 & 12.197 & 56.00 & 37.07 & 6.440 & 5.322 & 1.285 & 2.194 \\ \emph{STGCN (TC+SP)} & 1.738 & 1.806 & 1.630 & 2.789 & 3.453 & 8.402 & 11.070 & 47.40 & 35.19 & 6.236 & 2.493 & 1.125 & 1.237 \\ \emph{GMAN (TC+SP)} &\textbf{1.632*}& \textbf{1.529}& \textbf{1.355*}& 2.769& 3.520 & 8.503 & 11.598 &49.21 & 36.66 & 6.214 & 3.484 & 1.136 & 1.436 \\ \emph{Graph-WaveNet (TC+SP+SD)} & \textbf{1.644} & \textbf{1.460*} & \textbf{1.357} & 2.764 & 3.442 & 8.066 & 10.571 & 47.84 & 35.04 & \textbf{5.270*} & 2.780 & 1.065 & 1.169 \\ \emph{ST-ResNet (TM+SP)} & --- & --- & --- & 2.686 & 3.314 & --- & --- & --- & --- & --- & --- & --- & --- \\ \emph{ST-MGCN (TM+SM)}& 1.687 & 1.646 & 1.545 & 2.714 & 3.293 & 7.986 & 9.818 & 46.54 & \textbf{32.72} & 6.645 & \textbf{2.426*} & 1.078 & 1.261 \\ \emph{AGCRN-CDW (TM+SD)} & 1.836 & 1.883 & 1.745& 2.722& 3.296 & 9.386 & 10.127 & 77.06 & 46.95 & 6.709 & 2.453 & 1.246 & 1.882 \\ \emph{STMeta-GCL-GAL (TM+SM)} & 1.659 & 1.607 & 1.527 & 2.653 & \textbf{3.244} & \textbf{7.561*} & \textbf{9.695} & \textbf{41.67} & \textbf{31.39*} & \textbf{5.644} & \textbf{2.433} & \textbf{1.031*} & \textbf{1.127*} \\ \emph{STMeta-GCL-CON (TM+SM)} & 1.673 & 1.629 & 1.512 & \textbf{2.637*} & \textbf{3.241*} & 7.791 & \textbf{9.673*} & 43.83 & 38.21 & 5.800 & 2.449 & 1.062 & 1.217 \\ \emph{STMeta-DCG-GAL (TM+SM)} & 1.654 & 1.609 & 1.517 & \textbf{2.648} & 3.254 & \textbf{7.717} & 9.716 & \textbf{40.94*} & 36.90 & 5.788 & 2.446 & \textbf{1.050} & 1.176 \\ \bottomrule \end{tabular}} \end{center} \end{table*} \newpage \subsection*{Dataset Details} The city area and the locations for each dataset are shown in Figure~\ref{fig:cities}. The dataset statistics are listed in Table~\ref{tab:datasets}. 1) \textbf{Bikesharing}. The bikesharing datasets are collected from U.S. open data portals including New York City (NYC, \url{https://www.citibikenyc.com/system-data}), Chicago (CHI, \url{https://www.divvybikes.com/system-data}), and DC (\url{https://www.capitalbikeshare.com/system-data}). The dataset time span for all three cities is more than four years. The total number of historical flow records is around 49 million, 13 million, and 14 million in NYC, Chicago, and DC, respectively, and each record contains the start station, start time, stop station, stop time, etc. We predict the number of bikesharing demands in each station (i.e., the number of bike borrowers). 2) \textbf{Ridesharing}. The ridesharing order datasets are collected from DiDi's open research collaboration project, including the Chinese cities of Xi'an (XA) and Chengdu (CD). The time span is two months, and the total number of the historical ridesharing orders is around 6 and 8 million for Xi'an and Chengdu, respectively. The order records contain start location, start time, end location, and end time. The location information has longitude and latitude. {blue} Note that these open data cover only the central area of Xi'an and Chengdu, instead of the whole city area. We use two different strategies to split regions for prediction. (1) \textit{Grid (gr.)}: \color{black} We divide the area into $16*16$ grids with a size of $0.5km*0.5km$ for each grid, then we predict the number of taxi orders in each grid; (2) \textit{District (di.)}: We split the area according to the administrative district division, and obtain 28 and 25 districts for Xi'an and Chengdu, respectively. \begin{figure*}[b \centering \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/NYC.jpg} \caption{BS: NYC} \label{fig:nyc} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/Bike_Chicago.jpg} \caption{BS: CHI} \label{fig:chicago} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/Bike_DC.jpg} \caption{BS: DC} \label{fig:dc} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/DiDi_Xian_district.jpg} \caption{RS: XA (gr. \& di.)} \label{fig:xian} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/DiDi_Chengdu_district.jpg} \caption{RS: CD (gr. \& di.)} \label{fig:chengdu} \end{subfigure} \\ \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/Shanghai.jpg} \caption{MT: SH} \label{fig:shanghai} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/Metro_Chongqing.jpg} \caption{MT: CQ} \label{fig:chongqing} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/Beijing.jpg} \caption{EV: BJ} \label{fig:beijing} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/la.png} \caption{SP: LA} \label{fig:la} \end{subfigure} \begin{subfigure}[t]{.19\linewidth} \includegraphics[width=1\linewidth]{./figs/bay.png} \caption{SP: Bay} \label{fig:bay} \end{subfigure} \caption{Visualization of each dataset. (BS: bikesharing, RS: ridesharing, MT: metro, EV: electrical vehicle, SP: speed)} \label{fig:cities} \end{figure*} \begin{table*}[b!] \footnotesize \caption{Dataset statistics} \label{tab:datasets} \begin{center} \begin{tabular}{lccccc} \toprule & \multicolumn{3}{c}{\textbf{Bikesharing}} & \multicolumn{2}{c}{\textbf{Ridesharing}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-6} & \textit{NYC} & \textit{CHI} & \textit{DC} & \textit{XA} & \textit{CD} \\ \midrule \textbf{Time span} & 2013.07-2017.09 & 2013.07-2017.09 & 2013.07-2017.09 & 2016.10-2016.11 & 2016.10-2016.11 \\ \textbf{\#Records} & 49,100,694 & 13,130,969 & 13,763,675 & 5,922,961 & 8,439,537 \\ \textbf{\#Locations} & 820 & 585 & 532 & 256 (grid), 28 (district) & 256 (grid), 25 (district) \\ \bottomrule \end{tabular} \\ \vspace{+2em} \begin{tabular}{lccccc} \toprule & \multicolumn{2}{c}{\textbf{Metro}} & \textbf{EV} & \multicolumn{2}{c}{\textbf{Speed}} \\ \cmidrule(lr){2-3} \cmidrule(lr){4-4} \cmidrule(lr){5-6} & \textit{Shanghai} & \textit{Chongqing} & \textit{Beijing} & \textit{LA} & \textit{Bay}\\ \midrule \textbf{Time span} & 2016.07-2016.09 & 2016.08-2017.07 & 2018.03-2018.08 & 2012.03-2012.06 & 2017.01-2017.07\\ \textbf{\#Records} & 333,149,034 & 409,277,117 & 1,272,961 & 34,272 & 52,128\\ \textbf{\#Locations} & 288 & 113 & 629 & 207 & 325\\ \bottomrule \end{tabular} \end{center} \end{table*} 3) \textbf{Metro}. The metro datasets are collected from Shanghai (SH) and Chongqing (CQ). For Shanghai, the time span is three months with around 333 million records; for Chongqing, the time span is one year with around 409 million records. Each metro trip record has the check-in time, check-in station, check-out time, and check-out station. We target predicting the check-in flow amount for all the metro stations. 4) \textbf{Electrical Vehicle (EV)}. The EV charging station usage dataset is collected from Beijing (BJ) in the form of stations' occupation at different time slots, i.e., the number of available and occupied docks. The holder of the stations is one of the largest EV charging station companies in China. The dataset time span is six months and the total number of EV charging station usage records is more than one million. We predict the number of docks in use for each station as this is a demand indicator of the EV charging stations. 5) \textbf{Speed}. The two traffic speed datasets are widely used in STTP research: METR-LA and PEMS-BAY from Los Angeles (LA) County and Bay Area, respectively. In METR-LA, 207 sensors record highway vehicles' speeds for four months; In PEMS-BAY, there are 325 sensors for six months. Each sensor can be seen as a station, and we predict the traffic speed of each sensor at the next time slot. \section{Future Work} \section{Conclusion} In this paper, we propose an analytic framework, called \textit{STAnalytic}, for investigating and comparing existing models for spatio-temporal traffic prediction (STTP). Particularly, with STAnalytic, researchers can investigate and compare what high-level spatial or temporal knowledge is exploited in STTP models, and further justify which model may be generalized to other STTP scenarios. Additionally, we propose a ``model of model'', i.e., the meta-model, called \textit{STMeta}, to flexibly integrate multiple spatio-temporal knowledge identified by STAnalytic from literature. With ten real-life datasets, we have demonstrated that STMeta can generally work well on various scenarios. Lastly, we re-highlight the novel ideas in this research, which may advance the STTP research promisingly: (1) \textit{Re-framing the fundamental thinking paradigm for STTP research}. From the pioneering deep learning-based STTP research in 2017 \cite{zhang2017deep}, the STTP area becomes enthusiastic about adopting novel machine and deep learning techniques. Our research reveals that only putting efforts into techniques may not be enough, and we should put more focus on \textit{which knowledge factors are considered and whether these factors are generalizable}. (2) \textit{Proposing the first (partially) analytical methodology to compare STTP approaches}. Generally, no one machine learning technique can win all the time, i.e., the machine learning `No free lunch' theorem.\footnote{http://www.no-free-lunch.org/} Most prior STTP papers only rely on experiments over certain datasets to verify performance `\textit{empirically}'. However, whether these approaches can work well for un-tested datasets is still questionable to a certain extent. In comparison, with \textit{STAnalytic}, our research proposes perhaps the first methodology to compare STTP approaches (partial) `\textit{analytically}' by considering their considered knowledge factors. \color{blue} Our future work would include: (1) We will continue updating our project website (\url{https://github.com/uctb/UCTB}) to cover new STTP models and datasets. (2) We will extend experimental STTP tasks to multi-step prediction. Given an STTP model, various techniques could be applied to achieve multi-step prediction \cite{taieb2015bias}. It would be interesting to investigate whether (i) there is one single technique that dominantly performs the best, or (ii) different STTP models should cooperate with diverse techniques to achieve the best multi-step prediction performance. \color{black} \section*{Acknowledgment} This work is supported by NSFC Grant no. 61972008, PKU-Baidu Fund Project no. 2019BD005, and Hong Kong RGC Theme-based Research Scheme no. T41-603/20-R. \subsection{Benchmark Implications} \subsubsection{Knowledge vs. Modeling} With the popularity of machine learning, especially deep learning, more and more studies focus on applying novel modeling techniques to the STTP model design, while which temporal or spatial knowledge is considered often lacks detailed analysis. However, our benchmark results indicate that, \textbf{for STTP model design, it is probable that which part of knowledge in consideration is more important than which modeling technique in use}. For example, when we consider complete temporal closeness, daily and weekly periodicity together in the naive historical mean method, \textit{HM (TM)} can significantly outperform the advanced deep modeling technique with inadequate temporal knowledge, \textit{LSTM (TC)} that considers only the temporal closeness in all the benchmark scenarios. In a word, regarding the \textit{knowledge} and \textit{modeling techniques}, we believe that researchers and practitioners should make more efforts on the knowledge part, i.e., considering more carefully about the temporal and spatial knowledge that may be suitable for the target STTP scenario. \subsubsection{Temporal Knowledge vs. Spatial Knowledge} With the benchmark experiments, we can also compare the relative importance between temporal and spatial knowledge in their generalizability. Overall, we find that purely using temporal knowledge can already achieve competitive generalizability performance across different datasets, compared to the approaches with both temporal and spatial knowledge. For example, TMeta-LSTM-GAL's \textit{AvgNRMSE} ranges from 1.047 to 1.086 for 15/30/60-minute prediction experiments. This indicates that the best model with extra spatial knowledge may help improve only $\sim$5\% beyond temporal knowledge. Specifically, for Bikesharing-CHI (30-minute), TMeta-LSTM-GAL performs the best (tie with STMeta-GCL-CON). This reveals that temporal knowledge can dominate the spatio-temporal factors in some cases. In comparison, as shown in Sec.~\ref{exp:spatial_knowledge}, adding spatial knowledge does not always improve the prediction accuracy. For different datasets, which spatial knowledge contributes more varies significantly. Hence, our benchmark results reveal that \textbf{temporal knowledge is more generalizable than spatial knowledge across different STTP scenarios}. \color{black} \subsubsection{Design Guidelines} For the researchers needing to design STTP approaches for their applications, we summarize the following guidelines. \textbf{Guideline 0 (most important)}: Always think deeply about which knowledge should be encoded in the model design before focusing on sophisticated modeling tricks. For a targeted STTP scenario, finding a good set of knowledge suitable for the scenario is a prerequisite and fundamental step before designing model details. \textbf{Guideline 1 (Temporal Knowledge)}: For temporal knowledge, consider temporal closeness, daily and weekly periodicity together. They are perhaps generalized and robust knowledge for various STTP scenarios, as these are fundamental human activity patterns.\footnote{Other scenario-specific temporal knowledge may also be carefully designed. For example, if we predict traffic in special seasons such as the \textit{Spring Festival Travel Season} in China, yearly periodicity is critical.} \textbf{Guideline 2 (Spatial Knowledge)}: For spatial knowledge, it needs more careful consideration. Overall, spatial knowledge is not as generalizable as temporal knowledge, whether it is pre-specified or purely learned from data. \color{black} Hence, instead of simply aggregating all the varieties of spatial knowledge, conduct trial-and-error tests to select the best spatial knowledge combination. \textbf{Guideline 3 (STMeta)}: Our STMeta can be used as a meta-model to integrate multiple temporal and spatial knowledge. With STMeta, researchers only need to consider how to find effective spatial knowledge and encode the knowledge into an inter-location relationship graph. \textbf{Guideline 4 (TMeta)}: To deal with a new STTP problem, we recommend firstly building a TMeta model with only temporal knowledge as an easy-to-implement baseline. This is because temporal knowledge is more generalized than spatial knowledge, and the computation efficiency of TMeta is better than STMeta. \textbf{Guideline 5 (Traditional Models)}: For STTP with short-length time slot settings, the traditional machine learning models with only temporal knowledge, such as GBRT (TM), can be a nice option to trade off the prediction accuracy and computation efficiency. \color{black} \section{Benchmark Experiment} \label{sec:evaluation} \subsection{Benchmark Datasets} Ten datasets are used in the experiment, covering five scenarios including \textbf{bikesharing demand} (New York City, Washington D.C., and Chicago), \textbf{ridesharing order} (Xi'an and Chengdu)\footnote{We conducted ridesharing experiments on both regular (grid) and irregular (administrative district) region-based prediction tasks.}, \textbf{metro flow} (Shanghai and Chongqing), \textbf{electric vehicle charging station usage} (Beijing), and \textbf{traffic speed} (Los Angeles and Bay Area). The length of a time slot has three different settings, 15/30/60 minutes. Our task is to predict the traffic information at the next time slot. \color{blue} Due to the page limitation, dataset details are described in the online appendix. \color{black} \subsection{Experiment Settings} \subsubsection{Hardware and Training Configurations} The configurations of the experiments are as follows: \textbf{Hardware}. Our experiment platform is a computation server with AMD Ryzer 9 3900X CPU (12 cores @ 3.80 GHz), 64 GB RAM, and Nvidia RTX 2080Ti GPU (11GB). \textbf{Train/Validation/Test Split}. We choose the last 10\% duration in each dataset as test data, the 10\% data before the test for validation. The prediction granularity is set to three settings including 15, 30, and 60 minutes for all datasets. \textbf{Training Stopping Criteria}. In training, as different datasets and methods need a varying number of epochs for convergence, we thus leverage \textit{t-test} for the training stopping criteria instead of setting a fixed number of epochs. Particularly, we divide the validation loss of recent epochs (the number of recent epochs is called \textit{early stop patience}) into two halves. For example, if the early stop patience is 100, then the two halves are last 1-50 epochs and last 51-100 epochs. Then, we perform the independent sample t-test on the validation losses of the two halves. When the p-value is smaller than a threshold (we set it to 0.1), the validation losses of the two halves are statistically different, and thus we continue training. The setting of early stop patience is critical, as a small value may stop training too early when the model is still unstable, while a large value may let early stop become useless and lead to overfitting. With trial-and-error, the early stop patience values of the bikesharing, ridesharing, metro, and EV datasets are set to 200, 1000, 400, and 400, respectively, in our experiments. \subsubsection{Spatio-Temporal Factors in Consideration} We consider the following spatio-temporal factors. \textbf{Temporal}: We consider temporal \textit{closeness}, \textit{daily}, and \textit{weekly periodicity} in our experiments. For each temporal factor in STMeta, we build one time-series data. \textbf{Spatial}: For all the datasets, we consider the spatial information including proximity and functionality. For \textit{proximity}, we build a graph by linking locations whose distance is smaller than a threshold. For \textit{functionality}, we use the Pearson correlation of the historical traffic data between two locations to indicate their functionality similarity, and link locations with a large correlation. For ridesharing and bikesharing cases, we also build an \textit{interaction} graph by linking the two locations with frequent interactions (many users go from one location to another) \citep{chai2018bike}; for metro, we construct a \textit{same-line} graph by linking the stations in the same line together. The thresholds for building the graphs are shown in Table~\ref{tab:thresholds}. We select these thresholds so that the average number of connections for each node is around 20--30\% of the total number of nodes, which performs well in our experiments. \begin{table}[t] \caption{Inter-location relationship graph thresholds. For proximity (prox.) graph, it is distance (meter); for functionality (func.) graph, it is Pearson correlation; for interaction (inte.) graph, it is \#records per month.} \label{tab:thresholds} \begin{center} \resizebox{1\textwidth}{!}{ \begin{tabular}{lccccc} \toprule & \textbf{Bikesharing} & \textbf{Ridesharing} & \textbf{Metro} & \textbf{EV} & \textbf{Speed} \\ \midrule \textbf{Prox.} & 1,000 & 7,500 & 5,000 & 1,000 & 5,500\\ \textbf{Func.} & 0 & 0.65 & 0.35 & 0.1 & 0.73 (LA)/0.63 (Bay) \\ \textbf{Inte.} & 40 & 30 & --- & --- & --- \\ \bottomrule \end{tabular}} \end{center} \end{table} \subsubsection{STMeta Implementations} As shown in Table~\ref{tab:stmeta-version}, we implement three variants of STMeta by changing the techniques used in spatio-temporal modeling and aggregation units (see Section~\ref{sub:STMeta_details}). Specifically, GCLSTM and DCGRU both contain one layer and 64 hidden units; GAL is set to include two heads and 64 hidden units. After temporal and spatial aggregations, we further stack two dense layers with 64 hidden units to generate the prediction output. We choose the optimization algorithm as ADAM \citep{kingma2014adam}; the learning rate is 1e-5. \color{black} We also implement TMeta (only temporal factors) with LSTM~\citep{gers1999learning}. \subsubsection{Benchmark Approaches} We implement a number of benchmark approaches in the literature. These approaches fall into two types, the first only considers the temporal factors and the second considers both temporal and spatial factors. Approaches with \textbf{only temporal} factors: \begin{itemize} \item \textbf{HM} (Historical Mean) predicts the traffic according to the mean value of the historical records. We implement two variants of the HM algorithms. The first considers only the recent time slots (closeness), denoted as \textit{HM (TC)}. \color{black} The second averages recent time slots (closeness), the historical records in the same time of last day (daily periodicity) and last week (weekly periodicity), thus considering multiple temporal factors, denoted as \textit{HM (TM)}. \item \textbf{ARIMA} \citep{williams2003modeling} is a widely used time series prediction model, which mainly considers temporal closeness. \item \textbf{GBRT} (Gradient Boosted Regression Trees) \citep{li2015traffic} can be applied to predict the traffic for each location. Our GBRT implementation uses historical traffic data as features, not only from recent time slots, but also from last day and last week. Hence, GBRT considers multiple temporal factors. \item \textbf{XGBoost} \citep{chen2016xgboost} is similar to GBRT, another widely used tree-based machine learning model. \item \textbf{LSTM} \cite{ma2015long} neural networks take the recent time-slot traffic data as inputs (closeness) and predict the future. \end{itemize} Approaches with \textbf{both temporal and spatial} factors: \begin{itemize} \item \textbf{ST-ResNet} \cite{zhang2017deep} leverages residual convolution networks to consider spatial proximity and also considers temporal closeness, daily and weekly periodicity simultaneously. Note that ST-ResNet can only work for grid-based traffic prediction (ridesharing). \item \textbf{DCRNN} \cite{li2017diffusion} combines diffusion convolution and recurrent networks for capturing spatio-temporal features. The original DCRNN model only considers the temporal closeness and the spatial proximity graph. \item \textbf{STGCN} \cite{yu2018spatio} combines graph convolution and gated convolution units to catch spatial and temporal features, respectively. It considers the temporal closeness and spatial proximity graph. \item \textbf{GMAN} \cite{zheng2020gman} leverages attention mechanisms to model both temporal closeness and spatial proximity patterns for traffic prediction. \item \textbf{Graph-WaveNet} \cite{wu2019graph} designs a data-driven graph convolution method for adaptively learning spatial knowledge in addition to proximity. For temporal knowledge, it considers only recent traffic data. \color{black} \item \textbf{ST-MGCN} \cite{geng2019spatiotemporal} captures multiple spatial relations with graph convolutions. It also considers temporal closeness, daily and weekly periodicity. Not like STMeta, ST-MGCN concatenates the inputs regarding different temporal factors into one time-series data. \item \textbf{ARGCN-CDW} purely relies on data-driven graph convolution methods for extracting spatial knowledge \cite{bai2020adaptive}. Meanwhile, it considers temporal closeness, daily and weekly periodicity same as ST-MGCN.\footnote{The original ARGCN \cite{bai2020adaptive} considers only temporal closeness, but it is hard to converge in our experiments. By modifying its input as the time-series data combined by closeness, daily and weekly periodicity (same as ST-MGCN), the performance of ARGCN is much improved. We denote this model as ARGCN-CDW.} \color{black} \end{itemize} \begin{table}[t] \caption{STMeta and TMeta implementations. (ST-Unit: Spatio-Temporal Unit; TA-Unit: Temporal Aggregation Unit; SA-Unit: Spatial Aggregation Unit)} \footnotesize \label{tab:stmeta-version} \vspace{-1em} \begin{center} \resizebox{.8\textwidth}{!}{ \begin{tabular}{lccc} \toprule & \textit{ST Unit} & \textit{TA Unit} & \textit{SA Unit}\\ \midrule \textbf{STMeta-GCL-GAL} & GCLSTM & GAL & GAL \\ \textbf{STMeta-GCL-CON} & GCLSTM & Concatenation & GAL \\ \textbf{STMeta-DCG-GAL} & DCGRU & GAL & GAL \\ \midrule \textbf{TMeta-LSTM-GAL} & LSTM & GAL & --- \\ \bottomrule \end{tabular}} \end{center} \end{table} \begin{table*}[t] \caption{60-minute prediction error. The best two results are highlighted in bold, and the top one result is marked with `*'. (TC: Temporal Closeness; TM: Multi-Temporal Factors; SP: Spatial Proximity; SM: Multi-Spatial Factors; SD: Data-driven Spatial Knowledge Extraction)} \label{tab:result-all-60} \begin{center} \resizebox{\textwidth}{!}{ \begin{tabular}{lcccccccccccccc} \toprule & \multicolumn{3}{c}{\textbf{Bikesharing}} & \multicolumn{4}{c}{\textbf{Ridesharing}} & \multicolumn{2}{c}{\textbf{Metro}} & \textbf{EV} & \multicolumn{2}{c}{\textbf{Speed}} & \multicolumn{2}{c}{\textbf{Overall}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-8} \cmidrule(lr){9-10} \cmidrule(lr){11-11} \cmidrule(lr){12-13} \cmidrule(lr){14-15} & \textit{NYC} & \textit{CHI} & \textit{DC} & \textit{XA-gr.} & \textit{CD-gr.} & \textit{XA-di.} & \textit{CD-di.} & \textit{SH} & \textit{CQ} & \textit{BJ} & \textit{LA} & \textit{Bay} & \textit{AvgNRMSE} &\textit{WstNRMSE}\\ \midrule \textbf{Temporal} &&&&&&&&&&&&&&\\ \emph{HM (TC)} &5.814 & 4.143 & 3.485 & 10.136 & 14.145 &52.610 & 74.212 & 824.94 & 673.55 & 1.178 & 12.303& 5.779 & 2.597 & 7.106 \\ \emph{ARIMA (TC)} & 5.289 & 3.744 & 3.183 & 9.475 & 13.259 &47.794 & 65.725 & 676.79 & 578.19 & 0.982 & 11.739 &5.670 & 2.297 &6.100\\ \emph{LSTM (TC) } & 5.167 & 3.721 & 3.234 & 9.830 & 13.483 &43.962 & 51.355 & 506.07 & 322.81 & 0.999 & 10.083 &4.777 & 1.882 & 3.535 \\ \emph{HM (TM)} & 3.992 & 3.104 & 2.632 & 6.186 & 7.512 & 27.821 & 30.917 & 172.55 & 119.86 & 1.016 & 10.727 &4.018 & 1.180 & 1.265 \\ \emph{XGBoost (TM)} & 4.102 & 3.003 & 2.643 & 6.733 & 7.592 & 27.745 & 30.347 & 160.38 & 117.05 & 0.834 & 10.299 &3.703& 1.146 & 1.235 \\ \emph{GBRT (TM)} & 4.039 & 2.984 & 2.611 & 6.446 & 7.511 & 25.654 & 27.591 & 154.29 & 113.92 & 0.828 & 10.013 &3.704& 1.111 & 1.202\\ \emph{TMeta-LSTM-GAL (TM)} & 3.739 & 2.840 & 2.557 & \textbf{5.843} & 6.949 &\textbf{23.024} & \textbf{25.264*} & 163.31 & 102.86 & 0.840 & \textbf{8.670*} &3.616& 1.047 &1.141\\ \midrule \textbf{Temporal \& Spatial} &&&&&&&&&&&& \\ \emph{DCRNN (TC+SP)} & 4.187 & 3.081 & 3.016 & 8.203 & 11.444 & 39.028 & 48.393 & 340.25 & 122.31 & 0.989 & 11.121 &6.920& 1.544 &2.376\\ \emph{STGCN (TC+SP)} & 3.895 & 2.989 & 2.597 & 6.150 & 7.710 & 23.916 & 28.940 & 187.98 & 106.16 & 0.859 & 10.688 & 3.472 & 1.121 & 1.313 \\ \emph{GMAN (TC+SP)} & 4.251 & 2.875 & 2.530 & 7.099 & 13.351 & 28.086 & 30.741 & 193.39 & 117.52 & 0.949 & 10.012 & 3.846 & 1.251 & 1.947 \\ \emph{Graph-WaveNet (TC+SP+SD)} & 3.863 & 2.812 & \textbf{2.403*} & 6.541 & 8.162 & 24.101 & 29.406 & 186.82 & 102.75 & 0.930 & 9.463 & 4.135 & 1.129 & 1.305 \\ \emph{ST-ResNet (TM+SP)} & --- & --- & --- & 6.075 & 7.155 & --- & --- & --- & --- & --- & --- &--- & --- & ---\\ \emph{ST-MGCN (TM+SM)}& 3.723 & 2.904 & 2.518 & 5.878 & 7.067 & 30.413& 26.014 & 159.52 & 104.87 & 0.827 & 10.798 &\textbf{3.486}& 1.094&1.324\\ \emph{AGCRN-CDW (TM+SD)} & 3.795 & 2.935 & 2.580 & 8.835 & 10.275 & 35.801 & 38.093 & 658.12 & 287.41 & 0.844 & 10.728 & \textbf{3.381*} & 1.688 & 4.596 \\ \emph{STMeta-GCL-GAL (TM+SM)} & \textbf{3.518} & \textbf{2.695} & 2.405 & 5.871 & \textbf{6.858*} & 24.127 & 25.669 & 153.17 & \textbf{97.87} & 0.831 & \textbf{8.834} &3.514& \textbf{1.024} &\textbf{1.070*}\\ \emph{STMeta-GCL-CON (TM+SM)} & \textbf{3.507*} & 2.739 & \textbf{2.404} & \textbf{5.829*} & \textbf{6.873} & 23.244 & \textbf{25.296} & \textbf{149.05} & 106.41 & \textbf{0.807} & 9.147 &3.552 & 1.027 & 1.123 \\ \emph{STMeta-DCG-GAL (TM+SM)} & 3.521 & \textbf{2.652*} & 2.423 & 5.908 & 6.904 & \textbf{22.979*} & 27.217 &\textbf{143.18*} & \textbf{94.78*} & \textbf{0.803*}& 8.993 &3.500 & \textbf{1.015*} & \textbf{1.077} \\ \bottomrule \end{tabular}} \end{center} \end{table*} The hyperparameters of the above benchmark approaches follow the default settings as their original papers.\footnote{ We have also tested some other approaches in Table~\ref{tab:existing_work}, such as ASTGCN \cite{guo2019attention} and STSGCN \cite{song2020spatial}; however, they are hard to converge under certain experiment scenarios.} \color{black} \subsubsection{Metric} We use RMSE (root mean square error) to report the prediction error, as this is the most widely used metric in almost all the STTP research \cite{zhang2017deep,liang2018geoman,geng2019spatiotemporal,chai2018bike,Zhang0QLYL18}.\footnote{We have also tested methods in MAE (Mean Absolute Error), and the results are consistent with RMSE. For clarity, we just report RMSE.} We also compute two aggregation scores to indicate the overall performance (i.e., generalizability) of an approach $x \in \mathcal X$ ($\mathcal X$ is the set of all approaches) among all the datasets $\mathcal D$: \begin{equation} \textit{AvgNRMSE}_x = avg_{d\in \mathcal D}(\frac{RMSE_{x, d}}{min_{x'\in \mathcal X}(RMSE_{x',d})}) \end{equation} where $RMSE_{x,d}$ is the RMSE of approach $x$ in dataset $d$. The meaning of the score is the average of the normalized RMSE (normalized by the smallest RMSE for every dataset $d$). Ideally, if an approach can perform the best among all datasets, then \textit{AvgNRMSE} is $1$. \begin{equation} \textit{WstNRMSE}_x = max_{d\in \mathcal D}(\frac{RMSE_{x, d}}{min_{x'\in \mathcal X}(RMSE_{x',d})}) \end{equation} If a method is generalizable, its \textit{WstNRMSE} should also be close to $1$, i.e., in the worst dataset, its performance is still near the best one. \subsection{Experiment Questions} We aim to answer the following questions by experiments. \textbf{Q1. Model Generalizability}. \textit{Can STMeta demonstrate better generalizability than state-of-the-art models?} We deem that a model is more generalizable, if it can achieving lower AvgNRMSE and WstNRMSE. \textbf{Q2. Knowledge Generalizability}. \textit{Which temporal or spatial knowledge factors are more generalizable across different datasets?} A generalizable factor means that a model considering the factor would exhibit significantly lower AvgNRMSE and WstNRMSE than a model not considering the factor. \subsection{Model Generalizability Results} Table~\ref{tab:result-all-60}, \ref{tab:result-all-30} and \ref{tab:result-all-15} (Appendix) show our evaluation results for the 60, 30, and 15-minute time slots. For each approach, we mark in the bracket which temporal and/or spatial factors are considered following STAnalytic. The best two results for each dataset are highlighted in bold. First, we highlight the generalization effectiveness of our STMeta variants over different datasets. From the overall results in Table~\ref{tab:result-all-60}, \ref{tab:result-all-30} and \ref{tab:result-all-15}, we can see that the three different variants of STMeta are usually ranked among the top methods. Particularly, the top method of the three experiments with different time slot lengths is always \textit{STMeta} variants regarding both \textit{AvgNRMSE} and \textit{WstNRMSE}, which verifies the better generalizability of our proposed meta-model STMeta compared to other benchmark approaches. This indicates that our STMeta has the potential to serve as a generalizable STTP meta-model to guide future approach design for a variety of scenarios. Regarding different variants, which one is better depends on the application scenario. This also matches our expectation as we believe that the concrete component implementations in STMeta can have alternative choices (e.g., GCLSTM or DCGRU for the spatio-temporal modeling unit) depending on the scenarios. In the future, if new modeling techniques are proposed, it is possible to implement new STMeta variants. We also investigate the generalizability of benchmark modeling techniques. To reduce the impact of knowledge variation on our analysis, we compare different approaches with the same spatial and temporal knowledge factors. For `TM' approaches, we find that their overall performance \textit{AvgNRMSE} ranges from 1.047/1.047/1.086 (TMeta-LSTM-GAL (TM)) to 1.180/1.235/1.246 (HM (TM)) for 60/30/15-minute time slot. On one hand, this validates that advanced modeling techniques can actually improve the model generalizability toward diverse datasets (e.g., state-of-the-art deep learning techniques of TMeta compared to the naive historical mean of HM). On the other hand, it reveals that the improvement brought by modeling technique is around 10-20\%, much smaller than the improvement of the extra temporal knowledge (e.g., HM (TC) is worse than HM (TM) by more than 100\% in the 60-min experiment). \begin{table*}[t] \footnotesize \caption{Temporal knowledge evaluation (60-min). The model is STMeta-DCGRU-GAL. The best result is in bold. The training/inference time is shown in the brackets. \color{black} (C: Closeness, D: Daily Periodicity, W: Weekly Periodicity)} \label{tab:result-temporal} \begin{center} \begin{tabular}{lccccc} \toprule & \multicolumn{1}{c}{\textbf{Bikesharing}} & \multicolumn{1}{c}{\textbf{Ridesharing}} & \multicolumn{1}{c}{\textbf{Metro}} & \textbf{EV} & \textbf{Speed}\\ & \textit{NYC} & \textit{CD-grid} & \textit{SH} & \textit{BJ} & \textit{LA}\\ \midrule \emph{C}&4.205 (14.22h/10.53s)&8.380 (6.72h/0.11s)&328.81 (7.12h/0.12s)&3.423 (5.09h/0.20s)&10.672 (2.16h/0.19s)\\ \emph{CD}&3.631 (28.37h/21.54s)&7.517 (9.23h/0.22s)&\textbf{140.67} (10.47h/0.24s) & 0.809 (7.22h/0.40s) & 10.117 (3.35h/0.35s)\\ \emph{CDW}&\textbf{3.521} (34.46h/27.74s)&\textbf{6.920} (10.03h/0.28s)&143.18 (12.46h/0.31s)&\textbf{0.803} (7.93h/0.52s) & \textbf{8.993} (3.72h/0.45s)\\ \bottomrule \end{tabular} \end{center} \end{table*} Another interesting observation is the traditional machine learning model GBRT performs competitively to the state-of-the-art deep learning models in the 15-minute experiment (Table~\ref{tab:result-all-15}). In particular, \textit{AvgNRMSE} of GBRT in 15-minute prediction is 1.097 (i.e., GBRT is only worse by 9.7\% compared to the best model on average). \color{blue} More specifically, in the ridesharing-CD (grid) experiment, GBRT is worse than the best model only by 3.8\%, and outperforms many deep models such as Graph-WaveNet and STGCN. \color{black} Considering the computation resources (computation time), we deem that for STTP with short-length time slots, classical machine learning models may be computation-efficient, i.e., getting relatively good accuracy with significantly lower computation resources, than deep learning methods. This is perhaps because the traffic data relations between continuous time slots become more obvious with the decrease of time slot duration, and classical methods can already capture the relations well. In addition, we find that the data-driven spatial knowledge modeling (the methods with `SD') performs not stable across different datasets. For instance, AGCRN-CDW (TM+SD) has achieved the smallest prediction error in Speed-Bay (60-minute); however, it performs very poorly in the Metro scenarios (60-minute). Occurring such a large difference is perhaps because extracting spatial knowledge purely from data is of distinct difficulties between datasets. While we believe that data-driven spatial pattern extraction is promising, adopting it in practice still needs caution, as the performance is highly application-dependent. \color{black} In summary, by comparing STMeta to various benchmark approaches, we validate its superiority on the generalizable effectiveness over different datasets. Meanwhile, for STTP with short-length time slots, traditional machine learning models, such as GBRT, can also be a good selection thanks to its high computation efficiency and relatively good accuracy. \subsection{Knowledge Generalizability Results} Here, we analyze the results to see how various knowledge factors impact the prediction. Overall, we observe that the best series of approaches regarding knowledge are the ones that consider the largest number of knowledge factors, i.e., the approaches marked as `\textit{TM+SM}' (multi-temporal and multi-spatial factors). This in fact supports the hypothesis that we have made when we analyze the existing research approaches with STAnalytic (Section~\ref{sub:analyze_existing}), i.e., \textit{the more knowledge, the better prediction}. Next, we present a detailed analysis regarding various temporal and spatial factors. \subsubsection{Temporal Knowledge} Regarding the temporal knowledge factors, we first investigate the prediction performance of the `temporal' approaches in Table~\ref{tab:result-all-60}/\ref{tab:result-all-30}/\ref{tab:result-all-15}. According to the results, considering more temporal knowledge would improve prediction significantly. For example, in 60-minute prediction (Table~\ref{tab:result-all-60}), \textit{HM~(TM)}'s \textit{AvgNRMSE} = 1.190; in comparison, \textit{HM~(TC)}'s \textit{AvgNRMSE} = 2.597, which is much worse than \textit{HM (TM)}. \color{black} This reveals involving multiple temporal factors indeed enhances the prediction accuracy. To further elaborate on the impacts of different temporal factors, we conduct an experiment with STMeta by removing certain temporal factors. The results are shown in Table~\ref{tab:result-temporal}. We observe that adding periodicity can always enhance the prediction accuracy as human mobility has intrinsic regularity \cite{song2010limits}; meanwhile, the training and inference time also increases a bit. \color{black} Generally, adding both daily and weekly periodicity can bring much improvement, while adding only daily periodicity might be the best (metro, Shanghai). Hence, the temporal periodicity knowledge is often generalizable, while which periodicity performs the best depends on applications. Besides, with the decrease of the time slot length, the performance gap between `TC' and `TM' methods becomes smaller, indicating that the temporal closeness plays a more important role. For example, in the 60-min experiment, \textit{AvgNRMSE} of LSTM (TC) and TMeta-LSTM-GAL (TM) are 1.882 and 1.047, respectively, leading to a gap of 0.835; in the 15-min experiment, \textit{AvgNRMSE} of LSTM (TC) and TMeta-LSTM-GAL (TM) are 1.332 and 1.086, respectively, indicating a gap of only 0.246. \color{black} This observation signifies that the \textit{temporal closeness} factor becomes more important when the time slot length is reduced. This also fits our expectation --- the correlation between the next 15-minute traffic data and the recent 15-minute should be higher than the correlation between the next 60-minute traffic data and the recent 60-minute, as the time difference of the two continuous slots in the former case is much smaller than the latter case. \subsubsection{Spatial Knowledge} \label{exp:spatial_knowledge} \begin{table*}[t] \footnotesize \caption{Spatial knowledge evaluation (60-min). The model is STMeta-DCGRU-GAL. The best result is in bold. The training/inference time is shown in the brackets. \color{black} (F:Function, P:Proximity, I: Interaction, S: Same-Line)} \label{tab:result-spatial} \begin{center} \begin{tabular}{lccccc} \toprule & \multicolumn{1}{c}{\textbf{Bikesharing}} & \multicolumn{1}{c}{\textbf{Ridesharing}} & \multicolumn{1}{c}{\textbf{Metro}} & \textbf{EV} & \textbf{Speed}\\ & \textit{NYC} & \textit{CD-grid} & \textit{SH} & \textit{BJ} & \textit{LA}\\ \midrule \emph{F}&\textbf{3.477} (6.40h/5.03s)&\textbf{6.878} (2.62h/0.06s)&148.25 (2.97h/0.06s)&0.813 (2.93h/0.18s)&10.149 (1.64h/0.19s)\\ \emph{P}&3.509 (6.48h/5.02s)&6.914 (2.60h/0.07s)&153.98 (2.96h/0.06s) & 0.835 (2.93h/0.18s)&10.168 (1.65h/0.19s)\\ \emph{I/S}&3.543 (6.40h/5.01s)&6.879 (2.60h/0.06s)&151.38 (2.98h/0.06s)&-&-\\ \midrule \emph{Full}&3.521 (34.46h/27.74s)&6.904 (10.03h/0.28s)&\textbf{143.18} (12.46h/0.31s)&\textbf{0.803} (7.93h/0.52s)&\textbf{8.993} (3.72h/0.45s)\\ \bottomrule \end{tabular} \end{center} \end{table*} Similarly, to analyze how spatial knowledge impacts prediction, we remove some spatial factors from \textit{STMeta-DCG-GAL} and then compare it to the original \textit{STMeta-DCG-GAL} (with full spatial knowledge). In particular, for the 60-minute prediction, we implement some variants of \textit{STMeta-DCG-GAL} with partial spatial information: one of the proximity, functionality, and interaction/same-line graphs. Due to the page limitation, we only show one dataset for each scenario. Results are shown in Table~\ref{tab:result-spatial}. First, among different spatial graphs, the functionality graph performs always the best. In this regard, we deem that it is more generalizable across different datasets. Besides, the metro, EV, and speed scenarios benefit from the integration of multiple spatial knowledge more significantly than the bikesharing and ridesharing scenarios. For example, in ridesharing, STMeta with full spatial knowledge perform worse than the approach with only one type of spatial knowledge in Chengdu; moreover, training STMeta with full spatial knowledge (i.e., three graphs) costs more than 5 times of the computation hours compared with STMeta with only one spatial graph. Hence, if we blindly add a variety of spatial knowledge graphs into a model, it may degrade both the model effectiveness and efficiency. \color{black} \textbf{This inspires that, while generally considering spatial knowledge can improve prediction, selecting and integrating which specific spatial knowledge should be carefully determined for a specific application}. Otherwise, it is possible that the overall prediction performance is degraded by adding more spatial knowledge. \section{STAnalytic: Analytic Framework We propose an analytic framework, called \textit{STAnalytic}, with which we can investigate and compare different application-driven STTP models and justify their generalizability. \subsection{Framework Overview} Our framework \textit{STAnalytic} is illustrated in Figure~\ref{fig:framework}. Overall, the framework considers STTP approaches mainly from two aspects: \textit{temporal} and \textit{spatial} factors by answering the following research questions. \textbf{RQ1}: \textit{Does the approach consider temporal and/or spatial factors in predicting traffic?} \textbf{RQ2}: \textit{What temporal knowledge factors have been taken into building the approach? For each considered temporal knowledge factor, how does the approach model it?} \textbf{RQ3}: \textit{What spatial knowledge factors have been taken into building the approach? For each considered spatial knowledge factor, how does the approach model it?} Regarding RQ1, the STTP approaches based on traditional time-series analysis techniques, such as autoregressive integrated moving average (ARIMA), consider only temporal factors \citep{hamilton1994time,hamed1995short}. Other studies leveraging more advanced temporal learning techniques, such as long short-term memory (LSTM) \cite{ma2015long,tian2015predicting}, also belong to this temporal-factor-only category. In comparison, more recent STTP approaches mostly consider both temporal and spatial factors explicitly into the model design, especially with state-of-the-art deep learning techniques such as convolution networks \citep{zhang2017deep,chai2018bike}. Regarding RQ2 and RQ3, it needs more effort to answer for an STTP approach. To help answer RQ2 and RQ3, the next subsection will review and summarize common temporal and spatial factors that have been considered in the STTP literature. Then, when analyzing a new STTP approach, we can quickly check `\textit{whether the temporal and spatial factors in consideration belong to our summarized ones}' and `\textit{whether there is new temporal or spatial knowledge beyond our summarized ones}', so as to answer RQ2 and RQ3. While spatial and temporal factors are the foundation for traffic prediction, other \textit{external factors}, e.g., weather \cite{koesdwiady2016improving} and social events \cite{ni2016forecasting}, may impact traffic patterns prominently, leading to the fourth research question. \textbf{RQ4:} \textit{What external factors have been considered in predicting traffic?} \subsection{Temporal and Spatial Knowledge Factors} \label{sub:st_factors} To help answer RQ2 and RQ3, we investigate the temporal and spatial knowledge that has been well studied in the literature. \subsubsection{Temporal Knowledge Factors and Modeling} Modeling temporal factors has been well studied in STTP, which can be traced back to a very classical research area, \textit{time-series analysis}~\citep{hamilton1994time}. In general, most time series analysis techniques can be applied to STTP; for clarity, we just highlight some most widely used temporal knowledge and its related techniques. The most widely considered temporal knowledge includes temporal closeness, daily periodicity, and weekly periodicity: \textbf{Temporal Closeness}. One of the most intuitive ways to predict future traffic data is checking back the traffic information of the recent time slots, which is called \textit{closeness}. In other words, for the models considering closeness (in fact, almost all the models consider closeness), they would take the recent a few $k$ time slots' traffic data as input and then predicts the future. In literature, many classical statistical methods have been proposed to extract meaningful closeness patterns from the time-series data. The most famous model is perhaps ARIMA \citep{hamed1995short}. In brief, ARIMA models the traffic of a future slot as a linear combination of the flow of recent slots. As non-linear relations are hard to find with ARIMA, recently researchers started using non-linear models such as tree-based models (e.g., XGBoost~\cite{chen2016xgboost}) and recurrent neural networks (e.g., LSTM~\cite{gers1999learning,ma2015long}). Note that, regardless of the modeling techniques, if an approach takes recent a few time slots' traffic data as input, then its temporal consideration factor is closeness. \textbf{Daily Periodicity}. As human activity has high regularity, the traffic dynamics, whatever the specific application, also often has obvious patterns. The daily periodicity is one of the most significant patterns. For example, on workdays around 8:00 a.m., people get out of home and go to workplaces, leading to the morning rush hours when many types of traffic data (metro, taxis, buses, etc.) will go from the residential area to the working area. In general, if a model considers daily periodicity, it will put the traffic data of previous days at the same time (e.g., the same hour) into the input. To model the daily periodicity, the \textit{seasonal} component can be added to ARIMA \citep{williams1998urban}. Another widely used method is selecting the historical traffic data at the same daily time slot during the last few days into the input, and then use non-linear models to extract daily patterns \citep{zhang2017deep}. \textbf{Weekly Periodicity}. Similar to daily periodicity, the traffic data of certain scenarios may follow weekly periodicity. As an example, Saturday's traffic will usually be much more similar to last Saturday instead of Friday. In practice, the difference of modeling weekly periodicity compared to daily periodicity is the temporal lags. For example, suppose we want to predict the traffic data of `\textit{8:00-8:30 a.m. Oct. 15}'. By considering daily periodicity, we take the traffic data of `\textit{8:00-8:30 a.m. Oct. 14}' as input; in comparison, by considering weekly periodicity, we take that of `\textit{8:00-8:30 a.m. Oct. 8}' as input. Apart from the different-lag inputs, the modeling techniques are almost the same for weekly and daily periodicity, such as seasonal ARIMA \citep{williams2003modeling}. \subsubsection{Spatial Knowledge Factors and Modeling} Compared to temporal knowledge modeling, spatial knowledge modeling recently attracts more interest from researchers as it is more complicated and heterogeneous. For different scenarios, the spatial knowledge may also be different from each other. \textbf{Geographic Proximity}. `\textit{Everything is related to everything else. But near things are more related than distant things.}', pointed by Waldo R. Tobler in 1969, has been extensively recognized as the `First Law of Geography'. It clearly highlights the importance of proximity in geographic studies. To model geographic proximity in STTP, one widely used method is: for a target location, firstly select the time-series traffic data in near locations into the input, and then leverage methods such as K nearest neighbors to aggregate near locations' knowledge. More recently, convolution neural networks (CNN) have been widely used to extract geographic proximity patterns, especially for grid-based traffic prediction problems \cite{zhang2017deep}. CNN is good at this because it learns a small $m \times n$ parameter matrix (e.g., $3\times3$ or $5\times5$) that can well aggregate a (grid) location's data together with its nearby (grid) locations. As CNN can be stacked to a very deep structure (e.g., by ResNet~\cite{zhang2017deep}), then the geographic proximity pattern can be extracted at different levels. \begin{table*}[t] \scriptsize \caption{Analysis of representative STTP approaches with STAnalytic.} \label{tab:existing_work} \begin{tabular}{@{}llllll@{}} \toprule & \textbf{Model Name} & \textbf{RQ2: Temporal} & \textbf{RQ3: Spaital} & \textbf{RQ4: External} & \textbf{Modeling Technique (T: Temporal, S: Spatial)} \\ \midrule \textbf{Temporal Only} &&&& \\ \textit{Hamed et al. 1995} \cite{hamed1995short} & --- & close. & --- & none & ARIMA (T) \\ \textit{Williams et al. 1998} \cite{williams1998urban} & --- & close., daily & --- & none & Seasonal ARIMA (T) \\ \textit{Williams et al. 2003} \cite{williams2003modeling} & --- & close., weekly & --- & none & Seasonal ARIMA (T) \\ \textit{ Ma et al. 2015} \cite{ma2015long} & --- & close. & ---& none & LSTM (T) \\ \midrule \textbf{Temporal \& Spatial} &&&& \\ \textit{Zhang et al. 2017} \cite{zhang2017deep} & ST-ResNet & close., daily, weekly & prox. & weather, holiday& Residual Convolution (T, S) \\ \textit{Liang et al. 2018} \cite{liang2018geoman} & GeoMAN & close. & func. & none & LSTM (T), Attention (S) \\ \textit{Li et al. 2018} \cite{li2017diffusion} & DCRNN & close. & prox. & none& GRU (T), Diffusion Convolution (S) \\ \textit{Yu et al. 2018} \cite{yu2018spatio} & STGCN & close. & prox. & none& Gated Convolution (T), Graph Convolution (S) \\ \textit{Geng et al. 2019} \cite{geng2019spatiotemporal} & ST-MGCN & close., daily, weekly & prox., func., conn. & none & GRU (T), Graph Convolution (S) \\ \textit{Guo et al. 2019} \cite{guo2019attention} & ASTGCN & close., daily, weekly & prox. & none & Attention \& Graph Convolution (T, S) \\ \textit{Wu et al. 2019} \cite{wu2019graph} & Graph-WaveNet & close. & prox., data-driven & none & Gated Unit \& Dilated Convolution (T), Graph Convolution (S) \\ \textit{Bai et al. 2020} \cite{bai2020adaptive} & AGCRN & close. & data-driven & none & GRU (T), Graph Convolution (S) \\ \textit{Zheng et al. 2020} \cite{zheng2020gman} & GMAN & close. & prox. & none & Attention (T, S) \\ \textit{Song et al. 2020} \cite{song2020spatial} & STSGCN & close. & prox. & none & Graph Convolution (T, S) \\ \textit{Yi and Park 2020} \cite{yi2020hypergraph} & HGC-RNN & close. & func. & holiday & GRU (T), Hypergraph Convolution (S) \\ \bottomrule \end{tabular} \end{table*} \textbf{Location Functionality}. Functionality is one fundamental character of a location. For example, some locations are residence areas, some locations are shopping areas, and others are industrial areas. Apparently, these characteristics, if obtained, can greatly improve our understanding of these locations' traffic patterns \citep{yuan2014discovering}. In practice, one of the most widely used data sources to characterize the functionality of a location is points-of-interests (POIs) \citep{geng2019spatiotemporal} and/or their related social media open check-ins \citep{yang2013fine,wang2019cross}. For example, the number or the distribution of different types of POIs are often used as a spatial feature vector for a location in literature~\citep{guo2018citytransfer,liang2018geoman}. With such feature vectors, different modeling methods can be leveraged to extract the hidden patterns about the location functionality that are related to the traffic data \citep{yao2018deep}. Note that, if we have a large amount of historical data among many locations, it is probable that we can directly infer the location functionality from its historical traffic records, so some existing studies also develop methods to use traffic pattern or similarity to describe location functionality \citep{wang2019cross,Chen2017FineGrainedUE,Fan2014CitySpectrumAN}. \textbf{Inter-Location Relationship}. In real-world applications, there are many types of spatial relationships between different locations which may indicate traffic patterns. For example, in traffic volume prediction, the locations connected by the same major city road (e.g., circle road in Beijing) will probably have related flow patterns, i.e., \textit{connectivity} relationship \cite{geng2019spatiotemporal}; in metro station flow prediction, the stations in the same metro line may also hold certain correlations in the flow patterns, i.e., \textit{same-line} relationship. To model such diverse inter-location relationships, a natural way is to build a graph to link locations with certain relationships. That is, we see each location as a graph node, and then link two location nodes with an edge if they have some relationship (e.g., connected by the same road). Recently, graph convolution techniques have become very powerful tools to extract hidden spatial knowledge from such constructed inter-location relation graphs~\cite{geng2019spatiotemporal,chai2018bike}. It is worth noting that, the \textit{geographic proximity} and \textit{location functionality} can also be seen as special instances of inter-location relationships. For geographic proximity, nearby locations can be linked in the graph; for location functionality, the locations with similar functionality can also be connected \cite{geng2019spatiotemporal}. \textbf{This indicates that the inter-location relationship is promising to be generalized to represent various spatial knowledge for STTP. } \textbf{Data-Driven Modeling without Explicit Knowledge}. While spatial patterns of traffic are complicated and heterogeneous in reality, some recent studies attempt to catch spatial knowledge directly by data-driven methods rather than encoding explicit knowledge factors. One representative method is first randomly constructing an inter-location graph, and then applying the graph neural network learning technique to refine the inter-location graph \cite{wu2019graph,bai2020adaptive}. Generally, the patterns learned by such purely data-driven methods are highly dependent on the amount and quality of the input historical data. Besides, since the inter-location relationship becomes learnable, the overall computation overhead is increased \cite{bai2020adaptive}. \subsection{External Factors} Besides spatial and temporal factors, researchers have also studied how various external factors may influencer traffic patterns \cite{zheng2019deepstd}. These research achievements inspire that for a fine-grained traffic prediction, external factors could be a useful extra knowledge source. We list some representative external factors widely studied in the literature. \textbf{Weather}. Weather information, including temperature, humidity, condition (e.g., rainy, cloudy), etc., would impact human mobility obviously. It has been reported that more than 20\% of car accidents are related to weather conditions.\footnote{\url{https://ops.fhwa.dot.gov/weather/q1_roadimpact.htm}} Some researchers have analyzed the correlations of various weather variables and traffic for identifying influential weather factors \cite{koesdwiady2016improving}. \textbf{Workday/Holiday}. Human mobility patterns are diversified between workdays and holidays. For instance, during the Thanksgiving and Christmas holiday, there would be a significant increase on long-distance travels in U.S., leading to heavy congestion on highways \cite{jun2010understanding}. Hence, whether it is a workday or holiday can cause distinct traffic flows. \textbf{Event}. When certain events happen around a location, the corresponding traffic would be biased from its normal pattern. For instance, when a sports game or concert is held at a stadium, then the passenger flow around the stadium would rapidly rise up, thus impacting the traffic of its nearby metro \cite{ni2016forecasting}, bikesharing stations \cite{chen2016dynamic}, etc. \color{black} \subsection{Analyzing Existing Models} \label{sub:analyze_existing} With the preceding issues, now we summarize representative research studies on STTP with STAnalytic. Since in recent years we have witnessed numerous STTP efforts, we thus only select some representative studies from both classical statistical learning and new deep learning methodologies to give an overview. Regarding RQ1, we select two main streams of traffic prediction studies to analyze with STAnalytic. The first stream only considers the temporal factors with classical statistical methods (e.g., ARIMA) or recent deep learning methods (e.g., LSTM); the second stream leverages the deep learning techniques with both temporal and spatial knowledge in consideration. As shown in Table~\ref{tab:existing_work}, most of the first stream of works are much older, including Hamed et al. (1995) \cite{hamed1995short}, Williams et al. (1998) \cite{williams1998urban}, and Williams et al. (2003) \cite{williams2003modeling}. All of them take the traffic prediction problem as time-series data analysis and thus solve the problem with ARIMA methods. The results from Williams et al. (1998, 2003) \cite{williams1998urban,williams2003modeling} reveal that the daily and weekly periodicity widely exists and thus it is important to consider them in the temporal factors of the traffic prediction. More recently, researchers start leveraging advanced machine learning techniques, such as LSTM, to learn the temporal patterns in traffic prediction \cite{ma2015long}. \color{black} For the second stream of works, we list several representatives \cite{zhang2017deep,liang2018geoman,li2017diffusion,yu2018spatio,geng2019spatiotemporal,guo2019attention,wu2019graph,bai2020adaptive}, which are published in prestigious venues and highly cited. \color{black} All of these studies apply deep learning techniques into STTP with both temporal and spatial knowledge in consideration. Note that their modeling techniques are distinct (see `modeling technique' in Table~\ref{tab:existing_work}), thus not directly comparable from the technique perspective. However, with STAnalytic, we put more focus on analyzing which types of temporal and spatial knowledge are taken into consideration, and then these studies are clearly comparable as follows: 1) From temporal knowledge (RQ2), ST-ResNet \cite{zhang2017deep}, ST-MGCN \cite{geng2019spatiotemporal}, and ASTGCN \cite{guo2019attention} \color{black} consider both closeness and daily/weekly periodicity, while others only consider closeness. 2) From spatial knowledge (RQ3), ST-MGCN \cite{geng2019spatiotemporal} considers multiple factors including proximity, functionality, and road connectivity. In comparison, other studies only consider one spatial knowledge of proximity or functionality. Note that Graph-WaveNet \cite{wu2019graph} and AGCRN \cite{bai2020adaptive} use data-driven methods to automatically extract spatial knowledge, which has the potential to outperform specified spatial knowledge with adequate high-quality historical data. \color{black} Based on the above comparison, among these approaches investigated by STAnalytic, we can infer that \textit{ST-MGCN \cite{geng2019spatiotemporal} is probably more generalizable over various scenarios, as it considers more temporal and spatial factors which have been verified effective in literature}. That is, \textit{the more knowledge, the better prediction}. Later in Section~\ref{sec:evaluation}, we will quantitatively compare most of these representative approaches with real-life STTP datasets Another interesting observation from the analysis is based on RQ4. While the literature has shown that various external factors, such as weather and events, can influence traffic patterns, most spatio-temporal traffic prediction methods ignore external factors completely. There may be several reasons. First, how to extract useful external factors, such as events, is a non-trivial problem itself \cite{ni2016forecasting}. Second, how external factors impact traffic patterns is highly application-dependent (e.g., the event impacts on metro passenger volume may not be generalized to traffic speed). Then, it is still challenging for general-purpose traffic prediction approaches to incorporate external factors in a unified way for diverse applications. According to this state and making the method comparison fair, we then ignore external factors for all the approaches in our quantitative benchmark experiment (Section~\ref{sec:evaluation}). Nevertheless, we believe that investigating external factors is a promising research direction for STTP. \color{black} \section{Introduction} The \textbf{Spatio-Temporal Traffic Prediction (STTP)} problem refers to the problem that resides in many urban predictive applications related to both spatial and temporal human mobility dynamics, e.g., the predictions of taxi demand \citep{zhang2017deep}, metro human flow \citep{wei2012forecasting}, electrical vehicle charging usage \citep{bae2011spatial}, and traffic speed \citep{li2017diffusion}. The STTP problems play a vital role in today's smart city management and organization, e.g., traffic monitoring and emergency response. Traditionally, STTP is often formulated as a time series prediction problem, where statistical methods such as ARIMA (AutoRegressive Integrated Moving Average) \citep{williams1998urban,hamed1995short} are widely used. In recent years, with the advance of machine learning, especially deep learning techniques, a variety of new models have been developed for STTP. Today, researchers can be quickly overwhelmed by numerous STTP related papers that continuously emerge in top-tier conferences and journals \citep{zhang2017deep,li2017diffusion,liang2018geoman,geng2019spatiotemporal,chai2018bike}. However, most efforts focus on the sophisticated application-specific model design and then test their models on limited data of one or few specialized applications, e.g., ridesharing~\citep{geng2019spatiotemporal}, bikesharing~\citep{chai2018bike,yang2016mobility}, and highway traffic speed \citep{li2017diffusion}. Although the proposed models can conceptually be applied to other STTP scenarios, whether the performance can still be as good as their specialized applications remains unclear. In other words, it becomes rather difficult to analyze whether an STTP model can be quickly generalized over various scenarios. Indeed, the generalizability is a fundamental and key property of an STTP model, and significantly determines the potential impact scope. In this regard, it is highly urgent to require a general analytic framework that can help investigate and compare different application-driven STTP models. Furthermore, the insights derived from the analytic framework can guide researchers to justify the generalizability of these models, and then design new models with better generalizability. To fill this research gap, this paper makes efforts from the following aspects: 1) To make different application-driven STTP approaches comparable, we propose \textbf{an analytic framework}, called \textit{STAnalytic}, to investigate the STTP approaches from their considered high-level spatial and temporal factors. Particularly, STAnalytic maps an STTP model into a two-level hierarchical analysis process where the first level is \textit{spatial and temporal} perspective, and the second level is \textit{knowledge and modeling} perspective. Then, every STTP model can be analyzed as two research questions: (1) \textit{``what effort is done from temporal and spatial perspective?''}; and (2) \textit{``which spatial/temporal knowledge is considered with which modeling techniques?''}. This qualitative analysis can provide useful insights about whether an STTP model can be well generalized to various scenarios even before we run quantitative experiments over the model. 2) To elaborate the effectiveness of STAnalytic in terms of helping design generalizable STTP models, we propose a \textbf{spatio-temporal meta-model}, called \textit{STMeta}, based on the analysis results of the STTP over state-of-the-art in literature \citep{zhang2017deep,li2017diffusion,liang2018geoman,geng2019spatiotemporal}. STMeta is a ``model of model'' (meta-model) which has a hierarchical structure to flexibly and efficiently integrate generalizable temporal and spatial knowledge identified by STAnalytic from literature. With state-of-the-art deep learning techniques such as graph convolution \citep{defferrard2016convolutional} and attention mechanisms \citep{vaswani2017attention}, we implement three variants of STMeta and verify their generalizable effectiveness via multiple real-life STTP benchmark datasets (listed next). 3) To alleviate the issue that today's STTP research studies usually conduct experiments on certain specific applications and do not justify the generalizability among various applications quantitatively, we build \color{blue} a set of \textbf{STTP benchmark datasets} \color{black} including five scenarios, i.e., ridesharing, bikesharing, metro, electric vehicle charging, and traffic speed. The datasets cover ten cities, where the longest time duration spans four years and the largest number of traffic data records is more than 400 million. We have released our code and data repository\footnote{\url{https://github.com/uctb/UCTB}} To summarize, this paper makes the following contributions: 1) We develop an analytic framework, namely \textit{STAnalytic}, following which existing STTP approaches can be qualitatively explored. To the best of our knowledge, this is one of the first studies that propose such an analytic framework for the STTP problem. 2) We design a meta-model called \textit{STMeta} based on the insights derived from STAnalytic over state-of-the-art research \citep{zhang2017deep,li2017diffusion,liang2018geoman,geng2019spatiotemporal}. STMeta can flexibly and efficiently take into account multiple spatial and temporal knowledge for building an STTP model. 3) We build a set of real-life STTP benchmark datasets covering five scenarios and ten cities. The benchmark results verify that STMeta generally outperforms state-of-the-art approaches. After analyzing the results, we provide several design guidelines to develop STTP approaches with better generalizability. \section{STMeta: STTP Meta-Model To show the effect of STAnalytic in guiding the design of generalizable STTP approaches, we propose a meta-model called \textit{STMeta}, which can consider multiple generalizable spatial and temporal knowledge identified by STAnalytic from literature. \begin{figure*}[t] \centering \includegraphics[width=.85\textwidth]{./figs/model.pdf} \caption{STMeta: a meta-model for spatio-temporal traffic prediction} \label{fig:model} \end{figure*} \begin{figure}[t] \centering \includegraphics[width=.9\linewidth]{./figs/TMeta.pdf} \caption{TMeta with temporal factors} \label{fig:tmeta} \end{figure} \subsection{Design Principles} Before describing the details of STMeta, we first illustrate the key design consideration of STMeta from two aspects: (1) \textit{From the modeling perspective, we aim to fully leverage the state-of-the-art deep learning techniques}, which can extract latent features and representations very effectively, especially when we can collect a large amount of historical traffic data with advanced IT infrastructures nowadays. (2) \textit{From the spatio-temporal knowledge perspective, we attempt to consider the representative and generalizable knowledge captured by STAnalytic}, so that the knowledge that has already been validated from literature can contribute to our model. Note that STMeta is a `\textit{meta-model}' of model: many components of STMeta are not restricted to specific types of learning techniques, but can be implemented by alternative techniques that suit the modeling purpose. Next we will describe the details of STMeta. \subsection{Meta-Model Details} \label{sub:STMeta_details} The overview of STMeta is in Figure~\ref{fig:model}. The key components include the \textit{spatio-temporal modeling}, \textit{temporal aggregation}, and \textit{spatial aggregation} units. We illustrate them as follows. \subsubsection{Spatio-Temporal Modeling} The spatio-temporal modeling part of STMeta includes two key steps. First, we decide which input format is suitable for the temporal and/or spatial knowledge. Second, we need some modeling techniques to extract useful patterns from the temporal and/or spatial knowledge inputs. To consider the temporal knowledge including closeness, daily periodicity, and weekly periodicity, our model has constructed \textbf{multiple time-series data} regarding different temporal knowledge as the input. Particularly, for \textit{closeness}, the time-series consists of the traffic data in recent time slots; for \textit{daily} (or \textit{weekly}) \textit{periodicity}, the time-series includes the traffic data in the same time slot of last a few days (or the same weekday-time slot in last a few weeks). We use this input format because it is flexible and can be generalized to other cases. For example, if certain traffic data has bi-weekly/monthly/yearly periodicity patterns, it is easy to implement them into STMeta by adding a corresponding time series. To consider spatial knowledge, we adopt the \textbf{inter-location relationship graph} as the input because of its generality \citep{geng2019spatiotemporal,chai2018bike} (Details in `Inter-Location Relationship' of last section). Then, for specific STTP scenarios, researchers can build suitable inter-location relation graphs, e.g., proximity and functionality, to encode the useful spatial knowledge. Given the temporal and spatial inputs, the key component of our model is the \textbf{spatio-temporal unit} that takes both \textit{time-series data} (temporal knowledge) and \textit{graph structures} (spatial knowledge) into account. Recent deep learning research has developed techniques such as \textit{graph convolutional long short-term memory} (GCLSTM) \citep{chai2018bike} and \textit{diffusion convolutional gated recurrent unit} (DCGRU) \citep{li2017diffusion}. (1) \textit{GCLSTM}: Graph convolution works on a graph $G = (V, A)$ where $V$ is the vertices and $A$ is the adjacency matrix. Let $L=I-D^{-1/2} * A * D^{-1/2}$ be the normalized Laplace matrix, where $D_{ii}=\sum_jA_{i,j}$ is the diagonal degree matrix. The graph convolution can be computed by Chebyshev approximation \citep{defferrard2016convolutional} : $X'=\sum_{k=0}^K{T_k(L)*X*\theta_k}$ where $T_k(L)$ is the $k$-$th$ Chebyshev polynomial and $\theta_k$ is a parameter matrix. To implement GCLSTM, we modify the input $X_t$ and the hidden state $h_{t-1}$ of the LSTM unit to a graph convoluted version: \begin{align} & X_t'=\sum_{k=0}^K{T_k(L)*X_t*\theta_k} \\ & h_{t-1}'=\sum_{k=0}^K{T_k(L)*h_{t-1}*\theta_k} \end{align} The graph convolution part in GCLSTM can consider the spatial information while the LSTM part can take temporal information. (2) \textit{DCGRU}: From the design concept, DCGRU is very similar to GCLSTM. That is, DCGRU also re-designs the recurrent neural unit by considering node relations in a graph. The difference is that it uses GRU instead of LSTM, and also replaces the graph convolution operation with the diffusion convolution one. \subsubsection{Spatial and Temporal Knowledge Aggregation} As shown in Figure~\ref{fig:model}, after the spatio-temporal modeling unit, STMeta will first conduct \textit{temporal aggregation} to integrate multi-temporal knowledge, and then \textit{spatial aggregation} to merge multi-spatial knowledge. Similar to the spatio-temporal model unit, there are many candidate deep learning techniques that can be used for temporal and spatial aggregation. (1) \textit{Graph Attention Layer}. After firstly being introduced by Google \citep{vaswani2017attention}, the attention mechanism has quickly been popular in the deep network structure design. One of its main usages is to aggregate multiple features into an integrated one by learning weights for each feature. Particularly, we introduce a method of using the \textit{graph attention layer} (GAL) \citep{velivckovic2017graph} to merge multiple features. The input of GAL is a set of node features $\mathbf h=[h_1,h_2,...,h_N]$, $h_i \in \mathbb{R}^F$, each node being the feature learned from one specific temporal or spatial knowledge (e.g., for three temporal features as closeness, daily and weekly periodicity, $\mathbf h$ has three elements). We first conduct linear transform parametrized by a shared weight matrix $W \in \mathbb{R}^{F,F'}$, and then perform self-attention on each node using a shared attention parameter $a \in \mathbb{R}^{2F'}$: \begin{equation} e_{i,j}= a \cdot [h_i \cdot W; h_j \cdot W] \end{equation} where $e_{i,j}$ represents the importance of $h_j$ to $h_i$. To make the attention coefficient comparable, we normalize them using softmax: \begin{equation} \alpha_{i,j} = softmax_j(e_{i,j}) \end{equation} The output of GAL at $h_i$ can then be represented as \begin{equation} h'_i=\sigma(\sum_j{\alpha_{i,j}*(h_j \cdot W)}) \end{equation} where $\sigma$ is the activation function and we use leaky RELU \citep{velivckovic2017graph}. To make the self-attention process more robust, we add the multi-head mechanism into the model \citep{vaswani2017attention} ($M$ is the number of multi-head): \begin{equation} h'_i= \frac{1}{M} \sum_{m=1}^{M}\sigma(\sum_j{\alpha^m_{i,j}*(h_j \cdot W^m)}) \end{equation} As each node has its own feature after GAL, we then use an average pooling layer to aggregate $h'_i$ into a feature vector: \begin{equation} \bar h=AveragePooling(h'_i) \end{equation} where $\bar h$ is the final GAL aggregated feature representation from a set of features $\mathbf h$. (2) \textit{Concatenation with Dense Layer}. Another widely used technique in deep learning to combine multiple features is concatenation. Then, dense layers can be applied to the concatenated features so as to extract useful representations for the target task: \begin{equation} \hat h = Dense([h_1;h_2;...;h_N]) \end{equation} For the temporal or spatial aggregation unit in Figure~\ref{fig:model}, either of the above two techniques can be selected. \subsubsection{Combing Together} With the spatio-temporal modeling unit and the temporal and spatial aggregation unit, we can then implement concrete STTP approaches following STMeta. Particularly, after spatial aggregation, we can simply stack several dense network layers on the aggregated spatio-temporal representations to predict the future traffic. \subsubsection{TMeta: Considering Only Temporal Factors} It is worth noting that, following the design principle of STMeta, we can have a simplified version by considering only temporal factors, called \textit{TMeta} (Figure~\ref{fig:tmeta}). The temporal modeling unit can be implemented by LSTM~\citep{gers1999learning} or GRU~\citep{chung2014empirical}. Later in the benchmark experiments, we will also check how TMeta performs so as to investigate how much improvement can be brought into practice by encoding spatial knowledge. \subsubsection{Comparison with Existing Methods} Compared with the existing methods listed in Table~\ref{tab:existing_work}, STMeta is flexible to incorporate a variety of temporal and spatial factors. In particular, ST-MGCN \cite{geng2019spatiotemporal} has also considered multiple temporal and spatial knowledge factors, but its network structure is different from STMeta in temporal modeling. More specifically, ST-MGCN directly combines the weekly, daily, and closeness historical records into \textit{one} time-series sequence as the input. In comparison, the inputs of STMeta include \textit{three} types of time-series data regarding closeness, daily periodicity, and weekly periodicity, respectively; thus, STMeta introduces a temporal aggregation unit to combine the three temporal patterns. We think that the design of STMeta may help to learn different temporal patterns more easily, as each temporal pattern (closeness, daily, and weekly periodicity) has its own time-series sequence for dedicated learning. \color{black} \section{Problem and Generalizability} \subsection{Problem Formulation} First, we formulate the \textbf{Spatio-Temporal Traffic Prediction} problem. Suppose that there are a set of $n$ locations $\mathcal L = \{l_1, l_2, \cdots, l_n\}$, and for each $l_i \in \mathcal L$, it has a historical series of traffic information from time slot $1$ to the current slot $k$, denoted as $F_i = \{f_{i1}, f_{i2},\cdots, f_{ik}\}$. Then, we want to predict the traffic information for each $l_i$ in the next time slot $k+1$ to minimize, \begin{equation} error(\hat f_{i(k+1)}, f_{i(k+1)}) \quad \forall l_i \in \mathcal L \end{equation} where $\hat f_{i(k+1)}$ is the predicted traffic of $l_i$ in the next time slot $k+1$, and $f_{i(k+1)}$ is the ground truth; the $error$ function may have many choices. In this paper, we use RMSE (root mean square error). \subsection{Application Scenarios} STTP is an abstraction of many real-world smart city applications that are reported and studied in the literature: \begin{itemize} \item \textit{Region-based Ridesharing Demand Prediction} \cite{geng2019spatiotemporal}: With the popularity of ridesharing services, one fundamental problem is to predict how many ridesharing demands will emerge in every area of a city. Usually, a city will be split into a set of equal-size regular regions (e.g., grids of 1km * 1km) \cite{geng2019spatiotemporal,zhang2017deep} or irregular regions (e.g., functional areas split by road network) \cite{sun2020predicting}, and then one needs to predict the ridesharing demand for each region in near future. \item \textit{Station-based Bikesharing Demand Prediction} \citep{chai2018bike}: Bikesharing is another quickly developed service in many cities nowadays. One major type of bikesharing services builds a set of fixed stations in a city and then users can borrow and return bikes at any of those stations. As each station has a limited number of docks to hold bikes, it is important to predict how many users will borrow or return bikes in near future \item \textit{Other Applications.} In literature, a lot of other specific problems can also be converted to STTP problems. Actually, most of them can be categorized to region-based or station-based problems. For example, for taxi flow prediction of a city, the problem is often formulated same as ridesharing demand and the regions are pre-defined \cite{zhang2017deep,Zhang0QLYL18}; for traffic speed prediction of road segments, the problem formulation is similar to the station-based bikesharing case~\citep{yu2018spatio,Zheng2020GMANAG} \end{itemize} \subsection{Generalizability} While most prior studies focus on specific applications, this paper aims to explore the generalizability issue in STTP. In particular, we concentrate on two generalizability issues: \textit{model generalizability} and \textit{knowledge generalizability}: \textbf{Model Generalizability}. As different STTP applications involve diverse spatial and temporal knowledge factors, the model generalizability refers to: (1) \textit{Regarding different spatial and temporal knowledge factors, is a model generalizable to incorporate diverse factors?} (2) \textit{By incorporating different factors, can a model be generally competitive to the state-of-the-art models in a variety of applications?} \textbf{Knowledge Generalizability}. With the generalizable model that can incorporate various spatial and temporal knowledge factors, we aim to study the knowledge generalizability issue: \textit{Given a certain spatial or temporal knowledge factor, is it generalizable to be effective for various STTP applications?} To address the \textit{model generalizability} issue, we first propose \textit{STAnalytic}, an analytic framework to investigate the spatial and temporal factors considered in a specific STTP model, which can facilitate a qualitative analysis of the model's generalizability. With the spatial and temporal factors identified by STAnalytic in mind, we propose \textit{STMeta}, a meta-model that can incorporate distinct factors in a unified manner; we verify STMeta's superiority of generalizability over state-of-the-art models by running \textit{an extensive benchmark experiment} with ten real-life STTP datasets. Finally, with STMeta, we tackle the \textit{knowledge generalizability} issue by studying how the importance of different spatial and temporal factors vary with the change of benchmark datasets. \color{black} \section{Related Work} The STTP problem is useful for many urban computing scenarios including ridesharing demand, public transportation flow, EV charging station usage \citep{geng2019spatiotemporal,chai2018bike,zhang2017deep}. Our paper has investigated some representative studies while there are still many others not mentioned in detail \cite{yao2018deep,ke2017short,Pan2019UrbanTP,Lv2015TrafficFP,Zhang2019FlowPI,yao2019revisiting}. Due to the page and time limitation, we have not yet analyzed these approaches and re-implemented their methods for evaluation. We will extend our analysis and experimental comparison by selecting more studies and add their model implementations into our code repository There are also some research topics related to STTP: \textit{Sensory time-series processing} focuses on mining time-series data generated by pervasive sensors, e.g., accelerometers, gyroscopes, and magnetometers \citep{yao2018deep} to facilitate applications such as mobile sensing \citep{Lane2010ASO,zhou2015smiler} and activity recognition \citep{Wang2018DeepLF}. Compared to traffic data, usually the time slot length of the sensory time-series data can be much shorter (e.g., in seconds), and thus the temporal knowledge in consideration can be different. However, we still think that STAnalytic may inspire a similar analysis framework for sensory time-series data. \textit{Individual mobility prediction} targets predicting an individual person's future visiting locations \citep{Feng2018DeepMovePH,Gao2019PredictingHM}. While this is individual level and STTP involves mostly aggregation level information, there are many commonalities in the leveraged knowledge for building the prediction model. For example, periodicity is recently added by DeepMove \citep{Feng2018DeepMovePH} into individual mobility prediction and offers a significant improvement. Hence, analyzing the literature on individual mobility prediction following a framework similar to STAnalytic can be interesting and valuable. It is also possible that traffic prediction and individual mobility prediction can learn from each other from such analysis.
{'timestamp': '2021-11-29T02:06:35', 'yymm': '2009', 'arxiv_id': '2009.09379', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09379'}
arxiv
\section{Towards an implementation}\label{sec:comp} Theorem~\ref{thm:main} guarantees the existence of Walrasian equilibria maximizing CES welfare, but says nothing about how to find these equilibria. As discussed in Section~\ref{sec:results}, we could always explicitly ask each agent for her valuation, and directly solve Program~\ref{pro:ces}. However, agents are generally not able to articulate their entire valuations, and even if they are, doing so could be extremely tedious. In this section, we give an iterative algorithm for computing the WE given by Theorem~\ref{thm:main}. The algorithm will just compute the optimal allocation; Lemma~\ref{lem:x-to-q} shows how the equilibrium pricing rule can easily be obtained once the optimal allocation is in hand. Our algorithm is computationally equivalent to running the general-purpose ellipsoid method on Program~\ref{pro:ces}, i.e., it explores the exact same sequence of allocations. The key is that we are able to implement the ellipsoid method only using valuation gradient queries, i.e., ``tell me the gradient of your valuation at this point". We immediately inherit the correctness and polynomial-time convergence properties of the ellipsoid algorithm. Throughout this section, we make the same assumptions as in Theorem~\ref{thm:main}: each $v_i$ is concave, homogeneous of degree $r$, and differentiable. First, recall that the pricing rule from Theorem~\ref{thm:main} takes the form $p(x_i) = \rho r^{\frac{\rho - 1}{\rho}} (\sum_{j \in M} q_j x_{ij})^{1/\rho}$. Since $\rho$ and $r$ are constants, it suffices to compute $\q = q_1,\dots,q_m$. Helpfully, Theorem~\ref{thm:main} tells us that if $\q$ are optimal Lagrange multipliers for Program~\ref{pro:ces}, then $(\mathbf{x}, p)$ is a WE for any $\mathbf{x} \in \Psi(\rho)$. The next lemma states if we know an $\mathbf{x} \in \Psi(\rho)$, and have access to the gradients of the agents' valuations at $\mathbf{x}$, we can determine optimal Lagrange multipliers. \begin{restatable}{lemma}{lemXToQ}\label{lem:x-to-q} Let $\mathbf{x} \in \Psi(\rho)$. Then we can determine optimal Lagrange multipliers $\q$ using only\\ $\nabla v_1(x_1),\dots,\nabla v_n(x_n)$. \end{restatable} \begin{proof} First, using Euler's Theorem for homogeneous functions (Theorem~\ref{thm:euler}), we can obtain $v_1(x_1),\dots,v_n(x_n)$ using only $\nabla v_1(x_1),\dots,\nabla v_n(x_n)$. Next, since $\mathbf{x} \in \Psi(\rho)$, the KKT conditions for Program~\ref{pro:ces} imply that whenever $x_{ij} > 0$, $q_j = v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$. Fix a $j \in M$. If $x_{ij} > 0$ for some agent $i$, then $q_j = v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$. We know all the values on the right hand side, so we can compute $q_j$. if $x_{ij} = 0$ for all $i \in N$, then complementary slackness implies that $q_j = 0$. \end{proof} Thus it suffices to find an allocation $\mathbf{x} \in \Psi(\rho)$, which is equivalent to finding an $\mathbf{x}$ that is optimal for Program~\ref{pro:ces}. There are many iterative algorithms for solving convex programs of this form. Furthermore, many only require (1) oracle access to the objective function and its gradient, and (2) \emph{a separation oracle}\footnote{A separation oracle is an algorithm which, given a point $x$ and a convex set $\mathcal{X}$, determines whether $x \in \mathcal{X}$. If $x\not\in\mathcal{X}$, it must return a separating hyperplane (if $\mathcal{X}$ is specified by a set of constraints, returning a violated constraint is sufficient).} for the constraint set (and no additional assumptions of strong convexity or other properties). For the sake of specificity, we focus on the \emph{ellipsoid method}~\cite{Bubeck2015}, but any algorithm with these properties is sufficient for our purposes. \begin{lemma}[\cite{Bubeck2015}]\label{lem:converge} Let $f$ be a convex function and let $\mathcal{X}$ be a convex set. Consider the program $\min_{x \in \mathcal{X}} f(x)$. Let $\E$ be a ball containing the minimum of $f$, and suppose there exists a polynomial-time separation oracle for $\mathcal{X}$. Then the ellipsoid method starting from $\E$ requires only oracle access to $f$ and $\nabla f$, and converges to the minimum of $f$ in polynomial time. \end{lemma} In our case, we have a trivial polynomial-time separation oracle: simply check each constraint to see if it is violated. For the gradient of our objective function, we have $\mfrac{\partial}{\partial x_{ij}} \Big(\frac{1}{\rho} \sum_{i \in N} v_i(x_i)^\rho\Big) = \mfrac{\partial v_i(x_i)}{\partial x_{ij}} v_i(x_i)^{\rho-1}$. By Euler's Theorem for homogeneous functions (Theorem~\ref{thm:euler}), we have \begin{align} \frac{\partial v_i(x_i)}{\partial x_{ij}} v_i(x_i)^{\rho-1} = \frac{\partial v_i(x_i)}{x_{ij}} \Big(r^{-1} \sum_{\ell \in M} x_{i\ell} \frac{\partial v_i(x_i)}{x_{i\ell}}\Big)^{\rho-1} \label{eq:euler} \end{align} Similarly, \begin{align} \frac{1}{\rho} \sum_{i \in N} v_i(x_i)^\rho = \frac{1}{\rho} \sum_{i \in N} \Big(r^{-1} \sum_{j \in M} x_{ij} \frac{\partial v_i(x_i)}{\partial x_{ij}}\Big)^\rho\label{eq:euler2} \end{align} Therefore for any allocation $\mathbf{x}$, we can compute both the objective function value and the gradient of the objective function using only the gradients of $v_1,\dots,v_n$. The final ingredient we need is an initial ball guaranteed to contain the optimum; we can simply enclose the entire feasible region in a ball of constant radius. Thus we get the following iterative algorithm for computing the equilibrium pricing rule: \begin{enumerate} \item Run the ellipsoid method (or any other suitable convex optimization algorithm) to solve Program~\ref{pro:ces}. \item At the start of each iteration, ask each agent $i$ for the gradient of $v_i$ at the current point $\mathbf{x}$. \item Whenever the algorithm requires the gradient of the objective function at $\mathbf{x}$, compute it via Equation~\ref{eq:euler}. \item Whenever the algorithm requires the objective function value at $\mathbf{x}$, compute it via Equation~\ref{eq:euler2}. \end{enumerate} Lemma~\ref{lem:converge} immediately implies correctness and polynomial-time convergence. \subsection{Eliciting the gradients of valuations} The above algorithm (as well as Lemma~\ref{lem:x-to-q}) requires us to have access the gradients of agents' valuations. We could simply ask each agent for this information explicitly; depending on the application domain, this may or may not be reasonable. An alternative approach is to relate $\nabla v_i(x_i)$ to agent $i$'s willingness to pay. For example, consider the following query to agent $i$: ``Suppose you have already bought the bundle $x_i$. What is the smallest marginal price for good $j$ such that you would not buy more of good $j$?" The KKT conditions for agent $i$'s demand set imply that the answer to this question is exactly $\mfrac{\partial v_i(x_i)}{\partial x_{ij}}$ (assuming that the agent would not buy more if she is indifferent). Such a query could be implemented in a variety of ways. One possibility would be gradually increasing the hypothetical marginal price of good $j$ in a continuous fashion, and asking agent $i$ to say ``stop" when she would no longer buy more of good $j$ (in a ``moving-knife"-like fashion). Also, rather asking agents about hypothetical marginal prices, one could build the necessary marginal prices into an actual pricing rule, e.g., even one as simple as $p(x_i) = \sum_{j \in M} c_j x_{ij}$. The choice of implementation would depend heavily on the specific problem setting; our point here is that there are a variety of ways to elicit $\nabla v_i(x_i)$ via queries about what agent $i$ would purchase in different (hypothetical) situations. \section{Conclusion} In this paper, we studied a simple family of convex pricing rules, motivated by the widespread use of convex pricing in the real world, especially for water. We proved that these pricing rules implement CES welfare maximization in Walrasian equilibrium, providing a formal quantitative interpretation of the frequent informal claim that convex pricing promotes equality. Furthermore, by tweaking the exponent of the pricing rule, the social planner can precisely control the tradeoff between equality and efficiency. This result also shows that convex pricing is not necessarily economically inefficient, as often claimed; it simply maximizes a different welfare function than the traditional utilitarian one. Improved implementation is perhaps the most important of the future directions we propose. One concrete possibility is a \emph{\tat}: an iterative algorithm where on each step, each agent reports her demand for the current pricing rule, and the pricing rule is adjusted accordingly. Demand queries are arguably easier for agents to answer than valuation gradient queries. Some implementation questions -- in particular, how to deal with Sybil attacks -- would likely need to be handled on a case-by-case basis. Aside from the implementation itself, there is the additional challenge of convincing market designers to consider using this type of convex pricing. Equality is generally thought to be desirable, but sellers may be concerned that this will decrease their revenue. In future work, we hope to show that our pricing rule guarantees a good approximation of the optimal revenue for sellers. Another possible direction would be CES welfare maximization for indivisible goods. The analogous pricing rule would be $p(S) = (\sum_{j \in S} q_j)^{1/\rho}$, where $S$ is a set of indivisible goods. It seems like very different theoretical techniques would be needed in this setting (along with perhaps a gross substitutes assumption), but we suspect that the same intuition of convex pricing improving equality would hold. \section{Negative results}\label{sec:counter} Even when Sybil attacks are not possible, there are limitations to implementation in WE. This section presents several relevant counterexamples. \subsection{Linear pricing poorly approximates CES welfare for $\rho \ne 1$} Recall that for an allocation $\mathbf{x}$, $\Phi(\rho, \mathbf{x})$ denotes the CES welfare of $\mathbf{x}$. In contrast, $\Psi(\rho)$ denotes the set of allocations with optimal CES welfare with respect to $\rho$. Our first negative result relates to linear pricing. In particular, can linear pricing guarantee a reasonable approximation of CES welfare? We show that the answer is no, justifying the need for nonlinear pricing. In particular, for any $\rho \in (0,1)$, the gap between the CES welfare of any linear pricing equilibrium and the optimal CES welfare can be arbitrarily large. Note that as $\rho$ goes to zero, $\frac{1}{\rho} - 1$ goes to infinity, so the denominator of the bound (and thus the gap in CES welfare) in the following theorem can indeed be arbitrarily large. \begin{theorem}\label{thm:rho=1-bad} Let $m=1$, $\rho \in (0,1]$, $v_1(x) = (1+\ep) x$ for some $\ep > 0$, and $v_i(x) = x$ for all $i \ne 1$. Suppose $(\mathbf{x}, p)$ is a WE where $p$ is linear. Then \[ \frac{\Phi(\rho, \mathbf{x})}{\max_{\mathbf{y}} \Phi(\rho, \mathbf{y})} \le \frac{1+\ep}{n^{\frac{1}{\rho}-1}} \] \end{theorem} \begin{proof} By the First Welfare Theorem, $\mathbf{x}$ must maximize utilitarian (i.e., $\rho = 1$) welfare. Thus by Lemma~\ref{lem:m=1-x}, $\mathbf{x}$ must give the entire good to agent 1: $x_1 = 1$ and $x_i = 0$ for $i \ne 1$. Thus the CES welfare of $\mathbf{x}$ with respect to $\rho$ is \[ \Phi(\rho, \mathbf{x}) = \Big(\sum_{i \in N} v_i(x_i)^\rho\Big)^{1/\rho} = \big( (1+\ep)^\rho \big)^{1/\rho} \] In contrast, consider the allocation $\mathbf{y}$ such that $y_i = 1/n$ for all $i \in N$: \[ \Phi(\rho, \mathbf{y}) = \Big( \sum_{i \in N} v_i(1/n)^{\rho} \Big)^{1/\rho} \ge \Big(\sum_{i \in N} (1/n)^\rho \Big)^{1/\rho} = \Big(n (1/n)^{1/\rho} \Big)^{1/\rho} = n^{\frac{1}{\rho} - 1} \] Thus $\max_{\mathbf{y}} \Phi(\rho, \mathbf{y}) \ge n^{\frac{1}{\rho} - 1}$, as required. \end{proof} \subsection{Theorem~\ref{thm:main} does not extend to nonuniform homogeneity degrees} In this section, we show that for all $\rho \in (0,1)$, Theorem~\ref{thm:main} does not extend to the case where different $v_i$'s have different homogeneity degrees. This shows that our result is tight in the sense that it is necessary to require the same homogeneity degree. We begin with the following lemma, which is a standard property of strictly concave and differentiable functions: it essentially states that any such function is bounded above by any tangent line. This lemma is sometimes called the ``Rooftop Theorem". \begin{lemma}\label{lem:rooftop} Let $f: \bbr \to \bbr$ be strictly concave and differentiable. Then for all $a,b \in \bbr$ where $a\ne b$, $f(a) < f(b) + f'(b)(a-b)$, where $f'$ denotes the derivative of $f$. \end{lemma} The next lemma is also quite standard; we provide a proof for completeness. \begin{lemma}\label{lem:concave-bound} Let $f: \bbr \to \bbr$ be strictly concave and differentiable, and let $x, a_1, \dots, a_k$ be nonnegative reals such that $\sum_{i=1}^k a_i = 0$. Then $\sum_{i =1}^k f(x + a_i) < kf(x)$. \end{lemma} \begin{proof} The lemma follows from Lemma~\ref{lem:rooftop} and arithmetic: \begin{align*} \sum_{i =1}^k f(x + a_i) <&\ \sum_{i=1}^k (f(x) + f'(x)(x+a_i - x))\\ =&\ \sum_{i=1}^k f(x) + f'(x) \sum_{i=1}^k a_i\\ =&\ \sum_{i=1}^k f(x) + f'(x) \cdot 0\\ =&\ kf(x) \end{align*} \end{proof} We are now ready to present our counterexample. \begin{theorem}\label{thm:different-r} Let $n =2$ and $m=1$, and for $x \in \bbrpos$, let $v_1(x) = x$ and $v_2(x) = \sqrt{2x}$. Then for all $\rho \in (0,1)$, there exists no allocation $\mathbf{x} \in \Psi(\rho)$ and pricing rule $p: \bbrpos \to \bbrpos$ such that $(\mathbf{x}, p)$ is a WE. \end{theorem} \begin{proof} Suppose for sake of contradiction that such $\mathbf{x}, p$ do exist. We first claim that $x_1 > x_2$. Suppose the opposite: then $x_2 \ge 1/2 \ge x_1$. Thus $v_2(x_2) \ge 1 > 1/2 \ge v_1(x_1)$. We also have $\mfrac{\partial v_2(x_2)}{\partial x_2} = \mfrac{1}{\sqrt{2x_2}} \le 1 = \mfrac{\partial v_1(x_1)}{\partial x_1}$. Thus $v_2(x_2) > v_1(x_2)$ and $\mfrac{\partial v_2(x_2)}{\partial x_2} \le \mfrac{\partial v_1(x_1)}{\partial x_1}$. Since $\rho < 1$, $\rho - 1 < 0$, so we have $v_2(x_2)^{\rho - 1}\mfrac{\partial v_2(x_2)}{\partial x_2} < v_1(x_1)^{\rho - 1}\mfrac{\partial v_1(x_1)}{\partial x_2}$. But this contradicts $\mathbf{x} \in \Psi(\rho)$, so we have $x_1 > x_2$ as claimed.\footnote{This immediately implies $\frac{\partial v_2(x_2)}{\partial x_2} < 1 =\frac{\partial v_1(x_1)}{\partial x_1}$, which, in combination with $x_1 > x_2$, rules out convex $p$. However, we still need to rule out non-convex $p$.} Since $(\mathbf{x}, p)$ is a WE, we must have $x_i \in D_i(p)$ for both agents $i$. Thus for any $x \ne x_i$, $v_i(x_i) - p(x_i) \ge v_i(x) - p(x)$. Therefore \begin{align*} v_1(x_1) - p(x_1) \ge&\ v_1(x_2) - p(x_2) \quad \text{and} \quad v_2(x_2) - p(x_2) \ge v_2(x_1) - p(x_1)\\ v_1(x_1) + v_2(x_2) - p(x_1) - p(x_2) \ge&\ v_1(x_2) + v_2(x_1) - p(x_1) - p(x_2)\\ v_1(x_1) + v_2(x_2) \ge&\ v_1(x_2) + v_2(x_1)\\ v_1(x_1) - v_1(x_2) \ge&\ v_2(x_1) - v_2(x_2) \end{align*} Since $x_1 > 1/2 > x_2$ and $x_1 + x_2 = 1$, let $x_1 = 1/2 + \ep$ and $x_2 = 1/2 - \ep$. Then we have $v_1(x_1) - v_1(x_2) = 2\ep$. For $v_2(x_1) - v_2(x_2)$, we have \begin{align*} v_2(x_1) - v_2(x_2) =&\ \sqrt{1+2\ep} - \sqrt{1-2\ep}\\ =&\ \frac{(\sqrt{1+2\ep} - \sqrt{1-2\ep})(\sqrt{1+2\ep} - \sqrt{1-2\ep})} {\sqrt{1+2\ep} + \sqrt{1-2\ep}}\\ =&\ \frac{(1+2\ep) - (1-2\ep)}{\sqrt{1+2\ep} + \sqrt{1-2\ep}}\\ =&\ \frac{4\ep}{\sqrt{1+2\ep} + \sqrt{1-2\ep}} \end{align*} Applying Lemma~\ref{lem:concave-bound} with $f(x) = \sqrt{x}$, $x=1$, $k=2$, and $(a_1, a_2) = (2\ep, -2\ep)$, we get $\sqrt{1+2\ep} + \sqrt{1-2\ep} < 2$. Thus $v_2(x_1) - v_2(x_2) > 4\ep/2 = 2\ep = v_1(x_1) - v_1(x_2)$. However, this contradicts $v_1(x_1) - v_1(x_2) \ge v_2(x_1) - v_2(x_2)$, as we showed above. We conclude that there is no $\mathbf{x} \in \Psi(\rho)$ and pricing rule $p$ such that $(\mathbf{x}, p)$ is a WE. \end{proof} \subsection{CES welfare maximization for $\rho \le 0$} In this section, we show that there is no pricing rule supporting CES welfare maximization for any $\rho < 0$. For $\rho = 0$ (i.e., Nash welfare), the situation is slightly different. We do show, however, that Nash welfare maximization cannot be supported by a differentiable pricing rule. \begin{theorem}\label{thm:neg-rho-counter} Consider the instance with $n=2$, $m=1$, $v_1(x) = x$ and $v_2(x) = 2x$. Then for every $\rho < 0$, there is no pricing rule $p$ and allocation $\mathbf{x} \in \Psi(\rho)$ such that $(\mathbf{x}, p)$ is a WE. \end{theorem} \begin{proof} For any $\rho < 0$ and any $\mathbf{x} \in \Psi(\rho)$, we must have $x_1 > x_2$. Assume $(\mathbf{x}, p)$ is a WE for some pricing rule $p$: then $x_1 \in D_1(p)$, so $v_1(x_1) - p(x_1) \ge v_1(x_2) - p(x_2)$. Thus $p(x_1) \le p(x_2) + v_1(x_1) - v_2(x_2) = p(x_2) + x_2 - x_1$. Therefore \begin{align*} v_2(x_1) - p(x_1) \ge&\ 2x_1 - (p(x_2) + x_2 - x_1)\\ =&\ 3x_1 - x_2 - p(x_2)\\ >&\ 2x_1 - p(x_2)\\ >&\ 2x_2 - p(x_2)\\ =&\ v_2(x_2) - p(x_2) \end{align*} Thus agent 2 would rather purchase $x_1$ than $x_2$, so $x_2 \not\in D_2(p)$. Therefore $(\mathbf{x}, p)$ is not a WE. \end{proof} For $\rho = 0$, the situation is different. Recall that Fisher market equilibrium always maximizes Nash welfare, and we can simulate Fisher market budgets by setting \[ p(x_i) = \begin{cases} 0 &\ \text{ if } \sum_{j \in M} q_j x_{ij} \le 1\\ \infty &\ \text{ otherwise} \end{cases} \] where $q_1\dots q_m$ are the optimal Lagrange multipliers in the convex program for maximizing Nash welfare. Gale and Eisenberg's famous result implies that for such a pricing rule, a WE always exists, and all WE maximize Nash welfare~\cite{Eisenberg1961,Eisenberg1959}. Note that for $\sum_{j \in M} q_j x_{ij} > 1$, $p(x_i) = \infty$ can be implemented by setting $\mfrac{\partial p(x_i)}{\partial x_{ij}}$ to be at least $\max_{i \in N} \max_{x_i \in [0,1]^m} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$. This ensures that no agent purchases a bundle $x_i$ such that $\sum_{j \in M} q_j x_{ij} > 1$. The above pricing rule is somewhat artificial, however. One natural question is whether Nash welfare maximization can be implemented with a differentiable pricing rule. We next show that the answer is no. \begin{theorem}\label{thm:nash-counter} Consider the instance with $n=2$, $m=1$, $v_1(x) = x$ and $v_2(x) = 2x$. Then there is no allocation $\mathbf{x}$ maximizing Nash welfare and differentiable pricing rule $p$ such that $(\mathbf{x}, p)$ is a WE. \end{theorem} \begin{proof} Suppose the opposite: that such $\mathbf{x}, p$ exist. The unique $\mathbf{x}$ maximizing Nash welfare must have $x_1 = x_2 = 1/2$. Since $p, v_1,$ and $v_2$ are all differentiable, we have $x_i \in D_i(p)$ if and only if $\mfrac{\dif p(x_i)}{\dif x_i} = \mfrac{\dif v_i(x_i)}{\dif x_i}$. Since $x_1 = x_2$, we have $\mfrac{\dif p(x_1)}{\dif x_1} = \mfrac{\dif p(x_2)}{\dif x_2}$. Thus implies $\mfrac{\dif v_1(x_1)}{\dif x_1} = \mfrac{\dif v_2(x_2)}{\dif x_2}$, which is a contradiction. We conclude that no such $\mathbf{x}, p$ exist. \end{proof} \section{Omitted proofs}\label{sec:proofs} \thmEuler* \begin{proof} Fix an arbitrary $\B \in \bbrpos^m$ and let $g(\lambda) = f(\lambda\B)$. Since $f$ is differentiable, so is $g$, and its derivative is given by the multidimensional chain rule: $\frac{\dif g(\lambda)}{\dif \lambda} = \sum_{j = 1}^m b_j \frac{\partial f(\lambda\B)}{\partial b_j}$. Since $f$ is homogeneous of degree $r$, we have $f(\lambda\B) = \lambda^r f(\B)$ for all $\lambda \ge 0$. Thus $g(\lambda) = \lambda^r f(\B)$ for all $\lambda \ge 0$, so we can differentiable both sides of this equation to get $\sum_{j = 1}^m b_j \frac{\partial f(\lambda\B)}{\partial b_j} = r\lambda^{r-1} f(\B)$. This holds for all $\lambda \ge 0$, so setting $\lambda = 1$ completes the proof. \end{proof} \lemHomoOneGood* \begin{proof} By Euler's Theorem (Theorem~\ref{thm:euler}), we have $x \mfrac{\dif f(x)}{\dif x} = r f(x)$ for all $x \in \bbrpos$. Let $y = f(x)$. We can solve this differential equation explicitly: \begin{align*} \frac{1}{y}\cdot \frac{\dif y}{\dif x} =&\ \frac{r}{x}\\ \int \frac{1}{y}\cdot \frac{\dif y}{\dif x} \dif x =&\ \int \frac{r}{x} \dif x\\ \int \frac{1}{y} \dif y =&\ r \int \frac{1}{x} \dif x\\ \ln y =&\ r \ln x + \ln c \end{align*} where $c$ (and thus $\ln c$) is some constant. Therefore \begin{align*} e^y =&\ e^{r \ln x + \ln c}\\ y =&\ c x^r \end{align*} Thus $f(x) = c x^r$, as required. \end{proof} \lemOptOneGood* \begin{proof} As in Section~\ref{sec:main}, strong duality for Program~\ref{pro:ces} implies that any optimal $\mathbf{x}$ must satisfy the KKT conditions. Thus $\mathbf{x} \in \Psi(\rho)$ if and only if there exists $q \in \bbrpos$ such that (1) stationarity holds: $\mfrac{\partial v_i(x_i)}{\partial x_i} v_i(x_i)^{\rho -1} \le q$ for all $i \in N$, and if $x_i > 0$, the inequality holds with equality, and (2) complementary slackness holds: either $\sum_{i \in N} x_i = 1$, or $q = 0$. Since we assume that $w_i > 0$ for all $i \in N$, any allocation with $\sum_{i \in N} x_i < 1$ is not Pareto optimal, and thus cannot be optimal for Program~\ref{pro:ces}. In other words, we must have $q > 0$. Thus complementary slackness simply requires that $\sum_{i \in N} x_i = 1$, and we can focus on stationarity. We first handle $\rho = 1$. In this case, $\mfrac{\partial v_i(x_i)}{\partial x_i} v_i(x_i)^{\rho -1} = \mfrac{\partial v_i(x_i)}{\partial x_i} = w_i$. Thus if $\mathbf{x} \in \Psi(\rho)$ we must have $w_i \le q$, and if $x_i > 0$, then $w_i = q$. This implies that $q = \max_{k \in N} w_k$. Thus if $x_i > 0$, then $w_i = \max_{k \in N} w_k$, as required. For the rest of the proof, we assume $r\rho \ne 1$. Since $r,\rho \in (0,1]$, we have $0 < r\rho < 1$. By the definition of $v_i$, for an arbitrary allocation $\mathbf{x}$ and $i \in N$ we have \[ \frac{\partial v_i(x_i)}{\partial x_i} v_i(x_i)^{\rho -1} = (w_i r x_i^{r-1})(w_i^{\rho-1} x_i^{r(\rho-1)}) = r w_i^\rho x_i^{r\rho - 1} \] Thus $q \ge rw_i^\rho x_i^{r\rho - 1}$. Since $r\rho < 1$, if $x_i = 0$, then $x_i^{r\rho-1}$ is undefined. Therefore stationarity is satisfied if and only if $q = r w_i^\rho x_i^{r\rho-1}$ for all $i \in N$, which is equivalent to \begin{align} x_i = (q/r)^{\frac{1}{r\rho-1}} w_i^{\frac{\rho}{1-r\rho}} \label{eq:x-expr} \end{align} Furthermore, if $\mathbf{x}$ satisfies Equation~\ref{eq:x-expr} for all $i \in N$, then $\sum_{i \in N} x_i = 1$ is equivalent to \begin{align*} \sum_{i \in N} (q/r)^{\frac{1}{r\rho-1}} w_i^{\frac{\rho}{1-r\rho}} =&\ 1\\ (q/r)^{\frac{1}{r\rho-1}} =&\ \Big(\sum_{i \in N} {w_i}^{\frac{\rho}{1-r\rho}}\Big)^{-1} \end{align*} Therefore $\mathbf{x}$ satisfies stationarity and complementary slackness (and thus satisfies $\mathbf{x} \in \Psi(\rho)$) if and only if \[ x_i = \frac{{w_i}^{\frac{\rho}{1-r\rho}}}{\sum_{k \in N} {w_k}^{\frac{\rho}{1-r\rho}}} \] as required. \end{proof} \section{Connections to Fisher markets}\label{sec:fisher} The focus of this paper is on markets for quasilinear utilities, where agents can spend as much money as they want, and the amount spent is incorporated into their resulting utility. The other predominant market model assumes each agent $i$ has a finite budget $B_i$ of money to spend, and has no value for leftover money (in general, this implies that each agent $i$ spends exactly $B_i$). This is called the \emph{Fisher market} model.\footnote{There are also more general versions of this model that allow each agent's initial endowment to be goods instead of money (``exchange economies") and/or allow production (``Arrow-Debreu markets").} In this section, we explore connections between our results and the Fisher market model. In the Fisher market model, each agent's utility $u_i(x_i)$ is simply $v_i(x_i)$. For pricing rule $p$, the Fisher market demand set is given by \[ D_i^F(p) = \argmax_{x_i \in \bbrpos^m:\ p(x_i) \le B_i} v_i(x_i) \] We will reserve the notation $D_i(p)$ for the demand set in the quasilinear case, i.e., $D_i(p) = \argmax_{x_i \in \bbrpos^m} (v_i(x_i) - p(x_i))$. For an allocation $\mathbf{x}$, agent budgets $\bigB = (B_1,\dots,B_n)$, and a pricing rule $p$, $(\mathbf{x}, \bigB, p)$ is a \emph{Fisher market Walrasian equilibrium} if (1) $x_i \in D_i^F(p)$ for all $i \in N$, and (2) $\sum_{i \in N} x_{ij} \le 1$ for all $j \in M$, and if good $j$ has nonzero cost, $\sum_{i \in N} x_{ij} = 1$.\footnote{Recall that good $j$ has nonzero cost for $j$ if there is a bundle $x_i$ such that $x_{i\ell} = 0$ for all $\ell \ne j$, but $p(x_i) > 0$.} These are the same two conditions for Walrasian equilibrium in quasilinear markets: the only change is the definition of the demand set. To distinguish, we will use the terms ``Fisher WE" and ``quasilinear WE". \subsection{CES welfare maximization in Fisher markets} In the quasilinear model, agents can express not only their relative values between goods, but also the absolute scale of their valuation (i.e., the ``intensity" of their preferences) by choosing how much money to spend. In contrast, agents in the Fisher market model spend exactly their budget, and so have no way to express the absolute scale of their valuation. This should make us pessimistic about the possibility of CES welfare maximization in the Fisher market model in general. Indeed, consider a single good and two agents with valuations $v_1(x) = x$, $v_2(x) = 2x$. For any $\rho > 0$, any optimal allocation $\mathbf{x} \in \Psi(\rho)$ has $x_2 > x_1$. But if $B_1 = B_2$, any Fisher market Walrasian equilibrium will always have $x_1 = x_2$, since both agents simply spend their entire budget on the single good. However, in general we can convert a quasilinear WE to a Fisher WE if the agents' budgets are sized appropriately. Specifically, we need agent $i$'s budget to be exactly the amount she pays in the quasilinear WE: \begin{theorem}\label{thm:fisher-we} Suppose $(\mathbf{x}, p)$ is a quasilinear WE, and let $B_i = p(x_i)$. Then $(\mathbf{x}, \bigB, p)$ is a Fisher WE. \end{theorem} \begin{proof} For all $i \in N$, $x_i$ is affordable to agent $i$ under $p$ by definition of $B_i$. Suppose there were another bundle $y_i$ such that $p(y_i) \le B_i$ but $v_i(y_i) > v_i(x_i)$. That would contradict $x_i \in D_i(p)$ for the quasilinear case, since $u_i(y_i) = v_i(y_i) - p(y_i) > v_i(x_i) - p(y_i) \ge v_i(x_i) - p(x_i) = u_i(x_i)$. Therefore $x_i \in D_i^F(p)$ for all $i \in N$. Furthermore, the market clearing conditions for Fisher WE and quasilinear WE are identical. We conclude that $(\mathbf{x}, \bigB, p)$ is a Fisher WE. \end{proof} Combining the above result with Theorem~\ref{thm:main} gives us the following corollary for CES welfare maximization: \begin{corollary}\label{cor:fisher-we} Assume each $v_i$ is homogeneous of degree $r$, concave, and differentiable. Let $\rho \in (0, 1]$, and $p(x_i) = \rho r^{\frac{\rho -1}{\rho}} (\sum_{j \in M} q_j x_{ij})^{1/\rho}$, where $q_1,\dots, q_m$ are optimal Lagrange multipliers for Program~\ref{pro:ces}. For $\mathbf{x} \in \Psi(\rho)$, let $B_i = p(x_i)$ for all $i \in N$, Then $(\mathbf{x}, \bigB, p)$ is a Fisher WE. \end{corollary} Perhaps the more interesting connection relates to the welfare function being optimized. In the case of linear pricing, the Fisher market Walrasian equilibria are exactly the budget-weighted maximum Nash welfare allocations.\footnote{Recall that Nash welfare corresponds to $\rho = 0$, and the budget-weighted Nash welfare of an allocation $\mathbf{x}$ is $\prod_{i \in N} v_i(x_i)^{B_i}$.} One natural question is whether the Fisher market equilibria from Theorem~\ref{thm:fisher-we} also optimize a budget-weighted CES welfare function. We answer this in the affirmative. Recall that we define $\Phi_\bigB(\rho, \mathbf{x}) = \big(\sum_{i \in N} B_i v_i(x_i)^{\rho}\big)^{1/\rho}$, and $\Psi_\bigB(\rho) = \argmax_\mathbf{x} \Phi_\bigB(\rho, \mathbf{x})$. \begin{lemma}\label{lem:fisher-double-opt} Assume each $v_i$ is concave and differentiable. Let $\xprime$ be any allocation, let $a_i = v_i(x_i')$ for each $i \in N$, and let $\rho \in (0, 1]$. Then $\xprime \in \Psi(\rho)$ if and only if $\xprime \in \Psi_\mathbf{a}(\rho - 1)$. \end{lemma} \begin{proof} When $\rho = 1$, $\rho - 1 = 0$, so Program~\ref{pro:ces} does not apply, and we must handle this case separately. We first consider $\rho \ne 1$. The Lagrangian for Program~\ref{pro:ces} for $\Psi_\mathbf{a}(\rho-1)$ is $L(\mathbf{x}, \q) = \frac{1}{\rho-1} \sum_{i \in N} a_i v_i(x_i)^{\rho-1} - \sum_{j \in M} q_j (\sum_{i \in N} x_{ij} - 1)$. The KKT conditions imply that $\mathbf{x} \in \Psi_\mathbf{a}(\rho-1)$ if and only if there exist Lagrange multipliers $q_1,\dots, q_m$ such that: \begin{enumerate} \item Stationarity: $\mfrac{\partial L(\mathbf{x}, \q)}{\partial x_{ij}} = a_i v_i(x_i)^{\rho - 2} \mfrac{\partial v_i(x_i)}{\partial x_{ij}} \le 0$ for all $i,j$.\footnote{Note that since $\xprime$ is a fixed allocation, $a_i$ is just some constant, so the differentiation does not affect it.} Furthermore, if $x_{ij} > 0$, the inequality holds with equality. \item Complementary slackness: for all $j \in M$, either $\sum_{i \in N} x_{ij} = 1$, or $q_j = 0$. \end{enumerate} For Program~\ref{pro:ces} for $\Psi(\rho)$, as before we have $L'(\mathbf{x}, \q) = \frac{1}{\rho} \sum_{i \in N} v_i(x_i)^\rho - \sum_{j \in M} q_j (\sum_{i \in N} x_{ij} - 1)$. Thus the KKT conditions imply that $\mathbf{x} \in \Psi(\rho)$ if and only if there exist $q_1',\dots,q_m' \in \bbrpos$ such that (1) $v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}} \le q_j$ for all $i,j$, and when $x_{ij} > 0$, the inequality holds with equality, and (2) for all $j \in M$, either $\sum_{i \in N} x_{ij} = 1$, or $q_j = 0$. Note that if $q_j = q_j'$ for all $j \in M$, the complementary slackness conditions become equivalent. Next, for $\mathbf{x} = \xprime$ we have \[ v_i(x_i')^{\rho - 1} \frac{\partial v_i(x_i')}{\partial x'_{ij}} = v_i(x'_i) v_i(x'_i)^{\rho - 2} \frac{\partial v_i(x'_i)}{\partial x'_{ij}} = a_i v_i(x'_i)^{\rho - 2} \frac{\partial v_i(x'_i)}{\partial x'_{ij}} \] Therefore for given $q_j$, we have $q_j \ge v_i(x'_i)^{\rho - 1} \mfrac{\partial v_i(x'_i)}{\partial x'_{ij}}$ if and only if $q_j \ge a_i v_i(x'_i)^{\rho - 2} \mfrac{\partial v_i(x'_i)}{\partial x'_{ij}}$, and $q_j = v_i(x'_i)^{\rho - 1} \mfrac{\partial v_i(x'_i)}{\partial x'_{ij}}$ if and only if $q_j \ge a_i v_i(x'_i)^{\rho - 2} \mfrac{\partial v_i(x'_i)}{\partial x'_{ij}}$. Now suppose $\xprime \in \Psi(\rho)$. Then there exist $q_1,\dots, q_m \in \bbrpos$ that satisfy both stationarity and complementary slackness. Then as we showed above, $\xprime$ and $q_1,\dots, q_m$ satisfy stationarity for $\Psi_\mathbf{a}(\rho-1)$. Furthermore, the complementary slackness conditions are equivalent, so we have $\xprime \in \Psi_\mathbf{a}(\rho-1)$. Similarly, suppose $\xprime \in \Psi_\mathbf{a}(\rho-1)$. Then there exist $q_1,\dots, q_m$ satisfying stationarity and complementary slackness, so the same $q_1,\dots, q_m$ along with $\xprime$ satisfy the KKT conditions for $\Psi(\rho)$. Therefore $\Psi(\rho)$, and we conclude that $\xprime \in \Psi(\rho)$ if and only if $\xprime \in \Psi_\mathbf{a}(\rho-1)$ for $\rho \ne 1$. All of the above was for $\rho \ne 1$; it remains to handle the case of $\rho = 1$. In this case, we can use the same KKT conditions for $\Psi(\rho)$, but must use a different convex program for $\Psi_\mathbf{a}(\rho-1)$. Consider the following convex program for maximizing Nash welfare (i.e., CES welfare for $\rho = 0$): \begin{alignat}{2} \max\limits_{\mathbf{x} \in \bbrpos^{n\times m}} &\ \sum_{i \in N} a_i \log v_i(x_i) \label{pro:eg} \\ s.t.\ &\ \sum\limits_{i \in N} x_{ij}\leq 1\quad &&\ \forall j \in M \nonumber \end{alignat} This is known as the Eisenberg-Gale program~\cite{Eisenberg1961,Eisenberg1959}. In this case, the stationarity condition requires that $\mfrac{\partial}{\partial x_{ij}} a_i \log v_i(x_i) = a_i v_i(x_i)^{-1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}} \le q_j$ for all $i,j$, and when $x_{ij} > 0$, the inequality holds with equality. Since $\rho = 1$ here, we have $\rho - 2 = - 1$. Thus the stationarity condition for $\Psi_\mathbf{a}(\rho - 1)$ requires that $a v_i(x_i)^{\rho-2} \mfrac{\partial v_i(x_i)}{\partial x_{ij}} \le q_j$ for all $i,j$ (and if $x_{ij} > 0$, this holds with equality). This is exactly what we had above, and since we are using the same KKT conditions for $\Psi(\rho)$, this case reduces to the case for $\rho \ne 1$. Therefore for $\rho = 1$, $\xprime \in \Psi(\rho)$ if and only if $\xprime \in \Psi_\mathbf{a}(\rho-1)$. \end{proof} Combining Theorem~\ref{thm:fisher-we} and Lemma~\ref{lem:fisher-double-opt}, we get: \begin{theorem}\label{thm:full} Assume each $v_i$ is homogeneous of degree $r$, concave, and differentiable, let $\rho \in (0, 1]$, let $q_1,\dots,q_m \in \bbrpos$, and let $p(x_i) = \rho \big(\sum_{j \in M} q_j x_{ij}\big)^{1/\rho}$. Given $\mathbf{x} \in \Psi(\rho)$, let $B_i = p(x_i)$. Then all of the following hold: \begin{enumerate} \item $(\mathbf{x}, p)$ is a quasilinear WE. \item $(\mathbf{x}, \bigB, p)$ is a Fisher WE. \item $\mathbf{x} \in \Psi_\bigB(\rho - 1)$ \end{enumerate} \end{theorem} \begin{proof} The first and second conditions hold by Theorems~\ref{thm:main} and \ref{thm:fisher-we}, respectively. Then Corollary~\ref{cor:utility-price} implies that $p(x_i) = r\rho v_i(x_i)$. Let $a_i = v_i(x_i) = \mfrac{B_i}{r\rho}$. Thus by Lemma~\ref{lem:fisher-double-opt}, we have $\mathbf{x} \in \Psi_\mathbf{a}(\rho-1)$. Since scaling all agents' multipliers by the same factor does not affect $\Psi_\mathbf{a}(\rho-1)$, we have $\mathbf{x} \in \Psi_{r\rho \mathbf{a}}(\rho-1) = \Psi_\bigB(\rho-1)$, as required. \end{proof} It is worth noting that the special case of Theorem~\ref{thm:fisher-we} for $\rho = 1$ and Leontief utilities with $w_{ij} \in \{0,1\}$\footnote{This is also known as the bandwidth allocation setting, where each good represents a link in a network, and agent $i$ has $w_{ij} = 1$ for every link $j$ on a fixed path (and $w_{ij} = 0$ otherwise).} is implied by the work of Kelly et al.~\cite{Kelly1998}. \section{Introduction}\label{sec:intro} Markets are one of the oldest mechanisms for distributing resources; indeed, commodity prices were meticulously recorded in ancient Babylon for over 300 years~\cite{Spek2005,Spek2003}. In a market, buyers and sellers exchange goods according to some sort of pricing system, and \emph{Walrasian equilibrium}\footnote{This is also known as market equilibrium, competitive equilibrium, and general equilibrium, depending on the context.} occurs when the demand of the buyers exactly equals the supply of the sellers. This concept was first studied by Walras in the 1870's~\cite{Walras1874}. In 1954, Arrow and Debreu showed that under some conditions, a Walrasian equilibrium is guaranteed to exist~\cite{Arrow1954}. Most of the literature on Walrasian equilibrium only considers \emph{linear} pricing, meaning the cost of a good is proportional to the quantity purchased. In this paper, we consider the problem of allocating divisible goods to competing agents via a market mechanism. We assume each agent has quasilinear utility: an agent's utility is her value for the resources she obtains (her \emph{valuation}), minus the money she spends (her \emph{payment}). The First Welfare Theorem states that in this setting, the linear-pricing Walrasian equilibria are exactly the allocations maximizing utilitarian welfare, i.e., the sum of agent valuations. Thus linear pricing \emph{implements} utilitarian welfare in Walrasian equilibrium (sometimes abbreviated ``WE"). The result is powerful, but also limiting. Maximizing utilitarian welfare yields the most efficient outcome, but may also cause maximal inequality (see Figure~\ref{fig:linear}). One common alternative is \emph{convex} pricing. In this paper, we study convex pricing rules $p$ of the form \begin{align*} p(x_i) = \Big(\sum_{j} q_j x_{ij}\Big)^{1/\rho} \end{align*} where $x_i$ is \emph{bundle} agent $i$ receives, $x_{ij} \in \bbrpos$ is the fraction of good $j$ she receives, $q_1,\dots,q_m$ are constants, and $\rho \in (0,1]$ determines the curvature of the pricing rule. Like linear pricing, $p$ is still \emph{anonymous}, meaning that agents' payments depend only on their purchases (and not on their preferences, for example). When $\rho =1$, $p$ reduces to linear pricing. When $\rho < 1$, $p$ is strictly convex, meaning that doubling one's consumption will more than double the price. This will make it easy to buy a small amount, but hard to buy a large amount, which intuitively should lead to a more equal distribution of resources. As the curvature of the pricing rule grows, this effect should be amplified, leading to a different equality/efficiency tradeoff. Our work seeks to formalize that claim. We will show that the Walrasian equilibria of these convex pricing rules are guaranteed to maximize a \emph{constant elasticity of substitution} (CES) welfare function, where the choice of $\rho$ determines the specific welfare function and thus the precise equality/efficiency tradeoff (Theorem~\ref{thm:main}). Our result holds for a wide range of agent valuations. \input{water_fig} \paragraph{Convex pricing in the real world.} Convex pricing is especially pervasive in the water sector, where such pricing rules are known as \emph{increasing block tariffs} (IBTs)~\cite{Whittington1992}, typically implemented with discrete blocks of water (hence the name). IBTs have been implemented and empirically studied in Israel~\cite{Becker2015}, South Africa~\cite{Burger2014}, Spain~\cite{Garcia-Rubio2015}, Jordan~\cite{Klassert2018}, and the United States~\cite{Renwick2000}, among many other countries. IBTs are often claimed to promote equality in water access~\cite{Whittington1992}, but there has been limited theoretical evidence supporting this (see~\cite{Monteiro2011} for one of the only examples). On the other hand, a common concern is that IBTs may lead to poor ``economic efficiency"~\cite{Boland2000,Monteiro2011}. Our work shows that at least on a theoretical level, convexity of pricing does not necessarily lead to inefficiency: it simply maximizes a different welfare function than the traditional utilitarian one. In particular, it maximizes a CES welfare function. \paragraph{The Second Welfare Theorem and personalized pricing.} The Second Welfare Theorem is perhaps the most famous theoretical result regarding implementation in Walrasian equilibrium. It states any Pareto optimum can be a WE when an arbitrary redistribution of initial wealth is allowed.\footnote{Specifically, for any Pareto optimal allocation, there exists a redistribution of initial wealth which makes that allocation a WE. However, our quasilinear utility model does not have a concept of initial wealth (alternatively, initial wealth is simply an additive constant in agents' utilities which does not affect their behavior), so this result is not as mathematically relevant. See Section~\ref{sec:prior} for additional discussion.} Another method that achieves the same goal is \emph{personalized pricing}, where different agents can be charged different (linear) prices. In contrast, convex pricing is anonymous: agents purchasing the same bundle always pay the same price. Each of these approaches certainly has its own pros and cons. In this paper, our goal is not to claim that convex pricing is ``better" than other approaches (or vice versa). Regardless of which is ``better" in any given situation, convex pricing \emph{is} widely used in practice, and is often claimed to promote equality. Our goal in this paper is to formally quantify that claim. \subsection{CES welfare functions}\label{sec:ces-intro} A welfare function~\cite{Bergson1938,Samuelson1947} assigns a real number to each possible outcome, with higher numbers (i.e, higher welfare) indicating outcomes that are more desirable to the social planner. Different welfare functions represent different priorities; our focus will be the tradeoff between overall efficiency and individual equality. For a fixed constant $\rho \in (-\infty, 0) \cup (0,1]$, the constant elasticity of substitution (CES) welfare of outcome $\mathbf{x}$ is \[ \Phi(\rho, \mathbf{x}) = \bigg(\sum_{\text{agents } i} v_i(\mathbf{x})^{\rho}\bigg)^{1/\rho} \] where $v_i(\mathbf{x})$ is agent $i$'s value for $\mathbf{x}$. In general, different values of $\rho$ will lead to different optimal allocations, so whenever we say ``maximum CES welfare allocation", we mean with respect to a fixed value of $\rho$. See Section~\ref{sec:model} for an axiomatic characterization of CES welfare functions. For $\rho = 1$, this is utilitarian welfare, i.e., the sum of valuations. The limit as $\rho \to -\infty$ yields max-min welfare (the minimum valuation)~\cite{Rawls2009,Sen1977,Sen1976}, whereas $\rho \to 0$ yields Nash welfare (the product of valuations)~\cite{Kaneko1979,Nash1950}. The closer $\rho$ gets to $-\infty$, the more the social planner cares about individual equality (max-min welfare being the extreme case of this), and the closer $\rho$ gets to 1, the more the social planner cares about overall societal good (utilitarian welfare being the extreme case of this). For this reason, $\rho$ is called the \emph{inequality aversion} parameter, and this family of welfare functions is thought to exhibit an \emph{equality/efficiency} tradeoff. These welfare functions were originally proposed by Atkinson~\cite{Atkinson70}; indeed, his motivation was to measure the level of inequality in a society. Despite being extremely influential in the traditional economics literature (see~\cite{Cowell2011} for a survey), the CES welfare function has received almost no attention in the computational economics community.\footnote{To our knowledge, only three other computational economics papers have studied CES welfare in any context:~\cite{Arunachaleswaran2019,Goel2019nash,Plaut2019}.} Finally, note that $\Phi(\rho, \mathbf{x})$ is defined with respect to the each agent's valuation $v_i$ and \emph{not} her overall quasilinear utility $u_i$. We acknowledge that it is standard to define welfare with respect to the overall utility $u_i$, and we have two reasons for not doing so. First, in the case of scarce resources, a social planner may be interested in equality in \emph{consumption} (e.g., equality in water access), not just equality in utility derived. Second, it turns out mathematically that this is the welfare function maximized by convex pricing WE in our model; the version where $\Phi(\rho, \mathbf{x})$ considers $u_i$ may be not be maximized by the resulting WE. This may yield valuable qualitative insights about convex pricing; for example, does convex pricing lead to equality with respect to consumption but not necessarily with respect to underlying utility? \paragraph{CES welfare in healthcare.} These welfare functions have also seen substantial use in healthcare under the name of \emph{isoelastic welfare functions}. This began with~\cite{Wagstaff1991}, largely motivated by concerns abeout purely utilitarian approaches to healthcare (i.e., allocating resources to maximize total health in a community, without concern for equality). Since these decisions can affect who lives and who dies, significant effort has been invested into understanding the equality/efficiency tradeoff, with this class of welfare functions serving as a theoretical tool~\cite{Dolan1998,Ortun1996,Wagstaff1991}; see Section~\ref{sec:prior} for additional discussion. Despite the ongoing interest in this tradeoff, the healthcare literature has not (to our knowledge) considered convex pricing as a mechanism for balancing equality and efficiency. More broadly, our work can be thought of as weaving together the previously disjoint threads of CES welfare and convex pricing to provide theoretical support for the oft-cited but rarely quantified claim that IBTs promote equality. \section{CES welfare maximization for Leontief valuations}\label{sec:leontief} We say that $v_i$ is \emph{Leontief} if there exist weights $w_1,\dots,w_m \in \bbrpos$ such that \[ v_i(x_i) = \min_{j:\ w_{ij} \ne 0} \frac{x_{ij}}{w_{ij}} \] Leontief valuations are not differentiable, and so Theorem~\ref{thm:main} does not apply. In this section, we handle Leontief valuations as a special case. Although there are many non-differentiable valuations we could consider, there is substantial related work on Leontief valuations (\cite{Goel2019nash,Plaut2019}), so we find it worthwhile to show that our result does indeed extend to this case. Recall Program~\ref{pro:ces}: \begin{alignat*}{2} \max\limits_{\mathbf{x} \in \bbrpos^{n\times m}} &\ \frac{1}{\rho}\sum_{i \in N} v_i(x_i)^\rho \\ s.t.\ &\ \sum\limits_{i \in N} x_{ij}\leq 1\quad &&\ \forall j \in M \nonumber \end{alignat*} We will work with a specialized version of this for Leontief utilities: \begin{alignat}{2} \max\limits_{\mathbf{x} \in \bbrpos^{n\times m}, \bfa \in \bbrpos^m} \frac{1}{\rho}\sum_{i \in N} \alpha_i^\rho &\ \label{pro:leontief}\\ s.t.\ w_{ij} \alpha_i \le&\ x_{ij}\quad &&\ \forall i \in N, j \in M \nonumber\\ \sum\limits_{i \in N} x_{ij}\le&\ 1\quad &&\ \forall j \in M \nonumber \end{alignat} where we use $\bfa$ to denote the vector $(\alpha_1,\dots,\alpha_n) \in \bbrpos^n$. Also recall each agent's demand set $D_i(p) = \argmax_{x_i \in \bbrpos^m}\ \big( v_i(x_i) - p(x_i)\big)$. Similarly to Program~\ref{pro:leontief}, we consider the following equivalent (specialized) convex program for agent $i$'s demand set: \begin{alignat}{2} \max\limits_{x_i \in \bbrpos^m, \alpha_i \in \bbrpos} \big(\alpha_i - p(x_i)\big) &\ \label{pro:leontief-demand}\\ s.t.\ w_{ij} \alpha_i \le&\ x_{ij}\quad &&\ \forall j \in M \nonumber \end{alignat} \begin{theorem}\label{thm:leontief} Assume each $v_i$ is Leontief with weights $w_{i1},\dots,w_{im}$. Then for any $\rho \in (0, 1]$ and any allocation $\mathbf{x}$, we have $\mathbf{x} \in \Psi(\rho)$ if and only if there exist $q_1,\dots, q_m\in \bbrpos$ such that for the pricing rule $p(x_i) = \rho (\sum_{j \in M} q_j x_{ij})^{1/\rho}$, $(\mathbf{x}, p)$ is a WE. Furthermore, $q_1,\dots, q_m$ are optimal Lagrange multipliers (for the $\sum_{i \in N} x_{ij} \le 1$ constraints) for Program~\ref{pro:leontief}. \end{theorem} \begin{proof} We first claim that in an optimal solution $\mathbf{x},\bfa$ to either Program~\ref{pro:leontief} or Program~\ref{pro:leontief-demand}, we have $v_i(x_i) = \alpha_i$ for all $i \in N$: that is, that these programs are doing what we want them to. To see this, note that $\alpha_i \le x_{ij} / w_{ij}$ for all $j$ with $w_{ij} \ne 0$, so $\alpha_i \le v_i(x_i)$. Furthermore, at least one constraint involving $\alpha_i$ must be tight: otherwise, we could increase $\alpha_i$ and thus the objective value. In particular, we must have $\alpha_i = \min_{j:\ w_{ij} \ne 0} \frac{x_{ij}}{w_{ij}} = v_i(x_i)$. Thus Program~\ref{pro:leontief-demand} is indeed maximizing $v_i(x_i) - p(x_i)$, so $x_i \in D_i(p)$ if and only if $(x_i, \alpha_i)$ is optimal for Program~\ref{pro:leontief-demand} (for some $\alpha_i$). Similarly, Program~\ref{pro:leontief} is indeed maximizing $\frac{1}{\rho}\sum_{i \in N} v_i(x_i)^\rho$ subject to $\sum_{i \in N} x_{ij} \le 1$ for all $j \in M$, so $(\mathbf{x}, \bfa)$ is optimal for Program~\ref{pro:leontief} if and only if $\mathbf{x}$ is optimal for Program~\ref{pro:ces}. Therefore $\mathbf{x} \in \Psi(\rho)$ if and only if $(\mathbf{x}, \bfa)$ is optimal for Program~\ref{pro:leontief} (for some $\bfa$). Next, we write the Lagrangian of Program~\ref{pro:leontief}:\footnote{As in the proof of Theorem~\ref{thm:main}, we omit the $\mathbf{x} \in \bbrpos^{m\times n}$ constraint from the Lagrangian incorporate it into the KKT conditions instead.} \[ L(\mathbf{x}, \bfa, \q, \bflam) = \frac{1}{\rho} \sum_{i \in N} \alpha_i^\rho - \sum_{i \in N} \sum_{j \in M} \lambda_{ij} (w_{ij} \alpha_i - x_{ij}) - \sum_{j \in M} q_j \Big(\sum_{i \in N} x_{ij} - 1\Big) \] We have strong duality by Slater's condition, so the KKT conditions are both necessary and sufficient for optimality. That is, $(\mathbf{x}, \bfa)$ is optimal if and only if there exist $\q \in \bbrpos^m$, $\bflam \in \bbrpos^{m\times n}$ such that all of the following hold:\footnote{As in the proof of Theorem~\ref{thm:main}, primal and dual feasibility are trivially satisfied.} \begin{enumerate} \item Stationarity for $\mathbf{x}$: $\mfrac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial x_{ij}} \le 0$ for all $i,j$. Furthermore, if $x_{ij} > 0$, the inequality holds with equality. \item Stationarity for $\bfa$: $\mfrac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial \alpha_i} \le 0$ for all $i \in N$. Furthermore, if $\alpha_i > 0$, the inequality holds with equality. \item Complementary slackness for $\q$: for all $j \in M$, either $\sum_{i \in N} x_{ij} = 1$, or $q_j = 0$. \item Complementary slackness for $\bflam$: for all $i \in N$, $j\in M$, either $w_{ij} \alpha_i = x_{ij}$ or $\lambda_{ij} = 0$. \end{enumerate} Similarly, let $L_i'$ denote the Lagrangian of Program~\ref{pro:leontief-demand} for agent $i$: \[ L_i'(x_i, \alpha_i, \lambda_i) = \alpha_i - p(x_i) - \sum_{j \in M} \lambda_{ij} (w_{ij} \alpha_i - x_{ij}) \] where $\lambda_i = (\lambda_{i1},\dots,\lambda_{im}) \in \bbrpos^m$. We again have strong duality, so the KKT conditions are again necessary and sufficient. Let $L_i'(x_i, \alpha_i, \lambda_i)$ denote the Lagrangian of this program; then $(x_i, \alpha_i)$ is optimal for Program~\ref{pro:leontief-demand} if and only if all of the following hold: \begin{enumerate} \item Stationarity for $x_i$: $\mfrac{\partial L_i'(x_i, \alpha_i, \lambda_i)}{\partial x_{ij}} \le 0$ for all $j \in M$. If $x_{ij} > 0$, the inequality holds with equality. \item Stationarity for $\alpha_i$: $\mfrac{\partial L_i'(x_i, \alpha_i, \lambda_i)}{\partial \alpha_i} \le 0$. If $\alpha_i > 0$, the inequality holds with equality. \item Complementary slackness for $\lambda_i$: for all $i \in N$, $j\in M$, either $w_{ij} \alpha_i = x_{ij}$ or $\lambda_{ij} = 0$. \end{enumerate} We will claim that $(\mathbf{x}, \bfa, \q, \bflam)$ is optimal for Program~\ref{pro:leontief} if and only if for all $i \in N$, $(x_i, \alpha_i, \alpha_i^{1-\rho} \lambda_i)$ is optimal for Program~\ref{pro:leontief-demand}. Essentially, we show that if complementary slackness holds (for either program), the stationarity conditions are equivalent. To begin, we can explicitly compute the relevant partial derivatives for given $\mathbf{x}, \bfa, \q, \bflam$, with $p(x_i) = \rho (\sum_{j \in M} q_j x_{ij})^{1/\rho}$: \begin{align*} \frac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial x_{ij}} =&\ \lambda_{ij} - q_j \\ \frac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial \alpha_i} =&\ \alpha_i^{\rho - 1} - \sum_{j \in M} \lambda_{ij} w_{ij}\\ \frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial x_{ij}} =&\ \lambda'_{ij} - q_j \Big(\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{\frac{1-\rho}{\rho}}\\ \frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial \alpha_i} =&\ 1 - \sum_{j \in M} \lambda'_{ij} w_{ij} \end{align*} \textbf{Part 1:} $(\implies)$ Suppose that $\mathbf{x} \in \Psi(\rho)$. Then there exist $\bfa, \q, \bflam$ such that the KKT conditions for Program~\ref{pro:leontief} are satisfied for $(\mathbf{x}, \bfa, \q, \bflam)$. We first claim that $\alpha_i > 0$ for all $i \in N$. Suppose not: stationarity implies that $\alpha_i^{\rho-1} \le \sum_{j \in M} \lambda_{ij} w_{ij}$, but since $\rho - 1< 0$, the left hand side is not defined for $\alpha_i = 0$. Thus $\alpha_i > 0$. Therefore by stationarity for $\alpha_i$, we have $\alpha_i^{\rho-1} = \sum_{j \in M} \lambda_{ij} w_{ij}$. Let $\lambda'_{ij} = \alpha_i^{1-\rho} \lambda_{ij}$ for all $i,j$\footnote{Note that this is \emph{not} defining $\lambda'_{ij}$ to be a function of $\alpha_i$. This is defining $\lambda'_{ij}$ based on a fixed value of $\alpha_i$: in particular, the value from $(\mathbf{x}, \bfa, \q, \bflam)$, which we assumed to be optimal for Program~\ref{pro:leontief}. Consequently, the derivatives in the KKT conditions treat $\lambda'_{ij}$ as a constant.}. Then $\alpha_i^{\rho-1} = \sum_{j \in M} \lambda_{ij} w_{ij}$ is equivalent to $1 = \sum_{j \in M} \lambda'_{ij} w_{ij}$, and thus $\mfrac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial \alpha_i} = 0$ for all $i \in N$. Thus for all $i \in N$, $(x_i, \alpha_i, \lambda'_i)$ satisfies stationarity for $\alpha_i$ for Program~\ref{pro:leontief-demand}. We now turn to the $x_{ij}$ variables. Stationarity for $x_{ij}$ in Program~\ref{pro:leontief} implies that $\lambda_{ij} = q_j$ whenever $x_{ij} > 0$. Furthermore, complementary slackness for $\lambda_{ij}$ implies that if $\lambda_{ij} > 0$, $w_{ij} \alpha_i = x_{ij}$. Thus whenever $q_j > 0$ and $x_{ij} > 0$, $w_{ij} \alpha_i = x_{ij}$ and $\lambda_{ij} = q_j$. Therefore for all $i,j$, \begin{align*} \frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial x_{ij}} =&\ \lambda'_{ij} - q_j \Big(\sum_{\ell: q_\ell, x_{i\ell} > 0} q_\ell x_{i\ell} \Big)^{\frac{1-\rho}{\rho}}\\ =&\ \lambda'_{ij} - q_j \Big(\sum_{\ell \in M} \lambda_{i\ell} w_{i\ell} \alpha_i\Big)^{\frac{1-\rho}{\rho}}\\ =&\ \lambda'_{ij} - q_j \Big(\alpha_i \sum_{\ell \in M} \lambda_{i\ell} w_{i\ell} \Big)^{\frac{1-\rho}{\rho}}\\ =&\ \lambda'_{ij} - q_j (\alpha_i \alpha_i^{\rho-1})^{\frac{1-\rho}{\rho}}\\ =&\ \alpha_i^{1-\rho} \lambda_{ij} - q_j \alpha_i^{1-\rho}\\ =&\ \alpha_i^{1-\rho} \frac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial x_{ij}} \end{align*} We have $\mfrac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial x_{ij}} \le 0$ for all $i,j$ by stationarity (and the inequality holds with equality when $x_{ij} > 0$), so $\frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial x_{ij}} \le 0$ for all $j \in M$ (and the inequality holds with equality when $x_{ij} > 0$). Thus for each $i \in N$, $(x_i, \alpha_i, \lambda'_i)$ satisfies stationarity for Program~\ref{pro:leontief-demand} for $x_{ij}$ for all $j \in M$. As mentioned above, we have $w_{ij} \alpha_i = x_{ij}$ whenever $\lambda_{ij} > 0$. Since $\lambda'_{ij} > 0$ if and only if $\lambda_{ij} > 0$, we have $w_{ij} \alpha_i = x_{ij}$ whenever $\lambda'_{ij} > 0$. Thus for each $i \in N$, $(x_i, \alpha_i, \lambda'_i)$ satisfies complementary slackness for Program~\ref{pro:leontief-demand}. Therefore $(x_i, \alpha_i, \lambda'_i)$ satisfies the KKT conditions, and thus is optimal for Program~\ref{pro:leontief-demand}. Therefore $x_i \in D_i(p)$ for all $i \in N$. The complementary slackness condition for $\q$ is identical to the market clearing condition, so we conclude that $(\mathbf{x}, p)$ is a WE. \textbf{Part 2:} $(\impliedby)$ Suppose that $(\mathbf{x}, p)$ is a WE, where $p(x_i) = \rho (\sum_{j \in M} q_j x_{ij})^{1/\rho}$ for constants $q_1,\dots,q_m \in \bbrpos$. Then $x_i \in D_i(p)$ for all $i \in N$, so there exists $\bfa, \bflamp$ such that $(x_i, \alpha_i, \lambda'_i)$ is optimal for Program~\ref{pro:leontief-demand} for all $i \in N$. Thus by stationarity, we have $\frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial \alpha_i} \le 0$ and $\frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial x_{ij}} \le 0$ for all $i,j$ (and if $\alpha_i > 0$ and $x_{ij} > 0$, the inequalities hold with equality). Using the definition of $p$, we have $\frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial x_{ij}} = \lambda'_{ij} - q_j \big(p(x_i)/\rho\big)^{1-\rho}$. Thus $1 \le \sum_{j \in M} \lambda'_{ij} w_{ij}$ and $\lambda'_{ij} \le q_j \big(p(x_i)/\rho\big)^{1-\rho}$. We first claim that $\alpha_i > 0$ for all $i \in N$. For each agent $i$, there must exist $j \in M$ such that $\lambda'_{ij} > 0$ and $w_{ij} > 0$: otherwise $1 \le \sum_{j \in M} \lambda'_{ij} w_{ij}$ would be impossible. Consider any such $j$: then $0 < \lambda'_{ij} \le q_j \big(p(x_i)/\rho\big)^{1-\rho}$, so we must have $p(x_i) > 0$. Suppose $\alpha_i = 0$: then the optimal objective value of Program~\ref{pro:leontief-demand} is $\alpha_i - p(x_i) < 0$. But setting $x_{ij} = 0$ for all $j \in M$ achieves an objective value of 0, so $\alpha_i - p(x_i) < 0$ cannot be optimal. This is a contradiction, and so $\alpha_i > 0$ for all $i \in N$. Returning to the stationarity conditions, we then have $1 = \sum_{j \in M}\lambda'_{ij} w_{ij}$. Complementary slackness implies that $w_{ij} \alpha_i = x_{ij}$ whenever $\lambda'_{ij} > 0$, so we get \begin{align*} \alpha_i =&\ \sum_{j \in M} \lambda'_{ij} w_{ij} \alpha_i \\ \alpha_i =&\ \sum_{j: \lambda'_{ij} > 0} \lambda'_{ij} w_{ij} \alpha_i \\ \alpha_i =&\ \sum_{j \in M} \lambda'_{ij} x_{ij} \end{align*} Combining this with $\lambda'_{ij} = q_j \big(p(x_i)/\rho\big)^{1-\rho}$ whenever $x_{ij} > 0$ gives us \begin{align*} \alpha_i =&\ \sum_{j: x_{ij} > 0} \lambda'_{ij} x_{ij}\\ =&\ \sum_{j \in M} q_j x_{ij} \big(p(x_i)/\rho\big)^{1-\rho}\\ =&\ \big(p(x_i)/\rho\big)^{1-\rho} \sum_{j \in M} q_j x_{ij} \\ =&\ \big(p(x_i)/\rho\big)^{1-\rho} \big(p(x_i)/\rho\big)^\rho \\ =&\ p(x_i)/\rho \end{align*} Now let $\lambda_{ij} = \alpha_i^{\rho - 1} \lambda'_{ij}$ for all $i,j$. We claim that $(\mathbf{x}, \bfa, \q, \bflam)$ satisfies the KKT conditions for Program~\ref{pro:leontief}. For each $(i,j)$ pair, we have \[ \frac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial \alpha_i} = \alpha_i^{\rho - 1} - \sum_{j \in M} \lambda_{ij} w_{ij} = \alpha_i^{\rho - 1}\Big(1 - \sum_{j \in M} \lambda'_{ij} w_{ij}\Big) = \alpha_i^{\rho - 1} \frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial \alpha_i} \] Since $\alpha_i > 0$, stationarity for Program~\ref{pro:leontief-demand} implies that $\frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial \alpha_i} = 0$, so we have $\frac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial \alpha_i} = 0$. Next, we have \begin{align*} \frac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial x_{ij}} =&\ \lambda_{ij} - q_j\\ =&\ \alpha_i^{\rho - 1} \lambda'_{ij} - q_j\\ =&\ \alpha_i^{\rho - 1} ( \lambda'_{ij} - q_j \alpha_i^{1-\rho})\\ =&\ \alpha_i^{\rho - 1} \Big(\lambda'_{ij} - q_j \big(p(x_i)/\rho\big)^{1-\rho}\Big)\\ =&\ \alpha_i^{\rho - 1} \frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial x_{ij}} \end{align*} Stationarity for Program~\ref{pro:leontief-demand} implies that $\frac{\partial L_i'(x_i, \alpha_i, \lambda'_i)}{\partial x_{ij}} \le 0$ for all $i,j$ (and when $x_{ij} > 0$, this holds with equality), so we have $\frac{\partial L(\mathbf{x}, \bfa, \q, \bflam)}{\partial x_{ij}}$ for all $i,j$ (and when $x_{ij} > 0$, this holds with equality). Thus we have shown that $(\mathbf{x}, \bfa, \q, \bflam)$ satisfies stationarity for Program~\ref{pro:leontief}. As before, the market clearing condition is equivalent to complementary slackness for $\q$. By complementary slackness for $\bflamp$ (for Program~\ref{pro:leontief-demand}), we have $w_{ij} \alpha_i = x_{ij}$ whenever $\lambda'_{ij} > 0$. By definition, $\lambda'_{ij} > 0$ if and only if $\lambda_{ij} > 0$, so this implies the required complementary slackness for $\bflam$ (for Program~\ref{pro:leontief}). Therefore $(\mathbf{x}, \bfa, \q, \bflam)$ satisfies the KKT conditions for Program~\ref{pro:leontief}, and thus is optimal for that program. We conclude that $\mathbf{x} \in \Psi(\rho)$. \end{proof} \section{The First Welfare Theorem and linear pricing}\label{sec:linear} Recall our main result: \mainThm* For this class of valuations, Theorem~\ref{thm:main} for $\rho = 1$ implies the First Welfare Theorem: $p$ becomes a linear pricing rule, and CES welfare for $\rho = 1$ is just utilitarian welfare. In particular, Theorem~\ref{thm:main} implies both the existence of a WE, and that every WE maximizes utilitarian welfare. Typically, the ``the First Welfare Theorem" refers to just half of this: that every WE maximizes utilitarian welfare. The reason is that WE are not always guaranteed to exist: for divisible goods, generally at least concavity or quasi-concavity of valuations is necessary. On the other hand, very few assumptions are needed to show that linear pricing equilibria always maximize utilitarian welfare; for example, divisibility of goods is not needed. We provide a proof of this below. \begin{theorem}[The First Welfare Theorem]\label{thm:first-welfare} Let $\X_i \subset \bbr^m$ denote the set of feasible bundles for agent $i$ (not necessarily convex, and not necessarily the same for all agents). Let $D_i(p) = \argmax_{x_i \in \X_i} (v_i(x_i) - p(x_i))$ and assume $p$ is linear. Then if $(\mathbf{x}, p)$ is a WE, $\mathbf{x}$ maximizes utilitarian welfare. \end{theorem} \begin{proof} Since $p$ is linear, there exist $q_1,\dots,q_m$ such that $p(y_i) = \sum_{j \in M} q_j y_{ij}$ for any bundle $y_i$. Consider an arbitrary feasible allocation $\mathbf{y}$. Since $(\mathbf{x}, p)$ is a WE, we have $x_i \in D_i(p)$, so $v_i(x_i) - p(x_i) \ge v_i(y_i) - p(y_i)$. Therefore \begin{align*} v_i(x_i) - \sum_{j \in M} q_j x_{ij} \ge&\ v_i(y_i) - \sum_{j \in M} q_j y_{ij}\\ \sum_{i \in N} v_i(x_i) - \sum_{i \in N} \sum_{j \in M} q_j x_{ij} \ge&\ \sum_{i \in N} v_i(y_i) - \sum_{i \in N} \sum_{j \in M} q_j x_{ij}\\ \sum_{i \in N} v_i(x_i) - \sum_{j \in M} q_j \sum_{i \in N} x_{ij} \ge&\ \sum_{i \in N} v_i(y_i) - \sum_{j \in M} q_j \sum_{i \in N} x_{ij} \end{align*} Furthermore, $\sum_{i \in N} x_{ij} = 1$ for all $j \in M$ with $q_j > 0$. Also, since $\mathbf{y}$ is a valid allocation, $\sum_{i \in N} y_{ij} \le 1$ for all $j \in M$. Therefore \begin{align*} \sum_{i \in N} v_i(x_i) - \sum_{j \in M} q_j \sum_{i \in N} x_{ij} \ge&\ \sum_{i \in N} v_i(y_i) - \sum_{j \in M} q_j \sum_{i \in N} x_{ij}\\ \sum_{i \in N} v_i(x_i) - \sum_{j \in M} q_j \ge&\ \sum_{i \in N} v_i(y_i) - \sum_{j \in M} q_j\\ \sum_{i \in N} v_i(x_i) \ge&\ \sum_{i \in N} v_i(y_i) \end{align*} Thus the utilitarian welfare of $\mathbf{x}$ is at least as high as that of any other allocation. We conclude that $\mathbf{x}$ maximizes utilitarian welfare. \end{proof} Note that no assumptions at all were made on the nature of the valuations: all we needed was $x_i \in \argmax_{y_i \in \X_i} (v_i(y_i) - p(y_i))$, and $\sum_{j \in M} x_{ij} = 1$ whenever $q_j > 0$. The most natural cases are $\X_i = \bbrpos^m$ (divisible goods) and $\X_i = \{0,1\}^m$ (indivisible goods), but the result does hold more broadly. \section{Main result}\label{sec:main} We begin with our main result: for a wide range of valuations and any $\rho \in (0,1]$, a simple convex pricing rule leads to CES welfare maximization in Walrasian equilibrium. Our pricing rule has many additional interesting properties; to avoid redundancy, we refer the reader back to our discussion in Section~\ref{sec:results}. On a high level, the proof relies on the KKT conditions for CES welfare maximization and the KKT conditions for each agent's demand set, and uses Euler's Theorem for homogeneous functions to conjoin the two. This will result in the following theorem: \begin{restatable}{theorem}{mainThm}\label{thm:main} Assume each $v_i$ is homogeneous of degree $r$, concave, and differentiable. For any $\rho \in (0, 1]$ and any allocation $\mathbf{x}$, we have $\mathbf{x} \in \Psi(\rho)$ if and only if there exist $q_1,\dots, q_m\in \bbrpos$ such that for the pricing rule \[ p(x_i) = \rho r^{\frac{\rho -1}{\rho}} \Big(\sum_{j \in M} q_j x_{ij}\Big)^{1/\rho}, \] $(\mathbf{x}, p)$ is a WE. Furthermore, $q_1,\dots, q_m$ are optimal Lagrange multipliers for Program~\ref{pro:ces}. \end{restatable} \subsection{Proof setup} We begin by setting up the two relevant convex programs and proving several lemmas. For valuations $v_1\dots v_n$, nonnegative multipliers $\mathbf{a} = a_1\dots a_n$, and $\rho \in (-\infty, 0) \cup(0,1]$, consider the following nonlinear program for maximizing CES welfare: \begin{alignat}{2} \max\limits_{\mathbf{x} \in \bbrpos^{n\times m}} &\ \frac{1}{\rho}\sum_{i \in N} a_i v_i(x_i)^\rho \label{pro:ces} \\ s.t.\ &\ \sum\limits_{i \in N} x_{ij}\leq 1\quad &&\ \forall j \in M \nonumber \end{alignat} Since the constraints are linear and the objective function is concave (since $\rho \le 1$), Program~\ref{pro:ces} is a convex program. Program~\ref{pro:ces} depends on $\rho$, but we will leave this implicit when clear from context: we will simply say ``$\mathbf{x}$ is optimal for Program~\ref{pro:ces}" as opposed to ``$\mathbf{x}$ is optimal for Program~\ref{pro:ces} with respect to $\rho$". Note also that we are maximizing $\frac{1}{\rho}\sum_{i \in N} a_i v_i(x_i)^\rho$ instead of the true CES welfare $\Phi_\mathbf{a}(\rho, \mathbf{x}) = (\sum_{i \in N} a_i v_i(x_i)^\rho)^{1/\rho}$; this will lead to the same optimal allocation $\mathbf{x}$ and will simplify the analysis. When $\mathbf{a}$ is not specified, we assume that $\mathbf{a} = \one$. Nonuniform multipliers will only be used in Appendix~\ref{sec:fisher} when we consider connections to Fisher markets, but we include them here for completeness. Next, consider each agent's demand set given a pricing rule $p$: \begin{align} D_i(p) = \argmax_{x_i \in \bbrpos^m}\ \big(v_i(x_i) - p(x_i)\big) \label{pro:demand} \end{align} When $p$ is convex (as in Theorem~\ref{thm:main}), $-p$ is concave. Since $v_i$ is also concave, $v_i(x_i) - p(x_i)$ is concave, so each agent's demand set defines a convex program (Program~\ref{pro:demand}). Program~\ref{pro:demand} depends on $i$, the agent in question, but again we leave this implicit when it is clear from context. We will also use the following theorem, due to Euler. We include a short proof in Appendix~\ref{sec:proofs}.\footnote{The reason we provide a proof is that this theorem is often stated with the requirement of continuous differentiability, but in fact only requires differentiability; to avoid any confusion, we provide a proof only using differentiability.} \begin{restatable}[Euler's Theorem for homogeneous functions]{theorem}{thmEuler}\label{thm:euler} Let $f: \bbrpos^m \to \bbr$ be differentiable and homogenous of degree $r$. Then for any $\B = (b_1,\dots b_m) \in \bbrpos^m$, $\sum_{j = 1}^m b_j \mfrac{\partial f(\B)}{\partial b_j} = r f(\B)$. \end{restatable} Before we state and prove Theorem~\ref{thm:main}, we note one other property: for a pricing rule of the form $p(x_i) = c(\sum_{j \in M} q_j x_{ij})^{1/\rho}$ where $c>0$, good $j$ has nonzero cost (for the purposes of Walrasian equilibrium) if and only if $q_j = 0$. \subsection{Proof of Theorem~\ref{thm:main}} The proof of Theorem~\ref{thm:main} is divided into three parts. The first part involves setting up the KKT conditions for Programs~\ref{pro:ces} and \ref{pro:demand}. The second assumes that $\mathbf{x} \in \Psi(\rho)$ and proves that $(\mathbf{x}, p)$ is a WE, and the third assumes that $(\mathbf{x}, p)$ is a WE and proves that $\mathbf{x} \in \Psi(\rho)$. \begin{proof}[Proof of Theorem~\ref{thm:main}] \textbf{Part 1: Setup.} Let $\q$ denote the vector $(q_1,\dots,q_m) \in \bbrpos^m$; then the Lagrangian of Program~\ref{pro:ces} is $L(\mathbf{x}, \q) = \frac{1}{\rho} \sum_{i \in N} v_i(x_i)^\rho - \sum_{j \in M} q_j (\sum_{i \in N} x_{ij} - 1)$.\footnote{The expert reader may notice that we have omitted the $\mathbf{x} \in \bbrpos^{m\times n}$ constraint from the Lagrangian. We do this to slightly simplify the analysis. The effect on the KKT conditions is that stationarity changes from ``For all $i,j$, $\frac{\partial L(\mathbf{x}, \q)}{\partial x_{ij}} = 0$" to ``For all $i,j$, $\frac{\partial L(\mathbf{x}, \q)}{\partial x_{ij}} \le 0$, and the inequality holds with equality when $x_{ij} > 0$".} Since Program~\ref{pro:ces} is convex and satisfies strong duality by Slater's condition, the KKT conditions are both necessary and sufficient for optimality. That is, $\mathbf{x}$ is optimal for Program~\ref{pro:ces} (which is equivalent to $\mathbf{x} \in \Psi(\rho)$) if and only if there exist Lagrange multipliers $\q \in \bbrpos^m$ such that both of the following hold:\footnote{The KKT conditions also include primal feasibility and dual feasibility. Since we will only work with valid allocations $\mathbf{x}$ and nonnegative $q_1,\dots,q_m$, these two conditions are trivially satisfied.} \begin{enumerate} \item Stationarity: $\mfrac{\partial L(\mathbf{x}, \q)}{\partial x_{ij}} \le 0$ for all $i,j$. Furthermore, if $x_{ij} > 0$, the inequality holds with equality. \item Complementary slackness: for all $j \in M$, either $\sum_{i \in N} x_{ij} = 1$, or $q_j = 0$. \end{enumerate} For a given $(i,j)$ pair, $\mfrac{\partial L(\mathbf{x}, \q)}{\partial x_{ij}}$ is equal to $v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}} - q_j$, so stationarity for Program~\ref{pro:ces} is equivalent to: $q_j \ge v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$ for all $i,j$, and when $x_{ij} > 0$, the inequality holds with equality. Next consider Program~\ref{pro:demand}, which defines each agent's demand set. This program has no constraints (other than $x_i \in \bbrpos^m$), so we can ignore complementary slackness. Thus by the KKT conditions, $x_i \in D_i(p)$ if and only if for every $j \in M$, $\mfrac{\partial v_i(x_i)}{\partial x_{ij}} \le \mfrac{\partial p(x_i)}{\partial x_{ij}}$, and if $x_{ij} > 0$, the inequality holds with equality (stationarity). We can explicitly compute the partial derivatives of $p$: $\mfrac{\partial p(x_i)}{\partial x_{ij}} = r^{\frac{\rho -1}{\rho}} q_j \big(\sum_{\ell \in M} q_\ell x_{i\ell}\big)^{\frac{1-\rho}{\rho}}$. \textbf{Part 2: Optimal CES welfare implies WE.} Suppose that $\mathbf{x} \in \Psi(\rho)$. Then there exists $\q \in \bbrpos^m$ such that $q_j \ge v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$ for all $j$, and $q_j = v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$ whenever $x_{ij} > 0$. Using the latter in combination with Euler's Theorem for homogeneous functions, for each $(i,j)$ pair we have \begin{align*} \frac{\partial p(x_i)}{\partial x_{ij}} =&\ r^{\frac{\rho -1}{\rho}} q_j \Big(\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{\frac{1-\rho}{\rho}}\\ =&\ q_j \Big(r^{-1} \sum_{\ell: x_{i\ell} > 0} q_\ell x_{i\ell}\Big)^{\frac{1-\rho}{\rho}}\\ =&\ q_j \Big(r^{-1} \sum_{\ell: x_{i\ell} > 0} v_i(x_i)^{\rho - 1} \frac{\partial v_i(x_i)}{\partial x_{i\ell}} x_{i\ell}\Big)^{\frac{1-\rho}{\rho}} &&\ \text{(stationarity for $x_{i\ell}$ when $x_{i\ell} > 0$)}\\ =&\ q_j \Big(r^{-1} v_i(x_i)^{\rho - 1} \sum_{\ell \in M} \frac{\partial v_i(x_i)}{\partial x_{i\ell}} x_{i\ell}\Big)^{\frac{1-\rho}{\rho}}\\ =&\ q_j \big(r^{-1} v_i(x_i)^{\rho - 1} r v_i(x_i)\big)^{\frac{1-\rho}{\rho}} \quad\quad &&\ \text{(Euler's Theorem)}\\ =&\ q_j v_i(x_i)^{1-\rho} \end{align*} Thus $\mfrac{\partial p(x_i)}{\partial x_{ij}} = q_j v_i(x_i)^{1-\rho}$. Next, we claim that $x_i \in D_i(p)$ for all $i \in N$. Fix an agent $i$; we show by case analysis that $x_i$ satisfies stationarity (for Program~\ref{pro:demand}) for each $j \in M$. Case 1: $q_j = v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$. Then $\mfrac{\partial p(x_i)}{\partial x_{ij}} = q_j v_i(x_i)^{1-\rho} = v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}} v_i(x_i)^{1-\rho} = \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$, and we are done. Case 2: $x_{ij} = 0$ and $q_j \ge v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$. Then similarly, $\mfrac{\partial p(x_i)}{\partial x_{ij}} = q_j v_i(x_i)^{1-\rho} \ge v_i(x_i)^{\rho - 1} \mfrac{\partial v_i(x_i)}{\partial x_{ij}} v_i(x_i)^{1-\rho} = \mfrac{\partial v_i(x_i)}{\partial x_{ij}}$, and again we are done. Therefore $x_i \in D_i(p)$ for all $i \in N$. Since $\mathbf{x}$ is a valid allocation, $\sum_{i \in N} x_{ij} \le 1$ for all $j \in M$. This, combined with complementary slackness for Program~\ref{pro:ces}, is identical to the market clearing condition for Walrasian equilibrium. Thus we have shown that if $\mathbf{x} \in \Psi(\rho)$, there exist $q_1,\dots, q_m$ (which are optimal Lagrange multipliers for Program~\ref{pro:ces}) such that for pricing rule $p$ as defined, $(\mathbf{x}, p)$ is a WE. \textbf{Part 3: WE implies optimal CES welfare.} This is similar to Part 2. Suppose there exists $\q \in \bbrpos^m$ such that for pricing rule $p(x_i) = \rho r^{\frac{\rho -1}{\rho}} (\sum_{j \in M} q_j x_{ij})^{1/\rho}$, $(\mathbf{x}, p)$ is a WE. Recall the partial derivatives of $p$: $\mfrac{\partial p(x_i)}{\partial x_{ij}} = q_j \big(r^{-1} \sum_{\ell \in M} q_\ell x_{i\ell}\big)^{\frac{1-\rho}{\rho}}$. We multiply each side by $x_{ij} r^{-1}$, and sum both sides over $j$: \begin{align*} r^{-1} \sum_{j \in M} x_{ij} \frac{\partial p(x_i)}{\partial x_{ij}} =&\ \Big(r^{-1}\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{\frac{1-\rho}{\rho}} r^{-1} \sum_{j \in M} q_j x_{ij}\\ r^{-1}\sum_{j: x_{ij} > 0} x_{ij} \frac{\partial p(x_i)}{\partial x_{ij}} =&\ \Big(r^{-1}\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{\frac{1-\rho}{\rho} + 1} \end{align*} Since $(\mathbf{x}, p)$ is a WE, we have $x_i \in D_i(p)$ for all $i \in N$. Thus $\mfrac{\partial v_i(x_i)}{\partial x_{ij}} = \mfrac{\partial p(x_i)}{\partial x_{ij}}$ whenever $x_{ij} > 0$, so \begin{align*} r^{-1}\sum_{j: x_{ij} > 0} x_{ij} \frac{\partial v_i(x_i)}{\partial x_{ij}} =&\ \Big(r^{-1}\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{1/\rho}\\ r^{-1}\sum_{j \in M} x_{ij} \frac{\partial v_i(x_i)}{\partial x_{ij}} =&\ \Big(r^{-1}\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{1/\rho}\\ v_i(x_i) =&\ \Big(r^{-1}\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{1/\rho} \quad\quad \text{(Euler's Theorem)}\\ v_i(x_i)^{\rho-1} =&\ \Big(r^{-1}\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{\frac{\rho-1}{\rho}} \end{align*} Using this in combination with $\mfrac{\partial p(x_i)}{\partial x_{ij}} = q_j \big(r^{-1} \sum_{\ell \in M} q_\ell x_{i\ell}\big)^{\frac{1-\rho}{\rho}}$, we get \[ q_j = \frac{\partial p(x_i)}{\partial x_{ij}}\Big(r^{-1}\sum_{\ell \in M} q_\ell x_{i\ell}\Big)^{\frac{\rho-1}{\rho}} = \frac{\partial p(x_i)}{\partial x_{ij}} v_i(x_i)^{\rho - 1} \] Next, we claim that $(\mathbf{x}, \q)$ satisfies stationarity for Program~\ref{pro:ces}. We proceed by case analysis for each $(i,j)$ pair. Stationarity for Program~\ref{pro:demand} implies that these are the only two possible cases. Case 1: $\mfrac{\partial v_i(x_i)}{\partial x_{ij}} = \mfrac{\partial p(x_i)}{\partial x_{ij}}$. In this case, $q_j = \mfrac{\partial v_i(x_i)}{\partial x_{ij}} v_i(x_i)^{\rho - 1}$, and we are done. Case 2: $x_{ij} = 0$ and $\mfrac{\partial v_i(x_i)}{\partial x_{ij}} \le \mfrac{\partial p(x_i)}{\partial x_{ij}}$. In this case we have $q_j \ge \mfrac{\partial v_i(x_i)}{\partial x_{ij}} v_i(x_i)^{\rho - 1}$, and we are again done. Thus $(\mathbf{x}, \q)$ satisfies stationarity for Program~\ref{pro:ces}. Furthermore, the second condition of Walrasian equilibrium is again identical to the complementary slackness condition. We conclude that $\mathbf{x} \in \Psi(\rho)$, and that $q_1,\dots, q_m$ are optimal Lagrange multipliers for Program~\ref{pro:ces}. This completes the proof. \end{proof} The following corollary states that under this pricing rule, each agent's resulting value will be proportional to the her payment. This property will be helpful in future sections, and may also be interesting independently. \begin{restatable}{corollary}{corUtilityPrice}\label{cor:utility-price} Assume each $v_i$ is homogeneous of degree $r$, concave, and differentiable, and let $p(x_i) = (\sum_{j \in M} q_j x_{ij})^{1/\rho}$ for some $\q\in\bbrpos^m$. Then if $x_i \in D_i(p)$, $p(x_i) = \rho r v_i(x_i)$. \end{restatable} \begin{proof} As before, stationarity for Program~\ref{pro:demand} gives us $\mfrac{\partial v_i(x_i)}{\partial x_{ij}} = \mfrac{\partial p(x_i)}{\partial x_{ij}}$ whenever $x_{ij} > 0$. Also note that by definition, $p$ is homogeneous of degree $1/\rho$. Using these two properties in combination with Euler's Theorem, we get \begin{align*} \frac{\partial v_i(x_i)}{\partial x_{ij}} =&\ \frac{\partial p(x_i)}{\partial x_{ij}} \quad \text{for all $j \in M$ s.t. $x_{ij} > 0$} \\ \sum_{j \in M} x_{ij} \frac{\partial v_i(x_i)}{\partial x_{ij}} =&\ \sum_{j \in M} x_{ij} \frac{\partial p(x_i)}{\partial x_{ij}}\\ r v_i(x_i) =&\ \frac{1}{\rho} p(x_i) \end{align*} Multiplying both sides by $1/\rho$ completes the proof. \end{proof} \section*{Acknowledgements} This research was supported in part by NSF grant CCF-1637418, ONR grant N00014-15-1-2786, and the NSF Graduate Research Fellowship under grant DGE-1656518. \end{document} \section{Model}\label{sec:model} Let $N = \{1,2,\ldots n\}$ be a set of agents, and let $M = \{1,2,\dots m\}$ be a set of divisible goods. Throughout the paper, we use $i$ and $k$ to refer to agents and $j$ and $\ell$ to refer to goods. We need to determine an \emph{allocation} $\mathbf{x} \in \bbr_{\ge 0}^{n\times m}$, where $x_i \in \bbr_{\ge 0}^m$ is the \emph{bundle} of agent $i$, and $x_{ij} \in [0,1]$\footnote{Without loss of generality, we can normalize the supply of each good to be 1.} is the quantity of good $j$ allocated to agent $i$. An allocation cannot allocate more than the available supply: $\mathbf{x}$ is a valid allocation if and only if $\sum_i x_{ij} \leq 1$ for all $j$. We will also determine \emph{payments} $p_1,\dots,p_n$, where $p_i$ is the payment charged to agent $i$. Thus an outcome is an allocation $\mathbf{x}$ and payments $p_1,\dots,p_n$. Agent $i$'s utility for a bundle $x_i$ is denoted by $u_i(x_i) \in \bbr$. We assume that agents have quasilinear utility: for an allocation $\mathbf{x}$ and payment $p_i$, agent $i$'s utility is $u_i(x_i) = v_i(x_i) - p_i$, where $v_i$ is agent $i$'s \emph{valuation}. When each agent's payment only depends on the bundle she receives, i.e., $p_i = p(x_i)$, we call $p$ a \emph{pricing rule}. With the exception of Section~\ref{sec:truthful}, we will focus on pricing rules. For $v_i$, we make the following standard assumptions throughout the paper: \begin{enumerate} \item Nonzero: There exists a bundle $x_i$ such that $v_i(x_i) > 0$. \item Montone: If $x_{ij} \ge y_{ij}$ for all $j \in M$, then $v_i(x_i) \ge v_i(y_i)$. \item Normalized: $v_i(0,\dots, 0) = 0$. \end{enumerate} Our positive results require the following three additional properties, which we will mention explicitly whenever used: \begin{enumerate} \setcounter{enumi}{3} \item Concave: For any bundles $x_i, y_i$ and constant $\lambda \in [0,1]$, we have $v_i(\lambda x_i + (1 - \lambda) y_i) \geq \lambda v_i( x_i) + (1-\lambda)u_i(y_i)$. \item Homogeneous of degree $r$: for any bundle $x_i$ and constant $\lambda \ge 0$, $v_i(\lambda x_i) = \lambda^r v_i(x_i)$. For $0 < r < 1$, this models diminishing returns. Note that homogeneity implies normalization, and for monotone and concave $v_i$, we must have $r \ge 0$ and $r \le 1$ respectively. \item Differentiable: for any bundle $x_i$ and all $j \in M$, $\mfrac{\partial v_i(x_i)}{\partial x_{ij}}$ is defined. \end{enumerate} \paragraph{CES welfare.} For multipliers $\mathbf{a} = (a_1, a_2\dots a_n) \in \bbrpos^n$ and $\rho \in (-\infty, 0)\cup(0,1]$, the (weighted) CES welfare of an allocation $\mathbf{x}$ is $\Phi_\mathbf{a}(\rho, \mathbf{x}) = \big(\sum_{i \in N} a_i v_i(x_i)^{\rho}\big)^{1/\rho}$. For $\rho \ne 1$, $\Phi$ is strictly concave in $v_i(x_i)$ for all $i \in N$, so every optimal allocation $\mathbf{x}$ has the same valuation vector $v_1(x_1),\dots, v_n(x_n)$. We will use $\Psi_\mathbf{a}(\rho)$ to denote CES welfare maximization, i.e., $\Psi_\mathbf{a}(\rho) = \argmax_{\mathbf{x} \in \bbrpos^m:\ \sum_i x_{ij} \le 1\ \forall j} \Phi_\mathbf{a}(\rho, \mathbf{x})$. There may be multiple optimal allocations (for example, if there is a good which no one values), so $\Psi_\mathbf{a}(\rho)$ denotes a set. Thus $\mathbf{x} \in \Psi_\mathbf{a}(\rho)$ denotes that $\mathbf{x}$ has maximum CES welfare. When each agent has the same multiplier (other than Appendix~\ref{sec:fisher}, this will always be the case), we simply write $\Phi(\rho, \mathbf{x})$ and $\Psi(\rho)$. As an illustrative example, consider a single good and valuations that are homogeneous of degree 1. Utilitarian welfare results in the good being entirely allocated to agents with $w_i = \max_k w_k$, with other agents receiving nothing (see Figure~\ref{fig:linear}). In contrast, for $\rho < 1$, the unique allocation maximum CES welfare welfare gives the following bundle $x_i \in \bbrspos$ to each agent $i$ (Lemma~\ref{lem:m=1-x}): $x_i = \mfrac{{w_i}^{\frac{\rho}{1-\rho}}}{\sum_{k} {w_k}^{\frac{\rho}{1-\rho}}}$. One natural case is $\rho = 1/2$, which results in a proportional allocation. \paragraph{Axiomatic characterization.} CES welfare functions also admit an axiomatic characterization. Consider the following axioms: (1) Monotonicity: if one agent's valuation increases while all others are unchanged, the welfare function should prefer the new allocation, (2) Anonymity: the welfare function should treat all agents the same, (3) Continuity: the welfare function should be continuous.\footnote{A slightly weaker version of continuity is often used: if an allocation $\mathbf{x}$ is strictly preferred to an allocation $\mathbf{y}$, there should be neighborhoods $N(\mathbf{x})$ and $N(\mathbf{y})$ such that every $\xprime \in N(\mathbf{x})$ is preferred to every $\yprime \in N(\mathbf{y})$. This weaker version only requires a welfare \emph{ordering} and does not require that this ordering be expressed by a function. However, any such ordering which also satisfies the rest of our axioms is indeed representable by a welfare function~\cite{Debreu1960}, and so both sets of axioms end up specifying the same set of welfare functions/orderings.}, (4) Independence of common scale: scaling all agent valuations by the same factor should not affect which allocations have better welfare than others, (5) Independence of unconcerned agents: when comparing the welfare of two allocations, the comparison should not depend on agents who have the same valuation in both allocations, and (6) The Pigou-Dalton principle: when choosing between equally efficient allocations, the welfare function should prefer more equitable allocations~\cite{Dalton1920,Pigou1912}. Disregarding monotonic transformations of the welfare function (which of course do not affect which allocations have better welfare than others), the set of welfare functions satisfying these axioms is exactly the set of CES welfare functions with $\rho \in (-\infty,0)\cup(0,1]$, including Nash welfare~\cite{Moulin2003}.\footnote{This actually does not include max-min welfare, which satisfies weak monotonicity but not strict monotonicity.} This axiomatic characterization shows that we are not just focusing on an arbitrary class of welfare functions: CES welfare functions are arguably the most reasonable welfare functions. \paragraph{Walrasian equilibrium.} Given a pricing rule $p$, agent $i$'s \emph{demand set} is defined by $D_i(p) = \argmax_{x_i \in \bbrpos^m} u_i(x_i)$, or equivalently, $D_i(p) = \argmax_{x_i \in \bbrpos^m} \big(v_i(x_i) - p(x_i)\big)$. Given an allocation $\mathbf{x}$ and payment rule $p$, $(\mathbf{x}, p)$ is a\emph{Walrasian equilibrium} (WE) if both of the following hold: \begin{enumerate} \item Each agent receives a bundle in her demand set: $x_i \in D_i(p)$ for all $i \in N$. \item The market clears: for all $j \in M$, $\sum_{i \in N} x_{ij} \le 1$, and for all $j \in M$ with nonzero cost, $\sum_{i \in N} x_{ij} = 1$.\footnote{We say that good $j$ has nonzero cost for $j$ if there is a bundle $x_i$ such that $x_{i\ell} = 0$ for all $\ell \ne j$, but $p(x_i) > 0$.} \end{enumerate} \subsection{Related work}\label{sec:prior} The study of markets has a long history in economics~\cite{Arrow1954,Brainard2005,Fisher1892,Varian1974,Walras1874}. Recently, this topic has received substantial attention in the computer science community as well (see~\cite{Vazirani2007} for an algorithmic introduction). We first provide some important background on different market models and the First and Second Welfare Theorems, and then move on to more recent related work. \paragraph{Quasilinear markets and Fisher markets.} There are two primary market models for divisible goods. This paper considers the quasilinear utility model, where each agent can spend as much as she wants, and the amount spent is incorporated into her utility function. The other predominant model is the \emph{Fisher market} model~\cite{Brainard2005,Fisher1892}, where each agent has a fixed budget constraint, and the amount spent does not affect her resulting utility (as a result, each agent always spends exactly her budget). Although these two models share many of the same conceptual messages, some of the technical results vary. See Appendix~\ref{sec:fisher} for the technical relationship between the two models with respect to WE and CES welfare maximization. Since agents in Fisher markets always spend exactly their budgets, there is no way to elicit the absolute scale of agent valuations. Nash welfare maximization is invariant to this type of scaling, but no other CES welfare function is~\cite{Moulin2003}. For this reason, the Fisher market model is not well suited to reason about other welfare functions. In contrast, the quasilinear model \emph{does} allow agents to express the absolute scale of their valuation: specifically, by choosing how much to spend. That is one reason that we focus on the quasilinear model for this paper. The other is that convex pricing is most easily applied to a small submarket of the broader economy (e.g., water pricing), and quasilinear utility captures the fact that agents may wish to spend money on other goods outside of this submarket. In contrast, Arrow and Debreu's model (see below) can arguably capture the entire economy, so there is nothing outside of the market to spend money on. \paragraph{The First and Second Welfare Theorems.} Conceptually, the First Welfare Theorem establishes an efficiency property that any WE must satisfy, and the Second Welfare Theorem deals with implementing a wide range of allocations as WE. The two welfare theorems originate in the context of \emph{Arrow-Debreu} markets~\cite{Arrow1954}, which generalize Fisher markets to allow for (1) agents to enter the market with goods (as opposed to just money)\footnote{These are known as ``exchange markets" or ``exchange economies".} and (2) production of goods. The statements of the First and Second Welfare Theorems in that model are, respectively, ``Any (linear pricing) WE is Pareto optimal" and ``Any Pareto optimal allocation can be a (linear pricing) WE with \emph{transfers}, i.e., under a suitable redistribution of initial wealth". In the Fisher market and quasilinear utility models, the First Welfare Theorem can be strengthened to ``Any (linear pricing) WE maximizes budget-weighted Nash welfare"~\cite{Eisenberg1961,Eisenberg1959,Vazirani2007} and ``Any (linear pricing) WE maximizes utilitarian welfare", respectively. The version of the Second Welfare Theorem stated above is appropriate for Fisher markets, since agents' budgets constitute the ``initial wealth". However, for quasilinear utilities, there is no notion of initial wealth (alternatively, initial wealth is an additive constant in agents' utilities which does not affect their behavior). Thus for quasilinear utilities, allowing transfers actually does not affect the set of WE. This may seem counterintuitive, since the Second Welfare Theorem (which still holds in this setting) states that any Pareto optimum can be a WE. However, Pareto optimality here is referring to agents' overall quasilinear utilities, \emph{not} the agents' valuations. It can be shown that the only allocations which are Pareto optimal with respect to the quasilinear utilities are allocations maximizing utilitarian welfare, which are already covered by the First Welfare Theorem (without transfers). Thus on a technical level, the Second Welfare Theorem is not helpful in the world of quasilinear utilities. However, even when the Second Welfare Theorem is mathematically relevant, a centrally mandated redistribution of wealth is often out of the question in practice. \paragraph{The equality/efficiency tradeoff in healthcare.} In Section~\ref{sec:ces-intro}, we discussed how CES welfare has been studied from a theoretical perspective in healthcare~\cite{Dolan1998,Ortun1996,Wagstaff1991}. There have also been several empirical studies aiming to understand the general population's view of the equality/efficiency tradeoff, with results generally indicating a disapproval of purely utilitarian approaches to healthcare~\cite{Dolan2000,Wittrup-Jensen2008}. For example, a survey of 449 Swedish politicians found widespread rejection of purely utilitarian decision-making in healthcare, and under some conditions, the respondents were willing to sacrifice up to 15 of 100 preventable deaths in order to ensure equality across subgroups~\cite{Lindholm1998}. \paragraph{CES welfare and $\alpha$-fairness in networking.} CES welfare functions have also enjoyed considerable attention from the field of networking, under the name of \emph{$\alpha$-fairness} (the parameter $\alpha$ corresponds to $1-\rho$ in our definition). The $\alpha$-fairness notion was proposed by~\cite{Mo2000}, motivated in part as a generalization of the prominent \emph{proportional fairness} objective (which is equivalent to Nash welfare)~\cite{Kelly1998}. See~\cite{Bertsimas2012} and references therein for further background on $\alpha$-fairness in networking. To our knowledge, a market-based understanding was developed only for proportional fairness, starting with the seminal work of Kelly et al.~\cite{Kelly1998}. \paragraph{Nonlinear market mechanisms and CES welfare maximization.} We are aware of just two papers studying market mechanisms for CES welfare functions: \cite{Goel2019nash} and \cite{Plaut2019}. Like our work, both of these papers explore nonlinear pricing rules, but unlike our work, only consider Leontief valuations. Furthermore, both of those papers are in the Fisher market model and only achieve CES welfare maximization under strong assumptions on the absolute scale of the agents' valuations.\footnote{In particular, that each agent's weight for each good is either 0 or 1. This subclass of Leontief valuations is known as ``bandwidth allocation" valuations, where each good is a link in a network, and agents transmit data over fixed paths.} In contrast, our main result holds for any valuations that are homogeneous of degree $r$, differentiable, and concave, a much larger range of valuations. (Leontief valuations are not differentiable, but we handle them as a special case in Appendix~\ref{sec:leontief} and show that our result still holds.) It is worth noting that~\cite{Goel2019nash} focuses on the WE model, whereas~\cite{Plaut2019} considers strategic agents and Nash equilibria. On a related note, we are not aware of any broader results regarding general nonlinear pricing, i.e., what set of allocations can be implemented if we allow $p(x_i)$ to be any nondecreasing function of $x_i$ (but still require anonymity)? This could be an interesting direction for future work. The rest of the paper is organized as follows. Section~\ref{sec:model} formally defines the model. In Section~\ref{sec:main}, we present our main result: a simple convex pricing rule implements CES welfare maximization in WE for $\rho \in (0,1]$ (Theorem~\ref{thm:main}). Section~\ref{sec:comp} presents an iterative algorithm for computing these WE. In Section~\ref{sec:truthful}, we consider truthful mechanisms for CES welfare maximization. Section~\ref{sec:sybil} discusses Sybil attacks, and Section~\ref{sec:counter} presents our negative results. At this point we conclude the main paper. Appendix~\ref{sec:fisher} discusses connections to Fisher markets, Appendix~\ref{sec:leontief} shows that our main result extends to Leontief valuations, Appendix~\ref{sec:linear} discusses the First Welfare Theorem in more detail, and Appendix~\ref{sec:proofs} provides some proofs omitted from the main paper. \section{Results and related work}\label{sec:results} \paragraph{Main result: convex pricing implements CES welfare maximization in Walrasian equilibrium.} Our main result is that for convex pricing of the form $p(x_i) = (\sum_j q_j x_{ij})^{1/\rho}$ for any $\rho \in (0,1]$\footnote{The case of $\rho < 0$ is slightly unintuitive, as it can result in agents who care more receiving \emph{less} of the good. Consequently, implementation in WE is impossible; see Theorem~\ref{thm:neg-rho-counter}.}, a Walrasian equilibrium is guaranteed to exist, and every WE maximizes CES welfare with respect to $\rho$. This holds for a wide range of agent valuations. \begin{theoremNumbered}[\ref{thm:main} \textnormal{(Simplified version)}] Assume each valuation is homogeneous of degree $r$,\footnote{A valuation is homogeneous of degree $r$ if scaling any bundle by a constant $c$ scales the resulting value by $c^r$.} differentiable, and concave, and fix $\rho \in (0,1]$. Then an allocation $\mathbf{x} = (x_1,\dots, x_n)$ maximizes CES welfare if and only if there exist constants $q_1,\dots,q_m \in \bbrpos$ such that for the pricing rule \[ p(x_i) = \Big(\sum_{j} q_j x_{ij}\Big)^{1/\rho}, \] $\mathbf{x}$ and $p$ form a WE. \end{theoremNumbered} \noindent Note that the $\rho$ in $p(x_i)$ is the same $\rho$ for which CES welfare is maximized. We call the reader's attention to two important aspects of this result. Perhaps most importantly, our result is not simply a reformulation of the First Welfare Theorem: although maximizing CES welfare for valuations $v_1,\dots,v_n$ is equivalent to maximizing utilitarian welfare for valuations $v_1^\rho,\dots,v_n^\rho$, the First Welfare Theorem does not say anything about the agent demands in response to this convex pricing rule. The First Welfare Theorem also does not help with identifying the exact conditions under which Theorem~\ref{thm:main} holds, e.g., homogeneity of valuations.\footnote{In fact, not only is homogeneity necessary, but homogeneity of the same degree is necessary: if we allow the degree of homogeneity to differ across agents, the result no longer holds (Theorem~\ref{thm:different-r}).} Secondly, the class of homogeneous, differentiable, and concave valuations is quite large: it generalizes most of the commonly studied valuations, e.g., linear, Cobb-Douglas, and CES (note that here we are referring to CES agent valuations, not CES welfare functions). Although Leontief valuations are not differentiable, we handle them as a special case and show that the same result holds (Theorem~\ref{thm:leontief}). The following additional properties are of note: \begin{enumerate} \item For this class of utilities, Theorem~\ref{thm:main} generalizes the First Welfare Theorem:\footnote{One direction of the First Welfare Theorem (if $(\mathbf{x}, p)$ is a linear pricing WE, then $\mathbf{x}$ maximizes utilitarian welfare) holds in a much more general setting; see Appendix~\ref{sec:linear}.} when $\rho = 1$, $p(x_i)$ yields linear pricing and CES welfare yields utilitarian welfare. \item The constants $q_1,\dots,q_m$ will be the optimal Lagrange multipliers for a convex program maximizing CES welfare. This connection to duality will be very helpful for computing these WE (see Section~\ref{sec:comp}). \item Our pricing rule is strictly convex for $\rho < 1$, with the curvature growing as $\rho$ goes to 0. The smaller $\rho$ gets, the easier it is to buy a small amount, but the harder it is to buy a large amount. Intuitively, this should prevent any single individual from dominating the market and lead to a more equitable outcome. Furthermore, the marginal price at $x_i = \zero$ is zero, which ensures that everyone ends up with a nonempty bundle (in contrast to linear pricing: see Figure~\ref{fig:linear}). Theorem~\ref{thm:main} provides a tight relationship between the curvature of the pricing rule and the exact equality/efficiency tradeoff. \end{enumerate} \paragraph{Towards an implementation.} We also prove several supporting results: in particular, regarding implementation. The WE from Theorem~\ref{thm:main} can always be computed by asking each agent for her entire utility function, and then solving a convex program for maximizing CES welfare maximization to obtain the optimal Lagrange multipliers $q_1,\dots,q_m$. However, this is not very practical: people are generally not able to articulate a full cardinal utility function, and even if they are, doing so could require transmitting an enormous amount of information. Section~\ref{sec:comp} presents our first supporting result: an iterative algorithm for computing the WE, where in each step, each agent only needs to report the gradient of her valuation at the current point. Our algorithm is based on the ellipsoid method, and inherits its polynomial-time convergence properties. We recognize that even valuation gradient queries may be difficult for agents to answer, and we leave the possibility of an improved implementation -- in particular, a \emph{\tat}\footnote{A \tat is an iterative algorithm which only asks \emph{demand queries}, i.e., what would each agent purchase given the current prices. Demand queries may be easier to answer than the valuation gradient queries in our algorithm.} -- as an open question. \paragraph{Truthfulness.} Our second supporting result considers a different approach to implementation: \emph{truthful} mechanisms. Walrasian equilibria are generally not truthful: agents can lie about their preferences to affect the equilibrium prices for their personal gain.\footnote{Another interpretation is that WE assumes agents are \emph{price-taking} (i.e., treat the prices are given and do not lie about their preferences to affect the equilibrium prices) and breaks down when agents are \emph{price-anticipating}.} For $\rho = 1$, the Vickrey-Clarke-Groves (VCG) mechanism is known to truthfully maximize utilitarian welfare~\cite{Nisan2007}. For the case of a single good and any $\rho \in (0,1)$, we give a mechanism which truthfully maximizes CES welfare (Theorem~\ref{thm:truthful}). We also show that our mechanism is the unique truthful mechanism up to an additive constant in the payment rule (Theorem~\ref{thm:truthful-unique}). The proof of Theorem~\ref{thm:truthful-unique} is quite involved, and requires techniques from real analysis such as Kirszbraun's Theorem for Lipschitz extensions and the Fundamental Theorem of Lebesgue Calculus. \paragraph{Negative results.} We prove the following negative results. Most importantly, we show that for any $\rho \ne 1$, linear-pricing WE can have arbitrarily poor CES welfare (Theorem~\ref{thm:rho=1-bad}); were this not the case, perhaps it would suffice to simply use linear pricing and accept an approximation of CES welfare. Next, note that Theorem~\ref{thm:main} requires each agent's valuation to be homogeneous with the same degree $r$. We show that when agents' valuations have different homogeneity degrees, there exist instances where no pricing rule can implement CES welfare maximization in WE (Theorem~\ref{thm:different-r}), and thus our assumption is necessary. We also show that CES welfare maximization cannot be implemented in WE for $\rho < 0$ (Theorem~\ref{thm:neg-rho-counter}), and discuss the special case of $\rho = 0$ (i.e., Nash welfare). There is an additional crucial issue which any practical implementation of Theorem~\ref{thm:main} would need to address: \emph{Sybil attacks}. A Sybil attack is when a selfish agent attempts to gain an advantage in a system by creating fake identities~\cite{Douceur2002}. Since the pricing rule from Theorem~\ref{thm:main} is strictly convex for $\rho < 1$, an agent can decrease her payment by masquerading as multiple individuals and splitting her purchase across those identities.\footnote{In contrast, for $\rho = 1$, there is nothing to be gained by creating fake identities.} In Appendix~\ref{sec:sybil}, we propose a model for analyzing Sybil attacks in markets, and show that if these attacks are possible, there exist instances where no pricing rule can implement CES welfare maximization in WE (Theorem~\ref{thm:sybil-other-p}).\footnote{There are combinations of parameters, however, where our pricing rule is naturally robust to Sybil attacks: in particular, when $v_i(\mathbf{x}) (1-\rho) \le \kappa$ (where $v_i(\mathbf{x})$ is agent $i$'s value for the maximum CES welfare allocation and $\kappa$ is the identity creation cost). This suggests a natural way for an equality-focused social planner to choose a specific value for $\rho$: estimate the identity creation cost and scale of valuations in the system of interest, and pick $\rho$ to be as small as possible without incentivizing Sybil attacks.} \paragraph{Additional results.} In Appendix~\ref{sec:fisher}, we explore connections between our results in the quasilinear utility model, and the Fisher market fixed-budget model. Appendix~\ref{sec:leontief} shows that Theorem~\ref{thm:main} extends to Leontief valuations, which are not differentiable (so the main proof does not apply). Leontief valuations have been a focus of prior work, so we find is worthwhile to handle this as a special case. \section{Sybil attacks}\label{sec:sybil} In Sections~\ref{sec:comp} and \ref{sec:truthful}, we discussed two alternative approaches to implementation: an iterative query-based algorithm, and a truthful mechanism. However, there is an additional crucial issue which any practical implementation must address: since our pricing rule $p(x_i) = (\sum_{j \in M} q_j x_{ij})^{1/\rho}$ is strictly convex for $\rho < 1$, agents have an incentive to create fake identities. In particular, an agent can decrease her payment while receiving the same bundle by splitting the payment over multiple fake identities.\footnote{Note that for linear prices there is no such incentive.} This is known as a \emph{Sybil attack}. The truthful payment rule from Section~\ref{sec:truthful} is not strictly convex everywhere, but it is strictly convex on some intervals, and thus has the same vulnerability. \paragraph{Model of Sybil attacks.} We model this as follows. Let $\kappa$ denote the cost of creating a new identity. The cost could reflect inconvenience, risk of getting caught, or other factors, and would depend on the nature of the system. Let $\eta_i$ be the \emph{multiplicity} of agent $i$, i.e., the number of identities agent $i$ controls in the system. This includes both fake identities and the agent's single real identity, so we assume that $\eta_i \in \bbnspos$. For convex $p$, multiplicity $\eta_i$, and a desired bundle for purchase, it is always optimal for agent $i$ to split the purchase evenly across her identities.\footnote{This is essentially a multidimensional version of Jensen's inequality; see, e.g.,~\cite{Neuman1990}.} Thus we can assume that each identity purchases the same bundle $x_i$, and we define agent $i$'s utility as \[ u_i(x_i, \eta_i) = v_i(\eta_i x_i) - \eta_i p(x_i) - \eta_i \kappa \] We do not claim that this perfectly models the reality of Sybil attacks; for example, the identity creation cost is arguably sublinear (one someone has created a single fake identity, creating more might become easier). Our goal here is simply to show formally that at least in some cases, CES welfare maximization cannot be robust to Sybil attacks in general. \paragraph{Walrasian equilibrium.} We focus on a Walrasian model of Sybil attacks; the analogous analysis for truthful mechanisms is left as an open question. We define each agent's \emph{Sybil demand set} by \[ D_i(p) = \argmax_{x_i \in \bbrpos^m, \eta_i \in \bbnspos}\ u_i(x_i, \eta_i) \] Note that we require $\eta_i \in \bbnspos$. We define a \emph{Sybil Walrasian equilibrium} (SWE) to be an allocation $\mathbf{x}$, payment rule $p$, and vector of multiplicities $\bfeta = \eta_1,\dots,\eta_n$ such that \begin{enumerate} \item Each agent receive a bundle in her demand set: $(x_i, \eta_i) \in D_i(p)$ for all $i \in N$. \item The market clears: for all $j \in M$, $\sum_{i \in N} x_{ij} \le 1$. Furthermore, for any $j\in M$ with nonzero cost\footnote{Recall that good $j$ has ``nonzero cost" in our pricing rule if $q_j > 0$.}, $\sum_{i \in N} x_{ij} = 1$. \end{enumerate} In this section, we will focus on the case of homogeneity degree $r=1$. The following lemma states that for any pricing rule, a rational agent either creates no fake identities (i.e, $\eta_i = 1$), or creates an unbounded number (and consequently the demand set is empty). \begin{lemma}\label{lem:sybil-demand} Assume each $v_i$ is concave, differentiable, and homogeneous of degree 1. Let $\rho \in (0,1]$, define $p$ as in Theorem~\ref{thm:main}, and let $\mathbf{x} \in \Psi(\rho)$. Then we have \[ D_i(p) = \begin{cases} (x_i, 1) &\ \text{if } v_i(x_i) (1-\rho) \le \kappa\\ \emptyset &\ \text{otherwise} \end{cases} \] where $x_i$ is agent $i$'s bundle in $\mathbf{x}$. \end{lemma} \begin{proof} When $v_i$ is homogeneous of degree 1, for any bundle $y_i$, we have $u_i(y_i, \eta_i) = \eta_i v_i(y_i) - \eta_i p(y_i) - \eta_i \kappa = \eta_i\big(v_i(y_i) - p(y_i) - \kappa\big)$. Thus given a choice of $\eta_i$, $y_i$ must be chosen to maximize $v_i(y_i) - p(y_i) - \kappa$. Let $\mathbf{x} \in \Psi(\rho)$: then by Theorem~\ref{thm:main} $y_i$ optimizes $v_i(y_i) - p(y_i)$ (and thus $v_i(y_i) - p(y_i) - \kappa$) if and only if $y_i = x_i$. Therefore the demand set is equal to \[ D_i(p) = \Big(x_i,\ \argmax_{\eta_i \in \bbnspos}\ \eta_i \big(v_i(x_i) - p(x_i) - \kappa\big) \Big) \] That is, the demanded bundle must always be $x_i$, and $\eta_i$ is optimized accordingly. By Corollary~\ref{cor:utility-price}, $p(x_i) = \rho v_i(x_i)$, so $v_i(x_i) - p(x_i) - \kappa = v_i(x_i)(1-\rho) - \kappa$. Thus if $v_i(x_i) (1-\rho) \le \kappa$, then $1$ is an optimal choice for $\eta_i$, so $(x_i, 1) \in D_i(p)$. However, if $v_i(x_i) (1-\rho) > \kappa$, there is no optimal choice for $\eta_i$: specifically, $\eta_i$ goes to infinity. Thus if $v_i(x_i) (1-\rho) > \kappa$, $D_i(p) = \emptyset$. \end{proof} This immediately implies that if $\mathbf{x} \in \Psi(\rho)$ satisfies $v_i(x_i) (1-\rho) \le \kappa$ for all $i \in N$, the convex pricing rule from Theorem~\ref{thm:main} is naturally robust to Sybil attacks. \begin{theorem}\label{thm:sybil-r=1-good} Assume each $v_i$ is concave, differentiable, and homogeneous of degree 1. Let $\mathbf{x} \in \Psi(\rho)$ for $\rho \in (0,1]$, and define $p$ as in Theorem~\ref{thm:main}. Then if $v_i(x_i) (1-\rho) \le \kappa$ for all $i \in N$, $(\mathbf{x}, p, \one)$ is a SWE. \end{theorem} \begin{proof} By Lemma~\ref{lem:sybil-demand}, we have $(x_i, 1) \in D_i(p)$ for all $i \in N$ in this case. Theorem~\ref{thm:main} implies that the market clearing condition is met, so $(\mathbf{x}, p, \one)$ is a SWE. \end{proof} In other words, if the identity creation cost is small, $\rho$ is close to 1, and/or agents valuations are not too large, we need not worry about Sybil attacks. As discussed in Section~\ref{sec:results}, this suggests one possible way for a social planner to choose a value of $\rho$: estimate $\kappa$ and the magnitude of valuations, and choose $\rho$ to be as small as possible without incentivizing Sybil attacks. On the other hand, if $v_i(x_i) (1-\rho) > \kappa$, how bad are the consequences? Theorem~\ref{thm:sybil-r=1-bad} states that an agent's valuation at equilibrium has a hard cap at $\mfrac{\kappa}{1-\rho}$. This provides a hard maximum on the CES welfare in any SWE with $p$ thus defined: in particular, the CES welfare is at most $\big(\sum_{i \in N} \big(\frac{\kappa}{1-\rho}\big)^\rho\big)^{1/\rho} = n^{1/\rho} \frac{\kappa}{1-\rho}$. In general, each $v_i(x_i)$ (and thus the CES welfare) can be arbitrarily large, so Theorem~\ref{thm:sybil-r=1-bad} implies an unbounded ratio between the optimal CES welfare and that of any SWE with this $p$. \begin{theorem}\label{thm:sybil-r=1-bad} Assume each $v_i$ is concave, differentiable, and homogeneous of degree 1. Let $\rho \in (0,1]$, and define $p$ as in Theorem~\ref{thm:main}. Then for any allocation $\mathbf{x}$ and multiplicities $\bfeta$ such that $(\mathbf{x}, p, \bfeta)$ is a SWE, we have \[ v_i(x_i) \le \frac{\kappa}{1-\rho} \] \end{theorem} \begin{proof} Suppose $(\mathbf{x}, p, \bfeta)$ is a SWE for some allocation $\mathbf{x}$ and multiplicities $\bfeta$: then each $(x_i, \eta_i) \in D_i(p)$ for all $i \in N$; Thus $D_i(\mathbf{p}) \ne \emptyset$, so Lemma~\ref{lem:sybil-demand} implies that $v_i(x_i) (1-\rho) \le \kappa$, and consequently, $v_i(x_i) \le \frac{\kappa}{1-\rho}$. \end{proof} The next natural question is, can we circumvent this by using a different pricing rule? Theorem~\ref{thm:sybil-other-p} answers this in the negative. The counterexample uses an instance with a single good; recall that $x_i$ denotes a scalar in this case. \begin{theorem}\label{thm:sybil-other-p} Let $m=1$, $v_1(x_1) = w x_1$, and $v_i(x_i) = x_i$ for all $i \ne 1$. Let $(\mathbf{x}, p, \bfeta)$ be any SWE. Then for all $i \ne 1$, \[ v_i(x_i) \le \frac{\kappa}{w-1} \] \end{theorem} \begin{proof} Let $(\mathbf{x}, p, \bfeta)$ be any SWE. Fix an arbitrary $i \in N$. As in Lemma~\ref{lem:sybil-demand}, we have $u_i(x_i, \eta_i) = \eta_i (v_i(x_i) - p(x_i) - \kappa)$. Since $(x_i, \eta_i) \in D_i(p)$, we must have $\eta_i \in \argmax_{\eta_i' \in \bbnspos} \eta_i (v_i(x_i) - p(x_i) - \kappa)$ (note that we are not assuming anything about the bundle $x_i$). Since $\argmax_{\eta_i' \in \bbnspos} \eta_i' (v_i(x_i) - p(x_i) - \kappa)$ cannot be the empty set, we must have $v_i(x_i) \le p(x_i) + \kappa$ and $\eta_i = 1$. Focusing on agent 1, we further claim that $v_1(x_i) \le p(x_i) + \kappa$ for any $i \ne 1$. Suppose not: then agent 1 could purchase $x_i$ and set $\eta_1 = \infty$ to increase her utility. Thus $v_1(x_i) \le p(x_i) + \kappa$ for each $i \ne 1$. Now looking at the optimization for $i \ne 1$, we have $v_i(x_i) \ge p(x_i)$. Combining this with $v_1(x_i) \le p(x_i) + \kappa$, we get $v_1(x_i) \le v_i(x_i) + \kappa$. Plugging in our definitions of $v_1$ and $v_{i \ne 1}$, we get $w x_i \le x_i + \kappa$, so $x_i (w - 1) \le \kappa$. Substituting back in the definition of $v_i$, we get $v_i(x_i) \le \mfrac{\kappa}{w-1}$ for all $i \ne 1$, as required. \end{proof} Although the bound in Theorem~\ref{thm:sybil-other-p} is different from that in Theorem~\ref{thm:sybil-r=1-bad}, the implication is the same: this is a hard maximum on the value obtained by any agent other than agent 1. As $\kappa$ goes to zero, the fraction of the good agent 1 receives approaches 1, so the outcome approaches the maximum utilitarian welfare outcome (where agent 1 receives the entirety of the good). Therefore by Theorem~\ref{thm:rho=1-bad}, the CES welfare at any Sybil Walrasian equilibrium (for any pricing rule) can be arbitrarily bad in comparison to the optimal CES welfare. Thus in general, when Sybil attacks are possible, it is impossible to implement any bounded approximation of CES welfare maximization in Walrasian equilibrium. \section{Truthfulness}\label{sec:truthful} An alternative approach to implementation is via \emph{truthful} mechanisms. Walrasian equilibria are generally not truthful: agents can sometimes create more favorable equilibrium prices by lying about their preferences. In this section, we present a truthful mechanism for optimizing CES welfare in the case of a single good (Theorem~\ref{thm:truthful}), and show that it is unique up to additive constants in the payment rule (Theorem~\ref{thm:truthful-unique}). Note that uniqueness beyond additive constants in the payment rule can never be achieved without additional assumptions (e.g., individual rationality), since such constants do not affect the behavior of agents. Before formally stating and proving these results, we mention an important distinction between this section and Section~\ref{sec:comp}. Section~\ref{sec:comp} is an implementation of the WE from Theorem~\ref{thm:main} (which we know maximizes CES welfare). In contrast, the truthful mechanism from this section is an implementation of CES welfare maximization directly, not an implementation of the WE from Theorem~\ref{thm:main}. Indeed, we know that the payment rule from Theorem~\ref{thm:main} is not truthful, so we must consider a different payment rule if we desire truthfulness. To define our truthful mechanism we need the following two lemmas, whose proofs appear in Appendix~\ref{sec:proofs}. The first states that for a single good, homogeneous and differentiable functions take a very simple form. The second states that for a single good, the maximum CES welfare allocations take a very simple form; also, for $\rho \ne 1$, the optimum is unique. \begin{restatable}{lemma}{lemHomoOneGood}\label{lem:homo-m=1} Let $f: \bbrpos \to \bbrpos$ be differentiable and homogeneous of degree $r$. Then there exists $c \in \bbrpos$ such that $f(x) = c x^r$. \end{restatable} \begin{restatable}{lemma}{lemOptOneGood}\label{lem:m=1-x} Let $m=1$ and $v_i(x_i) = w_i x_i^r$ for all $i \in N$ where $r \in (0,1]$. Then $\rho \in (0,1]$ and $r\rho \ne 1$, $\mathbf{x} \in \Psi(\rho)$ if and only if \[ x_i = \frac{{w_i}^{\frac{\rho}{1-r\rho}}}{\sum_{k \in N} {w_k}^{\frac{\rho}{1-r\rho}}} \] If $\mathbf{x} \in \Psi(\rho)$ and $r = \rho = 1$, then whenever $x_i > 0$, $w_i = \max_{k \in N} w_k$. \end{restatable} We now define our mechanism. For $\rho = 1$, the VCG mechanism truthfully maximizes utilitarian welfare~\cite{Nisan2007}, so assume $\rho \in (0,1)$. We ask each agent $i$ to report $w_i$ (where $v_i(x_i) = w_i \cdot x_i^r$), assume the $w_i$'s are truthful, and output the (unique) optimal allocation $\mathbf{x} \in \Psi(\rho)$ according to Lemma~\ref{lem:m=1-x}. Let $\B = b_1,\dots,b_n$ be the vector of reported $w_i$'s. We then charge each agent $i$ the following payment:\footnote{Although this integral does not have a simple closed form, it can be expressed via the hypergeometric function.} \begin{align} p_i(\B) = \frac{r\rho}{1-r\rho} \Big(\sum_{k \ne i} b_k^\frac{\rho}{1-r\rho}\Big) \int_{b = 0}^{b_i} \frac{b^\frac{r\rho}{1-r\rho}}{\big(b^\frac{\rho}{1-r\rho} + \sum_{k \ne i} b_k^\frac{\rho}{1-r\rho}\big)^{r+1}}\dif b \label{eq:payment} \end{align} This payment is chosen so that the derivative of agent $i$'s utility at $b_i = w_i$ is 0. In particular, let $x_i(\B)$ denote agent $i$'s bundle under reports $\B$. Then we will have $\mfrac{\partial v_i(x_i(\B))}{\partial b_i} = rw_i\mfrac{\partial x_i(\B)}{\partial b_i} x_i(\B)^{r-1}$, and $\mfrac{\partial p_i(\B)}{\partial b_i} = rb_i\mfrac{\partial x_i(\B)}{\partial b_i} x_i(\B)^{r-1}$, so the derivative of agent $i$'s overall utility will be $\mfrac{\partial u_i(\B)}{\partial b_i} = r (w_i - b_i) \mfrac{\partial x_i(\B)}{\partial b_i} x_i(\B)^{r-1}$. This will imply that it is optimal for agent $i$ to truthfully report $b_i = w_i$. \begin{restatable}{theorem}{thmTruthful}\label{thm:truthful} Assume $m=1$, and that each $v_i$ is homogenous of degree $r$ (with $r$ publicly known), concave, and differentiable. Then for all $\rho \in (0,1)$, there is a truthful mechanism which outputs an allocation $\mathbf{x} \in \Psi(\rho)$. \end{restatable} \begin{proof} Since VCG satisfies the claim for $\rho = 1$, assume $\rho \in (0,1)$. Let $\mathbf{x}(\B)$ denote the allocation outputted given reports $\B$, and let $x_i(\B)$ denote agent $i$'s bundle: formally, $x_i(\B) = \mfrac{{b_i}^{\frac{\rho}{1-r\rho}}}{\sum_{k \in N} {b_k}^{\frac{\rho}{1-r\rho}}}$. Since $m=1$, Lemma~\ref{lem:homo-m=1} implies that for all $i \in N$, there exists $w_i \in \bbrpos$ such that $v_i(x) = w_i\cdot x^r$ for all $x \in \bbrpos$. Then by Lemma~\ref{lem:m=1-x}, $x_i(\B) \in \Psi(\rho)$, so it remains to prove truthfulness. Since we assume that each agent's valuation is not identically zero, we have $w_i > 0$. Also, by concavity and monotonicity of $v_i$, we have $r \in (0,1]$. Thus $0 < r\rho < 1$. Since we also have $b_i > 0$, all denominators in $p_i(\B)$ are nonzero and thus $p_i(\B)$ is well-defined. Let $v_i(\B) = v_i(x_i(\B)) = w_i x_i(\B)^r$ for brevity, and let $u_i(\B) = v_i(\B) - p_i(\B)$ denote agent $i$'s resulting utility under bids $\B$. Note that $x_i(\B)$, $v_i(\B)$, $p_i(\B)$, and $u_i(\B)$ are all differentiable with respect to $b_i$. Also let $\alpha = \mfrac{\rho}{1-r\rho}$ for brevity; then $p_i(\B) = r\alpha (\sum_{k \ne i} b_k^\alpha) \int_{b = 0}^{b_i} \mfrac{b^{r\alpha}}{(b^\alpha + \sum_{k \ne i} b_k^\alpha)^{r+1}}\dif b$ and $x_i(\B) = \mfrac{b_i^\alpha}{\sum_{k \in N} b_k^\alpha}$. To prove truthfulness, we need to show that $w_i \in \argmax_{b_i \in \bbr_{> 0}} u_i(\B)$, i.e., truthfully reporting $w_i$ is an optimal strategy for agent $i$.\footnote{Note that $u_i(\B)$ is not concave in $b_i$, since $p_i(\B)$ is not convex in $b_i$. Thus the KKT conditions do not apply, so we will have to use a different approach.} Since $u_i(\B)$ is differentiable with respect to $b_i$, we have $\mfrac{\partial u_i(\B)}{\partial b_i} = \mfrac{\partial v_i(\B)}{\partial b_i} - \mfrac{\partial p_i(\B)}{\partial b_i}$. The first term on the right hand side is \[ \frac{\partial v_i(\B)}{\partial b_i} = rw_i\frac{\partial x_i(\B)}{\partial b_i} x_i(\B)^{r-1} \] The second term is \begin{align*} \frac{\partial p_i(\B)}{\partial b_i} =&\ r \alpha \Big(\sum_{k \ne i} b_k^\alpha\Big) \frac{b_i^{r\alpha}}{(b_i^\alpha + \sum_{k \ne i} b_k^\alpha)^{r+1}}\\ =&\ r \alpha \Big(\sum_{k \ne i} b_k^\alpha\Big) \frac{b_i^{r\alpha}}{(\sum_{k \in N} b_k^\alpha)^{r+1}}\\ =&\ r \alpha \Big(\sum_{k \ne i} b_k^\alpha\Big) \frac{b_i^\alpha}{(\sum_{k \in N} b_k^\alpha)^2} \Big(\frac{b_i^\alpha}{\sum_{k \in N} b_k^\alpha}\Big)^{r-1}\\ =&\ r \alpha \Big(\sum_{k \ne i} b_k^\alpha\Big) \frac{b_i^\alpha}{(\sum_{k \in N} b_k^\alpha)^2} x_i(\B)^{r-1} \end{align*} Conveniently, we have $\mfrac{\partial}{\partial b_i} \big(\mfrac{b_i^\alpha}{\sum_{k \in N} b_k^\alpha}\big) = \alpha \big(\sum_{k \ne i} b_k^\alpha\big) \mfrac{b_i^{\alpha-1}}{(\sum_{k \in N} b_k^\alpha)^2}$. Thus \begin{align*} \frac{\partial p_i(\B)}{\partial b_i} =&\ r b_i \frac{\partial}{\partial b_i} \Big(\frac{b_i^\alpha}{\sum_{k \in N} b_k^\alpha}\Big) x_i(\B)^{r-1}\\ =&\ r b_i \frac{\partial x_i(\B)}{\partial b_i} x_i(\B)^{r-1} \end{align*} Therefore \[ \frac{\partial u_i(\B)}{\partial b_i} = r (w_i - b_i) \frac{\partial x_i(\B)}{\partial b_i} x_i(\B)^{r-1} \] Since $\frac{\partial x_i(\B)}{\partial b_i} > 0$ and $x_i(\B)^{r-1} > 0$ for all $b_i$, this implies \begin{enumerate} \item For all $b_i < w_i$, $\mfrac{\partial u_i(\B)}{\partial b_i} > 0$. \item For all $b_i > w_i$, $\mfrac{\partial u_i(\B)}{\partial b_i} > 0$. \item For $b_i = w_i$, $\mfrac{\partial u_i(\B)}{\partial b_i} = 0$. \end{enumerate} Therefore $w_i \in \argmax_{b_i \in \bbr_{> 0}}$ (in fact, $w_i$ is the unique maximizer). We conclude that the mechanism is truthful. \end{proof} From a technical standpoint, the harder task is proving that this mechanism is unique (up to additive constants in the payment rule). We assume without loss of generality that the mechanism asks each agent $i$ to report $w_i$, and let $\B=b_1,\dots,b_n$ be the vector of reported $w_i$'s. We use the standard notation of $(\B_{-i}, b_i')$ to denote the vector where the $i$th entry is $b_i'$, and the $k$th entry for each $k\ne i$ is $b_k$. The proof takes a real analysis approach, with Kirszbraun's Theorem for Lipschitz extensions~\cite{kirszbraun1934} playing a central role. On a high level, the proof proceeds as follows: (1) we establish some basic properties of the payment rule, (2) we show that the payment rule must be Lipschitz continuous not including $b_i = 0$, (3) there exists a Lipschitz extension $\phat$ including $b_i = 0$ (Kirszbraun's Theorem), (4) since $\phat$ is Lipschitz, it is differentiable almost everywhere and is equal to the integral of its derivative, (5) since it has the same derivative (when defined) as the payment rule from Theorem~\ref{thm:truthful}, the payment rules are equal (up to the constant of integration). \begin{theorem}\label{thm:truthful-unique} Assume $m=1$, and that each $v_i$ is homogenous of degree $r$ (with $r$ publicly known), concave, and differentiable. Fix $\rho \in (0,1)$, and let $\Gamma$ be a truthful mechanism which outputs an allocation $\mathbf{x} \in \Psi(\rho)$. Then the allocation rule is the same as in Theorem~\ref{thm:truthful}, and the payment rule $p_i(\B)$ is the same up to an additive constant. \end{theorem} \begin{proof} \textbf{Part 1: Setup and basic properties.} Since there is a unique optimal allocation (Lemma~\ref{lem:m=1-x}), $\Gamma$ must take $\B = (b_1,\dots, b_n)$ as honest and output the same allocation $\mathbf{x}(\B)$. It remains to consider the payment rule. Let $p_i(\B)$ denote the payment rule from Theorem~\ref{thm:main}, and let $\tilp(\B)$ denote the payment rule for $\Gamma$. Given reports $\B$, define $v_i(\B)$ as before, and let $u_i(\B) = v_i(\B) - \tilp(\B)$ be agent $i$'s resulting utility under $\Gamma$. From the point of view of a given agent $i$, the other agents' reports $\B_{-i}$ can be treated as a constant. Thus for brevity, write $x_i(b) = x_i(\B_{-i}, b)$, $p_i(b) = p_i(\B_{-i}, b)$, and $\tilp(b) = \tilp(\B_{-i}, b)$ for each $i \in N$. Fix an $i \in N$. Since $\Gamma$ is truthful, we must have $w_i \in \argmax_{b_i \in \bbr_{>0}} u_i(\B)$. Then by definition of $u_i(\B)$, we have $w_i \in \argmax_{b_i \in \bbr_{>0}} \big(w_i x_i(b_i)^r - \tilp(b_i)\big)$. Since $w_i$ could be any element of $\bbrspos$, and $\Gamma$ must be agnostic to $w_i$, we must have $b \in \argmax_{b_i \in \bbr_{>0}} \big(b x_i(b_i)^r - \tilp(b_i)\big)$ for all $b \in \bbrspos$. We first claim that $\tilp(b)$ is nondecreasing. Suppose the opposite: then there exists exists $b > b'$ such that $\tilp(b) < \tilp(b')$. But this means that if $w_i = b'$, reporting $b_i = w_i$ is never an optimal strategy, because the payment can be decreased by reporting $b_i = b$, and $x_i(b) \ge x_i(b')$ (since $x_i(b)$ is nondecreasing). Thus $\tilp(b)$ is nondecreasing. \medskip \textbf{Part 2: $\tilp$ is Lipschitz continuous.} Fix an arbitrary $b_i > 0$. Since $b_k > 0$ for all $k \ne i$, it can be seen from the definition of $x_i(b)$ that $x_i(b)^r$ is continuously differentiable on $[0,b_i]$. Therefore the maximum of $\mfrac{\dif x_i(b)^r}{\dif b}$ is a Lipschitz constant for $x_i(b)^r$, so $x_i(b)^r$ is Lipschitz continuous on $[0,b_i]$. Let $\kappa$ be this Lipschitz constant: then for all $b, b' \in [0, b_i]$, $|x_i(b)^r - x_i(b')^r| \le \kappa |b - b'|$. We claim that $\tilp$ is Lipschitz continuous on $(0, b_i]$ with constant $b_i \kappa$. Suppose the opposite: then there exist $b, b' \in (0, b_i]$ such that $|\tilp(b) - \tilp(b')| > b_i \kappa |b - b'|$. Assume without loss of generality that $b > b'$. Since $\tilp$ and $x_i$ are both nondecreasing, we then have $\tilp(b) - \tilp(b') > b_i \kappa (b - b')$ and $x_i(b)^r - x_i(b')^r \le \kappa(b-b')$. Since $b \in \argmax_{b_i \in \bbr_{>0}} \big(b x_i(b_i)^r - \tilp(b_i)\big)$, we have $b x_i(b)^r - \tilp(b) \ge b x_i(b')^r - \tilp(b')$ and thus $b(x_i(b)^r - x_i(b')^r) \ge \tilp(b) - \tilp(b')$. Therefore \[ b\kappa(b-b') \ge b\big(x_i(b)^r - x_i(b')^r\big) \ge \tilp(b) - \tilp(b') > b_i \kappa (b - b') \] Therefore $\mfrac{b\kappa}{b_i \kappa} > 1$, which contradicts $b \le b_i$. Therefore $\tilp$ is Lipschitz continuous on $(0, b_i]$. \medskip \textbf{Part 3: Kirszbraun's Theorem.} Thus by Kirszbraun's Theorem~\cite{kirszbraun1934}, $\tilp$ has a Lipschitz extension to $[0,b_i]$: that is, there exists $\phat: [0,b_i] \to \bbrpos$ such that $\phat$ is Lipschitz continuous on $[0,b_i]$, and $\phat(b) = \tilp(b)$ for $b \in (0, b_i]$. \medskip \textbf{Part 4: $\phat$ is the integral of its derivative.} Lipschitz continuity implies absolute continuity~\cite{Royden1988}, so $\phat$ is absolutely continuous on $[0, b_i]$. Thus by the Fundamental Theorem of Lebesgue Calculus~\cite{Royden1988}, $\phat$ is differentiable almost everywhere on $[0, b_i]$, its derivative $\mfrac{\dif \phat(b)}{\dif b}$ is integrable over $[0, b_i]$, and \[ \phat(b_i) - \phat(0) = \int_{b = 0}^{b_i} \frac{\dif \phat(b)}{\dif b} \dif b \] \textbf{Part 5: The derivatives of $\phat$ and $p_i$ match, so $\phat = p_i + c$.} Consider a $b > 0$ at which $\phat$ is differentiable. Then $\tilp$ is also differentiable, so $b \in \argmax_{b_i \in \bbr_{>0}} \big(b x_i(b_i)^r - \tilp(b_i)\big)$ implies $\mfrac{\dif \tilp(b)}{\dif b} = b\mfrac{\dif}{\dif b} (x_i(b)^r) = rb\mfrac{\dif x_i(b)}{\dif b} x_i(b)^{r-1}$.\footnote{Note that the $b$ in $bx_i(b_i)^r$ is a constant from the point of view of the argmax, so it is treated as a constant by the derivative. To be technically precise, we have $(\frac{\dif}{\dif b_i} b x_i(b_i)^r)|_{b_i = b} = rb\frac{\dif x_i(b)}{\dif b} x_i(b)^{r-1}$.} We showed in the proof of Theorem~\ref{thm:truthful} that $\mfrac{\partial p_i(\B)}{\partial b_i} = r b_i \frac{\partial x_i(\B)}{\partial b_i} x_i(\B)^{r-1}$; equivalently, $\mfrac{\dif p_i(b)}{\dif b} = r b \frac{\dif x_i(b)}{\dif b} x_i(b)^{r-1}$. Therefore for all $b > 0$ at which $\phat$ is differentiable, we have $\mfrac{\dif \phat(b)}{\dif b} = \mfrac{\dif p_i(b)}{\dif b}$. Since $\phat$ is differentiable almost everywhere, we have $\mfrac{\dif \phat(b)}{\dif b} = \mfrac{\dif p_i(b)}{\dif b}$ almost everywhere. Thus $ \mfrac{\dif p_i(b)}{\dif b}$ is also integrable over $[0,b_i]$, and $\int_{b = 0}^{b_i} \mfrac{\dif p_i(b)}{\dif b} \dif b = \int_{b = 0}^{b_i} \mfrac{\dif \phat(b)}{\dif b} \dif b$~\cite{Royden1988}. Therefore \begin{align*} \phat(b_i) =&\ \phat(0) + \int_{b = 0}^{b_i} \frac{\dif p_i(b)}{\dif b} \dif b\\ =&\ \phat(0) + p_i(b_i) \end{align*} where the second equality is from the definition of $p_i(\B)$. Therefore for all $b_i > 0$, $\tilp(b_i) = \phat(0) + p_i(b_i)$, and so $\tilp(\B) = \phat(0) + p_i(\B)$ for all $\B$. Since this holds for all $i \in N$, $\tilp(\B)$ is exactly the payment rule from Theorem~\ref{thm:truthful}, up to the additive constant of $\phat(0)$. \end{proof} It is worth noting that this truthful payment rule is quite complex; in particular, it may be hard to convince agents that it is actually in their best interest to be truthful. In contrast, the Walrasian pricing rule from Theorem~\ref{thm:main} is much simpler and more intuitive. That pricing rule is not truthful, but perhaps formal truthfulness is not crucial if a practical iterative implementation is possible. We do not claim that our algorithm from Section~\ref{sec:comp} is truly practical, but it could be a step in the right direction.
{'timestamp': '2020-09-22T02:14:08', 'yymm': '2009', 'arxiv_id': '2009.09351', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09351'}
arxiv
\section{Introduction} Outliers, also known as anomalies, are data points that have different characteristics from normal observations. Because the existence of outliers can markedly impact the results of statistical analyses, it thus becomes pivotal to identify and remove anomalous data objects from the general data distribution in order to preserve the integrity of data science models. Outlier detection algorithms have many practical applications \cite{zhao2019pyod}, such as credit card fraud detection, network intrusion detection, and synthetic data generation \cite{wan2020sync}. These applications demand outlier detection algorithms with high detection performance, fast execution, and great interpretability. Numerous algorithms have been proposed over the last decades, which includes covariance based models like Outlier Detection with Minimum Covariance Determinant (MCD) \cite{mcd}, proximity based models like k-Nearest Neighbors Detector (kNN) \cite{Ramaswamy2000efficient}, linear models like One-class SVM detector \cite{scholkopf2001estimating}, ensemble base models like Locally Selective Combination of Parallel Outlier Ensembles (LSCP) \cite{zhao2019lscp}, and neural network based models like Single-Objective Generative Adversarial Active Learning (SO-GAAL) and Multi-Objective Generative Adversarial Active Learning (MO-GAAL) \cite{Liu2019generative}. Existing approaches faces a few limitations. First, their performances suffer from the curse of dimensionality, and are constrained to low dimensional data. Secondly, most methods require hyperparameter selection and tuning (e.g., number of clusters for clustering based models, layer architecture for neural network based models \cite{li2020autood}, and choices for individual classifiers for ensemble models). The choice of hyperparameters is sometimes subjective, leading to different outcomes. The proposed method, called \textbf{COPOD} (\textbf{COP}ula-based \textbf{O}utlier \textbf{D}etector), has the follow key advantages: \begin{itemize} \item \textbf{COPOD is deterministic without hyperparameters}. COPOD is based on empirical cumulative distribution functions (ECDFs), and involves no learning or stochastic training. This avoids challenges in hyperparameters selection and potential biases. \item \textbf{COPOD is one of the top performing outlier detection algorithms}. Among the 10 popular detectors in comparison, COPOD ranks first, and scores 1.5\% more in ROC-AUC and 2.7\% more in Average Precision than the second best performing detector. \item \textbf{COPOD is highly interpretable via quantifying the abnormality contribution of each dimension through the Dimensional Outlie Graph}. This provides guidance to practitioners on the causes of abnormality---they can focus on certain subspaces to better improve data quality. \item \textbf{COPOD is an efficient model, and an ideal choice for high dimensional datasets}. Of the 30 datasets tested, COPOD averages third in execution time. Furthermore, COPOD scales well for large datasets, as low computation overhead is required. COPOD can easily handle datasets with 10,000 features and 1,000,000 observations on a standard personal laptop. \end{itemize} \section{Proposed Algorithm} \label{sec:proposed_algorithm} This section is divided into two parts. First, we give a theoretical background of copula models, which is the foundation and main motivation of COPOD, and in the second part, we describe the algorithmic design of COPOD in detail. \subsection{Copula Models} Copulas are functions that enable us to separate marginal distributions from the dependency structure of a given multivariate distribution. Formally, a $d$-variate copula, $C: [0,1]^d \rightarrow [0,1]$, is the cumulative distribution function (CDF) of a random vector $(U_1, U_2,...,U_d)$ with Uniform$(0,1)$ marginals: \begin{equation}\label{cop_main} C_{\textbf{U}}(\textbf{u}) = \mathbb{P}(U_1 \leq u_1,...,U_d \leq u_d) \end{equation} where $P(U_j \leq u_j) = u_j$ for $j \in {1,..,d}$ and $u_j \in [0,1]$. We will drop the subscript $\textbf{U}$ when there is no confusion. It is well known that uniform distributions can be transformed into any desired distributions via inverse sampling \begin{equation}\label{inverse relationship} X_j = {F_j}^{-1}(U_j) \sim F_j \end{equation} Sklar \cite{sklar1959fonctions} show that for any random variables $(X_1,\cdots,X_d)$ with joint distribution function $F(x_1,...,x_d)$ and marginal distributions $F_1,...,F_d$, there exists a copula such that \begin{equation}\label{sklar1} F(\textbf{x}) = C(F_1(x_1),...,F_d(x_d)) \end{equation} In other words, a copula allows us to describe the joint distribution of $(X_1,\cdots,X_d)$ using only their marginals. This gives a lot of flexibility when modelling high dimensional datasets, as we can model each dimension separately, and there is a guaranteed way to link the marginal distributions together to form the joint distribution. Sklar also shows that if $F$ has univariate marginal distributions $F_1,..., F_d$, then there exists a copula $C(.)$ such that equation \ref{sklar1} holds. Furthermore, if the marginals are continuous, then $C(.)$ can be uniquely determined. Similarly, by substituting the inverse of equation \ref{inverse relationship} into equation \ref{cop_main}, we obtain the copula equation expressed in terms of the joint CDF and inverse CDFs. \begin{align}\label{sklar} C(\textbf{u}) & = \mathbb{P}(F_{X_1}(X_1) \leq u_1, \cdots, F_{X_d}(X_d) \leq u_d) \nonumber\\ & = \mathbb{P}(X_1 \leq F_{X_1}^{-1}(X_1), \cdots, F_{X_d}^{-1}(X_d)) \nonumber\\ & = F_{\textbf{X}}(F_{X_d}^{-1}(u_1),\cdots,F_{X_d}^{-1}(u_d)) \end{align} Together, these two results are known as Sklar's Theorem, and they guarantee the exists of a copula for any given multivariate CDF with continuous marginals, and provides a closed form equation for how the copula can be constructed. \subsection{Empirical Copula} COPOD uses a nonparametric approach based on fitting empirical cumulative distribution functions (ECDFs) called \textbf{Empirical Copula}. Let $X$ be a $d$-dimensional dataset with $n$ observations. We use $X_{j,i}$ to denote the $i^{th}$ observation of the $j^{th}$ dimension. When there is no confusion, we will only use one of the two subscripts, $X_j$ or $X_i$, to denote dimension or observation, respectively. The empirical CDF, $\hat{F}(x)$ is defined: \begin{equation}\label{empirical cdf} \hat{F}(x) = \mathbb{P}((-\infty, x]) = \frac{1}{n}\sum_{i=1}^n\mathbb{I}(X_i \leq x) \end{equation} By leveraging the inverse of equation \ref{inverse relationship}, we can obtain the empirical copula observations, $\hat{U}^i$, by \begin{equation}\label{empirical cop obs} (\hat{U}_{1,i},...,\hat{U}_{d,i}) = \big(\hat{F}_1(X_{1,i}),...,\hat{F}_d(X_{d,i})\big) \end{equation} Finally, by substituting the empirical copula observations into the first equality of equation \ref{sklar}, we have \begin{equation}\label{empirical cop} \hat{C}(u_1,\cdots,u_d) = \frac{1}{n} \sum_{i=1}^n \mathbb{I}\left(\tilde{U}_{1,i}\leq u_1,\cdots,\tilde{U}_{d,i}\leq u_d\right) \end{equation} Nelsen \cite{nelsen2007introduction} show that an empirical copula, $\hat{C}(\textbf{u)}$ with multivariate CDFs supported on $n$ points in the grid $\{1/n, 2/n,\dots, 1\}^d$, has discrete uniform marginals on $\{1/n, 2/n,\dots,1\}$, and asymptotically converges to $C(\textbf{u})$ as a result of the central limit theorem. \subsection{Theoretical Framework of COPOD} Outlier detection with COPOD is a three-stage process. First, we compute the empirical CDFs based on the dataset of interest $X = [X_{1,i},\cdots,X_{d,i}], \, i=1,\cdots,n$. Secondly, we use the empirical CDFs to produce the empirical copula function. Finally, we use the empirical copula to approximate the tail probability, namely equation \ref{sklar1} or alternatively, $F_X(x_i) = \mathbb{P}(X_1 \leq x_{1,i},...,X_d \leq x_{d,i})$ for each $x_i$. \subsubsection{Outliers as Tail Events} For every observation $x_i$, our goal is to compute the probability of observing a point at least as extreme as $x_i$. In other words, assume that $x_i$ is distributed according to some $d$-variate distribution function $F_X$, we want to calculate $F_X(x_i) = \mathbb{P}(X \leq x_i)$ and $1-F_X(x_i) = \mathbb{P}(X \geq x_i)$. If $x_i$ is an outlier, it should occur infrequently, and as such, the probability of observing a point at least as extreme as $x_i$ should be small. Therefore, if either $F_X(x_i)$ or $1 - F_X(x_i)$ is extremely small, there is evidence that this point has rare occurrence, and is, therefore, likely to be an outlier. We call $F_X(x_i)$ the \textit{left tail probability} of $x_i$ and $1 - F_X(x_i)$ the \textit{right tail probability} of $x_i$. We say that an outlier has a small tail probability if either of the two quantities are small. In order to compute the tail probabilities empirically, we first compute the empirical CDF using equation \ref{empirical cdf}, once we have the empirical CDFs, we can approximate the inverse of equation \ref{inverse relationship} to obtain the estimated copula observations $u_j$ by feeding each $x_j$ into $\hat{F}_j$. The estimated copula observations tells us the probability of observing something as extreme as $x$ along the $j^{th}$ dimension. Finally, multiplying all $u_j$'s together gives the empirical estimate of the left tail probability. \subsubsection{Computing Right Tail Probabilities} In a similar fashion, we can compute the right tail probabilities. All we needed is \begin{equation}\label{cop inverse} C(1-u) = \mathbb{P}(U_1 \geq u_1,...,U_d \geq u_d) \end{equation} and since we are feeding $1 - u_j$ into $\hat{F}_j$, this should give us the desired result. However, because $\hat{F}_j$ is not a true cumulative distribution function, and it only has support from $\{1/n, 2/n,..., 1\}^d$. The largest $u_j$, in this case, would equal to 1, and substituting that into equation \ref{cop inverse} implies that $\mathbb{P}(U_1 \geq u_1,..., U_j \geq u_j,...,U_d \geq u_d) = \mathbb{P}(U_1 \geq u_1,..., U_j \geq 1,...,U_d \geq u_d) = 0$, as no uniforms can take on values greater than or equal to zero. A zero tail probability would make computing the outlier score difficult in subsequent steps. A simply way to address this challenge is to calculate $\hat{F}_j$ based on $-X = [-X_{1,i},-X_{2,i},\dots,-X_{d,i}]$, and by calculating $\hat{F}_d(-x)$. The desired result follows from substituting $-X_i$ and $-x$ in the last part of equation \ref{empirical cdf}. To avoid confusion in notations, we use $\hat{F}_j$ to denote the left tail ECDF derived from $X$ and $\hat{\bar{F}}_j$ to denote the right tail ECDF derived from $-X$. \subsubsection{Diminishing Tail Probabilities} It is well known that various unusual phenomena arise in high-dimensional spaces, which do not occur in low-dimensional settings. This is known as the \textit{curse of dimensionality} and outlier detection algorithms are known to be victims. Consider equation \ref{empirical cop} in both low dimensional and high dimensional settings. As dimensionality increases, the probability of $\tilde{U}_{j,i} \leq u_j, \forall j$ decreases exponentially. Specifically, \small \begin{align}\label{cop2} \hat{C}(u_1,\dots,u_d) & = \frac{1}{n} \sum_{i=1}^n \mathbb{I}\left(\tilde{U}_{1,i}\leq u_1,\dots,\tilde{U}_{d,i}\leq u_d\right) \nonumber \\ & = \frac{1}{n} \sum_{i=1}^n \mathbb{I}(\tilde{U}_{1,i}\leq u_1) \times \dots \times \mathbb{I}(\tilde{U}_{d,i}\leq u_d) \nonumber \\ & \approx \mathbb{P}(\tilde{U}_{1,i}\leq u_1) \times...\times \mathbb{P}(\tilde{U}_{d,i}\leq u_d) \end{align} \normalsize and copula function approaches zero as $d$ increases. In order to avoid diminishing tail probabilities, and using the monotonicity property of the $\log()$ function, we instead work with the sum of the negative log probabilities. \small \begin{align} \label{neg log prob} -\log(\hat{C}(\textbf{u})) & = -\log(\mathbb{P}(\tilde{U}_{1,i}\leq u_1) \times...\times \mathbb{P}(\tilde{U}_{d,i}\leq u_d)) \nonumber \\ & = - \sum_{j=1}^d \log(\mathbb{P}(\tilde{U}_{j,i}\leq u_j)) = - \sum_{j=1}^d \log(u_j) \end{align} \normalsize The last line holds since $\tilde{U}_{1,i}$ is uniformly distributed on $[0,1]$.Notice that the motivation of taking logs is similar to that of the log likelihood functions. \subsubsection{Skewness Correction} We point out a need for correcting for skewness, in cases where outliers fall on one extreme end of the distribution. Consider Figure 1, where five sets of training and testing results are shown. The images on the left most column are plots of two generated 2-dimensional datasets, with outliers labelled as yellow in the training set and red in the test set. The datasets are generated by taking samples from a combination of normal and uniform distributions on the square. In the next three columns, we show the results of COPOD if left tail probabilities, right tail probabilities, and averages of both tail probabilities are used, respectively. Because of the nature of this dataset (i.e., all outliers fall on the left end of the 2-dimensional distribution), using the left tail probabilities works surprising well, because all outliers, by the construction of the dataset, are ``smaller" than normalcy. On the other hand, using the right tail worked extremely poorly, because there are no extremely large outliers, and thus COPOD would have wrongfully captured the relatively large points as outliers. Taking an average of the two tail probabilities (column 4 of Figure 1) compromises the situation, and identifies half of the left tail outliers and misidentifies half of the right tail. We should point out that if the dataset is flipped, and all outliers appear on the top right corner while the inliers appear on the bottom left, then COPOD with right tail ECDFs would have worked perfectly, while left tail ECDFs would perform poorly. Averaging, on the other hand, works if both large and small outliers occur. To overcome this, we note that the skewness of the dataset plays a major role in whether left tail ECDFs or right tail ECDFs should be used. In this example, both marginals of $X_1$ and $X_2$ skew negatively (i.e., the left tail is longer and the mass of the distribution is concentrated on the right). In this case, it makes sense to use the left tail ECDF. For dimensions that skew positively, using the right tail ECDFs would become a better choice. Referring back to equation \ref{neg log prob}, whether we use $\leq$ or $\geq$ depends on whether dimension $j$ skews negatively or positively. The right most column of Figure 1 demonstrates the outcome of COPOD of tail selection is based on skewness of each dimension, and we can see that it is able to capture the correct outliers. We called this the skewness corrected version of COPOD and in Section \ref{sec:empirical_evaluation}, we demonstrate the performance of different variants of COPOD through simulation studies. \begin{figure*}[htp]\label{toy_example_pic} \centering \includegraphics[scale=0.425]{cod_example.png} \vspace{-0.3in} \caption{A toy example of how using different tail probabilities affect the results. The leftmost column are plots of the ground truth, the second column are COPOD's detection if left tail probabilities are used. The middle column corresponds to outlier detection if right tail probabilities are used, followed by both tail probabilities (Two Tails) in the fourth column and skewness corrected tail probabilities (SC Tails) in the rightmost column (which shows the best result).} \end{figure*} \subsection{COPOD Algorithm} Now we are ready to formally introduce COPOD. COPOD is a three stage algorithm, which takes a $d$-dimensional input dataset $X = (X_{1,i},X_{2,i},\dots,X_{d,i}), \, i=1,\dots,n$, and produces an outlier score vector $O(X) = [X_1,...,X_n]$. Outlier scores are between $(0, \infty)$, and are to be use comparatively. \textbf{In other words, the score does not indicate the probability of $X_i$ being an outlier, but rather the relative measure of how likely $X_i$ is when compared to other points in the dataset}. . The bigger $O(X_i)$ is, the more likely $X_i$ is an outlier. In the first step, COPOD fits $d$ empirical lef tail CDFs, $\hat{F}_1(x),\cdots, \hat{F}_d(x)$, using equation \ref{empirical cdf}, and $d$ empirical right tail CDFs $\hat{\bar{F}}_1(x),\cdots, \hat{\bar{F}}_d(x)$ by replacing $X$ with $-X$. We also compute the skewness vector, $b = [b_1,...,b_d]$, where \begin{equation}\label{skewness coef} b_i = \frac{\tfrac{1}{n} \sum_{i=1}^n (x_i-\overline{x_i})^3}{ \sqrt{\tfrac{1}{n-1} \sum_{i=1}^n (x_i-\overline{x_i})^2}^{\,3}} \end{equation} is the standard formula for estimating skewness. In the second step, we compute the empirical copula observations for each $X_i$ according to equation \ref{empirical cop obs}, where we obtain $\hat{U}_{d,i} = \hat{F}_d(x_i)$ and $\hat{V}_{d,i} = \hat{\bar{F}}_d(x_i)$, respectively. Further, we calculate the skewness corrected empirical copula observations, $\hat{W}_{d,i} = \hat{U}_{d,i}$ if $b_d < 0$, otherwise $\hat{V}_{d,i}$. Lastly, we compute the probability of observing a point at least as extreme as each $x_i$ along each dimension. We take the maximum of the negative log of the probability generated by the left tail empirical copula, right tail empirical copula and skewness corrected empirical copula to be the outlier score. Intuitively, the smaller the tail probability is, the bigger its minus log, and so we claim a point is an outlier if it has a small left tail probability, a small right tail probability, or a small skewness corrected tail probability. We summarise the algorithm in Algorithm \ref{alg:COPOD}. \begin{algorithm} [ht] \caption{Copula Outlier Detector} \label{alg:COPOD} \scriptsize \begin{algorithmic}[1] \Require{input data $X$} \Ensure{outlier scores $O(X)$} \For{each dimension $d$} \State Compute left tail ECDFs: $\hat{F}_d(x) = \frac{1}{n}\sum_1^n\mathbb{I}(X_i \leq x)$ \State Compute right tail ECDFs: $\hat{\bar{F}}_d(x) = \frac{1}{n}\sum_1^n\mathbb{I}(-X_i \leq -x)$ \State Compute the skewness coefficient according to Equation \ref{skewness coef}. \EndFor \For{each $i$ in $1,...n$} \State Compute empirical copula observations \Indent \State $\hat{U}_{d,i} = \hat{F}_d(x_i)$, \State $\hat{V}_{d,i} = \hat{\bar{F}}_d(x_i)$ \State $\hat{W}_{d,i} = \hat{U}_{d,i} \: \text{if $b_d < 0$ otherwise} \: \hat{V}_{d,i}$ \EndIndent \State Calculate tail probabilities of $X_i$ as follows: \Indent \State $p_l = -\sum_{j=1}^d \log(\hat{U}_{j,i})$ \State $p_r = -\sum_{j=1}^d \log(\hat{V}_{j,i})$ \State $p_s = -\sum_{j=1}^d \log(\hat{W}_{j,i})$ \EndIndent \State Outlier Score $O(x_i) = \max\{p_l, \; p_r, \; p_s\}$ \EndFor \State \textbf{Return} $O(X)=[O(x_1),...,O(x_d)]^T$ \end{algorithmic} \end{algorithm} \subsection{COPOD as an Interpretable Outlier Detector} Interpretability in machine learning is an important concept, as it provides domain experts some insights into how algorithms make their decisions. Interpretable algorithms provide both transparency and reliability \cite{hu2019optimal}. Having a transparent model means that humans can learn from the thought process of models, and try to discover the ``whys" behind why a particular data point is classified. Reliability, on the other hand, ensures that machine learning models can be properly audited so that their reasoning processes align with human expectations. As COPOD evaluates the anomalous behaviours on a dimensional basis, it is possible to use COPOD as an explainable detector. From equation \ref{alg:COPOD}, we know that if a point has a large outlier score, then at least one of the three tail copulas is large. Thus, let $O_d(x_i) = \max\{\log(\hat{U}_{d,i}), \: \log(\hat{V}_{d,i}), \: \log(\hat{W}_{d,i})\}$ be the outlier score for dimension $d$, and using fact that the $\log$ function is monotone, we can see that each $O_d(x_i)$ represents the degree of anomalousness of dimension $d$. This can be compared against some desired threshold, such as $-\log(0.01) = 4.61$, or top $\alpha$ percent of $O_d(x_i) \; \forall i$ to give practitioners some indications why particular points are considered outliers. We illustrate the interpretability aspect of COPOD with the Breast Cancer Wisconsin (Diagnostic) Data Set (BreastW) as an example. Cell samples are provided by Dr. William H. Wolberg from the University of Wisconsin as part of his reports on clinical cases. This batch of data used has 369 samples, with 9 features listed below, and two outcome classes (benign and malignant). Features are scored on a scale of 1-10, and are 1) Clump Thickness, 2) Uniformity of Cell Size, 3) Uniformity of Cell Shape, 4) Marginal Adhesion, 5) Single Epithelial Cell Size, 6) Bare Nuclei, 7) Bland Chromatin, 8) Normal Nucleoli and 9) Mitoses. Section \ref{sec:empirical_evaluation} discusses this dataset in greater detail. We are particularly interested in providing an explanation, in addition to giving the right classification of outlier vs. inliner, as this can provide useful guidance for physicians to further investigate why certain cells are potentially harmful. We illustrate how COPOD attempts to explain its outlier detection process using the following example. For each of the 9 dimensions of data point $i$, we plot $O_d(x_i)$, the dimensional outlier score. In additional, we also plot the $99^{th}$ percentile band in green, and the $65.01^{th}$ percentile band in black (which corresponds to $1 -$ contamination rate). We call this the \textit{Dimensional Outlier Graph}. In the analysis below, we plot the Dimensional Outlier Graph for data point 70 (row 70 in BreastW), which is an outlier and has been successfully detected by COPOD. \begin{figure}[tp]\label{od70} \includegraphics[width=0.5\textwidth]{Dimensional_70.pdf} \vspace{-0.3in} \caption{\textit{Dimensional Outlier Graph} for sample 70 (row 70); dimension 2, 5, 9 are identified as outlier subspaces.} \end{figure} We see that for features 2, 5 and 9, the dimensional outlier scores have touched the $99^{th}$ percentile band, while all other features remain below the contamination rate band. This suggests that this point is likely an outlier because it is extremely non-uniform in size, has a large single epithelial cell size, and is more likely to reproduce via mitosis rather than meiosis. \section{Empirical Evaluation} \label{sec:empirical_evaluation} \subsection{Datasets and Evaluation Metrics} 30 public outlier detection benchmark datasets used in this study are from \texttt{ODDS}\footnote{ODDS Library: \url{http://odds.cs.stonybrook.edu}} and \texttt{DAMI} Datasets\cite{dami}. In each experiment, 60\% of the data is used for training and the remaining 40\% is set aside for validation. Performance is evaluated by taking the average score of 10 independent trials using area under the receiver operating characteristic (ROC-AUC) and average precision (AP). \subsection{COPOD Implementation} Our implementation of COPOD\footnote{\url{https://github.com/winstonll/COPOD}} is featured and included in PyOD \cite{zhao2019pyod}, a popular open-source Python toolbox for performing scalable outlier detection on multivariate data with a single, well-documented API. This allows us to easily compare COPOD with other outlier detectors. In the subsequent experiments, a Windows laptop with Intel i5-8265U @ 1.60 GHz quad core CPU and 8 GB of memory is used. \subsection{Performance of COPOD variants} In the first experiment, we compare performances of a several variants of COPOD. Specifically, we look at comparisons between four variants, namely, \textit{left tail ECDF}, \textit{right tail ECDF}, \textit{two tails ECDF}, and \textit{skewness corrected ECDF} as outlined in Section \ref{sec:proposed_algorithm}. COPOD with skewness corrected ECDF achieves the best performance, with an average ROC-AUC of 0.8247 and average precision of 0.5649, followed by COPOD with two tails (ROC: 0.7818, AP: 0.4767), COPOD with right tail ECDF (ROC: 0.7148, AP: 0.4118) and finally COPOD with left tail ECDF (ROC: 0.5061, AP: 0.2514). \subsection{Performance vs. other outlier detectors} \begin{table*}[ht] \setlength{\tabcolsep}{3pt} \centering \caption{ROC-AUC scores of detector performance (average of 10 independent trials, highest score highlighted in bold); rank is shown in parenthesis (lower is better). COPOD outperforms all baselines.} \vspace{-0.1in} \footnotesize \scalebox{0.735}{ \begin{tabular}{l|rrrrrrrrr|r} \toprule \textbf{Data} & \textbf{ABOD} & \textbf{CBLOF} & \textbf{FB} & \textbf{HBOS} & \textbf{IForest} & \textbf{KNN} & \textbf{LODA} & \textbf{LOF} & \textbf{OCSVM} & \textbf{COPOD} \\ \midrule Arrhythmia (mat) & 0.7688 (9) & 0.7838 (6) & 0.7839 (5) & \textbf{0.8219 (1)} & 0.802 (3) & 0.7861 (4) & 0.7497 (10) & 0.7787 (8) & 0.7812 (7) & 0.8021 (2) \\ Breastw (mat) & 0.3959 (10) & 0.9651 (6) & 0.396 (9) & 0.9825 (4) & 0.9869 (3) & 0.9755 (5) & 0.9873 (2) & 0.47 (8) & 0.9612 (7) & \textbf{0.9936 (1)} \\ Cardio (mat) & 0.5692 (10) & 0.81 (6) & 0.7057 (8) & 0.8351 (5) & 0.9226 (2) & 0.7236 (7) & 0.8559 (4) & 0.5736 (9) & \textbf{0.9348 (1)} & 0.8974 (3) \\ Ionosphere (mat) & 0.9248 (3) & 0.8972 (4) & \textbf{0.9495 (1)} & 0.5614 (10) & 0.8472 (6) & 0.9267 (2) & 0.7975 (9) & 0.8753 (5) & 0.8419 (7) & 0.8307 (8) \\ Lympho (mat) & 0.911 (8) & 0.9673 (7) & 0.8809 (9) & \textbf{0.9957 (1)} & 0.9934 (3) & 0.9745 (6) & 0.7303 (10) & 0.9771 (4) & 0.9759 (5) & 0.9935 (2) \\ Mammography (mat) & 0.5494 (10) & 0.8213 (8) & \textbf{0.8775 (2)} & 0.8342 (7) & 0.8602 (5) & 0.841 (6) & 0.8809 (3) & 0.7293 (9) & 0.8724 (4) & \textbf{0.8942 (1)} \\ Optdigits (mat) & 0.4667 (7) & 0.7692 (3) & 0.7948 (2) & \textbf{0.8732 (1)} & 0.7209 (5) & 0.3708 (10) & 0.3982 (9) & 0.45 (8) & 0.4997 (6) & 0.7328 (4) \\ Pima (mat) & 0.6794 (3) & 0.6578 (6) & 0.3781 (10) & 0.7000 (2) & 0.6778 (4) & \textbf{0.7078 (1)} & 0.592 (9) & 0.6271 (7) & 0.6215 (8) & 0.6638 (5) \\ Satellite (mat) & 0.5714 (9) & 0.7494 (2) & 0.6525 (7) & \textbf{0.7581 (1)} & 0.7024 (3) & 0.6836 (4) & 0.5969 (8) & 0.5573 (10) & 0.6622 (5) & 0.6612 (6) \\ Satimage-2 (mat) & 0.819 (8) & \textbf{0.9992 (1)} & 0.5670 (9) & 0.9804 (6) & 0.9947 (3) & 0.9536 (7) & 0.9866 (4) & 0.4577 (10) & 0.9978 (2) & 0.9852 (5) \\ Shuttle (mat) & 0.6591 (7) & 0.6075 (8) & 0.6715 (6) & 0.9948 (3) & \textbf{0.9983 (1)} & 0.7381 (5) & 0.5892 (9) & 0.5243 (10) & 0.9945 (4) & 0.998 (2) \\ Speech (mat) & \textbf{0.6267 (1)} & 0.4515 (7) & 0.4503 (8) & 0.4538 (6) & 0.447 (10) & 0.4581 (4) & 0.4551 (5) & 0.4714 (3) & 0.4472 (9) & 0.4845 (2) \\ WBC (mat) & 0.9047 (9) & 0.9201 (7) & 0.4615 (10) & 0.9516 (2) & 0.9314 (6) & 0.9366 (3) & 0.9126 (8) & 0.9349 (4) & 0.9319 (5) & \textbf{0.9747 (1)} \\ Wine (mat) & 0.4305 (9) & 0.2835 (10) & 0.9346 (2) & 0.9001 (4) & 0.8163 (5) & 0.5177 (8) & 0.7873 (6) & 0.9045 (3) & 0.6363 (7) & \textbf{0.949 (1)} \\ Arrhythmia (arff) & 0.7396 (9) & 0.7514 (5) & 0.7614 (2) & 0.7493 (7) & 0.7567 (3) & 0.7508 (6) & 0.7028 (10) & 0.749 (8) & 0.7557 (4) & \textbf{0.7618 (1)} \\ Cardiotocography (arff) & 0.4593 (10) & 0.5673 (6) & 0.5184 (7) & 0.5936 (5) & 0.6828 (2) & 0.4904 (9) & 0.6738 (3) & 0.5045 (8) & \textbf{0.6976 (1)} & 0.637 (4) \\ HeartDisease (arff) & 0.5969 (6) & 0.5926 (7) & 0.6286 (3) & \textbf{0.6893 (1)} & 0.602 (5) & 0.6136 (4) & 0.4821 (10) & 0.5626 (8) & 0.5548 (9) & 0.6728 (2) \\ Hepatitis (arff) & 0.7155 (9) & 0.7585 (8) & 0.8420 (2) & 0.7961 (5) & 0.7935 (6) & 0.8111 (4) & 0.6075 (10) & 0.8305 (3) & 0.7644 (7) & \textbf{0.8432 (1)} \\ InternetAds (arff) & 0.6427 (4) & 0.6166 (7) & 0.6132 (8) & \textbf{0.6994 (1)} & 0.6851 (2) & 0.6216 (6) & 0.5276 (10) & 0.6057 (9) & 0.6233 (5) & 0.6763 (3) \\ Ionosphere (arff) & \textbf{0.9250 (1)} & 0.8859 (3) & 0.8800 (4) & 0.552 (10) & 0.836 (7) & 0.9187 (2) & 0.8222 (8) & 0.8604 (5) & 0.8381 (6) & 0.8219 (9) \\ KDDCup99 (arff) & 0.6925 (8) & 0.9970 (2) & 0.391 (10) & 0.995 (4) & 0.9968 (3) & 0.7611 (6) & 0.7277 (7) & 0.5774 (9) & 0.9948 (5) & \textbf{0.9972 (1)} \\ Lymphography (arff) & 0.9864 (9) & 0.9956 (6) & 0.9961 (5) & 0.9984 (3) & 0.9994 (1) & 0.9965 (4) & 0.8385 (10) & 0.995 (7) & 0.9915 (8) & 0.9985 (2) \\ Pima (arff) & 0.6666 (3) & 0.6658 (4) & 0.6544 (7) & 0.6591 (5) & 0.6756 (2) & \textbf{0.7063 (1)} & 0.5974 (10) & 0.6582 (6) & 0.6403 (9) & 0.6466 (8) \\ Shuttle (arff) & 0.8338 (7) & 0.9802 (2) & 0.3671 (10) & 0.7924 (8) & 0.8661 (6) & 0.9607 (4) & 0.7066 (9) & \textbf{0.9857 (1)} & 0.9658 (3) & 0.8795 (5) \\ SpamBase (arff) & 0.4349 (9) & 0.5476 (5) & 0.6795 (2) & 0.6698 (3) & 0.6328 (4) & 0.5399 (6) & 0.4449 (8) & 0.4255 (10) & 0.5386 (7) & \textbf{0.7007 (1)} \\ Stamps (arff) & 0.7617 (7) & 0.7299 (10) & 0.7419 (8) & 0.9182 (2) & 0.9132 (3) & 0.8738 (6) & 0.9014 (4) & 0.739 (9) & 0.88 (5) & \textbf{0.9388 (1)} \\ Waveform (arff) & 0.6522 (9) & 0.7143 (4) & 0.6966 (5) & 0.683 (6) & 0.6813 (7) & 0.7403 (2) & 0.622 (10) & 0.7354 (3) & 0.6649 (8) & \textbf{0.7865 (1)} \\ WBC (arff) & 0.9559 (8) & 0.9658 (7) & 0.9432 (9) & 0.9819 (3) & \textbf{0.9906 (1)} & 0.9715 (6) & 0.9811 (4) & 0.9315 (10) & 0.9751 (5) & 0.9904 (2) \\ WDBC (arff) & 0.9032 (9) & 0.9088 (8) & 0.5388 (10) & 0.9674 (2) & 0.9462 (3) & 0.9272 (6) & 0.9455 (4) & 0.9204 (7) & 0.938 (5) & \textbf{0.9826 (1)} \\ WPBC (arff) & 0.457 (10) & 0.4918 (9) & 0.5196 (4) & 0.5357 (2) & 0.5164 (5) & 0.526 (3) & 0.5029 (7) & 0.5108 (6) & 0.4979 (8) & \textbf{0.5465 (1)} \\ \midrule AVG & 0.6900 (9) & 0.7617 (5) & 0.6792 (10) & 0.7974 (3) & 0.8092 (2) & 0.7601 (6) & 0.7135 (7) & 0.6974 (8) & 0.7826 (4) & \textbf{0.8247 (1)} \\ \bottomrule \end{tabular}} \label{table:od comparison roc} \end{table*} In this section, we compare the performance of COPOD with 9 other outlier detectors. We aim to include a variety of detectors to make the comparison robust. Specifically, the 9 competitors are Angle-Based Outlier Detection (ABOD), Clustering-Based Local Outlier Factor (CBLOF), Feature Bagging (FB), Histogram-based Outlier Score (HBOS), Isolation Forest (IForest), k Nearest Neighbors (KNN), Lightweight On-line Detector of Anomalies (LODA), Local Outlier Factor(LOF) and One-Class Support Vector Machines (OCSVM). Their implementations can all be found in PyOD. Of the 30 datasets used, COPOD scores the highest in terms of ROC-AUC. Specifically, COPOD achieves an average ROC-AUC score of 82.47\%, which is 1.5\% higher than the second best alternative. COPOD ranks first in 12 out of 30 occasions and ranks in the top two places in 16 out of 30 occasions. Similar results are seen for average precision scores. Of the 10 detectors, COPOD achieves an average precision of 56.49\%, which is 2.7\% higher than the second place. COPOD ranks first in 12 out of 30 datasets, and ranks in the top two places in 17 times. Finally, COPOD ranks third in computation time with an average of 0.227 seconds to process the 30 test dataset, falling just behind HBOS (0.046s) and LODA (0.062s). \begin{table*}[ht] \setlength{\tabcolsep}{3pt} \centering \caption{Average precision of detector performance (average of 10 independent trials, highest score highlighted in bold); rank is shown in parenthesis (lower is better). COPOD outperforms all baselines.} \vspace{-0.1in} \footnotesize \scalebox{0.735}{ \begin{tabular}{l|rrrrrrrrr|r} \toprule \textbf{Data} & \textbf{ABOD} & \textbf{CBLOF} & \textbf{FB} & \textbf{HBOS} & \textbf{IForest} & \textbf{KNN} & \textbf{LODA} & \textbf{LOF} & \textbf{OCSVM} & \textbf{COPOD} \\ \midrule Arrhythmia (mat) & 0.3585 (10) & 0.399 (6) & 0.3872 (8) & 0.4928 (2) & \textbf{0.5062 (1)} & 0.3968 (7) & 0.4359 (4) & 0.3742 (9) & 0.4045 (5) & 0.4727 (3) \\ Breastw (mat) & 0.2945 (9) & 0.9141 (7) & 0.2927 (10) & 0.953 (4) & 0.9721 (3) & 0.9269 (6) & 0.9777 (2) & 0.3215 (8) & 0.9343 (5) & \textbf{0.9877 (1)} \\ Cardio (mat) & 0.1936 (9) & 0.4136 (6) & 0.2091 (8) & 0.4602 (4) & 0.5763 (2) & 0.3451 (7) & 0.4237 (5) & 0.1626 (10) & 0.5324 (3) & \textbf{0.5793 (1)} \\ Ionosphere (mat) & 0.9141 (2) & 0.8712 (3) & 0.1198 (10) & 0.3664 (9) & 0.7889 (6) & \textbf{0.9238 (1)} & 0.7156 (8) & 0.8211 (5) & 0.8229 (4) & 0.7194 (7) \\ Lympho (mat) & 0.5168 (9) & 0.8078 (8) & 0.8266 (4) & 0.9252 (2) & \textbf{0.9516 (1)} & 0.82 (6) & 0.4165 (10) & 0.8252 (5) & 0.8144 (7) & 0.8936 (3) \\ Mammography (mat) & 0.0232 (10) & 0.1369 (7) & 0.4258 (2) & 0.1222 (8) & 0.2329 (4) & 0.1695 (6) & 0.2808 (3) & 0.1179 (9) & 0.188 (5) & \textbf{0.429 (1)} \\ Optdigits (mat) & 0.0279 (7) & 0.0624 (3) & 0.1092 (2) & \textbf{0.1957 (1)} & 0.0553 (4) & 0.0223 (10) & 0.0244 (9) & 0.0288 (6) & 0.0275 (8) & 0.0532 (5) \\ Pima (mat) & 0.5107 (4) & 0.4771 (6) & 0.0234 (10) & \textbf{0.5693 (1)} & 0.5031 (5) & \textbf{0.5145 (3)} & 0.4081 (9) & 0.4299 (8) & 0.4608 (7) & 0.5407 (2) \\ Satellite (mat) & 0.3973 (9) & \textbf{0.6897 (1)} & 0.4518 (8) & 0.6866 (2) & 0.6539 (3) & 0.5431 (7) & 0.5805 (6) & 0.3898 (10) & 0.6529 (4) & 0.5854 (5) \\ Satimage-2 (mat) & 0.1874 (9) & \textbf{0.9777 (1)} & 0.3984 (8) & 0.758 (6) & 0.9285 (3) & 0.4186 (7) & 0.8695 (4) & 0.0267 (10) & 0.9746 (2) & 0.8599 (5) \\ Shuttle (mat) & 0.1705 (8) & 0.1945 (7) & 0.0353 (10) & 0.9796 (3) & \textbf{0.9857 (1)} & 0.2036 (6) & 0.3786 (5) & 0.1421 (9) & 0.9015 (4) & 0.9807 (2) \\ Speech (mat) & \textbf{0.0395 (1)} & 0.0216 (5) & 0.0223 (4) & 0.0272 (2) & 0.0177 (9) & 0.0216 (5) & 0.0165 (10) & 0.0243 (3) & 0.0214 (7) & 0.0195 (8) \\ WBC (mat) & 0.3545 (10) & 0.4995 (9) & 0.562 (5) & 0.6627 (2) & 0.5898 (3) & 0.5294 (7) & 0.5641 (4) & 0.558 (6) & 0.5137 (8) & \textbf{0.7827 (1)} \\ Wine (mat) & 0.0838 (9) & 0.0598 (10) & 0.3563 (4) & 0.405 (2) & 0.2794 (5) & 0.0946 (8) & 0.2783 (6) & 0.3611 (3) & 0.1414 (7) & \textbf{0.6082 (1)} \\ Arrhythmia (arff) & 0.6987 (9) & 0.7118 (6) & 0.7314 (4) & 0.7504 (2) & 0.7463 (3) & 0.7118 (6) & 0.697 (10) & 0.704 (8) & 0.7164 (5) & \textbf{0.7519 (1)} \\ Cardiotocography (arff) & 0.247 (10) & 0.3625 (6) & 0.2702 (8) & 0.3664 (5) & \textbf{0.4342 (1)} & 0.3108 (7) & 0.4315 (2) & 0.2582 (9) & 0.4185 (3) & 0.3778 (4) \\ HeartDisease (arff) & 0.5341 (5) & 0.521 (7) & 0.5506 (3) & 0.6247 (2) & 0.5337 (6) & 0.5384 (4) & 0.445 (10) & 0.4779 (9) & 0.5128 (8) & \textbf{0.64 (1)} \\ Hepatitis (arff) & 0.3304 (10) & 0.3739 (9) & \textbf{0.5660 (2)} & 0.4732 (5) & 0.4424 (6) & 0.4752 (4) & 0.3957 (8) & 0.4986 (3) & 0.4274 (7) & \textbf{0.5849 (1)} \\ InternetAds (arff) & 0.276 (7) & 0.3153 (5) & 0.2737 (8) & \textbf{0.5347 (1)} & 0.4895 (3) & 0.2805 (6) & 0.2417 (10) & 0.2622 (9) & 0.3157 (4) & 0.5102 (2) \\ Ionosphere (arff) & \textbf{0.5055 (6)} & 0.4839 (7) & 0.5286 (2) & 0.5281 (3) & 0.5146 (5) & 0.525 (4) & 0.4199 (10) & 0.4584 (9) & 0.4779 (8) & \textbf{0.5302 (1)} \\ KDDCup99 (arff) & 0.3798 (7) & 0.4143 (5) & 0.3018 (10) & 0.5249 (2) & 0.4923 (3) & 0.4219 (4) & 0.3752 (8) & 0.3489 (9) & 0.4115 (6) & \textbf{0.5667 (1)} \\ Lymphography (arff) & 0.2465 (8) & 0.2409 (9) & 0.4352 (2) & 0.3983 (4) & 0.3936 (5) & 0.3412 (7) & 0.4038 (3) & 0.2291 (10) & 0.3464 (6) & \textbf{0.4637 (1)} \\ Pima (arff) & \textbf{0.9153 (1)} & 0.8619 (3) & 0.4545 (9) & 0.3637 (10) & 0.7767 (6) & \textbf{0.9145 (2)} & 0.7631 (7) & 0.811 (5) & 0.8215 (4) & 0.7031 (8) \\ Shuttle (arff) & 0.0182 (10) & 0.1977 (5) & \textbf{0.3171 (1)} & 0.2781 (2) & 0.2733 (3) & 0.0457 (8) & 0.1352 (6) & 0.028 (9) & 0.1249 (7) & 0.2389 (4) \\ SpamBase (arff) & 0.8013 (8) & 0.925 (6) & 0.4128 (10) & 0.9783 (3) & \textbf{0.9917 (1)} & 0.9417 (4) & 0.4914 (9) & 0.9254 (5) & 0.8367 (7) & 0.9817 (2) \\ Stamps (arff) & 0.2626 (5) & 0.3583 (3) & 0.1195 (8) & 0.0804 (10) & 0.1297 (7) & 0.3597 (2) & 0.1316 (6) & \textbf{0.3945 (1)} & 0.3042 (4) & 0.0854 (9) \\ Waveform (arff) & 0.0656 (7) & 0.1293 (3) & \textbf{0.1925 (1)} & 0.0547 (9) & 0.0559 (8) & 0.1343 (2) & 0.0521 (10) & 0.108 (4) & 0.0702 (6) & 0.0785 (5) \\ WBC (arff) & 0.5422 (9) & 0.5561 (8) & 0.7534 (3) & 0.6935 (6) & \textbf{0.863 (1)} & 0.5806 (7) & 0.7242 (4) & 0.3303 (10) & 0.7018 (5) & 0.8381 (2) \\ WDBC (arff) & 0.43 (9) & 0.6669 (6) & 0.2973 (10) & 0.7952 (2) & 0.7178 (4) & 0.6535 (7) & 0.7935 (3) & 0.7038 (5) & 0.6123 (8) & \textbf{0.8407 (1)} \\ WPBC (arff) & 0.2095 (10) & 0.2244 (7) & \textbf{0.2412 (2)} & 0.2303 (5) & 0.2313 (4) & 0.2328 (3) & 0.2231 (8) & 0.2248 (6) & 0.2226 (9) & \textbf{0.2438 (1)} \\ \midrule AVG & 0.3512 (10) & 0.4623 (5) & 0.3715 (9) & 0.5093 (3) & 0.5376 (2) & 0.4466 (6) & 0.4365 (7) & 0.3782 (8) & 0.4904 (4) & \textbf{0.5649 (1)}\\ \bottomrule \end{tabular}} \label{table:od comparison map} \end{table*} \subsection{Scaling to High Dimensions} COPOD is an efficient algorithm that scales well in high dimensional settings. Unlike proximity based models that require pairwise distance calculation \cite{Zhao2018,zhao2020suod}, or learning based models that require training, COPOD incurs low computational overhead. We carry out an experiment using random datasets of dimensions 10, 100, 1,000, and 10,000. The number of observations are 1,000, 10,000, 100,000, and 1,000,000. All datasets are randomly generated and used strictly for evaluating COPOD's computation time as shown in Table \ref{table:copod speed}. \begin{table}[H] \caption{COPOD's Performance in Seconds Under Different Dimension and Data Size. It scales well regarding dimensions.} \vspace{-0.1in} \centering \scalebox{0.9}{ \begin{tabular}{l|llll} \toprule & d=10 & d=100 & d=1,000 & d=10,000 \\ \midrule n=1,000 & 0.0687 & 0.1731 & 1.1632 & 11.4605 \\ n=10,000 & 0.1718 & 0.4686 & 5.2441 & 55.1901 \\ n=100,000 & 0.6405 & 7.1858 & 70.5410 & 567.1058 \\ n=1,000,000 & 11.4036 & 130.9741 & 694.4056 & 5376.5937\\ \bottomrule \end{tabular}} \label{table:copod speed} \end{table} Table \ref{table:copod speed} outlines COPOD's performance and its scalability across both number of dimensions and number of data points. Even on a moderately equipped personal computer, COPOD can easily handle datasets with 10,000 dimensions and 1,000,000 data points in just under an hour and half. In addition, COPOD requires no re-training fit new data points, and thus is desirable for real time prediction applications. \section{Conclusion} \label{sec:conclusion} In this paper, we present COPOD, a novel outlier detection algorithm based on estimating tail probabilities using empirical copula. To the best of our knowledge, this is the first time that copula models have been used in explainable outlier detection tasks. Our key contributions are 1) propose a novel, parameter-free, copula-based outlier detection algorithm, 2) perform comparative studies on 30 datasets to show that COPOD outperforms in most cases and is also one of the fastest algorithms, and 3) release an easy-to-use Python implementation for accessibility and reproducibility. Through extensive experiments with real world data, we show that COPOD's performance is comparable or better to leading outlier detection algorithms, regarding both detection accuracy and computational cost. \bibliographystyle{./bibliography/IEEEtran}
{'timestamp': '2020-09-22T02:18:14', 'yymm': '2009', 'arxiv_id': '2009.09463', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09463'}
arxiv
\section{Additive Attention}\label{app:add} First proposed by \cite{align}, additive attention uses a one-hidden layer feed-forward network to calculate the attention alignment. We use the attention function in \citet{zhouhan}, which is also a self-attention, as an example. It aims at extracting the latent representation of a sentence. The single-head attention function is: \begin{align*} {\boldsymbol{a}} = \softmax(\boldsymbol{v}^{\top} \tanh(\Wmat {\bf H}^{\top})), \boldsymbol{z} = {\boldsymbol{a}} {\bf H} \label{add_single} \end{align*} where ${\bf H} \in \mathbb{R}^{n\times d} $ is the hidden state matrix of a sentence with $n$ words, every word is embedded in a $d$ dimensional vector. $\boldsymbol{v} \in \mathbb{R}^{1\times n} $ is the normalized alignment score vector for each word. $\Wmat \in \mathbb{R}^{d_{a}\times d} $ and $\bm{v}\in \mathbb{R}^{d_a\times 1} $ are attention parameters. The final sentence representation vector $\boldsymbol{z}$ is a weighted sum of words' hidden states weighted by attention vector. In order to capture overall semantics of the sentence instead of a specific component, multi-head attention could be applied as \begin{equation*} \Amat = \softmax(\Vmat^{\top} \tanh(\Wmat {\bf H}^{\top})) \label{add}, {\bf Z} = \Amat {\bf H} \end{equation*} where $\Vmat \in \mathbb{R}^{d_{a}\times M}$ is the matrix performs $M$ heads, $\Amat \in \mathbb{R}^{M\times n}$ is the $M$-head attention matrix and ${\bf Z}\in \mathbb{R}^{M\times d}$ is the resulting sentence representation matrix contains semantics from multiple aspects. \section{Additional Experimental Details} For our approach, RBF kernel $\kappa(x,y)=\text{exp}(-\frac{1}{h}\|x-y\|_2^2)$ with the bandwidth $h={med}^2 / \log M$ is used as the kernel function, where $med$ denotes the median of the pairwise distance between current particles. The prior distribution of attention parameters is assumed to be uniform. We find that adding an repulsive weight before the repulsive term (i.e. the second term in Eq. \ref{svgd2}) in particle-optimization update rules could help adjusting the degree of diversity in attention and achieving better performance. In our experiments, we adopt this trick and use the hyper-parameter $\alpha$ to denote the repulsive weight. Since our method only modifies the learning process of attention, all models and settings in our experiments kept the same with the corresponding previous work unless stated otherwise. \subsection{Self-attentive Sentence Classification} \paragraph{Dataset} Three tasks are conducted on three public sentence classification datasets. \textit{Author profiling} (Age dataset \footnote{https://pan.webis.de/clef16/pan16-web/author-profiling.html}) is to predict the age range of the user by giving their tweets. \textit{Sentiment analysis} (Yelp dataset \footnote{https://www.yelp.com/dataset/download}) is to predict the number of stars the user assigned to by analysis their reviews. \textit{Textual entailment} (SNLI dataset \footnote{https://nlp.stanford.edu/projects/snli/}) is to tell whether the semantics in the two sentences are entailment or contradiction or neutral. Following \citet{zhouhan}, the train / validate / test split of Age is 68485 / 4000 / 4000, Yelp is 500K / 2000 / 2000, SNLI is 550K / 10K / 10K. \paragraph{Experimental settings} We implement the standard multi-head attention model in \citet{zhouhan} following the settings in it except that we use Spacy toolkit \footnote{https://spacy.io/} as the tokenizer and GloVe \footnote{https://nlp.stanford.edu/projects/glove/} (GloVe 840B 300D) as the pre-trained word embedding. For repulsive multi-head attention learning, we keep all settings the same with the standard one \cite{zhouhan}. Hyper-parameters $\epsilon$ and $\alpha$ in SVGD are selected with grid search. For SPOS, we fix these two hyper-parameters and only tune $\beta$. The selection is based on the performance on the validation data. We train and evaluate all the models with 10 random seeds and compare their average performance. Models are trained on one TITAN Xp GPU. \subsection{Transformer-based Neural Translation} \paragraph{Dataset} IWSLT14 German-to-English (De-En) dataset contains 153K / 7K / 7K sentence pairs. WMT14 English-to-German (En-De) dataset contains about 4.5 million training sentence pairs and uses newstest2013 dataset as the validation set, newstest2014 dataset as the test set. Data and the processing scripts could be found here \footnote{https://github.com/pytorch/fairseq/tree/v0.6.0/examples/translation}. \paragraph{Experimental settings} Our implementation is based on the open-sourced \texttt{fairseq} \footnote{https://github.com/pytorch/fairseq} \cite{fairseq}. We follow the settings in \citet{attention} and have reproduced their reported results. For the WMT14 dataset, the \texttt{base} Transformer is used, which consists of a 6-layer encoder and a 6-layer decoder. The size of the hidden units and embeddings is 512 and the number of heads is 8. The \texttt{big} Transformers has 1024 hidden units and 16 heads, which is listed as a reference. For IWSLT14 dataset, the \texttt{small} setting is used and the number of heads in every layer is set to 4. All the configurations are kept the same when applying our method or the regularization method. In our method, only the training process is changed and SVGD update rule is utilized in our algorithm. The stepsize $\epsilon$ in our method is set to 0.1 and the repulsive term $\alpha$ is set to 0.01. The Transformer-\textit{small} model is trained on one TITAN Xp GPU. The Transformer-\textit{base} model is trained on four GTX 1080Ti GPUs. \paragraph{Additional Results} To support a fair comparison, we also evaluate the Transformer-base model on WMT14 En-De task. The SACREBLEU score \cite{sacrebleu} with and without our approach is 27.1 and 26.2\footnote{SacreBLEU hash: \texttt{BLEU+case.mixed+lang.en-de +numrefs.1+smooth.exp+test.wmt14/full+tok. 13a+version.1.4.12}}, respectively. \subsection{ELECTRA} \paragraph{Dataset} Following the official code of \citet{electra}, ELECTRA models are pretrained on the OpenWebTextCorpus \footnote{https://skylion007.github.io/OpenWebTextCorpus/} dataset, an open source effort to reproduce OpenAI’s WebText dataset. OpenWebTextCorpus containes 38GB of text data from 8,013,769 documents. The pretrained model is then finetuned and evaluated on GLUE benchmark \footnote{https://gluebenchmark.com/}. GLUE contains a variety of tasks covering textual entailment (RTE and MNLI) question-answer entailment (QNLI), paraphrase (MRPC), question paraphrase (QQP), textual similarity (STS), sentiment (SST), and linguistic acceptability (CoLA). Our evaluation metrics are Spearman correlation for STS, Matthews correlation for CoLA, and accuracy for the other GLUE tasks. \paragraph{Experiment settings} The ELECTRA-\textit{small} model we implemented follow all official settings \footnote{https://github.com/google-research/electra} except that it is fully-trained on one GTX 1080Ti GPU for 6 days. The ELECTRA-\textit{small} model has 12 layers with 4 heads in every layer's attention. For our method, the stepsize $\epsilon$ is set to 0.01 and the repulsive term $\alpha$ is set to 0.1. The repulsive learning of attention is only applied to the pre-training stage. The fine-tuning remains the same with the original one. \subsection{GraphWriter} \paragraph{Dataset} Experiments are conducted on the Abstract GENeration DAtaset (AGENDA) \cite{Graphwriter}, a dataset of knowledge graphs paired with scientific abstracts. It consists of 40k paper titles and abstracts from the Semantic Scholar Corpus taken from the proceedings of 12 top AI conferences. We use the standard split of AGENDA dataset in our experiments: 38,720 for training, 1000 for validation, and 1000 for testing. \paragraph{Experimental settings} We follow the official settings \footnote{https://github.com/rikdz/GraphWriter} in \citet{Graphwriter} with the encoder containing 6 layers and 4-head graph attention in every layer. We reproduce their results and keep all settings the same when applying the proposed repulsive attention. The SVGD update rule is used in our algorithm and applied to all layers. The stepsize $\epsilon$ is set to 0.1 and the repulsive weight is set to 0.01 in this experiment. The model is trained on one TITAN Xp GPU. \section{Additional Analysis of Our Approach} \subsection{Comparison with SGLD} We also conducted a comparison of our method with Stochastic gradient Langevin dynamics (SGLD) \cite{sgld}, which is also a Bayesian sampling method. Results are in Table \ref{tab:sgld}. Though random noise brought by SGLD might help achieving diversity, it's sub-optimal. Using particle-optimization to add the repulsive term makes it more effective. \begin{table}[h] \small \centering \begin{tabular}{c c c c c} \toprule \textbf{Sampling} &&&&\\ \textbf{Method} &\textbf{Age} & \textbf{Yelp} & \textbf{SNLI} & \textbf{IWSLT14 De-En} \\ \midrule None & 81.47 & 69.3 & 83.79 & 34.4\\ SGLD & 81.57 & 70.1 & 83.80 & 34.7\\ SVGD & \bf81.82 & \bf71.2 & \bf84.58 & \bf35.2\\ \bottomrule \end{tabular} \caption{Performance of attention models with different sampling methods on four tasks. For Age, Yelp and SNLI sentence classification tasks, the evaluation metric is accuracy (\%). For IWSLT14 De-En translation task, the evaluation metric is BLEU score. "None" here means the standard multi-head attention models.} \label{tab:sgld} \end{table} \subsection{What Prior to Use?} In our approach, the repulsiveness is imposed by the inference algorithm (\textit{i.e.} SVGD), not prior. To study the impact of different priors, we also tested the Gaussian prior. We found that (see Table \ref{tab:gaussian}) different priors have little impact on the final results, \textit{i.e.}, there is not a consistent winner for different priors. This suggests that, the prior has little impact on repulsiveness in our framework. But one can still impose prior knowledge of the attention to help our algorithm learn a better attention model. We would like to explore that in future works. \begin{table}[h] \small \centering \begin{tabular}{cccc} \toprule \textbf{Prior} & \textbf{Age} & \textbf{Yelp} & \textbf{SNLI}\\ \midrule Uniform & 81.82 & 71.7 & 84.58 \\ Gaussian & 81.88 & 71.6 & 84.28 \\ \bottomrule \end{tabular} \caption{Performance of our approach with different priors on three sentence classification tasks.The evaluation metric is accuracy (\%)} \label{tab:gaussian} \end{table} \subsection{Which attention modules to be diversified?}\label{app:Transformer-abl} \begin{table}[h] \small \centering \begin{tabular}{l c c} \toprule \textbf{Models} & \textbf{BLEU} & \textbf{Time}\\ \midrule MA & 34.4 & 1 \\ \midrule RMA (Q) & 34.7 & 1.06 \\ RMA (K) & 34.7 & \\ RMA (V) & 34.9 & \\ \midrule RMA (En) & 34.6 & 1.06 \\ RMA (De) & 34.7 & \\ RMA (En-De) & 34.9 & \\ \midrule RMA (first layer) & \textbf{35.1} & 1.03 \\ RMA (last layer) & 34.7 & \\ \midrule RMA (All) & \textbf{35.2} & 1.13\\ \bottomrule \end{tabular} \caption{Ablation study of Transformer-\texttt{small}-RMA model on IWSLT14 De-En dataset with repulsive multi-head attention applied on different part of the model. En: self-attention in encoder. De: self-attention in decoder. En-De: inter-attention between encoder and decoder. Time: relative training time of every step versus MA.} \label{tab:Transformer-abl} \end{table} There are three types of attention in Transformer: self-attention in the encoder, self-attention in the decoder, and inter-attention between the encoder and decoder. We conduct extra experiments on Transformer-\texttt{small} to investigate which attention module benefits most from the repulsiveness. Results are shown in Table \ref{tab:Transformer-abl}. We first apply the repulsive attention on each of \{Q,K,V\} parameters in every attention module for all layers. The results indicate that diversifying the $V$-parameter seems to yield better performance. We then compare repulsive attention inside the encoder, inside the decoder and between them, respectively. The results show improvement in all cases, and diversifying inter-attention seems to achieve the most benefit. Finally, we diversify the attention in different layers of the Transformer. The results suggest that only diversifying the attention in the first layer is able to achieve comparable performance to the case of diversifying all layers, with little computational time increased. \subsection{Improved Calibration} \begin{figure*} \centering \subfloat[]{{\includegraphics[width=0.3\textwidth]{snli_orig_spos_conf.png}}} \subfloat[]{{\includegraphics[width=0.3\textwidth]{snli_orig_spos_conf_error.png}}} \\ \caption{(a) Scatterplots for accuracy and confidence for SNLI test set. The repulsive case (RMA) is much better calibrated with the points lying closer to the $y = x$ line, while in the standard case (MA), points tend to lie in the overconfident region. (b) Expected Calibration Error (ECE) and Overconfidence Error (OE) for two cases.} \label{fig:calibration} \end{figure*} A reliable model must not only be accurate, but also indicate when it is likely to get the wrong answer. It means the confidence of a well calibrated model should be indicative of the actual likelihood of correctness. Following the calibration metrics in~\citet{calibration} and \citet{uncertainty}, we evaluate the calibration of the model in Figure \ref{fig:calibration}. For classifiers, the predicted softmax scores of winning class are represented as the confidence of models. Expected Calibration Error (ECE) and Overconfidence Error (OE) are two calibration metrics evaluating the reliability of a model. Following \citet{calibration} and \citet{uncertainty}, softmax predictions are grouped into $M$ interval bins of equal size. Let $B_m$ be the set of samples whose prediction scores (the winning softmax score) fall into bin $B_m$. The accuracy and confidence of $B_m$ are defined as \begin{align*} \text{acc}(B_m) &= \frac{1}{|B_m|} \sum_{i\in B_m}\textbf{1}(\hat{y}_i=y_i)\\ \text{conf}(B_m) &= \frac{1}{|B_m|} \sum_{i\in B_m}\hat{p}_i \end{align*} where $\hat{p}_i$ is the confidence (winning score) of sample $i$. The Expected Calibration Error (ECE) is then defined as: \begin{equation*} \text{ECE} = \sum_{m=1}^M \frac{|B_m|}{n}|\text{acc}(B_m) - \text{conf}(B_m)| \end{equation*} In high-risk applications, confident but wrong predictions can be especially harmful. Overconfidence Error (OE) is defined as follow for this case. \begin{align*} \text{OE} = &\sum_{m=1}^M \frac{|B_m|}{n}[\text{conf}(B_m) \times \\ &\text{max}(\text{conf}(B_m) - \text{acc}(B_m), 0)] \end{align*} As shown in Figure \ref{fig:calibration}, the standard attention model is prone to be over-confident, meaning that the accuracy is likely to be lower than what is indicated by the predictive score. With the proposed repulsive training of attention, the model becomes better calibrated with much lower calibration error and overconfidence error, indicating that our method is beneficial for training more reliable multi-head attention models. \subsection{Improved Uncertainty Prediction} \begin{figure} \centering \includegraphics[width=0.5\textwidth]{uncertainty_entropy_yelp_model_age_data.png} \caption{Empirical CDF for the entropy of the predictive distributions on Age dataset from the model trained on Yelp dataset. Curves that are closer to the bottom right part of the plot are preferable, as it denotes that the probability of observing a high confidence prediction is low.} \label{fig:uncertainty_entropy} \end{figure} We follow \citet{uncertainty_entropy} to evaluate the predictive uncertainty. We estimate the entropy of the predictive distributions on Age dataset (out-of-distribution entropy) from the models trained on Yelp dataset. Since we a-priori know that none of the Age classes correspond to a trained class (they are two different tasks), the ideal predictive distribution is uniform over the Age dataset, i.e. a maximum entropy distribution. We plot the empirical CDF for the entropy in Figure \ref{fig:uncertainty_entropy}. It shows that the uncertainty estimates from the repulsive multi-head attention model is better than the standard attention and the regularization approach. \subsection{Discussion with Existing Regularization-based Methods}\label{app:regu} \begin{table}[] \small \centering \begin{tabular}{r|cc} \toprule \multirow{2}{*}{\bf Methods} & \multicolumn{2}{c}{\bf Acc(\%)}\\ \cline{2-3} & Age & Yelp \\ \midrule cosine similarity regularization & 81.35 & 68.50\\ $i ->j$ & 81.65 &71.45\\ $i ->j$, +smooth & 81.85 & 71.50\\ \bottomrule \end{tabular} \caption{Adapt cosine similarity regularization on attention parameters gradually to our framework. Accuracy of the model is evaluated on the test set of Age and Yelp dataset.} \label{tab:R_RMA} \end{table} Learning diverse attentions has been proposed in~\citet{zhouhan} and \citet{disagree}, with different regularization techniques to enforce repulsiveness. In fact, we can show that existing methods are simplified versions of our framework, but with a potential mismatch between their algorithm and the underlying repulsiveness guarantee. To explain this, we follow \citet{disagree} and apply cosine similarity regularizer to the attention parameter $\boldsymbol{\theta}$. When negative log-likelihood is used as the loss function and the prior of $\boldsymbol{\theta}^{(i)}$ is assumed to be uniform, the update function $\phi$ becomes: \fontsize{10}{11} \begin{align} \phi(\boldsymbol{\theta}_{\ell}^{(i)}) = -\nabla_{\boldsymbol{\theta}_{\ell}^{(i)}}U(\boldsymbol{\theta}_{\ell}^{(i)}) + \nabla_{\boldsymbol{\theta}_{\ell}^{(i)}}\frac{1}{M}\sum_{j=1}^M \frac{\boldsymbol{\theta}_{\ell}^{(i)}\boldsymbol{\theta}_{\ell}^{(j)}}{\Vert \boldsymbol{\theta}_{\ell}^{(i)} \Vert \Vert\boldsymbol{\theta}_{\ell}^{(j)}\Vert} \notag \end{align} One can consider the cosine similarity as a kernel function. Applying this new kernel function to our framework results in the following update: \fontsize{10}{11} \begin{align*}\label{eq:reg} \phi(\boldsymbol{\theta}_{\ell}^{(i)}) &= \frac{1}{M} \sum_{j=1}^M-\frac{\boldsymbol{\theta}_{\ell}^{(i)}\boldsymbol{\theta}_{\ell}^{(j)}}{\Vert \boldsymbol{\theta}_{\ell}^{(i)} \Vert \Vert\boldsymbol{\theta}_{\ell}^{(j)}\Vert} \nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}U(\boldsymbol{\theta}_{\ell}^{(j)}) \\ &+ \frac{1}{M} \sum_{j=1}^M\nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}\frac{\boldsymbol{\theta}_{\ell}^{(i)}\boldsymbol{\theta}_{\ell}^{(j)}}{\Vert \boldsymbol{\theta}_{\ell}^{(i)} \Vert \Vert\boldsymbol{\theta}_{\ell}^{(j)}\Vert} \end{align*} It is clear that our method \eqref{eq:reg} reduces to the regularizing method when 1) removing the smoothing term $\frac{\boldsymbol{\theta}_{\ell}^{(i)}\boldsymbol{\theta}_{\ell}^{(j)}}{\Vert \boldsymbol{\theta}_{\ell}^{(i)} \Vert \Vert\boldsymbol{\theta}_{\ell}^{(j)}\Vert}$ for $j\neq i$; and 2) replacing the derivative $\nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}$ with $\nabla_{\boldsymbol{\theta}_{\ell}^{(i)}}$ in the repulsive term. For this reason, we argue that the regularization method lacks of a formal guarantee on the repulsiveness. To show this, we adapt the cosine similarity regularization on attention parameters gradually to our framework by 1) replacing the derivative $\nabla_{\boldsymbol{\theta}_{\ell}^{(i)}}$ with $\nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}$ in the repulsive term; 2) adding the smoothing term $\kappa(\boldsymbol{\theta}_{\ell}^{(j)}, \boldsymbol{\theta}_{\ell}^{(i)})$. Table \ref{tab:R_RMA} shows that both the smoothing and the corrected gradient lead to performance improvement over the standard regularization methods. \newpage \onecolumn \section{Visualization of Multi-head Attention in Sentence Classification Task} \label{app:vis} \begin{figure}[h] \centering \subfloat[detailed attentions of 30 heads]{\includegraphics[width=0.88\textwidth]{orig_short_30head.png}} \\ \subfloat[overall attention]{\includegraphics[width=0.88\textwidth]{orig_short_all_v2.png}} \caption{Attention heatmaps for the standard multi-head attention model} \label{fig:my_label} \end{figure} \begin{figure} \centering \subfloat[detailed attentions of 30 heads]{\includegraphics[width=0.88\textwidth]{F_short_30head.png}} \\ \subfloat[overall attention]{\includegraphics[width=0.88\textwidth]{F_short_all_v2.png}} \caption{Attention heatmaps for the standard multi-head attention model trained with Frobenius regularization} \label{fig:my_label} \end{figure} \begin{figure} \centering \subfloat[detailed attentions of 30 heads]{\includegraphics[width=0.88\textwidth]{spos_short_30head.png}} \\ \subfloat[overall attention]{\includegraphics[width=0.88\textwidth]{spos_short_all_v2.png}} \caption{Attention heatmaps for the repulsive multi-head attention model} \label{fig:my_label} \end{figure} \newpage \onecolumn \section{A Generation Sample of Graph-to-Text Task} \label{app:GW} \vspace{2cm} \begin{figure*}[h] \centering \includegraphics[width =\textwidth]{GW_2.pdf} \caption{Example outputs of various systems versus Gold} \label{tab:GW_gen_example_1} \end{figure*} \section{Introduction} Multi-head attention~\cite{attention} is an effective module in deep neural networks, with impressive performance gains in many natural-language-processing (NLP) tasks. By extending a single head to multiple paralleled attention heads, the architecture is widely adopted to capture different attentive information and strengthen the expressive power of a model. \citet{zhouhan} applied the idea of multi-heads on self-attention and extract a 2-D matrix instead of a vector to represent different contexts of a sentence. The Transformer \cite{attention} and its variants such as BERT \cite{bert} are influential architectures solely based on multi-head attention, achieving state-of-the-art performance on plenty of NLP tasks. The key of multi-head attention is its ability to jointly attend to information from different representation subspaces at different positions, which results in multiple latent features depicting the input data from different perspectives. However, there are no explicit mechanisms guaranteeing this desired property, leading to potential attention redundancy or attention collapse, which has been observed in previous research \cite{prune,kovaleva2019revealing}. Although there exist works by directly adding regularization on loss functions to encourage diversity in multi-head attention \cite{zhouhan, disagree}, the underlying working principle has not been well-validated, and performance improvement is limited. Furthermore, an important problem on why and how multi-head attention improves over its single-head counterpart is poorly understood. In this paper, we provide a novel understanding of multi-head attention from a Bayesian perspective by adapting the deterministic attention to a stochastic setting. The standard multi-head attention can be understood as a special case of our framework, where attention-parameter updates between heads are independent, instead of sharing a common prior distribution. Based on our framework, attention repulsiveness could then be imposed by performing Bayesian inference on attention parameters with the recently developed particle-optimization sampling methods \cite{svgd}, which has been shown to be effective in avoiding mode collapse. These methods treat each head as a particle/sample, which is then optimized to approximate a posterior distribution of an attention model. With it, multiple heads are enforced to move to modes in the parameter space to be far from each other, thus improving the repulsiveness in multi-head attention and enhancing model's expressiveness. Our Bayesian interpretation also provides a theoretical understanding of the reason and benefits of applying multi-head attention. Experiments on various attention models demonstrate the effectiveness of our framework. Our contributions are summarized as follow: \begin{itemize} \item We provide a new understanding of multi-head attention from a Bayesian perspective, yielding a more principled and flexible interpretation of multi-head attention. \item Based on the recently developed particle-optimization sampling techniques, we propose an algorithm to explicitly encourage repulsiveness in multi-head attention without introducing extra trainable parameters or explicit regularizers. The proposed method can be implemented with an efficient end-to-end training scheme. \item Our Bayesian interpretation provides a theoretical foundation to understand the benefits of multi-head attention, which reveals the existence of an optimal number of attention heads in a specific model. \item We apply our approach on four attention models with a wide range of tasks. Experimental results show that repulsive attention improves the expressiveness of models, and yields consistent performance gains on all the tasks considered. \end{itemize} \section{Preliminaries} \subsection{Multi-head Attention} The attention mechanism aims at modeling dependencies among elements of a learned representation at different positions. The two commonly used attention functions are additive attention \cite{zhouhan, align} and dot-product attention \cite{attention}. We review the popularly used dot-product attention below and defer the additive attention to Appendix \ref{app:add}. \paragraph{Dot-product Attention} The multi-head scaled dot-product attention is used in the Transformer model \cite{attention}. The attention function for a single head is formulated as mapping a query and a set of key-value pairs to output as \begin{align} \Amat_i =& \softmax({\bf Q}_i {\bf K}_i^T/\sqrt{d_k}), {\bf Z}_i = \Amat_i \Vmat_i \label{dot_single}\\ \text{where } & {\bf Q}_i = {\bf Q} \Wmat_i^Q, {\bf K}_i = {\bf K} \Wmat_i^K, \Vmat_i = \Vmat\Wmat_i^V \notag \end{align} ${\bf Q}, {\bf K}, \Vmat$ are matrices depicting the hidden representation of every word in one sentence ({\it i.e.} self-attention) or two sentences ({\it i.e.} inter-attention); $d_k$ is the dimension of key and query; ${\bf Z}_i$ is the attention feature of the input sentence from the $i$-th head; $\{\Wmat_i^Q, \Wmat_i^K,\Wmat_i^V\}$ are the corresponding learnable attention parameters. The $M$-head attention projects the queries, keys and values into $M$ subspaces with different learnable linear projections. These attention functions are performed in parallel and are concatenated at last, resulting in a final latent representation: \begin{align}\label{mul} &\multihead({\bf Q}, {\bf K}, \Vmat) = {\bf Z} \Wmat^O, \text{ with} \\ &{\bf Z} = \concat({\bf Z}_1, \cdots, {\bf Z}_M) \notag \end{align} \subsection{Particle-optimization Sampling} Particle-optimization sampling is a recently developed Bayesian sampling technique that interactively transports a set of particles/samples to a target distribution $p$ by minimizing the KL divergence between the particle density and the target $p$. In our case, $p$ would be a posterior distribution, $p(\boldsymbol{\theta} | \mathcal{D}) \propto \exp(-U(\boldsymbol{\theta}))$, of the parameter $\boldsymbol{\theta} \in \mathbb{R}^d$, defined over an observed dataset $\mathcal{D} = \{D_k\}_{k=1}^N$. Here $U(\boldsymbol{\theta})\triangleq -\log p(\mathcal{D} | \boldsymbol{\theta}) - \log p_0(\boldsymbol{\theta}) = - \sum_{k=1}^N\log p(D_k | \boldsymbol{\theta})-\log p_0(\boldsymbol{\theta})$ is called the potential energy with $p_0$ a prior over $\boldsymbol{\theta}$. In our case, the model parameter $\boldsymbol{\theta}$ could be one or several of the attention parameters such as $\Wmat_i^Q$. For simplicity, we will stick to $\boldsymbol{\theta}$ in the presentation. In particle-optimization sampling, a total of $M$ particles $\{\boldsymbol{\theta}^{(i)}\}_{i=1}^M$ are updated iteratively to approximate $p(\boldsymbol{\theta} | \mathcal{D})$. In this paper, we use two representative algorithms, the Stein Variational Gradient Descent (SVGD) and the Stochastic Particle-Optimization Sampling (SPOS), for sampling. \paragraph{SVGD} In SVGD \cite{svgd}, the $i$-th particle in the $(\ell+1)$-th iteration is updated with stepsize $\epsilon_{\ell+1}$ as \begin{align} &\boldsymbol{\theta}_{\ell + 1}^{(i)} = \boldsymbol{\theta}_{\ell}^{(i)} + \epsilon_{\ell+1} \phi(\boldsymbol{\theta}_{\ell}^{(i)})\label{svgd1}\\ \phi(\boldsymbol{\theta}_{\ell}^{(i)}) = &\frac{1}{M} \sum_{j=1}^M[-\kappa(\boldsymbol{\theta}_{\ell}^{(j)}, \boldsymbol{\theta}_{\ell}^{(i)})\nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}U(\boldsymbol{\theta}_{\ell}^{(j)}) \notag \\ &+ \nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}\kappa(\boldsymbol{\theta}_{\ell}^{(j)}, \boldsymbol{\theta}_{\ell}^{(i)})]\label{svgd2} \end{align} where $\kappa(\cdot, \cdot)$ is a positive definite kernel ({\it e.g.}, RBF kernel). The two terms in $\phi$ play different roles: the first term drives the particles towards high density regions of $p(\boldsymbol{\theta} | \mathcal{D})$; whereas the second term acts as a repulsive force that prevents all the particles from collapsing together into local modes of $p(\boldsymbol{\theta} | \mathcal{D})$. \paragraph{SPOS} Though obtaining significant empirical success, under certain conditions, SVGD experiences a theoretical pitfall, where particles tend to collapse. To overcome this, \citet{zhang2018stochastic} generalize SVGD to a stochastic setting by injecting random noise into particle updates. The update rule for particles $\boldsymbol{\theta}_{\ell}^{(i)}$ is {\fontsize{9}{10}\begin{align}\label{spos1} &\phi(\boldsymbol{\theta}_{\ell}^{(i)}) = \frac{1}{M} \sum_{j=1}^M[-\kappa(\boldsymbol{\theta}_{\ell}^{(j)}, \boldsymbol{\theta}_{\ell}^{(i)})\nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}U(\boldsymbol{\theta}_{\ell}^{(j)}) + \\ & \nabla_{\boldsymbol{\theta}_{\ell}^{(j)}}\kappa(\boldsymbol{\theta}_{\ell}^{(j)}, \boldsymbol{\theta}_{\ell}^{(i)})] -\beta^{-1}\nabla_{\boldsymbol{\theta}_{\ell}^{(i)}}U(\boldsymbol{\theta}_{\ell}^{(i)})+\sqrt{2\beta^{-1}\epsilon_{\ell}^{-1}} \xiv_{\ell}^{(i)} \notag \end{align}} where $\beta > 0$ is a hyperparameter, $\xiv_{\ell}^{(i)} \sim \mathcal{N}(\bm{0}, \bm{I})$ is the injected random Gaussian noise to enhance the ability of escaping local modes, leading to better ergodic properties compared to standard SVGD. \section{A Bayesian Inference Perspective of Multi-head Attention} \label{app:attention} In this section, we interpret multi-head attention as Bayesian inference of latent representation via particle-optimization sampling. We denote $\bm{x}$ and $\bm{z}$ as the input and output (latent representation) of the attention model, respectively. The single-head attention can be written as a deterministic mapping $\bm{z} = f_{att}(\bm{x}; \boldsymbol{\theta})$, with $\boldsymbol{\theta}$ the parameter of the mapping. Standard multi-head attention defines multiple parallel attention mappings, each endowed with independent parameters. The attention features are finally aggregated via a function $g(\cdot)$ as \begin{align} \bm{z} = g(\bm{z}_1,...,\bm{z}_M), \quad \bm{z}_i =f_{att}(\bm{x}; \boldsymbol{\theta}_i)~. \label{det} \end{align} Next, we generalize \eqref{det} as a Bayesian inference problem for the latent representation $\bm{z}$. \paragraph{Attention as Bayesian Inference} We first generalize the deterministic transformation, $\bm{z} = f_{att}(\bm{x}; \boldsymbol{\theta})$, to a stochastic generative process as: \begin{align*} \boldsymbol{\theta} \sim p(\boldsymbol{\theta}|\mathcal{D}),~~\bm{z} = f_{att}(\bm{x}; \boldsymbol{\theta})~, \end{align*} where a sample of the posterior of the global attention parameter $\boldsymbol{\theta}$, $p(\boldsymbol{\theta}|\mathcal{D}) \propto p(\mathcal{D} | \boldsymbol{\theta})p(\boldsymbol{\theta})$, is used as the parameter when generating the latent attention feature $\bm{z}$. Bayesian inference for attention then computes the predictive distribution $p(\bm{z} | \bm{x}, \mathcal{D})$ of the attentive latent representation $\bm{z}$ for a new input $\bm{x}$ given the training data $\mathcal{D}$ by $p(\bm{z} | \bm{x}, \mathcal{D}) = \int \delta_{f_{att}(\bm{x}; \boldsymbol{\theta})}(\bm{z}) p(\boldsymbol{\theta} | \mathcal{D})d\boldsymbol{\theta}~ \label{stoc}$, where $\delta_{\bm{z}}(\cdot)$ is the delta function with point mass at $\bm{z}$. To enable efficient evaluation of the integral, we adopt Bayesian sampling for approximation, {\it i.e.}, $p(\bm{z} | \bm{x}, \mathcal{D})$ is approximated by a set of $M$ samples/particles initialized from $p(\boldsymbol{\theta}|\mathcal{D})$, leading to the following generative process: \begin{align} &\bm{z} = g(\bm{z}_1,...,\bm{z}_M) \label{re_mul}\\ \bm{z}_i =f_{att}(&\bm{x}; \boldsymbol{\theta}_i), \quad \text{with} \quad \boldsymbol{\theta}_i\sim p(\boldsymbol{\theta} | \mathcal{D}) \notag \end{align} The above formulation defines a principled version of multi-head attention from a Bayesian view. One can see that \eqref{re_mul} reduces to the standard multi-head attention if all $\boldsymbol{\theta}_i$ are treated independently without sharing the common parameter distribution $p(\boldsymbol{\theta}|\mathcal{D})$. In other words, our reformulation of multi-head attention is a stochastic generative process, thus is more general. Furthermore, efficient end-to-end learning can be performed by conducting repulsive Bayesian sampling for all parameters $\{\boldsymbol{\theta}_i\}_{i=1}^M$, which consequently could diversify the attention features $\{\bm{z}_i\}_{i=1}^M$. \section{Repulsive Attention Optimization} The Bayesian multi-head attention in \eqref{re_mul} further inspires us to develop the repulsive attention. The idea is to learn to generate repulsive samples from the posterior $p(\boldsymbol{\theta}|\mathcal{D})$. We propose to adopt the particle-optimization sampling methods, which could explicitly encourage repulsiveness between samples. In our algorithm, the parameter of $p(\bm{z} | \bm{x}; \boldsymbol{\theta})$ for each head is considered as one particle. Following the particle-optimization rules, $M$ heads $\{\boldsymbol{\theta}_i\}_{i=1}^M$ are updated iteratively to approximate the posterior distribution of attention parameter $p(\boldsymbol{\theta} | \mathcal{D})$. \subsection{Learning Repulsive Multi-head Attention} We propose to learning repulsive attention by replacing the standard updates of attention parameters via stochastic gradient descent (SGD) with particle-optimization sampling methods while keeping the multi-head attention model unchanged. This procedure forms an efficient end-to-end training scheme similar to standard attention learning. To be specific, in standard multi-head attention, the parameter of every head is updated independently according to the respective gradient of a loss function. To achieve repulsive multi-head attention, we follow the particle-optimization sampling update rule ({\it e.g.} \eqref{svgd1} and \eqref{svgd2}) to update the parameter of every head while keeping the update for the remaining parameters via SGD unchanged. Equations \eqref{svgd2} and \eqref{spos1} can be viewed as modified gradients with explicit repulsive force and can be integrated into any optimizer, {\it e.g.}, Adam \cite{adam}. Note that $\nabla_{\boldsymbol{\theta}_{\ell}^{(i)}}U(\boldsymbol{\theta}_{\ell}^{(i)})$ equals to the gradient of $\boldsymbol{\theta}_{\ell}^{(i)}$ in standard multi-head attention when the negative log-likelihood is used as the loss function and the prior of $\boldsymbol{\theta}^{(i)}$ is assumed to be uniform. The learning algorithm is illustrated in Algorithm \ref{alg:1}. In practice, the update of $M$ heads can be performed in parallel with efficient matrix operations. \begin{algorithm} \caption{Repulsive Multi-head Attention} \label{alg:1} {\bf Input:} Initialized $M$-head attention model $\mathcal{A}$ with attention parameters $\bm{\Theta}_0 = \{\boldsymbol{\theta}_i\}_{i=1}^M$ and all the other parameters $\bm{\Omega}_0$; Training data $\mathcal{D} = \{D_k\}_{k=1}^N = \{(\boldsymbol{x}_k, y_k)\}_{k=1}^N$; {\bf Output:} Optimized attention model with learned parameters $\hat{\bm{\Theta}}$ and $\hat{\bm{\Omega}}$; {\bf Train:} \begin{algorithmic}[l] \FOR{iteration $\ell$} \STATE {\bf forward}: $\hat{y}_k = \mathcal{A}(\boldsymbol{x}_k; \bm{\Theta}_{\ell},\bm{\Omega}_{\ell}), \forall k$; \STATE calculate loss: $\mathcal{L}(\{\hat{y}_k\}, \{y_k\})$; \STATE {\bf backward} and calculate gradients: \STATE gradient of $\bm{\Omega}_{\ell}$: $\varphi(\bm{\Omega}_{\ell}) \gets \nabla_{\bm{\Omega}_{\ell}} \mathcal{L}$ \FOR{attention head $i$} \STATE calculate $\phi(\boldsymbol{\theta}_{\ell}^{(i)})$ with Eq (\ref{svgd2}) or (\ref{spos1}); \STATE gradient of $\boldsymbol{\theta}_{\ell}^{(i)}$:$\varphi(\boldsymbol{\theta}_{\ell}^{(i)})\gets \epsilon_{\ell} \phi(\boldsymbol{\theta}_{\ell}^{(i)})$; \ENDFOR \STATE update parameters: \STATE $\bm{\Omega}_{\ell+1} \gets \text{Optimizer}(\bm{\Omega}_{\ell}, \varphi(\bm{\Omega}_{\ell}))$ \STATE $\bm{\Theta}_{\ell+1} \gets \text{Optimizer}(\bm{\Theta}_{\ell}, \varphi(\bm{\Theta}_{\ell}))$ \ENDFOR \end{algorithmic} \end{algorithm} \subsection{In-depth Analysis}\label{sec:why} \paragraph{Why Multi-head Attention?} Our Bayesian interpretation of the attention mechanism naturally provides an answer to the question of why one needs multi-head attention. By treating each head as one sample, adopting multiple heads means using more samples to approximate an underlying posterior distribution. The question comes to should one use more heads (samples). Intuitively this seems to be true because more samples typically make more accurate approximations. However, this could not be the case in practice. The reason might be two-fold: $\RN{1})$ {\em{Overfitting}}: Learning with a limited amount of data could easily causes overfitting, thus requiring a smaller model (less attention heads); $\RN{2})$ {\em{Numerical error}}: Our proposed method to update samples (attention-head parameters) is essentially a discrete numerical method of the corresponding continuous-time partial differential equation, {\it i.e.}, the samples are not exact samples from the target distribution. Thanks to the recently developed theory for particle-optimization sampling \cite{zhang2018stochastic}, one can conclude that more heads could accumulate more numerical errors, leading to performance deterioration. More formally, when using particles to approximate a target posterior distribution, there exists a gap (approximation error) between the particle distribution and the true distribution \cite{zhang2018stochastic}. This approximation error, when applied to our setting, approximately scales in the order of $O(\frac{1}{\sqrt{M}} + M\epsilon_0^{1/2} + e^{-\sum_{\ell}\epsilon_{\ell}})$. Please refer to Theorem 10 in \cite{zhang2018stochastic} for a formal description. \paragraph{How Many Heads are Enough?} The above error bound suggests that there is a trade-off between approximation accuracy and the number of heads $M$. Specifically, we have $\RN{1})$ when $M$ is small, the term $\frac{1}{\sqrt{M}}$ in the bound would dominate, leading to decreasing errors (increasing performance) with increasing $M$; $\RN{2})$ when $M$ is large enough, the term $M\epsilon_0^{1/2}$ dominates, suggesting that larger $M$ could actually increase the approximation error (decreased performance). These phenomena are consistent with our experimental results. We note that an exact form of the optimal $M$ is not available due to a number of unknown constants (omitted in the big-O notation). Therefore, one should seek other ways such as cross-validation to choose a good $M$ in practice. Our argument also aligns with recent research, which found that more heads do not necessarily lead to better performance \cite{sixteen}. \section{Experiments} We demonstrate the effectiveness of our method with representative multi-head attention models on a broad range of tasks including sentence classification, machine translation, language modeling and text generation. This section summarizes key results on different models. More detailed experiment settings and analysis are deferred to the appendix. To apply our approach, only the learning method of multi-head attention is adapted. \begin{figure*}[t] \centering \subfloat[detailed attentions]{{\includegraphics[width=0.46\textwidth]{orig_short_5head.png}}} \qquad \subfloat[detailed attentions]{{\includegraphics[width=0.46\textwidth]{spos_short_5head.png}}} \\ \subfloat[standard multi-head attention]{{\includegraphics[width=0.46\textwidth]{orig_short_all.png}}} \qquad \subfloat[repulsive multi-head attention]{{\includegraphics[width=0.46\textwidth]{spos_short_all.png}}} \caption{Attention heatmaps of a 4-star Yelp review. Results on the left is from the standard multi-head attention, and the result on the right is from our repulsive multi-head attention. (a) and (b) shows detailed attention maps taken by 5 out of 30 rows of the matrix embedding, while (c) and (d) shows the overall attention by summing up all 30 attention weight vectors.} \label{fig:vis} \vspace{-0.3cm} \end{figure*} \subsection{Self-attentive Sentence Classification} \label{sec:classification} \begin{table}[] \small \centering \begin{tabular}{l c c} \toprule \textbf{Models} & \textbf{Acc(\%) }& \textbf{Dist}\\ \midrule \multicolumn{3}{c}{\quad \quad Age}\\ \midrule BiLSTM + MA & 81.47 & 0.129 \\ BiLSTM + MA + R & 81.30 & 0.178 \\ BiLSTM + RMA (SVGD) & 81.82 & 0.492 \\ BiLSTM + RMA (SPOS) & \textbf{82.55} & 0.461 \\ \midrule \multicolumn{3}{c}{\quad \quad Yelp}\\ \midrule BiLSTM + MA & 69.3 & 0.246 \\ BiLSTM + MA + R & 70.2 & 0.536 \\ BiLSTM + RMA (SVGD) & 71.2 & 1.602 \\ BiLSTM + RMA (SPOS) &\textbf{ 71.7} & 1.655 \\ \midrule \multicolumn{3}{c}{\quad \quad SNLI}\\ \midrule BiLSTM + MA & 83.79 & 1.293 \\ BiLSTM + MA + R & 84.55 & 1.606 \\ BiLSTM + RMA (SVGD) & 84.58 & 1.688 \\ BiLSTM + RMA (SPOS) & \textbf{84.76} & 1.370 \\ \bottomrule \end{tabular} \caption{Performance (accuracy) comparison on Age, Yelp and SNLI dataset. Dist: the average 2-norm distance between each pair of the latent representation encoded from different heads on test set. MA: standard multi-head attention. RMA: proposed repulsive multi-head attention. R: regularization approach.} \label{tab:self-att sentence} \end{table} \paragraph{Model \& Baselines} We first apply our method to the self-attentive sentence classification model \cite{zhouhan} which combines BiLSTM with additive attention to learn the sentence embedding and then does classification on it. We compare our method with the one using the standard multi-head attention (BiLSTM + MA) and the one applying the Frobenius regularization (BiLSTM + MA + R) on it to introduce diversity as in \citet{zhouhan}. \paragraph{Tasks \& Datasets} Following \citet{zhouhan}, three sentence classification tasks including author profiling, sentiment analysis, and textual entailment are evaluated on the Age, Yelp, and SNLI datasets respectively. \paragraph{Results} As shown in Table \ref{tab:self-att sentence}, with the proposed repulsive multi-head attention, the model achieves higher accuracy on all three tasks. Especially on the sentiment analysis task which often contains multiple aspects in one sentence. Our methods also outperform the regularization method proposed in \citet{zhouhan}. With different particle-optimization rules, SPOS is able to achieve better performance due to its extra advance discussed by \citet{zhang2018stochastic}. We further evaluate the diversity of multiple heads by calculating the average distance between each pair of latent representations. Results show that our methods indeed enforce heads to be more diverse, compared with the standard multi-head attention. The less diverse of the regularization-based method also indicates the validness of our argument in Appendix~\ref{app:regu}. \paragraph{Repulsive-attention visualization} We further visualize attention maps in the learned sentence embedding space in Figure \ref{fig:vis}. It is interesting to see attention collapse indeed happens in the standard multi-head attention, where almost all heads focus on one single factor \textit{"amazing"}. On the contrary, the proposed method is able to capture multiple key factors in the review that are strong indicators of the sentiment behind the sentence. For example, \textit{"downfall"} and \textit{"service was passing"} are key factors for this 4-star review captured by our repulsive multi-head attention, which are missed by the standard attention. The full attention heatmaps of all 30 heads and more examples are in Appendix \ref{app:vis}. \subsection{Transformer-based Neural Translation}\label{sec:transformer} \paragraph{Model \& Baselines} The Transformer \cite{attention} is a representative multi-head attention based model. We apply the proposed repulsive multi-head attention (RMA) on it and compare our method with the original one (MA) and the disagreement regularization method (R) \cite{disagree} which encourages the diversity in attention by a cosine similarity penalty on attention outputs. \paragraph{Tasks \& Datasets} Following \citet{attention} , we apply Transformer for machine translation, with two standard translation datasets: the IWSLT14 German-to-English (De-En) dataset , and the WMT14 English-to-German (En-De) dataset. \begin{table}[t] \small \centering \begin{tabular}{l c c} \toprule \textbf{Models} & \textbf{BLEU} & \textbf{Time}\\ \midrule \multicolumn{3}{c}{\quad \quad IWSLT14 De-En}\\ \midrule Transformer-\texttt{small}-MA & 34.4 & 1 \\ Transformer-\texttt{small}-MA + R & 34.9 & 1.29 \\ Transformer-\texttt{small}-RMA & \textbf{35.2} & 1.13 \\ \midrule \multicolumn{3}{c}{\quad \quad WMT14 En-De}\\ \midrule Transformer-\texttt{base}-MA & 27.3 & 1\\ Transformer-\texttt{base}-MA + R & 28.2 & 1.35 \\ Transformer-\texttt{big}-MA & \textbf{28.4} & - \\ Transformer-\texttt{base}-RMA & \textbf{28.4} & 1.18\\ \bottomrule \end{tabular} \caption{Translation Performance on IWSLT14 De-En and WMT14 En-De Datasets. MA: standard multi-head attention. RMA: proposed repulsive multi-head attention. R: regularization approach. Time: relative training time of every step versus MA.} \label{tab:transformer_main} \vspace{-0.3cm} \end{table} \paragraph{Results} Results are presented in Table \ref{tab:transformer_main}. With the repulsive multi-head attention, Transformer models achieve noticeable improvement on the BLEU score on both datasets, compared with both baselines. It is also encouraging to see that the Transformer-\texttt{base}-RMA with a much smaller model achieves comparable performance as Transformer-\texttt{big}. As for training time, our approach takes slightly more time than the baseline, but is much more efficient than the regularization approach. \paragraph{Which attention module to be diversified?} We conduct extra experiments on Transformer-\texttt{small} to investigate which attention module benefits most from the repulsiveness. Results (see Appendix \ref{app:Transformer-abl}) suggest that diversifying different attention module benefits differently. Remarkably, only diversifying the attention in the first layer is able to achieve comparable performance to the case of diversifying attention in all layers, with little computational time increased. This finding suggests that the repulsiveness in the first layer's attention plays an important role for modelling language. \paragraph{Redundancy in heads} \begin{figure} \centering \subfloat[Transformer-\texttt{base}-MA]{{\includegraphics[width=0.5\linewidth]{BLEU_drop_base.png}}} \subfloat[Transformer-\texttt{base}-RMA]{{\includegraphics[width=0.5\linewidth]{BLEU_drop_base_svgd.png}}} \caption{Distribution of heads by performance drop after masking at test time. The redundancy of heads in RMA is much less.} \label{fig:redundancy} \vspace{-0.3cm} \end{figure} The redundancy problem in attention has been observed in recent works \cite{sixteen}, that a large percentage of attention heads can be removed at test time without significantly impacting performance. Following \citet{sixteen}, we analysis the redundancy in Transformer by ablating each head at testing and evaluating the performance drop. The more drops, the more important of the head. Figure \ref{fig:redundancy} shows that the majority of heads in standard multi-head attention are redundant for the performance is comparable before and after masking. However, the repulsive attention largely alleviates the redundancy. More interestingly, there are a lot of counter-intuitive cases in standard attention: removing a head results in an increase in performance. However, this does not seem to happen in repulsive attention model, indicating better leveraging of the superior expressiveness of multi-head mechanism. \subsection{Language Representation Learning} \label{sec:electra} \begin{table*}[t] \small \centering \setlength\tabcolsep{4pt} \begin{tabular}{c | l c c c c c c c c @{\hspace{1.5\tabcolsep}} c @{\hspace{1.7\tabcolsep}} c} \toprule \small \textbf{Pre-training Data} & \textbf{Model} & \textbf{Prams} & \textbf{CoLA} & \textbf{SST} & \textbf{MRPC} & \textbf{STS} & \textbf{QQP} & \textbf{MNLI} & \textbf{QNLI} & \textbf{RTE} & \textbf{Avg.} \\ \midrule \multirow{5}{*}{\shortstack{Wikipedia \\ + \\BooksCorpus}} & TinyBERT & 14.5M & 51.1 & 93.1 & 82.6 & 83.7 & 89.1 & 84.6 & 90.4 & 70.0 & 80.6\\ & MobileBERT & 25.3M & 51.1 & 92.6 & 84.5 & 84.8 & 88.3 & 84.3 & 91.6 & 70.4 & 81.0\\ & GPT & 117M & 45.4 & 91.3 & 75.7 & 80.0 & 88.5 & 82.1 & 88.1 & 56.0 & 75.9 \\ & BERT-Base & 110M & 52.1 & 93.5 & 84.8 & 85.8 & 89.2 & 84.6 & 90.5 & 66.4 & 80.9 \\ & ELECTRA & 14M & 54.6 & 89.1 & 83.7 & 80.3 & 88.0 & 79.7 & 87.7 & 60.8 & 78.0 \\ \midrule \multirow{2}{*}{\shortstack{OpenWebText}} & ELECTRA & 14M & 56.2 & \textbf{88.3} & 87.5 & 86.8 & 88.1 & 78.6 & 87.4 &\textbf{67.3} / 71.4 & 80.0 / 80.5 \\ & \quad + RMA & 14M & \textbf{59.4} & 87.1 & \textbf{87.9} &\textbf{87.0} & \textbf{88.6} &\textbf{79.3} & \textbf{87.8} & 64.9 / \textbf{73.1} & \textbf{80.3} / \textbf{81.3} \\ \bottomrule \end{tabular} \caption{Results on the GLUE test set. For RMA, repulsive attention is only applied to pre-training. For RTE, the left value is fine-tuned from pre-trained models, the right value is from intermediate task training.} \label{tab:electra} \vspace{-0.3cm} \end{table*} \paragraph{Model} ELECTRA \cite{electra} is an efficient approach to self-supervised language representation learning. It consists of two networks, {\em Generator} and {\em Discriminator}, both of which are parameterized by Transformers. The pre-trained Discriminator is used in various downstream tasks via fine-tuning. We apply the proposed repulsive multi-head attention to ELECTRA (small setting) in the pre-training stage. We only make the first layer attention of Discriminator to be repulsive, according to the finding in Section~\ref{sec:transformer} that the diversity in the first attention layer of Transformer benefits the most. \paragraph{Tasks \& Dataset} We train ELECTRA models on OpenWebText Corpus due to the data used in \citet{electra} is not publicly available. The pretrained models are then fine-tuned and evaluated on the General Language Understanding Evaluation (GLUE) \cite{GLUE} benchmark on eight datasets \cite{cola, sst, mrpc, sts, mnli, qnli, rte1,rte2,rte3,rte4}. \paragraph{Results} Results are shown in Table \ref{tab:electra}. For each task, we perform single-task fine-tuning 50 times, and report the averaged results. The training time with and without repulsive attention is almost the same. It shows that repulsive attention improves the baseline results \cite{electra} in seven out of eight tasks on GLUE, and the gains are larger especially on MNLI (the largest dataset on GLUE) and CoLA . This suggests that repulsive attention can yield better language representations. Since MNLI and RTE are both entailment tasks, following~\citet{electra} and ~\citet{intermediate}, we use intermediate task training for RTE. We first fine-tune the pre-trained model on MNLI, then continuously fine-tune it on RTE. The repulsive attention outperforms the baseline method by a large margin in this setting. This is probably because the repulsive attention particularly favor large data variability (e.g., MNLI dataset), where different aspects of data can be uniquely represented in different heads. \subsection{Graph-to-Text Generation}\label{sec:GW} \paragraph{Model \& Baselines} GraphWriter \cite{Graphwriter} is a knowledge-graph-to-text model, which aims at generating coherent multi-sentence abstract given a knowledge graph and a title. There is a Transformer-style encoder defined with graph attention modules \cite{GAT} that could also be easily adapted to our method. We compare our method with the original one that has the standard multi-head attention, and the one with the cosine similarity regularization on attention parameters in encoder layers. \paragraph{Tasks \& Datasets \& Metrics} Experiments are conducted on the Abstract GENeration DAtaset (AGENDA) \cite{Graphwriter}, a dataset of knowledge graphs paired with scientific abstracts. We evaluate the quality of abstracts with 3 major metrics: BLEU (uni-gram to 4-gram BLEU) \cite{BLEU}, METEOR \cite{METEOR}, ROUGE \cite{ROUGE}. In ROUGE, the unigram and bigram overlap (ROUGE-1 and ROUGE-2) are a proxy for assessing informativeness and the longest common subsequence (ROUGE-L) represents fluency. \begin{table}[] \small \centering \begin{tabular}{l c c c} \toprule \textbf{ Metrics} & \textbf{GW} & \textbf{+ R} & \textbf{+ RMA} \\ \midrule BLEU-1 & 42.56 & 42.25 & \textbf{45.60} \\ BLEU-2 & 27.64 & 27.98 & \textbf{29.96} \\ BLEU-3 & 19.27 & 19.77 & \textbf{21.07} \\ BLEU-4 & 13.75 & 14.21 & \textbf{15.12} \\ METEOR & 18.11 & 18.61 & \textbf{19.52}\\ ROUGE-1 & 35.80 & 37.24 & \textbf{38.23}\\ ROUGE-2 & 16.83 & 17.78 & \textbf{18.39}\\ ROUGE-L & 27.21 & 26.90 & \textbf{28.55}\\ \bottomrule \end{tabular} \caption{Automatic evaluations of generation systems on test set of AGENDA.} \label{tab:GW} \end{table} \begin{table}[] \small \centering \begin{tabular}{l c c c} \toprule & Win & Lose & Tie \\ \midrule Structure & 51\% & 12\% & 37\% \\ Informativeness & 66\% & 13\% & 21\% \\ Grammar & 37\% & 17\% & 46\% \\ Overall & 65\% & 14\% & 21\% \\ \bottomrule \end{tabular} \caption{Human judgments of GraphWriter with and without repulsive attention.} \label{tab:human} \vspace{-0.3cm} \end{table} \paragraph{Results} The results are shown in Table \ref{tab:GW}. The GraphWriter model with repulsive multi-head attention significantly outperforms the original model and regularization approach in all metrics. Especially, the higher recall score in ROUGE shows that there are more N-grams across the reference abstracts that can be found in the generated abstracts. Similar observations are noticed when analyzing the generated examples in detail (an example is illustrated in Appendix \ref{app:GW}). \citet{Graphwriter} pointed out one limitation of their model is 40\% of entities in the knowledge graphs do not appear in the generated text. With the repulsive attention, remarkably, the GraphWriter model is observed to perform much better with a 10\% improvement on the knowledge graph coverage and fewer repeat clauses. \paragraph{Human Evaluation} To further illustrate the improvement of using diverse attention, we conduct human evaluation. Following~\citet{Graphwriter}, we give 50 test datapoints to experts (5 computer science students) and ask them to provide per-criterion judgments for the generated abstracts. Comparisons of the two methods from 4 aspects are shown in Table \ref{tab:human}. The human judgment indicates that the repulsive attention improves both the structure and informativeness of generated abstracts significantly, which is consistent with the automatic evaluation and our observations. \subsection{On the Number of Attention Heads} \begin{figure}[t!] \centering \subfloat[]{{\includegraphics[width=0.5\linewidth]{yelp_head_ab.png}}} \subfloat[]{{\includegraphics[width=0.5\linewidth]{head_ab.png}}} \vspace{-0.3cm} \caption{Demonstration on performance difference with different number of heads. (a) Testing error of the self-attentive sentence classification model on Yelp dataset. (b) Negative log likelihood loss of Transformer-\texttt{small} on IWSLT14 De-En dataset. } \label{fig:head} \vspace{-0.3cm} \end{figure} Our analysis in Section~\ref{sec:why} suggests the existence of the optimal number of attention heads. To verify this, we further conduct experiments on sentence classification and translation tasks by varying the number of attention heads in models. The results are shown in Figure~\ref{fig:head}. The model error/loss first decreases then increases w.r.t.\! $M$, the number of attention heads. The optimal $M$ are around 20 and 4 for the sentiment analysis and the Transformer, respectively. Interestingly, the Transformer degrades quickly as the number of heads increases. This might because the constant corresponding to the $O(M\epsilon_0)$ term in the bound is too large, making this term quickly dominate with increasing $M$. Furthermore, it is also observed that the standard multi-head attention follows the same trend, but performs much worse and is more sensitive to the $M$. This indicates the benefit of Bayesian modeling, which could usually stabilize a model better. \section{Related Work} We provide a first explanation of multi-head attention from a Bayesian perspective, and propose particle-optimization sampling for repulsive attention. Most previous works aim at improving attention diversity with regularization-based methods, {\it e.g.}, the Frobenius regularization on attention weights in \citet{zhouhan} and the cosine similarity regularization on attention outputs in \citet{disagree}. These works focus on a particular model and the underlying working principle has not been well-validated. Our approach is a principled one that is more interpretable and widely applicable. The attention collapse belongs to a feature-overlapping problem, which also happens in other areas. Some works tackle this problem by changing architectures, for example ResNet \cite{resnet} and DenseNet \cite{densnet} implicitly reduce feature correlations by summing or concatenating activation from previous layers. There are also works done by altering the training method as we do. \citet{DSD} adopt the dropout mechanism and propose a dense-sparse-dense training flow, for regularizing deep neural networks. \citet{RePr} attempt addressing the unnecessary overlap in features captured by image filters with pruning-restoring scheme in training. To our knowledge, we are the first to tackle the attention-feature overlap problem from a Bayesian view with a principled interpretation. \section{Conclusion} We propose a principled way of understanding multi-head attention from a Bayesian perspective. We apply particle-optimization sampling to train repulsive multi-head attention with no additional trainable parameters nor explicit regularizers. Our Bayesian framework explains the long-standing question of why and how multi-head attention affects model performance. Extensive experimental results on representative attention models demonstrate that our approach can significantly improve the diversity in multi-head attention, resulting in more expressiveness attention models with performance improvement on a wide range of tasks. \section*{Acknowledgements} We sincerely thank all the reviewers for providing valuable feedback. This paper is supported by the Verizon Media FREP program. \bibliographystyle{acl_natbib}
{'timestamp': '2020-11-03T02:33:10', 'yymm': '2009', 'arxiv_id': '2009.09364', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09364'}
arxiv
\section{Detail of Dataset} \label{app:sec:data_statistic} The data split method provided by \citet{hou2020few} are applied in SNIPS and NER datasets. Statistical analyses of the original datasets are provided in Table \ref{tab:ori_dataset}, where the number of labels (``\# Labels'') is counted in inside/outside/beginning (IOB) schema. \begin{table}[htbp] \small \centering \begin{tabular}{ccccc} \hline \textbf{Task} & \textbf{Dataset} & \textbf{Domain} & \textbf{\# Sent} & \textbf{\# Labels} \\ \hline \multirow{7}{*}{\begin{tabular}[c]{@{}c@{}}Slot\\ Tagging\end{tabular}} & \multirow{7}{*}{SNIPS} & We & 2100 & 17 \\ & & Mu & 2100 & 18 \\ & & Pl & 2042 & 10 \\ & & Bo & 2056 & 12 \\ & & Se & 2059 & 15 \\ & & Re & 2073 & 28 \\ & & Cr & 2054 & 5 \\ \hline \multirow{4}{*}{NER} & CoNLL & News & 20679 & 9 \\ & GUM & Wiki & 3493 & 23 \\ & WNUT & Social & 5657 & 13 \\ & OntoNotes & Mixed & 159615 & 37 \\ \hline \end{tabular} \caption{Statistics of original dataset.} \label{tab:ori_dataset} \end{table} \citet{hou2020few} reorganized the dataset for few-shot slot tagging and NER in the \emph{episode} data setting~\cite{vinyals2016matching}, where each episode contains a support set (1-shot or 5-shot) and a batch of labeled samples. The 1-shot and 5-shot scenarios mean each label of a domain appears about 1 and 5 times, respectively. The overview of the few-shot data split on SNIPS and NER are shown in Table \ref{tab:few_shot_SNIPS_dataset} and Table \ref{tab:few_shot_NER_dataset} respectively. For SNIPS, each domain consists of 100 episodes. For NER, each domain contains 200 episodes in 1-shot scenario and 100 episodes in 5-shot scenario. \begin{table}[htbp] \small \centering \begin{tabular}{ccccc} \hline \multirow{2}{*}{\textbf{Domain}} & \multicolumn{2}{c}{\textbf{1-shot}} & \multicolumn{2}{c}{\textbf{5-shot}} \\ \cline{2-3} \cline{4-5} & \textbf{Avg. $|S|$} & \textbf{\# Sent} & \textbf{Avg. $|S|$} & \textbf{\# Sent} \\ \hline \textbf{We} & 6.15 & 2000 & 28.91 & 1000 \\ \textbf{Mu} & 7.66 & 2000 & 34.43 & 1000 \\ \textbf{Pl} & 2.96 & 2000 & 13.84 & 1000 \\ \textbf{Bo} & 4.34 & 2000 & 19.83 & 1000 \\ \textbf{Se} & 4.29 & 2000 & 19.27 & 1000 \\ \textbf{Re} & 9.41 & 2000 & 41.58 & 1000 \\ \textbf{Cr} & 1.30 & 2000 & 5.28 & 1000 \\ \hline \end{tabular} \caption{Overview of few-shot slot tagging data from SNIPS. ``Avg. $|S|$'' refers to the average support set size of each domain, and ``Sample'' indicates the number of labelled samples in the batches of all episodes.} \label{tab:few_shot_SNIPS_dataset} \end{table} \begin{table}[htbp] \small \centering \begin{tabular}{ccccc} \hline \multirow{2}{*}{\textbf{Domain}} & \multicolumn{2}{c}{\textbf{1-shot}} & \multicolumn{2}{c}{\textbf{5-shot}} \\ \cline{2-3} \cline{4-5} & \textbf{Avg. $|S|$} & \textbf{\# Sent} & \textbf{Avg. $|S|$} & \textbf{\# Sent} \\ \hline \textbf{News} & 3.38 & 4000 & 15.58 & 1000 \\ \textbf{Wiki} & 6.50 & 4000 & 27.81 & 1000 \\ \textbf{Social} & 5.48 & 4000 & 28.66 & 1000 \\ \textbf{Mixed} & 14.38 & 4000 & 62.28 & 1000 \\ \hline \end{tabular} \caption{Overview of few-shot data for NER experiments.} \label{tab:few_shot_NER_dataset} \end{table} \section{Training Details} \label{app:sec:training} In all the experiments, we use the uncased \texttt{BERT-Base}~\cite{devlin2019bert} as $E$ to extract contextual word embeddings. The models are trained using ADAM \cite{kingma2014adam} with the learning rate of 1e-5 and updated after each episode. We fine-tune BERT with layer-wise learning rate decay (rate is 0.9), i.e., the parameters of the $l$-th layer get an adaptive learning rate $1\text{e-}5* 0.9^{(L - l)}$, where $L$ is the total number of layers in BERT. For the CRF transition parameters, they are initialized as zeros, and a large learning rate of 1e-3 is applied. For each dataset, we follow \citet{hou2020few} to select one target domain for evaluation, one domain for validation, and utilize the rest domains as source domains for training. The models are trained for five iterations, and we save the parameters with the best F$_1$ score on the validation domain. We use the average F$_1$ score at episode level, and the F$_1$-score is calculated using CoNLL evaluation script\footnote{\url{https://www.clips.uantwerpen.be/conll2000/chunking/output.html}}. For each experiment, we run it ten times with different random seeds generated at \url{https://www.random.org}. We run our models on GeForce GTX 2080 Ti Graphics Cards, and the average training time for each epoch and number of parameters in each model are provided in Table \ref{tab:reproducibility}. \begin{table}[htp] \small \centering \begin{tabular}{|c|c|c|c|} \hline \multirow{2}{*}{\textbf{Method}} & \multicolumn{2}{c|}{\textbf{Time per Batch}} & \multirow{2}{*}{\textbf{\# Param.}} \\ \cline{2-3} & SNIPS & NER & \\ \hline L-TapNet+CDT+VP & 224ms & 273ms & 110M \\ ProtoNet+CDT+VP & 176ms & 223ms & 110M \\ ProtoNet+CDT+VPB & 184ms & 240ms & 110M \\ \hline \end{tabular} \caption{Runtime and mode size of our methods.} \label{tab:reproducibility} \end{table} \section{Additional Analyses and Results} \subsection{Fine-tuning on the Support Set} \label{app:sec:finetune} Almost all few-shot slot tagging methods choose not to keep fine-tuning on the support set for efficiencies. Here we want to know how performances change if our methods are fine-tuned on the support set. Concretely, pre-trained models are fine-tuned on the support set of one episode and then evaluated on the data batch of the episode. Since different episodes are independent, models would be reinitialized as the pre-trained ones to prepare for the next episode. We fine-tune the ``ProtoNet+CDT+VP'' model for $1\sim10$ steps using the same hyper-parameters with the training. As illustrated in Table \ref{tab:finetune}, we can find that fine-tuning on the support set can get further improvements greatly. \input{tables/finetune} \input{tables/all_with_std} \subsection{Result with Standard Deviations} \label{app:sec:res_std} Table \ref{tab:1shot_snips_with_var}, \ref{tab:5shot_snips_with_var}, \ref{tab:1shot_ner_with_var} and \ref{tab:5shot_ner_with_var} show the complete results with standard deviations on SNIPS and NER. \section{Introduction} Natural language understanding (NLU) is a key component of conversational dialogue systems, converting user's utterances into the corresponding semantic representations~\cite{wang2005spoken} for certain narrow domain (e.g., \emph{booking hotel}, \emph{searching flight}). As a core task in NLU, slot tagging is usually formulated as a sequence labeling problem~\cite{mesnil2015using,sarikaya2016overview,liu2016attention}. Recently, motivated by commercial applications like Amazon Alexa, Apple Siri, Google Assistant, and Microsoft Cortana, great interest has been attached to rapid domain transfer and adaptation with only a few samples~\cite{Bapna2017towards}. Few-shot learning approaches~\cite{fei2006one,vinyals2016matching} become appealing in this scenario ~\cite{fritzler2019few,geng2019induction,hou2020few}, where a general model is learned from existing domains and transferred to new domains rapidly with merely few examples (e.g., in one-shot learning, only one example for each new class). The similarity-based few-shot learning methods have been widely analyzed on classification problems~\cite{vinyals2016matching,snell2017prototypical,sung2018learning,yan2018few,yu2018diverse,sun2019hierarchical,geng2019induction,yoon2019tapnet}, which classify an item according to its similarity with the representation of each class. These methods learn a domain-general encoder to extract feature vectors for items in existing domains, and utilize the same encoder to obtain the representation of each new class from very few labeled samples (\emph{support set}). This scenario has been successfully adopted in the slot tagging task by considering both the word-label similarity and temporal dependency of target labels~\cite{hou2020few}. Nonetheless, it is still a challenge to devise appropriate word-label similarity metrics for generalization capability. In this work, a vector projection network is proposed for the few-shot slot tagging task in NLU. To eliminate the impact of unrelated label vectors but with large norm, we exploit projections of contextual word embeddings on each normalized label vector as the word-label similarity. Moreover, the half norm of each label vector is utilized as a threshold, which can help reduce false positive errors. One-shot and five-shot experiments on slot tagging and named entity recognition (NER)~\cite{hou2020few} tasks show that our method can outperform various few-shot learning baselines, enhance existing advanced methods like TapNet~\cite{yoon2019tapnet,hou2020few} and prototypical network~\cite{snell2017prototypical,fritzler2019few}, and achieve state-of-the-art performances. Our contributions are summarized as follows: \begin{itemize} \item We propose a vector projection network for the few-shot slot tagging task that utilizes projections of contextual word embeddings on each normalized label vector as the word-label similarity. \item We conduct extensive experiments to compare our method with different similarity metrics (e.g., dot product, cosine similarity, squared Euclidean distance). Experimental results demonstrate that our method can significantly outperform the others. \end{itemize} \section{Related Work} One prominent methodology for few-shot learning in image classification field mainly focuses on metric learning~\cite{vinyals2016matching,snell2017prototypical,sung2018learning,oreshkin2018tadam,yoon2019tapnet}. The metric learning based methods aim to learn an effective distance metric. It can be much simpler and more efficient than other meta-learning algorithms~\cite{munkhdalai2017meta,mishra2018a,finn2017model}. As for few-shot learning in natural language processing community, researchers pay more attention to classification tasks, such as text classification~\cite{yan2018few,yu2018diverse,sun2019hierarchical,geng2019induction}. Recently, few-shot learning for slot tagging task becomes popular and appealing. \citet{fritzler2019few} explored few-shot NER with the prototypical network. \citet{hou2020few} exploited the TapNet and label dependency transferring for both slot tagging and NER tasks. Compared to these methods, our model can achieve better performance in new domains by utilizing vector projections as word-label similarities. \section{Problem Formulation} \begin{figure}[] \centering \includegraphics[width=0.48\textwidth]{./figs/data_annotation.png} \caption{A data sample in domain \texttt{GetWeather}.} \label{fig:data_sample} \end{figure} We denote each sentence $\boldsymbol{x} = (x_1, \cdots, x_{|\boldsymbol{x}|})$ as a word sequence, and define its label sequence as $\boldsymbol{y} = (y_1, \cdots, y_{|\boldsymbol{x}|})$. An example for slot tagging in domain \texttt{GetWeather} is provided in Fig \ref{fig:data_sample}. For each domain $\mathcal{D}$, it includes a set of $(\boldsymbol{x}, \boldsymbol{y})$ pairs, i.e., $\mathcal{D}=\{(\boldsymbol{x}^{(i)}, \boldsymbol{y}^{(i)})\}_{i=1}^{|\mathcal{D}|}$. In the few-shot scenario, the slot tagging model is trained on several source domains $\{\mathcal{D}_1, \mathcal{D}_2, \cdots, \mathcal{D}_M\}$, and then directly evaluated on an unseen target domain $\mathcal{D}_t$ which only contains few labeled samples~(\emph{support set}). The support set, $S=\{(\boldsymbol{x}^{(i)}, \boldsymbol{y}^{(i)})\}_{i=1}^{|S|}$, usually includes $k$ examples (K-shot) for each of N labels (N-way). Thus, the few-shot slot tagging task is to find the best label sequence $\boldsymbol{y}^*$ given an input query $\boldsymbol{x}$ in target domain $\mathcal{D}_t$ and its corresponding support set $S$, \begin{equation} \boldsymbol{y}^* = \arg \max _{\boldsymbol{y}} p_{\theta}(\boldsymbol{y}|\boldsymbol{x}, S) \end{equation} where $\theta$ refers to parameters of the slot tagging model, the $(\boldsymbol{x}, \boldsymbol{y})$ pair and the support set are from the target domain, i.e., $(\boldsymbol{x}, \boldsymbol{y}) \sim \mathcal{D}_t$ and $S \sim \mathcal{D}_t$. The few-shot slot tagging model is trained on the source domains to minimise the error in predicting labels conditioned on the support set, \begin{equation*} \theta = \arg \max _{\theta} \sum_{m=1}^M \sum_{(\boldsymbol{x}, \boldsymbol{y}) \sim \mathcal{D}_m,\ S \sim \mathcal{D}_m} \log p_{\theta}(\boldsymbol{y}|\boldsymbol{x}, S) \end{equation*} \section{Vector Projection Network} In this section, we will introduce our model for the few-shot slot tagging task. \subsection{Few-shot CRF Framework} Linear Conditional Random Field (CRF)~\cite{sutton2012introduction} considers the correlations between labels in neighborhoods and jointly decodes the most likely label sequence given the input sentence~\cite{yao2014recurrent,ma-hovy-2016-end}. The posterior probability of label sequence $\mathbf{y}$ is computed via: \begin{align*} \psi_\theta(\boldsymbol{y}, \boldsymbol{x}, S) &= \sum_{i=1}^{|\boldsymbol{x}|} (f_T(y_{i-1}, y_i) + f_E(y_i, \boldsymbol{x}, S))\\ p_{\theta}(\boldsymbol{y}|\boldsymbol{x}, S) &= \frac{ \text{exp}(\psi_\theta(\boldsymbol{y}, \boldsymbol{x}, S))}{\sum_{\boldsymbol{y}'}\text{exp}(\psi_\theta(\boldsymbol{y}', \boldsymbol{x}, S)) } \end{align*} where $f_T(y_{i-1}, y_i)$ is the transition score and $f_E(y_i, \boldsymbol{x}, S)$ is the emission score at the $i$-th step. The transition score captures temporal dependencies of labels in consecutive time steps, which is a learnable scalar for each label pair. To share the underlying factors of transition between different domains, we adopt the Collapsed Dependency Transfer (CDT) mechanism~\cite{hou2020few}. The emission scorer independently assigns each word a score with respect to each label $y_i$, which is defined as a word-label similarity function: \begin{equation} f_E(y_i, \boldsymbol{x}, S) = \textsc{Sim}(E(\boldsymbol{x})_i, \mathbf{c}_{y_i}) \end{equation} where $E$ is a contextual word embedding function, e.g., BLSTM~\cite{graves2012supervised}, Transformer~\cite{vaswani2017attention}, $\mathbf{c}_{y_i}$ is the label embedding of $y_i$ which is extracted from the support set $S$. In this paper, we adopt a pre-trained BERT model~\cite{devlin2019bert} as $E$. Various models are proposed to extract label embedding $\mathbf{c}_{y_i}$ from $S$, such as matching network~\cite{vinyals2016matching}, prototypical network~\cite{snell2017prototypical} and TapNet~\cite{yoon2019tapnet}. Take the prototypical network as an example, each prototype~(label embedding) is defined as the mean vector of the embedded supporting points belonging to it: { \begin{equation} \mathbf{c}_{y_i} = \frac{1}{N_{y_i}}\sum_{j=1}^{|S|}\sum_{k=1}^{|\boldsymbol{x}^{(j)}|} \mathbb{I}\{y_k^{(j)}=y_i\} E(\boldsymbol{x}^{(j)})_k \end{equation}}where $N_{y_i}=\sum_{j=1}^{|S|}\sum_{k=1}^{|\boldsymbol{x}^{(j)}|} \mathbb{I}\{y_k^{(j)}=y_i\}$ is the number of words labeled with $y_i$ in the support set. \subsection{Vector Projection Similarity} For the word-label similarity function, we propose to exploit vector projections of word embeddings $\mathbf{x}_i$ on each normalized label vector $\mathbf{c}_{k}$: { \begin{equation} \textsc{Sim}(\mathbf{x}_i, \mathbf{c}_{k}) = \mathbf{x}_i^{\top}\frac{\mathbf{c}_{k}}{||\mathbf{c}_{k}||} \end{equation}}Different with the dot product used by~\citet{hou2020few}, it can help eliminate the impact of $\mathbf{c}_{k}$'s norm to avoid the circumstance where the norm of $\mathbf{c}_{k}$ is enough large to dominate the similarity metric. In order to reduce false positive errors, the half norm of each label vector is utilized as an adaptive bias term: { \begin{equation} \textsc{Sim}(\mathbf{x}_i, \mathbf{c}_{k}) = \mathbf{x}_i^{\top}\frac{\mathbf{c}_{k}}{||\mathbf{c}_{k}||} - \frac{1}{2}||\mathbf{c}_{k}|| \end{equation}} \subsection{Explained as a Normalized Linear Model} A simple interpretation for the above vector projection network is to learn a distinct linear classifier for each label. We can rewrite the above formulas as a linear model: { \begin{equation} \textsc{Sim}(\mathbf{x}_i, \mathbf{c}_{k}) = \mathbf{x}_i^{\top}\mathbf{w}_k + b_k \label{eqn:norm_linear} \end{equation}}where $\mathbf{w}_k=\frac{\mathbf{c}_{k}}{||\mathbf{c}_{k}||}$ and $b_k=-\frac{1}{2}||\mathbf{c}_{k}||$. The weights are normalized as $||\mathbf{w}_k||=1$ to improve the generalization capability of the few-shot model. Experimental results indicate that vector projection is an effective choice compared to dot product, cosine similarity, squared Euclidean distance, etc. \section{Experiment} We evaluate the proposed method following the data split~\footnote{\url{https://atmahou.github.io/attachments/ACL2020data.zip}} provided by \citet{hou2020few} on SNIPS~\cite{coucke2018snips} and NER datasets. It is in the \emph{episode} data setting~\cite{vinyals2016matching}, where each episode contains a support set (1-shot or 5-shot) and a batch of labeled samples. For slot tagging, the SNIPS dataset consists of 7 domains with different label sets: Weather (We), Music (Mu), PlayList (Pl), Book (Bo), Search Screen (Se), Restaurant (Re) and Creative Work (Cr). For NER, 4 different datasets are utilized to act as different domains: CoNLL-2003 (News)~\cite{sang2003introduction}, GUM (Wiki)~\cite{zeldes2017gum}, WNUT-2017 (Social)~\cite{derczynski2017results} and OntoNotes (Mixed)~\cite{pradhan2013towards}. More details of the data split are shown in Appendix \ref{app:sec:data_statistic}. For each dataset, we follow \citet{hou2020few} to select one target domain for evaluation, one domain for validation, and utilize the rest domains as source domains for training. We also report the average F$_1$ score at the episode level. For each experiment, we run it ten times with different random seeds. The training details are illustrated in Appendix \ref{app:sec:training}. \input{tables/1shot_5shot_snips} \input{tables/1shot_5shot_ner} \input{tables/different_distances} \subsection{Baselines} \noindent\textbf{SimBERT:} For each word $x_i$, SimBERT finds the most similar word $x'_k$ in the support set and assign the label of $x'_k$ to $x_i$, according to cosine similarity of word embedding of a fixed BERT. \noindent\textbf{TransferBERT:} A trainable linear classifier is applied on a shared BERT to predict labels for each domain. Before evaluation, it is fine-tuned on the support set of the target domain. \noindent\textbf{L-WPZ(ProtoNet)+CDT+PWE:} WPZ is a few-shot sequence labeling model~\cite{fritzler2019few} that regards sequence labeling as classification of each word. It pre-trains a prototypical network~\cite{snell2017prototypical} on source domains, and utilize it to do word-level classification on target domains without fine-tuning. It is enhanced with BERT, Collapsed Dependency Transfer (CDT) and Pair-Wise Embedding (PWE) mechanisms by~\cite{hou2020few}. \noindent\textbf{L-TapNet+CDT+PWE:} The previous state-of-the-art method for few-shot slot tagging~\cite{hou2020few}, which incorporates TapNet~\cite{yoon2019tapnet} with BERT, CDT and PWE. We borrow the results of these baselines from \citet{hou2020few}. ``\textbf{L-}'' means label-enhanced prototypes are applied by using label name embeddings. \subsection{Main Results} Table \ref{tab:1shot_5shot_snips} and Table \ref{tab:1shot_5shot_ner} show results on both 1-shot and 5-shot slot tagging of SNIPS and NER datasets respectively. Our method can significantly outperform all baselines including the previous state-of-the-art model. Moreover, the previous state-of-the-art model heavily relies on PWE, which concatenates an input sentence with each sample in the support set and then feeds them into BERT to get pair-wise embeddings. By comparing ``L-TapNet+CDT+PWE'' with ``L-TapNet+CDT+VP'', we can find that our proposed Vector Projection (VP) can achieve better performance as well as higher efficiency. If we incorporate the negative half norm of each label vector as a bias (VPB), F$_1$ score on 5-shot slot tagging is dramatically improved. We speculate that 5-shot slot tagging involves multiple support points for each label, thus false positive errors could occur more frequently if there is no threshold when predicting each label. We also find that label name embeddings (``\textbf{L-}') help less in our methods. \subsection{Analysis} \input{tables/error_analysis} \noindent \textbf{Ablation Study} For the word-label similarity function $\textsc{Sim}(\mathbf{x}, \mathbf{c})$, we also conduct contrastive experiments between our proposed vector projection and other variants including the dot product ($\mathbf{x}^\top \mathbf{c}$), the projection of label vector on word embedding ($\frac{\mathbf{x}^\top}{||\mathbf{x}||} \mathbf{c}$), cosine similarity ($\frac{\mathbf{x}^\top}{||\mathbf{x}||} \frac{\mathbf{c}}{||\mathbf{c}||}$), squared Euclidean distance ($-\frac{1}{2}||\mathbf{x}-\mathbf{c}||^2$), and even a trainable scaling factor ($\lambda \mathbf{x}^\top \mathbf{c}$)~\cite{oreshkin2018tadam}. The results in Table \ref{tab:different_distances} show that our methods can significantly outperform these alternative metrics. We also notice that the squared Euclidean distance can achieve competitive results in the 5-shot setting. Mathematically, { \begin{align*} -\frac{1}{2}||\mathbf{x}-\mathbf{c}||^2 & =-\frac{1}{2}\mathbf{x}^\top \mathbf{x} + \mathbf{x}^\top \mathbf{c} -\frac{1}{2}\mathbf{c}^\top \mathbf{c}\\ & \approxeq \mathbf{x}^\top \mathbf{c} - \frac{1}{2}\mathbf{c}^\top \mathbf{c} \end{align*}}where $-\frac{1}{2}\mathbf{x}^\top \mathbf{x}$ is constant with respect to each label and thus omitted. It further consolidates our assumption that $\frac{1}{2}\mathbf{c}^\top \mathbf{c}$ can function as a bias term to alleviate false positive errors. \noindent \textbf{Effect of Vector Projection} We claimed that vector projection could help reduce false positive errors. As illustrated in Figure \ref{fig:error_types}, we classify all wrong predictions of slot tagging into three error types (i.e., ``O-X'', ``X-O'' and ``X-X''), where ``O'' means no slot and ``X'' means a slot tag beginning with `B' or `I'. The error analysis of these three error types are illustrated in Table \ref{tab:error_analysis}. We can find that our methods can significantly reduce wrong predictions of these three types in SNIPS dataset. In NER dataset, our methods can achieve a remarkable reduction in ``O-X'' and ``X-X'', while leading to an increase of ``X-O'' errors. However, the total number of these three errors are reduced by our methods in NER dataset. \begin{figure}[] \centering \includegraphics[width=0.45\textwidth]{./figs/error_types.png} \caption{Definition of three error types of slot tagging, which are ``O-X'', ``X-O'' and ``X-X''. ``C'' means correct predictions.} \label{fig:error_types} \end{figure} \noindent \textbf{Fine-tuning with Support Set} Apart from the few-shot slot tagging focusing on model transfer instead of fine-tuning, we also analyze keeping fine-tuning our models on the support set in Appendix \ref{app:sec:finetune}. \section{Conclusion} In this paper, we propose a vector projection network for the few-shot slot tagging task, which can be interpreted as a normalized linear model with an adaptive bias. Experimental results demonstrate that our method can significantly outperform the strongest few-shot learning baseline on SNIPS and NER datasets in both 1-shot and 5-shot settings. Furthermore, our proposed vector projection based similarity metric can remarkably surpass others variants. For future work, we would like to add a learnable scale factor for bias in Eqn. \ref{eqn:norm_linear}.
{'timestamp': '2020-09-23T02:11:17', 'yymm': '2009', 'arxiv_id': '2009.09568', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09568'}
arxiv
\section{Introduction} \label{sec:intro} Vector autoregression (VAR) models have been widely used in econometric, business statistics, and other fields \citep{Sims:1980tu,Fuller:1996wa,Lutkepohl:2007vj}. These models can capture the dynamic relationship between factors through transition matrices. In practice, the number of factors can be large, even larger than the sample size. For instance, the number of stocks in the market is usually larger than the number of observations. This fact leads researchers to consider high-dimensional VAR models. High-dimensional VAR models have been thoroughly studied in the past decades. For instance, \cite{Guo:2016hi} imposed banded structure on the transition matrices and established the convergence rates of the least squares estimators. A series of works in the literature has proposed the sparsity constraint on the transition matrices and used the Lasso \citep{Tibshirani:1996} to estimate the parameters \citep{Hsu:2008,Song:2011,Negahban:2011dm,Loh:2012if,Chen:2013fu,Han:2015vc,Kock:2015bb,Basu:2015ho,Davis:2016fq}. Under regularity conditions, \cite{Basu:2015ho} established the deviation bounds of the Lasso estimators, which are essential for studying the theoretical properties of Lasso-based estimators in high-dimensional sparse VAR models. In addition to parameter estimation, confidence intervals and hypothesis testing provide practitioners, such as, policy makers and business owners, with more valuable and solid information for assessing the significance of the correlations between factors. For instance, \cite{wilms2016predictive} used Granger causality test \citep{granger1969investigating} based on the bootstrap adaptive Lasso to detect the most predictive industry-specific economic sentiment indicators for macro-economic indicators. \cite{lin2017regularized} proposed testing procedures in multi-block VAR models to test whether a block ``Granger-causes'' another block of variables and applied them to analyze the temporal dynamics of the S\&P100 component stocks and key macroeconomic factors. In the context of VAR models, the Granger causality test is equivalent to test if the element of transition matrices is equal to zero \citep{Lutkepohl:2007vj}. There is an increasing demand for constructing confidence intervals or performing hypothesis testing for the element of transition matrices in high-dimensional VAR models. Since the limiting distribution of the Lasso is complicated \citep{Knight:2000}, we cannot directly use it for statistical inference. In high-dimensional sparse linear regression models, a series of studies has proposed methods based on the Lasso or its variants for statistical inference. One direction of research has proposed the de-biased Lasso method, which focuses on obtaining an asymptotically normal estimator by correcting the bias of the Lasso estimator \citep{Zhang:2014,vandeGeer:2014,Javanmard:2014}. We will refer the method in \cite{Zhang:2014} and \cite{vandeGeer:2014} as LDPE (low dimensional projection estimator) and the method in \cite{Javanmard:2014} as JM. These estimators are also called the de-sparsified Lasso since they are no longer sparse after correcting for the bias. Another direction of research uses the bootstrap \citep{Efron:1979ha} for inference, including the bootstrap threshold Lasso \citep{Chatterjee:2011}, bootstrap adaptive Lasso \citep{Chatterjee:2013}, bootstrap Lasso + ordinary least squares (OLS) \citep{Liu:2013} and bootstrap de-biased Lasso \citep{Dezeure:2017jla}. \cite{Ning:2017ee} generalized the de-biased Lasso method from linear regression to penalized M-estimators using the so called de-correlated score function. \cite{Neykov:2016to} generalized this method to estimating equation problems that are likelihood-free using the projection approach. Based on the framework of \cite{Ning:2017ee}, \cite{Zheng:2018} studied hypothesis testing for sub-Gaussian VAR models using the de-correlated method. \cite{Basu:2017vr} proposed using the de-biased Lasso estimator to perform inference for high-dimensional sparse VAR models but did not provide rigorous theoretical guarantees. Since the predictors in VAR models are random and exhibit complex correlation structure, it is uncertain whether the de-biased Lasso method is valid and it is challenging to provide theoretical guarantees. \cite{Krampe:2018wf} proposed a model-based bootstrap de-biased Lasso estimator to perform inference, but its computational burden is heavy when the dimension $p$ is large. Moreover, in order to guarantee the required order of sparsity in the bootstrap sample, the study used the thresholded Lasso which is complicated than the Lasso although it is easier for theoretical study. To fill in the theoretical gap of the de-biased Lasso estimator and to address the computation problem of the model-based bootstrap de-biased Lasso estimator, in this study, we formally establish the asymptotic normality of the de-biased Lasso estimator for inferring the elements of the transition matrix of high-dimensional sparse VAR(1) models. Then, we propose two computational feasible bootstrap methods, residual bootstrap de-biased Lasso (BtLDPE) and multiplier wild bootstrap de-biased Lasso (MultiBtLDPE). Our methods can be generalized to VAR($k$) models through transformation. Our contributions are summarized as follows. First, we derive the asymptotic properties of the de-biased Lasso, residual bootstrap de-biased Lasso and multiplier wild bootstrap de-biased Lasso estimators in high-dimensional sparse VAR models by using the deviation bounds of the Lasso estimator \citep{Basu:2015ho} and the martingale central limit theorem (Theorem 5.3.4 in \cite{Fuller:1996wa}). We demonstrate the validity and robustness of these methods for statistical inference in a context broader than linear regression models. As a by-product, we show that the sparse Riesz condition holds for high-dimensional sparse VAR models and provide an upper bound on the sparsity of the Lasso estimator which is essential for obtaining appropriate variance estimators and studying the theoretical properties of bootstrap de-biased Lasso. Second, to implement our methods, we provide algorithms which are feasible and easy to parallel. Specifically, for each of the $p$ equations of the VAR models, we perform statistical inference separately. Since the $p$ equations share the same design matrix, we need only run nodewise lasso once, which is the main computational burden of de-biased Lasso and bootstrap de-biased Lasso. Compared to the model-based bootstrap de-biased Lasso, our methods have significant computational advantages especially when $p$ is large. Third, we conduct comprehensive simulation studies to compare our methods with the bootstrap Lasso, bootstrap Lasso+OLS and another de-biased Lasso method proposed by \cite{Javanmard:2014}. We find that the de-biased Lasso method, the LDPE, can always yield honest coverage probabilities, and when the sample size is large, two bootstrap methods, the BtLDPE and MultiBtLDPE, can yield the honest coverage probabilities with shorter interval lengths. We also apply our methods to analyze the S\&P 500 constituent stocks data set in 2019. We find that the prices of some stocks have significant predictive power over the prices of most stocks, for example, Newmont Corporation, which is the largest producer of gold in the world and the only gold producer listed in the S\&P 500 Index, has the ability to affect many other stock prices in advance. \textbf{Notation}. For a vector $a=(a_1,...,a_n)$, we denote $\|a\|_{1}=\sum_{i=1}^{n}\left|a_{i}\right|$, $\|a\|_{2}^{2}=\sum_{i=1}^{n} a_{i}^{2}$ and $\|a\|_{\infty}= \max_i \left|a_{i}\right|$. We use $e_j$ to denote the vector whose $j$th element is one, zero otherwise. For a square matrix $A$, let $\Lambda_{\rm min}(A)$ and $\Lambda_{\rm max}(A)$ be the smallest and largest eigenvalues of $A$ respectively. Let $|A|$ denote the determinant of $A$. For a design matrix $\mathbf{X}$, let $X_{tj}$ denote the $(t,j)$th element of $\mathbf{X}$, $X_j$ denote the $j$th column of $\mathbf{X}$ and $\mathbf{X}_{-j}$ denote the $\mathbf{X}$ without the $j$th column. Let $||\mathbf{X}||_{\infty}$ denote the maximum absolute value of the elements of $\mathbf{X}$. For a set $S$, let $|S|$ denote the number of elements of $S$ and $\mathbf{X}_S$ denote the selected columns of $\mathbf{X}$ in $S$. We use i.i.d as the abbreviation of independent and identically distributed. Let $z_\alpha$ denotes the lower $\alpha$ quantile of the standard normal distribution. For two sequences of positive numbers $\{a_n\}$ and $\{b_n\}$, we denote $a_n=o(b_n)$ if $a_{n} / b_{n} \rightarrow 0$ as $n \rightarrow \infty$ and $a_n=O(b_n)$ if $\limsup \left|a_{n} / b_{n}\right|<\infty$. We denote $a_{n} \asymp b_{n}$ if there exist positive constants $C_1,C_2>0$ such that $\limsup \left|a_{n} / b_{n}\right|\leq C_1$ and $\liminf \left|a_{n} / b_{n}\right|\geq C_2$. We denote $Z_n=o_p(1)$ if $Z_n$ convergent to zero in probability and $Z_n=O_p(1)$ if $Z_n$ is bounded in probability. The rest of the paper is organized as follows. In Section 2, we introduce the high-dimensional sparse VAR models and the de-biased Lasso, residual bootstrap de-biased Lasso and multiplier wild bootstrap de-biased Lasso methods. In Section 3, we provide theoretical results, including the upper bound of the number of selected variables by the Lasso estimator and the asymptotic normality of the proposed estimators. In Section 4, simulation studies are provided for investigating the finite-sample performance of different methods. In Section 5, we illustrate our method using the S\&P 500 constituent stocks data set. We summarize the results and discuss possible extensions in the last section. Proof details are given in the supplementary material. \section{Methods} \label{sec:method} In this section, we first introduce the high-dimensional sparse VAR models. Consider a $p$-dimensional VAR(1) model, \begin{equation}\label{eq:VAR} \mathbf{y}_t = A\mathbf{y}_{t-1} + \mathbf{e}_t,\quad t=1,...,n, \end{equation} where $\mathbf{y}_t=({y}_{1t},...,{y}_{pt})^{\T}$ is a $p$-dimensional random vector, $A=(a_{ij})_{p \times p}$ is a $p \times p$ transition matrix and $\mathbf{e}_t=({e}_{1t},...,{e}_{pt})^{\T}$ is a $p$-dimensional Gaussian white noise, namely, $\mathbf{e}_t$ is independently and identically distributed in multivariate Gaussian distribution $\mathcal{N}_p (\mathbf{0},\Sigma_\mathbf{e})$. We assume that the VAR process $\{\mathbf{y}_t\}$ is stable, namely, $\Lambda_{\rm max}(A)<1$. We have $n$ observations of $\mathbf{y}_t$ and $n$ may be smaller than $p$. There are $p$ equations, corresponding to $p$ components of $\mathbf{y}_t$, in the VAR(1) model. We consider each of the $p$ equations separately, \begin{equation*} y_{it} = a_i^{\T}\mathbf{y}_{t-1} + {e}_{it},\quad i=1,...,p,\quad t=1,...,n, \end{equation*} where $a_i=(a_{i1},...,a_{ip})$ is the $i$th row of $A$ and we denote the support set of $a_i$ by $S_i=\{j\in \{1,...,p\}:a_{ij}\ne0\}$ and let $s_{i}=|S_i|$. To gather all observations, we denote \begin{equation} \label{eqn:var1} Y_{i} = \mathbf{X} a_i + {\varepsilon}_{i},\quad i=1,...,p, \end{equation} where $Y_{i}=({y}_{i1},...,{y}_{in})^{\T}$, $\mathbf{X}=(\mathbf{y}_0,...,\mathbf{y}_{n-1})^{\T}$ and $\varepsilon_i=(e_{i1},...,e_{in})^{\T}$. The denotation is to distinguish them from $\mathbf{y}_t$ and $\mathbf{e}_t$. Although equation \eqref{eqn:var1} violates the basic assumptions of linear regression models, it has the same form. Thus, we can apply the de-biased Lasso and bootstrap de-biased Lasso original proposed for linear regression models to construct confidence intervals for $a_i$'s, with caution that these methods may not be valid. \subsection{De-biased Lasso} \label{sec:dbl} The Lasso is widely used for simultaneous parameter estimation and model selection in high-dimensional linear regression models \citep{Tibshirani:1996}, which adds an $l_1$ penalty to the loss function to obtain sparse estimates. \cite{Hsu:2008} proposed to use the Lasso estimator in VAR models, \begin{equation}\label{eq:lasso} \hat a^{\rm Lasso}_{i} := \mathop{{\rm argmin}}\limits_{\alpha\in \mathbb{R}^p}\{ ||Y_i - \mathbf { X } \alpha||_2^2/n + 2\lambda||\alpha||_1\},\quad i=1,...,p, \end{equation} where $\lambda$ is the tuning parameter which controls the amount of regularization. In practice, $\lambda$ is often chosen by cross-validation. We denote the set of selected variables by $\hat S_i:=\{j\in \{1,...,p\}:\hat a^{\rm Lasso}_{ij}\ne0\}$ and let $\hat s_{i}:=|\hat S_i|$. The Lasso estimator is hard to use directly for statistical inference due to its bias. \cite{Zhang:2014} and \cite{vandeGeer:2014} proposed the de-biased Lasso method for construct confidence intervals, which proceeds as follows. The Lasso estimator in (\ref{eq:lasso}) satisfies the Karush-Kuhn-Tucker (KKT) conditions, \begin{equation}\label{eq:KKT-1} -\mathbf { X } ^ {\T } ( Y_i - \mathbf { X } \hat { a }^{\rm Lasso}_i ) / n +\lambda \hat { \kappa }=0, \end{equation} where $\hat { \kappa }$ is the sub-gradient of $\ell_1$ norm and satisfies $\|\hat { \kappa }\|_\infty\leq 1$ and $\hat { \kappa }_j=\operatorname { sign } ( \hat { a } ^{\rm Lasso}_ { ij } )$ if $\hat { a }^{\rm Lasso} _ {i j } \neq 0$. By $Y_{i} = \mathbf{X} a_i + {\varepsilon}_{i}$ and $\hat { \Sigma } := \mathbf { X } ^ {\T } \mathbf { X } / n$, we obtain \begin{equation}\label{eq:KKT-2} \hat { \Sigma } ( \hat { a }^{\rm Lasso}_i - a_i ) + \lambda \hat { \kappa } = \mathbf { X } ^ {\rm T } \varepsilon_i / n. \end{equation} With $\Sigma:=E(\hat\Sigma)=E(\mathbf{y}_{t-1}\mathbf{y}_{t-1}^{\T})$, if we have a proper approximation for the precision matrix $\Theta:=\Sigma^{-1}$, say $\hat\Theta$, then multiplying both hand sides of (\ref{eq:KKT-2}) by $\hat\Theta$, we obtain \begin{equation}\label{eq:KKT-3} \hat { a }^{\rm Lasso}_i - a_i + \hat\Theta\lambda \hat { \kappa } = \hat\Theta\mathbf { X } ^ {\rm T } \varepsilon_i / n + (I-\hat\Theta\hat { \Sigma })(\hat { a }^{\rm Lasso}_i - a_i) . \end{equation} The de-biased Lasso estimator is $$ \hat a_i:=\hat { a }^{\rm Lasso}_i + \hat\Theta\lambda \hat { \kappa } = \hat { a }^{\rm Lasso}_i + \hat\Theta\mathbf { X } ^ {\T } ( Y_i - \mathbf { X } \hat { a }^{\rm Lasso}_i ) / n, $$ where the second equality is due to (\ref{eq:KKT-1}). Intuitively, as long as we can prove that the first term of the right-hand of (\ref{eq:KKT-3}) is asymptotically normal with mean zero and the second term is asymptotically negligible, then with a consistent estimator of the variance of $\varepsilon_i$, we can perform inference for $a_i$. Following \cite{Zhang:2014} and \cite{vandeGeer:2014}, we get $\hat\Theta$ by nodewise Lasso \citep{Meinshausen:2006kb}. Specifically, for $j=1,...,p$, we run a Lasso regression of $X_j$ versus $\mathbf{X}_{-j}$, \begin{equation}\label{eq:nodelasso} \hat{\gamma}_j := \mathop{{\rm argmin}}\limits_{\gamma\in \mathbb{R}^{p-1}}\{ ||X_j-\mathbf{X}_{-j}\gamma||_2^2/n + 2\lambda_j||\gamma||_1\}, \end{equation} where $\lambda_j$ is the tuning parameter. Note that $\hat{\gamma}_j$ with the components of $\{\hat{\gamma}_{jk};k=1,...,p,k\ne j\}$ is an estimator of $\gamma_{j}:=\Sigma_{-j,-j}^{-1}\Sigma_{-j,j}$, where $\Sigma_{-j,-j}$ is the covariance matrix of $\mathbf{X}_{-j}$ and $\Sigma_{-j,j}$ is the covariance matrix of $\mathbf{X}_{-j}$ and $X_j$. We denote the sparsity of $\gamma_{j}$ by $q_j:=|\left\{ k\neq j : \gamma _ { jk } \neq 0 \right\}|$. We further denote \begin{gather*} \hat{C}:= \left[ \begin{matrix} 1 & -\hat{\gamma}_{12} & \cdots & -\hat{\gamma}_{1p} \\ -\hat{\gamma}_{21} & 1 & \cdots & -\hat{\gamma}_{2p} \\ \vdots & \vdots & \ddots & \vdots \\ -\hat{\gamma}_{p1} & -\hat{\gamma}_{p2} & \cdots &1 \end{matrix} \right], \\ \hat{\tau}_{j}^{2}:=\left\|X_{j}-\mathbf{X}_{-j} \hat{\gamma}_{j}\right\|_{2}^{2} / n+\lambda_{j}\left\|\hat{\gamma}_{j}\right\|_{1}, \quad \hat { T } ^ { 2 } : = \operatorname { diag } ( \hat { \tau } _ { 1 } ^ { 2 } , \ldots , \hat { \tau } _ { p } ^ { 2 } ). \end{gather*} Then we get \begin{equation}\label{eq:nodelasso3} \hat { \Theta } : = \hat { T } ^ { - 2 } \hat { C }. \end{equation} \cite{Javanmard:2014} uses a different approach to obtain $\hat\Theta$. We do not adopt their approach because of its inferior finite-sample performance as shown in the simulation section. According to the discussion in \cite{Reid:2016es}, we estimate the variance of $\varepsilon_i$, say $\sigma^2_i$, by the residual sum of squares of the Lasso estimator divided by its degree of freedom, \begin{equation}\nonumber \hat { \sigma } _ { i } ^ { 2 } := \frac { 1 } { n - \hat { s }_{i} } \| \hat \varepsilon_i \| _ { 2 } ^ { 2 }, \end{equation} where \begin{equation*} \hat \varepsilon_i = (\hat \varepsilon_{i1},...,\hat \varepsilon_{in} )^{\T}:=Y_i-\mathbf { X }\hat { a }^{\rm Lasso}_i. \end{equation*} The procedure of nodewise Lasso requires to compute the Lasso solution path for $p$ times, which is the main computation burden of the de-biased Lasso. Fortunately, for different variable $i=1,...,p$, we need only to compute $\hat { \Theta }$ once since the $p$ equations share the same $\mathbf{X}$. The whole procedures is summarized in Algorithm \ref{alg:dbl}, where every \code{for} loop could be ran in parallel. \begin{algorithm}[ht] \caption{Construction of confidence intervals by the de-biased Lasso} \label{alg:dbl} \SetAlgoLined \textbf{Input} Data $\{\mathbf{y}_t\}, t=0,...,n$; Confidence level $1-\alpha$. \textbf{Output} Confidence intervals for elements of transition matrix $A$ in VAR models. \For {$j=1,...,p$} { Compute the nodewise Lasso estimator $\hat\gamma_j$ and residuals $\hat{Z}_{j}=X_{j}-\mathbf{X}_{-j} \hat{\gamma}_{j}$\; } Compute the $\hat\Theta$ in (\ref{eq:nodelasso3})\; \For {$i=1,...,p$}{ Compute the Lasso estimator $\hat a_i^{\rm Lasso}$ given the data $(Y_i,\mathbf{X})$\; Compute the de-biased Lasso estimator $\hat a_i = \hat { a }^{\rm Lasso}_i + \hat\Theta\mathbf { X } ^ {\T } ( Y_i - \mathbf { X } \hat { a }^{\rm Lasso}_i ) / n$, residuals $\hat \varepsilon_i =Y_i-\mathbf { X }\hat { a }^{\rm Lasso}_i$, and variance estimator $\hat { \sigma } _ { i } ^ { 2 } = \| \hat \varepsilon_i \| _ { 2 } ^ { 2 }/( n - \hat { s }_{i} )$\; \For {$j=1,...,p$}{ Compute $l_{ij}=\hat a_{ij}-z_{1-\alpha/2} \hat \sigma _ { i } \| \hat Z _ { j } \| _ { 2 } /|\hat Z _ { j } ^ {\T } X _ { j } | $ and $u_{ij}=\hat a_{ij}-z_{\alpha/2} \hat \sigma _ {i} \| \hat Z _ { j } \| _ { 2 }/|\hat Z _ { j } ^ {\T } X _ { j } | $\; } } \textbf{Return} $1-\alpha$ confidence interval $[l_{ij},u_{ij}]$ for $a_{ij}$, $i,j=1,...,p$. \end{algorithm} \subsection{Bootstrap de-biased Lasso} \label{sec:resBt} \begin{algorithm} \caption{Construction of confidence intervals by bootstrap de-biased Lasso} \label{alg:bdbl} \SetAlgoLined \textbf{Input} Data $\{\mathbf{y}_t\}, t=0,...,n$; Confidence level $1-\alpha$; Bootstrap type (residual bootstrap or wild multiplier bootstrap); Number of bootstrap replications $B$. \textbf{Output} Confidence intervals for elements of transition matrix $A$ in VAR models. \For {$j=1,...,p$} { Compute the nodewise Lasso estimator $\hat\gamma_j$ and residuals $\hat{Z}_{j}=X_{j}-\mathbf{X}_{-j} \hat{\gamma}_{j}$\; } Compute the $\hat\Theta$ in (\ref{eq:nodelasso3})\; \For {$i=1,...,p$} { Compute the Lasso estimator $\hat a_i^{\rm Lasso}$ given the data $(Y_i,\mathbf{X})$\; Compute the de-biased Lasso estimator $\hat a_i = \hat { a }^{\rm Lasso}_i + \hat\Theta\mathbf { X } ^ {\T } ( Y_i - \mathbf { X } \hat { a }^{\rm Lasso}_i ) / n$, residual $\hat \varepsilon_i =Y_i-\mathbf { X }\hat { a }^{\rm Lasso}_i$, and variance estimator $\hat { \sigma } _ { i } ^ { 2 } = \| \hat \varepsilon_i \| _ { 2 } ^ { 2 }/( n - \hat { s }_{i} )$\; \For {$b=1,...,B$} { \uIf {Bootstrap type $==$ residual bootstrap} { Resample with replacement from the centered residuals $\{\hat \varepsilon_{ij} - \hat\varepsilon_{i\cdot}\}$ and obtain the bootstrap residuals $\varepsilon^*_i=(\varepsilon^*_{i1},...,\varepsilon^*_{in})^{\T}$\; } \uElseIf {Bootstrap type $==$ wild multiplier bootstrap} { Generate i.i.d multiplier $W _ {i 1 } , \ldots , W _ {i n }$ with $E(W _ { ij }) = 0$, $E( W _ { ij } ^ { 2 }) = 1$ and $E (W _ { ij } ^ { 4 }) < \infty$. Then we obtain $\varepsilon _ { ij } ^ { * } = W _ { ij }( \varepsilon_{ij} - \hat\varepsilon_{i\cdot})$\; } Generate bootstrap samples $Y_i ^ { * } = \mathbf { X } \hat {a}_i + \varepsilon _i^ { * }$\; Compute the Lasso estimator $\hat a_i^{\rm Lasso*}$ given the bootstrap data $(Y_i^*,\mathbf{X})$\; Compute $\hat a_i^* = \hat { a }^{\rm Lasso*}_i + \hat\Theta\mathbf { X } ^ {\T } ( Y^*_i - \mathbf { X } \hat { a }^{\rm Lasso*}_i ) / n$, $\hat \varepsilon_i^* =Y_i^*-\mathbf { X }\hat { a }^{\rm Lasso*}_i$, and $\hat { \sigma } _ { i } ^ { *2 } = \| \hat \varepsilon^*_i \| _ { 2 } ^ { 2 }/( n - \hat { s }^*_{i} )$\; Compute the pivot $T^{*(b)}$ with $T^{*(b)}_{ij}=(\hat a_{ij}^*-\hat a^{\rm Lasso*}_{ij})|\hat Z _ { j } ^ {\T } X _ { j } | / (\hat \sigma ^*_ { i} \| \hat Z _ { j } \| _ { 2 })$\; } \For {$j=1,...,p$} { Let $l_{ij}=\hat a_{ij}-q_{1-\alpha/2} \hat \sigma _ { i } \| \hat Z _ { j } \| _ { 2 } /|\hat Z _ { j } ^ {\T } X _ { j } | $ and $u_{ij}=\hat a_{ij}-q_{\alpha/2} \hat \sigma _ {i} \| \hat Z _ { j } \| _ { 2 }/|\hat Z _ { j } ^ {\T } X _ { j } |$, where $q_{\alpha}$ denotes the lower $\alpha$ quantile of $\{T^{*(1)}_{ij},...,T^{*(B)}_{ij}\}$\; } } \textbf{Return} $1-\alpha$ confidence interval $[l_{ij},u_{ij}]$ for $a_{ij}$, $i,j=1,...,p$. \end{algorithm} In this section, we introduce the residual bootstrap de-biased Lasso and wild multiplier bootstrap de-biased Lasso proposed in \cite{Dezeure:2017jla}. The only difference of these two bootstrap methods is the approach to generate bootstrap residuals. For residual bootstrap, we resample with replacement from the centered residuals $\{\hat \varepsilon_{it} - \hat\varepsilon_{i\cdot},t=1,2,...n\}$, where $\hat\varepsilon_{i\cdot}:=\sum_{t=1}^{n}\hat \varepsilon_{it}/n $, and obtain the bootstrap residuals $\varepsilon^*_i=(\varepsilon^*_{i1},...,\varepsilon^*_{in})^{\T}$. For wild multiplier bootstrap, we generate i.i.d multiplier $W _ {i 1 } , \ldots , W _ {i n }$ with $E(W _ { it }) = 0$, $E( W _ { it } ^ { 2 }) = 1$ and $E (W _ { it } ^ { 4 }) < \infty$, for example, $W_{it}\sim \mathcal{N}(0,1)$, which is independent of the original data. Then we multiply the centered residuals by multiplier as $\varepsilon _ { it } ^ { * } = W _ { it }( \varepsilon_{it} - \hat\varepsilon_{i\cdot})$, and obtain the bootstrap residuals $\varepsilon^*_i=(\varepsilon^*_{i1},...,\varepsilon^*_{in})^{\T}$. Next, the bootstrap sample are generated as \begin{equation*} Y_i ^ { * } = \mathbf { X } \hat {a}_i + \varepsilon _i^ { * }. \end{equation*} Then we can replace the original sample $(Y_i,\mathbf { X })$ by the bootstrap sample $(Y^*_i,\mathbf { X })$ to compute the corresponding quantities for the de-biased Lasso. For example, the bootstrap version de-biased Lasso estimator is obtained by \begin{equation*} \hat a_i^* := \hat { a }^{\rm Lasso*}_i + \hat\Theta\mathbf { X } ^ {\T } ( Y_i^* - \mathbf { X } \hat { a }^{\rm Lasso*}_i ) / n, \end{equation*} where $\hat { a }^{\rm Lasso*}_i$ is the bootstrap version Lasso estimator and defined by \begin{equation} \hat a^{\rm Lasso*}_{i} := \mathop{{\rm argmin}}\limits_{\alpha\in \mathbb{R}^p}\{ ||Y_i^* - \mathbf { X } \alpha||_2^2/n + 2\lambda^* ||\alpha||_1\}, \nonumber \end{equation} where $\lambda^*$ is the tuning parameter. Note that, one can use different tuning parameters in the original and bootstrap Lasso estimators. Our simulation results indicate that using the same tuning parameters often performs well. We also denote the set of selected variables by $\hat S_i^*:=\{j\in \{1,...,p\}:\hat a^{\rm Lasso*}_{ij}\ne0\}$ and let $\hat s_{i}^*:=|\hat S_i^*|$. For both of bootstrap procedures above, we have $E^*(\varepsilon _ { it } ^ { * } )=0$ and $\sigma^{*2}_i:=E^*(\varepsilon _ { it } ^ { * 2 } )=\sum_{t=1}^{n}(\hat \varepsilon_{it}-\hat\varepsilon_{i\cdot})^2/n$, where $E^*$ indicates the expectation is with respect to the bootstrap measure. Similarly, we estimate $\sigma^{*2}_i$ by $\hat { \sigma } _ { i } ^ { *2 } := \| \hat \varepsilon^*_i \| _ { 2 } ^ { 2 }/( n - \hat { s }^*_{i} )$, where $\hat \varepsilon_i^*:=Y_i^*-\mathbf { X }\hat { a }^{\rm Lasso*}_i$. We repeat the above procedure $B$ times to obtain the empirical distribution of the statistics of interest. Quantities determined by $\mathbf{X}$, such as $\hat\Theta$, do not need to be re-computed in the bootstrap replications, since $\mathbf{X}$ is the same in every bootstrap sample. This is the most significant advantage of our bootstrap methods over the model-based bootstrap method \citep{Krampe:2018wf}, which will regenerate the entire time series $\{\mathbf{y}_t\}$. Such bootstrap time series will not share the same $\mathbf{X}$, leading to the computations of $\hat\Theta$ for $B$ times, which is usually not feasible in practice for relatively large $p$. Furthermore, we will show that our two bootstrap de-biased Lasso methods are consistent even though they ignore the dependence structure of VAR models. In all, in order to make the bootstrap de-biased Lasso methods feasible, we save the computation cost of $\hat\Theta$ on two folds. First, once we obtain $\hat\Theta$, we do not need to compute $\hat\Theta$ for the $p$ equations in VAR models; second, we do not need to compute $\hat\Theta$ for $B$ bootstrap replications. The whole procedure is summarized in Algorithm \ref{alg:bdbl}, where every \code{for} loop could be also ran in parallel. \section{Theoretical results} \label{sec:theo} In this section we discuss the theoretical properties of the de-biased Lasso and the bootstrap de-biased Lasso. Different from the fixed design matrix case in linear regression models, the design matrix in equation \eqref{eqn:var1} of VAR models is random, exhibits complex dependence structure, and is correlated with $\varepsilon_i$, that is, equation \eqref{eqn:var1} does not justify the assumptions of linear regression models. However, we can still obtain their asymptotic normality under appropriate conditions, using the deviation bound of the Lasso estimator in high-dimensional sparse VAR models \citep{Basu:2015ho} and the martingale central limit theorem (Theorem 5.3.4 in \cite{Fuller:1996wa}). \subsection{Asymptotic distribution of the de-biased Lasso} \label{sec:dbl-th} We first introduce the following three assumptions. \begin{assumption}\label{ap:lambda} Suppose that the tuning parameters for the Lasso and nodewise Lasso satisfy: $\lambda\asymp \sqrt{\log(p)/n}$ and $\lambda_j\asymp \sqrt{\log(p)/n}$. \end{assumption} \begin{assumption}\label{ap:s0} $\max _i s_{i}\log(p)/\sqrt{n}=o (1)$. \end{assumption} \begin{assumption}\label{ap:sj} $\max_jq_j\log(p)/\sqrt n=o(1)$. \end{assumption} Assumption \ref{ap:lambda} requires that the convergence rates of the tuning parameters are of order $\sqrt{\log(p)/n}$. Assumption \ref{ap:s0} is a sparsity assumption on each row of the transition matrix $A$, which is commonly assumed in statistical inference based on the de-biased Lasso methods. These two assumptions are the same as the counterparts in \cite{vandeGeer:2014}. The sparsity assumption on the presicion matrix, Assumption \ref{ap:sj}, is a little stronger than that in \cite{vandeGeer:2014}. We need this assumption because of the complicated dependence structure in VAR models. \begin{proposition}\label{prop:Riesz} Under Assumption \ref{ap:s0}, for $i=1,...,p$, there exist constants $0< c_*<c^*<\infty$, such that, for $s_R>(2 + 2c^*/c_*)s_{i}+1$ and $s_R=O(s_{i})$, the following holds with probability converging to 1: \begin{equation} c_{*} \leq \min _{\|v\|_0\le s_R} \min _{\|v\|_2=1}\left\|\mathbf{X} v\right\|^{2}_2 / n \leq \max _{\|v\|_0\le s_R} \max _{\|v\|_2=1}\left\|\mathbf{X} v\right\|^{2}_2 / n \leq c^{*}. \nonumber \end{equation} \end{proposition} Proposition \ref{prop:Riesz} states that $\mathbf{X}$ satisfies the sparse Riesz condition \citep{Zhang:2008ga}, which bounds the extreme eigenvalues of $\mathbf{X}^\T\mathbf{X}/n$ in a sparse space. \cite{Basu:2015ho} has obtained the lower bound in the sparse Riesz condition and we complement their result by providing the upper bound. The sparse Riesz condition is crucial for proving the conclusion (b) of Theorem \ref{thm:Lasso} below. \begin{theorem}\label{thm:Lasso} For $i=1,...,p$, \\ (a) Under Assumptions \ref{ap:lambda} and \ref{ap:s0}, we have \begin{gather} || \hat a^{\rm Lasso}_{i}- a_i || _ { 1 } = O_p(s_{i}\sqrt{\log (p)/n}), \nonumber \\ ||\mathbf{X}(\hat a^{\rm Lasso}_{i}- a_i )||_2^2/n=O_p(s_{i}\log (p)/n). \nonumber \end{gather} (b) Under Assumption \ref{ap:s0}, for any $\lambda\geq 4C_1c^*/c_*\sqrt{\log p/n}$, where $C_1$ is a constant defined in the supplementary material, we have $$ \hat s_{i}=O_p( s_{i} ). $$ \end{theorem} The first statement of Theorem~\ref{thm:Lasso} provides the estimation and prediction error bounds for the Lasso estimator, which has been established by \cite{Basu:2015ho}. The second statement (b) provides an upper bound on the sparsity of the Lasso estimator. This bound has been obtained under high-dimensional sparse linear regression models \citep{Zhang:2008ga}. Theorem~\ref{thm:Lasso} (b) extends the result to high-dimensional sparse VAR models. It is essential for proving the consistency of the variance estimator in the following Theorem \ref{thm:dbl} and for showing the validity of the bootstrap de-biased Lasso, especially the latter, since it requires the sparsity of $\hat a^{\rm Lasso}_{i}$. Propositions 4.1 in \cite{Basu:2015ho} provided a similar bound, but for a thresholded variant of the Lasso. \begin{proposition}\label{prop:nodelasso} Under Assumptions \ref{ap:lambda} and \ref{ap:sj}, for $j=1,...,p$, we have \begin{gather} \| \hat { \gamma } _ { j } - \gamma _ { j } \| _ { 1 } = O_p \left(q _ { j }\sqrt{\log p/n}\right),\nonumber \\ \| \mathbf { X } _ { - j } \left( \hat { \gamma } _ { j } - \gamma _ { j } \right) \| _ { 2 } ^ { 2 } / n = O_p \left(q _ { j } { \log p/n}\right).\nonumber \end{gather} \end{proposition} Proposition \ref{prop:nodelasso} provides the estimation and prediction error bounds for the nodewise Lasso estimator defined in (\ref{eq:nodelasso}). \begin{theorem}\label{thm:dbl} Under Assumptions \ref{ap:lambda}, \ref{ap:s0} and \ref{ap:sj}, the de-biased Lasso estimator is asymptotically normal, that is, \begin{equation*} (\hat a_{ij}- a_{ij}) /s.e._{ij}\stackrel { d } { \rightarrow } \mathcal{N}(0,1), \quad i,j=1,...,p, \end{equation*} where \begin{equation*} s.e. _{ij} = \frac { \sigma _ {i} \| \hat Z _ { j } \| _ { 2 } } {|\hat Z _ { j } ^ {\T } X _ { j } | }. \end{equation*} Furthermore, \begin{equation*} \hat\sigma _ { i }/\sigma _ {i }\stackrel { P } { \rightarrow } 1,\quad i=1,...,p. \end{equation*} \end{theorem} \begin{remark} The asymptotic normality of the de-biased Lasso is also proven in Theorem 3.4 in \cite{Zheng:2018}. They propose $\sum_{i=1}^p\| \hat \varepsilon_i \| _ { 2 } ^ { 2 }/ (np)$ as a consistent variance estimator of $\varepsilon_i$. \end{remark} Theorem \ref{thm:dbl} shows that the de-biased Lasso estimator is asymptotically normal and its asymptotic variance can be estimated consistently. Thus, we can construct an asymptotically valid confidence interval for each element of $A$, $a_{ij}$, by using normal approximation. \subsection{Asymptotic distribution of the bootstrap de-biased Lasso} \label{sec:bdbl-th} \begin{assumption}\label{ap:lambda_bt} Suppose that the tuning parameters for the Lasso, nodewise Lasso, and bootstrap Lasso satisfy: $\lambda \asymp \sqrt{\log(p)/n}$, $\lambda_j \asymp \sqrt{\log(p)/n}$, and $\lambda^* \asymp \log p/\sqrt{n}$. \end{assumption} \begin{assumption}\label{ap:s0_bt} $s_{i}(\log p)^{3/2}/\sqrt{n}=o (1), i=1,...,p$. \end{assumption} Assumptions~\ref{ap:lambda_bt} and \ref{ap:s0_bt} require stronger convergence rates compared to those in \cite{Dezeure:2017jla} used to obtain the asymptotic distribution of the bootstrap de-biased Lasso in high-dimensional sparse linear regression models. However, \cite{Dezeure:2017jla} assumed that $\|\mathbf{X}\|_\infty=O(1)$, which does not hold for the random design matrix in VAR models. In fact, we can only show that $\|\mathbf{X}\|_\infty=O_p(\sqrt{\log pn} )$. This is why we require stronger conditions on the sparsity and tuning parameters of the bootstrap Lasso estimator. \begin{theorem}\label{thm:BtLasso} For $i=1,...,p$, \\ (a) Under Assumptions \ref{ap:lambda_bt} and \ref{ap:s0_bt}, we have \begin{gather} ||\hat a^{\rm Lasso*}_{i}-\hat { a }^{\rm Lasso}_{i} || _ { 1 } = O_p(s_{i}\log (p)/\sqrt{n}), \nonumber \\ ||\mathbf{X}(\hat a^{\rm Lasso*}_{i}-\hat { a }^{\rm Lasso}_{i} )||_2^2/n=O_p(s_{i}\log^2 (p)/n). \nonumber \end{gather} (b) Under Assumption \ref{ap:s0_bt}, for any $\lambda^*\geq 4C_2 c^*/c_*\sqrt{\log (p)/n}$, where $C_2$, $c^*$ and $c_*$ are constants defined in the supplementary material, we have $$ \hat s^*_{i}=O_p( s_{i} ), $$ where $\hat s^*_{i}=|\{j\in \{1,...,p\}:\hat a^{\rm Lasso*}_{ij}\ne0\}|$. \end{theorem} Theorem~\ref{thm:BtLasso} is the bootstrap analogue of Theorem~\ref{thm:Lasso}. The different convergence rates in statement (a) are due to Assumption \ref{ap:lambda_bt}. \begin{theorem}\label{thm:bdbl} Under Assumptions \ref{ap:sj} -- \ref{ap:s0_bt}, the bootstrap de-biased Lasso estimators are asymptotically normal, that is, \begin{equation*} (\hat{a}_{ij}^*-\hat { a }^{\rm Lasso}_{ij} ) /s.e.^*_{ij}\stackrel { d^* } { \rightarrow } \mathcal{N}(0,1) \; \text{in probability},\quad i,j=1,...,p, \end{equation*} where $\hat{a}_{ij}^*$ denotes either residual or multiplier wild bootstrap de-biased Lasso estimators, \begin{equation*} s.e. ^*_{ij} = \frac { \sigma ^*_ { i } \| \hat Z _ { j } \| _ { 2 } } {|\hat Z _ { j } ^ {\T } X _ { j } | }, \end{equation*} and $d^*$ indicates the convergence is with respect to the bootstrap measure. Furthermore, \begin{equation*} \hat\sigma^* _ { i }/\sigma^* _ { i }\stackrel { P ^*} { \rightarrow } 1\; \text{in probability},\quad i=1,...p. \end{equation*} \end{theorem} Theorems \ref{thm:dbl} and \ref{thm:bdbl} imply that the conditional distributions of both residual and multiplier wild bootstrap de-biased Lasso estimators are valid approximations to the (unconditional) distribution of the de-biased Lasso estimator. Thus, we could perform valid inference about $a_{ij}$'s using the bootstrap. \section{Simulation studies} \label{sec:sim} We evaluate the finite-sample performance of the proposed methods by simulation studies in this section. We compare the methods with the bootstrap Lasso/Lasso+OLS and another de-biased Lasso method, JM \citep{Javanmard:2014}, in terms of bias, root mean squared error (RMSE), coverage probabilities and mean confidence interval lengths. We use \code{R} package \code{hdi} to implement the de-biased Lasso, residual bootstrap de-biased Lasso and multiplier wild bootstrap de-biased Lasso, \code{R} package \code{HDCI} to implement the bootstrap Lasso and bootstrap Lasso+OLS, and \code{R} code provided by \cite{Javanmard:2014} to implement their version of de-biased Lasso. The tuning parameters are selected by 10-fold cross-validation. We set the number of bootstrap replications $B=500$. \subsection{Setups} With sample size $n= 100,300$, dimension $p=200$ and sparsity $s_{i}=5, 10$ for $i=1,...,p$, we first generate transition matrix $A$ as follows. \begin{enumerate} \item We generate $s_{i}\times p$ non-zero parameters independently from a uniform distribution on $[-1,-0.5]\cup[0.5,1]$; \item On each row of $A^{init}$, we set the diagonal element to be non-zero and randomly arrange the other $s_{i}-1$ non-zero parameters on the other positions; \item Since the largest modulus of eigenvalues of $A^{init}$ may greater than 1, in order to make time series stable, we let $$ A=\frac{0.9}{\Lambda_{\rm max}(A^{init})}{A^{init}}. $$ \end{enumerate} The third step makes the maximum eigenvalue of $A$ equals to $0.9$. We also try to let $\Lambda_{\rm max}(A)=0.7$ and the results are similar. Unlike in linear regression models we can arbitrarily set the range of the absolute value of the non-zero parameters, the third step will make the absolute value of each parameter small, no matter how large the non-zero parameters are generated in the first step. In our simulation, when $s_{i}$ equals $5$ and $10$, the ranges of the absolute values of elements of $A$ are $(0.23,0.46)$ and $(0.17,0.34)$ respectively. The smaller absolute values of the parameters implies that the de-biased Lasso will outperform the bootstrap Lasso/Lasso+OLS since the validity of the latter usually requires the ``beta-min'' condition (all nonzero parameters are sufficiently large in absolute values) while the former does not. We generate data $\{\mathbf{y}_1,...,\mathbf{y}_n\}$ from VAR model (\ref{eq:VAR}) with \begin{enumerate} \item homoscedastic Gaussian errors $\mathbf{u}_t = \mathbf{\xi}_t$; \item homoscedastic non-Gaussian errors $\mathbf{u}_t = (\xi_t^2 - 1)/\sqrt{2}$; \item heteroscedastic Gaussian errors $\mathbf{u}_t = \eta_t\,\xi_t$; \item heteroscedastic non-Gaussian errors $\mathbf{u}_t = \eta_t(\xi_t^2 - 1)/\sqrt{2}$, \end{enumerate} where $\mathbf{\xi}_t \stackrel{i.i.d} \sim\mathcal{N}_p (\mathbf{0},I)$ and $\eta_t\stackrel{i.i.d}\sim U(1,3)$. Note that the first type of errors satisfies our theoretical assumptions while the other three are not, which are used to explore the robustness of our methods to the distributions of errors. For homoscedastic Gaussian errors with different $n$ and $s_{i}$, there are four cases in total and the results will be showed in Section \ref{sec:homo-sim-est} and Section \ref{sec:homo-sim-ci}. For the other three types of errors, since we set $n=100$ and $s_{i}=5$, there are three cases in total and the results will be discussed in Section \ref{sec:heter-sim}. For every case, we generate 1000 sets of data in order to evaluate the repeated sampling performance of different methods. We only report the results with respect to the first row of $A$ since the conclusions for other rows are similar. \begin{figure}[t] \centering \includegraphics[scale=0.8]{fig/bias1.pdf}\par \caption{Comparison of absolute bias for 1000 replications produced by four methods (columns) in four cases (rows). Index on the $x$-axis corresponds to different $a_{1j}$'s, which are arranged from small to large in absolute values. The first $p-s_1$ elements of $a_{1j}$'s are zeros (blue points) and the last $s_1$ are non-zeros (red points). The black lines are total averages of absolute bias for zero and non-zero parameters respectively.} \label{fig:bias} \end{figure} \begin{figure}[t] \centering \includegraphics[scale=0.8]{fig/RMSE1.pdf}\par \caption{Comparison of RMSE for 1000 replications produced by four methods (columns) in four cases (rows). Index on the $x$-axis corresponds to different $a_{1j}$'s, which are arranged from small to large in absolute values. The first $p-s_1$ elements of $a_{1j}$'s are zeros (blue points) and the last $s_1$ are non-zeros (red points). The black lines are total averages of absolute RMSE for zero and non-zero parameters respectively.} \label{fig:RMSE} \end{figure} \subsection{Comparison of bias and RMSE} \label{sec:homo-sim-est} \begin{table}[ht] \centering \caption{Average absolute bias and RMSE} \label{tab:bias} \begin{tabular}{rrlrrrr} \hline \multicolumn{1}{l}{n} & \multicolumn{1}{l}{s} & $a_{ij}$ & \multicolumn{1}{l}{Lasso} & \multicolumn{1}{l}{Lasso+OLS} & \multicolumn{1}{l}{LDPE} & \multicolumn{1}{l}{JM} \\ \hline &&&\multicolumn{4}{c}{Average absolute bias}\\ \cline{4-7} 100 & 5 & non-zero & 0.1228 & 0.0719 & 0.02 & 0.0378 \\ 100 & 5 & zero & 0.001 & 0.0009 & 0.0122 & 0.0062 \\ 100 & 10 & non-zero & 0.1174 & 0.0902 & 0.0215 & 0.0463 \\ 100 & 10 & zero & 0.0019 & 0.0021 & 0.0175 & 0.0104 \\ 300 & 5 & non-zero & 0.0631 & 0.0058 & 0.0066 & 0.0068 \\ 300 & 5 & zero & 0.0006 & 0.0003 & 0.0056 & 0.0022 \\ 300 & 10 & non-zero & 0.057 & 0.0126 & 0.0056 & 0.0066 \\ 300 & 10 & zero & 0.0011 & 0.0008 & 0.0067 & 0.0036 \\ \hline &&&\multicolumn{4}{c}{Average RMSE}\\ \cline{4-7} 100 & 5 & non-zero & 0.1467 & 0.1409 & 0.0853 & 0.0882 \\ 100 & 5 & zero & 0.0149 & 0.017 & 0.0783 & 0.0589 \\ 100 & 10 & non-zero & 0.1389 & 0.1422 & 0.0842 & 0.0888 \\ 100 & 10 & zero & 0.0195 & 0.0258 & 0.0772 & 0.0592 \\ 300 & 5 & non-zero & 0.0761 & 0.0437 & 0.0446 & 0.0485 \\ 300 & 5 & zero & 0.0076 & 0.0058 & 0.0428 & 0.0443 \\ 300 & 10 & non-zero & 0.0698 & 0.0507 & 0.0425 & 0.0451 \\ 300 & 10 & zero & 0.0101 & 0.01 & 0.0409 & 0.0419 \\ \hline \end{tabular} \label{tab:est} \end{table} In this section, we compare the bias and RMSE of four estimation methods: Lasso, Lasso+OLS, LDPE and JM. Figures \ref{fig:bias} and \ref{fig:RMSE} and Table \ref{tab:bias} show the results of absolute bias ($|E\hat a_{1j}-a_{1j}|$) and RMSE ($[E(\hat a_{1j}-a_{1j})^2]^{1/2}$). For non-zero parameters, the Lasso estimator has large bias, the Lasso+OLS estimator reduces the bias (23\% - 41\% when $n=100$, 77\% - 90\% when $n=300$), and two de-biased Lasso estimators further reduce the bias (60\% - 90\%). For zero parameters, the Lasso and Lasso+OLS estimators have nearly zero bias, while the bias of two de-biased Lasso estimators are about the same magnitude as those of non-zero parameters. In terms of RMSE, when $n=100$, situation is almost the same as bias; when $n=300$, for those non-zero parameters, the Lasso and Lasso+OLS estimators have RMSE comparable to two de-biased Lasso estimators while for those zero parameters, the Lasso and Lasso+OLS estimators have much smaller RMSE. Specifically, for those zero parameters, compared to the LDPE, the Lasso reduces the RMSE by 75\% - 82\%. For estimation purpose, we recommend the Lasso and Lasso+OLS since their RMSEs are smaller. However, for construction of confidence intervals, small bias will lead to more accurate coverage probabilities, which will be seen in the next section. \subsection{Comparison of coverage probabilities and confidence interval lengths} \label{sec:homo-sim-ci} \begin{figure}[ht] \centering \includegraphics[scale=0.8]{fig/cp1.pdf}\par \caption{Comparison of empirical coverage probabilities for 1000 replications produced by six methods (columns) in four cases (rows). Index on the $x$-axis corresponds to different $a_{1j}$'s, which are arranged from small to large in absolute values. The first $p-s_1$ elements of $a_{1j}$'s are zeros (blue points) and the last $s_1$ are non-zeros (red points). The black lines are total averages of coverage probabilities for zero and non-zero parameters respectively. The red dashed lines correspond to the nominal confidence level 95\%.} \label{fig:cp1} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.8]{fig/length1.pdf}\par \caption{ Comparison of average confidence interval lengths for 1000 replications produced by six methods (columns) in four cases (rows). Index on the $x$-axis corresponds to different $a_{1j}$'s, which are arranged from small to large in absolute values. The first $p-s_1$ elements of $a_{1j}$'s are zeros (blue points) and the last $s_1$ are non-zeros (red points). The black lines are total averages of interval lengths for zero and non-zero parameters respectively. } \label{fig:length1} \end{figure} \begin{table}[ht] \centering \caption{Average empirical coverage probabilities and average confidence interval lengths} \label{tab:coverage} \begin{tabular}{rrlrrrrrr} \hline \multicolumn{1}{l}{n} & \multicolumn{1}{l}{s} & $a_{ij}$ & \multicolumn{1}{l}{BtLasso} & \multicolumn{1}{l}{BtLassoOLS} & \multicolumn{1}{l}{LDPE} & \multicolumn{1}{l}{BtLDPE} & \multicolumn{1}{l}{MultiBtLDPE} & \multicolumn{1}{l}{JM} \\ \hline &&&\multicolumn{6}{c}{Average empirical coverage probabilities (\%)}\\ \cline{4-9} 100 & 5 & non-zero & 55.8 & 69 & 93.2 & 90.7 & 90.5 & 89.4 \\ 100 & 5 & zero & 95.1 & 99 & 95.6 & 95.9 & 95.7 & 98.3 \\ 100 & 10 & non-zero & 40 & 51.3 & 93.2 & 86.9 & 87.2 & 92.1 \\ 100 & 10 & zero & 93.4 & 97.3 & 96 & 96.1 & 96 & 98.6 \\ 300 & 5 & non-zero & 88.2 & 95.2 & 94.5 & 93.8 & 94.1 & 94.3 \\ 300 & 5 & zero & 95.3 & 99.7 & 95.4 & 95 & 94.9 & 96.3 \\ 300 & 10 & non-zero & 82.4 & 91.5 & 94.8 & 93.7 & 93.8 & 96 \\ 300 & 10 & zero & 94.3 & 99 & 95.7 & 95.1 & 95.1 & 97.1 \\ \hline &&&\multicolumn{6}{c}{Average confidence interval lengths}\\ \cline{4-9} 100 & 5 & non-zero & 0.174 & 0.259 & 0.315 & 0.296 & 0.302 & 0.295 \\ 100 & 5 & zero & 0.021 & 0.012 & 0.313 & 0.283 & 0.28 & 0.294 \\ 100 & 10 & non-zero & 0.124 & 0.178 & 0.313 & 0.285 & 0.289 & 0.309 \\ 100 & 10 & zero & 0.03 & 0.027 & 0.314 & 0.276 & 0.274 & 0.311 \\ 300 & 5 & non-zero & 0.145 & 0.19 & 0.172 & 0.166 & 0.167 & 0.186 \\ 300 & 5 & zero & 0.017 & 0.003 & 0.17 & 0.159 & 0.159 & 0.184 \\ 300 & 10 & non-zero & 0.13 & 0.165 & 0.165 & 0.157 & 0.158 & 0.182 \\ 300 & 10 & zero & 0.03 & 0.013 & 0.166 & 0.151 & 0.151 & 0.183 \\ \hline \end{tabular}% \label{tab:ci}% \end{table}% We now compare the coverage probabilities and mean confidence interval lengths of 95\% confidence intervals constructed by six methods: de-biased Lasso (LDPE), residual bootstrap de-biased Lasso (BtLDPE), multiplier wild bootstrap de-biased Lasso (MultiBtLDPE), bootstrap Lasso (BtLasso), bootstrap Lasso+OLS (BtLasso+OLS) and de-biased Lasso of \cite{Javanmard:2014} (JM). Figure \ref{fig:cp1} and Table \ref{tab:coverage} show the results of coverage probabilities. For non-zero parameters, the coverage probabilities of BtLasso and BtLasso+OLS do not reach the nominal confidence level in all cases except for $n=300, s_{i}=5$. The LDPE, BtLDPE, MultiBtLDPE and JM can reach the nominal confidence level when $n=300$ while only the LDPE reaches the nominal confidence level when $n=100$. For zero parameters, all methods except the BtLasso reach the nominal confidence level. Note that the BtLasso+OLS and JM produce much higher coverage probabilities, for example 99\%, than the nominal level 95\%. Figure \ref{fig:length1} and Table \ref{tab:coverage} show the results of average confidence interval lengths. For non-zero parameters, the BtLasso and BtLasso+OLS produce shorter confidence intervals than the other four methods. Moreover, compared to the LDPE, the BtLDPE reduces confidence interval lengths by 6\% - 12\% when $n=300$ and 3\% - 9\% when $n=100$. For zero parameters, the BtLasso and BtLasso+OLS have nearly zero average confidence interval lengths, reflecting the super-efficiency of these two methods. For the other four methods, the LDPE, BtLDPE, MultiBtLDPE and JM, the confidence interval lengths for zero parameters are nearly the same as those for non-zero parameters. Meanwhile, confidence intervals produced by the BtLDPE and MultiBtLDPE are shorter than those produced by the LDPE and JM. Taking into account both coverage probabilities and confidence interval lengths, when $n$ is small, we recommend the LDPE for its honest coverage probabilities; when $n$ is large, we recommend the BtLDPE and MultiBtLDPE for their honest coverage probabilities and shorter confidence interval lengths. \subsection{Robustness to the distributions of errors} \label{sec:heter-sim} In this subsection, we explore the robustness of our methods to different distributions of errors, namely, homoscedastic non-Gaussian errors, heteroscedastic Gaussian errors and heteroscedastic non-Gaussian errors. Compared to homoscedastic Gaussian errors, different distributions of errors do not lead to significant difference of performance; see the results in the supplementary material. Again, we can see that the LDPE has honest coverage probabilities and the BtLDPE and MultiBtLDPE have shorter confidence interval lengths compared to the LDPE. \section{Real data} \begin{figure}[ht] \centering \includegraphics[scale=0.18]{fig/rd_matrix.png}\par \caption{ Statistical inference results of the $500 \times 500$ transition matrix of the VAR model for the returns of the S\&P 500 constituent stocks using six methods: de-biased Lasso (LDPE), residual bootstrap de-biased Lasso (BtLDPE), multiplier wild bootstrap de-biased Lasso (MultiBtLDPE), de-biased Lasso of \cite{Javanmard:2014} (JM), bootstrap Lasso (BtLasso) and bootstrap Lasso+OLS (BtLasso+OLS). The red point indicates that the corresponding parameter $a_{ij}$ is significant (its 95\% confidence interval does not include 0). The gray square indicates that the two stocks corresponding to $a_{ij}$ are in the same sector. } \label{fig:sp500-sig} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.18]{fig/rd_length.png}\par \caption{ Box plot of confidence interval lengths of the $500\times 500$ parameters produced by six methods: de-biased Lasso (LDPE), residual bootstrap de-biased Lasso (BtLDPE), multiplier wild bootstrap de-biased Lasso (MultiBtLDPE), de-biased Lasso of \cite{Javanmard:2014} (JM), bootstrap Lasso (BtLasso) and bootstrap Lasso+OLS (BtLasso+OLS). } \label{fig:sp500-length} \end{figure} In practice, researchers often use VAR models to analyze the time series data of stocks and conduct statistical inference on the elements of transition matrix, so as to produce knowledge about the relationship between different stocks. In this section, we use the prices of the S\&P 500 constituent stocks in 2019 to demonstrate our methods. There are 505 stocks in total because there are five companies have two share classes of stock. There are 252 trading days in 2019, but five stocks have incomplete data for some reasons. After deleting these five stocks, we have data of 500 stocks for 252 days. Because our model needs the stationarity of time series data, we use the daily return $$ r_{t}=\frac{p_{t}}{p_{t-1}}-1, \quad t=0, \ldots, n $$ as $\{\mathbf{y}_t\}$ in model (\ref{eq:VAR}), where $p_{t}$ is the adjusted price. Since the transformation reduces one observation and $t$ begins from $0$, in our model, $n=250$. These 500 companies are in eleven different sectors: Communication Services, Consumer Discretionary, Consumer Staples, Energy, Financials, Health Care, Industrials, Information Technology, Materials, Real Estate and Utilities. We apply the same six methods as in Section \ref{sec:sim} to this data set and obtain the 95\% confidence intervals for elements of the transition matrix $A$. The results are shown in Figures \ref{fig:sp500-sig} and \ref{fig:sp500-length}. First, compared with the BtLasso, BtLasso+OLS and JM, our proposed methods produce more significant parameters, which can provide users with more candidates for effective relationships to make future decisions. Second, some of the columns of the estimated transition matrix have many significant parameters (see the vertical red lines in Figure \ref{fig:sp500-sig}), indicating that the prices of some stocks have prediction power on the prices of most stocks. A further look at the results reveals that all six methods indicate that Newmont Corporation is such a stock having the ability to predict many other stock prices in advance. Newmont Corporation is the largest producer of gold in the world and the only gold producer listed in the S\&P 500 Index. Considering that the turbulent global financial environment in 2019 made gold the best safe-haven asset, our findings have practical significance. Third, there are relationships both within and between sectors. Finally, Figure \ref{fig:sp500-length} shows that the BtLasso and BtLasso+OLS produce confidence intervals with lengths nearly zero, while the confidence interval lengths of the other four methods are larger than zero and roughly comparable. \section{Conclusion} Performing statistical inference for parameters in high-dimensional VAR models is a challenging but important problem. We propose to use the de-biased Lasso (LDPE), residual bootstrap de-biased Lasso (BtLDPE) and multiplier wild bootstrap de-biased Lasso (MultiBtLDPE) to construct confidence intervals for the individual parameter of the transition matrix. Unlike the fixed design case in linear regression models, the design matrix in VAR models is random with complex dependence structure, which makes theoretical analysis challenging. Based on the convergence rates of the Lasso and the nodewise Lasso estimators, we obtain the asymptotic unbiasedness of the de-biased Lasso estimator. Combined with the martingale central limit theorem, we obtain its asymptotic normality. For the two bootstrap de-biased Lasso methods, the analysis is conditional on the original data and we derive their asymptotic properties based on the randomness coming from the bootstrap sampling. We demonstrate the validity of statistical inference for the parameters of high-dimensional sparse VAR models using these methods. Furthermore, we propose feasible and parallelizable algorithms to implement our methods. More specifically, we apply the de-biased Lasso, residual bootstrap de-biased Lasso and multiplier wild bootstrap de-biased Lasso to each of the $p$ equations of VAR models separately, which can be ran in parallel. More importantly, the $p$ equations share the same design matrix, so we need only to compute the nodewise Lasso once, which is the main computational burden of the de-biased Lasso and bootstrap de-biased Lasso. The proposed methods have significant computational advantages, especially when $p$ is large. We conduct comprehensive simulation studies to compare our methods with the bootstrap Lasso, bootstrap Lasso+OLS and another de-biased Lasso method proposed by \cite{Javanmard:2014}. We find that the LDPE can always give the honest coverage probabilities, and when sample size is large, the BtLDPE and MultiBtLDPE can also give the honest coverage probabilities but with shorter confidence interval lengths. Therefore, when the sample size is small, we recommend the LDPE for its reliability, and when the sample size is large, we recommend the BtLDPE and MultiBtLDPE for their reliability and power. Lastly, we apply our methods to analyze the S\&P 500 constituent stock prices data set and obtain reasonable confidence intervals. In our theoretical study, we assume the homoscedastic Gaussian errors. However, we find in simulations that our methods are robust to heteroscedastic and/or non-Gaussian errors. It is interesting and worthy of further investigation to obtain the asymptotic distributions of the proposed methods for heteroscedastic and/or non-Gaussian errors. The main technical difficulty is to establish convergence rates of the Lasso and martingale central limit theorem for this type of errors. This article focuses on statistical inference for individual parameter of the transition matrix in high-dimensional sparse VAR models. It is interesting to extend the methods for simultaneous confidence intervals and multiple hypothesis testing. For this purpose, we can use the Bonferroni correction or Westfall-Young procedure \citep{Westfall:1993uu}. We leave the corresponding theoretical investigation to future work. \section*{Supplementary Material} The document provides the detailed proofs of the theoretical results, as well as additional simulation results for different distributions of errors. \section*{Acknowledgments} The authors thank Dr. Lixiang Zhang for his suggestions that have helped clarify the text. \section*{Funding} Dr. Hanzhong Liu acknowledges the financial support from the National Natural Science Foundation of China (grant nos. 11701316). \bibliographystyle{natbib.bst}
{'timestamp': '2020-09-22T02:18:14', 'yymm': '2009', 'arxiv_id': '2009.09462', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09462'}
arxiv
\section{Introduction} In recent years, several technologies have been developed to achieve sustainable coverage for large scale Internet of Things (IoT) devices that will become an integral part of future smart cities. These technologies, featuring low power and long range connectivity to IoT in the licensed as well as the unlicensed spectrum. In the licensed band, LTE-M and narrowband IoT (NBIoT)~\cite{IEEEhowto:01} are cellular IoT technologies that achieve reliable connectivity for a massive number of devices. While licensed operation of IoT devices is costly, it can achieve better quality of service (QoS)~\cite{IEEEhowto:00}. In unlicensed bands, SigFox~\cite{IEEEhowto:000} and LoRa~\cite{IEEEhowto:07} are two proprietary technologies that are increasingly deployed in different IoT applications. SigFox uses ultra narrowband channels ($\approx$ 100 Hz) within the 869 MHz (Europe) and 915 MHz (US) bands~\cite{IEEEhowto:02}. It is suitable for applications that require extremely low uplink (UL) rates with a maximum payload size of 12 bytes. LoRaWAN, on the other hand uses the LoRa modulation scheme over its PHY layer and achieve a better UL rate, ranging from 0.3kbps to 27kbps~\cite{IEEEhowto:03}. Fig.~\ref{jpg1} shows a typical LoRaWAN architecture consisting of devices connected to the network server through one or multiple gateways. The interface between the server and gateway can be Ethernet, 3G/4G, etc. The LoRaWAN architecture is designed to achieve optimal operation for constrained application (CoAP) environments. Devices are connected over-the-air to LoRa gateways and are served through unlicensed region specific ISM bands defined in~\cite{IEEEhowto:05}. To send packets over the network, a device can either be activated over-the-air or it can be manually registered using activation by personalization (ABP) at the network server before its deployment~\cite{IEEEhowto:04}. The gateways are just traffic forwarding elements and implement the physical layer processing of LoRaWAN packets. As shown in Fig.~\ref{jpg1}, the LoRa PHY performs LoRa/FSK modulation/demodulation of the DL/UL packets and forwards them to the corresponding device/network server, respectively. Typically over the UL, the device performs the application specific information processing and forwards packets to the NS via one or multiple gateways. The LoRa medium access control (MAC) layer management at NS includes removing duplicate UL messages, processing acknowledgements (ACKs) for confirmed frames, and assigning MAC layer parameters e.g. channel, data rate/spreading factors (DR/SF), etc. to different network devices. The join server (JS), as shown in Fig.~\ref{jpg1} keeps track of all network session keys and application session keys issued to network devices as well as the network server and application server associated with that device. This enables secure data transfer between session establishment and termination procedures. \begin{figure}[!t] \begin{center} \resizebox{3.2 in}{2.0 in}{\includegraphics{fig1}} \caption{\em LoRaWAN Network Architecture and Network Component Layers~\cite{IEEEhowto:08}} \label{jpg1} \end{center} \end{figure} Due to low deployment cost, simple network maintenance, energy efficiency, and higher achievable rates, LoRaWAN is getting increasingly adopted for different industrial applications, ranging from agriculture and environment monitoring, to various smart city applications~\cite{IEEEhowto:03}. With this increasing popularity, it is important to explore its operation under different settings and use cases. The current LoRaWAN specification~\cite{IEEEhowto:04} does not provide details about various aspects of its operation that may affect the resulting performance gains. Therefore an in-depth study of different operational features of LoRaWAN is required using a physical testbed or a simulation tool. This paper presents an experimental study of key performance metrics in a LoRaWAN network using system-level simulations. We evaluate parameters such as channel utilization and packet delivery ratio (PDR) for confirmed and unconfirmed UL transmissions in different scenarios. Our study reveals new key insights for service providers on how LoRaWAN efficiency is affected by the variation in network parameters e.g. spreading factor (SF), number of transmissions, channels, and the network load. \section{Background} \subsection{Layers in LoRaWAN} The physical (PHY) layer in LoRaWAN makes use of LoRa, which is a chirp-spread spectrum (CSS) modulation scheme that uses a chip-coded sequence to spread the data-sequence signal over a much wider bandwidth~\cite{IEEEhowto:031}. This makes the modulated signal robust against noise and multi-path fading. The higher the chip rate ($DR_{chip}$) compared to the original data rate ($DR$), the wider the frequency range over which the transmitted data spreads and the longer the distance it can reach. The log-ratio of the chip rate to the original data sequence rate is called the spreading factor (SF), defined as $SF$ = $log_2$($DR_{chip}$/$DR$)~\cite{IEEEhowto:03,IEEEhowto:031}. Different SFs are defined (from 7 to 12) based on the rate of the chip sequence used. Note that the chip sequences for different SFs are orthogonal to each other, hence giving additional diversity in the achievable channel gain. In short, LoRa in itself hides the LoRaWAN complexity and enables different SF configurations over a channel with a variety of bandwidths (e.g. 125 kHz, 250 kHz, and 500 kHz) and code rate settings. The medium access control (MAC) layer uses LoRaWAN that supports the operation of different types of LoRa devices namely, Class A, B, and C. Class A devices enable energy efficient data frame transmission only in the UL. All LoRaWAN devices must support UL operation which makes this class as the baseline class of LoRaWAN. The downlink (DL) transmissions for Class A devices must follow an UL data frame sent by an end device application. For this reason, the LoRaWAN frame header includes a pending data field, which is set if there is more DL data needed to be sent to the device. Based on this field, a device wakes up to receive the next DL data frame. Class B devices focus on the DL transmission of data frames. This class support extra slots known as $ping$ $slots$ that can be scheduled by the NS within each beacon duration of 128 seconds. Note that in both of these classes (A and B), the UL and DL operations are suitable for devices with limited energy supply. Class C type devices remain in the active state all the time to receive data from the NS as they have no energy constraints. \subsection{LoRaWAN Operation} As described earlier, any UL transmission from a class A type device requires it to open two receive slots on different channels, one after the other. As shown in Fig.~\ref{jpg2}a, initially the device will open the first slot ($RS_1$) after the time length of RECV-DELAY~\footnote{From LoRaWANv1.1, recommended value of RECV-DELAY is 1 second.}, and then it will open the slot 2 ($RS_2$) exactly after one second of $RS_1$. The LoRaWANv1.1 protocol supports two types of UL transmissions from Class A devices to the gateway, an UL unconfirmed transmission and a confirmed transmission. An unconfirmed UL transmissions does not require an ACK from the gateway as shown in Fig.~\ref{jpg2}a. In contrast to unconfirmed transmissions, a confirmed UL transmission requires the gateway to send an ACK frame if the frame is received successfully. An ACK frame can be sent in either one of the two receive slots, that are opened following an UL data frame transmission, as shown in Fig.~\ref{jpg2}b. Each UL transmission from the LoRaWAN device must follow the regulatory duty cycle (RDC) constraint which is specifically defined for different available sub-bands and regions in~\cite{IEEEhowto:05}. The LoRaWAN MAC header defines a frame counter field within the UL and DL frame that counts the number of frames sent over the UL/DL, respectively. For each next UL and DL frame the counter gets incremented by one. The maximum number of retransmissions limits the lora-device MAC (e.g. LoRaWAN) to retransmit the confirmed UL frame up to maximum $N_{max-C}-1$ times, in case no ACK is received. Note that maximum transmission $N_{max-C}$ can be restricted to 1, resulting for a device to move to the next frame immediately after an RDC timeout following an UL transmission as shown in Fig.~\ref{jpg2}c. The LoRaWAN specification~\cite{IEEEhowto:04} recommends the maximum number of retransmissions as 7~\footnote{e.g. including the first transmission, overall $N_{max-C}$ will be 8.}. Also note that each retransmission is done on a different channel and the SF for each second confirmed frame retransmission is increased~\cite{IEEEhowto:16}. \begin{figure*}[t!] \begin{center} \resizebox{4.0 in}{3.0 in}{\includegraphics{fig2abc}} \caption{\em UL transmission scenario with different maximum tx. limits in LoRaWAN: When (a) $N_{max-UC}$ = 4, (b) $N_{max-C}$ = 8, (c) $N_{max-C}$ = 1} \label{jpg2} \end{center} \end{figure*} \section{Related Work} Previous research on LoRaWAN broadly used either physical test-bed experiments, network simulation based evaluations, or mathematical modeling for LoRaWAN network study. In~\cite{IEEEhowto:15}, the authors studied the received signal strength indicator (RSSI) and coverage using different settings of SFs on a physical LoRa test-bed consisting of a single device and gateway. The results compare the measured RSSI with the one specified in the LoRa device data sheets and show that the actual RSSI is around 6 dB less than the one specified in the data sheets. Furthermore, the field tests show that the LoRa gateway can achieve a range of up to 3km in the suburban environment. Other works such as ~\cite{IEEEhowto:02,IEEEhowto:14,IEEEhowto:09} used simulation tools to study various aspects of LoRaWAN. In~\cite{IEEEhowto:02,IEEEhowto:14}, the authors used LoRaSim~\footnote{http://www.lancaster.ac.uk/scc/sites/lora/}, for the scalability analysis of LoRaWAN in different environments.~\cite{IEEEhowto:02} investigates the data extraction rate and the overall network energy consumption in a network with a single and multiple sinks. The results show that LoRa enables scalability, provided that different transmission parameters (e.g. channels, SFs, etc.) are carefully chosen. Similarly, the authors in~\cite{IEEEhowto:14} did experiments to analyze the effect of DL traffic over the UL throughput performance in LoRaWAN. In this regard, the work shows that even in the presence of a small fraction of DL traffic, achieving scalability is crucial as the UL goodput decreases sharply.~\cite{IEEEhowto:14} takes a step further and emphasizes that it is important to efficiently choose the number of gateways and retransmissions to support the required UL performance for the end nodes. Next, ~\cite{IEEEhowto:09} introduces a new LoRaWAN network simulation module built in NS-3. Using different network settings, the work evaluates the PDR over the UL and DL confirmed/unconfirmed messages where all end devices and gateways are using a single UL channel (868.1 MHz) other than the high power reserved channel for $RS_2$. The results show that the PDR for confirmed frames is highly affected, especially when the transmission period is small. Next, following the works of~\cite{IEEEhowto:02,IEEEhowto:14}, the NS-3 based simulation experiments of LoRaWAN in~\cite{IEEEhowto:09} also reaffirms the finding that the UL PDR gets highly affected in the presence of DL traffic. Further studies~\cite{IEEEhowto:03,IEEEhowto:16} have used a Pure Aloha based mathematical model to explore the performance limits of LoRaWAN. In~\cite{IEEEhowto:03}, the authors perform an analysis of performance achieved using LoRaWAN in terms of the number of successfully received packets per hour. The works show that when the packet transmission rate is low, the UL throughput is mainly limited by the number of collisions. In contrast, when the transmissions rate is high, the duty cycle limitation limits the network performance. As such, the study suggests that further modifications should be made in LoRaWAN to enable support for different use case scenarios. The study also gives some new research directions, e.g. designing new channel hopping schemes, multi-hop transmissions in LoRaWAN, and TDMA based UL scheduler over LoRaWAN. Similarly, the work of~\cite{IEEEhowto:16} proposes a mathematical model of LoRaWAN channel access. The model can be used to estimate the packet error rates considering the capture effect for a given range of network traffic load. In this work, we explore LoRaWAN using the NS-3 based LoRaWAN module (discussed in~\cite{IEEEhowto:09}). NS-3 is one of the most widely used network simulation platform and it allows us to explore various performance metrics in different network settings. This paper presents new results illustrating the effect of the maximum transmission limits ($N_{max-C}$/$N_{max-UC}$) and the number of available channels on the resulting PDR and sub-band utilization, in the case of confirmed and unconfirmed UL transmissions. The next section gives details about our experimental methodology. This includes a description of the NS-3 based LoRaWAN module, different performance metrics, and the simulation environment of our experiments. Section V gives details of each use case and provides the corresponding results from our experiments using the NS-3 based LoRaWAN module. Later in Section V, the simulation results are discussed showing PDR, UL throughput, sub-band utilization as well as the impact of network load and the sub-band resources on the resulting performance. Finally, section VI concludes this study. \section{Experimental Methodology} A reasonably sized LoRaWAN network requires the deployment of several low power sensor devices that may scale up to several thousand nodes. Building and maintaining such a huge network is not trivial, expensive, and time consuming. Therefore, a common way is to use simulation to provide an approximation of a real network environment. \subsection{LoRaWAN Module in NS-3} The NS-3 LoRaWAN module is an extension of the NS-3 module for the low power wide area network (LPWAN)~\cite{IEEEhowto:11}. The LoRaWAN MAC/PHY components are running over each LoRa device and the gateway. The PHY layer of each device interacts with that of the respective gateway via the NS-3 Spectrum PHY module, implementing the devices air interface and channel specific parameters, as shown in Fig.~\ref{jpg3}. As mentioned earlier, on each channel in a sub-band, a gateway can receive signals with different SFs simultaneously. Note that in the testbed the LoRa PHY uses the error model from the baseband implementation of the PHY layer in MATLAB, simulations considering an AWGN channel as described in~\cite{IEEEhowto:09}. The collision model used in the NS-3 module is based on the capture effect. The capture effect comes into play when during the collision of two simultaneous UL transmissions (with same frequency and SF) the stronger signal captures the weaker signal. As a result, the frame with stronger received power is successfully received by the gateway while the frame with a weaker receive power is lost In the LoRaWAN module, for the case of confirmed UL transmissions, the choice of receive slots ($RS_1$/$RS_2$) by the gateway for sending ACKs back to the device is based on the following: \begin{itemize} \item RDC restriction over the sub-band. \item Over the given channel and SF the LoRaWAN MAC is in idle state. \item No other MAC data is scheduled on the particular channel with same bandwidth and SF. \end{itemize} \begin{figure}[t!] \begin{center} \resizebox{3.2 in}{2.5 in}{\includegraphics{fig3}} \caption{\em LoRaWAN module setup in NS-3: Class A LoRaWAN devices, gateway, and the NS~\cite{IEEEhowto:09}.} \label{jpg3} \end{center} \end{figure} \subsection{Performance Metrics} We consider a LoRaWAN network with a NS, one gateway, and $|A|$ number of devices in the network. A device $a$ ($\in$ $A$) application generates packets following Poisson law with average rate $\lambda$, regarded as the traffic arrival rate. We assume this packet generation rate is fix for all network devices. Next, all packets generated by the device application are forwarded to the MAC layer to send immediately over the UL only if the RDC timer at the device from earlier transmission has expired and the device MAC is in idle state. In our system, we assume only Class A UL frame transmissions from the end devices. The DL frames contain ACKs and are only sent in case of confirmed UL transmissions. If $t^{TX}$ is the air time of transmitted data frames, then following the RDC constraint ($\Delta$), a device can transmit data after a period of at least $\frac{t^{TX}}{\Delta}$ seconds. In other words, the maximum packet transmission rate is $\frac{\Delta}{t^{TX}}$. Next, as shown in Fig.~\ref{jpg2}, we use $N_{max-UC}$/$N_{max-C}$ to represent the maximum number of UL unconfirmed/confirmed frames transmissions respectively, from an end device. \begin{table}[t!] \caption{Symbols and their definition}\centering \label{table2:parameters} \begin{tabular}{|c|c|} \hline Symbols & Definition \\ \hline $T$ & Overall simulation duration \\ \hline $t^{TX}$ & Data frame transmission time \\ \hline $\Delta$ & UL duty cycle \\ \hline $N_{max-UC}$/$N_{max-C}$ & Max. frame transmissions \\ \hline $X_0$/$X_1$ & Actual tx. for unconfirmed/confirmed frame \\ \hline $s^{x}_a$/$r^{x}_a$ & UL sending/receiving rate \\ \hline $\rho$ & Sub-band load \\ \hline \end{tabular} \end{table} For a typical UL confirmed transmission, we assume $f_R(1,N_{max-C})$ is a path loss and load-dependent function that gives a random integer between 1 and $N_{max-C}$ as an output in the number of transmissions required for the confirmed frame reception. If $X_x$ defines a function that gives the number of transmissions of unconfirmed/confirmed frames when $x$ is 0 or 1, respectively. We can state this for unconfirmed/confirmed UL transmission as, \begin{subnumcases}{X_x =} N_{max-UC}, & for $x = 0$\\ f_R (1, N_{max-C}), & for $x = 1$ \label{eq01} \end{subnumcases} We consider one sub-band having $m_c$ channels is available to all the LoRaWAN devices for UL transmission. Following the RDC constraint of a sub-band with traffic arrival rate $\lambda$, the average frame generation rate of a device $a$ from Fig.~\ref{jpg2} is given as: \begin{subnumcases}{s^{x}_a =} \frac{1}{(\frac{1}{\Delta}) \cdot t^{TX}}, & if $\lambda$ $\geq$ $\frac{1}{(\frac{1}{\Delta}) \cdot t^{TX} \cdot X_x}$\\ \lambda \cdot X_x, & if $\lambda$ $<$ $\frac{1}{(\frac{1}{\Delta}) \cdot t^{TX} \cdot X_x}$ \label{eq02} \end{subnumcases} Here, $\Delta$ is the RDC limit over the maximum sub-band airtime that can be used by a device and $(\frac{1}{\Delta}) \cdot t^{TX}$ is the RDC period~\footnote{average period in which a device can send at most one UL frame.} of the sub-band. Using $\lambda$ and the RDC $\Delta$, we define the traffic intensity $t_I$ for a device $a$ as the ratio of average packet generation rate by device application ($\lambda$) to the maximum frame transmission rate $(\frac{\Delta}{t^{TX}})$, e.g. $t_I$ = $\lambda$ $\cdot$ $(\frac{1}{\Delta}) \cdot t^{TX}$. Note that since $\lambda$ is fixed for all $|A|$ devices, $t_I$ will be also be same for all network devices ($\forall$a $\in$ A). In a sub-band with $m_c$ channels, the load $\rho$ over the time duration (0, T] in the presence of $|A|$ devices is, \begin{equation}\label{eq03} \rho = \frac{t^{TX}}{m_c} \cdot \sum_{a=1}^{|A|} s^{x}_a, \end{equation} The above equation defines the fraction of the sub-band (with $m_c$ available channels) air-time used by all $|A|$ devices for UL data transmission. Let $r^{x}_{a}$ be the rate (of type $x$, i.e. confirmed or unconfirmed) of successfully received UL frames from a device $a$ over a sub-band. Then the capacity utilization of the sub-band (e.g. $U$) is: \begin{equation}\label{eq04} U = \frac{t^{TX}}{m_c} \cdot \sum_{a=1}^{|A|} r^{x}_{a}, \end{equation} In other words, the utilization in above equation is the ratio of total air-time of successfully received UL frames to the overall time $m_c$ channels in the sub-band are available over UL. It is important to note that, since the utilization is specific to the given sub-band, therefore it is calculated at the MAC (LoRaWAN) layer. We next define the PDR as the ratio of successfully received application packets to the number of packets transmitted by the source application. It can be mathematically stated for the considered LoRaWAN network as: \begin{equation}\label{eq05} PDR = \frac{1}{|A|} \cdot \sum_{a=1}^{|A|} (r^{x}_{a, App}/s^{x}_{a, App}). \end{equation} \subsection{Simulation Parameters} The parameters used in our experiments are listed in Table.~\ref{table1:parameters}. Furthermore, our results are based on the following assumptions: \begin{itemize} \item Only the UL traffic from Class A devices is considered, which can consist of either unconfirmed or confirmed frames. \item All UL transmissions from a device follow the specifications of EU863-870~\cite{IEEEhowto:05} e.g. UL transmissions follow 1\% RDC (as defined in Table.~\ref{table1:parameters}), whereas DL transmissions adhere to a RDC of 10\%. \item Each device $a$ $\in$ $A$ is sending equally sized frames over the UL with traffic intensity $t_I$. \end{itemize} \begin{table}[t!] \caption{Simulation Parameters}\centering \label{table1:parameters} \begin{tabular}{|c|c|} \hline Simulation Parameters & Value \\ \hline UL device tx. power & 14dBm \\ \hline Gateway coverage radius & Scenario I (7km), II (5km) \\ \hline Spreading factor (SF) & SF12 \\ \hline Preamble length & 8 bytes \\ \hline Frame PHY payload & 21 bytes \\ \hline ACK payload & 12 bytes \\ \hline Code rate & $\frac{4}{7}$ \\ \hline $\Delta$ & 1\% (for UL) \\ \hline Channel bandwidth & 125 kHz \\ \hline Path loss model & LogDistancePropagationLoss \\ \hline \end{tabular} \end{table} \section{Simulation Scenarios and Results} This section defines the simulation environment and the use case scenarios for the evaluation of different performance metrics as explained above. \begin{figure}[!ht] \begin{center} \resizebox{3.4 in}{1.80 in}{\includegraphics{fig4}} \caption{\em (a) Scenario I: Single device mobility, (b) Scenario II: Multiple devices uniformly distributed over the 5km radius.} \label{jpg4} \end{center} \end{figure} \subsection{Scenario I - Single Device} We consider a single gateway network connecting end devices to the NS. The server can manage the channel and SFs for a device through the gateway to achieve better performance. Initially, the network is serving a single device and one sub-band (with only one channel) is available for the UL data transmission. The end device is allocated a fixed SF by the server. \begin{itemize} \item Single gateway single device: As an initial case, an end device moves along a straight line, i.e. from distance of 1 km from the gateway, to 7 km away from the gateway (as shown in Fig.~\ref{jpg4}a). After some fixed time, the node sends 100 packets over the UL. Here, we are interested in evaluating the impact of mobility, or more precisely distance from the gateway, on the PDR and the UL throughput. Note that here we consider only unconfirmed frame transmission over the UL. \end{itemize} \subsection{Results for Single Device Mobility} \subsubsection{Packet Delivery Ratio (PDR)} Fig.~\ref{jpg6} plots the resulting PDR for the different fixed SFs setup over the given channel as the device moves away from the gateway. It can be seen that an UL rate setting of SF7 limits the communication range of the gateway to around 2km, and after $\approx$ 2.2km the UL frame PDR reduces to zero, as all frames are lost due to the low signal to noise ratio (SNR) at the receiver. Note that a higher SF increases the receiver sensitivity and enables better coverage and range over a larger distance. As a result, the UL PDR for SF12 remains close to 100\%, even though the device is $\approx$ 6km away from the gateway. \begin{figure}[!ht] \begin{center} \resizebox{3.4 in}{2.0 in}{\includegraphics{fig6}} \caption{\em UL PDR from a single mobile device with fixed SF.} \label{jpg6} \end{center} \end{figure} \subsubsection{Uplink (UL) Throughput} Next in Fig.~\ref{jpg7}, the result shows the UL throughput (bits per second) for a fixed SF. It can be seen that with low SF (e.g. SF7) a higher UL throughput can be achieved. However, it will only last for some small distance, as shown in Fig.~\ref{jpg7}, due to low receivers sensitivity. Similarly, with higher SF (e.g. SF12), all UL frames up to a distance of $\approx$ 6km can be successfully received. It is important to note that based on the above results, an optimal scheme can be devised that adaptively chooses the SFs for different devices to maximize their UL rates. By using an adaptive rate selection, it is expected that a mobile device can achieve a better overall UL rate compared to a fixed SF scheme. \begin{figure}[!ht] \begin{center} \resizebox{3.4 in}{2.0 in}{\includegraphics{fig7}} \caption{\em Uplink (UL) throughput for the mobile device with different fixed SF.} \label{jpg7} \end{center} \end{figure} \subsection{Scenario II - Multiple Devices, Poisson traffic pattern} In this scenario, we consider a single gateway network with multiple devices uniformly distributed over a circular area with 5km radius, as shown in Fig.~\ref{jpg4}b. All devices are configured to send UL data with SF12. For frame collisions, the model implemented in the LoRaWAN NS-3 module is based on the capture effect. Furthermore, where more than one channel is available over the sub-band (i.e. $m_c$>1), we assume that all channels have an equal probability to be selected by the device for each new UL transmission. At first, we consider a single channel gateway network (i.e. a sub-band with only one available channel) with traffic arrival following a Poisson process with exponentially distributed mean inter-arrival time $\frac{1}{\lambda}$, as shown in Fig.~\ref{jpg5}. The impact of the increasing load (number of devices) upon the network performance metrics such as sub-band utilization and PDR, is evaluated separately for the cases of confirmed and unconfirmed UL transmissions. \begin{figure}[!ht] \begin{center} \resizebox{3.0 in}{2.0 in}{\includegraphics{fig5}} \caption{\em Poisson arrivals over the sub-band with average rate $\lambda$} \label{jpg5} \end{center} \end{figure} \subsection{Results for Multiple Devices} In the following, we describe the results of scenario II. \subsubsection{Sub-band Utilization ($U$)} Considering different traffic intensities ($t_I$) as well as maximum transmissions for confirmed and unconfirmed UL frames (e.g. $N_{max-C}$ and $N_{max-UC}$), this section evaluates the sub-band utilization results. \begin{itemize} \item \textbf{Varying transmissions ($N_{max-UC}$/$N_{max-C}$)} The utilization results in Fig.~\ref{jpg8b} are achieved in a fully loaded (e.g. $t_I$=1) network environment. Note that with $N_{max-UC}$=1, the utilization gets higher in Fig.~\ref{jpg8b} as the UL transmissions are able to fully utilize the capacity as the number of devices grows. Intuitively, it can also be seen that the utilization results for confirmed UL transmissions with different $N_{max-C}$ does not change as expected. This is because the ACK transmission from the gateway over the same channel increases collisions and decreases the number of successfully delivered frames. As a result the resource utilization in case of confirmed frames is considerably lower than for unconfirmed ones. Next, when maximum transmissions increase from 1 to 8 (i.e. $N_{max-UC}$=8) the utilization remains unaffected. This is because the channel is used up to its maximum limit in both cases, and therefore the collision probability does not change. From an application perspective, the utilization for the unconfirmed case will be small when maximum number of transmissions is high, even though multiple copies of same frame are received successfully. However, only one of them will be forwarded to the application, and counts as a received packet at the application layer. \begin{figure}[!ht] \begin{center} \resizebox{3.4 in}{2.0 in}{\includegraphics{fig8b}} \caption{\em Sub-band utilization vs. network load with varying maximum number of allowed confirmed/unconfirmed UL frame transmissions with fixed SF12, $t_I$=1.0, $m_c$=1.} \label{jpg8b} \end{center} \end{figure} \item \textbf{Varying traffic intensity ($t_I$)} The results in Fig.~\ref{jpg9} show the impact of traffic intensity ($t_I$) on the sub-band utilization for confirmed and unconfirmed UL transmissions. As expected, when the traffic load is high, the utilization also increases for both unconfirmed/confirmed UL transmissions. It is important to observe in Fig.~\ref{jpg9} that in a less loaded environment, unconfirmed transmission still achieves better channel utilization. \begin{figure}[!ht] \begin{center} \resizebox{3.4 in}{2.0 in}{\includegraphics{fig9}} \caption{\em Sub-band utilization vs. total number of devices (|A|) with varying traffic intensity ($t_I$) for unconfirmed/confirmed UL transmissions with fixed SF12, $N_{max-UC}$=8, $N_{max-C}$=8, $m_c$=1.} \label{jpg9} \end{center} \end{figure} \end{itemize} \subsubsection{Packet Delivery Ratio (PDR)} Next, we evaluate the PDR for confirmed and unconfirmed frame transmissions in the presence of multiple available channels over the sub-band. \begin{itemize} \item \textbf{Fully loaded network ($t_I$=1) with varying maximum transmissions ($N_{max-UC}$ or $N_{max-C}$) } The results in Fig.~\ref{jpg12}a,b shows the effect on PDR due to the number of network devices (|A|), maximum number of transmissions and the number of available channels $m_c$. As seen in Fig.~\ref{jpg12}a with a single channel gateway (e.g. $m_c$=1) and fully loaded network, the confirmed UL frame transmission gives relatively better results compared to others when the maximum transmissions are 8. However, when the maximum transmissions are limited to $N_{max-C}$=1, the PDR drops because of two reasons; first, because the confirmed transmissions consume more resources (due to ACK transmissions) compared to the unconfirmed ones. Secondly, performing transmissions only one time results in a higher sending rate at the application layer and more unsuccessful UL frames, specifically when there are a lot of devices in the network. Finally, we can see that in a fully loaded network environment, when the maximum transmission limit is high, the choice of unconfirmed/confirmed transmission becomes less important, as they both achieve similar PDR values. \begin{figure}[!ht] \begin{center} \resizebox{3.4 in}{2.4 in}{\includegraphics{fig6a6b} \caption{\em PDR vs. network devices (|A|) for confirmed and unconfirmed UL transmissions with different number of maximum transmissions ($N_{max-UC}$ and $N_{max-C}$) and $t_I$=1.} \label{jpg12} \end{center} \end{figure} Fig.~\ref{jpg12}b shows the results of unconfirmed and confirmed UL transmissions when the number of available channels is increased to 7 ($m_c$=7). Note that with unconfirmed transmissions, when $N_{max-UC}$ is 1 and 8, the application layer PDR is high compared to the case of confirmed UL transmissions. Especially for $N_{max-UC}$=8, the number of frame transmissions increases the chance of successful frame reception, and thus the PDR remains close to 100\% for up to 150 network devices. For the case of only confirmed UL transmissions with max transmission ($N_{max-C}$) set as 8, we notice that the availability of 7 channels decreases the possibility of collisions and allows more new confirmed frames to be sent over the UL successfully. However, due to a higher number of available channels for confirmed transmissions, the ratio of successfully received packets is also high, resulting in a PDR which is the same as in the case of unconfirmed transmissions. \item \textbf{Reduced load ($t_I$=0.10) with varying maximum transmissions ($N_{max-UC}$ or $N_{max-C}$) } Further, we explored the case of a moderate network load, with a traffic intensity of $t_I$=0.10. In Fig.~\ref{jpg13}a the results of a single channel gateway network shows that when the load is high the PDR of confirmed transmissions for both the cases of $N_{max-C}$ 1 and 8 is small compared to the unconfirmed one when $N_{max-UC}$ is 1. Another important point to note is that when the network load is low (e.g. $t_I$=0.10) even a single unconfirmed transmission is enough and achieves a better PDR compared to repetitive UL unconfirmed transmissions of the same frame (e.g. when $N_{max-UC}$ = 8). This is because repetitive unconfirmed transmissions increase the network load and results in more collisions, thereby effectively reducing the PDR, as shown in Fig.~\ref{jpg13}a. From the interesting trend in low load conditions we can conclude that when network devices are less than $\approx$ 40, confirmed UL transmissions with a high maximum transmission limit can be used to achieve better reliability. Comparing this to the earlier results of a single channel gateway network in Fig.~\ref{jpg12}a, an important point to note is that when the network is lightly loaded, repetitive transmissions of the same unconfirmed frames increases the load and results in more collisions. In Fig.~\ref{jpg13}b the PDR results based on low traffic intensity ($t_I$=0.10) with all channels available ($m_c$=7) show that when the load on the channel is relatively small, the PDR results follow the patterns for different $N_{max-UC}/N_{max-C}$ and network devices, as expected. In other words, with a higher maximum transmission limit and more available channels, the PDR increases for both confirmed and unconfirmed transmissions. \begin{figure}[!ht] \begin{center} \resizebox{3.4 in}{2.4 in}{\includegraphics{fig6c6d} \caption{\em PDR vs. network devices (|A|) for confirmed and unconfirmed UL transmissions with different number of maximum transmissions ($N_{max-UC}$ and $N_{max-C}$) and $t_I$=0.10.} \label{jpg13} \end{center} \end{figure} \end{itemize} \section{Conclusion} In this paper, an extensive evaluation of Class A devices in LoRaWAN is performed separately for unconfirmed and confirmed UL transmissions. The results give us valuable new insights on the choice of different parameter values in LoRaWAN affects the overall network performance. For example, in a network with a single device, we found that adaptively changing rate can significantly increase the network performance. With multiple devices in a less loaded network, with a limited number of channels, we found that increasing the number of maximum transmission for unconfirmed frames degrades network performance by reducing the resulting PDR. Also, in such cases we observed that using confirmed transmission is better. Similarly, when the network is highly loaded, we found that unconfirmed transmissions result in better overall performance. The key findings from our work can be used to optimize the LoRaWAN network performance by appropriately choosing different network parameters and device transmission mode based on the network condition. \appendices \ifCLASSOPTIONcaptionsoff \newpage \fi
{'timestamp': '2020-09-22T02:19:22', 'yymm': '2009', 'arxiv_id': '2009.09503', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09503'}
arxiv
\section{Introduction}\label{sec: sec_introduction} Background noises greatly reduce the quality and intelligibility of the speech signal, limiting the performance of speech-related applications in real-world conditions (e.g. automatic speech recognition, dialogue system and hearing aid, etc.). The goal of speech enhancement \cite{loizou2013speech} is to generate enhanced speech with better speech quality and clarity by suppressing background noise components in noisy speech. Conventional speech enhancement approaches, such as spectral subtraction \cite{boll1979suppression}, Wiener filtering \cite{lim1978all}, minimum mean squared error (MMSE) estimation \cite{ephraim1985speech}, and the optimally-modified log-spectral amplitude (OM-LSA) speech estimator \cite{cohen2001speech,cohen2003noise}, have been extensively studied in the past. Recently, deep learning technologies have been successfully used for speech enhancement \cite{6932438,6639038,8369155}. Human auditory system can track a single target voice source in extremely noisy acoustic environment like a cocktail party, as known as the cocktail party effect \cite{cherry1953some}. This fascinating nature motivates us to utilize the discovery that humans perceive speech when designing speech enhancement systems. McGurk effect \cite{mcgurk1976hearing} suggests a strong influence of vision in human speech perception. More researches \cite{bernstein1996speech, macleod1987quantifying,massaro2014speech,rosenblum2008speech} have shown visual cues such as facial/lip movements can supplement acoustic information of the corresponding speaker, helping speech perception, especially in noisy environments. Inspired by the above discoveries, the speech enhancement method utilizing both audio and visual signals, known as audio-visual speech enhancement (AVSE), has been developed. The AVSE methods can be traced back to \cite{girin1995noisy} and following work, e.g. \cite{girin2001audio,fisher2001learning,deligne2002audio,goecke2002noisy,hershey2002audio,abdelaziz2013twin}. And recently numerous studies have attempted to build deep neural network-based AVSE models. \cite{gabbay2018seeing} employed a video-to-speech method to construct T-F masks for speech enhancement. An encoder-decoder architecture was used in \cite{gabbay2018visual, hou2018audio}. These methods were merely demonstrated under constrained conditions (e.g. the utterances consisted of a fixed set of phrases, or a small number of known speakers). \cite{Afouras2018} proposed a deep AVSE network consisting of the magnitude and phase sub-networks, which enhanced magnitude and phase, respectively. \cite{Ephrat2018looking} designed a model that conditioned on the facial embedding of the source speaker and outputted the complex mask. \cite{8969244} proposed a time-domain AVSE framework based on Conv-tasnet \cite{luo2019conv}. These methods all performed well in the situations of unknown speakers and unknown noise types. We briefly discuss the above-mentioned AVSE methods from following two perspectives: visual embedding and audio-visual fusion method. Regrading to the visual embedding, \cite{hou2018audio,gabbay2018seeing,gabbay2018visual} made use of the image sequences of the lip region. For discarding irrelevant variations between images, such as illumination, \cite{Ephrat2018looking} proposed using the face embedding obtained from a pre-trained face recognizer and confirmed through ablation experiments that the lip area played the most important role for enhancement performance in the face area. Moreover, \cite{Afouras2018, 8969244} chose lip embedding via the middle layer output in a pre-trained isolated word recognition model. In recent work, \cite{wu2019time} adopted the phone as the classification target instead of isolated word and provided a more useful visual embedding for speech separation. In the term of audio-visual fusion method, most AVSE methods focus on audio-visual fusion that happens at the middle layer of the enhancement network in the fashion of channel-wise concatenation. We can get some inspirations from these pioneering works. A useful visual embedding should contain as much acoustic information in the video as possible. But the acoustic information in video is very limited, and there is also other information redundancy. In the current classification-based embedding extracting framework, we can yield a more robust and generalized visual embedding by reducing the information redundancy and increasing the correlation between the classification target and the visual acoustic information. Cutting out the lip area is helpful for reducing the redundancy. While for the other one, finding a classification target that is more relevant to lip movements is informative. The superset of speech information called speech attributes include a series of fundamental speech sounds with their linguistic interpretations, speaker characteristics, and emotional state etc \cite{lee2007overview}. In contrast to phone models, a smaller number of universal attribute units are needed for a complete characterization of any spoken language \cite{li2006vector}. The set of universal speech attributes used in related works mainly consist of place and manner of articulation \cite{li2005study, siniscalchi2013universal, li2016improving}. We propose that a higher correlation between the speech attribute and the visual acoustic information can provide a more useful supervisory signal in the stage of visual embedding extractor training. One commonly accepted consensus in multimodal learning is that the data of each mode obeys an independent distribution conditioned on the ground truth label \cite{blum1998combining,dasgupta2002pac,leskes2005value,lewis1998naive}. Each mode captures features related to ground truth tags from different aspects, so the information extracted (labels excluded) is not necessarily related to the other. This shows that the ground truth can be seen as ``information intersection" between all modes \cite{sun2020tcgm}, i.e., the amount of agreement shared by all the modalities. Specifically, in AVSE, there is a mismatch between the information intersection and the ground truth label. The intersection of audio modal (noisy speech) and video modal (lip video) is not clean speech which is the ground truth. In this work, we extend the previous AVSE framework to the embedding aware speech enhancement (EASE) framework. The conventional AVSE methods are regarded as special EASE methods, which only utilize visual embedding extracted from lip frames, as known as visual-only EASE (VEASE) methods. In EASE framework, we propose a VEASE model using a novel visual embedding, which is the middle layer output in a pre-trained universal place recognizer. We have the same dataset in the stages of the embedding extractor training and the enhancement network training. A more effective visual embedding is obtained by utilizing a high correlation between the designed classification target, i.e., the articulation place, and the visual acoustic information rather than additional video data. Moreover, we present a novel multimodal EASE (MEASE) model using multimodal embedding instead of unimodal embedding. The visual embedding extractor in the VEASE model evolves into audio-visual embedding extractor in the MEASE model. The enhancement network takes not only the noisy speech but also the fused audio-visual embedding as inputs, and outputs a ideal ratio mask. The fusion of audio and visual embeddings occurs in the stage of embedding extractor training and is supervised by their information intersection at the articulation place label level. The main contributions of this paper are: \begin{enumerate}[(1)] \item We explore the effectiveness of different visual embeddings pre-trained for various classification targets on enhancement performance. A novel classification target, i.e., the articulation place, is proposed for training visual embedding extractor. The visual embedding utilizing a high correlation between the articulation place and the acoustic information in video achieves the better enhancement performance with no additional data used. \item We verify the complementarity between audio and visual embeddings lies in different SNR levels, as well as different articulation places by ablation experiments. And based on the information intersection, we adopt a novel fusion method integrating visual and audio embeddings in the proposed MEASE model, which achieves better performance in all SNR levels and all articulation places. \item We design experiments to study the effect of the stage when audio-visual fusion occurs on the quality and intelligibility of enhanced speech. And we observe that the early fusion of audio and visual embeddings achieves the better enhancement performance. \end{enumerate} Concurrently and independently from us, a number of groups have proposed various methods from above two perspectives for AVSE. \cite{wang2020robust} observed serious performance degradations when these AVSE methods were applied with a medium or high SNR \footnote{Performance degradation in \cite{wang2020robust} may result from the changes in the network structure, but we have indeed observed reduction in improvements from our results of comparative experiment, as will be discussed in Section \ref{sec: sec_MEASE_result}.} and proposed a late fusion-based approach to safely combine visual knowledge in speech enhancement. This is the opposite of our work. \cite{iuzzolino2020av} proposed a new mechanism for audio-visual fusion. In this research, the fusion block was adaptable to any middle layers of the enhancement network. This kind of multiple fusion in the enhancement network was better than the standard single channel-wise concatenation. However, their work differs ours in that audio-visual integration still occurs in the middle of the enhancement network. The rest of the paper is structured as follows. In Section \ref{sec: sec_VEASE_main} we describe the proposed VEASE method. The proposed MEASE method is presented in Section \ref{sec: sec_MEASE_main}. Section \ref{sec: sec_exp} has experimental setup including dataset, audio and video preprocessing as well as compares experimental results. Finally, we conclude this work and discuss future research directions in Section \ref{sec: sec_conclusion}. \section{VEASE Model Utilizing Articulation Place Label}\label{sec: sec_VEASE_main} In this section, we elaborate our proposed VEASE model, including two aspects, i.e., architecture and training process. The visual embedding extractor is an important part of the VEASE model, which takes a sequence of lip frames as input and outputs a compact vector for every lip frame, known as visual embedding. The VEASE model takes both noisy log-power spectra (LPS) features and visual embeddings as inputs, and outputs ideal ratio mask. The details of the visual embedding extractor and the VEASE model are elaborated in the following. \subsection{Architecture of Visual Embedding Extractor}\label{sec: sec_VEE_arc} \begin{figure}[htb] \centering \includegraphics[width=\linewidth]{fig_VEE-eps-converted-to.pdf} \caption{Illustration of a visual embedding extractor (in color blue for ease of cross-referencing in Figure \ref{fig: fig_VEE}, Figure \ref{fig: fig_VEASE}, Figure \ref{fig: fig_MEASE} and Figure \ref{fig: fig_fuse_stage}). For every lip frame, the extractor outputs a compact vector. We train visual embedding extractor by using 3 different classification labels, i.e., word, phone and place.} \label{fig: fig_VEE} \end{figure} The visual embedding extractor $f_{\rm V}$ has a similar structure to \cite{Stafylakis2017,petridis2018end}, which is also used in previous AVSE studies \cite{Afouras2018,8969244}. The extractor consists of a spatiotemporal convolution followed by an $18$-layer ResNet \cite{he2016deep} which is the identity mapping version \cite{he2016identity}, as shown in Figure \ref{fig: fig_VEE}. A spatiotemporal convolution consists of a convolution layer with $64$ 3D-kernels of $5\times7\times7$ (time/width/height), a batch normalization, a ReLU activation and a spatiotemporal max-pooling layer. For a sequence of lip frames $V=\{V^t\in \mathbb{R}^{H \times W}; t=0, 1, \dots, T_{\rm V}-1\}$, the feature maps is extracted by the spatiotemporal convolution. Then, the feature maps are passed through the $18$-layer ResNet. The spatial dimensionality shrinks progressively in the ResNet until output becomes a $L_{\rm V}$-dimensional vector per time step, known as the visual embedding $E_{\rm V}$: \begin{equation} \begin{split} E_{\rm V} &= \{E_{\rm V}^t \in \mathbb{R}^{L_{\rm V}}; t=0, 1, \dots, T_{\rm V}-1\} = f_{\rm V}(V)\\ &= \operatorname{ResNet-18}_{\rm V}(\operatorname{MaxPooling_{3D}}(\operatorname{BN}(\operatorname{ReLU}(\operatorname{Conv_{3D}}(V))))) \end{split} \end{equation} where $T_{\rm V}$, $H$ and $W$ denote the number and the size of lip frames, respectively. In this study, we use $L_{\rm V}=256$, $H=98$ and $W=98$ by default. The visual embedding extractor is trained with a classification backend $f'_{\rm C}$ in the right side of Figure \ref{fig: fig_VEE}, consisting of a $2$-layer BiGRU, a fully connected layer followed by a SoftMax activation. The output of the $E_{\rm V}$ is fed to $f'_{\rm C}$ and the posterior probability of each class representing each segment of lip frames $P_{\rm word}$ is calculated as follows: \begin{equation} P_{\rm class} = f'_{\rm C}(E_{\rm V}) = \operatorname{SoftMax}(\operatorname{Mean}(\operatorname{FC}(\operatorname{BiGRU}(\operatorname{BiGRU}(E_{\rm V}))))), \end{equation} where the class can be labeled as word, phone or place of articulation. \subsection{Word Based Visual Embedding Extraction}\label{sec: sec_VEE_word} Conventional AVSE techniques \cite{Afouras2018, 8969244} often obtain the visual embedding extractor discussed earlier based on an isolated word classification task by using a lip reading dataset, such as the Lip Reading in the Wild (LRW). We build our baseline model, denoted as VEASE-word using the LRW corpus consisting of up to $1000$ audio-visual speech segments extracted from BBC TV broadcasts (News, Talk Shows, etc.), totaling around $170$ hours. There are $500$ target words and more than $200$ speakers. The LRW dataset provides a word-level label for each audio-visual speech segment, i.e., the real distribution of word $P_{\rm word}^{\rm truth}$. We calculate the cross entropy (CE) loss $\mathcal{L}_{\rm CE}$ between $P_{\rm word}^{\rm truth}$ and $P_{\rm word}$: \begin{equation} \mathcal{L}_{\rm CE} = \operatorname{CE}(P_{\rm word}^{\rm truth} \| P_{\rm word}) = -\sum{P_{\rm word}^{\rm truth}\log P_{\rm word}}. \label{eq: eq_word_ce} \end{equation} The objective function, $\mathcal{L}_{\rm CE}$, is minimized by using Adam optimizer \cite{kingma2014adam} for $100$ epochs and the mini-batch size is set to $64$. The initial learning rate is set to $0.0003$ and is decreased on log scale after $30$ epochs. Data augmentation is performed during training, by applying random cropping ($\pm5$ pixels) and horizontal flips, which is the same across all lip frames of a sequence. The best model is selected by the highest frame-level classification accuracy. \subsection{Phone Based Visual Embedding Extraction}\label{sec: sec_VEE_phone} The isolated word classification task usually requires a word-level dataset which is not easy to collect in a large scale effort. To alleviate this problem, we propose that the same data is used during training visual embedding extractor and enhancement network with different labels. Under the guidance of results in \cite{wu2019time}, we choose context-independent (CI) phones consisting of $39$ units from CMU dictionary as classification labels, denoted as VEASE-phone. $E_{\rm V}$ is fed to a classification backend $f_{\rm C}$ which has a same structure as $f'_{\rm C}$ and outputs the posterior probability of each CI-phone for each specific time frame $P_{\rm phone} = f_{\rm C}(E_{\rm V}) = \operatorname{SoftMax}(\operatorname{FC}(\operatorname{BiGRU}(\operatorname{BiGRU}(E_{\rm V}))))$. The TCD-TIMIT dataset is a high quality audio-visual speech corpus labeled at both the phonetic and the word level. We can directly get the frame-level real distribution of CI-phone $P_{\rm phone}^{\rm truth}$. The calculation of $\mathcal{L}_{\rm CE}$ between $P_{\rm phone}^{\rm truth}$ and $P_{\rm phone}$ is similar to Equation (\ref{eq: eq_word_ce}): \begin{equation} \mathcal{L}_{\rm CE} = \operatorname{CE}(P_{\rm phone}^{\rm truth} \| P_{\rm phone}) = -\sum{P_{\rm phone}^{\rm truth}\log P_{\rm phone}} \label{eq: eq_phone_ce} \end{equation} We use the same optimization process as in Section \ref{sec: sec_VEE_word} to minimize $\mathcal{L}_{\rm CE}$. \subsection{Articulation Place Based Visual Embedding Extraction}\label{sec: sec_VEE_place} \begin{figure}[htb] \centering \includegraphics[width=\linewidth]{fig_lip_place-eps-converted-to.pdf} \caption{9 lip shapes corresponding to utterance segments representing 9 articulation positions: all lip shapes come from a single speaker starting with the lip closed. The lip shape changes greatly in High, Mid and Labial than Dental, Velar and Glottal.} \label{fig: fig_lip2place} \end{figure} As discussed earlier, we believe there is a high correlation between speech attributes and visual acoustic information. In order to verify our idea, we check the lip shapes belonging to different places and manners of articulation. We find that the influences of various articulation places on the change of lip shape are different, i.e., the lip shape changes greatly in some utterance segments belonging to specific articulation place. An example is presented in Figure \ref{fig: fig_lip2place}. In contrast, we do not observe similar changes in the term of articulation manner. Consequently we propose to train visual embedding extractor with the articulation place label in this study, denoted as VEASE-place. We adopt 10 units as in \cite{siniscalchi2009study,lee2013information} for articulation place set. Compared with the phone, the category granularity of articulation place is coarser. Thus, the classification model can achieve comparable performance with lower complexity. And the articulation place has fewer categories, which reduces the labeling costs. Moreover, the articulation place label is believe to be more language-independent than phones, which allows various languages to appear in training and testing. The same classification backend $f_{\rm C}$ takes $E_{\rm V}$ as input and outputs the posterior probability of each articulation place class for each specific time frame $P_{\rm place}$. \begin{table}[htb] \centering \caption{The mapping between articulation place classes and CI-phones as in \cite{siniscalchi2009study}.} \label{tab: tab_phone2place} \footnotesize \setlength{\tabcolsep}{20pt}{ \begin{tabular}[b]{|l|l|} \toprule \textbf{Articulation place classes}&\textbf{CI-phones}\\ \midrule Coronal&d, l, n, s, t, z\\ High&ch, ih, iy, jh, sh, uh, uw, y\\ Dental&dh, th\\ Glottal&hh\\ Labial&b, f, m, p, v, w\\ Low&aa, ae, aw, ay, oy\\ Mid&ah, eh, ey, ow\\ Retroflex&er, r\\ Velar&g, k, ng\\ Silence&sil\\ \bottomrule \end{tabular} } \end{table} $P_{\rm phone}^{\rm truth}$ is mapped into the frame-level real distribution of articulation place $P_{\rm place}^{\rm truth}$ by using Table \ref{tab: tab_phone2place}. $\mathcal{L}_{\rm CE}$ between $P_{\rm place}^{\rm truth}$ and $P_{\rm place}$ is calculated as follows: \begin{equation} \mathcal{L}_{\rm CE} = \operatorname{CE}(P_{\rm place}^{\rm truth} \| P_{\rm place}) = -\sum{P_{\rm place}^{\rm truth}\log P_{\rm place}} \label{eq: eq_place_ce} \end{equation} The optimization process to minimize $\mathcal{L}_{\rm CE}$ is same as in that in Section \ref{sec: sec_VEE_word}. \subsection{VEASE Model}\label{sec: sec_VEASE} \begin{figure}[htb] \centering \includegraphics[width=0.6\linewidth]{fig_VEASE-eps-converted-to.pdf} \caption{Illustration of the VEASE model. The VEASE model takes the visual embeddings as the auxiliary inputs except regular noisy LPS features. The visual embedding extractor is pre-trained separately with classification backend, following the steps introduced in the above-mentioned sections. In the training of the VEASE model, the visual embedding extractor is kept frozen.} \label{fig: fig_VEASE} \end{figure} The VEASE model consists of three stacks of 1D-ConvBlocks and a frozen visual embedding extractor, as shown in Figure \ref{fig: fig_VEASE}. Each 1D-ConvBlock includes a 1D convolution layer with a residual connection, a ReLU activation, and a batch normalization, as in \cite{Afouras2018}. Some of the blocks contain an extra up-sampling or down-sampling layer, because the number of audio frames is different from that of the video frames. Visual embedding $E_{\rm V}$ is processed by the stack $s_{\rm E}$ at the bottom left consisting of $N_{\rm E}$ 1D-ConvBlocks while noisy log-power spectra (LPS) features $A_{\rm LPS} = \{A^t_{\rm LPS}\in\mathbb{R}^{F};t=0,1,\dots,T_{\rm A}-1\}$ are processed by the stack $s_{\rm LPS}$ at the bottom right consisting of $N_{\rm LPS}$ 1D-ConvBlocks: \begin{align} R_{\rm E} &= s_{\rm E}(E_{\rm V}) = \overbrace{\operatorname{ConvBlock_{1D}}(\cdots \operatorname{ConvBlock_{1D}}(E_{\rm V}))}^{N_{\rm E}} \\ R_{\rm LPS} &= s_{\rm LPS}(A_{\rm LPS})= \overbrace{\operatorname{ConvBlock_{1D}}(\cdots \operatorname{ConvBlock_{1D}}(A_{\rm LPS}))}^{N_{\rm LPS}} \end{align} where $T_{\rm A}$ and $F$ denote the number of time frames and frequency bins for spectrogram, respectively. $R_{\rm E}$ and $R_{\rm LPS}$ denote outputs of different stacks. The $R_{\rm E}$ and $R_{\rm LPS}$ are then concatenated along the channel dimension and fed to the top stack $s_{\rm F}$ consisting of $N_{\rm F}$ 1D-ConvBlocks. The last convolution layer in the top stack projects the output's dimension into the same one of noisy magnitude spectrogram. Then, the hidden representation is activated by a sigmoid activation to obtain a magnitude mask $M \in \mathbb{R}^{T_{\rm A}\times F}$: \begin{equation} \begin{split} M &= \sigma(s_{\rm F}([R_{\rm E}, R_{\rm LPS}])) \\ &= \sigma(\overbrace{\operatorname{ConvBlock_{1D}}(\cdots \operatorname{ConvBlock_{1D}}([R_{\rm E}, R_{\rm LPS}]))}^{N_{\rm F}}) \end{split} \end{equation} The values of $M$ range from 0 to 1. In this study, we use $N_{\rm E}=10$, $N_{\rm LPS}=5$ and $N_{\rm F}=15$ by default. To show the effectiveness of embedding on enhancement performance, we also design a competitive no-embedding version of the EASE model which is stripped of the stack $s_{\rm E}$ at the bottom left and the frozen visual embedding extractor, denoted as NoEASE model. The NoEASE model computes $M$ only using the noisy LPS features as inputs: \begin{align} M=\sigma(s_{\rm F}(s_{\rm LPS}(A_{\rm LPS}))) \end{align} The ideal ratio mask (IRM) \cite{hummersone2014ideal} is employed as the learning target, which is widely used in monaural speech enhancement \cite{wang2014training}. IRM $M_{\rm IRM} \in \mathbb{R}^{T_{\rm A} \times F}$ is calculated as follows: \begin{equation} M_{\rm IRM}=\left(\frac{C_{\rm PS}}{C_{\rm PS}+D_{\rm PS}}\right)^{\frac{1}{2}} \end{equation} where $C_{\rm PS}\in \mathbb{R}^{T_{\rm A} \times F}$ and $D_{\rm PS}\in \mathbb{R}^{T_{\rm A} \times F}$ denote power spectrograms of clean speech and noise, respectively. The mean square error (MSE) $\mathcal{L}_{\rm MSE}$ between $M$ and $M_{\rm IRM}$ is calculated as the loss function: \begin{equation} \mathcal{L}_{\rm MSE} = \operatorname{MSE}(M, M_{\rm IRM}) = \sum \|M-M_{\rm IRM}\|^2_2 \label{eq: eq_mse} \end{equation} We use Adam optimizer to train for $100$ epochs with early stopping when there is no improvement on the validation loss for $10$ epochs. The batch size is $96$. Initial learning rate is set to $0.0001$, which is found by ``LR range test" proposed in \cite{smith2017cyclical}, and halved during training if there is no improvement for $3$ epochs on the validation loss. The best model is selected by the lowest validation loss. \section{Proposed MEASE Model}\label{sec: sec_MEASE_main} In this section, we elaborate our proposed MEASE model. The MEASE model takes the fused audio-visual embedding as the auxiliary input instead of the visual embedding. As described in Section \ref{sec: sec_introduction}, the MEASE model utilizing a complementarity of audio and visual features in an information intersection manner. In order to verify the complementarity between audio and visual embeddings, we design an EASE model that utilizes the audio embedding, denoted as AEASE model. The AEASE model has a similar structure to the VEASE model with the main difference of employing an audio embedding extractor instead of the visual embedding extractor. For verifying the effectiveness of the information intersection-based audio-visual fusion manner on enhancement performance, we design an EASE model that utilizes the concatenation of audio and visual embeddings, denoted as cMEASE model. The details of the AEASE model, the MEASE model and the cMEASE model are elaborated in the following. \subsection{AEASE model}\label{sec: sec_AEASE_main} \begin{figure}[htb] \centering \includegraphics[width=\linewidth]{fig_AEE-eps-converted-to.pdf} \caption{Illustration of a audio embedding extractor (in color green for ease of cross-referencing in Figure \ref{fig: fig_AEE}, Figure \ref{fig: fig_MEASE} and Figure \ref{fig: fig_fuse_stage}). The audio embedding extractor has the similar structure as the visual embedding extractor in Section \ref{sec: sec_VEE_arc}. The training of the audio embedding extractor is same as that in Section \ref{sec: sec_VEE_place}.} \label{fig: fig_AEE} \end{figure} The AEASE model has a similar structure to the VEASE model as shown in Figure \ref{fig: fig_VEASE}, with the main difference of employing a audio embedding extractor, instead of the visual embedding extractor. The audio embedding extractor $f_{\rm A}$ has a similar structure as the visual embedding extractor in Section \ref{sec: sec_VEE_arc}, as shown in Figure \ref{fig: fig_AEE}. The 3D-kernels in the spatiotemporal convolution are replaced by 1D-kernels meanwhile the 3D-MaxPooling layer is dropped in this case as the audio frame is a vector. We also use the ResNet-18 with the main difference of employing 1D-kernels instead of 2D-kernels. Given noisy FBANK features $A_{\rm FBANK}\in\mathbb{R}^{T_{\rm A}\times F_{\rm mel}}$, the audio embeddings $E_{\rm A}\in\mathbb{R}^{T_{\rm A}\times L_{\rm A}}$ are calculated as follows: \begin{equation} \begin{split} E_{\rm A} &= \{E^{t}_{\rm A}\in\mathbb{R}^{L_{\rm A}}; t=0, 1, \dots, T_{\rm A}-1\}= f_{\rm A}(A_{\rm FBANK}) \\ &= \operatorname{ResNet-18_A}(\operatorname{BN}(\operatorname{ReLU}(\operatorname{Conv_{1D}}(A_{\rm FBANK})))) \end{split} \end{equation} where, $F_{\rm mel}$ and $L_{\rm A}$ are the number of triangular filters set for FBANK features and the length of $E^{t}_{\rm A}$, respectively. In this study, $L_{\rm A}=L_{\rm V}=256$ is used by default. We use the same training process to train the audio embedding extractor as training the visual embedding extractor in Section \ref{sec: sec_VEE_place}. Adam optimizer is used to minimize $\mathcal{L}_{\rm CE}$, which is calculated by Equation (\ref{eq: eq_place_ce}). But $P_{\rm place}$ is computed by using $E_{\rm A}$: \begin{equation} P_{\rm place} = f_C(E_{\rm A}) \end{equation} The AEASE model takes both $A_{\rm LPS}$ and $E_{\rm A}$ as inputs and outputs $M$: \begin{align} M=\sigma(s_{\rm F}([s_{\rm E}(E_{\rm A}), s_{\rm LPS}(A_{\rm LPS})])) \end{align} The same optimization process as in Section \ref{sec: sec_VEASE} is also used to minimize $\mathcal{L}_{\rm MSE}$, which is calculated by Equation (\ref{eq: eq_mse}). \subsection{MEASE Model}\label{sec: sec_MEASE} \begin{figure}[htb] \centering \includegraphics[width=0.8\linewidth]{fig_MEASE-eps-converted-to.pdf} \caption{Illustration of the proposed MEASE model. The pervious visual embedding extractor evolves to the audio-visual embedding extractor, which consists of a visual stream (in blue), an audio stream (in green) and a fused stream (in orange). The audio-visual embedding extractor fuse the audio and visual embeddings in an information intersection manner.} \label{fig: fig_MEASE} \end{figure} The most significant change in the MEASE model is that the visual embedding extractor evolves into the audio-visual embedding extractor. The audio-visual embedding extractor takes not only lip frames but also noisy FBANK features as inputs and outputs the fused audio-visual embedding which is learned under the supervision of the information intersection, i.e., the articulation place label. The audio-visual embedding extractor consists of visual, audio and fused streams, as shown at the bottom left part of Figure \ref{fig: fig_MEASE}. The visual stream has the same structure as the visual embedding extractor in Section \ref{sec: sec_VEE_arc} while the audio stream has the same structure as the audio embedding extractor in Section \ref{sec: sec_AEASE_main}. $V$ and $A_{\rm FBANK}$ are processed by visual and audio streams, respectively: \begin{align} E^{\rm V}_{\rm AV} &= f_{\rm V}(V) \\ E^{\rm A}_{\rm AV} &= f_{\rm A}(A_{\rm FBANK}) \end{align} where $E^{\rm V}_{\rm AV}\in\mathbb{R}^{T_{\rm V}\times L_{\rm V}}$ and $E^{\rm A}_{\rm AV}\in\mathbb{R}^{T_{\rm A}\times L_{\rm A}}$ denotes the outputs of visual and audio streams, respectively. The mismatch in the number of frames between $E^{\rm V}_{\rm AV}$ and $E^{\rm A}_{\rm AV}$, i.e., $T_{\rm A} \ne T_{\rm V}$, is solved by repeating a video frame for several audio frames: \begin{equation} \tilde{E}^{\rm V}_{\rm AV} = \{\overbrace{E^{{\rm V}, 0}_{\rm AV}, \cdots, E^{{\rm V}, 0}_{\rm AV}}^{T_{\rm A}/T_{\rm V}}, E^{{\rm V}, 1}_{\rm AV}\cdots\} \end{equation} The fused stream consisting of a $2$-layers BiGRU at the top takes $\tilde{E}^{\rm V}_{\rm AV}$ and $E^{\rm A}_{\rm AV}$ as inputs and outputs the audio-visual embedding $E_{\rm AV}\in\mathbb{R}^{T_{\rm A}\times L_{\rm AV}}$: \begin{equation} E_{\rm AV} = \{E^{t}_{\rm AV}; t=0, 1, \cdots, T_{\rm A}-1\} = \operatorname{BiGRU}(\operatorname{BiGRU}([\tilde{E}^{\rm V}_{\rm AV}, E^{\rm A}_{\rm AV}])) \end{equation} where $L_{\rm AV}$ is the length of $E^t_{\rm AV}$. In this paper, we use $L_{\rm AV}=L_{\rm A}+L_{\rm V}=512$ by default. We also use the same steps to minimize $\mathcal{L}_{\rm CE}$, which is calculated by Equation (\ref{eq: eq_place_ce}), as these in Section \ref{sec: sec_VEE_place}. But $P_{\rm place}$ is computed by using $E_{\rm AV}$: \begin{equation} P_{\rm place} = f_C(E_{\rm AV}) \end{equation} It is a remarkable fact that the audio-visual classification model can achieve a better and faster convergence, by initializing visual and audio streams with the independently pre-trained params. The MEASE model takes both $A_{\rm LPS}$ and $E_{\rm AV}$ as inputs and outputs $M$: \begin{align} M=\sigma(s_{\rm F}([s_{\rm E}(E_{\rm AV}), s_{\rm LPS}(A_{\rm LPS})])) \end{align} We use the same optimization process as in Section \ref{sec: sec_VEASE} to minimize $\mathcal{L}_{\rm MSE}$, which is calculated by Equation (\ref{eq: eq_mse}). \subsection{cMEASE Model} \label{sec: sec_cMEASE} By ablating the fused stream in Figure \ref{fig: fig_MEASE}, another audio-visual embedding, $cE_{\rm AV}\in\mathbb{R}^{T_{\rm A}\times (L_{\rm A}+L_{\rm V})}$, which is the concatenation of audio and visual embeddings, is designed: \begin{equation} cE_{\rm AV} = [E_{\rm V}, E_{\rm A}] = [f_{\rm V}(V), f_{\rm A}(A_{\rm FBANK})] \label{eq: eq_ceav} \end{equation} where $f_{\rm A}$ and $f_{\rm V}$ are trained independently, following the steps introduced in Section \ref{sec: sec_AEASE_main} and Section \ref{sec: sec_VEE_place}, respectively. The cMEASE model takes both $A_{\rm LPS}$ and $cE_{\rm AV}$ as inputs and outputs $M$: \begin{align} M=\sigma(s_{\rm F}([s_{\rm E}(cE_{\rm AV}), s_{\rm LPS}(A_{\rm LPS})])) \end{align} We use the same optimization process as in Section \ref{sec: sec_VEASE} to minimize $\mathcal{L}_{\rm MSE}$, which is calculated by Equation (\ref{eq: eq_mse}). \subsection{Fusion Stage of Audio and Visual Embeddings}\label{sec: sec_fuse_stage} \begin{figure}[htb] \centering \includegraphics[width=0.95\linewidth]{fig_fuse_stage-eps-converted-to.pdf} \caption{Illustration of the MEASE model with different fusion stages of audio and visual embeddings.} \label{fig: fig_fuse_stage} \end{figure} To study the effect of the audio-visual fusion stage on enhancement performance, we design a MEASE model that fuses visual and audio embeddings at the $i$-th layer of the enhancement network, denoted as Middle-i model, as shown in Figure \ref{fig: fig_fuse_stage}. We change $N_{\rm E}$ with the fixed sum of $N_{\rm E}$ and $N_{\rm F}$ and use the same stack to process audio and visual embeddings, respectively: \begin{align} R_{E_{\rm V}}=& s_{\rm E}(E_{\rm V}) = \overbrace{\operatorname{ConvBlock_{1D}}(\cdots \operatorname{ConvBlock_{1D}}(E_{\rm V}))}^{N_{\rm E} = i} \label{eq: eq_VE} \\ R_{E_{\rm A}} =& s_{\rm E}(E_{\rm A}) = \overbrace{\operatorname{ConvBlock_{1D}}(\cdots \operatorname{ConvBlock_{1D}}(E_{\rm A}))}^{N_{\rm E} = i} \label{eq: eq_AE} \\ R_{\rm LPS}=& s_{\rm LPS}(A_{\rm LPS}) = \overbrace{\operatorname{ConvBlock_{1D}}(\cdots \operatorname{ConvBlock_{1D}}(A_{\rm LPS}))}^{N_{\rm LPS}}\\ \begin{split} M=&\sigma(s_{\rm F}([R_{E_{\rm V}}, R_{E_{\rm A}}, R_{\rm LPS}])) \\ =&\sigma(\overbrace{\operatorname{ConvBlock_{1D}}(\cdots \operatorname{ConvBlock_{1D}}([R_{E_{\rm V}}, R_{E_{\rm A}}, R_{\rm LPS}]))}^{N_{\rm F} = 25-i}) \end{split} \end{align} where $s_{\rm E}(\cdot)$ in Equation (\ref{eq: eq_VE}) has the same params as that in Equation (\ref{eq: eq_AE}), as well as $E_{\rm A}$ and $E_{\rm V}$ are extracted by using $f_{\rm A}$ and $f_{\rm V}$ trained independently. By modifying the value of $i$, we can make the fusion take places at different stages without changing the network structure. \section{Experiments}\label{sec: sec_exp} \subsection{Dataset}\label{sec: sec_dataset} To evaluate the performance of our proposed method, we created a simulation dataset of noisy speech based on the TCD-TIMIT audio-visual corpus \cite{harte2015tcd}. The TCD-TIMIT consisted of $59$ volunteer speakers with around $98$ videos each, as well as $3$ lipspeakers who specially were trained to speak in a way that helped the deaf understand their visual speech. The speakers were recorded saying various sentences from the TIMIT corpus \cite{garofolo1993darpa} by using both front-facing and $30$-degree cameras. However, the utterances of $3$ lipspeakers and $30$-degree videos were not used in this paper. For testing the robustness to unseen speaker condition, we divided these videos and audios into a \emph{train-clean} set which consisted of $57$ speakers ($31$ male and $26$ female) and a \emph{test-clean} set which consisted of $2$ speakers ($1$ male and $1$ female) who were not in the \emph{train-clean} set. We chose the TCD-TIMIT dataset for two main reasons: \begin{enumerate}[(1)] \item TCD-TIMIT was recorded in a controlled environment, and provided near-field signals collected by a microphone close to the mouth, which can ensure that the utterances do not contain background noise. While other large-scale in-the-wild audio-visual datasets, such as BBC-Oxford LipReading Sentences 2 (LRS2) dataset \cite{chung2017lip}, AVSpeech dataset \cite{Ephrat2018looking}, etc, were collected from real-world sources using automated pipeline, and none of them was checked whether background noise exists.\footnote{We manually listen to the test and verification sets of the LRS2 dataset. We find more than half of sentences can be clearly perceived as noisy.} When testing an enhancement system, if the ground truth contains background noise, the metrics will be severely distorted and cannot well measure the performance of the system. \item The utterances consisted of various phrases in the TCD-TIMIT dataset, thus they were more suitable for actual scenarios than the utterances consisting of a fixed set of phrases in the GRID dataset \cite{cooke2006audio}. The TCD-TIMIT dataset also contained phonetic-level transcriptions, which provided available labels for the embedding extractor training. \end{enumerate} A total of $115$ noise types, including $100$ noise types in \cite{hu2010tandem} and $15$ homemade noise types, were adopted for training to improve the robustness to unseen noise types. The $5600$ utterances from \emph{train-clean} set were corrupted with the above-mentioned $115$ noise types at five levels of SNRs, i.e., $15$ dB, $10$ dB, $5$ dB, $0$ dB and $-5$ dB, to build an $35$-hour multi-condition training set consisting of pairs of clean and noisy utterances. The other $43$ utterances from \emph{train-clean} set were corrupted with $3$ unseen noise types at above-mentioned SNR levels to build a validation set, i.e., Destroyer Operations, Factory2 and F-16 Cockpit. The $198$ utterances from \emph{test-clean} set were used to construct a test set for each combination of $3$ other unseen noise type and above SNR levels, i.e., Destroyer Engine, Factory1 and Speech Babble. All unseen noise were collected from the NOISEX-92 corpus \cite{varga1993assessment}. The five levels of SNRs in the training set were also adopted for testing and validating. For audio preprocessing, all speech signals were resampled to $16$ kHz. A $400$-point short-time Fourier transform was used to compute the spectra of each overlapping windowed frame. Here, a $25$-ms Hanning window and a $10$-ms window shift were adopted. In our experiments, $201$-dimensional LPS vectors were generated to train the enhancement network and $40$-dimensional FBANK vectors were generated to train the embedding extractor, i.e., $F=201, F_{\rm mel}=40$. Mean and variance normalizations were applied to the noisy LPS and FBANK vectors. For video preprocessing, a given video clip was downsampled from $29.97$ fps to $25$ fps, i.e., $T_A=4\times T_V$. For every video frame, $68$ facial landmarks were extracted by using Dlib \cite{king2009dlib} implementation of the face landmark estimator described in \cite{kazemi2014one}, then we cropped a lip-centered window of size $98\times 98$ pixels by using the $20$ lip landmarks from the $68$ facial landmarks. The frames were transformed to grayscale and normalized with respect to the overall mean and variance. \subsection{Evaluation Protocol}\label{sec: sec_metric} In this experiment, we mainly adopt Perceptual Evaluation of Speech Quality (PESQ) \cite{rix2001perceptual} and Short-Time Objective Intelligibility (STOI) \cite{taal2011algorithm} to evaluate models. Both metrics are commonly used to evaluate the performance of speech enhancement system. PESQ, which is a speech quality estimator, is designed to predict the mean opinion score of a speech quality listening test for certain degradations. Moreover, to show the improvement in speech intelligibility, we also calculated STOI. The STOI score is typically between $0$ and $1$, and the PESQ score is between $-0.5$ and $4.5$. For both metrics, higher scores indicate better performance. \subsection{Results of VEASE Models Utilizing Different Visual Embeddings}\label{sec: sec_best_VE} \begin{figure}[htb] \centering \includegraphics[width=0.8\linewidth]{fig_val_loss-eps-converted-to.pdf} \caption{A comparison of learning curves among NoEASE, VEASE-word (LRW), VEASE-phone and VEASE-place on the validation set.} \label{fig: fig_VEASE_val_loss} \end{figure} \begin{table}[htb] \centering \caption{Average performance comparison of VEASE models with different visual embeddings on the test set at different SNRs averaged over 3 unseen noise types.} \label{tab: tab_VEASE} \footnotesize \setlength{\tabcolsep}{5pt}{ \begin{tabular}[b]{|l|ccccc|ccccc|} \toprule \textbf{Model}&\multicolumn{5}{c|}{\textbf{PESQ}}&\multicolumn{5}{c|}{\textbf{STOI}(in \%)}\\ \midrule {\textbf{SNR}(in dB)}&-5&0&5&10&15&-5&0&5&10&15\\ \midrule {Noisy}&$1.70$&1.97&2.26&2.56&2.86&54.34&65.11&75.33&84.48&90.88\\ {NoEASE}&2.07&2.34&2.64&2.92&3.21&58.79&70.29&80.24&87.83&92.57\\ {VEASE-word}&2.16&2.45&2.72&2.99&3.25&66.26&75.11&82.57&88.75&92.98\\ {VEASE-phone}&2.14&2.42&2.69&2.96&3.23&66.29&74.89&82.22&88.45&92.79\\ {VEASE-place}&2.21&2.47&2.73&3.00&3.26&66.57&75.27&82.64&88.80&92.96\\ \bottomrule \end{tabular} } \end{table} In Section \ref{sec: sec_VEASE_main}, we proposed two VEASE models with different visual embeddings, i.e., VEASE-phone and VEASE-place. To compare their effectiveness with the baseline model, i.e., VEASE-word (LRW), on enhancement performance, a series of experiments were conducted for the unprocessed system denoted as Noisy, NoEASE, VEASE-word (LRW), VEASE-phone and VEASE-place. We present the learning curves of the MSEs among NoEASE, VEASE-word (LRW) and VEASE-phone and VEASE-place on the validation set in Figure \ref{fig: fig_VEASE_val_loss}. The corresponding evaluation metrics are shown in Table \ref{tab: tab_VEASE}. We evaluate the average performance of two measures at different SNRs across $3$ unseen noise types. Based on Figure \ref{fig: fig_VEASE_val_loss} and Table \ref{tab: tab_VEASE}, we find following observations. \begin{enumerate}[(1)] \item The learning curves of the MSEs indicate that all VEASE models consistently generate smaller MSEs on the validation set than NoEASE. This result implies that the visual embedding is useful for speech enhancement. As shown in Table \ref{tab: tab_VEASE}, all VEASE models yield improvements in PESQ and STOI over NoEASE in all SNRs. In particular, the improvement is more significant at low SNRs cases. \item VEASE-word (LRW) consistently yields smaller MSE values and a slower convergence than VEASE-phone. This implies that the visual embedding in VEASE-word (LRW) is more useful but slow-fit for speech enhancement. In VEASE-word (LRW), visual embedding extractor is trained with a large amount of additional data, so it can obtain better generalization ability and provide visual embedding with more information. On the other side, the data mismatch between embedding learning and enhancement task brings information redundancy, which leads to a slower convergence. This observation is consistent with the comparison of the objective evaluation metrics on the test set shown in Table \ref{tab: tab_VEASE}. And VEASE-phone does not perform better than VEASE-word (LRW) in any evaluation metrics. \item VEASE-place clearly achieves a better and faster convergence than VEASE-phone and VEASE-word (LRW). This implies that VEASE-place provides more useful and quick-fit visual embedding for speech enhancement. By comparing the evaluation metrics in Table \ref{tab: tab_VEASE}, we also observe that VEASE-place not only yields remarkable gains over VEASE-phone across all evaluation metrics and all SNR levels, but also outperforms VEASE-word (LRW) in most cases with only one exception for the STOI at $15$ dB SNR. And in that exceptional situation, the results are still close. These results suggest that our proposed VEASE-place model achieves a better generalization capability, while reducing mismatch between embedding learning and enhancement task. \end{enumerate} Overall, the high correlation between the articulation place label and the acoustic information in video is beneficial to the extraction of visual embedding, which is useful for speech enhancement, even if no requirement of additional data. Therefore, we select articulation place as the default classification target in all subsequent experiments and use VEASE to refer to VEASE-place in all subsequent sections. \subsection{Results of Proposed MEASE Model} \label{sec: sec_MEASE_result} \begin{table}[htb] \centering \caption{Average performance comparison of NoEASE model, VEASE model, AEASE model, cMEASE model and MEASE model on the test set at different SNRs averaged over 3 unseen noise types.} \label{tab: tab_MEASE_result} \footnotesize \setlength{\tabcolsep}{5pt}{ \begin{tabular}[b]{|l|ccccc|ccccc|} \toprule \textbf{Model}&\multicolumn{5}{c|}{\textbf{PESQ}}&\multicolumn{5}{c|}{\textbf{STOI}(in \%)}\\ \midrule \textbf{SNR}(in dB)&-5&0&5&10&15&-5&0&5&10&15\\ \midrule NoEASE&2.07&2.34& 2.64&2.92&3.21&58.79&70.29&80.24&87.83&92.57\\ VEASE&2.21&2.47&2.73&3.00&3.26&66.57&75.27&82.64&88.80&92.96\\ AEASE&2.09&2.39&2.69&2.98&3.27&60.84&72.24&81.58&88.39&92.76\\ cMEASE&2.27&2.55&2.81&3.08&3.34&67.60&76.26&83.26&89.13&93.12\\ MEASE&2.29&2.59&2.88&3.16&3.42&68.96&77.64&84.43&89.99&93.64\\ \bottomrule \end{tabular} } \end{table} In this section, the goal is to examine the effectiveness of the proposed MEASE model on enhancement performance, and obtain a better understanding about the contribution of different parts of the MESAE model. We present an average performance comparison between NoEASE, VEASE, AEASE, cMEASE and MEASE in Table \ref{tab: tab_MEASE_result}. Paying attention to the last row in Table \ref{tab: tab_MEASE_result}, we can observe that MEASE shows significant improvements over VEASE across all evaluation metrics, and larger gains are observed at high SNRs. By comparing the results of VEASE with NoEASE, the improvement yielded by visual embedding decreases as SNR increases, for example, the PESQ of VEASE increased from $2.07$ to $2.21$ at $-5$ dB SNR and from $3.21$ to $3.26$ at $15$ dB SNR. This observation is consistent with that in \cite{wang2020robust}. In contrast, MEASE shows stable improvements over NoEASE for high SNRs. For example, the PESQ of MEASE increased from $2.07$ to $2.29$ at $-5$ dB SNR and from $3.21$ to $3.42$ at $15$ dB SNR. All these results indicate that MEASE is more robust against the change of noise level and yields better generalization capability than VEASE. Table \ref{tab: tab_MEASE_result} also shows the results of AEASE. By comparing its results with NoEASE, we can observe that the improvement yielded by audio embedding increases as SNR grows, for example, the PESQ of AEASE increased from $2.07$ to $2.09$ at $-5$ dB SNR and from $3.21$ to $3.27$ at $15$ dB SNR. This suggest that the complementarity between audio and visual embeddings lies in the variation tendencies of metric improvement with respect to SNR level. But directly comparing AEASE and VEASE on the evaluation metrics as shown in Table \ref{tab: tab_MEASE_result}, we can not observe that AEASE performs better than VEASE at high SNRs, i.e., $\operatorname{SNR}=5$, $10$ and $15$ dB, especially at $5$ dB SNR. \begin{table}[htb] \centering \caption{Average performances of different models on the test set at different SNRs and different articulation places averaged over 3 unseen noise types.} \label{tab: tab_place_pesq} \tiny \setlength{\tabcolsep}{0.6pt}{ \begin{tabular}[b]{|l|c|c|c|c|c|c|c|c|c|c|c|c|} \toprule \textbf{SNR}(in dB)&\multicolumn{4}{c|}{-5}&\multicolumn{4}{c|}{0}&\multicolumn{4}{c|}{5}\\ \midrule \diagbox{Place}{Model}&NoEASE&AEASE&VEASE&MEASE&NoEASE&AEASE&VEASE&MEASE&NoEASE&AEASE&VEASE&MEASE\\ \midrule Labial&1.28&1.38&1.58&1.76&1.57&1.75&1.81&2.06&2.05&2.18&2.23&2.50\\ Mid&1.54&1.68&1.86&2.02&2.03&2.21&2.29&2.45&2.58&2.72&2.73&2.96\\ High&1.38&1.52&1.65&1.81&1.79&1.95&1.99&2.17&2.28&2.39&2.42&2.62\\ Low&1.63&1.89&2.00&2.29&2.17&2.48&2.46&2.69&2.84&2.99&2.93&3.20\\ Retroflex&1.46&1.66&1.75&2.00&1.95&2.15&2.12&2.32&2.44&2.57&2.54&2.77\\ Coronal&1.59&1.74&1.80&1.93&1.92&2.07&2.05&2.23&2.30&2.39&2.35&2.56\\ Glottal&1.02&1.22&1.36&1.70&1.42&1.71&1.59&1.92&1.95&2.10&2.05&2.30\\ Velar&1.31&1.44&1.41&1.49&1.48&1.64&1.68&1.86&1.86&2.01&2.00&2.22\\ Dental&0.94&1.22&1.25&1.64&1.32&1.62&1.36&2.05&1.98&2.21&1.98&2.44\\ \bottomrule \end{tabular} } \end{table} To further explore the complementarity between audio and visual embeddings, we present an average performance comparison between utterance segments belonging to different articulation places in Table \ref{tab: tab_place_pesq}. Because the utterance segment does not have actual semantics, we only examine the average performance of PESQ at different SNRs across $3$ unseen noise types. Table \ref{tab: tab_place_pesq} illustrates VEASE and AEASE play a major role at different articulation places, respectively, at the same SNR level. Even at high SNRs, VEASE still yields improvement than AEASE in some articulation places. For example, VEASE's PESQ values are $2.23$, $2.73$, $2.42$, while AEASE's PESQ values are $2.18$, $2.72$, $2.39$ in Labial, Mid, High at $5$ dB SNR level. This result explains why AEASE does not outperform VEASE at high SNR levels. Relating to the lip shapes belonging to different articulation places, as shown in Figure \ref{fig: fig_lip2place}, we find VEASE yields greater improvement at articulation places where the lip shapes change greatly, i.e., Labial, Mid and High, while AEASE is on the contrary. Overall, we can conclude that the complementarity between audio and visual embeddings lies in different SNR levels, as well as different articulation places. More specifically, in the cases that the SNR level is low and the articulation place has high visual correlation, visual embedding performs better. And audio embedding is better on articulation places with low visual correlation at high SNR levels. Based on these observations, our proposed MEASE model takes the advantages of visual and audio embeddings, and achieves the best performance in all SNRs and all articulation places. The information intersection-based audio-visual fusion manner in the MEASE model is our another contribution. From Table \ref{tab: tab_MEASE_result}, we can observe that MEASE consistently outperforms cMEASE over all SNR levels in terms of all 2 measures, especially at high SNRs. This observation demonstrates that the information intersection-based audio-visual fusion method has better information integration capability for audio and visual embeddings than channel-wise concatenation which is widely used in previous works. \subsection{Results of Different Audio-Visual Fusion Stages}\label{sec: sec_fusion_posion} \begin{figure}[htbp] \centering \subfigure[PESQ]{ \begin{minipage}[t]{\linewidth} \centering \includegraphics[width=0.8\linewidth]{figure_fusion_stage_PESQ-eps-converted-to.pdf} \label{fig: fig_fusion_stage_result_PESQ} \end{minipage}% }% \subfigure[STOI]{ \begin{minipage}[t]{\linewidth} \centering \includegraphics[width=0.8\linewidth]{figure_fusion_stage_STOI-eps-converted-to.pdf} \label{fig: fig_fusion_stage_result_STOI} \end{minipage}% }% \centering \caption{Average performance comparison among different audio-visual fusion stages for the PESQ/STOI measures at different SNRs averaged over $3$ unseen noise types. The top figure shows the PESQ measure. The bottom figure shows the STOI measure.} \label{fig: fig_fusion_position_result} \end{figure} One of the most significant differences between our method and previous methods is that the proposed MEASE model fuses audio and visual modes in the stage of embedding extractor training. It is an early fusion while previous methods fuse audio and visual modes in the middle of the enhancement network, known as the middle fusion. For verifying the effectiveness of the early fusion on enhancement performance, we design an experimental comparative study described in Section \ref{sec: sec_fuse_stage} and conduct a set of experiments using five different $i$, i.e., $i=5, 10, 15, 20, 25$. As we can see from Figure \ref{fig: fig_fusion_position_result}, MEASE achieves the best results over all models utilizing the middle fusion across all evaluation metrics for all SNR levels. By comparing the results of different middle fusion-based models, the variation tendencies of all objective metrics with respect to different fusion stage get worse as the stage moves back. These results suggest that early fusion strategy can better integrate useful information for speech enhancement from both modalities than the standard fusion which happens at the middle layer of enhancement network. \section{Conclusion} \label{sec: sec_conclusion} In this study, we extend the previous audio-visual speech enhancement (AVSE) framework to embedding aware speech enhancement (EASE). We first propose visual embedding to enhance speech, leveraging upon the high correlation between articulation place labels and acoustic information in videos. Next, we propose multi-modal audio-visual embedding obtained by fusing audio and visual embedding in the stage of embedding extraction training under the supervision of their information intersection at the articulation place label level. Extensive experiments empirically validate that our proposed visual embedding consistently yields improvements over the conventional word-based approaches. And our proposed audio-visual embedding achieves even greater performance improvements by utilizing the complementarity of audio and visual embedding in a information intersection-based way, with higher information integration capabilities and better speech enhancement performance in early fusion. Our future work will focus on how to use unsupervised or self-supervised techniques to extract effective audio-visual embedding, in order to achieve a comparable or better enhancement performance than the current framework. \section{Acknowledgements} This work was supported by the National Natural Science Foundation of China under Grant No.61671422.
{'timestamp': '2020-09-22T02:21:20', 'yymm': '2009', 'arxiv_id': '2009.09561', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09561'}
arxiv
\section*{Abstract} Modern reinforcement learning methods for planning often incorporate an unsupervised learning step where the training objective leverages only static inputs, such as reconstructing observations. These representations are then combined with predictor functions for simulating rollouts to navigate the environment. We are interested in advancing this idea by taking advantage of the fact that we are navigating a dynamic environment with visual stimulus and would like a representation that is specifically designed for control and action in mind. We propose to simultaneously learn a feature map that is maximally predictable for a predictor function. This results in representations that are well-suited, by design, for the downstream task of planning, where the predictor is used as an approximate forward model. To this end, we introduce a new way of jointly learning this representation along with the prediction function, a system we dub Latent Representation Prediction Network (LARP). The prediction function is used as a forward model for a search on a graph in a viewpoint-matching task and the representation learned to maximize predictability is found to outperform a pre-trained representation. The sample-efficiency \added{and overall performance} of our approach is shown to rival standard reinforcement learning methods and our learned representation transfers successfully to novel environments. \section*{Introduction} While modern reinforcement learning algorithms reach super-human performance on tasks such as gameplaying, they remain woefully sample inefficient compared to humans. An algorithm that is data~\cite{icpram19} or sample-efficient \cite{wang2016sample} requires only few samples for good performance and the study of sample-efficient control is currently an active research area \cite{corneil2018efficient}~\cite{du2019good}~\cite{saphal2020seerl}~\cite{NIPS2018_8044}. A powerful tool for increasing the sample-efficiency of machine learning methods is dimensionality reduction. There has been much recent work on methods that take advantage of compact, low-dimensional representations of states for search and exploration~\cite{kurutach2018learning}~\cite{corneil2018efficient}~\cite{{xu1029regression}}. One of the advantages of this approach is that a good representation aids in faster and more accurate planning. This holds in particular when the latent space is of much lower dimensionality than the state space\cite{hamilton2014efficient}. For high-dimensional inputs, such as image data, a representation function is frequently learned to reduce the complexity for a controller. In deep reinforcement learning, the representation and the controller are learned simultaneously. Similarly, a representation can in principle be learned along with a forward model for classical planning in high-dimensional space. This paper introduces \textit{Latent Representation Prediction} (LARP) networks, a novel neural network-based method for learning a domain representation and a transition function for planning within the learned latent space (Fig.~\ref{Conceptual1.pdf}). During training, the representation and the predictor are learned simultaneously from transitions in a \added{self-}supervised manner. We train the predictor to predict the most likely future representation, given a current representation and an action. The predictor is then used for planning by navigating the latent space defined by the representation to reach a goal state. Optimizing control in this manner after learning an environment model has the advantage of allowing for learning new reward functions in a fast and sample-efficient manner. \added{After the representation is learned, we find said goal state by conventional path planning.} Disentangling the reward from the transition function in such a way is helpful when learning for multiple or changing reward functions and aids with learning when there is no reward available at all. Thus, it is also good for a sparse or a delayed-reward setting. \begin{figure}[htb] \begin{adjustwidth}{-0.in}{0in} \caption{{\bf Conceptual overview of our method.} The important components are the representation network along with the predictor network. Together, they comprise a LARP network which is utilized by a planning algorithm.} \centering \includegraphics[width=0.7\textwidth]{assets_png/Conceptual_simpler.pdf} \label{Conceptual1.pdf} \end{adjustwidth} \end{figure} A problem that can arise in representation learning is the one of trivial features. This can happen when the method is optimizing an objective function that has a straightforward, but useless, solution. For example, Slow Feature Analysis (SFA) \cite{wiskott2002slow} has the objective of extracting the features of time series data that vary the least with time. This is easily fulfilled by constant functions, so SFA includes an optimization constraint to avoid constant solutions. Constant features would in a similar manner be maximally predictable representations for our system. Therefore, we study three different approaches to prevent this trivial representation from being learned, we either: \textbf{(i)} design the architecture such that the output is sphered, \textbf{(ii)} regularize it with a contrastive loss term, or \textbf{(iii)} include a reconstruction loss term along with an additional decoder module. We compare these approaches and validate our method experimentally on a visual environment: a viewpoint-matching task using the NORB data set \cite{lecun2004learning}, where the agent is presented with a starting viewpoint of an object and the task is to produce a sequence of actions such that the agent ends up with the goal viewpoint. As the NORB data set is embeddable on a cylinder \cite{schuler2018gradient} \cite{hadsell2006dimensionality} or a sphere \cite{wang2018toybox}, we can visualize the actions as traversing the embedded manifold. \added{ Our approach compares favorably to state-of-the-art methods on our testbed with respect to sample efficiency, but our asymptotic performance is still outclassed by other approaches.} \section*{Related work} Most of the related work falls into the categories of reinforcement learning, visual planning, or representation learning. The primary \replaced{difference between ours and}{conceptual shortcoming of} other model-based methods is that the representation is learned by optimizing auxiliary objectives which are \replaced{not directly useful for solving the main task.}{of direct interest for maximizing rewards.} \subsection*{Reinforcement learning} There are many works in the literature that also approximate the transition function of environments, for instance by performing explicit latent-space planning computations \cite{tamar2016value} \cite{srinivas2018universal} \cite{hafner2018learning} \cite{henaff2017model} \cite{chua2018deep} \cite{gal2016improving} as part of learning and executing policies. Gelada et al.\ \cite{gelada2019deepmdp} train a reinforcement learning (RL) agent to simultaneously predict rewards as well as future latent states. Our work is distinct from these as we are not assuming a reward signal \deleted{and are dependent on fewer known POMDP parameters} during training. Vision, memory, and controller modules are combined for learning a model of the world before learning a decision model in Ha and Schmidhuber's World Models \cite{ha2018world}. A predictive model is trained in an unsupervised manner, permitting the agent to learn policies completely within its learned latent space representation of the environment. The main difference is that they first approximate the state distribution using a variational autoencoder, producing the encoded latent space. In contrast, our representation is learned such that it is maximally predictable for the predictor network. Similar to our training setup, Oh et al.~\cite{oh2015action} predict future frames in ATARI environments conditioned on actions. The predicted frames are used for learning the transition function of the environment, e.g.\ for improving exploration by informing agents of which actions are more likely to result in unseen states. Our work differs as we are acting within a learned latent space and not the full input space \added{and our representations are used in a classical planning paradigm with start and goal states instead of a reinforcement learning one}. \subsection*{Visual planning} We define visual planning as the problem of synthesizing an action sequence to generate a target state from an initial state, and all the states are observed as images. Variational State Tabulations~\cite{corneil2018efficient} learn a state representation in addition to a transfer function over the latent space. However, their observation space is discretized into a table using a variational approach, as opposed to our continuous representation. \added{A continuous representation circumvents the problem of having to determine the size of such a table in advance or during training.} Similarly, Cuccu et al.~\cite{cuccu2018playing} discretize visual input using unsupervised vector quantization and use that representation for learning controllers for Atari games. Inspired by classic symbolic planning, Regression Planning Networks \cite{{xu1029regression}} create a plan backward from a symbolic goal. We do not have access to high-level symbolic goal information for our method and we assume that only high-dimensional visual cues are received from the environment. Topological memories of the environment are built in Semi-parametric Topological Memories \cite{savinov2018semi} after \replaced{being provided with observation sequences from humans exploring the environment.}{manual exploration.} Nodes are connected if a predictor estimates that they are close. The method has problems with generalization, which are reduced in Hallucinative Topological Memories \cite{liu2020hallucinative}, where the method also admits a description of the environment, such as a map or a layout vector, which the agent can use during planning. Our visual planning method does not receive any additional information on unseen environments and does not depend on manual exploration during training. Causal InfoGAN \cite{kurutach2018learning} and related methods \cite{wang2019learning} are based on generative adversarial networks (GANs) \cite{goodfellow2014generative}, inspired by InfoGAN in particular \cite{chen2016infogan}, for learning a plannable representation. A GAN is trained for encoding start and goal states and they plan a trajectory in the representation space as well as reconstructing intermediate observations in the plan. \replaced{Our method is different as it does not need to reconstruct the observations and the forward model is directly optimized for prediction.}{Our method is different as it learns the representation as well as the forward model end-to-end, giving up the need for reconstruction.} \subsection*{Prediction-based Representation learning} In Predictable Feature Analysis \cite{richthofer2015predictable}, representations are learned that are predictable by autoregression processes. Our method is more flexible and scales better to higher dimensions as the predictor can be any differentiable function. Using the output of other networks as prediction targets instead of the original pixels is not new. The case where the output of a larger model is the target for a smaller model is known as knowledge distillation \cite{hinton2015distilling} \cite{bucilua2006model}. This is used for compressing a model ensemble into a single model. Vondrick et al. \cite{vondrick2016anticipating} learn to make high-level semantic predictions of future frames in video data. Given a current frame, a neural network predicts the representation of a future frame. Our approach is not constrained only to pre-trained representations, we learn our representation together with the prediction network. Moreover, we extend this general idea by also admitting an action as the input to our predictor network. \section*{Materials and methods} In this work, we study different representations for learning the transition function of a partially observable MDP (POMDP) and propose a network that jointly learns a representation with a prediction model and apply it for latent space planning. We summarize here the different ingredients of the LARP network -- our proposed solution. More detailed descriptions will follow in later sections. \textbf{Training the predictor network:} We use a two-stream fully connected neural network (see~\nameref{S2_appendix} for details) to predict the representation of the future state given the current state's representation and the action bridging those two states. The predictor module is trained with a simple mean-squared error term. \textbf{Handling constant solutions:} The representation could be transferred from other domains or learned from scratch on the task. If the representation is learned simultaneously with an \replaced{estimate}{estimation} of a Markov decision process's (MDP) transition function, precautions must be taken such that the prediction loss is not trivially minimized by a representation that is constant over all states. We consider three approaches for tackling the problem: sphering the output, regularizing with a contrastive loss term, and regularizing with a reconstructive loss term. \textbf{Searching in the latent space:} Combining the representation with the predictor network, we can search in the latent space until a node is found that has the largest similarity to the representation of the goal viewpoint using a modified best-first search algorithm. \textbf{NORB environment:} We use the NORB data set~\added{\cite{lecun2004learning}} for our experiments. This data set consists of images of objects from different viewpoints and we create viewpoint-matching tasks from the data set. \subsection*{Partially-observable Markov decision processes} Many real-world situations can be \replaced{described as}{reduced to} partially-observable Markov decision processes (POMDP) \cite{cassandra1998survey}. Under this general framework, there are \textit{agents} taking \textit{actions} $A$ changing their environment's \textit{state} $S$. The information that they have on the states comes from the \textit{observations} $O$ they perceive as not all the details of the environment's state \replaced{are}{is} generally known. How the environment's state $S_t$ at a time step $t$ changes after an action $A_t$ is performed is governed by the transition function $T(S_t, A_t)$. \replaced{Additionally,}{After the action $A_t$ is realized,} the system grants the agent a reward $R_t$, whose value is determined by the reward function $R(S_t, A_t)$. In this work, we will refer the objective of the agent in the environment, such as reaching a goal location, as its \textit{task} The goal of the agent is to maximize the expected cumulative discounted future reward $\mathbb{E} \left[ \sum_{t=0}^\infty \gamma^t R_t \right]$ in the environment, where a discount factor $\gamma \in [0, 1]$ is given in the POMDP. Model-free RL methods learn an optimal policy to maximize the reward without modeling the environment transition function separately. We learn a transition function for a low-dimensional representation, as well as the representation itself, of the observation space, which we use to maximize the reward in the POMDP. Our method is thus a model-based RL method, since we effectively learn a model of the environment's dynamics. \subsection*{On good representations} We rely on heuristics to provide sufficient evidence for a good --- albeit not necessarily optimal --- decision at every time step to reach the goal. Here we use the Euclidean distance in representation space: a sequence of actions is preferred if their end location is closest to the goal. The usefulness of this heuristics depends on how well and how coherently the Euclidean distance encodes the actual distance to the goal state in terms of the number of actions. A learned predictor network approximates the transition function of the environment for planning in the latent space defined by some representation. This raises the question: what is the ideal representation for latent space planning? Our experiments show that an openly available, general-purpose representation, such as a pre-trained VGG16 \cite{simonyan2014very}, can already provide sufficient guidance to apply such heuristics effectively. Better still are representation models that are trained on the data at hand, for example, uniform manifold approximation and projection (UMAP) \cite{mcinnes2018umap} or variational auto-encoders (VAEs) \cite{kingma2013auto}. One might, however, ask what a particularly suited representation might look like when attainability is ignored. It would need to take the topological structure of the underlying data manifold into account, so that the Euclidean distance becomes a good proxy for the geodesic distance. One class of methods that satisfy this are spectral embeddings, such as Laplacian Eigenmaps (LEMs) \cite{belkin2003laplacian}. Their representations are smooth and discriminative which is ideal for our purpose. However, they do not easily produce out-of-sample embeddings, so they will only be applied in an in-sample fashion to serve as a control experiment\replaced{, yielding optimal performance.}{-- and we get perfect performance with LEMs.} \subsection*{Predictor network} As the representation is used by the predictor network, we want it to be predictable. Thus, we optimize the representation learner simultaneously with the predictor network, in an end-to-end manner. Suppose we have a representation map $\phi$ and a training set of $N$ labeled data tuples $(X_t = [O_t, A_t], Y_t = O_{t+1})$, where $O_t$ is the observation at time step $t$ and $A_t$ is an action resulting in a state with observation $O_{t+1}$. We train the predictor $f$, parameterized by $\theta$, by minimizing the mean-squared error\replaced{:}{loss over $f$'s parameters:} \begin{equation} \underset{\theta}{\text{argmin}} \ \mathcal{L}_{\text{prediction}}(\added{\mathcal{D}}, \theta) = \underset{\theta}{\text{argmin}} \ \frac{1}{N} \sum_{t=1}^N \big \Vert \phi(O_{t+1}) - f_\theta(\phi(O_t), A_t) \big \Vert ^2 \end{equation} \noindent where $\added{\mathcal{D}} = \{ (X_t, Y_t) \}_{t=0}^N $ is our set of training data. We construct $f$ as a two-stream, fully connected, neural network (\nameref{S2_appendix}). Using this predictor we can carry out planning in the latent space defined by $\phi$. By planning, we mean that there is a start state with observation $O_{\text{start}}$ and a goal state with $O_{\text{goal}}$ and we want to find a sequence of actions connecting them. The network outputs the expected representation after acting. Using this, we can formulate planning as a classical pathfinding or graph traversal problem. \subsection*{Avoiding trivial solutions} In the case where $\phi$ is trainable and parameterized by $\eta$, the loss for the whole system that only cares about maximizing predictability is \begin{equation} \underset{\theta, \eta}{\text{argmin}} \ \mathcal{L}_{\text{prediction}}(\added{\mathcal{D}}, \theta, \eta) = \underset{\theta, \eta}{\text{argmin}} \ \frac{1}{N} \sum_{t=1}^N \left(\phi_\eta(O_{t+1}) - f_\theta(\phi_\eta(O_t), A_t) \right)^2 \label{uselessloss} \end{equation} for a given data set \replaced{$\mathcal{D}$.}{$D$.} With no constraints on the family of functions that $\phi$ can belong to, we run the risk that the representation collapses to a constant. Constant functions $\phi = c$ trivially yield zero loss for any set \replaced{$\mathcal{D}$}{$D$} if $f_\theta$ outputs the input state again for any $A$, i.e $f(\phi(\cdot), A) = \phi(\cdot)$: Constant representations are optimal with respect to predictability but they are unfortunately useless for planning, as we need to discriminate different states. This objective is not present in the proposed loss function in Eq.~\eqref{uselessloss} and we must thus add a constraint or another loss term to facilitate differentiating the different states. There are several ways to limit the function space such that constant functions are not included, for example with decoder \cite{goroshin2015learning} or adversarial \cite{denton2017unsupervised} loss terms. In this work, we do this with \textbf{(i)} a sphering layer, \textbf{(ii)} a contrastive loss, or \textbf{(iii)} a reconstructive loss. \subsubsection*{(i) Sphering the output} The problem of trivial solutions is solved in Slow Feature Analysis \cite{wiskott2002slow} and related methods \cite{schuler2018gradient} \cite{escalante2013solve} by constraining the overall covariance of the output to be $I$. Including this constraint to our setting yields the optimization formulation: \begin{equation} \begin{aligned} & \underset{\eta, \theta}{\text{minimize}} & & \mathcal{L}_{\text{prediction}}(\added{\mathcal{D}}, \theta, \eta) \\ & \text{subject to} & & \mathbb{E}_{\added{\mathcal{D}}}\left[ \phi_\eta \right] \hspace{7pt}= 0 \hspace{47pt}\hspace{0.1em}\text{(zero mean)} \\ &&& \mathbb{E}_{\added{\mathcal{D}}}\left[ \phi_\eta\phi_\eta^T \right]= I\, \ \ \ \ \ \ \ \ \ \ \ \,\text{(unit covariance)} \\ \end{aligned} \end{equation} \noindent We enforce this constraint in our network via architecture design. The last layer performs differentiable sphering \cite{schuler2018gradient}~\cite{10.1007/978-3-030-30179-8_15} of the second-to-last layer's output using the whitening matrix $\bm{W}$. We get $\bm{W}$ using power iteration of the following iterative formula: \begin{equation} \bm{u}^{[i+1]} = \frac{\bm{T}\bm{u}^{[i]}}{|| \bm{T}\bm{u}^{[i]} ||} \end{equation} \noindent \noindent \added{where the superscript $i$ tracks the iteration number and $\bm{u}^{[0]}$ can be an arbitrary vector.} \replaced{The power iteration algorithm}{Which} converges to the largest eigenvector $\bm{u}$ of a matrix $\bm{T}$ in a few hundred, quick iterations. The eigenvalue $\lambda$ is determined and we subtract the eigenvector from the matrix: \begin{equation} \bm{T} \leftarrow \bm{T} - \lambda \bm{u} \bm{u}^T \end{equation} \noindent the process is repeated until the sphering matrix is found \begin{equation}\bm{W} = \sum_{j=0} \frac{1}{\sqrt{\lambda_j}}\bm{u}_j \bm{u}_j^T \end{equation} \noindent The whole system, including the sphering layer, can be seen in Fig~\ref{spheringdiagram}, \added{with an abstract convolutional neural network as the representation $\phi$ and a fully-connected neural network as the prediction function $f$}. \begin{figure}[htb] \begin{adjustwidth}{-0.63in}{0in} \caption{{\bf Predictive representation learning with sphering regularization.} The observations $O_t$, and the resulting observation $O_{t+1}$ after the action $A$ has been performed in $O_t$, are passed through the representation map $\phi$, whose outputs are passed to a differentiable sphering layer before being passed to $f$. The predictive network $f$ minimizes the loss function $\mathcal{L}$, which is the mean-squared error between $ \phi(O_t) = \rho_t$ and $ \phi(O_{t+1}) = \rho_{t+1}$.} \centering \includegraphics[width=1.0\textwidth]{assets_png/Sphering4_plos.pdf} \label{spheringdiagram} \end{adjustwidth} \end{figure} \subsubsection*{(ii) Contrastive loss} Constant solutions can also be dealt with in the loss function instead of via architecture design. Hadsell et al. \cite{hadsell2006dimensionality} propose to solve this with a loss function that pulls together the representation of similar objects (in our case, states that are reachable from each other with a single action) but pushes apart the representation of dissimilar ones: \begin{equation} L_{\text{contrastive}}{(O, O^{'} )} = \begin{cases} || \phi (O) - \phi(O^{'}) || & \text{if } O, O^{'} \text{ are similar} \\ \max(0, M - || \phi (O) - \phi(O^{'}) || ) & \text{otherwise} \end{cases} \end{equation} \noindent where $M$ is a margin and $|| \cdot||$ is some --- usually the Euclidean --- norm. The representation of dissimilar objects is pushed apart only if the inequality \begin{equation} || \phi (O) - \phi(O^{'}) || < M \end{equation} is violated. During each training step, we compare each observation to a similar and a dissimilar observation simultaneously~\cite{schroff2015facenet} by passing a triplet of (positive, anchor, negative) observations during training to three copies of $\phi$. In our experiments, the positive corresponds to the predicted embedding of $O_{t+1}$ given $O_t$ and $A_t$, the anchor is the true resulting embedding after an action $A_t$ is performed in state $O_t$ and the negative \added{$\phi(O_n)$} is \replaced{the representation of an arbitrarily chosen observation}{any other embedding} that is not reachable from $\phi(O_t)$ with a single action. \added{For environments where this is determinable, such as in our experiments, this can be assessed from the environment's full state. When this information isn't available, ensuring for $\phi(O_n)$ and $\phi(O_t)$ that $|n-t|>2$ is a good proxy, even though this can result in some incorrect triplets. For example, when the agent runs in a self-intersecting path.} We define the representation of the observation at time step $t$ as $\rho_t = \phi(O_t)$ and the next-step prediction $\Tilde{\rho}_{t+1} := f\left(\phi(O_t), A_t)\right)$ for readability \added{and our (positive, anchor, negative) triplet is thus $\left(\Tilde{\rho}_{t+1}, \phi(O_{t+1}), \phi(O_n) \right)$} and \added{we} minimize \added{the triplet loss}: \begin{equation} \mathcal{L}_{\text{contrastive}}(O_t, O_{t+1}, O_n, A_t) = || \rho_{t+1} - \Tilde{\rho}_{t+1} || + \max(0, M - || \rho_{t+1} - \rho_n || ) \label{ourcontrastive} \end{equation} \noindent It would seem that $\rho _{t+1}$ and $\Tilde{\rho}_{t+1}$ are interchangeable since the second term is included only to prevent the representation from collapsing into a constant. However, if the loss function is \begin{equation} \mathcal{L}_{\text{contrastive}}(O_t, O_{t+1}, O_n, A_t) = || \rho_{t+1} - \Tilde{\rho}_{t+1} || + \max(0, M - || \Tilde{\rho}_{t+1} - \rho_n || ) \label{badcontrastive} \end{equation} then the network is rewarded during training for making $f$ poor at predicting the next representation instead of simply pushing the representation of $O_{t}$ and $O_n$ away from each other. There are two main ways to set the margin $M$, one is dynamically determining it per batch \cite{sun2014deep}. The other, which we choose, is constraining the representation to be on a hypersphere using $L_2$ normalization and setting a small constant margin such as $m = 0.2$ \cite{schroff2015facenet}. The architecture for the training scheme using the contrastive loss regularization is depicted in Fig.~\ref{contrastivefigure}. \begin{figure}[htb] \caption{ {\bf Predictive representation learning with contrastive loss regularization.} We minimize the contrastive loss function $\mathcal{L}_{\text{contrastive}}$ (Eq. \ref{ourcontrastive}). The predicted future representation $\Tilde{\rho}_{t+1}$ is pulled toward the next step's representation $\rho_{t+1}$. However, $\rho_{t+1}$ is pushed away from the negative state's representation $\rho_{n}$ if the distance between them is less than $M$. The observation $O_n$ is randomly selected from those that are not reachable from $O_{t}$ with a single action.} \centering \includegraphics[scale=.99]{assets_png/triplet6_plos.pdf} \label{contrastivefigure} \end{figure} \subsubsection*{(iii) Reconstructive loss} Trivial solutions are avoided by Goroshin et al. \cite{goroshin2015learning} by introducing a decoder network $D$ to a system that would otherwise converge to a constant representation. We incorporate this intuition into our framework with the loss function \begin{align} \label{decoderloss} \mathcal{L}_{\text{decoder}} (O_{t}, O_{t+1}, A_t) = \mathcal{L}_{\text{prediction}}(O_{t},O_{t+1}) + \mathcal{L}_{\text{reconstruction}}(O_{t},O_{t+1}) \nonumber && \\ =\left( \rho_t - \Tilde{\rho}_{t+1}\right)^2 + \alpha \left(O_{t+1} - D \left( \Tilde{\rho}_{t+1} \right) \right) ^2 \hspace{12pt} && \text{} \end{align} \noindent \added{where $\alpha$ is a positive, real coefficient to control the regularization strength.} \added{Fig.~\ref{decoderlossgraphic} shows how the models and loss functions are related during the training of the representation and predictor using both a predictive and a reconstructive loss term.} The desired effect of the regularization can also be achieved by replacing the second term in Eq.~\eqref{decoderloss} with $\alpha \left( O_{t+1} - D \left( \rho_{t+1}\right) \right) ^2$. By doing this we would maximize the reconstructive property of the latent code in and of itself, which is not inherently useful for planning. We instead add an additional level of predictive power in $f$: in addition to predicting the next representation, its prediction must also be useful in conjunction with the decoder $D$ for reconstructing the new true observation. \begin{figure} \caption{{\bf Predictive representation learning with decoder loss regularization.} \replaced{At time step $t$, the observation $O_t$ is passed to the representation $\phi$. This produces $\rho_t$ which is passed, along with the action $A_t$ at time step $t$, to the predictor network $f$. This produces the predicted $\Tilde{\rho}_{t+1}$ which is compared to $\rho_{t+1} = \phi(O_{t+1})$ in the mean-squared error term $\mathcal{L}_\text{prediction}$. The prediction $\Tilde{\rho}_{t}$ is also passed to the decoder network $D$. We then compare $\Tilde{O}_{t+1} = D(\Tilde{\rho}_{t+1})$ with $O_{t+1}$ in $\mathcal{L}_\text{decoder}$, another mean-squared loss term. The final loss is the sum of these two loss terms $\mathcal{L}_\text{total} = \mathcal{L}_\text{prediction}+\mathcal{L}_\text{decoder}$.}{ The $\mathcal{L}_\text{prediction}$ and $\mathcal{L}_\text{decoder}$ boxes both return the mean-squared error of their inputs and the full loss $\mathcal{L}_\text{total}$ is the sum of those two terms.}} \centering \includegraphics[scale=.99]{assets_png/decoder8_plos.pdf} \label{decoderlossgraphic} \end{figure} This approach can have the largest computational overhead of the three, depending on the size of the decoder. We construct the decoder network $D$ such that it closely mirrors the architecture of $\phi$, with convolutions replaced by transposed convolutions and max-pooling replaced by upsampling. \subsection*{Training the predictor network} We train the representation network and predictor network jointly by minimizing Eq.~(2), Eq.~(10) or Eq.~(12). The predictor network can also be trained on its own for a fixed representation map $\phi$. In this case, $f$ is tasked as before with predicting $\phi(O_{t+1})$ after the action \replaced{$A_t$}{$A$} is performed in the state with observation $O_t$ by minimizing the mean-squared error between $f(\phi(O_{t}), A_t)$ and $\phi(O_{t+1})$. The networks are built with Keras \cite{chollet2015keras} and optimized with rmsprop \cite{tieleman2012lecture}. \subsection*{Planning in transition-learned domain representation space} We use a modified best-first search algorithm with the trained representations for our experiments (Algorithm \ref{algo: gs_algo}). From a given state, the agent performs a simulated rollout to search for the goal state. For each action, the initial observation is passed to the predictor function along with the action. This results in a predicted next-step representation, which is added to a \replaced{set}{queue}. The actions taken so far and resulting in each prediction are noted also. The representation that is closest to the goal (using for example the Euclidean distance) is then taken for consideration and removed from the \replaced{set}{queue}. This process is repeated until the maximum number of trials is reached. The algorithm then outputs the sequence of actions resulting in the predicted representation that is the closest to the goal representation. \begin{algorithm} \caption{Perform a simulated rollout to find a state that is maximally similar to a goal state. Output a \replaced{sequence}{plan} to reach the found state from the start state.}\label{algo: gs_algo} \begin{algorithmic}[1] \REQUIRE $O_{\text{start}}$, $O_{\text{goal}}$, max trials $m$, action set $\mathcal{A}$, representation map $\phi$ and predictor function $f$ \ENSURE A \replaced{sequence}{plan} of actions $(A_0, \dots, A_n)$ connecting the start state to the goal state \STATE Initialize the \replaced{set}{queue} $Q$ \added{of unchecked representations} with the representation of the start state $\phi(O_{\text{start}})$ \STATE \added{ Initialize the dictionary $P$ of representation-path pairs with the initial representation mapped to an empty sequence: $P[\phi(O_{\text{start}})]\leftarrow(\varnothing$) } \STATE Initialize \replaced{the empty set of checked representations $C \leftarrow \varnothing$}{the set of checked states D as empty} \FOR{$k \leftarrow 0 \text{ to } m$} \STATE Choose $\rho'$ \added{$\leftarrow$} $\underset{\rho \in Q}{\text{argmin}} ||\rho - \phi(O_{goal}) ||$ \STATE Remove $\rho'$ from $Q$ and add it to $\added{C}$ \FORALL{actions $A \in \mathcal{A}$} \STATE Get a new estimated representation $\rho^* \added{\leftarrow} f(\rho', A)$ and add it to the \replaced{set}{queue} Q \STATE \added{Concatenate $A$ to the end of $P[p']$ and associate the resulting sequence with $\rho^*$ in the dictionary: $P[\rho^*] \leftarrow P[\rho'] ^\frown (A)$} \STATE \deleted{Associate with $\rho^*$ the sequence $P^*$ of actions to reach it from the start state} \ENDFOR \ENDFOR \STATE \added{Find the most similar representation to the goal: $\rho_{\text{result}} \leftarrow \underset{\rho \in Q \cup \added{C}}{\text{argmin}} ||\rho - \phi(O_{goal}) ||$} \RETURN{the sequence \replaced{$P[\rho_{\text{result}}]$}{$P_{\text{out}}$ that is associated with $\rho_{\text{out}} $=\\$ \underset{\rho \in Q \cup D}{\text{argmin}} ||\rho - \phi(O_{goal}) ||$}} \end{algorithmic} \end{algorithm} To make the algorithm faster, we only consider paths that do not take us to a state that has already been evaluated, even if there might be a difference in the predictions from going this roundabout way. That is, if a permutation of the actions in the next path to be considered is already in an evaluated path, it will be skipped. This has the same effect as transposition tables used to speed up search in game trees. Paths might be produced with redundancies, which can be amended with path-simplifying routines (e.g. take one step forward instead of one step left, one forward then one right). We do Model-Predictive Control \cite{garcia1989model}, that is, after a path is found, one action is performed and a new path is recalculated, starting from the new position. Since the planning is possibly over a long time horizon, we might have a case where a previous state is revisited. To avoid loops resulting from this, we keep track of visited state-action pairs and avoid an already chosen action for a given state. \subsection*{NORB viewpoint-matching experiments} For our experiments, we create an OpenAI Gym environment based on the small NORB data set \cite{lecun2004learning}. The code for the environment is available at \url{https://github.com/wiskott-lab/gym-norb} and requires the pickled NORB data set hosted at \url{https://s3.amazonaws.com/unsupervised-exercises/norb.p}. The data set contains 50 toys, each belonging to one of five categories: four-legged animals, human figures, airplanes, trucks, and cars. Each object has stereoscopic images under six lighting conditions, 9 elevations, and 18 azimuths (in-scene rotation). In all of the experiments, we train the methods on nine car class toys, testing on the other toys. Each trial in the corresponding RL environment revolves around a single object under a given lighting condition. The agent is presented with a start and a goal viewpoint of the object and transitions between images until the current viewpoint matches the goal where each action operates the camera. To be concrete, the actions correspond to turning a turntable back and forth by $20^{\circ}$, moving the camera up or down by $5^{\circ}$ and, in one experiment, changing the lighting. The trial is a success if the agent manages to change viewpoints from the start position until the goal viewpoint is matched in fewer than twice the minimum number of actions necessary. We compare the representations learned using the three variants of our method to five representations from the literature, namely \textbf{(i)} Laplacian Eigenmaps \cite{belkin2003laplacian}, \textbf{(ii)} the second-to-last layer of VGG16 pre-trained on ImageNet\cite{deng2009imagenet}, \textbf{(iii)} UMAP embeddings \cite{mcinnes2018umap}, \textbf{(iv)} convolutional encoder \cite{masci2011stacked} and \textbf{(v)} VAE codes \cite{kingma2013auto}. As fixed representations do not change throughout the training, they can be saved to disk, speeding up the training. As a reference, we consider three reinforcement learning methods working directly on the input images: \textbf{(i)} a Deep Q-Networks (DQN)~\cite{mnih2013playing}, \textbf{(ii)} Proximal Policy Optimization (PPO)~\cite{schulman2017proximal} and \textbf{(iii)} World Models~\cite{ha2018world}. The data set is turned into a graph for search by setting each image as a node and each viewpoint-changing action as an edge. The task of the agent is to transition between neighboring viewing angles until a goal viewpoint is reached. The total number of training samples is fixed at 25600. For our method, a sample is a single ($O_t$, $O_{t+1}$, $A_t$) triplet to be predicted while for the regular RL methods it is a ($O_t$, $O_{t+1}$, $A_t$, $\rho_t$) tuple. \subsection*{Model \replaced{architectures}{Architectures}} \subsubsection*{Input} The network $\phi$ encodes the full NORB input, a $96 \times 96$ pixel grayscale image, to lower-dimensional representations. The system as a whole receives the image from the current viewpoint, the image of the goal viewpoint and a one-hot encoding of the taken action. The image inputs are converted from integers ranging from 0 to 255 to floating point numbers ranging from 0 to 1. \subsubsection*{Representation \replaced{learner $\phi$ architecture}{Learner $\phi$ Architecture}} We use the same architecture for the $\phi$ network in all of our experiments except for varying the output dimension, Table~\ref{table:phiarchiteture}. \begin{table}[htb]\begin{center} \captionof{table}{{\bf Representation network architecture.}} \label{table:phiarchiteture} \begin{tabular}{l r r r l r} Layer & Filters / Units & Kernel \replaced{size}{Size} & Strides & Output shape & Activation \\ [0.5ex] \arrayrulecolor{gray} \hline \hline Input & & & & (96, 96, 1) & \\ \arrayrulecolor{lightgray} \cline{1-6} Convolutional & 64 & $5 \times 5$ & $2 \times 2$ & (45, 45, 64) & ReLU \\ \arrayrulecolor{lightgray} \cline{1-6} \cline{1-5} Max-pooling & & & $2 \times 2$ & (22, 22, 64) & \\ \cline{1-6} Convolutional & 128 & $5 \times 5$ & $2 \times 2$ & (9, 9, 128) & ReLU \\ \cline{1-6} Flatten & & & & (10368) & \\ \cline{1-6} Dense & 600 & && (600) & ReLU \\ \cline{1-6} Dense & \#Features& && (\# Features) & Linear \\ \end{tabular} \end{center}\end{table} \subsubsection*{Regularizing \replaced{decoder architecture $D$}{Decoder Architecture $D$}} The decoder network $D$ has the architecture listed in Table~\ref{table:decoder}. It is designed to approximately inverse each operation in the original $\phi$ network. \begin{adjustwidth}{-3.25in}{0in} \begin{table}[htb] \begin{center} \captionof{table}{{\bf Regularizing decoder architecture.} The upsampling layer uses linear interpolation, BN stands for Batch Normalization and CT stands for Convolutional Transpose. } \label{table:decoder} \begin{tabular}{l r r r r l } Layer & Filters / Units & Kernel Size & Strides & Output shape & Activation \\ [0.5ex] \arrayrulecolor{gray} \hline \hline Input & & &&(\# Features) & \\ \arrayrulecolor{lightgray} \cline{1-6} Dense & 512 & &&(512) & ReLU\\ \arrayrulecolor{lightgray} \cline{1-6}BN & & & & (512) & \\ \cline{1-6} Dense & 12800 & &&(12800) &ReLU\\ \cline{1-6} BN & & & & (12800) & \\ \cline{1-6} Reshape & & & & (10, 10, 128) & \\ \cline{1-6} CT & 128 & $5 \times 5$ & $2 \times 2$ & (23, 23, 128) & ReLU \\ \cline{1-6} Upsampling & & & $2 \times 2$ & (46, 46, 128) &\\ \cline{1-6} BN & & &&(46, 46, 128) &\\ \cline{1-6} CT & 64 & $5 \times 5$ & $2 \times 2$ & (95, 95, 64) & ReLU\\ \cline{1-6} BN & & & & (95, 95, 64) & \\ \cline{1-6} CT & 1 & $2 \times 2$ & $1 \times 1$ & (96, 96, 1) & Sigmoid \\ \end{tabular} \end{center} \end{table} \end{adjustwidth} \subsubsection*{Predictor \replaced{network}{Network} $f$} The predictor network $f$ is a two-stream dense neural network. Each stream consists of a dense layer \added{with a rectified linear unit (ReLU) activation} followed by a batch normalization \added{(BatchNorm)} layer. The outputs of these streams are then concatenated and passed through 3 dense layers \added{with ReLU activations}, each one followed by a BatchNorm, and then an output dense layer, see Table \ref{table:predictornet}. \deleted{Every dense layer, except the last, is followed by a rectified linear unit activation.} \begin{adjustwidth}{-3.25in}{0in} \begin{table}[htb] \begin{center} \captionof{table}{{\bf Represention predictor architecture.} The $\phi$ stream receives the representation as input and the $A$ stream receives the one-hot action as input. Both streams are processed in parallel and then concatened, with each operation applied from top to bottom sequentially. The number of hidden units in the last layer depends on the chosen dimensionality of the representation.} \label{table:predictornet} \begin{tabular}{l r r l} Layer & Filters / Units & Output shape & Activation \\ [0.5ex] \arrayrulecolor{gray} \hline \hline \ \ \ \ $\phi$ Stream: Input & & (\# Features) & ReLU\\ \arrayrulecolor{lightgray} \cline{1-4} \ \ \ \ $\phi$ Stream: Dense & 256 & (256) & ReLU\\ \arrayrulecolor{lightgray} \cline{1-4}\ \ \ \ $\phi$ Stream: Batch Normalization & & (256) & \\ \cline{1-4}\ \ $A$ Stream: Input & & (\# Actions) & ReLU\\ \cline{1-4}\ \ $A$ Stream: Dense & 128 &(128)& ReLU\\ \cline{1-4}\ \ $A$ Stream: Batch Normalization & & (128) & \\ \cline{1-4} Concatenate $\phi$ and $A$ streams & & (384) & \\ \cline{1-4} Dense & 256 & (256) & ReLU \\ \cline{1-4} Batch Normalization & & (256) & \\ \cline{1-4} Dense & 256 & (256) & ReLU \\ \cline{1-4} Batch Normalization & & (256) & \\ \cline{1-4} Dense & 128 & (128) & ReLU \\ \cline{1-4} Batch Normalization & & (128) & \\ \cline{1-4}Dense & \# Features & (\# Features) & Linear \\ \end{tabular} \end{center} \end{table} \end{adjustwidth} \section*{Results} With our empirical evaluation we aim to answer the following research questions: \begin{enumerate} \item (Monotonicity) Is the Euclidean distance between a \added{suitable} representation and the goal representation \replaced{proportional}{similar} to the number of actions that separate them? \item (Trained predictability) Is training a representation for predictability\added{, as proposed,} feasible? \item (Dimensionality) What is the best dimensionality of the latent space for our planning tasks? \item (Solution constraints) In terms of planning performance, what are \replaced{promising}{the best} constraints to place on the representation to avoid trivial solutions? \item (Benchmarking) How does planning with LARP compare to other methods from the RL literature? \item (Generalization) \replaced{How well does our method generalize to unseen environments?}{How is the performance of our method affected when we place obstacles in trained environments?} \deleted{\\ 7. How does our method generalize to different environments?} \end{enumerate} we will refer to these research questions by number below as they get addressed. \subsection*{Latent space visualization} When the representation and predictor networks are trained, we apply Algorithm \ref{algo: gs_algo} to the viewpoint-matching task. As described above, the goal is to find a sequence of actions that connects the start state to the goal state, where the two states differ in their configurations. To support the qualitative analysis of the latent space, we plot heatmaps of similarity between the goal representation and the predicted representation of nodes during search (Fig~\ref{fig:lem_matching}). Of the 10 car toys in the NORB data set, we randomly chose 9 for our training set and test on the remaining one. \subsubsection*{In-sample embedding: Laplacian Eigenmaps} \label{sec:in_sample} First, we consider research question 1 (monotonicity). In order to get the best-case representation, we embed the toy using Laplacian Eigenmaps. Embedding a single toy in three dimensions using Laplacian Eigenmaps results in a tube-like embedding that encodes both elevation and azimuth angles, see Fig \ref{fig:azimuth_cylinder}. Three dimensions are needed so that the cyclic azimuth can be embedded correctly as $\sin(\theta)$ and $\cos(\theta)$. { \captionsetup{aboveskip=-13pt} \begin{figure} \begin{adjustwidth}{-1.65in}{0in} \centering \subcaptionbox*{}{\includegraphics[width=0.3\linewidth]{assets_png/merlin/current_azimuth_0202.png}} \hspace{-1.cm} \subcaptionbox*{}{\includegraphics[width=0.3\linewidth]{assets_png/merlin/current_azimuth_0002.png}} \hspace{-1.cm} \vspace{-0.45cm} \subcaptionbox*{}{\includegraphics[width=0.3\linewidth]{assets_png/merlin/current_azimuth_-202.png}} \vspace{5mm} \subcaptionbox*{}{\includegraphics[width=0.3\linewidth]{assets_png/merlin/current_elevation_0202.png}} \hspace{-1.cm} \subcaptionbox*{}{\includegraphics[width=0.3\linewidth]{assets_png/merlin/current_elevation_0002.png}} \hspace{-1.cm} \subcaptionbox*{}{\includegraphics[width=0.3\linewidth]{assets_png/merlin/current_elevation_-202.png}} \vspace{5mm} \caption{{\bf Laplacian Eigenmap representation space of a NORB toy.} The three-dimensional Laplacian Eigenmaps of a toy car where elements with the same azimuth values have the same color (top) and where elements with the same elevation values have the same color (bottom). Euclidean distance is a good proxy for geodesic distance in this case.} \label{fig:azimuth_cylinder} \end{adjustwidth} \end{figure} } If the representation is now used to train the predictor, one would expect that the representation becomes monotonically more similar to the goal representation as the state moves toward the goal. In Fig \ref{fig:lem_matching} we see that this is the case and that this behavior can be effectively used for a greedy heuristics. While the monotonicity is not always exact due to errors in the prediction, Fig \ref{fig:lem_matching} still qualitatively illustrates a best-case scenario. \begin{figure}[htb] \begin{adjustwidth}{-2.25in}{0in} \centering \captionsetup{width=1.0\linewidth} \resizebox*{1.25 \textwidth}{!}{\includegraphics {assets_png/merlin/lem.pdf}} \caption{ {\bf Heatmap of Laplacian Eigenmap latent space similarity.} Each pixel displays the difference between the predicted representation and the goal representation. Only the start and goal observations are given. The blue dot shows the start state, green the goal, and purple the solution state found by the algorithm. The search algorithm can rely on an almost monotonically decreasing Euclidean distance between each state's predicted representation and the goal's representation to guide its search. } \label{fig:lem_matching} \end{adjustwidth} \end{figure} We conclude from this that \deleted{training a representation for predictability is feasible and that} the Euclidean distance between a current representation and the goal representation is monotonically increasing as a function of the number of actions that separate them. \added{This supports the use of a prediction-based latent space search for planning.} \subsubsection*{Out-of-sample embedding: pre-trained VGG16 representation} Next, we consider the pre-trained representation of the VGG16 network to get a representation that generalizes to new objects. We train the predictor network and plot the heat map of the predicted similarity between each state and the goal state, beginning from the start state, in Fig~\ref{fig:allinone}. \begin{figure} \begin{adjustwidth}{-2.05in}{0in} \centering \captionsetup{width=1.0\linewidth} \resizebox*{1.25 \textwidth}{!}{\includegraphics {assets_png/lem2.pdf}} \caption{ {\bf Heatmap of VGG16 latent space similarity.} The predictor network estimates the VGG16 representation of the resulting states as the object is manipulated. \textbf{(a)} The goal lies on a hill containing a maximum of representational similarity. \textbf{(b)} The accumulated errors of iterated estimations cause the algorithm to plan a path to a wrong state with a similar shape. } \label{fig:allinone} \end{adjustwidth} \end{figure} The heat distribution in this case is more noisy. To get a view of the expected heat map profile, we average several figures of this type to show basins of attraction during the search. Each heat map is shifted such that the goal position is at the bottom, middle row (Fig~\ref{fig:all_seismic.png}, a). Here it is obvious that the goal and the $180^{\circ}$ flipped (azimuth) version of the goal are attractor states. This is due to the representation map being sensitive to the rough shape of the object, but being unable to distinguish finer details. In (Fig~\ref{fig:all_seismic.png}, b) we display an aggregate heat map when the agent can also change the lighting conditions. Our visualizations show a gradient toward the goal state in addition to visually similar far-away-states,\added{ sometimes causing the algorithm to produce solutions that are the polar opposite of the goal concerning the azimuth}. Prediction errors \added{also} prevent the planning algorithm from finding the exact goal for every task\added{, even if it is not distracted by the polar-opposite.} \deleted{ sometimes producing solutions that are the polar opposite of the goal concerning the azimuth.} \begin{figure} \begin{adjustwidth}{-2.25in}{0in} \centering \captionsetup{width=.9\linewidth} \resizebox*{1.25 \textwidth}{!}{\includegraphics {assets_png/new_map.png}} \caption{ {\bf Aggregate heat maps of VGG16 representation similarities on test data.} The data is collected as the state space is searched for a matching viewpoint. The pixels are arranged according to their elevation and azimuth difference from the goal state at $(0^{\circ}, 0^{\circ})$ on the left and $(0^{\circ}, 0^{\circ}, 0^{\circ})$ on the right. \textbf{(a)} We see clear gradients toward the two basins of attraction. There is less change along the elevation due to less change at each step. \textbf{(b)} The agent can also change the lighting of the scene, with qualitatively similar results. In this graphic we only measure the absolute value of the distance. } \label{fig:all_seismic.png} \end{adjustwidth} \end{figure} To investigate the accuracy of the search with respect to each dimension separately, we plot the histogram of distances between the goal states and the solution states in Fig~\ref{fig:allinone_histos.png}. The goal and start states are chosen randomly, with the restriction that the azimuth distance and elevation distance between them are each uniformly sampled. For the rest of the paper, all trials follow this sampling procedure. The results look less accurate for elevation than azimuth because the elevation changes are smaller than the azimuth changes in the NORB data set. The difference between the goal and solution viewpoints in Fig~\ref{fig:allinone} left, for example, is hardly visible. If one would scale the histograms by angle and not by bins, the drop-off would be similar. \begin{figure} \begin{adjustwidth}{-2.25in}{0in} \centering \includegraphics[width=1.25\textwidth]{assets_png/allinone_histos2.png} \caption{ {\bf Histograms of elevation-wise and azimuth-wise VGG16 errors.} The histograms display the counts of the distance between goal and solution states along elevation (left) and azimuth (right) on test data. The distance between the start and goal viewpoints is equally distributed across all the trials, along both dimensions. The goal and the $180^{\circ}$ flipped (azimuth) version of the goal are attractor states. } \label{fig:allinone_histos.png} \end{adjustwidth} \end{figure} \subsection*{Latent space dimensionality} With the next experiment, we aim to answer \added{research question 2 (trained predictability). While tuning the details of the design, we also tackle} research questions 3 (dimensionality) and 4 (solution constraints). We do an ablation study of the dimensionality of the representation for our method (Table~\ref{featuresablation}). The test car is an unseen car toy from the NORB data set and the train car comes from the training set. \begin{table}\begin{center} \captionof{table}{{\bf Ablation study of the representation dimensionality.} We change the output dimension of the representation learner subnetwork and compare it to the VGG16 representation trained on ImageNet. The performance (mean success rate) is averaged over ten separate instantiations of our systems, where each instance is evaluated on a hundred trials of the viewpoint-matching task. A trial is a success if the goal is reached by taking less than twice the minimum number of actions needed to reach it. The standard deviations range between 0.1 and 0.3 for each table entry.} \label{featuresablation} \begin{tabular}{l r r r r} Representation & Dimensions & Training Car ($\%$) & Test Car ($\%$) \\ [0.2ex] \arrayrulecolor{gray} \hline\\[-2.5ex]LARP (Contrastive) & 96 &59.3& 56.8 \\ & 64 & 64.1& 60.5\\ & 32&72.3& 59.4 \\ & 16 &74.1& 59.3 \\ & 8& 82.7& 58.0 \\ [0.1ex] \hline\\[-2.5ex]LARP (Sphering) & 96 & 41.1& 37.8 \\ & 64& \textbf{93.9}&53.7 \\ & 32& 89.8 & 51.9 \\ &16&85.2&42.6 \\ & 8 &85.1 & 40.1 \\ [0.1ex] \hline\\[-2.5ex]LARP (Decoder) & 96& 58.0 &51.9 \\ & 64& 79.5 & \textbf{63.0} \\ & 32 & 77.8 & 61.7\\ & 16 &51.9 & 45.2 \\ & 8 &51.1 & 42.4 \\ [.1ex] \hline\\[-2.5ex]VGG16 & 902 & 62.4 & 55.1 \\ [.1ex] \hline\\[-2.5ex]Random Steps & & 3.5 & 3.5 \\ [1ex] \end{tabular} \end{center}\end{table} There is no complete and total winner: the network with the sphering layer does the best on one of the cars used during training while the reconstructive-loss network does the best on the held-out test car. The sharp difference in performance between 64 and 94 sphering-regularized representation can be explained by the numerical instability of the power iteration method for too large matrix dimensions. The VGG16 representation is not the highest performer on any of the car toys. Many of VGG16's representation values are 0 for all images in the NORB data set, so we only use those that are nonzero for any of the images. We suggest that this high number of dead units is due to the representation being too general for the task of manipulating relatively homogenous objects. Another drawback of using pre-trained networks is that information might be encoded that is unimportant for the task. This has the effect that our search method is not guaranteed to output the correct solution in the latent space, as there might be distracting pockets of local minima. The random baseline has an average success rate of 3.5$\%$, which is very clearly outperformed by our method. As 64 is the best dimensionality for the representation on average, we continue with that number for our method in the transfer learning experiment. \added{We conclude that the proposed method of training a representation for predictability is feasible.} So far we have evidence that 64 is the best dimensionality of the \added{representation's} latent space for our planning tasks. However, it is not yet conclusive what the best restriction is to place on the representation to avoid the trivial solution, in terms of planning performance. \subsection*{Comparison with other RL methods} Now we divert our attention to research question 5 (benchmarking), where we compare our method to the literature. For the comparison with standard RL methods, we use the default configurations of the model-free methods DQN (off-policy) and PPO (on-policy) as defined in OpenAI Baselines~\cite{baselines}. Our model-based comparison is chosen to be world models \cite{ha2018world} from \url{https://github.com/zacwellmer/WorldModels}. We make sure that the compared RL methods are similar to our system in terms of the number of parameters as well as architecture layout and compare them with our method on the car viewpoint-matching task. \added{The task setup is the same as before and is converted to an OpenAI gym environment: a start observation and a goal observation are passed to the agent. If the agent manages to reach it within 2 times the minimum number of actions required (the minimum number is calculated by the environment), the agent receives a reward and the task is considered a success. Otherwise, no reward is given. } The results of the comparison can be viewed in Fig.~\ref{fig:rlfigs}. \added{Each point in the curve contains each method's mean success rate: the average of the cumulative reward from 100 test episodes from 5 different instantiations of the RL learner, so it is the average reward over 500 episodes in total. The test episodes are done on the same environment as is used for training, except that the policy is maximally exploiting and minimally exploring.} \begin{figure} \begin{adjustwidth}{-1.91in}{0in} \centering \subfloat[{\bf DQN Performance.}]{{\includegraphics[width=6.3cm, angle=90]{assets_png/dqn_x_meansucc3.pdf}}} \qquad \hspace{-5em} \subfloat[{\bf PPO Performance.}]{{\includegraphics[width=6.3cm, angle=90]{assets_png/ppox_2_meansucc2.pdf}}} \qquad \hspace{-5em} \subfloat[{\bf World Models Performance.}]{{\includegraphics[width=6.3cm, angle=90]{assets_png/wm_meansucc2.pdf}}} \qquad \hspace{-5em} \qquad \hspace{-5em} \caption{{\bf Reinforcement learning comparison.} The vertical dashed lines indicate when the compared algorithm has processed the same number of transitions as our method and the horizontal dotted line indicates the test performance of our method. Each data point is the mean \added{success rate} of 100 test episodes \added{after a varying number of training steps}, averaged over 5 different seeds of each learner. The model-free methods in {\bf(a)} and {\bf(b)} train the representation and the controller simultaneously by acting in the environment and collecting new experiences. The representation in {\bf(c)} is trained on 25.6k transitions, which is the same number we use. The plot shows the optimization curve for the controller, using a Covariance-Matrix Adaptation Evolution Strategy, which hardly improves after 500 or so training steps. The horizontal line starts at 0 for world models because the representation has finished training on the observations before the controller is optimized. } \label{fig:rlfigs} \end{adjustwidth} \end{figure} \replaced{In our experiments, the}{The} DQN networks are much more sample inefficient than PPO, which in turn is more sample inefficient than our method. However, our method is more time-consuming during test time. We require a forward pass of the predictor network for each node that is searched before we take the next step, \added{which can grow rapidly if the target is far away}. \replaced{In contrast, only a single pass through the traditional RL networks is required to compute the next action.}{ This is contrasted with a single pass in total of the DQN / PPO networks for the next step.} Our method reaches $93.9\%$ success rate on the train car (Table~\ref{featuresablation}) using 25.6k samples, but the best PPO run only reaches $70.5\%$ after training on the same number of samples. The best single PPO run needed 41.3k samples to get higher than $93.9\%$ success rate and the average performance is higher than $93.9\%$ at around 55k samples. After that, some PPO learners declined again in performance. The world models policy quickly reaches the same level of performance as DQN got after 50k steps and PPO after approximately 8k steps, but it doesn't improve beyond that. \begin{figure} \begin{adjustwidth}{-1.39in}{0in} \centering \subfloat[ {\bf} ] {{\includegraphics[width=6.55cm]{assets_png/obstacles_checkerboard.pdf}}} \qquad \hspace{-1.5em} \subfloat[{\bf} ] {{\includegraphics[width=9.63cm]{assets_png/retrain.pdf} \vspace{-2.0em}}} \caption{{\bf Re-training after placing checkerboard-patterned obstacles.} {\bf (a)} The task is the same as before, but nothing happens if the agent attempts to move to a state containing a black rectangle. {\bf (b)} After training the agents, we re-tested them after we introduced the checkerboard pattern of obstacles. Our method does not allow for re-training in the new environment.} \label{fig:checkz} \end{adjustwidth} \end{figure} We conclude that our method compares favorably to other methods from the RL literature in terms of sample efficiency. \subsection*{Modifying the environment} We now modify the environment to answer research question 6 (generalization). To see how the methods compare when obstacles are introduced to the environment, we repeat the trial on one of the car objects except that the agent can no longer pass through states whose elevation values are divisible by 10 and azimuth values are divisible by 40 (Fig.~\ref{fig:checkz}, (a)). As before, the goal and start locations can have any azimuth-elevation pair but the agent cannot move into states with the properties indicated by the black rectangle. Every action is available to the agent at all locations as before, but the agent's state is unchanged if it attempts to move to a state with a black rectangle. We trained LARP using the contrastive loss, PPO, and DQN agents until they reached $80\%$ accuracy on our planning task and then tested them with the added obstacles. Our method loses about $10\%$ performance, but PPO loses $50\%$. Nevertheless, we can continue training PPO until it quickly reaches top performance again (Fig.~\ref{fig:checkz}, (b)). Our method is not re-trained for the new task and DQN did not reach a good performance again in the time we allotted for re-training. Thus, we see that our method is quite flexible and generalizes well when obstacles are introduced to the environment. \subsection*{Transfer to dissimilar objects} \replaced{We now consider research question 6 (generalization) further by investigating how well our method transfers knowledge from one domain to another. }{We now investigate how well our method transfers knowledge from one domain to another, seeking to answer research question 7.} Selecting the best dimensionality for the representation from the previous set of experiments, we investigate further their performance in harder situations using unseen, non-car objects. \replaced{The models are trained on the same car objects as in the previous experiment, but they are tested on an array of different plastic soldiers: a kneeling soldier holding a bazooka, a standing soldier with a rifle, a native american with a bow and spear and a cowboy with a rifle (Fig.~\ref{fig:merge4.png}).}{(Table~\ref{moretesttoys}).} \begin{figure} \begin{adjustwidth}{-0.2in}{0in} \centering \captionsetup{width=.8\linewidth} \resizebox*{1. \textwidth}{!}{\includegraphics {assets_png/merge4.png}} \caption{ {\bf Toys for transfer learning experiments.} From left to right: Soldier (Kneeling), Soldier (Standing), Native American with Bow and Cowboy with Rifle. } \label{fig:merge4.png} \end{adjustwidth} \end{figure} \subsubsection*{\added{Qualitative results}} \added{We offer a visualization of the learned representation of the kneeling soldier toy using our method, a convolutional encoder, and VGG16 in Fig.~\ref{fig:4apics}. Each embedding was reduced to 2 dimensions using t-SNE. } Every method structures the domain in similar way. In the bottom row, we see that largest clusters for all methods are the ones with the highest (teal dots) illumination settings, which is explained by the effect of the lighting on the pixel value intensities. Within these clusters, we see clustering based on the azimuth (middle row). Finally, within these clusters, there is a gradient structure based on elevation (top row). This is due to the elevation changing in smaller step-sizes, with 5 degree differences, than azimuth with 20 degree differences. \begin{figure}[ht!] \begin{adjustwidth}{-0.93in}{0in} \captionsetup[subfigure]{justification=centering,singlelinecheck=false} \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/larp_Elevation_TSNE.pdf} \caption{\added{LARP Elevation t-SNE}} \label{fig:1picsa} \end{subfigure} \hspace{-2em} \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/cae_Elevation_TSNE.pdf} \caption{\added{Conv. Encoder Elevation t-SNE}} \label{fig:2picsb} \end{subfigure} \hspace{-2em} \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/vgg_Elevation_TSNE.pdf} \caption{\added{VGG16 Elevation t-SNE}} \label{fig:3picsb} \end{subfigure} \smallskip \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/larp_Azimuth_TSNE.pdf} \caption{\added{LARP Azimuth t-SNE}} \label{fig:4picsa} \end{subfigure} \hspace{-2em} \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/cae_Azimuth_TSNE.pdf} \caption{\added{Conv. Encoder Azimuth t-SNE}} \label{fig:5picsb} \end{subfigure} \hspace{-2em} \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/vgg_Azimuth_TSNE.pdf} \caption{\added{VGG16 Azimuth t-SNE}} \label{fig:6picsb} \end{subfigure} \smallskip \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/larp_Lighting_TSNE.pdf} \caption{\added{LARP Lighting t-SNE}} \label{fig:7picsc} \end{subfigure} \hspace{-2em} \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/cae_Lighting_TSNE.pdf} \caption{\added{Conv. Encoder Lighting t-SNE}} \label{fig:8picsd} \end{subfigure} \hspace{-2em} \begin{subfigure}{0.41\textwidth} \includegraphics[width=\linewidth]{assets_png/vgg_Lighting_TSNE.pdf} \caption{\added{VGG16 Lighting t-SNE}} \label{fig:9picsb} \end{subfigure} \captionsetup{margin=0cm} \caption{ \added{The clustering structure of a toy soldier embedding after dimensionality reduction with t-SNE. The top row colors the samples by elevation, the middle row by azimuth and the bottom one by lighting. The left column is the embedding given by our method using the contrastive loss term, the middle by a convolutional encoder, and the right by a pre-trained VGG16 network.}} \label{fig:4apics} \end{adjustwidth} \end{figure} \subsubsection*{\added{Quantitative results}} Our experiments include the pre-trained VGG16 network because we believe that a flexible algorithm should rather be based on a generic multi-purpose-representation and not on a specific representation. To our surprise, it is outperformed by our approach on every object, even as the viewpoint-matching task is done on objects that are different from the original car toys they are trained on. We also try transfer learning \deleted{a} VAE \added{and a convolutional encoder} using the same network as our representation \replaced{and a UMAP embedding, with 64 features each.}{ with 64 features each and a UMAP embedding.} \added{We display the results of the same viewpoint-matching tasks as before using these different representations on the unseen army figures in Table~\ref{moretesttoys}.} \replaced{Convolutional encoders have}{UMAP has} the lowest performance out of all the methods but the VAE representation \replaced{has the most similar performance to}{rivals} our own representations. \begin{table}\begin{center} \captionof{table}{ {\bf Transfer learning performance.} The methods are trained on the data set of different car images and then their performance on dissimilar toys is tested. Each number is the mean success rate of viewpoint matching out of 1000 trials.} \label{moretesttoys} \begin{tabular}{ l r r r r | r l} Representation & Soldier & Soldier & Native American & Cowboy & \\ [0.5ex] & (Kneeling) & (Standing) & with Bow & with Rifle & \added{Mean} \\ [0.5ex] \arrayrulecolor{gray}\hline LARP (Contrastive) & \textbf{\fpeval{round(100*(23+18+18+21+12)/(5*81), 1)}} & \fpeval{round(100*(11+8+12+5)/(4*81), 1)} & \fpeval{round(100*(11+11+10+7+0.11)/(4*81), 1)} & \textbf{\fpeval{round(100*(17+17+15+18)/(4*81), 1)}} & \added{\textbf{16.7}}\\ LARP (Sphering) & \fpeval{round(100*(14.9)/(1*81), 1)} & \fpeval{round(100*(12.43)/(1*81), 1)}& \textbf{\fpeval{round(100*(12.34)/(1*81), 1)}} & \fpeval{round(100*(12.8)/(1*81), 1)}& \added{16.2}\\ LARP (Decoder) & \fpeval{round(100*(11.6)/(1*81), 1)} & \textbf{\fpeval{round(100*(13.43)/(1*81), 1)}} & \fpeval{round(100*(11.93)/(1*81), 1)} & \fpeval{round(100*(12.63)/(1*81), 1)}& \added{15.3}\\ VAE & \fpeval{round(100*(11.7)/(1*81), 1)} & \fpeval{round(100*(10.61)/(1*81), 2)} & \fpeval{round(100*(11.01)/(1*81), 1)} & \fpeval{round(100*(11.211)/(1*81), 1)}& \added{13.7}\\ VGG16 & \fpeval{round(100*(10)/(1*81), 1)} & \fpeval{round(100*(10.45)/(1*81), 1)} & \fpeval{round(100*(9.54)/(1*81), 1)} & \fpeval{round(100*(11)/(1*81), 1)}& \added{12.7}\\ UMAP & \fpeval{round(100*(7)/(1*81), 1)} & \fpeval{round(100*(8.75)/(1*81), 1)} & \fpeval{round(100*(7.84)/(1*81), 1)} & \fpeval{round(100*(9)/(1*81), 1)}& \added{10.1}\\ \added{Conv. Encoder} & \added{\fpeval{round(100*(4)/(1*81), 1)}} & \added{\fpeval{round(100*(11.6)/(1*81), 1)}} & \added{\fpeval{round(100*(9.3)/(1*81), 1)}} & \added{\fpeval{round(100*(5.2)/(1*81), 1)}}& \added{9.3} \\ \end{tabular}\end{center}\end{table} Our representation is better than the others for this experiment. But we see that the performance of our method drops significantly as we attempt generalizing to different objects with changed input statistics. \added{Note that even though the representation clustering (Fig.~\ref{fig:4apics}) was more clear-cut using convolutional encoders and VGG, compared to ours, they did not perform as well in the trials. We attribute this to the fact that the main loss term in our representation was the one of future state predictability, which may not give as clear of a structure in two dimensions as a representation that is trained only for static image reconstruction.} \section*{Discussion} In this work, we present Latent Representation Prediction (LARP) networks with applications to visual planning. We jointly learn a model to predict transitions in Markov decision processes with a representation trained to be maximally predictable\replaced{. This allows}{, allowing} us to accurately search the latent space defined by the representation \added{using a heuristic graph traversal / best-first search algorithm}. We validate our method on a viewpoint-matching task derived from the NORB data set. Not surprisingly, a representation that is optimized simultaneously with the predictor network performs best in our experiments. A common issue of unsupervised representation learning is one of trivial solutions: a constant representation which optimally solves the unsupervised optimization problem but brings across no information. To avoid the trivial solution we constrain the training by introducing a sphering layer or a loss term that is either contrastive or reconstructive. Any of these approaches will do the job of preventing the representations from collapsing to constants, and none of them displays absolute superiority over the others. Our LARP representation is competitive with pre-trained representations for planning and compares favorably to other reinforcement learning (RL) methods. Our approach is a sound solution for learning a meaningful representation that is suitable for planning only from interactions. Furthermore, we find that our method has better sample-efficiency during training than several reinforcement learning methods from the literature\replaced{.}{and our learned representation and predictive model transfer to harder scenarios.} However, a disadvantage of our method compared to standard RL methods is that the execution time of our method is longer, as a forward pass is calculated for each node during the latent space search\added{, potentially resulting in a combinatorial explosion}. Our approach is adaptable to changes in the tasks. For example, our search would \replaced{only be slightly}{not be} hindered if some obstacles were placed in the environment or some states were forbidden to traverse through. Furthermore, \replaced{our method is independent of specific rewards or discount rates,}{the reward or discount rates can be easily changed for our method} while standard RL methods are usually restricted in their optimization problems. Often, there is a choice between optimizing discounted or undiscounted expected returns. Simulation/rollout-based planning methods are not restricted in that sense: If reward trajectories can be predicted, one can optimize arbitrary functions of these and regularize behavior. For example, a risk-averse portfolio manager can prioritize smooth reward trajectories over volatile ones. Future lines of work should investigate further the effect of the different constraints on the end-to-end learning of representations suited for a predictive forward model, as well as considering novel ones. The search algorithm can be improved and made faster, especially for higher-dimensional action spaces or continuous ones. Our network could also in principle be used to train an RL system, for instance, by encouraging it to produce similar outptus as ours and thereby combining sample efficiency with fast performance during inference time. \section*{Supporting information} \paragraph*{S1 Supplement} \label{S1_supplement} {\bf Environment Code} (ZIP) \paragraph*{S2 Appendix} \label{S2_appendix} {\bf Network Keras Code} (PDF) \paragraph*{S3 Figure} \label{S3_supplement} {\bf Train Cars Sample} (PNG) \paragraph*{S4 Figure} \label{S4_supplement} {\bf Test Car Sample} (PNG) \section*{Acknowledgments} We would like to thank Zahra Fayyaz, Simon Hakenes, and Daniel Vonk for contributing to discussions related to this project. \section*{Author contributions} \textbf{Conceptualization:} Hlynur Davíð Hlynsson, Tobias Glasmachers, Laurenz Wiskott \newline \newline \textbf{Data Curation:} Hlynur Davíð Hlynsson, Merlin Schüler, Robin Schiewer \newline \newline \textbf{Formal Analysis:} Hlynur Davíð Hlynsson, Merlin Schüler \newline \newline \textbf{Funding Acquisition:} Laurenz Wiskott \newline \newline \textbf{Investigation:} Hlynur Davíð Hlynsson \newline \newline \textbf{Methodology:} Hlynur Davíð Hlynsson, Laurenz Wiskott \newline \newline \textbf{Project Administration:} Hlynur Davíð Hlynsson \newline \newline \textbf{Resources:} Laurenz Wiskott, Merlin Schüler \newline \newline \textbf{Software:} Hlynur Davíð Hlynsson, Merlin Schüler, Robin Schiewer \newline \newline \textbf{Supervision:} Laurenz Wiskott \newline \newline \textbf{Validation:} Hlynur Davíð Hlynsson \newline \newline \textbf{Visualization:} Hlynur Davíð Hlynsson, Robin Schiewer \newline \newline \textbf{Writing – Original Draft Preparation:} Hlynur Davíð Hlynsson \newline \newline \textbf{Writing – Review \& Editing:} Hlynur Davíð Hlynsson, Laurenz Wiskott, Tobias Glasmachers, Merlin Schüler, Robin Schiewer \nolinenumbers
{'timestamp': '2021-03-18T01:18:34', 'yymm': '2009', 'arxiv_id': '2009.09439', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09439'}
arxiv
\section{Introduction} Persian \textit{ezafe} is an unstressed morpheme that appears on the end of the words, as \textit{-e} after consonants and as \textit{-ye}\footnote{The \textit{y} is called an intrusive \textit{y} and is an excrescence between two vowels for the ease of pronunciation.} after vowels. This syntactic phenomenon links a head noun, head pronoun, head adjective, head preposition, or head adverb to their modifiers in a constituent called `\textit{ezafe} construction' \cite{shojaei2019corpus}. Whether a word in a sentence receives or does not receive \textit{ezafe} might affect that sentence's semantic and syntactic structures, as demonstrated in Examples 1a and 1b in Figure \ref{fig:dep_tree}. There are some constructions in English that can be translated by \textit{ezafe} construction in Persian. For instance, English `of' has the same role as Persian \textit{ezafe} to show the part-whole relation, the relationship of possession, or `'s' construction, and possessive pronouns followed by nouns showing genitive cases are mirrored by Persian \textit{ezafe} \cite{karimi2012generalization}. This affix is always pronounced but almost always not written, which results in a high degree of ambiguity in reading and understanding Persian texts. It is hence considered as one of the most interesting issues in Persian linguistics, and it has been discussed in details from phonological aspects \cite{ghomeshi1997non}, morphological aspects \cite{samvelian2006morphology, samvelian2007Ezafe} and \cite{karimi2012generalization}, and syntactic aspects \cite{samiian1994Ezafe,larson2008Ezafe,kahnemuyipour2006persian,kahnemuyipour2014revisiting,kahnemuyipour2016Ezafe}. Nearly 22\% of the Persian words have \textit{ezafe} \cite{bijankhan2011lessons}, which shows the prevalence of this marker. Moreover, this construction also appears in other languages such as Hawramani \cite{holmberg2005noun}, Zazaki \cite{larson2006zazaki, toosarvandani2014syntax}, Kurdish \cite{karimi2007kurdish} etc. \textit{Ezafe} construction is also similar to \textit{idafa} construction in Arabic and construct state in Hebrew \cite{habash2010introduction,karimi2012generalization} and Zulu \cite{jones2018argument}. \textit{Ezafe} recognition is the task of automatically labeling the words ending with \textit{ezafe}, which is crucial for some tasks such as speech synthesis \cite{sheikhan1997continuous,bahaadini2011implementation}, as \textit{ezafe} is always pronounced, but rarely written. Furthermore, as recognizing the positions of this marker in sentences helps determine phrase boundaries, it highly facilitates other natural language processing (NLP) tasks, such as tokenization \cite{ghayoomi2009challenges}, syntactic parsing \cite{sagot2010morphological,nourian2015importance}, part-of-speech (POS) tagging \cite{hosseini2016persian}, and machine translation \cite{amtrup2000persian}. \begin{figure*}[ht] \centering \begin{tabular}{rcl} \addvbuffer[0ex 8ex]{(1)} & \addvbuffer[0ex 8ex]{a.} &\begin{dependency}[theme=default] \begin{deptext}[column sep=.5cm, row sep=.1ex] \textit{Darpey-e} \& \textit{ettef\={a}q\={a}t-e} \& \textit{diruz} \& \textit{'u} \& \textit{'este'f\={a}} \& \textit{d\={a}d} \& \textit{.} \\ following-\textit{ez.}\footnotemark \& events-\textit{ez.} \& yesterday \& he/she \& resign \& did \& . \\ P \& N \& ADV \& PRO \& N \& V \& DELM \\ \end{deptext} \depedge{7}{6}{root} \depedge{6}{4}{nsubj} \depedge{6}{5}{dobj-lvc} \depedge{1}{2}{pobj} \depedge{2}{3}{advmod} \depedge[edge unit distance=1.8ex]{6}{1}{prep} \end{dependency}\\[-.5em] &&\multicolumn{1}{l}{$\;$ ``Following the yesterday events, he/she resigned."}\\\\ & \addvbuffer[0ex 8ex]{b.} & \begin{dependency}[theme=default] \begin{deptext}[column sep=.5cm, row sep=.1ex] \textit{Darpey-e} \& \textit{ettef\={a}q\={a}t} \& \textit{diruz} \& \textit{'u} \& \textit{'este'f\={a}} \& \textit{d\={a}d} \& \textit{.} \\ following-\textit{ez.} \& events \& yesterday \& he/she \& resign \& did \& . \\ P \& N \& ADV \& PRO \& N \& V \& DELM \\ \end{deptext} \depedge{7}{6}{root} \depedge{6}{4}{nsubj} \depedge{6}{5}{dobj-lvc} \depedge{1}{2}{pobj} \depedge[edge unit distance=2.3ex]{6}{1}{prep} \depedge{6}{3}{advmod} \end{dependency}\\[-.5em] &&\multicolumn{1}{l}{$\;$ ``Following the events, he/she resigned yesterday."}\\ \end{tabular} \caption{\label{fig:dep_tree}An example of the role of \textit{ezafe} in the syntactic and semantic structures.} \end{figure*} In this paper, we experiment with different methods to achieve state-of-the-art results in the task of \textit{ezafe} recognition. We then use the best of these methods to improve the results for the task of POS tagging. After establishing a baseline for this task, we provide the \textit{ezafe} information to the POS tagging model once in the input text and the other time as an auxiliary task in a multi-task setting, to see the difference in the results. The contributions of this paper are (1) improving the state-of-the-art results in both of \textit{ezafe} recognition and POS tagging tasks, (2) analyzing the results of \textit{ezafe} recognition task to pave the way for further enhancement in the future work, (3) improving POS tagging results in some of the methods by providing \textit{ezafe} information and explaining why transformer-based models might not benefit from such information. The code for our experiments is available on this project's GitHub repository\footnotetext{\textit{Ezafe.}} \footnote{\href{https://github.com/edoost/pert}{https://github.com/edoost/pert}}. After reviewing the previous work of both tasks in Section \ref{sec:prev}, we introduce our methodology in Section \ref{sec:exp} and data in Section \ref{sec:data}. We then discuss \textit{ezafe} recognition and POS tagging tasks and their results in Sections \ref{sec:ezafe} and \ref{sec:pos}, respectively. \section{Previous Work} \label{sec:prev} \subsection{\textit{Ezafe} Recognition} \label{subsec:ezafe_literatur} In the field of NLP, a few studies have been carried out on Persian \textit{ezafe} recognition, including rule-based methods, statistical methods, and hybrid methods. Most of the previous work on the task rely on long lists of hand-crafted rules and fail to achieve high performance on the task. \newcite{megerdoomian2000persian} use a rule-based method to design a Persian morphological analyzer. They define an \textit{ezafe} feature to indicate the presence or absence of \textit{ezafe} for each word based on the following words in a sentence. Another work is \newcite{muller2010pergram} that considers \textit{ezafe} as a part of implemented head-driven phrase structure grammar (HPSG) to formalize Persian syntax and determine phrase boundaries. In addition, \newcite{nojoumian2011towards} designs a Persian lexical diacritizer to insert short vowels within words in sentences using finite-state transducers (FST) to disambiguate words phonologically and semantically. They use a rule-based method to insert \textit{ezafe} based on the context and the POS tags of the previous words. As for the statistical approach, \newcite{koochari2006Ezafe} employ classification and regression trees (CART) to predict the absence or presence of \textit{ezafe} marker. They use features such as Persian morphosyntactic characteristics, the POS tags of the current word, two words before, and three words after the current word to train the model. Their train set contains approximately 70,000 words, and the test corpus consists of 30,382 words. To evaluate the performance of the model, they use Kappa factor, and they report 98.25\% accuracy in the case of non-\textit{ezafe} words and 88.85\% in the case of words with \textit{ezafe}. As another research, we can mention \newcite{asghari2014probabilistic} that employs maximum entropy (ME) and conditional random fields (CRF) methods. They use the 10 million word Bijankhan corpus \cite{bijankhan2011lessons} and report an accuracy of 97.21\% for the ME tagger and 97.83\% for the CRF model with a window of size 5. They also utilize five Persian specific features in a hybrid setting with the models to achieve the highest accuracy of 98.04\% with CRF. \newcite{isapour2008prediction} propose a hybrid method to determine \textit{ezafe} positions using probabilistic context-free grammar (PCFG) and then consider the relations between the heads and their modifiers. The obtained accuracy is 93.29\%, reportedly. Another work is \newcite{noferesti2014hybrid} that uses both a rule-based method and a genetic algorithm. At first, they apply 53 syntactic, morphological, and lexical rules to texts to determine words with \textit{ezafe}. Then, the genetic algorithm is employed to recognize words with \textit{ezafe}, which have not been recognized at the previous step. To train and test the model, they use the 2.5 million word Bijankhan corpus \cite{bijankhan2004persian} and obtain an accuracy of 95.26\%. \subsection{POS Tagging} \newcite{azimizadeh2008persian} use a trigram hidden Markov model trained on the 2.5 million word Bijankhan corpus. In order to evaluate, a variety of contexts such as humor, press reports, history, and romance are collected with 2000 words for each context. The average accuracy on different contexts is 95.11\%. \newcite{mohseni2010persian} also train a trigram Markov tagger on the 10 million word Bijankhan corpus. However, the lemma of each word is determined by a morphological analyzer at first and then a POS tag is assigned to the word. They report an accuracy of 90.2\% using 5-fold cross-validation on the corpus. \newcite{hosseini2016persian} use \textit{ezafe} feature for Persian POS tagging. They use the 2.5 million word Bijankhan corpus to train a recurrent neural network-based model, whose input vectors contain the left and the right tags of the current word plus the probability of \textit{ezafe} occurrence in the adjacent words, achieving a precision of 94.7\%. \newcite{rezai2017farsitag} design a POS tool based on a rule-based method containing both morphological and syntactic rules. They use the tag set of the 2.5 million word Bijankhan corpus, and their test set is a collection of more than 900 sentences of different types, including medicine, literature, science, etc., and the obtained accuracy is 98.6\%. \newcite{mohtaj2018parsivar} train two POS taggers on the 2.5 million word Bijankhan corpus, ME and CRF with different window sizes, the best results of which are 95\% for both models with a window size of 5. \section{Methodology} \label{sec:exp} We see both \textit{ezafe} recognition and POS tagging as sequence labeling problems, i.e., mapping each input word to the corresponding class space of the task. For the \textit{ezafe} recognition task, the class space size is two, 0 for words without and 1 for words with \textit{ezafe}. The class space size for POS tagging task is 14, consisting of the coarse-grained POS tags in the 10 million word Bijankhan corpus. The results in Section \ref{subsec:ezafe_literatur} are unfortunately reported on different, and in most cases irreproducible, test sets, using accuracy as the performance measure (which is insufficient and unsuitable for the task), making the comparison difficult. We hence re-implemented the model that reports the highest accuracy on the largest test set and compare its results with ours. \subsection{Models} \label{subsec:models} We experiment with three types of models: conditional random fields (CRF) \cite{lafferty2001conditional}, recurrent neural networks (RNN) \cite{rumelhart1986learning} with long short-term memory (LSTM) cells \cite{hochreiter1997long} and convolutional neural networks (CNN), and transformer-based \cite{vaswani2017attention} models such as BERT \cite{devlin2018bert} and XLMRoBERTa \cite{conneau2019unsupervised}. These are the only transformer-based models pretrained on Persian data. To implement these models, we used sklearn-crfsuite \cite{sklearncrfsuite,CRFsuite}, TensorFlow \cite{tensorflow2015-whitepaper}, PyTorch \cite{NEURIPS2019_9015}, and HuggingFace's Transformers \cite{Wolf2019HuggingFacesTS} libraries. The implementation details are as follows: \begin{itemize} \item CRF\textsubscript{1}: This is a re-implementation of \newcite{asghari2014probabilistic}'s CRF model, as described in their paper. The input features were the focus word, 5 previous and 5 following words. We set the L1 and L2 regularization coefficients to $0.1$ and the max iteration argument to 100. \item CRF\textsubscript{2}: This one is the same as CRF\textsubscript{1}, plus 8 other features: 1 to 3 first and last characters of the focus word to capture the morphological information and two Boolean features indicating if the focus word is the first/last word of the sentence. \item BLSTM: A single layer bidirectional LSTM with a hidden state size of 256 plus a fully-connected network (FCN) for mapping to the class space. The input features were Persian word embedding vectors by FastText \cite{bojanowski2017enriching} without subword information with an embedding size of 300, which is proven to yield the highest performance in Persian language \cite{8472549}. The batch size was set to 16 for \textit{ezafe} recognition and 4 for POS tagging, and learning rate to $1e-3$. We applied a dropout of rate 0.5 on RNN's output and used cross-entropy as the loss function. \item BLSTM+CNN\footnote{Number of parameters are 3.4M and 9.0M for BLSTM and BLSTM+CNN, respectively.}: The same as above, except for the input features of the BLSTM layer, which also included extracted features from dynamic character embeddings of size 32 by two CNN layers with stride 1 and kernel size 2, followed by two max-pooling layers with pool size and stride 2. The first CNN layer had 64 filters and the second one 128. We also applied a dropout of rate 0.5 on CNN's output. The character embeddings were initialized randomly and were trained with other parameters of the model. \item BERT and XLMRoBERTa: The main models plus a fully-connected network mapping to the tag space. The learning rate was set to $2e-5$ and the batch size to 8. As for the pre-trained weights, for BERT, the multilingual cased model and for XLMRoBERTa, the base model were used. We have followed the recommended settings for sequence labeling, which is to calculate loss only on the first part of each tokenized word. Cross entropy was used as the loss function. \end{itemize} We used Adam \cite{kingma2014adam} for optimizing all the deep models above. For \textit{ezafe} recognition, we train the models in a single-task setting. For POS tagging, however, we train them in three different settings: \begin{enumerate} \item A single-task setting without \textit{ezafe} information for all of the models. \item A single-task setting with \textit{ezafe} information in the input. The outputs of the best \textit{ezafe} recognition model were added to the input of the POS tagging models: for CRFs as a Boolean feature, for BLSTM+CNN as input to CNN, and for BERT and XLMRoBERTa, in the input text. This setting was experimented with using all the models, except for CRF\textsubscript{1} and BLSTM. \item A multi-task setting where the model learns POS tagging and \textit{ezafe} recognition simultaneously, which means there is an FCN mapping to the POS class space and another one mapping to the \textit{ezafe} class space. For the BLSTM+CNN model, we used a batch size of 16 in this setting. The loss was calculated as the sum of the output losses of the two last fully-connected networks in this setting. \end{enumerate} The hyper-parameters of the abovementioned models have been tuned by evaluating on the validation set to get the highest F\textsubscript{1}-score. An Intel Xeon 2.30GHz CPU with 4 cores and a Tesla P100 GPU were used to train these models. \subsection{Performance Measure} Precision, recall, F\textsubscript{1}-score, and accuracy were used to measure the performance of each model. In all the cases, the model was tested on the test set, using the checkpoint with the best F\textsubscript{1}-score on the validation set. For the \textit{ezafe} recognition task, we report the measures on the positive class, and for the POS tagging task, we report the macro average. \section{Data} \label{sec:data} The 10 million word Bijankhan \cite{bijankhan2011lessons} corpus was used in the experiments. We shuffled the corpus, as adjacent sentences might be excerpts from the same texts, with a random seed of 17 using Python's random library. This corpus comprises different topics, including news articles, literary texts, scientific textbooks, informal dialogues, etc, making it a suitable corpus for our work. We used the first 10\% of the corpus as the test, the next 10\% as validation, and the remaining 80\% as the train set. $\sim$22\% of the words have \textit{ezafe} marker and $\sim$78\% of them do not, in each and all of the sets. Sentences with more than 512 words were set aside. Table \ref{tab:corpus_detail} shows the number of sentences and tokens in each set. \begin{table}[ht] \centering \begin{tabular}{c|cc} \Xhline{2\arrayrulewidth} \bf Set & \bf \# of Tokens & \bf \# of Sentences \\ \hline Train & 8,079,657 & 268,740 \\ Valid. & 1,011,338 & 33,592 \\ Test & 1,010,274 & 33,593 \\ \hline Total & 10,101,269 & 335,925 \\ \Xhline{2\arrayrulewidth} \end{tabular} \caption{\label{tab:corpus_detail} The number of sentences and tokens in train, validation, and test sets.} \end{table} Table \ref{tab:Ezafe_per_pos} shows the frequency percentage of \textit{ezafe} per POS in the corpus. Despite the previous claim that only nouns, adjectives, and some prepositions accept \textit{ezafe} \cite{ghomeshi1997non,karimi2012generalization,kahnemuyipour2014revisiting}, there is actually no simple categorization for POS's that accept \textit{ezafe} and those that do not, which can be seen in Table \ref{tab:Ezafe_per_pos} and is also backed by a more recent study on the matter \cite{shojaei2019corpus}. The last column in Table \ref{tab:Ezafe_per_pos}, $H$, is Shannon's diversity index \cite{shannon1948mathematical, spellerberg2003tribute}, and is calculated as a diversity measure using Equation \ref{eq:entropy} for each POS tag. The higher the index is, the more diverse distribution the unique words have. \begin{table}[ht] \centering \begin{tabular}{cccc} \Xhline{2\arrayrulewidth} \bf POS & \bf \% w/ \textit{Ezafe} & \bf Freq. \% & $\boldsymbol{H}$ \\ \hline N & 46.68\% & 38.50\% & 8.518 \\ ADJ & 24.87\% & 9.02\% & 7.468 \\ P & 10.10\% & 10.90\% & 2.034 \\ DET & 9.83\% & 2.42\% & 1.944 \\ ADV & 5.67\% & 1.78\% & 5.289 \\ NUM & 2.71\% & 4.44\% & 3.573 \\ MISC & 1.59\% & 0.10\% & 3.735 \\ PRO & 1.14\% & 2.49\% & 2.884 \\ FW & 0.73\% & 0.22\% & 7.735 \\ CON & 0.12\% & 9.37\% & 1.519 \\ \hline V & 0.00\% & 9.58\% & 5.354\\ PSTP & 0.00\% & 1.42\% & 0.029\\ IDEN & 0.00\% & 0.21\% & 3.366\\ DELM & 0.00\% & 9.54\% & 1.695\\ \Xhline{2\arrayrulewidth} \end{tabular} \caption{\label{tab:Ezafe_per_pos} Frequency percentage of \textit{ezafe} per POS, word frequency percentage per POS, and Shannon's diversity index ($H$) per POS.} \end{table} \begin{equation} \label{eq:entropy} H = -\sum_{i=1}^N P(x_i)\ln P(x_i) \end{equation} where $H$ is Shannon's diversity index, and $N$ is the number of unique words $x$ in each POS tag. \section{\textit{Ezafe} Recognition} \label{sec:ezafe} For \textit{ezafe} recognition, we experimented with different sequence labeling techniques and report the performance of them. These techniques include CRF\textsubscript{1}, CRF\textsubscript{2}, BLSTM, BLSTM+CNN, BERT, and XLMRoBERTa, as discussed in Section \ref{subsec:models}. \subsection{Results} Table \ref{tab:ezafe_results} shows the results of all the models on the validation and test sets. It can be seen that transformer-based models outperform the other models by a huge margin. The best RNN-based model, BLSTM+CNN, outperforms the best CRF model, CRF\textsubscript{2}, by 0.76\% F\textsubscript{1}-score. On the other hand, the best transformer-based model, XLMRoBERTa, outperforms the best RNN by 1.78\% F\textsubscript{1}-score, and the best CRF by 2.54\%. It should be noted that XLMRoBERTa outperforms the previous state-of-the-art, CRF\textsubscript{1}, by 2.68\% F\textsubscript{1}-score. Figure \ref{fig:ezafe_results} shows the precision, recall, and F\textsubscript{1}-score on the test set. The transformer-based models also enjoy a more balanced precision and recall, which means a higher F\textsubscript{1}-score. It is worth mentioning that XLMRoBERTa has a lower training time due to its much larger pretraining Persian data compared to BERT. \begin{figure}[ht] \includestandalone[width=.48\textwidth]{ezafe_bar_chart} \caption{\label{fig:ezafe_results} \textit{Ezafe} recognition precision, recall, and F\textsubscript{1}-score, respectively from top to bottom, for all of the models on the test set.} \end{figure} \begin{table*}[t] \centering \small \begin{tabular}{c|cccc|cccc|c} \Xcline{1-10}{2\arrayrulewidth}\\[-1em] \multirow{2}{*}{\textbf{Model}} & \multicolumn{4}{c|}{\textbf{Validation}} & \multicolumn{4}{c|}{\textbf{Test}} & \bf Approx. \\ & \textbf{Prec.} & \textbf{Recall} & \textbf{F\textsubscript{1}} & \textbf{Acc.} & \textbf{Prec.} & \textbf{Recall} & \textbf{F\textsubscript{1}} & \textbf{Acc.} & \bf T.T. \\ \hline \bf CRF\textsubscript{1} (baseline) & 0.9501 & 0.9613 & 0.9556 & 0.9805 & 0.9484 & 0.9609 & 0.9546 & 0.9801 & 0.3 h \\ \bf CRF\textsubscript{2} & 0.9525 & 0.9621 & 0.9573 & 0.9812 & 0.9508 & 0.9612 & 0.9560 & 0.9807 & 0.4 h \\ \bf BLSTM & 0.9541 & 0.9712 & 0.9625 & 0.9880 & 0.9541 & \textit{0.9710} & 0.9624 & 0.9878 & 0.8 h \\ \bf BLSTM+CNN & \textit{0.9547} & \textit{0.9721} & \textit{0.9633} & \textit{0.9887} & \textit{0.9551} & \underline{0.9722} & \textit{0.9636} & \textit{0.9889} & 1 h \\ \bf BERT & \underline{0.9767} & \bf 0.9839 & \underline{0.9803} & \underline{0.9913} & \underline{0.9764} & \bf 0.9837 & \underline{0.9800} & \underline{0.9912} & 1.3 h \\ \bf XLMRoBERTa & \bf 0.9784 & \underline{0.9836} & \bf 0.9810 & \bf 0.9917 & \bf 0.9791 & \bf 0.9837 & \bf 0.9814 & \bf 0.9919 & 0.8 h \\ \Xhline{2\arrayrulewidth} \end{tabular} \caption{\label{tab:ezafe_results} \textit{Ezafe} recognition results (precision, recall, F\textsubscript{1}-score, and accuracy) on the validation and test sets. In each column, the best result(s) is/are in bold, the second best underlined, and the third best italicized. The last column shows the approximate training time in hours.} \end{table*} \subsection{Analysis} In comparison to CRFs and RNN-based methods, transformer-based models perform much better on more scarce language forms, such as literary texts and poetry, which means, given a test corpus with a higher frequency of such texts, a much wider gap between the results is expected. We performed an error analysis specifically on XLMRoBERTa's outputs to better understand its performance. We report \textit{ezafe} F\textsubscript{1}-score per POS tag in order of performance in Table \ref{tab:ezafe_f1_per_pos}. \begin{table}[ht] \centering \begin{tabular}{cc|cc} \Xhline{2\arrayrulewidth} \bf POS & \bf \textit{Ezafe} F\textsubscript{1} & \bf POS & \bf \textit{Ezafe} F\textsubscript{1} \\ \hline P & 99.78\% & NUM & 92.19\% \\ DET & 98.60\% & CON & 91.16\% \\ N & 98.14\% & PRO & 84.74\% \\ ADJ & 96.61\% & MISC & 53.85\% \\ ADV & 95.13\% & FW & 30.43\% \\ \Xhline{2\arrayrulewidth} \end{tabular} \caption{\label{tab:ezafe_f1_per_pos} \textit{Ezafe} F\textsubscript{1}-score per POS for XLMRoBERTa's outputs on the test set. The average F\textsubscript{1}-score is 84.06\%.} \end{table} \begin{itemize} \item Preposition (P): With a relatively low diversity and a high frequency, according to Table \ref{tab:Ezafe_per_pos}, prepositions are the easiest one to label for the \textit{ezafe} recognizing model. In addition, prepositions are exclusive in \textit{ezafe} acceptance ~93\% of the time, making this POS quite easy. The most prevalent error in this POS is the model mistaking the preposition \textit{dar} ``in" with the noun \textit{dar} ``door", the second of which accepting \textit{ezafe} almost half of the time. \item Determiners (DET): They are easy to recognize partly due to their low diversity. In this POS, the model fails to recognize \textit{ezafe} specifically when the word shares another POS in which it differs in \textit{ezafe} acceptance, e.g., \textit{hadde'aksar} ``maximum" and \textit{bi\v{s}tar} ``mostly, most of", which accept \textit{ezafe} in DET role, but not in ADV. \item Nouns (N): Despite its high diversity, the model shows high performance in detecting \textit{ezafe} in this POS. This is probably due to its high frequency and high \textit{ezafe} acceptance. Morphological information helps the most in this POS, as many nouns are derived or inflected forms of the existing words. The performance suffers from phrase boundaries detection, which results in false positives. The model also fails to recognize \textit{ezafe} on low-frequency proper nouns, such as Shakespeare. Another common error in this POS is the combination of first and last names, which are usually joined using \textit{ezafe}. \item Adjective (ADJ) and Adverbs (ADV): Both mainly suffer from wrong detection of phrase boundaries, i.e., stopping too early or too late. For instance, look at Example 2 (the error is in bold): \begin{tabular}{llll} (2) & \textit{te'\={a}tr-e} & \textit{'emruz-}\emphb{e} & \textit{qarb} \\ & theater-\textit{ez.} & contemp.-\textit{ez.} & west \\ & \multicolumn{3}{l}{``contemporary western theater"} \\ \end{tabular} \item Numbers (NUM): The errors in this POS comprise mainly the cardinal numbers, especially when written in digits. The main reason could be the scarcity of digits with \textit{ezafe}. For instance, look at Example 3 (the error is in bold): \begin{tabular}{llll} (3) & \textit{s\={a}l-e} & \textit{1990-}\emphb{e} & \textit{mil\={a}di} \\ & year-\textit{ez.} & 1990-\textit{ez.} & Gregorian \\ & \multicolumn{3}{l}{``year 1990 of the Gregorian calendar"} \\ \end{tabular} \item Conjunctions (CON): It is quite rare for a conjunction to accept \textit{ezafe}, which consequently causes error in \textit{ezafe} recognition. \item Pronouns (PRO): PRO has a low \textit{ezafe} acceptance rate and a low frequency, which makes it a difficult POS. Most of the errors in this POS occur for the emphatic pronoun \textit{xod} ``itself, themselves, etc.", which receives \textit{ezafe}, as opposed to its reflective role, which does not. \item Miscellaneous (MISC): Low \textit{ezafe} acceptance and low frequency are the main reasons for the errors in this POS. The errors mainly consist of Latin single letters in scientific texts. Look at Example 4, for instance (the error is in bold): \begin{tabular}{lllll} (4) & \textit{L-}\emphb{e} & \textit{be} & \textit{dast} & \textit{'\={a}made} \\ & L-\textit{ez.} & to & hand & come \\ & \multicolumn{4}{l}{``the obtained [value of] L"} \\ \end{tabular} \item Foreign words (FW): With a very low frequency, very low \textit{ezafe} acceptance rate, and a very high diversity, this POS is by far the most difficult one for the model. Additionally, FW usually appears in scientific and technical texts, which makes it harder for the model, as such texts contain a considerable amount of specialized low-frequency vocabulary. Examples of errors in this POS are `DOS', `Word', `TMA', `off', `TWTA', etc. \end{itemize} As discussed above, errors are most prevalently caused by model's mistaking phrase boundaries and homographs that have different syntactic roles and/or \textit{ezafe} acceptance criteria. While conducting the error analysis, we discovered considerable amounts of errors in Bijankhan corpus, which motivated us to correct the \textit{ezafe} labels of a part of the test corpus and measure the performance again. We, therefore, asked two annotators to re-annotate \textit{ezafe} labels of the first 500 sentences of the test corpus in parallel, and a third annotator's opinion where there is a disagreement. The results of the best model, XLMRoBERTa, on the first 500 sentences of the test corpus before and after the \textit{ezafe} label correction can be seen in Table \ref{tab:rect_results}. These 500 sentences contain 14,934 words, 3,373 of them with \textit{ezafe}, based on Bijankhan labels. \begin{table}[ht] \centering \begin{tabular}{c|ccc} \Xhline{2\arrayrulewidth} \bf Test Corpus & \bf Precision & \bf Recall & \bf F\textsubscript{1}-score \\ \hline \bf Bijankhan & 0.9691 & 0.9851 & 0.9770 \\ \bf Corrected & 0.9838 & 0.9897 & 0.9867 \\ \Xhline{2\arrayrulewidth} \end{tabular} \caption{\label{tab:rect_results} XLMRoBERTa's precision, recall, and F\textsubscript{1}-score on the first 500 sentences of the test set, before and after \textit{ezafe} label correction.} \end{table} Correcting \textit{ezafe} labels resulted in 0.97\% increase in F\textsubscript{1}-score on the abovementioned part of the test corpus. The same correction for all of the test corpus might result in a near 99\% F\textsubscript{1}-score for XLMRoBERTa model. Transformer-based models perform remarkably even where there is a typo crucial to \textit{ezafe} recognition, i.e., when the intrusive consonant `\textit{y}' is missed between an ending vowel and a (not-written) \textit{ezafe}, for instance, \textit{diskh\={a}-}\emphb{y}\textit{[e]} ``disks" and \textit{be'ez\={a}-}\emphb{y}\textit{[e]} ``for". \section{POS Tagging} \begin{table*}[th] \centering \small \begin{tabular}{c|c|cccc|cccc|c} \Xcline{1-11}{2\arrayrulewidth}\\[-1em] &\multirow{2}{*}{\textbf{Model}} & \multicolumn{4}{c|}{\textbf{Validation}} & \multicolumn{4}{c|}{\textbf{Test}} & \bf Approx.\\ && \textbf{Prec.} & \textbf{Recall} & \textbf{F\textsubscript{1}} & \textbf{Acc.} & \textbf{Prec.} & \textbf{Recall} & \textbf{F\textsubscript{1}} & \textbf{Acc.} & \bf T.T. \\ \hline \parbox[t]{2mm}{\multirow{4}{*}{\rotatebox[origin=c]{90}{\bf Single}}} &\bf CRF\textsubscript{1} (baseline) & 0.9688 & 0.9380 & 0.9521 & 0.9832 & 0.9680 & 0.9373 & 0.9511 & 0.9831 & 0.8 h \\ &\bf CRF\textsubscript{2} & 0.9679 & 0.9530 & 0.9602 & 0.9854 & 0.9684 & 0.9514 & 0.9595 & 0.9854 & 0.9 h \\ &\bf BLSTM+CNN & 0.9680 & 0.9573 & 0.9626 & 0.9873 & 0.9677 & 0.9570 & 0.9623 & 0.9869 & 1.3 h \\ &\bf BERT & 0.9703 & \bf 0.9719 & \underline{0.9710} & \underline{0.9899} & 0.9687 & \bf 0.9716 & \underline{0.9701} & \textit{0.9895} & 1.4 h \\ &\bf XLMRoBERTa & 0.9700 & \underline{0.9718} & \textit{0.9708} & \bf 0.9900 & 0.9706 & \underline{0.9714} & \bf 0.9709 & \bf 0.9901 & 0.9 h \\ \hline \parbox[t]{2mm}{\multirow{4}{*}{\rotatebox[origin=c]{90}{\bf Input}}} &\bf CRF\textsubscript{2} & 0.9697 & 0.9563 & 0.9628 & 0.9859 & 0.9708 & 0.9555 & 0.9629 & 0.9859 & 1 h \\ &\bf BLSTM+CNN & 0.9724 & 0.9597 & 0.9660 & 0.9878 & 0.9731 & 0.9587 & 0.9658 & 0.9877 & 1.4 h \\ &\bf BERT & \underline{0.9731} & \textit{0.9691} & \bf 0.9711 & \textit{0.9897} & 0.9710 & \textit{0.9690} & \textit{0.9700} & \underline{0.9897} & 1.5 h \\ &\bf XLMRoBERTa & \textit{0.9730} & 0.9689 & 0.9709 & 0.9896 & \textit{0.9714} & 0.9692 & 0.9703 & \textit{0.9895} & 1 h \\ \hline \parbox[t]{2mm}{\multirow{3}{*}{\rotatebox[origin=c]{90}{\bf Multi}}} &\bf BLSTM+CNN & 0.9727 & 0.9569 & 0.9647 & 0.9875 & 0.9724 & 0.9565 & 0.9643 & 0.9872 & 1.4 h \\ &\bf BERT & \bf 0.9735 & 0.9665 & 0.9699 & 0.9896 & \bf 0.9728 & 0.9650 & 0.9688 & 0.9888 & 1.5 h \\ &\bf XLMRoBERTa & \textit{0.9730} & 0.9656 & 0.9692 & 0.9887 & \underline{0.9725} & 0.9648 & 0.9686 & 0.9884 & 1 h \\\Xhline{2\arrayrulewidth} \end{tabular} \caption{\label{tab:pos_results} POS tagging results (precision, recall, F\textsubscript{1}-score, and accuracy) on the validation and test sets using the single- and multi-task and \textit{ezafe} in the input settings. In each column, the best result(s) is/are in bold, the second best underlined, and the third best italicized. The last column shows the approximate training time in hours.} \end{table*} \label{sec:pos} For the task of POS tagging, we experimented with CRF\textsubscript{1}, CRF\textsubscript{2}, BLSTM+CNN, BERT, and XLMRoBERTa models in the single-task settings, multi-task settings with \textit{ezafe} as the auxiliary task (except for CRFs), and also in a single-task setting with \textit{ezafe} information in the input. For the last one, we added the \textit{ezafe} output of XLMRoBERTa in Section \ref{sec:ezafe} to the input text. In this section, we first explain the role of \textit{ezafe} information in POS tagging, then we discuss the results of the POS tagging task, and then we analyze it. \subsection{The Role of \textit{Ezafe}} \label{subsec:role_of_ezafe} \textit{Ezafe} is a linker between words in nonverbal phrases. It is hence not used between phrases, which can be an indicator of phrase boundaries \cite{tabibzadeh2014}. Compare Examples 5a and 5b, for instance. This means that \textit{ezafe} information will help the model, and also humans, to better detect the phrase boundaries, which can be helpful in recognizing syntactic roles \cite{nourian2015importance}. \medskip \begin{tabular}{lllll} (5) & a. & [\textit{pesar}] & [\textit{xo\v{s}h\={a}l}] & [\textit{'\={a}mad}] \\ && boy & happy & came \\ && N & ADV & V \\ && \multicolumn{3}{l}{``The boy came happily"} \\ &&&&\\ & b. & [\textit{pesar-e} & \textit{xo\v{s}h\={a}l}] & [\textit{'\={a}mad}] \\ && boy-\textit{ez.} & happy & came \\ && N & ADJ & V \\ && \multicolumn{3}{l}{``The happy boy came"} \\ \end{tabular} \medskip Knowing \textit{ezafe} also helps the model determine the POS of some homographs. Some examples are as follows. The information below is resulted from studying homographs based on their POSs in Bijankhan corpus. \begin{itemize} \item The `\textit{i}' suffix in Persian can be derivational or inflectional. When derivational, it is either a nominalizer or an adjectivizer and the derived form will accept \textit{ezafe}. When inflectional, it is an indefinite marker and the inflected form will not accept \textit{ezafe}. Some examples are \textit{kamy\={a}bi} ``scarcity, rarity", \textit{yeks\={a}ni} ``sameness", \textit{\v{s}egeft'angizi} ``wonderfulness", \textit{bim\={a}ri} ``illness", \textit{'\={a}\v{s}pazi} ``cooking". \item Adverbized adjectives that are homonyms in both roles, accept \textit{ezafe} only in their adjective role. For example \textit{samim\={a}ne} ``friendly, cordial" and \textit{ma'refat\v{s}en\={a}s\={a}ne} ``epistemological". \item Determiners that have a pronoun form accept \textit{ezafe} in the former, but not in the latter role. For example \textit{'aqlab} ``mostly", \textit{'aksar} ``most of", \textit{hame} ``all", \textit{'omum} ``general, most of". \item \textit{Ezafe} information might also help the model better recognize POSs that never accept \textit{ezafe}, such as verbs (V) and identifiers (IDEN). \end{itemize} \subsection{Results} Table \ref{tab:pos_results} shows the results of POS tagging on validation and test sets using single- and multi-task and \textit{ezafe} in the input settings. With the single-task settings, XLMRoBERTa and BERT outperform the other models and have almost equal performances. When \textit{ezafe} information is fed to the input, the precision of all the models increases while the recall shows a more complex behavior. For CRF\textsubscript{2} and BLSTM+CNN, we see a slight increase, and for the transformer-based models, we see a decrease of 0.3 to 0.4\%. The F\textsubscript{1}-score of CRF\textsubscript{2} model increases by 0.34\% and BLSTM+CNN model by 0.27\%. For BERT, it stays almost the same, and for XLMRoBERTa, it sees a decrease of 0.06\%. Table \ref{tab:pos_change} shows the change in F\textsubscript{1}-scores of each POS when \textit{ezafe} is fed with the input. As for the multi-task settings, the precision goes up, and the recall and the F\textsubscript{1}-score come down for transformer-based and BLSTM-CNN models. Figure \ref{fig:pos_results} shows POS tagging F\textsubscript{1}-scores for single-task, in the inputs, and multi-task settings, respectively, from top to bottom, on the test set. \begin{figure}[ht] \includestandalone[width=.48\textwidth]{pos_bar_chart} \caption{\label{fig:pos_results} POS tagging F\textsubscript{1}-scores for single-task, input, and multi-task settings, respectively from top to bottom, on the test set.} \end{figure} Table \ref{tab:pos_result_detailed} shows POS tagging F\textsubscript{1}-scores per POS on the test set for the single-task and \textit{ezafe} in the input settings for CRF\textsubscript{2} and BLSTM+CNN models and for single-task settings for XLMRoBERTa model. An increase can be seen in the F\textsubscript{1}-score when \textit{ezafe} information is provided to the model. As there is no increase in XLMRoBERTa's results when \textit{ezafe} information is provided, the results for this setting are not shown for this model. \begin{table}[ht] \centering \small \addtolength{\tabcolsep}{-1pt} \begin{tabular}{ccc|ccc} \Xhline{2\arrayrulewidth}\\[-1em] \bf POS & \bf CRF\textsubscript{2} & \bf B.+C. & \bf POS & \bf CRF\textsubscript{2} & \bf B.+C. \\ \hline \bf IDEN & 2.80\% & 2.69\% & \bf ADJ & 0.05\% & 0.07\% \\ \bf FW & 0.79\% & 0.83\% & \bf P & 0.03\% & 0.06\% \\ \bf ADV & 0.64\% & 0.69\% & \bf N & 0.03\% & 0.03\% \\ \bf DET & 0.13\% & 0.16\% & \bf NUM & 0.02\% & 0.02\% \\ \bf V & 0.06\% & 0.15\% & \bf CON & 0.01\% & 0.00\% \\ \bf PRO & 0.06\% & 0.08\% & \bf DELM & 0.00\% & 0.00\% \\ \bf MISC & 0.06\% & 0.08\% & \bf PSTP & 0.00\% & -0.01\% \\ \Xhline{2\arrayrulewidth} \end{tabular} \addtolength{\tabcolsep}{1pt} \caption{\label{tab:pos_change} The change in POS tagging F\textsubscript{1}-scores for CRF\textsubscript{2} and BLSTM+CNN models when \textit{ezafe} information is fed with the input.} \end{table} \begin{table}[ht] \centering \small \addtolength{\tabcolsep}{-1pt} \begin{tabular}{c|cccc|c} \Xhline{2\arrayrulewidth}\\[-1em] \multirow{2}{*}{\bf POS} & \multicolumn{2}{c}{\bf CRF\textsubscript{2}} & \multicolumn{2}{c|}{\bf BLSTM+CNN} & \bf X.R. \\ & \bf Single & \bf Input & \bf Single & \bf Input & \bf Single \\ \hline \bf DELM & 0.9999 & 0.9999 & 1.0000 & 1.0000 & 1.0000 \\ \bf PSTP & 0.9995 & 0.9995 & 0.9996 & 0.9995 & 0.9998 \\ \bf NUM & 0.9964 & 0.9966 & 0.9974 & 0.9982 & 0.9969 \\ \bf CON & 0.9949 & 0.9950 & 0.9964 & 0.9964 & 0.9968 \\ \bf P & 0.9944 & 0.9947 & 0.9959 & 0.9961 & 0.9966 \\ \bf V & 0.9943 & 0.9949 & 0.9958 & 0.9964 & 0.9965 \\ \bf N & 0.9870 & 0.9873 & 0.9893 & 0.9896 & 0.9904 \\ \bf PRO & 0.9711 & 0.9717 & 0.9788 & 0.9795 & 0.9835 \\ \bf DET & 0.9661 & 0.9674 & 0.9705 & 0.9713 & 0.9784 \\ \bf ADJ & 0.9519 & 0.9524 & 0.9539 & 0.9555 & 0.9635 \\ \bf ADV & 0.9300 & 0.9364 & 0.9414 & 0.9483 & 0.9534 \\ \bf MISC & 0.9117 & 0.9123 & 0.9127 & 0.9142 & 0.9375 \\ \bf FW & 0.9046 & 0.9125 & 0.9036 & 0.9119 & 0.9337 \\ \bf IDEN & 0.8318 & 0.8598 & 0.8375 & 0.8644 & 0.8656 \\ \Xhline{2\arrayrulewidth} \end{tabular} \addtolength{\tabcolsep}{1pt} \caption{\label{tab:pos_result_detailed} POS tagging F\textsubscript{1}-scores per POS on the test set for CRF\textsubscript{2} and BLSTM+CNN (single-task and \textit{ezafe} in the input) and for XLMRoBERTa (single-task).} \end{table} \subsection{Analysis} As discussed in Subsection \ref{subsec:role_of_ezafe}, we anticipated to see an increase in several POSs, including N, ADJ, ADV, DET, V, and IDEN. According to Table \ref{tab:pos_result_detailed}, the highest increase belongs to IDEN, FW, ADV with an average increase of $\sim$2.75\%, $\sim$0.81\%, and $\sim$0.67\%, respectively. The increase for V is 0.06\% and for N, 0.03\% for both models, and for DET, 0.13\% and 0.08\%, and for ADJ, 0.05\% and 0.16\% for CRF\textsubscript{2} and BLSTM+CNN, respectively. As for the transformer-based models results, they do not seem to benefit from the \textit{ezafe} information either in the input or as an auxiliary task. As the work on syntactic probing shows, attention heads in transformer-based models, specifically BERT, capture some dependency relation types \cite{htut2019attention}. As \textit{ezafe} is a more limited form of dependency \cite{shojaei2019corpus}, its information could be captured by the attention heads in such models. On the other hand, contextualized embeddings also seem to capture some syntactic relations \cite{47786,hewitt-manning-2019-structural}, which is another reason for such models' high performance in capturing \textit{ezafe} information. All in all, it seems that transformer-based models already have captured the \textit{ezafe} information owing to their architecture (attention heads), pretraining, contextual embeddings, and finally, being trained on the POS tagging task (which is related to the task of \textit{ezafe} recognition, and that is why their performance does not enhance when such information is provided. \section{Conclusion and Future Work} In this paper, we experimented with different models in the tasks of \textit{ezafe} recognition and POS tagging and showed that transformer-based models outperform the other models by a wide margin. We also provided \textit{ezafe} information to the POS tagging models and showed that while CRF and RNN-based models benefit from this information, transformer-based models do not. We suggest that this behavior is most probably due to (1) contextual representation, (2) pretrained weights, which means a limited knowledge of syntactic relations between words, (3) the attention heads in these models, and (4) being trained on the POS task, which is related to \textit{ezafe} recognition. An interesting direction for future work would be to investigate the role of \textit{ezafe} in transformer-based models in the tasks that such information would be helpful, such as dependency and shallow parsing.
{'timestamp': '2020-10-06T02:23:52', 'yymm': '2009', 'arxiv_id': '2009.09474', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09474'}
arxiv
\section{Introduction}\label{SEC:INT} The unmanned ground vehicle (UGV) has been the subject of much research and application toward numerous missions and goals that present a danger to human first responders such as exploration, reconnaissance, and search and rescue operations \cite{Delmerico2017,Perez-Imaz2016,Tadokoro2019}. The most widely used wheeled ground robots have skid-steer \cite{Yi2009} or Ackerman \cite{Weinstein2010} steering designs, so their movement is limited compared to legged robots that can move omnidirectionally. In order to maximize the capability of wheeled UGVs, different steering geometries have been considered. AGRO is a novel Agile Ground RObot that aims to be highly maneuverable and rapidly deployable with the best attributes of both wheeled and legged robots. AGRO has the ability to maneuver quasi-omnidirectionally on the ground with a Four-Wheel Independent Drive and Steering (4WIDS) architecture similar to \cite{Mori2002} and \cite{Michaud2003}. This wheel architecture also allows AGRO the novel ability to control its orientation in the air by using the reaction torques from in-wheel hub motors to ensure it lands upright \cite{Gonzalez2020}. Inspired by the agile mobility of a cat, this capability allows AGRO to evenly distribute the force of impact to all four wheels when it is thrown over walls and fences, or through windows to achieve rapid and reliable deployment (See Fig. \ref{fig01}). \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/DemoAndCat.png} \caption{Composite video stills of (top) a cat orienting its body mid-air and landing on its feet \cite{Marey1894} and (bottom) AGRO being thrown, stabilizing its attitude mid-air, and landing on all four wheels.} \label{fig01} \end{figure} While airborne, AGRO exhibits complicated dynamics with coupled states. Since simple linear control design techniques can be easily employed, several linearization approaches have been proposed to control similar nonlinear systems \cite{Cambera2017,Buss2016,Farzan2019,Terry2017,Engelhardt2016}. One of the most commonly used control designs is a feedback linearization method that algebraically transforms the nonlinear system dynamics into a fully or partially linearized system by choosing the control inputs to cancel the nonlinear terms. In order to achieve the best results, however, exact knowledge of the system parameters is required, and these are difficult to fully model or acquire empirically. Another applicable nonlinear control strategy is the backstepping control technique that was introduced in 1992 \cite{kokotovic1992joy}. Backstepping control design shows more flexibility compared to the feedback linearization because the resulting input-output dynamics need not be linear. Additionally, backstepping controllers keep using useful nonlinear terms whereas a typical feedback linearization approach cancels nonlinear terms. The main idea of the backstepping control strategy is to use some of the state variables as virtual- or pseudo-controls, and depending on the dynamics of each state, design intermediate control laws that are verified using Lyapunov analysis. This paper presents two nonlinear controllers for the AGRO system. First, we apply a feedback linearization approach to control $\varphi$-$\theta$-$\psi$. To apply the feedback linearization controller without complicated calculation, we simplify the equation of system dynamics by defining specific control input terms. Although the feedback linearization controller is simple to implement, there is the possibility that the model uncertainty and external disturbances can cause instability of the system or performance degradation because it uses inverse system dynamics as part of the control input to cancel nonlinear terms. To consider the robustness issue with model uncertainty and external disturbances, we apply the adaptive backstepping control strategy for controlling AGRO using a virtual control input. In this paper, the dynamics of an airborne 4WIDS robot are derived in Section II. In Section III, the feedback linearization strategy for stabilizing aerial attitude is described. Then the adaptive backstepping control approach is presented with system uncertainties and unknown disturbances in Section IV. In Section V, the simulation results of the two controllers are presented. Section VI provides a conclusion and outlines future work to be conducted. \section{Dynamics of an Airborne 4WIDS Robot} \begin{figure}[t] \centering \includegraphics[width=0.8\linewidth]{figure/AerialParams.png} \caption{3D Airborne Kinematic Parameters. Steering angle displacement $\delta_i$ is measured deviation from the forward driving direction, with $\delta_i = \angle \hat{B}_X \hat{S}_{xi}$ for $i$ = 1, 4 and $\delta_i = \angle\hat{B}_X \hat{S}_{xi}-\pi$ for $i$ = 2, 3. Unit Vectors $\hat{B}_X$, $\hat{B}_Y$, and $\hat{B}_Z$ are fixed in the Newtonian frame $O$} \label{Kinematic Params 3D} \end{figure} To design a controller for the orientation of AGRO while in the air, the dynamic model of the system must be derived. The following is a summarized derivation of the airborne dynamics of AGRO. For further understanding of kinematics parametrization, singularity analysis, and its affect on aerial orientation manipulability, as well as a more complete derivation of the following dynamics, please refer to \cite{Gonzalez2020}. The four attached steerable offset wheels impart reaction torques $\Vec{\tau}_{Bi}$ and forces $\Vec{F}_{Bi}$ on the base at points $S_i$ (See Fig. \ref{FBD}). Taking the Newton-Euler equation for angular momentum for the base about its mass center, we get \begin{equation} \sum_{i=1}^{4}\left(\Vec{\tau}_{Bi}+\Vec{r}_{BS_i}\times\Vec{F}_{Bi}\right) = \frac{d}{dt}\left(\left[J_B\right]\Vec{\Omega}\right) \end{equation} Torque from each wheel $\Vec{\tau}_{Bi}$ can be broken down as the commanded wheel drive torque input $\tau_i$, the commanded steering joint torque $\tau_{\delta i}$ and one reaction torque $\tau_x$ about the wheel’s local X axis. \begin{equation}\label{torques} \Vec{\tau}_{Bi} = \begin{cases} \tau_{xi} \hat{W_i}_x \\ \tau_i \hat{W_i}_y \\ \tau_{\delta i} \hat{W_i}_z \end{cases} \end{equation} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/FBD} \caption{Free Body Diagram for a) the main base and b) a single wheel module.} \label{FBD} \end{figure} This scalar wheel reaction torque component $\tau_{xi}$ can be derived by dotting the total angular momentum of the wheel about the steering joint by its local $\hat{W}_{ix}$ axis. \begin{equation}\label{Tauxi} \tau_{xi}=\left(-\frac{d}{dt}\left(\left[J_W\right]\Vec{\omega}_i\right)-\Vec{r}_{W_iS_i}\times\Vec{F}_{Bi}\right) \cdot \hat{W}_{ix}. \end{equation} Each wheel has linear momentum, is acted upon by gravity, and reacts against the robot base. Resultant reaction forces $\Vec{F}_{Bi}$ can be solved for using the linear momentum equation for the wheels. \begin{equation}\label{FBI} \Vec{F}_{Bi} = -m_W\left(\frac{d^2}{dt^2}\left(\Vec{r}_{OW_i}\right)+g\hat{Z}\right) \end{equation} For tractability, we assume nonmoving steering angles ($\dot\delta=0$, $\ddot\delta=0$), cross-symmetry ($\delta_1 = \delta_3$, $\delta_2 = \delta_4$), and cross-symmetric torque application ($\tau_1 = -\tau_3$, $\tau_2 = -\tau_4$). Combining these expressions leads to the three nonlinear equations of motion for AGRO’s orientation while in the air. \begin{equation} \label{EOMx} \begin{split} (J_{Bxx}+J_{m_Wxx}+2J_{Wxx}(\cos\delta_1+\cos\delta_2))\dot{\Omega}_x&\\ +(J_{Bzz}-J_{Byy} + J_{m_Wxx})\Omega_y\Omega_z&\\ = 2\tau_1 \sin\delta_1-2\tau_2\sin&\delta_2 \end{split} \end{equation} \begin{equation}\label{EOMy} \begin{split} (J_{Byy}+J_{m_Wyy}+2J_{Wxx}(\sin\delta_1+\sin\delta_2))\dot\Omega_y&\\ +(J_{Bxx}-J_{Bzz}+ J_{m_Wyy})\Omega_x\Omega_z&\\ =-2\tau_1 \cos \delta_1+2\tau_2\cos&\delta_2 \end{split} \end{equation} \begin{equation} \label{EOMz} \begin{split} (J_{Bzz})\dot\Omega_z + (J_{Byy}-J_{Bxx})\Omega_x\Omega_y&=4\tau_{\delta} \end{split} \end{equation} where \begin{equation} \label{JmWxx} J_{m_Wxx} = 2m_W\left((\frac{b}{2} + c\cos\delta_1)^2+(\frac{b}{2} + c\cos\delta_2)^2\right) \end{equation} and \begin{equation} \label{JmWyy} J_{m_Wyy} = 2m_W\left((\frac{a}{2} + c\sin\delta_1)^2+(\frac{b}{2} + c\sin\delta_2)^2\right) \end{equation} In \eqref{EOMx}-\eqref{JmWyy}, $J_{Bii}$ and $J_{Wii}$ are the body and wheel moment of inertia along $\hat{B}_{i}$ and $\hat{W}_{i}$, respectively. $J_{m_{W}ii}$ is the overall inertia of the base reflected by wheel masses. $\delta_i$ is steering angle displacement measured deviation from the forward driving direction. Each equation of motion \eqref{EOMx}-\eqref{EOMz} contains linear inertial terms, nonlinear Coriolis terms, and control inputs from wheel drive and steering torques. The input commands can be further simplified using the Jacobian relating whole body reaction torques about the body-centric axes to the wheel and steering torques: \begin{equation}\label{torqueMatrix} \begin{bmatrix}\tau_x\\ \tau_y \\ \tau_z\end{bmatrix} = \mathbb{J}_\tau\begin{bmatrix}\tau_1\\ \tau_2 \\ \tau_\delta\end{bmatrix} \end{equation} where \begin{equation}\label{Jacobian} \mathbb{J}_\tau= \begin{bmatrix} 2\sin(\delta_1) & -2\sin(\delta_2) & 0\\ -2\cos(\delta_1) & 2\cos(\delta_2) & 0\\ 0 & 0 & 4 \end{bmatrix} \end{equation} \section{Feedback Linearization Control}\label{SEC:FL} The ability to reliably and repeatably land on its wheels is critical for the continuation of AGRO's inspection and response missions. This section proposes an amendment to the original simple PD control strategy by using feedback linearization to enable AGRO to compensate for nonlinear dynamics and land more reliably. First, the equations of motion \eqref{EOMx}-\eqref{EOMz} can be rewritten with [$\Omega_x$, $\Omega_y$, $\Omega_z$] = [$\dot\varphi$, $\dot\theta$, $\dot\psi$] as \begin{equation} \label{eq_EOM1} \begin{split} &\ddot{\varphi} =\frac{(J_{Byy}-J_{Bzz}-J_{m_{W}xx})\dot{\theta}\dot{\psi}+\tau_x}{J_{Bxx}+J_{m_{W}xx}+2J_{Wxx}(cos\delta_{1}+cos\delta_{2})}\\ \end{split} \end{equation} \begin{equation} \label{eq_EOM2} \begin{split} &\ddot{\theta} = \frac{(-J_{Bxx}+J_{Bzz}-J_{m_{W}yy})\dot{\varphi}\dot{\psi}+\tau_y}{J_{Byy}+J_{m_{W}yy}+2J_{Wxx}(sin\delta_{1}+sin\delta_{2})} \end{split} \end{equation} \begin{equation} \label{eq_EOM3} \begin{split} \ddot{\psi} = \frac{1}{J_{Bzz}}\left((J_{Bxx}-J_{Byy})\dot{\varphi}\dot{\theta}+\tau_z\right) \end{split} \end{equation} where $[\varphi, \theta, \psi]$ represents the small rotation roll, pitch, and yaw angles, respectively. We define input terms as \begin{equation} \label{eq_inputs} u_1=\tau_x,~~ u_2=\tau_y,~~ u_3=\tau_z \end{equation} and simplify inertial constants as \begin{equation} \begin{split} J_{\varphi,1} &= \left(J_{Bxx}+J_{m_{W}xx}+2J_{Wxx}(cos\delta_1+cos\delta_2)\right)\\ J_{\theta,1} &= \left(J_{Byy}+J_{m_{W}yy}+2J_{Wxx}(sin\delta_1+sin\delta_2)\right)\\ J_{\psi,1} &= J_{Bzz}\\ J_{\varphi,2}&=J_{Byy}-J_{Bzz}-J_{m_{W}xx}\\ J_{\theta,2}&=-J_{Bxx}+J_{Bzz}-J_{m_{W}yy}\\ J_{\psi,2}&=J_{Bxx}-J_{Byy} \end{split} \end{equation} to simplify the equations of motion of the AGRO system to \begin{equation} \label{eq_EOM_phi} \ddot{\varphi}= \frac{J_{\varphi,2}\dot{\theta}\dot{\psi} + u_1}{J_{\varphi,1}} \end{equation} \begin{equation} \label{eq_EOM_theta} \ddot{\theta}= \frac{J_{\theta,2}\dot{\varphi}\dot{\psi} + u_2}{J_{\theta,1}} \end{equation} \begin{equation} \label{eq_EOM_psi} \ddot{\psi}= \frac{J_{\psi,2}\dot{\varphi}\dot{\theta} + u_3}{J_{\psi,1}}, \end{equation} For a vector form of the system, (\ref{eq_EOM_phi})-(\ref{eq_EOM_psi}) can be written with $\textbf{x} = [\varphi, \theta, \psi]^T$ and $\textbf{u}=[u_1, u_2, u_3]^T$ as the following \begin{equation} \label{eq_EOM_matrix} \begin{split} \ddot{\textbf{x}} &= f(\textbf{x},\dot{\textbf{x}})+g(\textbf{x})\textbf{u}\\ f(\textbf{x},\dot{\textbf{x}}) = \begin{bmatrix} \frac{J_{\varphi,2}}{J_{\varphi,1}}\dot{\theta}\dot{\psi}\\ \frac{J_{\theta,2}}{J_{\theta,1}}\dot{\varphi}\dot{\psi}\\ \frac{J_{\psi,2}}{J_{\psi,1}}\dot{\varphi}\dot{\theta}\\ \end{bmatrix}&, \quad g(\textbf{x}) = \begin{bmatrix} \frac{1}{J_{\varphi,1}} & 0 & 0\\ 0 & \frac{1}{J_{\theta,1}} & 0\\ 0 & 0 & \frac{1}{J_{\psi,1}} \end{bmatrix} \end{split} \end{equation} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/FLBlockDiagram.PNG} \caption{Block diagram of the PD + Feedback Linearization control architecture.} \label{figFLBlock} \end{figure} From (\ref{eq_EOM_matrix}), we apply the feedback linearization method for $\varphi$-$\theta$-$\psi$ control of the AGRO system, as shown in Fig. \ref{figFLBlock}. To obtain control inputs for the $\varphi$-$\theta$-$\psi$ controller, we choose \begin{equation} \label{eq_FL_u} \begin{bmatrix} u_1\\ u_2\\ u_3 \end{bmatrix} = g(x)^{-1} \begin{bmatrix} -\frac{J_{\varphi,2}}{J_{\varphi,1}}\dot{\theta}\dot{\psi}+v_1\\ -\frac{J_{\theta,2}}{J_{\theta,1}}\dot{\varphi}\dot{\psi}+v_2\\ -\frac{J_{\psi,2}}{J_{\psi,1}}\dot{\varphi}\dot{\theta}+v_3\\ \end{bmatrix} \end{equation} where [$v_1$, $v_2$, $v_3$] are pseudo-inputs. Setting pseudo input terms as shown in the following \begin{equation} \label{eq_FL_pseudo_u} \begin{split} v_1 = \ddot{\varphi}_d + k_{\varphi,1}\dot{e}_{\varphi} + k_{\varphi,2}e_{\varphi}\\ v_2 = \ddot{\theta}_d + k_{\theta,1}\dot{e}_{\theta} + k_{\theta,2}e_{\theta}\\ v_3 = \ddot{\psi}_d + k_{\psi,1}\dot{e}_{\psi} + k_{\psi,2}e_{\psi} \end{split} \end{equation} yields \begin{equation} \begin{split} \ddot{e}_{\varphi} + k_{\varphi,1}\dot{e}_{\varphi} + k_{\varphi,2}e_{\varphi} = 0\\ \ddot{e}_{\theta} + k_{\theta,1}\dot{e}_{\theta} + k_{\theta,2}e_{\theta} = 0\\ \ddot{e}_{\psi} + k_{\psi,1}\dot{e}_{\psi} + k_{\psi,2}e_{\psi} = 0 \end{split} \end{equation} where $e_{\varphi}=\varphi_d-\varphi$, $e_{\theta}=\theta_d-\theta$, $e_{\psi}=\psi_d-\psi$ and $k_{i,j}$ are the diagonal components of gain matrices $K_j$. By using these control inputs, the nonlinear terms in the system are canceled, and the system can be stable following a given reference input. \section{Adaptive Backstepping Control} We now consider an adaptive backstepping method of designing the feedback controller for AGRO, which can more readily counteract unmodeled external disturbances or modeling error. Considering model uncertainties and external disturbance, the AGRO system (\ref{eq_EOM_matrix}) can be rewritten as \begin{equation} \label{eq_dyn_with_L} \begin{split} \ddot{\textbf{x}} &= [f(\textbf{x},\dot{\textbf{x}}) + \Delta f(\textbf{x},\dot{\textbf{x}})] + [g(\textbf{x}) + \Delta g(\textbf{x})]\textbf{u} + \varepsilon \\ &= f(\textbf{x},\dot{\textbf{x}}) + g(\textbf{x})\textbf{u} + L, \end{split} \end{equation} where \begin{equation} L = \Delta f(\textbf{x},\dot{\textbf{x}}) + \Delta g(\textbf{x}) \textbf{u} + \varepsilon \end{equation} where $\Delta f(\textbf{x},\dot{\textbf{x}})$ and $\Delta g(\textbf{x})$ are the unknown uncertainties, $\varepsilon$ represents an unknown external disturbance. The control objective is to force $\textbf{x}$ to track a given reference signal $\textbf{x}_d$. \textbf{Specifically, our control objective is as follows:} Given the desired state variables, $\textbf{x}_d$, determine a backstepping controller, so the output errors are as small as possible under the constraints. Here, we assume that the given desired state variables are bounded as follows \begin{equation} \vert \textbf{x}_d \vert ^2 + \vert \dot{\textbf{x}}_d \vert ^2 + \vert \ddot{\textbf{x}}_d \vert ^2 \leq \rho \end{equation} where $\rho$ is a positive constant. Let $\textbf{e}_1 = \textbf{x}_d - \textbf{x}$ define the error vector with respect to the vector of desired state variables $\textbf{x}_d = [\varphi_d, \theta_d, \psi_d]^T$, and let the first Lyapunov function be \begin{equation} \label{eq_V1} V_1 = \frac{1}{2} \textbf{e}_1^T \textbf{e}_1. \end{equation} Then we have the derivative of $V_1$ as \begin{equation} \begin{split} \label{eq_V1-2} \dot{V}_1 &= \textbf{e}_1^T \dot{\textbf{e}}_1 \\ &= \textbf{e}_1^T (\dot{\textbf{x}}_d - \dot{\textbf{x}}). \end{split} \end{equation} Here, we set $\dot{\textbf{x}}$ as a virtual control and define the desired value of virtual control, known as a stabilizing function, as follows \begin{equation} \label{eq_U1} U_v = \dot{\textbf{x}}_d + K_1\textbf{e}_1, \end{equation} where $K_1 = diag[k_{11},k_{12},k_{13}]$ is a diagonal gain matrix with positive entries. Substituting $\dot{\textbf{x}}$ in (\ref{eq_V1-2}) with (\ref{eq_U1}), the derivative of $V_1$ becomes \begin{equation} \dot{V}_1 = -K_1 \textbf{e}_1^T \textbf{e}_1 \leq 0. \end{equation} Now, the deviation of the virtual control from its desired value can be defined as \begin{equation} \label{eq_e2} \textbf{e}_2 = U_v - \dot{\textbf{x}} = \dot{\textbf{x}}_d - \dot{\textbf{x}} + K_1\textbf{e}_1. \end{equation} The derivative of $\textbf{e}_2$ can be presented as \begin{equation} \label{eq_e2_dot} \begin{split} \dot{\textbf{e}}_2 &= \ddot{\textbf{x}}_d - \ddot{\textbf{x}} + K_1\dot{\textbf{e}}_1 \\ &=\ddot{\textbf{x}}_d - f(\textbf{x},\dot{\textbf{x}}) - g(\textbf{x})\textbf{u} - L + K_1\dot{\textbf{e}}_1. \end{split} \end{equation} Let us define $\hat{L}$ as the estimated value of $L$ and $\Tilde{L}:=L-\hat{L}$, and let the second Lyapunov function be \begin{equation} \label{eq_V2} V_2 = \frac{1}{2} \textbf{e}_1^T \Gamma \textbf{e}_1 + \frac{1}{2} \textbf{e}_2^T \Lambda \textbf{e}_2 + \frac{1}{2}\Tilde{L}^T \Sigma\Tilde{L}, \end{equation} where $\Gamma$, $\Lambda$, and $\Sigma$ are positive semi-definite weighting matrices. Assuming that $L$ changes slowly enough, which leads to $\frac{d}{dt}\Tilde{L}=\dot{\Tilde{L}} \approx -\dot{\hat{L}}$, the first-order derivative of $V_2$ can be derived as \begin{equation} \label{eq_V2-2_1} \dot{V}_2 = \textbf{e}_1^T \Gamma \dot{\textbf{e}}_1 + \textbf{e}_2^T \Lambda \dot{\textbf{e}}_2 + \Tilde{L}^T\Sigma(-\dot{\hat{L}}) \end{equation} Then \eqref{eq_V2-2_1} becomes \begin{equation} \label{eq_V2-2_2} \begin{split} \dot{V}_2 &= \textbf{e}_1^T \Gamma (\dot{\textbf{x}}_d-\dot{\textbf{x}}) + \textbf{e}_2^T \Lambda (\ddot{\textbf{x}}_d - \ddot{\textbf{x}} + K_1\dot{\textbf{e}}_1) - \Tilde{L}^T \Sigma \dot{\hat{L}}\\ &= \textbf{e}_1^T \Gamma (\textbf{e}_2 - K_1 \textbf{e}_1) \\ & \ \ + \textbf{e}_2^T \Lambda (\ddot{\textbf{x}}_d - f(\textbf{x},\dot{\textbf{x}}) - g(\textbf{x})\textbf{u} - L + K_1\dot{\textbf{e}}_1) - \Tilde{L}^T \Sigma \dot{\hat{L}}\\ \end{split} \end{equation} To make the first-order derivative of $V_2$ negative definite, the backstepping control input should be selected as \begin{equation} \label{eq_UB} U_{B} =g^{-1}(\textbf{x}) (\Lambda^{-1}\Gamma\textbf{e}_1 - f(\textbf{x},\dot{\textbf{x}}) - \hat{L} + \ddot{\textbf{x}}_d + K_1\dot{\textbf{e}}_1 + K_2 \textbf{e}_2). \end{equation} Then \eqref{eq_V2-2_2} with \eqref{eq_UB} becomes \begin{equation} \label{eq_V2_final} \begin{split} \dot{V}_2 &= - K_1 \textbf{e}_1^T \Gamma \textbf{e}_1 - K_2 \textbf{e}_2^T \Lambda \textbf{e}_2 - \textbf{e}_2^T \Lambda (L - \hat{L}) - \Tilde{L}^T \Sigma \dot{\hat{L}} \\ &= - K_1 \textbf{e}_1^T \Gamma \textbf{e}_1 - K_2 \textbf{e}_2^T \Lambda \textbf{e}_2 - \Tilde{L}^T(\Lambda \textbf{e}_2 + \Sigma \dot{\hat{L}}) \end{split} \end{equation} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/BSBlockDiagram.PNG} \caption{Block diagram of the Backstepping control architecture with $\dot{\textbf{x}_d}=0$ and $\ddot{\textbf{x}}_d=0$.} \label{figBSBlock} \end{figure} The term $K_2 \textbf{e}_2$ is added to stabilize the output error $\textbf{e}_1$. With positive entries of $K_2 = diag[k_{21},k_{22},k_{23}]$ and an adaptive update rule \begin{equation} \dot{\hat{L}} = -\Sigma^{-1}\Lambda \textbf{e}_2 \end{equation} we can write (\ref{eq_V2_final}) as \begin{equation} \label{eq_V2_stability} \dot{V}_2 = - K_1 \textbf{e}_1^T \Gamma \textbf{e}_1 - K_2 \Lambda \textbf{e}_2^T \textbf{e}_2 \leq 0 \end{equation} which means $e_1$ and $e_2$ go to zero and the system is stable. The estimation $\hat{L}$ from $\frac{d}{dt}{\hat{L}}$ will converge to $L$ in steady state, so $\dot{V}_2 $ is negative semidefinite. Thus the system achieves Globally Asymptotic Stability. \section{Simulation and Comparison} In this section, we present simulation results of the two controllers; Proportional-Derivative with Feedback Linearization (PD+FL) and adaptive Backstepping (BS). The unknown uncertainties and external disturbances are not considered in the first comparison. The same simulation is then performed for the adaptive Backstepping controller with unknown uncertainties and external disturbances, to test the adaptation law. Note that we do not consider $\psi$ control in this simulation section, because the objective of these control strategies is to enable ARGO to land on the ground with stabilized attitude, $i.e.$ $\phi = 0\ deg.$ and $\theta = 0\ deg.$. \subsection{Comparing Feedback Linearization and Backstepping} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/sim1.png} \caption{Simulation comparison between the Proportional-Derivative with Feedback Linearization (FL) controller and the Backstepping (BS) Controller.} \label{Sim1} \end{figure} By canceling nonlinear terms in the system dynamics using feedback linearization approach, the proposed controller can achieve all desired attitudes successfully. In this simulation, initial parameters are set to: \begin{equation} \begin{split} \delta_1 = 45~ deg, \quad \delta_2 = -45~ deg,\\ J_{Bii} = [0.662, 0.940, 1.448] \ kg \cdot m^2,\\ J_{Wii} = [0.006565, 0.011689, 0.006565] \ kg \cdot m^2,\\ J_{m_{W}ii} = [0.3055, 0.4103, 0.7158] \ kg \cdot m^2,\\ \textbf{x}(0) = [-22.5, 22.5, 0]^T \ deg. \end{split} \end{equation} The AGRO system has initial pitch and roll angles as -22.5 and 22.5 degrees, respectively, and the desired attitude is set as $\textbf{x}_d = [0, 0, 0]^T$ degrees. Also, the control input limit is set as $\pm$32.1521 $Nm$. The control gain values are obtained using the Linear Quadratic Regulator (LQR) method: \begin{equation} J(u) = \int_{0}^{inf} (x^TQx + u^TRu) dt, \end{equation} where $Q=diag[16.5~~ 5299.4~~ 16.5~~ 5299.4~~ 16.5~~ 16.5]$, $R=diag[0.0002487~~ 0.0001326~~ 0.00006407]$ which yields \begin{equation} \begin{bmatrix} k_{\varphi,1}\\ k_{\varphi,2} \end{bmatrix} = \begin{bmatrix} k_{\theta,1}\\ k_{\theta,2} \end{bmatrix} = \begin{bmatrix} k_{\psi,1}\\ k_{\psi,2} \end{bmatrix} = \begin{bmatrix} 19.9977\\ 122.6497 \end{bmatrix} \end{equation} The Backstepping controller for this comparison used $K1 = 20I$, $K2 = 1800I$, $\Lambda=I$, $\Gamma=I$ and $\Sigma=I$. The result of comparing the PD+FL controller and the Backstepping Controller are shown in Fig. \ref{Sim1}. Each proposed controller improves upon the simple PD controller, with both the PD+FL controller and the Backstepping controller achieving the desired attitude in about 250 milliseconds. For reference, the robot prototype takes about 400ms to fall from a 0.85 meter drop. \subsection{Adaptive Backstepping Control} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/sim2.png} \caption{Adaptive Backstepping Controller rejecting disturbances in simulation.} \label{Sim2} \end{figure} The adaptation law was tested with Backstepping in the same simulation situation, but with different control parameters and added disturbances in the form of an external control input. The Backstepping controller for this simulation used $K1 = 10I$, $K2 = 200I$, $\Lambda = I$, $\Gamma = I$ and $\Sigma = 0.0005I$. The disturbance $L$ is a combination of a constant offset, a low-frequency (2 $rad/s$) sine wave, and Gaussian noise. The affect of these sources of noise and disturbance was kept under 20\%, 20\%, and 5\% of the maximum control effort, respectively. As shown in Fig. \ref{Sim2}, the adaptation law tracks the constant offset and sinusoidal disturbance sufficiently to attain and maintain stability. Fig. \ref{Sim3} shows the external disturbance $L$, the estimate $\hat{L}$ from the adaptation law, and the error between the two over time. Transient motion of the system affects the adaptation convergence, but once the robot approaches steady-state, the adaptation law is able to compensate for the offset and 2 $rad/s$ sine wave. Fig. \ref{Sim3zoom} shows the disturbance estimate $\hat{L}$ tracking the external disturbance closely, and the error between the two approaching 0 by ~700$ms$. \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/sim3.png} \caption{Adaptive Backstepping Controller rejecting disturbances in simulation. (Full time profile)} \label{Sim3} \end{figure}\begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figure/sim3zoom.png} \caption{Adaptive Backstepping Controller rejecting disturbances in simulation. (Zoomed in from 600ms to 1000ms)} \label{Sim3zoom} \end{figure} \section{Conclusion and Future Work} The PD+FL control method was compared to the backstepping control method using the same initial conditions in simulation. Both the backstepping controller and the PD+FL controller stabilized the system within 250 milliseconds, The backstepping controller with the adaptation law also performed well at compensating for offset noisy sinusoidal disturbances. Future work includes implementing the backstepping controller on the AGRO prototype, changing the wheel steering configuration on-the-fly to increase the control authority about the instantaneous axis of rotation, and investigating using a pre-planned trapezoidal feedforward torque profile to drive the wheels to their torque and velocity limits and optimize for minimum-time stabilization, with a feedback controller providing any additional necessary stabilization. Such a feed-forward profile, with a stabilizing controller to handle unmodeled phenomena, should give the theoretical fastest convergence possible with this system. \bibliographystyle{IEEEtran}
{'timestamp': '2020-09-24T02:07:57', 'yymm': '2009', 'arxiv_id': '2009.09370', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09370'}
arxiv
\section{Introduction}\label{introduction}} \IEEEPARstart{I}{n} the last two decades, face recognition for visible (VIS) images has made a great breakthrough using deep convolutional neural networks \cite{wen2016discriminative,deng2019arcface}. Nevertheless, in some practical security applications, a face recognition network often needs to match cross-domain face images rather than merely VIS, raising the problem of Heterogeneous Face Recognition (HFR). For example, the near-infrared (NIR) imaging sensor has been integrated into many mobile devices, because it offers an inexpensive and effective solution to obtain clear NIR images in extreme lightings or even dark environment. At the same time, the enrollments of face templates are usually VIS images, which requires the recognition network to match the heterogeneous NIR-VIS images. Unfortunately, due to the large domain discrepancy, the performance of the recognition network trained on VIS images often degrades dramatically in such a heterogeneous case \cite{DBLP:journals/corr/abs-1708-02412}. Other HFR tasks include Sketch-Photo \cite{bhatt2012memetic}, Profile-Frontal Photo \cite{gross2010multi}, Thermal-VIS \cite{panetta2018comprehensive}, and ID-Camera \cite{huo2017heterogeneous}. In order to bridge the domain discrepancy between the heterogeneous data, extensive research efforts have been undertaken to match cross-domain features \cite{ouyang2016survey}. However, due to the difficulty of data acquisition, it is usually not feasible to collect large-scale heterogeneous databases. Over-fitting often occurs when the recognition network is trained on such insufficient data \cite{DBLP:journals/corr/abs-1708-02412}. \begin{figure*}[t] \centering \includegraphics[width=0.985\textwidth]{./fig/fig2.pdf} \caption{Comparisons between conditional image-to-image generation \cite{Song2018AdversarialDH} (on the left, the top is the input NIR and the bottom is the generated VIS) and our proposed unconditional dual variational generation (on the right, all paired NIR-VIS images are generated from noises). For the conditional generation, given one NIR image, the generator can only synthesize one VIS image with the same attributes (\textit{e.g.} the pose and the expression) except for the spectrum. By contrast, DVG-Face has the ability to generate large-scale new paired heterogeneous images with abundant intra-class diversity from noises. } \label{fig_2} \end{figure*} With the rapid development of deep generative models, ``recognition via generation'' has been a hot research topic in the computer vision community \cite{Huang2017BeyondFR}. Deep generative models are good at learning the mapping among different domains, and are therefore usually used to reduce the domain discrepancy \cite{isola2017image}. For example, \cite{Song2018AdversarialDH} proposes to transfer NIR images to VIS ones via a two-path generative model. \cite{Zhang2018IJCV} introduces a multi-stream feature fusion manner with Generative Adversarial Networks (GANs) \cite{Goodfellow2014GenerativeAN} to synthesize photo-realistic VIS images from polarimetric thermal ones. However, these conditional image-to-image translation based methods face two challenging issues: (1) \textbf{Diversity}. Since these methods adopt a ``one-to-one'' translation manner, the generator can only synthesize one new image of the target domain for each input image of the source domain. Hence, these methods can merely generate a limited number of new data to reduce the domain discrepancy. Meanwhile, as exemplified in the left part of Fig.~\ref{fig_2}, the generated images have the same attributes (\textit{e.g.} the pose and the expression) as the inputs except for the spectrum, which limits the intra-class diversity of the generated images. (2) \textbf{Consistency}. These methods require that the generated images belong to specific classes consistent with the inputs. Nevertheless, it is hard to meet this requirement, because the widely adopted identity preserving loss \cite{Huang2017BeyondFR,duan2019pose} only constrains the feature distance between the generated images and the targets, while ignores both intra-class and inter-class distances. The above two issues make it rather difficult for deep generative models to effectively boost the performance of HFR. In order to tackle the above challenges, we propose an unconditional Dual Variational Generation (DVG-Face) framework that can generate large-scale new diverse paired heterogeneous images. Different from the aforementioned conditional generation in HFR, unconditional generation has the ability to synthesize new data by sampling from noises \cite{Kingma2013AutoEncodingVB,karras2017progressive}. However, the small number of the heterogeneous training data may limit the identity diversity of sampling. In order to break through the limitation, we introduce abundant identity information of large-scale VIS images into the generated images. By contrast, these VIS images are merely leveraged to pre-train the HFR network in previous works \cite{deng2019residual,XWu:2018}, as discussed in Section~\ref{VIS data}. Moreover, DVG-Face focuses on the identity consistency of the generated paired heterogeneous images, rather than whom the generated images belong to. This avoids the consistency problem of the previous conditional generation based methods. Finally, a contrastive learning mechanism is employed to take advantage of these generated unlabeled images to train the HFR network. Specifically, benefiting from the identity consistency property, the generated paired heterogeneous images are regarded as positive pairs. Due to the identity diversity property, the images obtained from different samplings are considered as negative pairs, according to the instance discrimination criterion \cite{wu2018unsupervised,bachman2019learning}. The framework of our DVG-Face is depicted in Fig.~\ref{fig_framework}. We first train the dual variational generator with both paired heterogeneous data and large-scale unpaired VIS data. In the latent space, the joint distribution of paired heterogeneous data is disentangled into identity representations and domain-specific attribute distributions, which is implemented by an angular orthogonal loss. Fig.~\ref{fig_3} presents the disentanglement results. This disentanglement enables the integration of abundant identity information of the unpaired VIS images into the joint distribution. In the pixel space, we impose a pairwise identity preserving loss on the generated paired heterogeneous images to guarantee their identity consistency. After the training of the dual variational generator, we can obtain large-scale new diverse paired heterogeneous images with the same identity by sampling from noises. These generated images are organized as positive and negative pairs, and then are fed into the HFR network. A contrastive learning mechanism further facilitates the HFR network to learn both domain-invariant and discriminative embedding features. The main contributions are summarized as follows: \begin{itemize} \item We provide a new insight into HFR, considering it as a dual generation problem. This results in a novel unconditional Dual Variational Generation (DVG-Face) framework, which samples large-scale new diverse paired heterogeneous data from noises to boost the performance of HFR. \item Abundant identity information is integrated into the joint distribution to enrich the identity diversity of the generated data. Meanwhile, a pairwise identity preserving loss is imposed on the generated paired images to ensure their identity consistency. These two properties allow us to make better use of the generated unlabeled data to train the HFR network. \item By regarding the generated paired images as positive pairs and the images obtained from different samplings as negative pairs, the HFR network is optimized via contrastive learning to learn both domain-invariant and discriminative embedding features. \item Extensive experiments on seven HFR databases demonstrate that our method significantly outperforms state-of-the-art methods. In particular, on the challenging low-shot Oulu-CASIA NIR-VIS database, we improve the best TPR@FPR=10$^{-5}$ by 29.2$\%$. Besides, compared with the baseline trained on the Tufts Face database, VR@FAR=$1\%$ is increased by 26.1$\%$ after adding the generated data. \end{itemize} This paper is an extension of our previous conference version \cite{fu2019dual}, and there are three major improvements over the preliminary one: (1) \textbf{The generated images have richer identity diversity}. For the preliminary version, the generator can only be trained with the small-scale paired heterogeneous data, thereby limiting the identity diversity of the generated images. In the current version, the architecture and the training manner of the generator are redesigned, allowing it to be trained with both paired heterogeneous data and large-scale unpaired VIS data. The introduction of the latter greatly enriches the identity diversity of the generated images. (2) \textbf{The generated images are leveraged more efficiently}. The preliminary version trains the HFR network with the generated paired data via a pairwise distance loss, resorting to the identity consistency property. On this basis, benefiting from the aforementioned identity diversity property, the current version further regards the images obtained from different samplings as negative pairs, formulating a contrastive learning mechanism. Hence, the preliminary version can only leverage the generated images to reduce the domain discrepancy, while the current version utilizes the generated images to learn both domain-invariant and discriminative embedding features. (3) \textbf{More insightful analyses and more experiments are added}. Apart from NIR-VIS and Sketch-Photo, we further explore Profile-Frontal Photo, Thermal-VIS, and ID-Camera HFR tasks. Moreover, the current version gains significant improvements over the preliminary one on all the databases. \section{Related Work} \subsection{Heterogeneous Face Recognition} HFR has attracted increasing attention of researchers for its crucial practical value. In this subsection, we review the development of HFR from the perspectives of feature-level learning and image-level learning. \emph{Feature-level learning} based methods aim at seeking discriminative feature representations. Some methods try to capture a common latent space between heterogeneous data for relevance measurement. \cite{klare2012heterogeneous} employs a prototype random subspace to improve the HFR performance. \cite{shao2014generalized} introduces a generalized transfer subspace with a low-rank constraint. There are also some methods that focus on learning domain-invariant features. Traditional works mainly use handcrafted features. For example, \cite{Klare2011MatchingFS} extracts Histograms of Oriented Gradients (HOG) features with sparse representations to obtain cross-domain semantics. \cite{gong2017heterogeneous} proposes a common encoding model to obtain discriminant information for HFR. Recently, the thriving deep learning has powerful feature extraction capability, and thus has been widely applied in HFR. \cite{saxena2016heterogeneous} explores multiple different metric learning methods to reduce the domain gap. \cite{deng2019residual} designs a residual compensation framework that learns different modalities in separate branches. However, due to the lack of large-scale heterogeneous databases, the deep learning based methods often tend to over-fit \cite{XWu:2019}. In order to alleviate the over-fitting problem, our method generates large-scale new diverse paired data as an augmentation, thus significantly boosting the recognition performance. \emph{Image-level learning} based methods mainly operate on the pixel space to improve the performance of HFR. \cite{Tang2003FaceSS,peng2015multiple,peng2015superpixel} focus on Sketch-Photo synthesis to reduce the domain gap. \cite{huang2013coupled} improves the recognition performance by using coupled dictionary learning for cross-domain image synthesis. \cite{hu2017frankenstein} proposes to composite facial parts, \textit{e.g.} eyes, to augment the small database to a larger one. \cite{Lezama2017NotAO} uses a CNN to perform a cross-spectral hallucination, reducing the domain gap in pixel space. Recently, the rapidly developed GANs \cite{Goodfellow2014GenerativeAN} provide a solution to the problem of HFR. \cite{cao2018data} utilizes image-to-image translation methods to synthesize new data, and then incorporates the synthesized data into the training set to augment the intra-class scale and reduce inter-class diversity. \cite{zhang2019cascaded} proposes a cascaded face sketch synthesis model to deal with the illumination problem. As discussed in Section 1, the image-to-image translation based methods are limited in diversity and consistency. In order to break through the two limitations, DVG-Face employs a novel unconditional generation manner to generate large-scale new diverse paired images from noises, and a new pairwise identity preserving loss to ensure the identity consistency of the generated paired heterogeneous images. \begin{figure*}[t] \centering \includegraphics[width=0.985\textwidth]{./fig/framework.pdf} \caption{Illustration of our DVG-Face. (a) and (b): The training of the dual variational generator involves both paired heterogeneous data and unpaired VIS data (MS-Celeb-1M~\cite{guo2016ms}). The former is used to disentangle identity and attribute representations. The latter is introduced to enrich the identity diversity of the generated images. The identity representations of the latter can be obtained from either the identity sampler $F_s$ or the pre-trained face recognition network $F$, as discussed in Section~\ref{identity sampling}. In addition, a pairwise identity preserving loss is imposed on the generated paired images to guarantee their identity consistency. (c): After training the generator, we leverage it to synthesize a great deal of new paired heterogeneous images. Benefiting from the identity consistency property, the generated paired images are regarded as positive pairs. Due to the identity diversity property, the images obtained from different samplings are considered as negative pairs. A contrastive learning mechanism is imposed on the HFR network, yielding both domain-invariant and discriminative embedding features. } \label{fig_framework} \end{figure*} \subsection{Generative Model} As a hot topic in machine learning and computer vision communities, generative model has made gratifying progress in recent years\cite{Goodfellow2014GenerativeAN,Kingma2013AutoEncodingVB,van2016conditional,kingma2018glow}. Usually, it can be divided into two types: unconditional generative model and conditional generative model. \emph{Unconditional generative model} synthesizes data from noises. The most prominent models include Variational AutoEncoders (VAEs) \cite{Kingma2013AutoEncodingVB} and Generative Adversarial Networks (GANs) \cite{Goodfellow2014GenerativeAN}. VAEs adopt variational inference to lean data distribution, and consist of an encoder network $q_{\phi}(z|x)$ and a decoder network $p_{\theta}(x|z)$. The Evidence Lower Bound Objective (ELBO) is derived for an approximate optimization: \begin{equation} \label{eq:vae} \resizebox{0.49\textwidth}{!}{ $\log p_{\theta}(x) \geq \mathbb{E}_{q_{\phi}(z|x)}\log p_{\theta}(x|z) - D_{\text{KL}}(q_{\phi}(z|x) || p(z))$, } \end{equation} where the first term is a reconstruction loss and the second term is a Kullback-Leibler divergence. $p(z)$ is usually set to a standard Gaussian distribution. Recently, some variants are proposed to improve synthesis quality. IntroVAE \cite{Huang2018IntroVAEIV} generates high-resolution images via an introspective manner. VQ-VAE \cite{van2017neural} obtains high-quality images via learning discrete representations with an autoregressive prior. In a different way, GANs leverage an adversarial mechanism to learn data distribution implicitly. Generally, GANs consist of two networks: a generator $G$ and a discriminator $D$. $G$ generates data from a prior $p(z)$ to confuse $D$, while $D$ is trained to distinguish the generated data from the real data. Such an adversarial mechanism is formulated as: \begin{equation} \label{eq:gan} \resizebox{0.49\textwidth}{!}{ $\min \limits_{G} \max \limits_{D} \mathbb{E}_{x \sim p_{data}(x)} \left [ \log D(x) \right ] + \mathbb{E}_{z \sim p_{z}(z)} \left [ \log(1 - D(G(z))) \right ]$. } \end{equation} GANs are good at generating high-quality images. PGGAN \cite{karras2017progressive} significantly improves the resolution of the synthesized images to 1024$\times$1024. SinGAN \cite{shaham2019singan} generates realistic images merely using one single training image. CoGAN \cite{liu2016coupled} concerns a problem similar to the one tackled by our method. A weight-sharing manner is adopted to generate paired data from two domains. However, due to the lack of explicit identity constrains, it is rather challenging for such a weight-sharing manner of CoGAN to generate paired data with the same identity, as discussed in Section~\ref{identity consistency}. \emph{Conditional generative model} synthesizes data according to the given conditions. pix2pix \cite{isola2017image} realizes photo-realistic paired image-to-image translation with a conditional generative adversarial loss. CycleGAN \cite{zhu2017unpaired} employs a cycle-consistent network to tackle the unpaired image translation problem. GAN Compression \cite{li2020gan} reduces the model size and the inference time of Conditional GANs by the ways of Knowledge Distillation (KD) and Neural Architecture Search (NAS). MUNIT \cite{huang2018multimodal} decomposes image representations into a content code and a style code, realizing exemplar based image synthesis. BigGAN \cite{brock2018large} is the pioneer work for high-resolution natural image synthesis. StarGAN \cite{choi2019stargan} is designed for unpaired multi-domain image-to-image translation. StyleGAN \cite{karras2019style} proposes a style-based generator that can separate facial attributes automatically. SPADE \cite{park2019semantic} synthesizes high-quality images with the guidance of semantic layouts. InterFaceGAN \cite{shen2019interpreting} edits face images according to the interpretable latent semantics learned by GANs. In-Domain GAN inversion \cite{zhu2020domain} proposes to invert a pre-trained GAN model for real image editing, resorting to an image reconstruction in the pixel space and a semantic regularization in the latent space. \begin{table}[t] \centering \caption{Meaning of the symbols used in our method.} \label{table-symbol} \begin{spacing}{0.9} \resizebox{0.45\textwidth}{!}{ \begin{tabular}{c|l} Symbol & Meaning \\ \myhlineII $E_N$/$E_V$ & Attribute encoder for NIR/VIS \\ $G$ & Decoder network \\ $F$ & Pre-trained face recognition network \\ $F_s$ & Pre-trained identity sampler \\ \hline $I_N$/$I_V$ & NIR/VIS image \\ $z_N$/$z_V$ & Attribute distribution of $I_N$/$I_V$ \\ $f$ & Identity representation of $I_V$ \\ $\hat{I}_N$/$\hat{I}_V$ & Reconstructed NIR/VIS image \\ $\hat{f}_N$/$\hat{f}_V$ & Identity representation of $\hat{I}_N$/$\hat{I}_V$ \\ $\tilde{f}$ & Identity representation sampled from $F_s$ \\ $\tilde{I}_N$/$\tilde{I}_V$ & Generated NIR/VIS image with $\tilde{f}$ \\ $\tilde{f}_N$/$\tilde{f}_V$ & Identity representation of $\tilde{I}_N$/$\tilde{I}_V$ \\ \end{tabular}} \end{spacing} \end{table} \section{Method} \label{method} The goal of our method is to generate a large number of paired heterogeneous data from noises to boost the performance of HFR. Correspondingly, our method is divided into two parts to tackle the problems of (1) \emph{how to generate diverse paired heterogeneous data} and (2) \emph{how to effectively take advantage of these generated data}. These two parts are introduced in the following two subsections, respectively. We take NIR-VIS as an example for illustration. Other heterogeneous face images are in the same way. \subsection{Dual Generation} \label{dual generation} As stated in Section~\ref{introduction}, we expect the generated paired images to have two properties: identity diversity and identity consistency. On the one hand, in order to promote the identity diversity, we adopt an unconditional generation manner because it has the ability to generate new samples from noises \cite{Kingma2013AutoEncodingVB,karras2017progressive}. Meanwhile, considering that the small number of the paired heterogeneous training data may limit the identity diversity of the sampling, we introduce abundant identity information of large-scale VIS data into the generated images. On the other hand, in order to constrain the identity consistency property, we impose a pairwise identity preserving loss on the generated paired images, minimizing their feature distances in the embedding space. The above ideas are implemented by a dual variational generator and its framework is shown in Figs.~\ref{fig_framework} (a) and (b). The generator contains two domain-specific attribute encoders $E_N$ and $E_V$, a decoder $G$, a pre-trained face recognition network $F$, and an identity sampler $F_s$. Among them, $E_N$ and $E_V$ are utilized to learn domain-specific attribute distributions of NIR and VIS data, respectively. $F$ is used to extract identity representations. $F_s$ can flexibly sample abundant identity representations from noises. The joint distribution of the paired heterogeneous data consists of the identity representations and the attribute distributions. $G$ maps the joint distribution to the pixel space. The parameters of $F$ and $F_s$ are fixed, while those of the other networks are updated during the training with both paired heterogeneous data and unpaired VIS data. Table~\ref{table-symbol} summarizes the meaning of the symbols used in our method. \subsubsection{Training with Paired Heterogeneous Data} Given a pair of NIR-VIS data $I_N$ and $I_V$ with the same identity, the dual variational generator learns disentangled joint distribution in the latent space. Specifically, a face recognition network pre-trained on MS-Celeb-1M \cite{guo2016ms} is adopted as the feature extractor $F$. The compact embedding features extracted by $F$ are thought to be only identity related \cite{bao2018towards}. Meanwhile, considering that $F$ is better at extracting the features of VIS images than those of NIR images, we use $f = F(I_V)$ as the identity representation of both $I_N$ and $I_V$. Then, the encoders $E_N$ and $E_V$ are leveraged to learn domain-specific attribute distributions $z_N = q_{\phi_N}(z_N|I_N)$ and $z_V = q_{\phi_V}(z_V|I_V)$, respectively. $\phi_N$ and $\phi_V$ are the parameters of the encoders. According to the reparameterization trick \cite{Kingma2013AutoEncodingVB}, $z_N = u_N + \sigma_N \odot \epsilon$ and $z_V = u_V + \sigma_V \odot \epsilon$, where $u$ denotes mean and $\sigma$ denotes standard deviation. $\odot$ denotes Hadamard product and $\epsilon$ is a noise sampled from a multi-variate standard Gaussian distribution. Subsequently, in order to ensure that $z_N$ and $z_V$ are merely attribute related, we impose an angular orthogonal loss between the attribute and the identity representations. Finally, the disentangled identity and attribute representations constitute the joint distribution of paired NIR-VIS data, and then are fed to the decoder $G$ to reconstruct the inputs $I_N$ and $I_V$. A total of four loss functions are involved in the above process, including an angular orthogonal loss, a distribution learning loss, a pairwise identity preserving loss, and an adversarial loss. These losses are introduced below. \textbf{Angular Orthogonal Loss.} The angular orthogonal loss is imposed between $z_N$ and $f$ and between $z_V$ and $f$. For the $L_2$ normalized $z_V$ and $f$, their cosine similarity is formulated as: \begin{equation}\label{cos} \text{cos}(z_V, f) = \langle z_V, f \rangle, \end{equation} where $\langle \cdot, \cdot \rangle$ denotes inner product. When the two representations are orthogonal, Eq.~(\ref{cos}) is equal to zero. Minimizing the absolute value of Eq.~(\ref{cos}) will force $z_V$ and $f$ to be orthogonal, and thus they are disentangled. Ultimately, the angular orthogonal loss that considers both normalized $z_N$ and $z_V$ is defined as: \begin{equation} \label{orthogonal} \mathcal{L}_{\text{ort}} = \left | \langle z_V, f \rangle \right | + \left | \langle z_N, f \rangle \right |. \end{equation} In the following parts, $z_N$, $z_V$, and the output of $F(\cdot)$, \textit{e.g.} $f = F(I_V)$, all denote the normalized ones. \textbf{Distribution Learning Loss.} Inspired by VAEs \cite{Kingma2013AutoEncodingVB}, the posterior distributions $q_{\phi_N}(z_N|I_N)$ and $q_{\phi_V}(z_V|I_V)$ are constrained by a Kullback-Leibler divergence: \begin{equation} \label{kl} \mathcal{L}_{\text{kl}} = D_{\text{KL}}(q_{\phi_N}(z_N|x_N) || p(z_N)) + D_{\text{KL}}(q_{\phi_V}(z_V|x_V) || p(z_V)), \end{equation} where both the priors $p(z_N)$ and $p(z_V)$ are multi-variate standard Gaussian distributions. After obtaining the identity representation $f$ as well as the domain-specific attribute representations $z_N$ and $z_V$, the decoder network is required to reconstruct the inputs $I_N$ and $I_V$: \begin{equation} \mathcal{L}_{\text{rec}} = - \mathbb{E}_{q_{\phi_N}(z_N|I_N)\cup q_{\phi_V}(z_V|I_V)} \log p_{\theta}(I_N, I_V|f, z_N, z_V). \end{equation} In practice, $\mathcal{L}_{\text{rec}}$ is implemented as: \begin{equation} \label{rec} \mathcal{L}_{\text{rec}} = || \hat{I}_N - I_N ||_1 + || \hat{I}_V - I_V ||_1, \end{equation} where $\hat{I}_N = G(f, z_N)$ and $\hat{I}_V = G(f, z_V)$. In general, according to \cite{Kingma2013AutoEncodingVB}, the distribution learning loss is a combination of $\mathcal{L}_{\text{kl}}$ and $\mathcal{L}_{\text{rec}}$: \begin{equation} \label{dis} \mathcal{L}_{\text{dis}} = \mathcal{L}_{\text{kl}} + \mathcal{L}_{\text{rec}}. \end{equation} \textbf{Pairwise Identity Preserving Loss.} In order to preserve the identity of the generated data, previous conditional generation based methods usually adopt an identity preserving loss \cite{Huang2017BeyondFR,hu2018pose,duan2019pose}. A pre-trained face recognition network is used to extract the embedding features of the generated data and those of the real target data respectively, and then the two features are forced to be as close as possible. However, since there are neither intra-class nor inter-class constraints, it is challenging to guarantee that the generated images belong to specific classes consistent with the targets. As discussed in Section~\ref{introduction}, different from the previous methods, we focus on the identity consistency of the generated paired images, rather than whom the generated images belong to. Therefore, we propose a pairwise identity preserving loss that constrains the feature distance between $\hat{f}_N = F(\hat{I}_N)$ and $\hat{f}_V = F(\hat{I}_V)$: \begin{equation} \label{pairwise} \mathcal{L}_{\text{ip-pair}} = 1 - \langle \hat{f}_N, \hat{f}_V \rangle. \end{equation} Minimizing Eq.~(\ref{pairwise}) will increase the cosine similarity between $\hat{f}_N$ and $\hat{f}_V$. Besides, in order to stabilize the training process, we also constrain the feature distance between $\hat{f}_N$ and $f$ and that between $\hat{f}_V$ and $f$: \begin{equation} \label{ip-rec} \mathcal{L}_{\text{ip-rec}} = (1 - \langle \hat{f}_N, f \rangle) + (1 - \langle \hat{f}_V, f \rangle). \end{equation} The pairwise identity preserving loss that considers both $\mathcal{L}_{\text{ip-pair}}$ and $\mathcal{L}_{\text{ip-rec}}$ is formulated as: \begin{equation} \label{ip} \begin{split} \mathcal{L}_{\text{ip}} = \mathcal{L}_{\text{ip-pair}} + \mathcal{L}_{\text{ip-rec}}. \end{split} \end{equation} \textbf{Adversarial Loss.} Same as \cite{shu2018deforming}, an extra adversarial loss $\mathcal{L}_{\text{adv}}$ \cite{Goodfellow2014GenerativeAN} is also introduced to increase the sharpness of the generated data, where the dual variational generator and a discriminator are optimized alternately. We first fix the discriminator and train the generator with the adversarial loss to confuse the discriminator: \begin{equation} \label{adv-g} \begin{split} \mathcal{L}_{\text{adv-g}} = \log(1 - D(\hat{I}_N)) + \log(1 - D(\hat{I}_V)), \end{split} \end{equation} where $D$ denotes the discriminator. Then, we fix the generator and train the discriminator to distinguish the generated data from the real data: \begin{equation} \label{adv-d} \begin{split} \mathcal{L}_{\text{adv-d}} = & - \log(D(I_N)) - \log(1 - D(\hat{I}_N)) \\ & - \log(D(I_V)) - \log(1 - D(\hat{I}_V)). \end{split} \end{equation} \textbf{Overall Loss.} The overall loss for the training with paired heterogeneous data is a weighted sum of the above distribution learning loss $\mathcal{L}_{\text{dis}}$, the angular orthogonal loss $\mathcal{L}_{\text{ort}}$, the pairwise identity preserving loss $\mathcal{L}_{\text{ip}}$, and the adversarial loss $\mathcal{L}_{\text{adv}}$: \begin{equation} \label{pair} \mathcal{L}_{\text{pair}} = \mathcal{L}_{\text{dis}} + \lambda_1 \mathcal{L}_{\text{ort}} + \lambda_2 \mathcal{L}_{\text{ip}} + \lambda_3 \mathcal{L}_{\text{adv}}, \end{equation} where $\lambda_1$, $\lambda_2$, and $\lambda_3$ are trade-off parameters. Among them, $\lambda_3$ is fixed to 0.1 according to \cite{shu2018deforming}. \subsubsection{Training with Unpaired VIS Data} \label{training unpair} The number of the paired heterogeneous training data is limited, which may affect the identity diversity of the generated images. Therefore, we introduce abundant identity information of large-scale VIS data into the generated images. For the acquisition of the identity information, a straightforward approach is to use a pre-trained face recognition network to extract identities from the large-scale VIS data, as shown in the lower right corner of Fig.~\ref{fig_framework} (b). However, in this situation, if we desire to generate large-scale new paired data at the testing phase, we must have the same number of VIS data with different identities. This will make our framework a conditional generative model, leading to the diversity problem as mentioned in Section~\ref{introduction}. In order to overcome this obstacle, inspired by \cite{deng2020disentangled}, we introduce an identity sampler to replace the recognition network. Specifically, we first adopt the recognition network to extract the embedding features of MS-Celeb-1M \cite{guo2016ms}, and then leverage these embedding features to train a VAE model \cite{Kingma2013AutoEncodingVB}. After the training, the decoder of VAE is used as the identity sampler, which can map the points in a standard Gaussian noise to identity representations, as shown in Fig.~\ref{fig_framework} (b). Equipped with the identity sampler, our framework becomes an unconditional generative model. The required identity representations can be flexibly sampled from noises. A detailed discussion about the face recognition network and the identity sampler is provided in Section~\ref{identity sampling}. Since these sampled identity representations do not have corresponding ground truth paired heterogeneous images, we propose to train the generator in an unpaired way. To begin with, we sample an identity representation $\tilde{f}$ via the identity sampler $F_s$. Then, $\tilde{f}$ as well as the attribute representations $z_N$ and $z_V$ in Eq.~(\ref{orthogonal}) are fed into the decoder $G$. Finally, a pair of new heterogeneous images, \textit{i.e.} $\tilde{I}_N = G(\tilde{f}, z_N)$ and $\tilde{I}_V = G(\tilde{f}, z_V)$, that does not belong to the heterogeneous database is generated. We constrain $\tilde{I}_N$ and $\tilde{I}_V$ from the aspects of appearance and semantic. For appearance, we introduce a small-weight reconstruction loss \cite{bao2018towards} to force the appearance of the generated images to be consistent with that of the inputs: \begin{equation} \label{rec-u} \mathcal{L}_{\text{rec}}^\text{u} = \eta \left ( || \tilde{I}_N - I_N ||_1 + || \tilde{I}_V - I_V ||_1 \right ), \end{equation} where $\eta$ is set to $0.1$ according to \cite{bao2018towards}. For semantic, same as the aforementioned pairwise identity preserving manner in Eq.~(\ref{ip}), we constrain $\tilde{f}_N = F(\tilde{I}_N)$ and $\tilde{f}_V = F(\tilde{I}_V)$ via: \begin{equation} \label{ip-u} \begin{split} \mathcal{L}_{\text{ip}}^\text{u} = (1 - \langle \tilde{f}_N, \tilde{f}_V \rangle) + (1 - \langle \tilde{f}_N, \tilde{f} \rangle) + (1 - \langle \tilde{f}_V, \tilde{f} \rangle). \end{split} \end{equation} Consequently, the overall loss for the training with unpaired VIS data is a weighted sum of $\mathcal{L}_{\text{rec}}^\text{u}$, $\mathcal{L}_{\text{ip}}^\text{u}$, and an extra adversarial loss $\mathcal{L}_{\text{adv}}^\text{u}$ (replacing $\hat{I}_N$/$\hat{I}_V$ in Eq.~(\ref{adv-g}) and Eq.~(\ref{adv-d}) with $\tilde{I}_N$/$\tilde{I}_V$): \begin{equation} \label{unpair} \mathcal{L}_{\text{unpair}} = \mathcal{L}_{\text{rec}}^\text{u} + \lambda_2 \mathcal{L}_{\text{ip}}^\text{u} + \lambda_3 \mathcal{L}_{\text{adv}}^\text{u}, \end{equation} where $\lambda_2$ and $\lambda_3$ are the same as those in Eq.~(\ref{pair}). Algorithm~\ref{alg-dual} shows the training process with both paired heterogeneous data and unpaired VIS data. \begin{algorithm}[t] \caption{Training process of the generator} \label{alg-dual} \begin{algorithmic}[1] \Require Heterogeneous training set $I_i, i \in \{N, V\}$; A pre-trained face recognition network $F$; A pre-trained identity sampler $F_s$; \Ensure The parameters of the dual variational generator, including $E_N$, $E_V$, and $G$; \For{$t = 1,...,T$} \State \emph{\# Training with paired heterogeneous data.} \State Sample a batch of paired training data $\{I_N, I_V\}$; \State Use $F$ to extract the identity feature $f = F(I_V)$; \State Feed $I_N$, $I_V$, and $f$ to the generator; \State Calculate the loss in Eq.~(\ref{pair}); \State \emph{\# Training with unpaired VIS data.} \State Sample a random identity feature $\tilde{f}$ via $F_s$; \State Feed $I_N$, $I_V$, and $\tilde{f}$ to the generator; \State Calculate the loss in Eq.~(\ref{unpair}); \EndFor \\ \Return $E_N$, $E_V$, and $G$. \end{algorithmic} \end{algorithm} \subsection{Heterogeneous Face Recognition} After the training of the dual variational generator, we first employ it to generate large-scale paired heterogeneous images, and then leverage these images to facilitate the training of the HFR network. For HFR, we use a face recognition network pre-trained on MS-Celeb-1M as the backbone, and train it with both the limited number of real heterogeneous data $I_i~(i \in \{N, V\})$ and the large-scale generated heterogeneous data $\tilde{I}_i~(i \in \{N, V\})$. For the real heterogeneous data, we utilize a softmax loss to optimize the HFR network: \begin{equation} \label{softmax} \mathcal{L}_{\text{cls}} = \sum_{i \in \{N, V\}} \text{softmax}(f_i, y), \end{equation} where $y$ is the class label of the input $I_i$ and $f_i = F(I_i)$. $F$ denotes the pre-trained face recognition network, same as the feature extractor in Section~\ref{dual generation}. The difference is that the parameters of the former are updated while those of the latter are fixed. For the generated data, since there is no specific class label, the above softmax loss is inapplicable. However, benefiting from the properties of identity consistency and identity diversity, we propose to take advantage of these generated data via a contrastive learning mechanism \cite{hadsell2006dimensionality}. To be specific, as depicted in Fig.~\ref{fig_framework} (c), we first randomly sample two paired heterogeneous images ($\tilde{I}_N^1$, $\tilde{I}_V^1$) and ($\tilde{I}_N^2$, $\tilde{I}_V^2$) from the generated database. Based on the identity consistency property, the paired heterogeneous images ($\tilde{I}_N^1$, $\tilde{I}_V^1$) and ($\tilde{I}_N^2$, $\tilde{I}_V^2$) are set as positive pairs. At the same time, thanks to the identity diversity property, the images obtained from different samplings, \textit{i.e.} ($\tilde{I}_N^1$, $\tilde{I}_V^2$) and ($\tilde{I}_N^2$, $\tilde{I}_V^1$), are regarded as negative pairs. Note that we do not set ($\tilde{I}_N^1$, $\tilde{I}_N^2$) and ($\tilde{I}_V^1$, $\tilde{I}_V^2$) as negative pairs because HFR is dedicated to cross-domain matching. Formally, the contrastive loss for the generated data is: \begin{equation} \label{contrastive} \begin{split} \mathcal{L}_{\text{cont}} = & \sum_{j \neq k}~(1 - \langle \tilde{f}_N^j, \tilde{f}_V^j \rangle) + (1 - \langle \tilde{f}_N^k, \tilde{f}_V^k \rangle) \\ & + \text{max}(0, \langle \tilde{f}_N^j, \tilde{f}_V^k \rangle - m) + \text{max}(0, \langle \tilde{f}_N^k, \tilde{f}_V^j \rangle - m), \end{split} \end{equation} where $\tilde{f}_N^j = F(\tilde{I}_N^j)$, $\tilde{f}_V^j = F(\tilde{I}_V^j)$, and $m$ is a margin value. By minimizing Eq.~(\ref{contrastive}), the first two terms assist in reducing domain discrepancy, while the last two terms facilitate the learning of discriminative embedding features. Considering both the softmax loss $\mathcal{L}_{\text{cls}}$ and the contrastive loss $\mathcal{L}_{\text{cont}}$, the overall loss for the HFR network is given by: \begin{equation} \label{hfr} \mathcal{L}_{\text{hfr}} = \mathcal{L}_{\text{cls}} + \alpha \mathcal{L}_{\text{cont}}, \end{equation} where $\alpha$ is a trade-off parameter. \begin{figure}[t] \centering \includegraphics[width=0.46\textwidth]{./fig/fig3.pdf} \caption{Disentanglement experiments on CASIA NIR-VIS 2.0. The face images in the first row and the first column are real images, while the remaining face images are generated. After the disentanglement, our method can transfer the image attributes or the sampled attributes (the last two columns) to any identity, including the identities of the real face images and the identities sampled through the identity sampler (the last two rows). } \label{fig_3} \end{figure} \section{Experiments} In this section, we report insightful analyses of our proposed method and its evaluations against state-of-the-art methods on seven databases belonging to five HFR tasks, including NIR-VIS, Sketch-Photo, Profile-Frontal Photo, Thermal-VIS, and ID-Camera. \textbf{Note that the experiments on the Oulu-CASIA NIR-VIS \cite{JChen:2009}, the Multi-PIE \cite{gross2010multi}, and the NJU-ID \cite{huo2017heterogeneous} databases are presented in Sections 1.2.1, 1.2.2, and 1.2.3 of the supplementary material, respectively.} In the following four subsections, we describe (1) an introduction to the databases and protocols, (2) detailed experimental settings, (3) thorough qualitative and quantitative experimental analyses, and (4) comprehensive comparisons with state-of-the-art methods, respectively. \subsection{Databases and Protocols} \emph{CASIA NIR-VIS 2.0 Face Database} \cite{SLi:2013} contains a total of 725 identities, and each identity has 1-22 VIS and 5-50 NIR images. The protocol consists of ten-fold experiments, each including about 6,100 NIR images and 2,500 VIS images from 360 identities for training. Meanwhile, for each fold, 358 VIS images from 358 identities (each identity has one VIS image) constitute the gallery set. Over 6,000 NIR images from the same 358 identities compose the probe set. There is no identity overlap between the training and the testing. We conduct experiments on each fold separately, and then report the mean and standard deviation of the results. The Rank-1 accuracy, Verification Rate (VR) @ False Accept Rate (FAR)=0.1$\%$, and VR@FAR=0.01$\%$ are reported. \emph{BUAA-VisNir Face Database} \cite{DHuang:2012} is a popular heterogeneous face database that is usually utilized to evaluate domain adaption. It consists of 150 identities, and each identity includes multiple NIR and VIS images. The training set has about 1,200 images from 50 identities, and the testing set contains about 1,300 images from the remaining 100 identities. For testing, only one VIS image per identity is selected as the gallery set and the NIR images constitute the probe set. We report the Rank-1 accuracy, VR@FAR=1\%, and VR@FAR=0.1$\%$ for comparisons. \emph{IIIT-D Sketch Viewed Database} \cite{bhatt2012memetic} is developed for Sketch-Photo recognition and contains 238 image pairs. Among them, 67 pairs are from the FG-NET aging database, 99 pairs are from the Labeled Faces in Wild (LFW) database, and 72 pairs are from the IIIT-D student $\&$ staff database. Since the IIIT-D Sketch Viewed database only has a small number of images, following \cite{XWu:2018}, we use it as the testing set and adopt CUHK Face Sketch FERET (CUFSF) \cite{ZhangWT11} as the training set. CUFSF is also a Sketch-Photo face database that contains 1,194 image pairs. The Rank-1 accuracy is reported. \emph{Tufts Face Database} \cite{panetta2018comprehensive} is collected for the study of imaging systems and provides Thermal-VIS face images. There are a total of 113 identities with 74 females and 39 males from more than 15 countries. Each identity has multiple cross-domain face images with different poses. We randomly select 50 identities as the training set, including 1,490 VIS images and 450 thermal images. The remaining 63 identities are used as the testing set with 1,916 VIS images and 530 thermal images. We report the Rank-1 accuracy, VR@FAR=1$\%$, and VR@FAR=0.1$\%$. The testing process for the HFR network is as follows: Taking the Tufts Face database as an example, the 530 thermal images and the 1,916 VIS images constitute the probe set and the gallery set, respectively. During the testing phase, we first employ the trained HFR network to extract the embedding features of the images in both the probe and the gallery sets. Then, each thermal feature is matched against each VIS feature via calculating the cosine similarity between them, yielding a similarity matrix of size 530$\times$1916. Finally, we calculate the Rank-1 accuracy and the verification rate according to the similarity matrix. \begin{table}[t] \centering \caption{Network architectures of the encoder~$E_N / E_V$ and the decoder~$G$. K/S/P denotes kernel size/stride/padding.} \label{table-arc} \begin{spacing}{1.2} \subfloat[][Encoder architecture.]{ \label{table-arc-1} \resizebox{0.23\textwidth}{!}{ \begin{tabular}{|ccc|} \hline LAYER & K/S/P & OUTPUT \\ \hline Conv1 & 5/1/2 & ~~32 ~$\times$ 128$^2$ \\ Conv2 & 3/2/1 & ~64 ~$\times$ 64$^2$ \\ Conv3 & 3/2/1 & ~128 $\times$ 32$^2$ \\ Conv4 & 3/2/1 & ~256 $\times$ 16$^2$ \\ Conv5 & 3/2/1 & 256 $\times$ 8$^2$ \\ Conv6 & 3/2/1 & 256 $\times$ 4$^2$ \\ \hline FC1 & - & 512 \\ \hline \end{tabular}} } \subfloat[][Decoder architecture.]{ \label{table-arc-2} \resizebox{0.24\textwidth}{!}{ \begin{tabular}{|ccl|} \hline LAYER & K/S/P & OUTPUT \\ \hline FC2 & - & ~~~~2048 \\ Deconv1 & 2/2/0 & ~128 $\times$ 8$^2$ \\ Deconv2 & 2/2/0 & ~128 $\times$ 16$^2$ \\ Deconv3 & 2/2/0 & ~~64 ~$\times$ 32$^2$ \\ Deconv4 & 2/2/0 & ~~64 ~$\times$ 64$^2$ \\ Deconv5 & 2/2/0 & ~~32 ~$\times$ 128$^2$ \\ \hline Out & 1/1/0 & ~~~3 ~~$\times$ 128$^2$ \\ \hline \end{tabular}} } \end{spacing} \end{table} \subsection{Experimental Settings} For dual generation, we utilize LightCNN \cite{Wu2018ALC} pre-trained on MS-Celeb-1M \cite{guo2016ms} as the feature extractor $F$. The network architectures of the encoder $E_V / E_N$ and the decoder $G$ are reported in Table~\ref{table-arc}. `FC' denotes a fully connected layer. `Conv' contains a convolutional layer, an instance normalization (IN) layer, and a ReLU activation layer. Compared with `Conv', `DeConv' replaces the convolutional layer with a transposed convolutional layer and adds a resblock block \cite{he2016deep} after ReLU. In addition, inspired by \cite{karras2019style,choi2019stargan}, we introduce Adaptive Instance Normalization (AdaIN) \cite{huang2017arbitrary} to facilitate the learning of attributes. For NIR and VIS, the affine parameters of AdaIN are learned from the attribute representations $z_N$ and $z_V$ via two extra multilayer perceptrons \cite{huang2018multimodal}, respectively. Following \cite{karras2019style}, AdaIN is only applied on the low-level layer to avoid destroying the disentanglement of the attribute and the identity. As a result, IN in 'DeConv5' is replaced by AdaIN. Furthermore, for NIR and VIS, the weight parameters of the decoder are shared except for these of `Out', which is a single convolutional layer. All of the networks are trained via an Adam optimizer with a fixed learning rate of 2e-4. The parameters $\lambda_1$ and $\lambda_2$ in Eq.~(\ref{pair}) are set to 50 and 0.5, respectively. We determine the values of the two parameters by balancing the magnitude of the corresponding losses $\mathcal{L}_{\text{ort}}$ and $\mathcal{L}_{\text{ip}}$. For HFR, we adopt the pre-trained LightCNN as the backbone. Face images are first aligned to a resolution of 144$\times$144, and then are randomly cropped to a resolution of 128$\times$128 as inputs. One batch consists of 64 real heterogeneous images that are randomly sampled from the real training set, and 64 generated paired heterogeneous images that are randomly sampled from the generated dataset. We adopt Stochastic Gradient Descent (SGD) as the optimizer, where the learning rate is set to 1e-3 initially and is reduced to 5e-4 gradually. The momentum is set to 0.9 and the weight decay is set to 2e-4. The trade-off parameter $\alpha$ and the margin $m$ in Eq.~(\ref{hfr}) are set to 1e-3 and 0.5, respectively. \begin{table}[t] \centering \caption{Experimental analyses on Tufts Face. MS (Mean Similarity, higher is better) denotes the mean cosine similarity between the generated paired images. MIS (Mean Instance Similarity, lower is better) presents the mean cosine similarity between two randomly sampled images, including VIS-VIS and NIR-VIS. FID (Fr$\acute{\text{e}}$chet Inception Distance, lower is better) measures the distribution distance between the generated data and the real data. VR@FAR=1$\%$ suggests the recognition performance after using the generated data to train the HFR network via contrastive learning. } \label{table-1} \begin{spacing}{1.3} \resizebox{0.49\textwidth}{!}{ \begin{tabular}{l|ccccc} Method & MS & MIS$_\text{VIS-VIS}$ & MIS$_\text{NIR-VIS}$ & FID & VR@FAR=1$\%$ \\ \myhline CoGAN \cite{liu2016coupled} & 0.23 & 0.32 & 0.16 & 0.77 & 22.1 \\ DVG \cite{fu2019dual} & 0.52 & 0.45 & 0.41 & 0.65 & 39.3 \\ \hline DVG-Face & \textbf{0.53} & \textbf{0.14} & \textbf{0.14} & \textbf{0.57} & \textbf{68.5} \\ \end{tabular}} \end{spacing} \end{table} \subsection{Experimental Analyses} \subsubsection{Identity Consistency} \label{identity consistency} As discussed in Section~\ref{method}, the generated paired heterogeneous images are required to have the same identity. In order to verify this property, we propose to measure MS (Mean Similarity) between the paired images. Specifically, we utilize the pre-trained LightCNN to extract the $L_2$ normalized embedding features of the paired images, and then calculate their cosine similarity. The MS value is a mean of the similarities of 50K randomly generated paired heterogeneous images. As reported in Table~\ref{table-1}, the MS value of DVG-Face is 0.53, while that of the real database is 0.31. It is observed that the former is even larger than the latter, demonstrating that our method does in fact guarantee the identity consistency property. In addition, we can see that the preliminary version DVG also has this property due to the usage of the same pairwise identity preserving manner. By contrast, the MS value of CoGAN \cite{liu2016coupled} is only 0.23 that is significantly smaller than that of the real database. This reveals that it is difficult for the weight-sharing manner of CoGAN to ensure the identity consistency property. \subsubsection{Identity Diversity} \label{identity diversity} Identity diversity plays a crucial role in our method. The more diverse the generated data, the more valuable it will be for the HFR network. Inspired by the instance discrimination criterion \cite{wu2018unsupervised,bachman2019learning} that regards each image as an independent class, we propose a MIS (Mean Instance Similarity) metric to measure the identity diversity property. Intuitively, if the generated images have abundant identity diversity, the images obtained from different samplings can be considered to have different identities. Specifically, by randomly sampling twice from noises, two paired images ($\tilde{I}_N^1$, $\tilde{I}_V^1$) and ($\tilde{I}_N^2$, $\tilde{I}_V^2$) are generated. Then, we calculate the cosine similarities of the embedding features (extracted by LightCNN) between ($\tilde{I}_V^1$, $\tilde{I}_V^2$) and between ($\tilde{I}_N^1$, $\tilde{I}_V^2$), yielding IS$_\text{VIS-VIS}$ (Instance Similarity) and IS$_\text{NIR-VIS}$, respectively. After repeating the above sampling and calculation process 50K times, we average these IS$_\text{VIS-VIS}$ and IS$_\text{NIR-VIS}$ values to obtain MIS$_\text{VIS-VIS}$ and MIS$_\text{NIR-VIS}$ values, respectively. As listed in Table~\ref{table-1}, both CoGAN and DVG get a much higher MIS$_\text{VIS-VIS}$ value than DVG-Face, suggesting the presence of massive similar VIS images in the sampled data of CoGAN and DVG. We also observe that CoGAN gets a low MIS$_\text{NIR-VIS}$ value due to the identity inconsistency between the generated paired heterogeneous images. The lowest MIS$_\text{VIS-VIS}$ and MIS$_\text{NIR-VIS}$ values of DVG-Face prove that it can really generate more diverse data. In addition, when using the generated data to train the HFR network via the contrastive loss in Eq.~(\ref{contrastive}), it is observed that both CoGAN and DVG obtain a much worse recognition performance than DVG-Face. This is because that the validity of the contrastive loss is based on the identity consistency and the identity diversity properties, neither of which is simultaneously satisfied by CoGAN and DVG. \begin{figure}[t] \centering \includegraphics[width=0.48\textwidth]{./fig/fig5.pdf} \caption{Visualization comparisons of dual generation on Tufts Face. (a) CoGAN \cite{liu2016coupled}. (b) DVG \cite{fu2019dual}. (c) DVG-Face. } \label{fig_5} \end{figure} \begin{table}[t] \centering \caption{Recognition performances under different identity sampling approaches on Tufts Face. From top to bottom, the first one leverages LightCNN in both the training and the testing stages of dual generation. The second one uses LightCNN in the training stage and the identity sampler in the testing stage. The third one employs the identity sampler in the both stages.} \label{table-2} \begin{spacing}{1.3} \resizebox{0.49\textwidth}{!}{ \begin{tabular}{l|ccc} Method & Rank-1 & VR@FAR=1$\%$ & VR@FAR=0.1$\%$ \\ \myhline LightCNN - LightCNN & 74.6 & 67.9 & 33.7 \\ LigthCNN - Identity Sampler & 73.5 & 66.4 & 31.0 \\ Identity Sampler - Identity Sampler & \textbf{75.7} & \textbf{68.5} & \textbf{36.5} \\ \end{tabular}} \end{spacing} \end{table} \subsubsection{Distribution Consistency} The distribution of the generated data and that of the real data should be consistent, otherwise it will be difficult to boost the recognition performance with the generated data. FID (Fr$\acute{\text{e}}$chet Inception Distance) \cite{heusel2017gans} is employed to measure the distance between these two distributions in the feature space. In addition, considering the advantage of the face recognition network in extracting facial features, we use LightCNN rather than the conventional Inception model as the feature extractor. Specifically, we first generate 50K paired NIR-VIS data, and then calculate the FID value between the generated NIR data and the real NIR data, as well as the FID value between the generated VIS data and the real VIS data. Subsequently, these two FID values are averaged to get the final FID value. Table~\ref{table-1} suggests that both DVG and DVG-Face obtain a much lower FID value than CoGAN, proving that our method can really learn the distribution of the real data. Furthermore, Fig.~\ref{fig_5} shows the visualization comparisons of CoGAN, DVG, and DVG-Face. We can see that the generated results of CoGAN have many artifacts. It seems difficult for CoGAN to generate good results under such a large domain discrepancy case. Besides, it is observed that the generated paired images of CoGAN are not particularly similar, which is consistent with the MS value in Table~\ref{table-1}. By contrast, both DVG and DVG-Face generate photo-realistic results, further demonstrating the distribution consistency property of our method. In the end, it is obvious that the real training data are crucial for the dual variational generator to learn domain distributions. This motivates us to further investigate the effect of the number of the real data on domain learning. Specifically, apart from the whole training set of Tufts Face that has 1,940 images belonging to 50 identities, we also train the generator on 5 subsets that include 5, 10, 20, 30, and 40 identities with 198, 378, 734, 1,130, and 1,499 images, respectively. Subsequently, we measure the domain distances between the generated data of the above settings and the real data of the whole training set via FID. The lower the FID value, the closer the domain of the generated data is to that of the real data. The experimental results in Fig.~\ref{fig_7} (left) suggest that as the number of the trained identities increases, the FID value decreases gradually before 30 identities and then tends to be stable. Thus, 30 identities containing 1,130 real training images seem enough for the generator to learn the real domain. \begin{figure}[t] \centering \includegraphics[width=0.49\textwidth]{./fig/data.pdf} \caption{Studies of the real data (left) and the generated data (right) on Tufts Face. } \label{fig_7} \end{figure} \subsubsection{Identity Sampling} \label{identity sampling} As stated in Section~\ref{training unpair}, the identity representation can be obtained from the pre-trained face recognition network (LightCNN~\cite{Wu2018ALC}) or from the identity sampler. Correspondingly, there are three potential identity sampling approaches: (1) Using LightCNN in both the training and the testing stages of the dual generation. In this case, DVG-Face becomes a conditional generative model. At the testing stage, if we desire to generate large-scale paired data, we must have the same number of VIS data with different identities to provide the required identity representations. Therefore, the sampling diversity is limited by the size of the available VIS data. (2) Using LightCNN in the training stage and the identity sampler in the testing stage. By this means, we no longer need large-scale available VIS data in the testing stage. The required rich identity representations can be easily sampled from noises. However, the identity representations generated by the identity sampler conform to the Gaussian distribution, while those of LightCNN do not satisfy the Gaussian distribution hypothesis. Thus, there may be a distribution gap between the two types of identity representations. (3) Using the identity sampler in both the training and the testing stages. In this way, it is flexible to obtain massive identity representations in the both stages. The performances of the above three approaches are shown in Table~\ref{table-2}. We observe that the second approach obtains the worst results because of the aforementioned distribution gap. In addition, the third approach gets better results than the first approach, even though the identity sampler is trained on the extracted identity representations of LightCNN. This indicates that the identity sampler may produce new diverse identity representations based on the property of VAEs. \begin{table}[t] \centering \caption{Results under different usages of large-scale VIS data on Tufts Face. (A) trains LightCNN on the large-scale VIS database MS-Celeb-1M. (B) fine-tunes the pre-trained LightCNN on Tufts Face. (C) fine-tunes on both Tufts Face and MS-Celeb-1M. (D) is our method. It introduces the identities of MS-Celeb-1M to enrich the identity diversity of the generated data, and fine-tunes the pre-trained LightCNN on both Tufts Face and the generated data. } \label{table-3} \begin{spacing}{1.0} \resizebox{0.45\textwidth}{!}{ \begin{tabular}{c|ccc} Method & Rank-1 & VR@FAR=1$\%$ & VR@FAR=0.1$\%$ \\ \myhline (A) & 29.4 & 23.0 & 5.3 \\ (B) & 54.5 & 42.4 & 15.6 \\ (C) & 33.9 & 24.7 & 7.9 \\ \hline (D) & \textbf{75.7} & \textbf{68.5} & \textbf{36.5} \\ \end{tabular}} \end{spacing} \end{table} \subsubsection{Number of Generated Data} We also investigate the effect of the number of the generated data on the HFR performance. In particular, we use 0, 10K, 30K, 50K, 80K, 100K, 130K, 150K, 180K, and 200K generated paired heterogeneous data to train the HFR network, respectively. Fig.~\ref{fig_7} (right) depicts the results under different numbers of generated data on the Tufts Face database. It is clear that from 0 to 100K, the recognition performance is improved with increasing the number of the generated data. Compared with only using the real data (0 generated data), VR@FAR=1$\%$ is significantly improved by 26.1$\%$ after adding 100K generated paired data. These phenomena demonstrate that the generated data really contain abundant useful information that is helpful for recognition. Besides, as the number of the generated paired data exceeds 100K, no obvious improvement is observed, indicating that the generated data have been saturated. \begin{figure}[t] \centering \includegraphics[width=0.49\textwidth]{./fig/fig6.pdf} \caption{Qualitative ablation studies of the angular orthogonal loss $\mathcal{L}_{\text{ort}}$ and the pairwise identity preserving loss $\mathcal{L}_{\text{ip}}$ on Tufts Face. Given the attribute images, these methods generate two pairs of images with two different identity representations. } \label{fig_6} \end{figure} \begin{table}[t] \centering \caption{Quantitative ablation studies of the angular orthogonal loss $\mathcal{L}_{\text{ort}}$ and the pairwise identity preserving loss $\mathcal{L}_{\text{ip}}$ on Tufts Face.} \label{table-5} \begin{spacing}{1.1} \resizebox{0.43\textwidth}{!}{ \begin{tabular}{c|ccc} Method & Rank-1 & VR@FAR=1$\%$ & VR@FAR=0.1$\%$ \\ \myhlineII w/o $\mathcal{L}_{\text{ort}}$ & 55.9 & 43.6 & 16.7 \\ w/o $\mathcal{L}_{\text{ip}}$ & 62.4 & 57.6 & 22.1 \\ \hline Ours & \textbf{75.7} & \textbf{68.5} & \textbf{36.5} \\ \end{tabular}} \end{spacing} \end{table} \subsubsection{Usage of Large-Scale VIS Data} \label{VIS data} Generally, the large-scale VIS database, \textit{i.e.} MS-Celeb-1M \cite{guo2016ms}, is only used to pre-train the HFR network \cite{deng2019residual,XWu:2018}. The intuition behind this is that training the large-scale VIS data together with the small-scale heterogeneous data will lead to severe domain biases that may degrade the performance of HFR. In order to verify this point, four experiments are elaborately designed: (A) directly trains LightCNN on the large-scale VIS database MS-Celeb-1M. (B) fine-tunes the pre-trained LightCNN on the heterogeneous database, and (C) fine-tunes on both the heterogeneous database and MS-Celeb-1M. (D) is our method that fine-tunes on both the heterogeneous database and the generated data. Table~\ref{table-3} shows that the results of (C) are merely slightly better than those of (A), and are much worse than those of (B), revealing that the domain biases actually affect the performance of HFR. Moreover, (D) outperforms the others by a large margin. This demonstrates the effectiveness of our method that introduces the identity representations of MS-Celeb-1M to enrich the identity diversity of the generated data. In this case, the domain biases are mitigated because the generated data belong to the same domain of the real heterogeneous database. \begin{table}[t] \centering \caption{Results under different usages of the generated data on Tufts Face. (I) only uses the real data to train the HFR network, and (II) merely uses the generated unlabeled data. (III) leverages both the real data and the generated data, and the latter is utilized via the pairwise distance loss. (IV) is our method that replaces the pairwise distance loss with the contrastive loss. } \label{table-5-2} \begin{spacing}{1.0} \resizebox{0.45\textwidth}{!}{ \begin{tabular}{c|ccc} Method & Rank-1 & VR@FAR=1$\%$ & VR@FAR=0.1$\%$ \\ \myhline (I) & 54.5 & 42.4 & 15.6 \\ (II) & 36.6 & 24.7 & 7.2 \\ (III) & 70.3 & 60.8 & 29.6 \\ \hline (IV) & \textbf{75.7} & \textbf{68.5} & \textbf{36.5} \\ \end{tabular}} \end{spacing} \end{table} \begin{table}[t] \centering \caption{Verification rates on Tufts Face under different parameter values.} \label{table-6} \begin{spacing}{0.9} \subfloat[][$\lambda_1$ in Eq.~(\ref{pair})]{ \label{table-6-1} \resizebox{0.115\textwidth}{!}{ \begin{tabular}{cc} $\lambda_1$ & FAR=1$\%$ \\ \toprule[0.95 pt] 0 & 43.6 \\ 10 & 68.1 \\ 25 & \textbf{68.5} \\ 50 & \textbf{68.5} \\ 75 & 67.9 \\ 100 & 67.4 \\ \end{tabular}} } \subfloat[][$\lambda_2$ in Eq.~(\ref{pair})]{ \label{table-6-2} \resizebox{0.115\textwidth}{!}{ \begin{tabular}{cc} $\lambda_2$ & FAR=1$\%$ \\ \toprule[0.95 pt] 0 & 57.6 \\ 0.10 & 66.9 \\ 0.25 & 67.8 \\ 0.50 & \textbf{68.5} \\ 0.75 & 68.4 \\ 1.00 & 68.3 \\ \end{tabular}} } \subfloat[][$\eta$ in Eq.~(\ref{rec-u})]{ \label{table-6-4} \resizebox{0.115\textwidth}{!}{ \arrayrulecolor{black} \begin{tabular}{cc} $\eta$ & FAR=1$\%$ \\ \toprule[0.95 pt] 0 & 46.5 \\ 0.05 & 68.1 \\ 0.10 & \textbf{68.5} \\ 0.20 & 67.6 \\ 0.30 & 65.7 \\ 0.40 & 64.8 \\ \end{tabular}} } \subfloat[][$\alpha$ in Eq.~(\ref{hfr})]{ \label{table-6-3} \resizebox{0.115\textwidth}{!}{ \arrayrulecolor{black} \begin{tabular}{cc} $\alpha$ & FAR=1$\%$ \\ \toprule[0.95 pt] 0 & 42.4 \\ 2e-4 & 67.9 \\ 5e-4 & 68.3 \\ 1e-3 & \textbf{68.5} \\ 2e-3 & 67.6 \\ 3e-3 & 65.7 \\ \end{tabular}} } \end{spacing} \end{table} \begin{table}[t] \centering \caption{Studies of the margin $m$ in Eq.~(\ref{contrastive}) on Tufts Face.} \label{table-7} \begin{spacing}{1.1} \resizebox{0.45\textwidth}{!}{ \begin{tabular}{c|cccccc} margin $m$ & 0.2 & 0.3 & 0.4 & 0.5 & 0.6 & 0.7 \\ \myhlineII VR@FAR=1$\%$ & 67.0 & 67.5 & 68.1 & \textbf{68.5} & 68.2 & 67.4 \\ \end{tabular}} \end{spacing} \end{table} \subsubsection{Ablation Study} \textbf{For Dual Generation.} The angular orthogonal loss $\mathcal{L}_{\text{ort}}$ in Eq.~(\ref{orthogonal}) and the pairwise identity preserving loss $\mathcal{L}_{\text{ip}}$ in Eq.~(\ref{ip}) (including $\mathcal{L}_{\text{ip}}^{\text{u}}$ in Eq.~(\ref{ip-u})) are studied to analyze their respective roles. Both quantitative and qualitative results are presented for a comprehensive comparison. Fig.~\ref{fig_6} depicts the qualitative comparisons between our method and its two variants. Without $\mathcal{L}_{\text{ort}}$, the generated images are almost unchanged when the identity representation is varied. This means that we cannot enrich the identity diversity of the generated data via injecting more identity information. When omitting $\mathcal{L}_{\text{ip}}$, the generated paired images look inconsistent in identities, suggesting the effectiveness of $\mathcal{L}_{\text{ip}}$. In addition, Table~\ref{table-5} displays the quantitative comparison results. It is observed that the recognition performance drops significantly if one of the losses is discarded, which further proves the importance of each loss. For example, VR@FAR=0.1$\%$ decreases by 19.8$\%$ when $\mathcal{L}_{\text{ort}}$ is omitted. \textbf{For HFR.} We design four experiments to study the usage of the generated data: (I) only uses the real data to train the HFR network. (II) discards the real data and merely uses the generated data. (III) leverages both the real data and the generated data, and the latter is utilized via the pairwise distance loss as our preliminary version DVG. (IV) is our method that uses the real data and the generated data with the softmax loss and the contrastive loss, respectively. Table~\ref{table-5-2} shows that (II) gets the worst results. However, compared with the backbone LightCNN pre-trained on MS-Celeb-1M (Rank-1 = 29.4$\%$, listed in Table~\ref{table-3}), (II) still gains an improvement of 7.2$\%$ in terms of the Rank-1 accuracy, suggesting the value of the generated data. Compared with (I), the Rank-1 accuracy is boosted at least by 15.8$\%$ after introducing the generated data, including both (III) and (IV). This further demonstrates the importance of the generated data. In addition, we find that compared with our preliminary version DVG (Rank-1 = 56.1$\%$, listed in Table~\ref{table-tufts}), (III) improves the Rank-1 accuracy by 14.2$\%$. Since the difference between the two methods lies in the generated data, we attribute the improvement to the richer identity diversity of the generated data of DVG-Face, as discussed in Section~\ref{identity diversity}. (IV) gains better results than (III), which verifies the effectiveness of the introduced contrastive loss. It optimizes both the intra-class and the inter-class distances, facilitating to learn domain-invariant and discriminative embedding features. By contrast, the pairwise distance loss of DVG can only assist in reducing domain discrepancy. Note that the effectiveness of the contrastive loss is based on the identity consistency and the identity diversity properties of the generated data, as stated in Section~\ref{identity diversity}. Table~\ref{table-6} lists the results of sensitivity studies of the parameters $\lambda_1$ and $\lambda_2$ in Eq.~(\ref{pair}), $\eta$ in Eq.~(\ref{rec-u}), and $\alpha$ in Eq.~(\ref{hfr}). The parameters $\lambda_1$, $\lambda_2$, and $\alpha$ are set to balance the magnitude of the corresponding loss functions. $\eta$ is set according to \cite{bao2018towards}. It is observed that our method is not sensitive to these trade-off parameters in a large range. For instance, when $\lambda_1$ is varied from 10 to 100, the verification rate only changes from 67.4$\%$ to 68.5$\%$. Besides, Table~\ref{table-6} suggests that as the parameter becomes larger gradually, the recognition performance first increases and then decreases. The optimal setting is $\lambda_1$=50, $\lambda_2$=0.5, $\eta$=0.1, and $\alpha$=1e-3. More sensitivity studies of the parameters $\lambda_1$, $\lambda_2$, $\eta$, and $\alpha$ on the BUAA-Vis-Nir, the MultiPIE, and the NJU-ID databases are presented in Tables 4, 5, and 6 of the supplementary material, respectively. Finally, we further explore the setting of the margin parameter $m$ in Eq.~(\ref{contrastive}). Table~\ref{table-7} reveals that the best margin value is 0.5. Finally, it is worth noting that our method is computationally efficient. When using one TITAN Xp GPU, it takes about 20 minutes to train the generator on the Tufts Face database. In the inference stage of the generator, it merely takes about 4.7 ms to generate a pair of heterogeneous face images. Furthermore, training the HFR network with 100K generated data and about 2K real data costs about 5 hours. \begin{figure*}[t] \centering \includegraphics[width=0.98\textwidth]{./fig/fig4.pdf} \caption{Dual generation results on (a) CASIA NIR-VIS 2.0 \cite{SLi:2013}, (b) BUAA-VisNir \cite{DHuang:2012}, (c) CUFSF \cite{ZhangWT11}, and (d) Tufts Face \cite{panetta2018comprehensive}. More generation results, including those on Oulu-CASIA NIR-VIS \cite{JChen:2009} and Multi-PIE \cite{gross2010multi}, are shown in Fig.~2 of the supplementary material. } \label{fig_4} \end{figure*} \begin{table}[t] \centering \caption{Experimental results on CASIA NIR-VIS 2.0.} \label{table-casia} \begin{spacing}{1.1} \resizebox{0.47\textwidth}{!}{ \begin{tabular}{l|ccc} Method & Rank-1 & VR@FAR=0.1$\%$ & VR@FAR=0.01$\%$ \\ \myhline H2(LBP3) \cite{Shao2017CrossModalityFL} & 43.8 & 10.1 & - \\ DSIFT \cite{dhamecha2014effectiveness} & 73.3$\pm$1.1 & - & - \\ CDFL \cite{jin2015coupled} & 71.5$\pm$1.4 & 55.1 & - \\ Gabor+RBM \cite{yi2015shared} & 86.2$\pm$1.0 & 81.3$\pm$1.8 & - \\ Recon.+UDP \cite{JuefeiXu2015NIRVISHF} & 78.5$\pm$1.7 & 85.8 & - \\ CEFD \cite{gong2017heterogeneous} & 85.6 & - & - \\ \hline IDNet \cite{Reale2016SeeingTF} & 87.1$\pm$0.9 & 74.5 & - \\ HFR-CNN \cite{saxena2016heterogeneous} & 85.9$\pm$0.9 & 78.0 & - \\ Hallucination \cite{Lezama2017NotAO} & 89.6$\pm$0.9 & - & - \\ DLFace \cite{peng2019dlface} & 98.68 & - & - \\ TRIVET \cite{XXLiu:2016} & 95.7$\pm$0.5 & 91.0$\pm$1.3 & 74.5$\pm$0.7 \\ W-CNN \cite{DBLP:journals/corr/abs-1708-02412} & 98.7$\pm$0.3 & 98.4$\pm$0.4 & 94.3$\pm$0.4 \\ PACH \cite{duan2019pose} & 98.9$\pm$0.2 & 98.3$\pm$0.2 & - \\ RCN \cite{deng2019residual} & 99.3$\pm$0.2 & 98.7$\pm$0.2 & - \\ MC-CNN \cite{8624555} & 99.4$\pm$0.1 & 99.3$\pm$0.1 & - \\ DVR \cite{XWu:2019} & 99.7$\pm$0.1 & 99.6$\pm$0.3 & 98.6$\pm$0.3 \\ \hline DVG \cite{fu2019dual} & 99.8$\pm$0.1 & 99.8$\pm$0.1 & 98.8$\pm$0.2 \\ \textbf{DVG-Face} & \textbf{99.9}$\pm$0.1 & \textbf{99.9}$\pm$0.0 & \textbf{99.2}$\pm$0.1 \\ \end{tabular}} \end{spacing} \end{table} \begin{figure}[t] \centering \includegraphics[width=0.485\textwidth]{./fig/fig_roc.pdf} \caption{ROC curves of different methods on (a) CASIA NIR-VIS 2.0 and (b) BUAA-VisNir. } \label{fig_roc} \end{figure} \subsection{Comparisons with State-of-the-Art Methods} \subsubsection{Results on the CASIA NIR-VIS 2.0 Database} In order to verify the effectiveness of DVG-Face, we compare it with 16 state-of-the-art methods, including 6 traditional methods and 10 deep learning based methods. The traditional methods include H2(LBP3) \cite{Shao2017CrossModalityFL}, DSIFT+PCA+LDA \cite{dhamecha2014effectiveness}, CDFL \cite{jin2015coupled}, Gabor+RBM \cite{yi2015shared}, Recon.+UDP \cite{JuefeiXu2015NIRVISHF}, and CEFD \cite{gong2017heterogeneous}. The deep learning based methods consist of IDNet \cite{Reale2016SeeingTF}, HFR-CNN \cite{saxena2016heterogeneous}, Hallucination \cite{Lezama2017NotAO}, DLFace \cite{peng2019dlface}, TRIVET \cite{XXLiu:2016}, W-CNN \cite{DBLP:journals/corr/abs-1708-02412}, PACH \cite{duan2019pose}, RCN \cite{deng2019residual}, MC-CNN \cite{8624555}, and DVR \cite{XWu:2019}. Table~\ref{table-casia} shows the results of the Rank-1 accuracy and verification rates of the above methods. We can see that most of the deep learning based methods outperform the traditional methods. Nevertheless, the deep learning based method HFR-CNN performs worse than the traditional method Gabor+RBM. This indicates that it is challenging for the deep learning based methods to train on the small-scale heterogeneous data. The methods, such as W-CNN, MC-CNN, and DVR, which are devoted to tackling the over-fitting caused by the limited training data, get higher performances. Moreover, our method obtains the best results than all the competitors. In particular, regarding the Rank-1 accuracy and VR@FAR=0.1$\%$, DVG-Face exceeds the conditional generation based method PACH by 1.0$\%$ and 1.6$\%$ respectively, suggesting the superiority of our unconditional generation approach. Compared with the state-of-the-art method DVR, we improve VR@FAR=0.01$\%$ from 98.6$\%$ to 99.2$\%$. More importantly, the ROC curves in Fig.~\ref{fig_roc} (a) show that DVG-Face improves the harder indicator True Positive Rate (TPR)@False Positive Rate (FPR)=10$^{-5}$ by 3.0$\%$ over DVR. In addition, compared with the preliminary version DVG \cite{fu2019dual}, DVG-Face further improves TPR@FPR=10$^{-5}$ from 97.8$\%$ to 98.6$\%$. The improvement highlights the importance of the abundant identity diversity and the consequent contrastive loss. The generated paired NIR-VIS images of DVG-Face are exemplified in Fig.~\ref{fig_4} (a). \begin{table}[t] \centering \caption{Experimental results on BUAA-VisNir.} \label{table-buaa} \begin{spacing}{1.1} \resizebox{0.47\textwidth}{!}{ \begin{tabular}{l|ccc} Method & Rank-1 & VR@FAR=1$\%$ & VR@FAR=0.1$\%$ \\ \myhline MPL3 \cite{JChen:2009} & 53.2 & 58.1 & 33.3 \\ KCSR \cite{lei2009coupled} & 81.4 & 83.8 & 66.7 \\ KPS \cite{klare2012heterogeneous} & 66.6 & 60.2 & 41.7 \\ KDSR \cite{Huang2013RegularizedDS} & 83.0 & 86.8 & 69.5 \\ H2(LBP3) \cite{Shao2017CrossModalityFL} & 88.8 & 88.8 & 73.4 \\ \hline TRIVET \cite{XXLiu:2016} & 93.9 & 93.0 & 80.9 \\ W-CNN \cite{DBLP:journals/corr/abs-1708-02412} & 97.4 & 96.0 & 91.9 \\ PACH \cite{duan2019pose} & 98.6 & 98.0 & 93.5 \\ DVR \cite{XWu:2019} & 99.2 & 98.5 & 96.9 \\ \hline DVG \cite{fu2019dual} & 99.3 & 98.5 & 97.3 \\ \textbf{DVG-Face} & \textbf{99.9} & \textbf{99.7} & \textbf{99.1} \end{tabular}} \end{spacing} \end{table} \subsubsection{Results on the BUAA-VisNir Database} A total of 5 traditional methods and 4 deep learning based methods are compared on the BUAA-VisNir database. The former includes MPL3 \cite{JChen:2009}, KCSR \cite{lei2009coupled}, KPS \cite{klare2012heterogeneous}, KDSR \cite{Huang2013RegularizedDS}, and H2(LBP3) \cite{Shao2017CrossModalityFL}, and the latter includes TRIVET~\cite{XXLiu:2016}, W-CNN~\cite{DBLP:journals/corr/abs-1708-02412}, PACH \cite{duan2019pose}, and DVR~\cite{XWu:2019}. Here as well, we observe from Table~\ref{table-buaa} that the deep learning based methods are always superior to the traditional methods. Moreover, the improvements of DVG-Face over the conditional generation based method PACH are significant. VR@FAR=0.1$\%$ is increased from 93.5$\%$ to 99.1$\%$. In addition, although the state-of-the-art DVR has achieved very high results, DVG-Face still exceeds it by 2.2$\%$ in terms of VR@FAR=0.1$\%$. The ROC curves in Fig.~\ref{fig_roc} (b) further demonstrate the advantages of our method. Regarding TPR@FPR=10$^{-5}$, DVG-Face leads DVR by 5.4$\%$ and the preliminary version DVG by 5.1$\%$. The generated paired images of DVG-Face on the BUAA-VisNir database are presented in Fig.~\ref{fig_4} (b). \subsubsection{Results on the IIIT-D Sketch Viewed Database} Considering the crucial role of the Sketch-Photo recognition in criminal investigation, we further evaluate our method on the IIIT-D Sketch Viewed database. The compared methods include 5 traditional methods: Original WLD \cite{chen2009wld}, SIFT \cite{klare2010sketch}, EUCLBP \cite{bhatt2010matching}, LFDA \cite{Klare2011MatchingFS}, MCWLD \cite{bhatt2012memetic}, as well as 4 deep learning based methods: LightCNN \cite{Wu2018ALC}, CDL \cite{XWu:2018}, RCN\cite{deng2019residual}, and MC-CNN~\cite{8624555}. Table~\ref{table-sketch} suggests that on such a Sketch-Photo database, the overall performance discrepancy between the traditional methods and the deep learning based methods is not particularly large. The Rank-1 accuracy of MCWLD is even better than that of LightCNN, and is comparable with that of CDL. In addition, our method exhibits superior performances over all the competitors. The best Rank-1 accuracy is improved from 90.34$\%$ \cite{deng2019residual} to 97.21$\%$. Fig.~\ref{fig_4} (c) depicts the dual generation results of Sketch-Photo. \begin{table}[t] \centering \caption{Experimental results on IIIT-D Sketch Viewed.} \label{table-sketch} \begin{spacing}{1.1} \resizebox{0.27\textwidth}{!}{ \begin{tabular}{l|c} Method & Rank-1 \\ \myhline Original WLD \cite{chen2009wld} & 74.34 \\ SIFT \cite{klare2010sketch} & 76.28 \\ EUCLBP \cite{bhatt2010matching} & 79.36 \\ LFDA \cite{Klare2011MatchingFS} & 81.43 \\ MCWLD \cite{bhatt2012memetic} & 84.24 \\ \hline LightCNN \cite{Wu2018ALC} & 83.24 \\ CDL \cite{XWu:2018} & 85.35 \\ MC-CNN \cite{8624555} & 87.40 \\ RCN \cite{deng2019residual} & 90.34 \\ \hline DVG \cite{fu2019dual} & 96.99 \\ \textbf{DVG-Face} & \textbf{97.21} \\ \end{tabular}} \end{spacing} \end{table} \subsubsection{Results on the Tufts Face Database} As mentioned in Section~\ref{VIS data}, the face recognition network pre-trained on MS-Celeb-1M merely obtains a Rank-1 accuracy of 29.4$\%$ on the Tufts Face database, indicating the large domain discrepancy between the thermal data and the VIS data. At the same time, it is observed that after fine-tuning on the training set of Tufts Face, the Rank-1 accuracy only increases to 54.5$\%$ that is still unsatisfactory. This phenomenon is caused by the limited number of the Thermal-VIS training data. Obviously, data augmentation is a straightforward approach to alleviate this problem. Both the preliminary version DVG and the current DVG-Face aim to generate more data to facilitate the training of the HFR network. The comparisons of DVG, DVG-Face, and the baseline LightCNN are reported in Table~\ref{table-tufts}. We can see that compared with DVG, DVG-Face boosts the Rank-1 accuracy from 56.1$\%$ to 75.7$\%$, and VR@FAR=0.1$\%$ from 17.1$\%$ to 36.5$\%$. The dual generation results on Tufts Face are shown in Fig.~\ref{fig_4} (d). \begin{table}[t] \centering \caption{Experimental results on Tufts Face.} \label{table-tufts} \begin{spacing}{1.1} \resizebox{0.45\textwidth}{!}{ \begin{tabular}{l|ccc} Method & Rank-1 & VR@FAR=1$\%$ & VR@FAR=0.1$\%$ \\ \myhline LightCNN \cite{Wu2018ALC} & 29.4 & 23.0 & 5.3 \\ \hline DVG \cite{fu2019dual} & 56.1 & 44.3 & 17.1 \\ \textbf{DVG-Face} & \textbf{75.7} & \textbf{68.5} & \textbf{36.5} \\ \end{tabular}} \end{spacing} \end{table} \section{Conclusion} This paper has proposed a novel DVG-Face framework that generates large-scale new paired heterogeneous images from noises to boost the performance of HFR. To begin with, a dual variational generator is elaborately designed to train with both paired heterogeneous data and unpaired VIS data. The introduction of the latter greatly promotes the identity diversity of the generated images. Subsequently, a pairwise identity preserving loss is imposed on the generated paired images to guarantee their identity consistency. Finally, benefiting from the identity consistency and identity diversity properties, the generated unlabeled images can be employed to train the HFR network via contrastive learning. Our method obtains the best results on seven databases, exposing a new way to the HFR problem. \section*{Acknowledgments} The authors would like to greatly thank the associate editor and the reviewers for their valuable comments and advice. This work is funded by Beijing Natural Science Foundation (Grant No. JQ18017), National Natural Science Foundation of China (Grant No. 61721004, U20A20223) and Youth Innovation Promotion Association CAS (Grant No. Y201929). \ifCLASSOPTIONcaptionsoff \newpage \fi { \bibliographystyle{IEEEtran}
{'timestamp': '2021-01-19T02:09:32', 'yymm': '2009', 'arxiv_id': '2009.09399', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09399'}
arxiv
\section{Introduction} \label{sec:1} \iffalse \begin{itemize} \item \bm{Introduction} \item A brief introduction to multi-armed bandit, including the problem setup, the algorithm and the result \item Contextual bandits and RL setup \item The challenge of solving RL tasks and what algorithms have been proposed \item We extend MAB algorithm to RL and a summary on how the algorithm works \item What challenges has been brought by RL setting. However, RL often have unbounded rewards which follow a MDP. Current algorithms such as EXP3.P usually assume bounded rewards to guarantee optimal regrets. Specifically, under bounded condition, regret is proven to be optimal both in the expected sense and in the high probability sense where the latter is often harder and by far is not studied in contextual setting. To fill the gap, we first propose a new algorithm, EXP4.P and show its high probability optimal regret bound in bounded contextual bandits. To advance, we conduct thorough regret analysis of EXP4.P in unbounded ones which is again optimal. As a by-product, a similar analysis can be applied to the existing EXP3.P algorithm for unbounded MAB. \item The challenge of doing the analysis and what we have used to show the result. \item Summary on our contributions both on analytical side and on experimental side. Our analysis close the gap between the existing regret analysis and that under every possible scenario. \item \textcolor{red}{Lower bound on Gaussian bandits for finite time horizon. Lower bound in general unbounded bandits that show our regret is optimal. This is already done by Auer.} \item \bm{Literature Review} \item Exploration incentive in RL setting by extending exploration technique for bandit problems \item DQN technique in RL setting \item Regret analysis in bandit setting \end{itemize} \fi Multi-armed bandit (MAB) is to maximize cumulative reward of a player throughout a bandit game by choosing different arms at each time step. It is also equivalent to minimizing the regret defined as the difference between the best rewards that can be achieved and the actual reward gained by the player. Formally, given time horizon $T$, in time step $t\leq T$ the player chooses one arm $a_t$ among $K$ arms, receives $r^t_{a_t}$ among rewards $r^t=(r^t_1,r^t_2,\ldots,r^t_K)$, and maximizes the total reward $\sum_{t=1}^T r^t_{a_t}$ or minimizes the regret. Computationally efficient and with abundant theoretical analyses are the EXP-type MAB algorithms. In EXP3.P, each arm has a trust coefficient (weight). The player samples each arm with probability being the sum of its normalized weights and a bias term, receives reward of the sampled arm and exponentially updates the weights based on the corresponding reward estimates. It achieves the regret of the order $O(\sqrt{T})$ in a high probability sense. Contextual bandit is a variant of MAB by adding context or state space $S$ and a different regret definition. At time step $t$, the player has context $s_t\in S$ and rewards $r^t$ follow $f(\mu(s_t))$ where $f$ is any distribution and $\mu(s_t)$ is the mean vector that depends on state $s_t$. To incorporate the context information, a variant of EXP-type algorithms is proposed as EXP4,~\cite{auer2002nonstochastic}. In EXP4, there are any number of experts. Each expert has a sample rule over actions (arms) and a trust coefficient. The player samples according to the weighted average of experts' sample rules and updates the weights respectively. Then the regret is defined by comparing the actual reward with the reward that can be achieved by the best expert instead of by the best arm. Recently, contextual bandit has been further aligned with Reinforcement Learning (RL) where state and reward transitions follow a Markov Decision Process (MDP) represented by transition kernel $P(s_{t+1},r^t|a_{t},s_{t})$. A key challenge in RL is the trade-off between exploration and exploitation. Exploration is to encourage the player to try new arms in bandit or new actions in RL to understand the game better. It helps to plan for the future, but with the sacrifice of potentially lowering the current reward. Exploitation aims to exploit currently known states and arms to maximize the current reward, but it potentially prevents the player to gain more information to increase future reward. To maximize the cumulative reward, the player needs to learn the game by exploration, while guaranteeing current reward by exploitation. How to incentivize exploration in RL has been a main focus in RL. Since RL is built on bandits, it is natural to extend bandits techniques to RL and UCB is such a success. UCB \cite{auer2002finite} motivates count-based exploration \cite{strehl2008analysis} in RL and the subsequent Pseudo-Count exploration \cite{bellemare2016unifying}, though it is initially developed for stochastic bandit. Another line of work on RL exploration is based on deep learning techniques. Using deep neural networks to keep track of the $Q$-values by means of $Q$-networks in RL is called DQN \cite{mnih2013playing}. This combination of deep learning and RL has shown great success. $\epsilon$-greedy in \citet{mnih2015human} is a simple exploration technique based on DQN. Besides $\epsilon$-greedy, intrinsic model exploration computes intrinsic rewards that directly measure and thereby incentivizing exploration when added to extrinsic (actual) rewards of RL, e.g. DORA \cite{fox2018dora} and \cite{stadie2015incentivizing}. Random Network Distillation (RND)~\cite{burda2018exploration} is a more recent suggestion relying on a fixed target network. A drawback of RND is its local focus without global exploration. In order to address weak points of these various exploration algorithms in the RL context, we combine EXP-type algorithms in non-stochastic bandits with deep RL. EXP-type algorithms are proven optimal in terms of regret and thereby being the best we can do with bandits. Specifically, EXP4 in contextual bandits works by integrating arbitrary experts and hence providing exploration possibilities for RL. We propose a new EXP4 variant and extend it to RL that allows for general experts. This is the first RL algorithm using several exploration experts enabling global exploration. Focusing on DQN, in the computational study we focus on two agents consisting of RND and $\epsilon$-greedy DQN. We implement the EXP4-RL algorithm on hard-to-explore RL games Montezuma's Revenge and Mountain Car and compare it with the benchmark RND \cite{burda2018exploration}. The numerical results show that the algorithm gains more exploration than RND and it gains the ability of global exploration by avoiding local maximums of RND. Its total reward also increases with training. Overall, our algorithm improves exploration on the benchmark games and demonstrates a learning process in RL. There are two classic versions of non-stochastic bandits: Adversarial and Contextual. For adversarial MAB, rewards of the $K$ arms $r^t$ can be chosen arbitrarily by adversaries at step $t$. When the adversary is a context-dependent reward generator, it boils down to contextual bandits. EXP-type algorithms \cite{auer2002nonstochastic} are optimal for non-stochastic bandits under the assumption that $0 \leq r^t_i \leq 1 $ for any arm $i$ and step $t$. Specifically, while regret for adversarial bandit achieves optimality both in the expected sense and in the high probability sense, and the expectation of regret is proven to be optimal for contextual bandit, in the later case a high probability one has not yet been studied. Furthermore, rewards in RL can be unbounded since they follow MDPs with black-box transition kernels, which violates the bounded assumption. Meanwhile, it usually takes a lot of GPU resources in RL to compute an expected regret by Monte-Carlo simulation, which shows the necessity of regret in a high probability sense with unbounded rewards We are the first to propose a new algorithm, EXP4.P based on EXP4. We show its optimal regret holds with high probability for contextual bandits under the bounded assumption. Moreover, we analyze the regret of EXP4.P even without such an assumption and report its regret upper bound is of the same order as the bounded cases. The proof extension to the unbounded case is non-trivial since it requires several deep results from information theory and probability. In addition, it uses the result of the bounded case. Combining all these together is very technical and requires new ideas. As a by-product, the result is compatible with the existing EXP3.P algorithm for unbounded MAB. The upper bound for unbounded bandits requires $T$ to be sufficiently large, i.e. unbounded rewards may lead to extremely large regret without enough exploration, which is computationally expensive in RL setting. We herein provide a worst-case analysis implying no sublinear regret can be achieved below an instance-specific minimal $T$. The bounded assumption plays an important role in the proofs of these regret bounds by the existing EXP-type algorithms. Therefore, the regret bounds for unbounded bandits studied herein are significantly different from prior works. Though a high probability regret bound has already been established for EXP3.P in adversarial bandits~\citet{auer2002nonstochastic},a high probability regret for a contextual setting poses a challenge since the regret and update of weights are conceptually different. This necessitates the new algorithm EXP4.P following some ideas from the analysis of EXP3.P and EXP4 in~\citet{auer2002nonstochastic}. We also study regret lower bounds by our brand new construction of instances. Precisely, we derive lower bounds of order $\Omega(T)$ for certain fixed $T$ and upper bounds of order $O^*(\sqrt{T})$ for $T$ being large enough. The question of bounds for any value of $T$ remains open. The main contributions of this work are as follows. On the analytical side, our work is summarized as shown in Figure 4 (see Appendix). We introduce sub-Gaussian bandits with the unique aspect and challenge of unbounded rewards both in contextual bandits and MAB. We propose a new EXP4.P algorithm based on EXP4 and EXP3.P and analytically establish its optimal regret both in unbounded and bounded cases. Unbounded rewards and contextual setting pose non-trivial challenges in the analyses. We also provide the very first regret lower bound in such a case that indicates a threshold of $T$ for sublinear regret, by constructing a novel family of Gaussian bandits. We also provide the very first extension of EXP4.P to RL exploration. This is the first work to use multiple agents for RL exploration. We show its superior performance on two hard-to-explore RL games. A literature review is provided in Section \ref{sec:2}. Then in Section \ref{section:3} we develop a new algorithm EXP4.P by modifying EXP4, and exhibit its regret bounds for contextual bandits and that of the EXP3.P algorithm for unbounded MAB, and lower bounds. Section \ref{section:4} discusses the EXP4.P algorithm for RL exploration. Finally, in Section \ref{section:5}, we present numerical results related to the proposed algorithm. \section{Literature Review} \label{sec:2} The importance of exploration in RL is well understood. Count-based exploration in RL is such a success with the UCB technique. \citet{strehl2008analysis} develop Bellman value iteration $V(s)=\max_a\hat{R}(s,a)+\gamma E[V(s^{\prime})]+ \beta N(s,a)^{-\frac{1}{2}}$, where $N(s,a)$ is the number of visits to $(s,a)$ for state $s$ and action $a$. Value $N(s,a)^{-\frac{1}{2}}$ is positively correlated with curiosity of $(s,a)$ and encourages exploration. This method is limited to tableau model-based MDP for small state spaces. While \cite{bellemare2016unifying} introduce Pseudo-Count exploration for non-tableau MDP with density models, it is hard to model. However, UCB achieves optimality if bandits are stochastic and may suffer linear regret otherwise~\cite{zuo2020near}. EXP-type algorithms for non-stochastic bandits can generalize to RL with fewer assumptions about the statistics of rewards, which have not yet been studied. In conjunction with DQN, $\epsilon$-greedy in \citet{mnih2015human} is a simple exploration technique using DQN. Besides $\epsilon$-greedy, intrinsic model exploration computes intrinsic rewards by the accuracy of a model trained on experiences. Intrinsic rewards directly measure and incentivize exploration if added to actual rewards of RL, e.g. see \citet{fox2018dora} and \citet{stadie2015incentivizing} and~\citet{burda2018exploration}. Random Network Distillation(RND) in~\citet{burda2018exploration} define it as $e(s^{\prime},a) = \Vert\hat{f}(s^{\prime})-f(s^{\prime})\Vert^2_2$ where $\hat{f}$ is a parametric model and $f$ is a randomly initialized but fixed model. Here $e(s^{\prime},a)$, independent of the transition, only depends on state $s^{\prime}$ and drives RND to outperform others on Montezuma's Revenge. None of these algorithms use several experts which is a significant departure from our work. Along the line of work on regret analyses focusing on EXP-type algorithms, \citet{auer2002nonstochastic} first introduce EXP3.P for bounded adversarial MAB and EXP4 for bounded contextual bandits. For the EXP3.P algorithm, an upper bound on regret of order $O(\sqrt{T})$ holds with high probability and in expectation, which has no gap with the lower bound and hence it establishes that EXP3.P is optimal. EXP4 is optimal for contextual bandits in the sense that its expected regret is $O(\sqrt{T})$ whereas the high probability counterpart has not yet been covered. Moreover, these regret bounds are not applicable to bandits with unbounded support. Though \citet{srinivas2010gaussian} demonstrate a regret bound of order $O(\sqrt{T \cdot \gamma_T})$ for noisy Gaussian process bandits where a reward observation contains noise, information gain $\gamma_T$ is not well-defined in a noiseless setting. For noiseless Gaussian bandits, \citet{grunewalder2010regret} show both the optimal lower and upper bounds on regret, but the regret definition is not consistent with what is used in \citet{auer2002nonstochastic}. We tackle these problems by establishing an upper bound of order $O^*(\sqrt{T})$ on regret 1) with high probability for bounded contextual bandit and 2) for sub-Gaussian bandit both in expectation and with high probability. \section{Regret Bounds} \label{section:3} We first introduce notations. Let $T$ be the time horizon. For bounded bandits, at step $t$, $0 < t \leq T$ rewards $r^t$ can be chosen arbitrarily under the condition that $ -1 \leq r_t \leq 1$. For unbounded bandits, let rewards $r^t$ follow multi-variate distribution $f_t(\mu, \Sigma)$ where $\mu=(\mu_1,\mu_2,\ldots,\mu_K)$ is the mean vector and $\Sigma=(a_{ij})_{i,j \in \{1,\ldots,K\}}$ is the covariance matrix of the $K$ arms and $f_t$ is the density. We specify $f_t$ to be non-degenerate sub-Gaussian for analyses on light-tailed distributions where $\min_j a_{j,j} >0$. A random variable $X$ is $\sigma^2$-sub-Gaussian if for any $t>0$, the tail probability satisfies $P(|X|>t) \leq Be^{-\sigma^2t^2}$ where $B$ is a positive constant. The player receives reward $y_t=r^t_{a_t}$ by pulling arm $a_t$. The regret is defined as $R_T=\max_j\sum_{t=1}^{T}r^t_j-\sum_{t=1}^{T}y_t$ in adversarial bandits that depends on realizations of rewards. For contextual bandits with experts, besides the above let $N$ be the number of experts and $c_t$ be the context information. We denote the reward of expert $i$ by $G_i = \sum_{t=1}^{T} z_i(t) = \sum_{t=1}^{T} \xi_i(t)^Tx(t)$, where $x(t) = r^t$ and $\xi_i(t) = (\xi_i^1(t), \ldots, \xi_i^K(t))$ is the probability vector of expert $i$. Then regret is defined as $R_T =\max_i{G_i} - \sum_{t=1}^{T}y_t$, which is with respect to the best expert, rather than the best arm in MAB. This is reasonable since a uniform optimal arm is a special expert assigning probability 1 to the optimal arm throughout the game and experts can potentially perform better and admit higher rewards. This coincides with our generalization of EXP4.P to RL where the experts can be well-trained neural networks. We follow established definitions of pseudo regret $R^{\prime}_T=T\cdot \max_k\mu_k-\sum_tE[y_t]$ and $\sum_{t=1}^{T} \max_i \sum_{j=1}^K\xi_i^j(t)\mu_{j} - \sum_tE[y_t]$ in adversarial and contextual bandits, respectively. \subsection{Contextual Bandits and EXP4.P Algorithm} \label{section:exp4} For contextual bandits, \citet{auer2002nonstochastic} give the EXP4 algorithm and prove its expected regret to be optimal under the bounded assumption on rewards and under the assumption that a uniform expert is always included. Our goal is to extend EXP4 to RL where rewards are often unbounded, such as several games in OpenAI gym, for which the theoretical guarantee of EXP4 may be absent. To this end, herein we propose a new Algorithm, named EXP4.P, as a variant of EXP4. Its effectiveness is two-fold. First, we show that EXP4.P has an optimal regret with high probability in the bounded case and consequently, we claim that the regret of EXP4.P is still optimal given unbounded bandits. All the proof are in the Appendix under the aforementioned assumption on experts. Second, it is successfully extended to RL where it achieves computational improvements. \subsubsection{EXP4.P Algorithm} Our proposed EXP4.P is shown as Algorithm~\ref{EXP4.P}. The main modifications compared to EXP4 lie in the update and the initialization of trust coefficients of experts. The upper bound of the confidence interval of the reward estimate is added to the update rule for each expert, in the spirit of EXP3.P (see Algorithm ~\ref{EXP3.P}). However, this term and initialization of EXP4.P are quite different from that in EXP3.P for MAB. \begin{algorithm}[H] \SetAlgoLined \caption{EXP4.P} \label{EXP4.P} Initialization: Weights $w_i(1)=\exp{(\frac{\alpha\gamma}{3K}\sqrt{NT})}, i \in \{1,2,\ldots, N\}$ for $\alpha>0$ and $\gamma\in (0,1)$\; \For{$t=1,2,\ldots,T$}{ Get probability vectors $\xi_{1}(t),\ldots,\xi_{N}(t)$ of arms from experts where $\xi_{i}(t) = (\xi_{i}^{j}(t))_j$; \For{$j =1,2,\ldots,K$}{ $p_j(t)=(1-\gamma)\sum_{i=1}^{N}\dfrac{w_i(t)\cdot \xi_{i}^{j}(t)}{\sum_{j=1}^{N} w_j(t)}+\frac{\gamma}{K}$} Choose $i_t$ randomly according to the distribution $p_1(t),\ldots, p_K(t)$\; Receive reward $r_{i_t}(t) = x_{i_t}(t)$\; \For{$j=1,\ldots,K$}{ $\hat{x}_j(t) = \frac{r_j(t)}{p_j(t)} \cdot \mathds{1}_{j=i_t}$ } $\hat{x}(t) = (\hat{x}_j(t))_j$\; \For{$i = 1,\ldots,N$}{ $\hat{z}_i(t) = \xi_{i}(t)^T\hat{x}(t)$, $w_i(t+1) = w_i(t) \exp(\frac{\gamma}{3K}(\hat{z}_i(t)+\frac{\alpha}{(\frac{w_i(t)}{\sum_{j=1}^{N} w_j(t)}+ \frac{\gamma}{K} )\sqrt{NT}}))$} } \end{algorithm} \subsubsection{Bounded Rewards} Borrowing the ideas of~\citet{auer2002nonstochastic}, we claim EXP4.P has an optimal sublinear regret with high probability by first establishing two lemmas presented in Appendix. The main theorem is as follows. We assume the expert family includes a uniform expert that always assigns equal probability to each arm. \begin{theorem} \label{thm:highp} Let $0 \leq r^t \leq 1$ for every $t$. For any fixed time horizon $T > 0$, for all $K, \, N \geq 2$ and for any $ 1 > \delta > 0$, $\gamma = \sqrt{\frac{3K\ln{N}}{T(\frac{2N}{3} + 1) }} \leq \frac{1}{2}$, $\alpha = 2\sqrt{K\ln{\frac{NT}{\delta}}}$, we have that with probability at least $1-\delta$, \begin{center} $ R_T \leq 2\sqrt{3KT\left(\frac{2N}{3}+1\right)\ln{N}} + 4K\sqrt{KNT\ln{\left(\frac{NT}{\delta}\right)}} + 8NK\ln{\left(\frac{NT}{\delta}\right)}. $ \end{center} \end{theorem} Note that $\gamma < \frac{1}{2}$ for large enough $T$. The proof of Theorem~\ref{thm:highp} essentially combines Lemma 1 and Lemma 2 together, similar to that in~\citet{auer2002nonstochastic}. However, Lemma 1 and Lemma 2 themselves are different from those of ~\citet{auer2002nonstochastic}, which characterize the relationships among EXP4.P estimates and the actual value of experts' rewards and the total rewards gained by EXP4.P. Since our estimations and update of trust coefficients in EXP4.P are for experts, instead of EXP3.P for arms, it brings non-trivial challenges. Theorem~\ref{thm:highp} implies $R_T \leq O^*(\sqrt{T})$ \subsubsection{Unbounded Rewards} We proceed to show optimal regret bounds of EXP4.P for unbounded contextual bandit. Again, a uniform expert is assumed to be included in the expert family. Surprisingly, we report that the analysis can be adapted to the existing EXP3.P in next section, which leads to optimal regret in MAB under no bounded assumption which is also a new result. \begin{theorem}\label{th:5_new} For sub-Gaussian bandits, any time horizon $T$, for any $0<\eta<1$, $0 < \delta < 1$ and $\gamma,\alpha$ as in Theorem~\ref{thm:highp}, with probability at least $(1-\delta) \cdot (1-\eta)^T$, EXP4.P has regret \begin{center} $R_{T} \leq 4 \Delta(\eta) \left(2\sqrt{3KT\left(\frac{2N}{3}+1\right)\ln{N}} + 4K\sqrt{KNT\ln{\left(\frac{NT}{\delta}\right)}} + 8NK\ln{\left(\frac{NT}{\delta}\right)}\right) $ \end{center} where $\Delta(\eta)$ is determined by $\int_{-\Delta}^{\Delta} \ldots \int_{-\Delta}^{\Delta} f\left(x_{1}, \ldots, x_{K}\right) d x_{1} \ldots d{x_{K}}=1-\eta.$ \end{theorem} In the proof of Theorem \ref{th:5_new}, we first perform truncation of the rewards of sub-Gaussian bandits by dividing the rewards to a bounded part and unbounded tail. For the bounded part, we directly apply the upper bound on regret of EXP4.P presented in Theorem~\ref{thm:highp} and conclude with the regret upper bound of order $O(\Delta(\eta)\sqrt{T})$. Since a sub-Gaussian distribution is a light-tailed distribution we can control the probability of the tail, i.e. the unbounded part, which leads to the overall result. The dependence of the bound on $\Delta$ can be removed by considering large enough $T$ as stated next. \begin{theorem} \label{th:6_new} For sub-Gaussian bandits, for any $a>2$, $0<\delta <1$, and $\gamma,\alpha$ as in Theorem~\ref{thm:highp}, EXP4.P has regret $R_{T} \leq \log(1/\delta) O^*(\sqrt{T})$ with probability $(1-\delta) \cdot (1-\frac{1}{T^a})^T. $ \end{theorem} Note that the constant term in $O^*(\cdot)$ depends on $a$. The above theorems deal with $R_T$; an upper bound on pseudo regret or expected regret is established next. It is easy to verify by the Jensen's inequality that $R^{\prime}_T \leq E[R_T]$ and thus it suffices to obtain an upper bound on $E[R_T]$. For bounded bandits, the upper bound for $E[R_T]$ is of the same order as $R_T$ which follows by a simple argument. For sub-Gaussian bandits, establishing an upper bound on $E[R_T]$ or $R^{\prime}_T$ based on $R_T$ requires more work. We show an upper bound on $E[R_T]$ by using certain inequalities, limit theories, and Randemacher complexity. To this end, the main result reads as follows. \begin{theorem} \label{th:7_new} The regret of EXP4.P for sub-Gaussian bandits satisfies $R_T^{\prime} \leq E\left[R_{T}\right] \leq O^*(\sqrt{T})$ under the assumptions stated in Theorem~\ref{th:6_new}. \end{theorem} \subsection{MAB and EXP3.P Algorithm} \label{section:exp3} In this section, we establish upper bounds on regret in MAB given a high probability regret bound achieved by EXP3.P in \citet{auer2002nonstochastic}. We revisit EXP3.P and analyze its regret in unbounded scenarios in line with EXP4.P. Formally, we show that EXP3.P achieves regret of order $O^*(\sqrt{T})$ in sub-Gaussian MAB, with respect to $R_T$, $E[R_T]$ and $R^{\prime}_T$. The results are summarized as follows. \begin{theorem} \label{th:5} For sub-Gaussian MAB, any $T$, for any $0<\eta ,\delta<1$, $\gamma = 2\sqrt{\frac{3K\ln{K}}{5T}}$, $\alpha = 2\sqrt{\ln{\frac{NT}{\delta}}}$, EXP3.P has regret $R_{T} \leq 4 \Delta(\eta)\cdot ( \sqrt{KT\log(\frac{KT}{\delta})}+4\sqrt{\frac{5}{3}KT\log K}+8\log(\frac{KT}{\delta})) $ with probability $(1-\delta) \cdot (1-\eta)^T$. Value $\Delta(\eta)$ satisfies $\int_{-\Delta}^{\Delta} \ldots \int_{-\Delta}^{\Delta} f\left(x_{1}, \ldots, x_{K}\right) d x_{1} \ldots d{x_{K}}=1-\eta.$ \end{theorem} To proof Theorem \ref{th:5}, we again do truncation. We apply the bounded result of EXP3.P in~\citet{auer2002nonstochastic} and achieve a regret upper bound of order $O(\Delta(\eta)\sqrt{T})$. The proof is similar to the proof of Theorem~\ref{th:5_new} for EXP4.P. Similarly, we remove the dependence of the bound on $\Delta$ in Theorem~\ref{th:6} and claim a bound on the expected regret for sufficiently large $T$ in Theorem~\ref{th:7}. \vspace{-4mm} \begin{algorithm}[h] \SetAlgoLined \caption{EXP3.P} \label{EXP3.P} Initialization: Weights $w_i(1)=\exp{(\frac{\alpha\gamma}{3}\sqrt{\frac{T}{K}})}, i \in \{1,2,\ldots, K\}$ for $\alpha>0$ and $\gamma\in (0,1)$\; \For{$t=1,2,\ldots,T$}{ \For{$i =1,2,\ldots,K$}{ $p_i(t)=(1-\gamma)\frac{w_i(t)}{\sum_{j=1}^Kw_j(t)}+\frac{\gamma}{K}$} Choose $i_t$ randomly according to the distribution $p_1(t),\ldots, p_K(t)$\; Receive reward $r_{i_t}(t)$\; \For{$j=1,\ldots,K$}{ $\hat{x}_j(t) = \frac{r_j(t)}{p_j(t)} \cdot \mathds{1}_{j=i_t}$,\quad $w_j(t+1) = w_j(t) \exp{\frac{\gamma}{3K}(\hat{x}_j(t)+\frac{\alpha}{p_j(t)\sqrt{KT}})}$ } } \end{algorithm} \vspace{-3.5mm} \begin{theorem} \label{th:6} For sub-Gaussian MAB, for $a>2$, $0<\delta <1$, and $\gamma,\alpha$ as in Theorem~\ref{th:5}, EXP3.P has regret $R_{T} \leq \log(1/\delta) O^*(\sqrt{T})$ with probability $(1-\delta) \cdot (1-\frac{1}{T^a})^T. $ \end{theorem} \begin{theorem} \label{th:7} The regret of EXP3.P in sub-Gaussian MAB satisfies $R^{\prime}_T \le E\left[R_{T}\right] \leq O^*(\sqrt{T})$ with the same assumptions as in Theorem~\ref{th:6}. \end{theorem} \subsection{Lower Bounds on Regret} \label{section:lower_bound} Algorithms can suffer extremely large regret without enough exploration when playing unbounded bandits given small $T$. To argue that our bounds on regret are not loose, we derive a lower bound on the regret for sub-Gaussian bandits that essentially suggests that no sublinear regret can be achieved if $T$ is less than an instance-dependent bound. The main technique is to construct instances that have certain regret, no matter what strategies are deployed. We need the following assumption. \paragraph{Assumption 1} There are two types of arms with general $K$ with one type being superior ($S$ is the set of superior arms) and the other being inferior ($I$ is the set of inferior arms). Let $1-q,q$ be the proportions of the superior and inferior arms, respectively which is known to the adversary and clearly $0\le q\le 1$. The arms in $S$ are indistinguishable and so are those in $I$. The first pull of the player has two steps. First the player selects an inferior or superior set of arms based on $P(S) = 1-q, P(I)= q$ and once a set is selected, the corresponding reward of an arm from the selected set is received. An interesting special case of Assumption 1 is the case of two arms and $q=1/2$. In this case, the player has no prior knowledge and in the first pull chooses an arm uniformly at random. The lower bound is defined as $R_L(T)=\inf \sup R^{\prime}_T$, where, first, $\inf$ is taken among all the strategies and then $\sup$ is among all Gaussian MAB. The following is the main result for lower bounds based on inferior arms being distributed as $\mathcal{N}(0,1)$ and superior as $\mathcal{N}(\mu,1)$ with $\mu > 0$. \begin{theorem} \label{Th:2} In Gaussian MAB under Assumption 1, for any $q\ge 1/3$ we have $R_L(T) \geq (q-\epsilon) \cdot \mu \cdot T$, where $\mu$ has to satisfy $G(q,\mu)<q$ with $\epsilon$ and $T$ determined by $G(q,\mu) <\epsilon <q, T\leq \frac{\epsilon-G(q,\mu)}{(1-q) \cdot \int\left|e^{-\frac{x^2}{2}}-e^{-\frac{(x-\mu)^2}{2}}\right|}+2$ and $G(q,\mu)=\max \left\{\int\left|qe^{-\frac{x^2}{2}}-(1-q)e^{-\frac{(x-\mu)^2}{2}}\right| dx, \int\left|(1-q)e^{-\frac{x^2}{2}}-qe^{-\frac{(x-\mu)^2}{2}}\right| dx\right\}.$ \end{theorem} To prove Theorem \ref{Th:2}, we construct a special subset of Gaussian MAB with equal variances and zero covariances. On these instances we find a unique way to explicitly represent any policy. This builds a connection between abstract policies and this concrete mathematical representation. Then we show that pseudo regret $R^{\prime}_T$ must be greater than certain values no matter what policies are deployed, which indicates a regret lower bound on this subset of instances. Feasibility of the aforementioned conditions is established in the following theorem. \begin{theorem} \label{thm:new} In Gaussian MAB under Assumption 1, for any $q \ge 1/3$, there exist $\mu$ and $\epsilon, \epsilon < \mu$ such that $ R_L(T)\ge (q-\epsilon) \cdot \mu \cdot T$. \end{theorem} The following result with two arms and equal probability in the first pull deals with general MAB. It shows that for any fixed $\mu>0$ there is a minimum $T$ and instances of MAB so that no algorithm can achieve sublinear regret. Table 1 (see Appendix) exhibits how the threshold of $T$ varies with $\mu$ \begin{theorem}\label{coro:2} For general MAB under Assumption 1 with $K=2,q=1/2$, we have that $R_L(T) \geq \frac{T \cdot \mu}{4}$ holds for any distributions $f_0$ for the arms in $I$ and $f_1$ for the arms in $S$ with $\int |f_1-f_0| > 0$ (possibly with unbounded support), for any $\mu > 0$ and $T$ satisfying $T\leq \frac{1}{2 \cdot \int\left|f_0-f_1\right|}+1.$ \end{theorem} \section{EXP4.P Algorithm for RL} \label{section:4} EXP4 has shown effectiveness in contextual bandits with statistical validity. Therefore, in this section, we extend EXP4.P to RL in Algorithm \ref{exp4_rl} where rewards are assumed to be nonnegative. The player has experts that are represented by deep $Q$-networks trained by RL algorithms (there is a one to one correspondence between the experts and $Q$-networks). Each expert also has a trust coefficient. Trust coefficients are also updated exponentially based on the reward estimates as in EXP4.P. At each step of one episode, the player samples an expert ($Q$-network) with probability that is proportional to the weighted average of expert's trust coefficients. Then $\epsilon$-greedy DQN is applied on the chosen $Q$-network. Here different from EXP4.P, the player needs to store all the interaction tuples in the experience buffer since RL is a MDP. After one episode, the player trains all $Q$-networks with the experience buffer and uses the trained networks as experts for the next episode. \vspace{-3mm} \begin{algorithm}[ht] \SetAlgoLined \caption{EXP4-RL} \label{exp4_rl} Initialization: Trust coefficients $w_k=1$ for any $k\in \{1,\dots,E\}$, $E=$ number of experts ($Q$-networks), $K=$ number of actions, $\Delta,\epsilon,\eta>0$ and temperature $z,\tau>0$, $n_r=-\infty$ (an upper bound on reward)\; \While{True}{ Initialize episode by setting $s_0$\; \For{$i=1,2,\dots,T$\text{(length of episode)}}{ Observe state $s_{i}$\; Let probability of $Q_k$-network be $\rho_k=(1-\eta)\frac{w_k}{\sum_{j=1}^E w_j}+\frac{\eta}{E}$\; Sample network $\bar{k}$ according to $\{\rho_k\}_k$\; For $Q_{\bar{k}}$-network, use $\epsilon$-greedy to sample an action \begin{equation*} a^{*}=argmax_{a}Q_{\bar{k}}(s_i,a),\qquad \pi_{j} = (1-\epsilon)\cdot \mathds{1}_{j=a^{*}} + \frac{\epsilon}{K-1} \cdot \mathds{1}_{j \neq a^*}\qquad j \in \{1,2,\ldots,K\} \end{equation*} Sample action $a_i$ based on $\pi$\; Interact with the environment to receive reward $r_i$ and next state $s_{i+1}$\; $n_r=\max\{r_i,n_r\}$\; Update the trust coefficient $w_k$ of each $Q_k$-network as follows: \begin{equation*} P_{k}=\epsilon\text{-greedy}(Q_k),\> \hat{x}_{kj}=1-\frac{\mathds{1}_{j=a^*}}{P_{kj}+\Delta}(1 - \frac{r_i}{n_r}),\> j \in {1,2,\dots, K}, \> y_k=E[\hat{x}_{kj}],\> w_k=w_k \cdot e^{\frac{y_k}{z}} \end{equation*} Store ($s_i,a_i,r_i,s_{i+1}$) in experience replay buffer $B$\; } Update each expert's $Q_k$-network from buffer $B$\; } \end{algorithm} \vspace{-4mm} The basic idea is the same as in EXP4.P by using the experts that give advice vectors with deep $Q$-networks. It is a combination of deep neural networks with EXP4.P updates. From a different point of view, we can also view it as an ensemble in classification \cite{xia2011ensemble}, by treating $Q$-networks as ensembles in RL. While general experts can be used, these are natural in a DQN framework. In our implementation and experiments we use two experts, thus $E=2$ with two $Q$-networks. The first one is based on RND \cite{burda2018exploration} while the second one is a simple DQN. To this end, in the algorithm before storing to the buffer, we also record $c^i_r=||\hat{f}(s_{i})-f(s_{i})||^2$, the RND intrinsic reward as in \citet{burda2018exploration}. This value is then added to the 4-tuple pushed to $B$. When updating $Q_1$ corresponding to RND at the end of an iteration in the algorithm, by using $r_j+c^j_r$ we modify the $Q_1$-network and by using $c^j_r$ an update to $\hat{f}$ is executed. Network $Q_2$ pertaining to $\epsilon$-greedy is updated directly by using $r_j$. Intuitively, Algorithm \ref{exp4_rl} circumvents RND's drawback with the total exploration guided by two experts with EXP4.P updated trust coefficients. When the RND expert drives high exploration, its trust coefficient leads to a high total exploration. When it has low exploration, the second expert DQN should have a high one and it incentivizes the total exploration accordingly. Trust coefficients are updated by reward estimates iteratively as in EXP4.P, so they keep track of the long-term performance of experts and then guide the total exploration globally. These dynamics of EXP4.P combined with intrinsic rewards guarantee global exploration. The experimental results exhibited in the next section verify this intuition regarding exploration behind Algorithm \ref{exp4_rl}. We point out that potentially more general RL algorithms based on $Q$-factors can be used, e.g., boostrapped DQN \cite{osband2016deep}, random prioritized DQN \cite{osband2018randomized} or adaptive $\epsilon$-greedy VDBE \cite{tokic2010adaptive} are a possibility. Furthermore, experts in EXP4 can even be policy networks trained by PPO \cite{schulman2017proximal} instead of DQN for exploration. These possibilities demonstrate the flexibility of the EXP4-RL algorithm. \section{Computational Study} \label{section:5} As a numerical demonstration of the superior performance and exploration incentive of Algorithm~\ref{exp4_rl}, we show the improvements on baselines on two hard-to-explore RL games, Mountain Car and Montezuma's Revenge. More precisely, we present that the real reward on Mountain Car improves significantly by Algorithm~\ref{exp4_rl} in Section~\ref{section:5.1}. Then we implement Algorithm~\ref{exp4_rl} on Montezuma's Revenge and show the growing and remarkable improvement of exploration in Section~\ref{section:5.2}. \iffalse For the Mountain Car experiment, we use the Adam optimizer with the $2\cdot 10^{-4}$ learning rate. The batch size for updating models is 64 with the replay buffer size of 10,000. The remaining parameters are as follows: the discount factor for the $Q$-networks is 0.95, the temperature parameter $\tau$ is 0.1, $\eta$ is 0.05, and $\epsilon$ is decaying exponentially with respect to the number of steps with maximum 0.9 and minimum 0.05. The length of one epoch is 200 steps. The target networks load the weights and biases of the trained networks every 400 steps. Since a reward upper bound is known in advance, we use $n_r=1$. For the Montezuma's Revenge experiment, we use the Adam optimizer with the $10^{-5}$ learning rate. The other parameters read: the mini batch size is 4, replay buffer size is 1,000, the discount factor for the $Q$-networks is 0.999 and the same valus is used for the intrinsic value head, the temperature parameter $\tau$ is 0.1, $\eta$ is 0.05, and $\epsilon$ is increasing exponentially with minimum 0.05 and maximum 0.9. The length of one epoch is 100 steps. Target networks are updated every 300 steps. Pre-normalization is 50 epochs and the weights for intrinsic and extrinsic values in the first network are 1 and 2, respectively. The upper bound on reward is set to be constant $n_r=1$. \fi Intrinsic reward $c^i_r=||\hat{f}(s_{i})-f(s_{i})||^2$ given by intrinsic model $\hat{f}$ represents the exploration of RND in \citet{burda2018exploration} as introduced in Sections \ref{sec:2} and \ref{section:4}. We use the same criterion for evaluating exploration performance of our algorithm and RND herein. RND incentivizes local exploration with the single step intrinsic reward but with the absence of global exploration. \subsection{Mountain Car} \label{section:5.1} In this part, we summarize the experimental results of Algorithm \ref{exp4_rl} on Mountain Car, a classical control RL game. This game has very sparse positive rewards, which brings the necessity and hardness of exploration. Blog post \cite{orrivlin2019} shows that RND based on DQN improves the performance of traditional DQN, since RND has intrinsic reward to incentivize exploration. We use RND on DQN from \citet{orrivlin2019} as the baseline and show the real reward improvement of Algorithm \ref{exp4_rl}, which supports the intuition and superiority of the algorithm. \iffalse The neural networks of both experts are linear. For the RND expert, it has the input layer with 2 input neurons, followed by a hidden layer with 64 neurons, and then a two-headed output layer. The first output layer represents the $Q$ values with 64 hidden neurons as input and the number of actions output neurons, while the second output layer corresponds to the intrinsic values, with 1 output neuron. For the DQN expert, the only difference lies in the absence of the second output layer. \fi The comparison between Algorithm \ref{exp4_rl} and RND is presented in Figure \ref{fig:3}. Here the x-axis is the epoch number and the y-axis is the cumulative reward of that epoch. Figure \ref{fig3:subim3_1} shows the raw data comparison between EXP4-RL and RND. We observe that though at first RND has several spikes exceeding those of EXP4-RL, EXP4-RL has much higher rewards than RND after 300 epochs. Overall, the relative difference of areas under the curve (AUC) is 4.9\% for EXP4-RL over RND, which indicates the significant improvement of our algorithm. This improvement is better illustrated in Figure \ref{fig3:subim3_2} with the smoothed reward values. Here there is a notable difference between EXP4-RL and RND. Note that the maximum reward hit by EXP4-RL is $-86$ and the one by RND is $-118$, which additionally demonstrates our improvement on RND. We conclude that Algorithm \ref{exp4_rl} performs better than the RND baseline and that the improvement increases at the later training stage. Exploration brought by Algorithm \ref{exp4_rl} gains real reward on this hard-to-explore Mountain Car, compared to the RND counterpart (without the DQN expert). The power of our algorithm can be enhanced by adopting more complex experts, not limited to only DQN. \subsection{Montezuma's Revenge and Pure exploration setting} \label{section:5.2} In this section, we show the experimental details of Algorithm \ref{exp4_rl} on Montezuma's Revenge, another notoriously hard-to-explore RL game. The benchmark on Montezuma's Revenge is RND based on DQN which achieves a reward of zero in our environment (the PPO algorithm reported in \citet{burda2018exploration} has reward 8,000 with many more computing resources; we ran the PPO-based RND with 10 parallel environments and 800 epochs to observe that the reward is also 0), which indicates that DQN has room for improvement regarding exploration. To this end, we first implement the DQN-version RND (called simply RND hereafter) on Montezuma's Revenge as our benchmark by replacing the PPO with DQN. Then we implement Algorithm \ref{exp4_rl} with two experts as aforementioned. Our computing environment allows at most 10 parallel environments. In subsequent figures the x-axis always corresponds to the number of epochs. RND update probability is the proportion of experience that are used for training the intrinsic model $\hat{f}$~\cite{burda2018exploration}. \iffalse We use CNN architectures since we are dealing with videos. More precisely, for the $Q$-network of the DQN expert in EXP4-RL and the predictor network $\hat{f}$ for computing the intrinsic rewards, we use Alexnet \citet{krizhevsky2012imagenet} pretrained on ImageNet \citet{deng2009imagenet}. The number of output neurons of the final layer is 18, the number of actions in Montezuma. For the RND baseline and RND expert in EXP4-RL, we customize the $Q$-network with different linear layers while keeping all the layers except the final layer of pretrained Alexnet. Here we have two final linear layers representing two value heads, the extrinsic value head and the intrinsic value head. The number of output neurons in the first value head is again 18, while the second value head is with 1 output neuron. \fi A comparison between Algorithm \ref{exp4_rl} (EXP4-RL) and RND without parallel environments (the update probability is 100\% since it is a single environment) is shown in Figure \ref{fig:1} with the emphasis on exploration by means of the intrinsic reward. We use 3 different numbers of burn-in periods (58, 68, 167 burn-in epochs) to remove the initial training steps, which is common in Gibbs sampling. Overall EXP4-RL outperforms RND with many significant spikes in the intrinsic rewards. The larger the number of burn-in periods is, the more significant is the dominance of EXP4-RL over RND. EXP4-RL has much higher exploration than RND at some epochs and stays close to RND at other epochs. At some epochs, EXP4-RL even has 6 times higher exploration. The relative difference in the areas under the curves are 6.9\%, 17.0\%, 146.0\%, respectively, which quantifies the much better performance of EXP4-RL. \vspace{-8mm} \begin{figure}[ht] \noindent\begin{minipage}[b]{.4\textwidth} \centering \subfloat[original]{\includegraphics[width=0.45\linewidth, keepaspectratio]{Figures/Mountain_1_2.png}\label{fig3:subim3_1}} \subfloat[smooth]{\includegraphics[width=0.45\linewidth, keepaspectratio]{Figures/Mountain_1_1.png}\label{fig3:subim3_2}} \caption{The performance of Algorithm \ref{exp4_rl} and RND measured by the epoch-wise reward on Mountain Car} \label{fig:3} \end{minipage}% \quad \begin{minipage}[b]{.6\textwidth} \subfloat[small]{\includegraphics[width=0.3\linewidth, keepaspectratio]{Figures/Figure_1_1_rescale.png}\label{fig1:subim1}} \subfloat[medium]{\includegraphics[width=0.3\linewidth, keepaspectratio]{Figures/Figure_1_2.png}\label{fig1:subim2}} \subfloat[large]{\includegraphics[width=0.3\linewidth, keepaspectratio]{Figures/Figure_1_3.png}\label{fig1:subim3}} \caption{The performance of Algorithm \ref{exp4_rl} and RND measured by intrinsic reward without parallel environments with three different burn-in periods} \label{fig:1} \end{minipage}\par\medskip \vspace{-7.5mm} \centering \subfloat[$Q$-network losses with \hfill \break 0.25 update]{\includegraphics[width=0.25\linewidth, keepaspectratio]{Figures/EXP4_10_worker.png}\label{fig2:subim1}} \quad \subfloat[Intrinsic reward after \hfill \break \indent smoothing with 0.25 update]{\includegraphics[width=0.25\linewidth, keepaspectratio]{Figures/Figure_2_2.png}\label{fig2:subim3}} \quad \subfloat[Intrinsic reward after \hfill \break \hfill smoothing with 0.125]{\includegraphics[width=0.25\linewidth, keepaspectratio]{Figures/Figure_2_3.png}\label{fig3:subim2}} \caption{The performance of Algorithm \ref{exp4_rl} and RND with 10 parallel environments and with RND update probability 0.25 and 0.125, measured by loss and intrinsic reward.} \label{fig:2} \end{figure} \vspace{-3.5mm} We next compare EXP4-RL and RND with 10 parallel environments and different RND update probabilities in Figure \ref{fig:2}. The experiences are generated by the 10 parallel environments. Figure \ref{fig2:subim1} shows that both experts in EXP4-RL are learning with decreasing losses of their $Q$-networks. The drop is steeper for the RND expert but it starts with a higher loss. With RND update probability 0.25 in Figure \ref{fig2:subim3} we observe that EXP4-RL and RND are very close when RND exhibits high exploration. When RND is at its local minima, EXP4-RL outperforms it. Usually these local minima are driven by sticking to local maxima and then training the model intensively at local maxima, typical of the RND local exploration behavior. EXP4-RL improves on RND as training progresses, e.g. the improvement after 550 epochs is higher than the one between epochs 250 and 550. In terms for AUC, this is expressed by 1.6\% and 3.5\%, respectively. Overall, EXP4-RL improves RND local minima of exploration, keeps high exploration of RND and induces a smoother global exploration. With the update probability of 0.125 in Figure \ref{fig3:subim2}, EXP4-RL almost always outperforms RND with a notable difference. The improvement also increases with epochs and is dramatically larger at RND's local minima. These local minima appear more frequently in training of RND, so our improvement is more significant as well as crucial. The relative AUC improvement is 49.4\%. The excellent performance in Figure \ref{fig3:subim2} additionally shows that EXP4-RL improves RND with global exploration by improving local minima of RND or not staying at local maxima. Overall, with either 0.25 or 0.125, EXP4-RL incentivizes global exploration on RND by not getting stuck in local exploration maxima and outperforms RND exploration aggressively. With 0.125 the improvement with respect to RND is more significant and steady. This experimental evidence verifies our intuition behind EXP4-RL and provides excellent support for it. With experts being more advanced RL exploration algorithms, e.g. DORA, EXP4-RL can bring additional possibilities. \iffalse \textcolor{red}{Upper bound and lower bound,especially check the lower bound part and re-paraphrase the section since its position or connection with other parts change a little bit. Double check the upper bound part, everything that is put in appendix should have a sentence in main paper.} \textcolor{red}{Whether we can put the details of EXP3.P in Appendix since it's already elaborated in the paper of Auer.} \textcolor{red}{Whether we should first introduce EXP3.P and then our EXP4.P algorithm which says its connection with EXP4.P. EXP3.P, EXP4.P, regret in EXP4.P, regret in EXP3.P; need a little bit more words on how EXP4.P is come up with. } \textcolor{red}{Whether we should add discussions about noisy gaussian process; Lower bound essentially says time horizon should be large enough to guarantee the existence of no-regret algorithms.} \textcolor{red}{Whether we should cut off the literature review part since it has much overlap with the introduction part; Continue working on the introduction part; polish the abstract; highlight that we propose a algorithm for contextual bandits in bounded case with high probability, in unbounded case especially sub-gaussian. Would it be a future direction to study heavier tailed distribution like sub-exponential? Large-scale deviation.; The part regarding MAB is actually a by-product and has not too much difference compared to the result in Auer.} \textcolor{red}{Whether to mention that Auer analyze UCB in Gaussian setting; Whether to put it in the literature review.} \textcolor{red}{Work on the elaborations on tables and figures} \textcolor{red}{The lower bound result should be added to literature review, actually the result is essentially about the bound assumption.} \fi \newpage \medskip
{'timestamp': '2022-06-01T02:08:46', 'yymm': '2009', 'arxiv_id': '2009.09538', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09538'}
arxiv
\section{Introduction} \label{sec:int} Modern machine learning algorithms should not assume that they will deal with finite, closed collections of data. Contemporary data sources generate new information constantly and at a high speed. This combination of velocity and volume gave birth to the notion of data streams that constantly expand and flood the computing system \citep{Bifet:2019}. Data stream cannot be stored in memory and must be analyzed on the fly, without latency that may reduce the responsiveness and lead to a bottleneck. Such characteristics pose new challenges for machine learning algorithms. They need not only to display a high predictive accuracy, but also be capable of fast incorporation of new information, being computationally lightweight and responsive. The recent COVID-19 pandemic is an example of such a scenario, where models needed to be updated daily, whenever new information become available \citep{Chatterjee:2020a}. Due to the novelty of this disease and scarce access to ground truth, any new confirmed data was extremely valuable and updating the predictive model was of crucial importance. Efficient learning from data streams calls for such algorithms that can incorporate new data without a need for being retrained from scratch. Furthermore, algorithms dedicated to data stream mining problems must take into account the possibility of dealing with dynamic and non-stationary distributions \citep{Ditzler:2015}. Properties of data may change over time, making previously trained model outdated and forcing constant adaptation to changes. The ever-changing nature of data streams is known as concept drift. Concept drift can originate from the changes in underlying data generators (e.g., class distributions) or simply from having a lack of access to truly stable and well-defined collections of instances \citep{Lu:2019}. The former is the most common case, where the problem under consideration is subject to non-stationary changes and shifts in its nature. Recommendation systems are excellent examples of such naturally occurring drifts, as the tastes of users may change over time. An example of more rapid changes would include a sensor network, where one of the sensors becomes suddenly damaged and the entire system needs to adapt to the new situation \citep{Liu:2017}. The latter case is strongly connected with the problem of limited access to ground truth in data streams \citep{Masud:2011}. As we deal with constantly arriving instances, it may be impossible to provide a label for every one of them. Therefore, this becomes a problem of managing budget (how many instances can we afford to analyze and label) and time (how quickly are we able to label selected instances) \citep{Lughofer:2017}. Here, concept drift can be seen as a byproduct of the exploration-exploitation trade-off, where as we learn more about the underlying distributions, we need to update the previous models accordingly \citep{Korycki:2017}. While there is a plethora of methods dedicated to explicit or implicit concept drift detection, they all assume that the occurrence of the drift originates purely in the underlying changes in data sources \citep{Sethi:2018}. But what would happen if we considered the potential presence of a malicious party, aiming at attacking our data stream mining system \citep{Biggio:2018}? Adversarial learning in the presence of malicious data and poisoning attacks recently gained a significant attention \citep{Miller:2020}. However, this area of research focuses on dealing with corrupted training/testing sets \citep{Biggio:2012,Xiao:2015} and handling potentially dangerous instances present there \citep{Umer:2019}. Creating artificial adversarial instances \citep{Gao:2020} or using evasion \citep{Mahloujifar:2019} are considered as the most efficient approaches. The adversarial learning set-up has rarely been discussed in the data stream context, where adversarial instances may be injected into the stream at any point. One should consider the dangerous potential of introducing adversarial concept drift into the stream. Such a fake change may either lead to a premature and unnecessary adaptation to false changes, or slow down the adaptation to the real concept drift. Analyzing the presence of adversarial data and poisoning attack in the streaming setting is a challenging, yet important direction towards making modern machine learning systems truly robust. \smallskip \noindent \textbf{Goal of the paper.} To develop concept drift detector capable of efficient change detection, while being robust to adversarial and poisoning attacks that inject fake concept drifts. \smallskip \noindent \textbf{Summary of the content.} In this paper, we propose a holistic analysis of the adversarial concept drift problem, together with a robust framework for handling poisoning attacks coming from data streams. We discuss the nature of adversarial concept drift and introduce a taxonomy of different types of possible attacks -- based on poisoning instances or entire concepts. This allows us to understand the nature of the problem and gives a foundation for formulating a robust concept drift detector. We achieve this by introducing a novel and trainable drift detector based on Restricted Boltzmann Machine. It is capable of learning the compressed properties of the current state of stream and using a reconstruction error to detect the presence of concept drifts. In order to make it robust to adversarial and corrupted instances, we use a robust online gradient descent approach, together with a dedicated energy function used in our neural network. Finally, we introduce Relative Loss of Robustness -- a new measure for evaluating the robustness of concept drift detectors to varying levels of adversarial instances injected into the data stream. \smallskip \noindent \textbf{Main contributions.} This paper offers the following contributions to the field of learning from drifting data streams: \begin{itemize} \item \textbf{Taxonomy of adversarial concept drifts:} we discuss the potential nature of poisoning attacks that may result in adversarial concept drift occurrence and their influence on drift detectors. We also formulate scenarios that can be used to evaluate the robustness of an algorithm dedicated to data stream mining. \smallskip \item \textbf{Robust concept drift detector:} we introduce a novel drift detector based on Restricted Boltzmann Machine that is augmented with robust online gradient procedure and dedicated energy function to alleviate the influence of poisoned instances on the detector. \smallskip \item \textbf{Measure of robustness to adversarial drift:} we propose Relative Loss of Robustness, an aggregated measure used to analyze the effects of various levels of adversarial drifts injected into the stream. \smallskip \item \textbf{Extensive experimental study:} we evaluate the robustness of the proposed and state-of-the-art drift detectors, using a carefully designed experimental test bed that involves fully and sparsely labeled data stream benchmarks. \end{itemize} \section{Data stream mining} \label{sec:dsm} Data stream is defined as a sequence ${<S_1, S_2, ..., S_n,...>}$, where each element $S_j$ is a new instance. In this paper, we assume the (partially) supervised learning scenario with classification task and thus we define each instance as $S_j \sim p_j(x^1,\cdots,x^d,y) = p_j(\mathbf{x},y)$, where $p_j(\mathbf{x},y)$ is a joint distribution of the $j$-th instance, defined by a $d$-dimensional feature space and assigned to class $y$. Each instance is independent and drawn randomly from a probability distribution $\Psi_j (\mathbf{x},y)$. \smallskip \noindent \textbf{Concept drift.} When all instances come from the same distribution, we deal with a stationary data stream. In real-world applications data very rarely falls under stationary assumptions \citep{Masegosa:2020}. It is more likely to evolve over time and form temporary concepts, being subject to concept drift \citep{Lu:2019}. This phenomenon affects various aspects of a data stream and thus can be analyzed from multiple perspectives. One cannot simply claim that a stream is subject to the drift. It needs to be analyzed and understood in order to be handled adequately to specific changes that occur \citep{Goldenberg:2019,Goldenberg:2020}. More precise approaches may help us achieving faster and more accurate adaptation \citep{Shaker:2015}. Let us now discuss the major aspects of concept drift and its characteristics. \smallskip \noindent \textbf{Influence on decision boundaries}. Firstly, we need to take into account how concept drift impacts the learned decision boundaries, distinguishing between real and virtual concept drifts \citep{Oliveira:2019}. The former influences previously learned decision rules or classification boundaries, decreasing their relevance for newly incoming instances. Real drift affects posterior probabilities $p_j(y|\mathbf{x})$ and additionally may impact unconditional probability density functions. It must be tackled as soon as it appears, since it impacts negatively the underlying classifier. Virtual concept drift affects only the distribution of features $\mathbf{x}$ over time: \begin{equation} \widehat{p}_j(\mathbf{x}) = \sum_{y \in Y} p_j(\mathbf{x},y), \label{eq:cd2} \end{equation} \noindent where $Y$ is a set of possible values taken by $S_j$. While it seems less dangerous than real concept drift, it cannot be ignored. Despite the fact that only the values of features change, it may trigger false alarms and thus force unnecessary and costly adaptations. \smallskip \noindent \textbf{Locality of changes}. It is important to distinguish between global and local concept drifts~\citep{Gama:2006}. The former one affects the entire stream, while the latter one affects only certain parts of it (e.g., regions of the feature space, individual clusters of instances, or subsets of classes). Determining the locality of changes is of high importance, as rebuilding the entire classification model may not be necessary. Instead, one may update only certain parts of the model or sub-models, leading to a more efficient adaptation. \smallskip \noindent \textbf{Speed of changes}. Here we distinguish between sudden, gradual, and incremental concept drifts~\citep{Lu:2019}. \begin{itemize} \item \textbf{Sudden concept drift} is a case when instance distribution abruptly changes with $t$-th example arriving from the stream: \begin{equation} p_j(\mathbf{x},y) = \begin{cases} D_0 (\mathbf{x},y), & \quad \text{if } j < t\\ D_1 (\mathbf{x},y), & \quad \text{if } j \geq t. \end{cases} \label{eq:cd3} \end{equation} \smallskip \item \textbf{Incremental concept drift} is a case when we have a continuous progression from one concept to another (thus consisting of multiple intermediate concepts in between), such that the distance from the old concept is increasing, while the distance to the new concept is decreasing: \begin{equation} p_j(\mathbf{x},y) = \begin{cases} D_0 (\mathbf{x},y), & \text{if } j < t_1\\ (1 - \alpha_j) D_0 (\mathbf{x},y) + \alpha_j D_1 (\mathbf{x},y), &\text{if } t_1 \leq j < t_2\\ D_1 (\mathbf{x},y), & \text{if } t_2 \leq j \end{cases} \label{eq:cd4} \end{equation} \noindent where \begin{equation} \alpha_j = \frac{j - t_1}{t_2 - t_1}. \label{eq:cd5} \end{equation} \smallskip \item \textbf{Gradual concept drift} is a case where instances arriving from the stream oscillate between two distributions during the duration of the drift, with the old concept appearing with decreasing frequency: \begin{equation} p_j(\mathbf{x},y) = \begin{cases} D_0 (\mathbf{x},y), & \text{if } j < t_1\\ D_0 (\mathbf{x},y), & \text{if } t_1 \leq j < t_2 \wedge \delta > \alpha_j\\ D_1 (\mathbf{x},y), & \text{if } t_1 \leq j < t_2 \wedge \delta \leq \alpha_j\\ D_1 (\mathbf{x},y), & \text{if } t_2 \leq j, \end{cases} \label{eq:cd4} \end{equation} \noindent where $\delta \in [0,1]$ is a random variable. \end{itemize} \smallskip \noindent \textbf{Recurrence}. In many scenarios it is possible that a previously seen concept from $k$-th iteration may reappear D$_{j+1}$ = D$_{j-k}$ over time \citep{Sobolewski:2017}. One may store models specialized in previously seen concepts in order to speed up recovery rates after a known concept re-emerges \citep{Guzy:2020}. \smallskip \noindent \textbf{Presence of noise}. Apart from concept drift, one may encounter other types of changes in data. They are connected with the potential appearance of incorrect information in the stream and known as blips or noise. The former stands for singular random changes in a stream that should be ignored and not mistaken for a concept drift. The latter stands for significant corruption in the feature values or class labels and must be filtered out in order to avoid feeding false \citep{Krawczyk:2018} or even adversarial information to the classifier \citep{Sethi:2018}. \smallskip \noindent \textbf{Feature drift}. This is a type of change that happens when a subset of features becomes, or stops to be, relevant to the learning task \citep{Barddal:2017}. Additionally, new features may emerge (thus extending the feature space), while the old ones may cease to arrive. \smallskip \noindent \textbf{Drift detectors.} In order to be able to adapt to evolving data streams, classifiers must either have explicit information on when to update their model, or use continuous learning to follow the progression of a stream. Concept drift detectors are external tools that can be paired with any classifier and used to monitor a state of the stream \citep{Barros:2018}. Usually, this is based on tracking the error of the classifier \citep{Pinage:2020} or measuring the statistical properties of data \citep{Korycki:2019}. Drift detectors emit two-level signals. The warning signal means that changes start to appear in the stream and recent instances should be stored in a dedicated buffer. This buffer is used to train a new classifier in the background. The drift signal means that changes are significant enough to require adaptation and the old classifier must be replaced with the new one trained on the most recent buffer of data. This reduces the cost of adaptation by lowering the number of times when we train the new classifier, but may be subject to costly false alarms or missing changes appearing locally or on a smaller magnitude. One of the first and most popular drift detectors is Drift Detection Method (DDM) \citep{Gama:2004} that analyzes the standard deviation of errors coming from the underlying classifier. DDM assumes that the increase in error rates directly corresponds to changes in incoming data stream and thus can be used to signal the presence of drift. This concept was extended by Early Drift Detection Method (EDDM) \citep{Garcia:2006} by replacing the standard error deviation with a distance between two consecutive errors. This makes EDDM more reactive to slower, gradual changes in the stream, at the cost of losing sensitivity to sudden drifts. Reactive Drift Detection Method (RDDM) \citep{Barros:2017} is an improvement upon DDM that allows detecting sudden and local changes under access to a reduced number of instances. RDDM offers better sensitivity than DDM by implementing a pruning mechanism for discarding outdated instances. Adaptive Windowing (ADWIN) \citep{Bifet:2007} is based on a dynamic sliding window that adjusts its size according to the size of the stable concepts in the stream. ADWIN stores two sub-windows for old and new concepts, detecting a drift when mean values in these sub-windows differ more than a given threshold. Statistical Test of Equal Proportions (STEPD) \citep{Nishida:2007} also keeps two sub-window, but uses a statistical test with continuity correction to determine if instances in both windows originate from similar or different distributions. Page-Hinkley Test (PHT) \citep{Sebastiao:2017} measures the current accuracy, as well as mean accuracy over a window of older instances. PHT computes cumulative and minimum differences between those two values and compares them to a predefined threshold, assuming that higher values of cumulative differences indicate increasing presence of concept drift. Exponentially Weighted Moving Average for Concept Drift Detection (ECDD) \citep{Ross:2012} detects changes in the mean of sequences of instances realized as random variables, without the need for a prior knowledge about their mean and standard deviation. Sequential Drift (SEQDRIFT) \citep{Pears:2014} can be seen as an improved version of ADWIN, where the sub-window of instances from the old concept is obtained by a reservoir sampling with a single-pass approach. Additionally, the comparison between two windows is done using the Bernstein bound, alleviating the need for a user-specified threshold. SEED Drift Detector (SEED) \citep{Huang:2014} is another example of ADWIN extension, where the Hoeffding's inequality with Bonferroni correction is used as the threshold bound for comparing two sub-windows. Furthermore, SEED compresses its sub-windows by eliminating redundant instances from homogeneous parts of its windows. Drift Detection Methods based on the Hoeffding's bounds (HDDM) \citep{Blanco:2015} uses the identical bound as SEED, but drops the idea of sub-windows and focuses on measuring both false positive and false negative rates. Fast Hoeffding Drift Detection Method (FHDDM) \citep{Pesaranghader:2016} is yet another drift detector utilizing the popular Hoeffding's inequality, but its novelty lies in measuring the probability of correct decisions returned by the underlying classifier. Fisher Test Drift Detector (FTDD) \citep{Cabral:2018} is an extension of STEPD that addressees the issue of sub-windows being of insufficient size or holding imbalanced distributions. Wilcoxon Rank Sum Test Drift Detector (WSTD) \citep{Barros:2018w} is another extension of STEPD that uses the Wilcoxon rank-sum statistical test for comparing distributions in sub-windows. Diversity Measure as Drift Detection Method (DMDDM) \citep{Mahdi:2020} uses a combination of a pairwise diversity measure and PHT to offer an aggregated measure of difference between two concepts. Recently, we can see the emergence of the ensemble learning paradigm applied to drift detectors \citep{Krawczyk:2017}. Dynamic Classifier Selection with Local Accuracy and Drift Detector (DCS-LA+DDM) \citep{Pinage:2020} uses an ensemble of base classifiers together with a single drift detector. However, while based on ensemble idea, one cannot consider it a true ensemble of drift detectors. Drift Detection Ensemble (DDE) \citep{Maciel:2015} uses a combination of three independent drift detectors, which can be seen as a heterogeneous ensemble drift detector. Stacking Fast Hoeffding Drift Detection Method (FHDDMS) \citep{Pesaranghader:2018} uses a sequential combination of FHDDM detectors. Ensemble Drift Detection with Feature Subspaces (EDFS) \citep{Korycki:2019} uses a combination of incremental Kolmogorov-Smirnov detectors \citep{Reis:2016} deployed on a set of diverse feature subspaces. Every time drift is detected, the subspaces are reconstructed, allowing EDFS to capture the new data characteristics. EDFS can be seen as a homogeneous ensemble drift detector. \smallskip \noindent \textbf{Classifiers for drifting data streams.} Alternative approaches assume using classifiers that are capable of learning in an incremental or online manner. Sliding windows storing only the most recent instances are very popular, allowing for natural forgetting of older instances \citep{Ramirez-Gallego:2017tsmc,Roseberry:2019}. The size of the window is an important parameter and adapting it over time seems to yield the best results \citep{Bifet:2007}. Online learners are capable of learning instance by instance, discarding data after it passed the training procedure. They are very efficient on their own, but need to be equipped with a forgetting mechanism in order not to endlessly grow their complexity \citep{Yu:2019}. Adaptive Hoeffding Trees \citep{Bifet:2009} and gradient-based methods \citep{Jothimurugesan:2018} are among the most popular solutions. \smallskip \noindent \textbf{Ensemble approaches.} Combining multiple classifiers is a very popular and powerful approach for standard learning problems \citep{Wozniak:2014}. The technique transferred seamlessly to data stream mining scenarios, where ensemble approaches have displayed a great efficacy \citep{Krawczyk:2017}. They not only offer improved predictive power, robustness, and reduction of variance, but also can easily handle concept drift and use it as a natural way of maintaining diversity. By encapsulating new knowledge in the ensemble pool and removing outdated models, one can assure that the base classifiers are continuously mutually complementary, while adapting to changes in the stream. Popular solutions are based on the usage of online versions of bagging \citep{Bifet:2010}, boosting \citep{Oza:2001}, Random Forest \citep{Gomes:2017}, or instance-based clustering \citep{Korycki:2018}, as well as dedicated architectures such as Accuracy Updated Ensemble \citep{Brzezinski:2014} or Kappa Updated Ensemble \citep{Cano:2020}. \section{Adversarial concept drift and poisoning attacks in streaming scenarios} \label{sec:apa} In this section, we will discuss: the unique characteristic of adversarial learning scenario in the context of drifting data streams, the inadequacy of existing detectors for handling adversarial instances, why adversarial drift cannot be simply disregarded as a noise, how it impacts the learning from data streams, and what type of poisoning attacks we may expect. \smallskip \noindent \textbf{Adversarial learning for static data.} With the advent of deep learning and numerous success stories of its application in real-life problems, researchers started to notice that deep models can be easily affected by corrupted or noisy information \citep{Elsayed:2018}. Multiple studies reported that even small perturbations in the training data may have devastating effects on the efficacy of the neural model \citep{Su:2019}. While learning in the presence of noisy instances (either in a form of feature noise \citep{Adeli:2019} or label noise \citep{Frenay:2014}) has been studied thoroughly in machine learning, the specifics of deep learning gave a rise to novel challenges \citep{Wang:2020}. As deep learning usually deals with complex representations of data, such as images \citep{Dong:2020} or text \citep{Wallace:2019}, noise can be introduced in various new forms and affect multiple types of outputs generated by deep models: predictions, extracted features, embeddings, or generated instances \citep{Choi:2018}. Adversarial learning is nowadays used in the broad context of preparing models to deal with noisy and corrupted data \citep{Zhang:2016}, ether by evasion \citep{Li:2020} or poisoning attack \citep{Bojchevski:2019} training schemes. It is important to note that in the literature the term adversarial learning is used for both scenarios with a malicious party attacking the model \citep{Madry:2018} and scenarios where corrupted information is the effect of environmental factors \citep{Kaneko:2020}. As for the effect on data, it is either assumed that the training set is already corrupted \citep{Cohen:2020}, or that the corruption may appear during the prediction phase and thus the training set must be enriched in order to prepare the model \citep{Xiao:2018}. \smallskip \noindent \textbf{Unique characteristics of adversarial learning in data streams.} Works in adversarial learning assume the static nature of data and the fact that the true nature of classes is known beforehand. Therefore, one may generate instances that differ from the training data in order to predict the nature of noisy or corrupted instances. In this work, we propose to extend the concept of adversarial learning into the data stream scenario with concept drift presence. This poses massive new challenges for the learning algorithms that cannot be tackled by the existing adversarial models. Let us now discuss the unique challenges that are present in the adversarial set-up of learning from data streams. \begin{itemize} \smallskip \item \textbf{The true state of classes is subject to change over time.} Data streams are subject to change over time. Therefore, what could be considered an adversarial case, may become a valid instance from a drifted distribution. This prevents us from simply enhancing the training set with artificial adversarial instances, as we cannot know a priori if any changes in the stream originate from the actual drift presence or from an adversarial attack. \smallskip \item \textbf{Adversarial concept drift should be treated as malicious.} In order to inject an adversarial concept drift into data, an attacker must be aware of the nature of data. Through this work, we will consider a scenario with a malicious party providing corrupted, poisoned data with a clear aim of damaging and harming our learning system. Similarities to insider attacks \citep{Tuor:2017} can be drawn, as in both cases poisoning data is prepared in such a way that eludes clear early detection as outliers and damages the learning system over time. \smallskip \item \textbf{Need to differentiate between valid and adversarial concept drift.} We must always assume that the analyzed stream may be subject to a valid, non-malicious concept drift. This poses a very interesting challenge - how can we differentiate between the changes that we want to follow and changes that may be of adversarial nature? Here, we should assume that concept drift will become more and more present as the stream progresses, while adversarial attacks may have a periodic nature and usually constitute only a small portion of the incoming instances. It is highly unlikely that we will have equal proportions of valid and adversarial instances in the stream. \smallskip \item \textbf{Robustness to adversarial data cannot hinder the adaptation process.} While designing robust machine learning algorithms for adversarial concept drift, we cannot follow the standard procedure that treats all data different from the training set as adversarial ones. A robust learner that treats all new data distributions as corrupted will not be able to adapt to new concepts. We need to design novel algorithms capable of differentiating between valid and adversarial drifts, which in turn will be used to make autonomous and on-the-fly decisions whether the learner should adapt to new data or not. Therefore, we find creating robust concept drift detectors particularly promising direction. \end{itemize} \noindent \textbf{Limitations of existing drift detectors.} State-of-the-art drift detectors, discussed in details in Section~\ref{sec:dsm}, share common principles. They all monitor some characteristics of newly arriving instances from the data stream and use various thresholds to decide if the new data are different enough to signal concept drift presence. It is easy to notice that the used measures and statistical tests are very sensitive to any perturbations in data and offer no robustness to poisoning attacks. Existing drift detectors concentrate on checking the level of difference between two distributions, without actually analyzing the content of the newly arriving instances. Furthermore, they are realized as simple thresholding modules, not being able to adapt themselves to data at hand. This calls for new drift detectors that have enhanced robustness and can learn properties of data, instead of just measuring some simple statistics. \smallskip \noindent \textbf{Noisy data streams vs adversarial concept drift.} It is important to offer a clear distinction between noisy data streams and adversarial concept drift. The former cases assume that either some features or labels have been incorrectly measured or provided by annotators. They do not have any underlying characteristics and usually come from additive random distributions or human errors. They may misguide the training procedure, but there is no malicious intent associated with them. Adversarial concept drift and associated poisoning attacks assume that there is a malicious party actively working against our machine learning system. The injected poisoned data was designed and crafted in such a way that will purposefully damage the classifier while avoiding easy detection. Adversarial drift must be seen as a coordinated attempt to disturb or completely shut down the system under attack. Negative impacts of poisoning attacks will be discussed next. \smallskip \noindent \textbf{Negative impact of adversarial concept drift.} In order to offer a complex and holistic view on the problem of adversarial concept drift, let us now discuss the major difficulties imposed by such a phenomenon on the underlying machine learning system: \begin{itemize} \item \textbf{Forcing false and unnecessary adaptation.} Data stream mining algorithms, primarily detectors or adaptive classifiers, actively monitor the characteristics of the stream and trigger changing the learning model when newly arriving data differ from the previous concepts. Therefore, by injecting an adversarial drift during the stable period of a data stream (when no changes in data distributions are taking place), a false alarm will be raised. The learning algorithm will be cheated into thinking that a drift is taking place and will adapt to poisoned instances provided by the attacker. This can be used by a malicious party to damage the accuracy of the system at will, e.g., when two competitors are analyzing the same stream of data. Unnecessary adaptation not only will reduce the accuracy of the classifier, but also will consume precious computational resources and time, slowing the system down \citep{Zliobaite:2015} or even paralyzing it completely during the recovery after such an attack \citep{Shaker:2015}. \smallskip \item \textbf{Impairing the adaptation process.} Adversarial concept drift may also be injected during the occurrence of a valid concept drift. If poisoning instances are well-crafted, they will offer information contrary to the actual changes in data. This will confuse any adaptive learning system, forcing it to adapt to two completely opposing concepts. If the algorithm deals with a high number of poisoned instances, this may lead to a complete nullification of the adaptation process. Even under the assumption that the adversarial concept is much smaller than the valid concept, it will still significantly slow down the adaptation process. The speed of adaptation to new data is of crucial importance and any tampering with it may result in massive financial losses or staying behind the competition. \smallskip \item \textbf{Hindering label query process in partially labeled streams.} In real-life scenarios, one does not have access to fully labeled streams. As it is impossible to obtain the ground truth for each newly arriving instance, active learning is being used to select the most useful instances for the label query \citep{Lughofer:2017}. Obtaining labels is connected with budget management (i.e., the monetary cost for paying the annotator or domain expert) and time (i.e., how quickly the expert can label instance under the consideration). Adversarial concept drift will produce a number of instances that will pretend to be useful for the classifier (as they seem to originate from a novel concept). Even if the domain expert will correctly identify them as adversarial instances, the budget and time have already been spent. Therefore, adversarial concept drift is particularly dangerous for partially labeled streams, where it may force misuse of already scarce resources \citep{Zliobaite:2015}. \end{itemize} \noindent \textbf{Taxonomy of adversarial concept drift.} We have analyzed and understood the unique nature of adversarial concept drift, the challenges connected with its differentiation from a valid concept drift, and the negative impacts it may have on the learning algorithms. Let us now propose the first taxonomy of poisoning attacks in the streaming scenario: \begin{figure}[h] \centering \begin{subfigure}{0.31\linewidth}{ \includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/stand/0.pdf} \subcaption{Before drift}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.31\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/stand/1.pdf} \subcaption{Valid drift}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.31\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/stand/2.pdf} \subcaption{Second valid drift}} \end{subfigure}\vspace*{3pt}\\ \caption{Accurate adaptation to valid concept drift.} \label{fig:dr1} \end{figure} \begin{figure}[h] \centering \begin{subfigure}{0.31\linewidth}{ \includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/inst/0.pdf} \subcaption{Before drift}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.31\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/inst/1.pdf} \subcaption{Hindered adaptation}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.31\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/inst/2.pdf} \subcaption{Overfitting}} \end{subfigure}\vspace*{3pt}\\ \caption{Adversarial drift via instance-based poisoning attacks hinders (b) or exaggerates (c) the adaptation process.} \label{fig:dr2} \end{figure} \begin{figure}[h] \centering \begin{subfigure}{0.31\linewidth}{ \includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/conc/0.pdf} \subcaption{Before drift}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.31\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/conc/1.pdf} \subcaption{False adaptation}} \end{subfigure}\hspace*{10pt}% \begin{subfigure}{0.31\linewidth} {\includegraphics[width=\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/conc/2.pdf} \subcaption{Lack of adaptation}} \end{subfigure}\vspace*{3pt}% \caption{Adversarial drift via concept-based poisoning attacks critically misguides (b) or completely nullifies (c) the adaptation process.} \label{fig:dr3} \end{figure} \begin{itemize} \smallskip \item \textbf{Adversarial concept drift with instance-based poisoning attacks.} The first type assumes that the malicious party injects singular corrupted instances into the stream. They may be corrupted original instances with flipped labels or with modified feature values. Instance-based attacks are common when the attacker wants to test the robustness of the system and still needs to learn about the distribution of data in the stream. Additionally, supplying independent poisoned instances, especially when done from multiple sources, may be harder to detect that injecting a large number of instances at once. Such attacks, at lower rates, may be picked up by noise/outlier detection techniques. However, these attacks will appear more frequently than natural anomalies and will be crafted with malicious intent, requiring dedicated methods to filter them out. Instance-based poisoning attacks will not cause a false drift detection, but may significantly impair the adaptation to the actual concept drift. Figure~\ref{fig:dr1} depicts the correct adaptation to a valid concept drift, while Figure~\ref{fig:dr2} depicts the same scenario with a hindered or exaggerated adaptation affected by the instance-based poisoning attacks. \smallskip \item \textbf{Adversarial concept drift with concept-based poisoning attacks.} The second type assumes that the malicious party have crafted poisoned instances that form a coherent concept. This can be seen as injecting an adversarial distribution of data that fulfills the cluster and smoothness assumptions. Therefore, now we must handle a difficult attack that will elude any outlier/noise/novelty detection methods. With the concept-based poisoning attack, we may assume that the malicious party poses a significant knowledge about the real data distributions and is able to craft such concepts that are going to directly cause false alarms and conflicts with valid concept drift. The effects of concept-based poisoning attacks are much more significant that its instance-based counterparts and may result, if undetected, in significant harm to the learning system and increased recovery times for rebuilding the model. Such attacks can both cause false drift detection and hinder, critically misguide or even completely nullify, the adaptation of the learning algorithm. Figure~\ref{fig:dr1} depicts the correct adaptation to a valid concept drift, while Figure~\ref{fig:dr2} depicts the same scenario with an incorrect adaptation thwarted by the concept-based poisoning attacks. \end{itemize} \section{Robust Restricted Boltzmann Machine for adversarial drift detection} \label{sec:rrb} In this section, we describe in detail the proposed concept drift detector, realized as a trainable Restricted Boltzmann Machine with enhanced robustness to adversarial instances. \smallskip \noindent \textbf{Overview of the proposed method.} We introduce a novel concept drift detector that is characterized by an increased robustness to adversarial concept drift, while maintaining high sensitivity to valid concept drift. It is realized as a Restricted Boltzmann Machine with leveraged robustness via improved online gradient calculation and extended energy function. It is a fully trainable drift detector, capable of autonomous adaptation to the current state of the stream and not relying on user-defined thresholds or statistical tests. \subsection{Restricted Boltzmann Machine} \label{sec:rbm} \noindent \textbf{Neural network architecture.} Restricted Boltzmann Machines (RBMs) are a popular family of generative two-layered neural networks that are constructed using the $\mathbf{v}$ layer of $V$ visible neurons and the $\mathbf{h}$ layer of $H$ hidden neurons: \begin{equation} \begin{split} \mathbf{v} = [v_1,\cdots, v_V] \in \{0,1\}^V,\\ \mathbf{h} = [h_1,\cdots, h_H] \in \{0,1\}^H \end{split} \label{eq:rbm1} \end{equation} As we deal with the task of supervised learning from data streams (as defined in Section~\ref{sec:dsm}), we need to extend this two-layer RBM architecture with the third, final $\mathbf{z}$ layer for class representation. It is implemented as a "one-hot" encoding, meaning that only a single neuron in $\mathbf{z}$ may activate at a given moment (i.e., have value set to 1, while every other one has value set to 0). By $\mathbf{1}_z$ we denote the vector of RBM outputs with $1$ returned by $z$-th neuron and $0$ returned by all other ones. This allows to define $\mathbf{z}$, known also as the class layer or the softmax layer: \begin{equation} \mathbf{z} = [z_1, \cdots, z_Z] \in {\mathbf{1}_1,\cdots, \mathbf{1}_Z}. \end{equation} \noindent This final, class layer uses the softmax function to estimate the probabilities of activation of each neuron in $\mathbf{z}$. RBM assumes no connection between units in the same layer, which holds for $\mathbf{v}$, $\mathbf{h}$, and $\mathbf{z}$. Neurons in the visible layer $\mathbf{v}$ are connected with neurons in the hidden layer $\mathbf{h}$, and neurons in $\mathbf{h}$ are connected with those in the class layer $\mathbf{z}$. The weight assigned to a connection between the $i$-th visible neuron $v_i$ and the $j$-th hidden neuron $h_j$ is denoted as $w_{ij}$, while the weight assigned to a connection between the $j$-th hidden neuron $h_j$ and the $k$-th class neuron $z_k$ is denoted as $u_{jk}$. This allows us to define the RBM energy function: \begin{equation} E(\mathbf{v},\mathbf{h},\mathbf{z}) = - \sum_{i=1}^V v_i a_i - \sum_{j=1}^H h_j b_j - \sum_{k=1}^Z z_k c_k - \sum_{i=1}^V \sum_{j=1}^H v_i h_j w_{ij} - \sum_{j=1}^H \sum_{k=1}^Z h_j z_k u_{jk}, \label{eq:rbm2} \end{equation} \noindent where $a_i, b_j,$ and $c_k$ are biases introduced to $\mathbf{v}, \mathbf{h}$, and $\mathbf{z}$ respectively. Energy formula $E(\cdot)$ for state $[\mathbf{v},\mathbf{h},\mathbf{z}]$ can be used to calculate the probability of RBM of being in this state, using the Boltzmann distribution: \begin{equation} P(\mathbf{v},\mathbf{h},\mathbf{z}) = \frac{\exp \left( -E(\mathbf{v},\mathbf{h},\mathbf{z})\right)}{F}, \label{eq:rbm3} \end{equation} \noindent where $F$ is a partition function allowing to normalize the probability $P(\mathbf{v},\mathbf{h},\mathbf{z})$ to 1. RBM assumes that its hidden neurons in $\mathbf{h}$ are independent and work with variables (features in the case of supervised learning) given by the visible layer $\mathbf{v}$. The activation probability of the $j$-th given neuron $h_j$ can be calculated as follows: \begin{equation} \begin{split} P(h_j |\mathbf{v},\mathbf{z}) = \frac{1}{1 + \exp\left(-b_j - \sum_{i=1}^V v_i w_{ij} - \sum_{k=1}^Z z_k u_{jk}\right)} \\ = \sigma \left( b_j + \sum_{i=1}^V v_i w_{ij} + \sum_{k=1}^Z z_k u_{jk}\right), \end{split} \label{eq:rbm4} \end{equation} \noindent where $\sigma(\cdot) = 1/(1+\exp(- \cdot))$ stands for a sigmoid function. The same assumption may be made for neurons in the visible layer $\mathbf{v}$, when values of neurons in the hidden layer $\mathbf{h}$ are known. This allows us to calculate the activation probability of the $i$-th visible neuron as: \begin{equation} P(v_i |\mathbf{h}) = \frac{1}{1 + \exp\left(-a_i - \sum_{j=1}^H h_j w_{ij}\right)} = \sigma \left( a_i + \sum_{j=1}^H h_j w_{ij} \right), \label{eq:rbm5} \end{equation} \noindent where one must note that given $\mathbf{h}$, the activation probability of neurons in $\mathbf{v}$ does not depend on $\mathbf{z}$. The activation probability of class layer (i.e., decision which class the object should be assigned to) is calculated using the softmax function: \begin{equation} P(\mathbf{z} = \mathbf{1}_k |\mathbf{h}) = \frac{\exp \left( - c_k - \sum_{j=1}^H h_j u_{jk}\right)}{\sum_{l=1}^Z \exp\left( - c_l - \sum_{j=1}^H h_j u_{jl}\right)}, \label{eq:rbm6} \end{equation} \noindent where $k \in [1, \cdots, Z]$ and $k \neq l$. \smallskip \noindent \textbf{RBM training procedure.} As RBM is a neural network model, we may train it using a cost function $C(\cdot)$ minimization with a selected gradient descent method. RBM most commonly uses the negative log-likelihood of both external layers $\mathbf{v}$ and $\mathbf{z}$: \begin{equation} C(\mathbf{v},\mathbf{z}) = - \log\left( P(\mathbf{v},\mathbf{z}) \right). \label{eq:rbm7} \end{equation} \noindent By taking each independent weight $w_{ij}$, we may calculate now its gradient of the cost function: \begin{equation} \nabla C(w_{ij}) = \frac{\delta C(\mathbf{v},\mathbf{z})}{\delta w_{ij}} = \sum_{\mathbf{v},\mathbf{h},\mathbf{z}} P(\mathbf{v},\mathbf{h},\mathbf{z}) v_i h_j - \sum_{\mathbf{h}} P(\mathbf{h}|\mathbf{v},\mathbf{z}) v_i h_j. \label{eq:rbm8} \end{equation} \noindent This equation allows us to calculate the cost function gradient for a single instance. However, concept drift cannot be detected by analyzing individual instances independently. If we would base our change detection on variations induced by a single new instance, we would be highly sensitive to even the smallest noise ratio. Therefore, the properties of the stream should be analyzed over a batch of most recent instances. We propose to define RBM model for learning on mini-batches of instances. For a mini-batch of $n$ instances arriving in $t$ time $\mathbf{M}_t = {x_1^t,\cdots, x_n^t}$, we can rewrite the gradient from Eq.~\ref{eq:rbm8} using expected values: \begin{equation} \frac{\delta C(\mathbf{M}_t)}{\delta w_{ij}} = E_{\text{model}}[v_i h_j] - E_{\text{data}}[v_i h_j], \label{eq:rbm9} \end{equation} \noindent where $E_{\text{data}}$ is the expected value over the current mini-batch of instances and $E_{\text{model}}$ is the expected value from the current state of RBM. Of course, we cannot trace directly the value of $E_{\text{model}}$, therefore we must approximate it using Contrastive Divergence with $k$ Gibbs sampling steps to reconstruct the input data (CD-$k$): \begin{equation} \frac{\delta C(\mathbf{M}_t)}{\delta w_{ij}} \approx E_{\text{recon}}[v_i h_j] - E_{\text{data}}[v_i h_j]. \label{eq:rbm10} \end{equation} After processing the $t$-th mini-batch $\mathbf{M}_t$, we can update the wights in RBM using any gradient descent method as follows: \begin{equation} w_{ij}^{t+1} = w_{ij}^{t} - \eta \left( E_{\text{recon}}[v_i h_j] - E_{\text{data}}[v_i h_j]\right), \label{eq:rbm11} \end{equation} \noindent where $\eta$ stands for the learning rate of the RBM neural network. The way to update the $a_i$, $b_j$, and $c_k$ biases, as well as weights $u_{jk}$ is analogous to Eq.~\ref{eq:rbm11} and can be expressed as: \begin{equation} a_{i}^{t+1} = a_{i}^{t} - \eta \left( E_{\text{recon}}[v_i] - E_{\text{data}}[v_i]\right), \label{eq:rbm12} \end{equation} \begin{equation} b_{j}^{t+1} = b_{j}^{t} - \eta \left( E_{\text{recon}}[h_j] - E_{\text{data}}[h_j]\right), \label{eq:rbm13} \end{equation} \begin{equation} c_{k}^{t+1} = c_{k}^{t} - \eta \left( E_{\text{recon}}[z_k] - E_{\text{data}}[z_k]\right), \label{eq:rbm14} \end{equation} \begin{equation} u_{jk}^{t+1} = u_{jk}^{t} - \eta \left( E_{\text{recon}}[h_j z_k] - E_{\text{data}}[h_j z_k]\right). \label{eq:rbm15} \end{equation} \subsection{Drift detection with Robust RBM} \label{sec:drd} While RBM is a generative neural network model, we can use it as an explicit drift detector. The RBM model store compressed characteristics of the distribution of data it was trained on. Therefore, by using any similarity measure between the information stored in RBM and properties of newly arrived instances, one may evaluate if there are any changes in the distribution. This allows us to use RBM as a drift detector, introducing our Restricted Boltzmann Machine for Drift Detection (RBM-DD). Our RBM-DD model uses its similarity measure for monitoring the state of the stream and the level to which the newly arrived instances differ from the previous concepts. One should notice that RBM-DD is a fully trainable drift detector, capable not only of capturing the trends in a single evaluation measure (like most of drift detectors do), but also of learning and adapting to the current state of the stream. This makes it a highly attractive approach for handling difficult and rapidly changing streams where non-trainable drift detectors tend to fail. \smallskip \noindent \textbf{Measuring data similarity}. In order to evaluate the similarity of newly arrived instances to old concepts stored in RBM-DD, we will use the reconstruction error. It is calculated for every instance independently in an online fashion, by inputting a newly arrived $d$-dimensional instance $S_n = [x_1^n, \cdots, x_d^n, y^n]$ to the $\mathbf{v}$ layer of RBM. Then values of neurons in $\mathbf{v}$ are calculated to reconstruct the feature values. Finally, class layer $\mathbf{z}$ is activated and used to reconstruct the class label. We can denote the reconstructed vector as: \begin{equation} \tilde{S}_n = [\tilde{x}_1^n, \cdots, \tilde{x}_d^n, \tilde{y}_1^n, \cdots, \tilde{y}_Z^n], \label{eq:rbm16} \end{equation} \noindent where the reconstructed vector features and labels are taken from probabilities calculated using the hidden layer: \begin{equation} \tilde{x}_i^n = P (v_i|h), \label{eq:rbm17} \end{equation} \begin{equation} \tilde{y}_k^n = P (z_k|h). \label{eq:rbm18} \end{equation} \noindent The $\mathbf{h}$ layer is taken from the conditional probability, in which the $\mathbf{v}$ layer is identical to the input instance: \begin{equation} \mathbf{h} \sim P(\mathbf{h}|\mathbf{v} = x^n, \mathbf{z} = \mathbf{1}_{y_n}). \label{eq:rbm19} \end{equation} \noindent This allows us to write the reconstruction error in a form of the mean squared error between the original and reconstructed instance: \begin{equation} R(S_n) = \sqrt{\sum_{i=1}^d (x_i^n - \tilde{x}_i^n)^2 + \sum_{k=1}^Z(\mathbf{1}^{y_n}_k - \tilde{y}_k^n)^2}. \label{eq:rbm19} \end{equation} \smallskip For the purpose of a stable concept drift detector, we do not look for a change in distribution over a single instance, but in a change of distribution over the newly arriving batch of instances. Therefore, we need to calculate the average reconstruction error over the recent mini-batch of data: \begin{equation} R(\mathbf{M}_t) = \frac{1}{n} \sum_{m=1}^n R(x_m^t). \label{eq:rbm20} \end{equation} \smallskip \noindent \textbf{Adapting reconstruction error to drift detection.} In order to make the reconstruction error a practical measure for detecting the presence of concept drift, we propose to measure the evolution of this measure (i.e., its trends) over arriving mini-batches of instances. We achieve this by using the well-known sliding window technique that will move over the arriving mini-batches. Let us denote the trend of reconstruction error over time as $Q_r(t)$ and calculate it using the following equation: \begin{equation} Q_r(t) = \frac{\bar{n}_t \bar{TR}_t - \bar{T}_t \bar{R}_t}{\bar{n}_t \bar{T^2}_t - (\bar{T}_t)^2 }. \label{eq:rbm21} \end{equation} \smallskip \noindent The trend over time can be computed using a simple linear regression, with the terms in Eq.~\ref{eq:rbm21} being simply sums over time as follows: \begin{equation} \bar{TR}_t = \bar{TR}_{t-1} + t R(\mathbf{M}_t), \label{eq:rbm22} \end{equation} \begin{equation} \bar{T}_t = \bar{T}_{t-1} + t, \label{eq:rbm23} \end{equation} \begin{equation} \bar{R}_t = \bar{R}_{t-1} + R(\mathbf{M}_t), \label{eq:rbm24} \end{equation} \begin{equation} \bar{T^2}_t = \bar{T^2}_{t-1} + t^2, \label{eq:rbm25} \end{equation} \smallskip \noindent where $\bar{TR}_0 = 0$, $\bar{T}_0 = 0$, $\bar{R}_0 = 0$, and $\bar{T^2}_0 = 0$. We capture those statistics using a sliding window of size $W$. Instead of using a manually set size, which is inefficient for drifting data streams, we propose to use a self-adaptive window size \citep{Bifet:2007}. To allow flexible learning from various sizes of mini-batches, we must consider a case where $t > W$. Here, we must compute the terms for the trend regression using the following equations: \begin{equation} \bar{TR}_t = \bar{TR}_{t-1} + t R(\mathbf{M}_t) - (t - w)R(\mathbf{M}_{t-w}), \label{eq:rbm26} \end{equation} \begin{equation} \bar{T}_t = \bar{T}_{t-1} + t - (t - w), \label{eq:rbm27} \end{equation} \begin{equation} \bar{R}_t = \bar{R}_{t-1} + R(\mathbf{M}_t) - R(\mathbf{M}_{t-w}), \label{eq:rbm28} \end{equation} \begin{equation} \bar{T^2}_t = \bar{T^2}_{t-1} + t^2 - (t - w)^2. \label{eq:rbm29} \end{equation} \smallskip \noindent The required number of instances $\bar{n}_t$ to compute the trend of $Q_r(t)$ as time $t$ is given as follows: \begin{equation} \bar{n}_t = \begin{cases} t & \quad \text{if } t \leq w\\ w & \quad \text{if } t > w \end{cases} \label{eq:rbm30} \end{equation} \smallskip \smallskip \noindent \textbf{Drift detection.} The above Eq.~\ref{eq:rbm21} allows us to compute the trends for every analyzed mini-batch of data. In order to detect the presence of drift we need to have capability of checking if the new mini-batch differs significantly from the previous one. Our RBM-DD achieves this by using Granger causality test \citep{Sun:2008} on trends from subsequent mini-batches of data $Q_r(\mathbf{M}_t)$ and $Q_r(\mathbf{M}_{t+1})$. This is a statistical test that determines whether one trend is useful in forecasting another. As we deal with non-stationary processes we perform the variation of Granger causality test based on first differences \citep{Mahjoub:2020}. Accepted hypothesis means that it is assumed that there exist Granger causality relationship between $Q_r(\mathbf{M}_t)$ and $Q_r(\mathbf{M}_{t+1})$, which means there is no concept drift. If the hypothesis is rejected, RBM-DD signals the presence of concept drift. \subsection{Introducing robustness to RBM} \label{sec:rob} The previous section introduced our RBM-DD -- a drift detection method based on Restricted Boltzmann Machine. While this novel trainable drift detector may offer a significant drift detection capabilities and adaptation to the current state of the data stream, it offers no robustness to adversarial concept drift. In this section, we discuss how to introduce robustness into RBM-DD, leading to Robust Restricted Boltzmann Machine for Drift Detection (RRBM-DD) that is capable of handling adversarial concept drift, while still displaying sensitiveness to the emergence of valid drifts. \smallskip \noindent \textbf{Robust gradient descent.} The first weak point of the RBM-DD in the adversarial scenario lies in its training phase. Adversarial instances may affect the update of our trainable drift detector and thus make it less robust to poisoning attacks over time. To avoid this, we propose to create RRBM-DD by replacing the original online cost gradient calculation in RBM-DD (see Eq.~\ref{eq:rbm8}) used to update weights (see Eq.~\ref{eq:rbm11}) by the robust gradient descent introduced in \citep{Holland:2019}. It postulates to rescale the instance values by using a soft truncation of potentially adversarial instances. It achieves this by using a class of $M$-estimators of location and scale. It introduces a robust truncation factor $\hat{\theta}$ to control the influence of adversarial instances during the weight update: \begin{equation} w_{ij}^{t+1} = w_{ij}^{t} - \eta \left( E_{\text{recon}}[v_i h_j] - \hat{\theta_i} E_{\text{data}}[v_i h_j]\right), \label{eq:rgd1} \end{equation} \noindent where $\hat{\theta_i}$ stands for the truncation factor for the $i$-th neuron in $\mathbf{v}$ (and thus for the $i$-th input feature) that is calculated as follows: \begin{equation} \hat{\theta_i} \in \arg \min_{\theta \in \mathbb{R}} \sum_{a=1}^n \rho \left( \frac{L_i(y_a;\mathbf{z}) - \theta}{s_i} \right), \label{eq:rgd2} \end{equation} \smallskip \noindent where $\rho$ is a convex, even function and $L_i(y_a;\mathbf{z})$ is a loss function between true and predicted class labels (0-1 loss function is commonly used here). The authors of the robust gradient descent \citep{Holland:2019} postulate that for $\rho(\cdot) = \cdot^2$ the estimated truncation factor $\hat{\theta_i}$ is reduced to the sample mean of the loss function, thus alleviating the impact of extreme (in our case adversarial) instances. Therefore, they recommend to take $\rho(\cdot) = o(\cdot^2)$ for the function argument $\rightarrow \pm \infty$. The parameter $s_i$ is a scaling factor used to ensure that consistent estimates take place irrespective of the order of magnitude of the observations. It is calculated as: \begin{equation} s_i = \hat{\sigma}_i \sqrt{n/\log(2\delta^{-1})}, \label{eq:rgd3} \end{equation} \smallskip \noindent where $\delta \in (0,1)$ is the confidence level and $\hat{\sigma}_i$ stands for an dispersion estimate of the instances in the mini-batch: \begin{equation} \hat{\sigma}_i \in \left\{ \sigma > 0: \sum_{a=1}^n \chi \left( \frac{L_i(y_a;\mathbf{z}) - \gamma_i}{\sigma} \right) = 0 \right\}, \label{eq:rgd4} \end{equation} \smallskip \noindent where $\chi: \mathbb{R} \rightarrow \mathbb{R}$ is an even function that satisfies $\chi(0) < 0$ and $\chi(\cdot) > 0$ for the function argument $\rightarrow \pm \infty$. This ensures that $\hat{\sigma}_i$ is an adequate measure of dispersion of the loss function about a pivot point $\gamma_i = \sum_{a=1}^n L_i(y_a;\mathbf{z}) / n$ \citep{Holland:2019}. Analogously to Eq.~\ref{eq:rgd1}, we use the robust truncation factor $\hat{\theta}$ to update remaining weights and parameters of RRBM-DD given by Eq.~\ref{eq:rbm12}-\ref{eq:rbm15}. \smallskip \noindent \textbf{Robust energy function.} Another weak spot of the RBM-DD lies in its energy function (see Eq.~\ref{eq:rbm2}). It is a crucial part for calculating the probability of RBM-DD entering a given state and is used as the basis for the RBM-DD training procedure. In our case, as we use RBM as a trainable drift detector, energy function plays a crucial role in updating the detector with new instances and adapting it to the current state of the stream. RBM-DD energy function assumes working on clean (i.e., non-adversarial) data and thus can easily be corrupted by any poisoning attacks. Therefore, we propose to improve it for our RRBM-DD to alleviate its sensitivity to corrupted instances. We achieve this by adding a gating step to the visible layer $\mathbf{v}$, allowing for switching on and off neurons that may be strongly affected by noise (i.e., coming from adversarial sources). We add two new sets of variables: $\mathbf{\tilde{v}} = [\tilde{v}_1,\cdots, \tilde{v}_V]$ that stands for a Gaussian noise model for each neuron in the visible layer and $\mathbf{g} = [g_1,\cdots, g_V]$ that stands for a binary gating function for each neuron. This allows us to use gating to switch off neurons in $\mathbf{v}$ that have a chance probability of being affected by noisy instances. As we train our RRBM-DD over mini-batches of data, this approach will effectively switch off the RRBM-DD training procedure for every new instance that is denoted as adversarial by our underlying Gaussian noise model. The robust energy function for RRBM-DD is expressed as follows: \begin{equation} \begin{split} E_R(\mathbf{v},\mathbf{\tilde{v}},\mathbf{h},\mathbf{z},\mathbf{g}) = \frac{1}{2}\sum_{i=1}^V g_i (v_i - \tilde{v_i})^2 - \sum_{i=1}^V v_i a_i - \sum_{j=1}^H h_j b_j - \sum_{k=1}^Z z_k c_k \\ - \sum_{i=1}^V\sum_{j=1}^H v_i h_j w_{ij} - \sum_{j=1}^H \sum_{k=1}^Z h_j z_k u_{jk} + \frac{1}{2}\sum_{i=1}^V \frac{(\tilde{v_i} - \tilde{b_i})^2}{\tilde{\sigma}_i^2}, \label{eq:ref1} \end{split} \end{equation} \smallskip \noindent where the first (added) term stands for the gating interactions between $v_i$ and $\tilde{v}_i$, the original energy function models the clean data, the last (added) term stands for the noise model, and $\tilde{b_i}$ and $\tilde{\sigma}_i^2$ stands for mean and variance of the noise. If RRBM-DD assumes that the $i$-th neuron in $\mathbf{v}$ is corrupted by the adversarial instance ($g_i = 0$) then $\tilde{v}_i \sim \mathcal{N}(\tilde{v}_i|\tilde{b_i};\tilde{\sigma}_i^2)$. \subsection{Metric for evaluating robustness to poisoning attacks in streaming scenarios} \label{sec:met} Concept drift detectors are commonly evaluated by the prequential accuracy \citep{Hidalgo:2019} or prequential AUC/G-mean \citep{Korycki:2019bd} of the underlying classifier. The reasoning behind it is that the better the detection of drift offered by the evaluated algorithm, the faster and more accurate classifier adaptation becomes. However, this set-up is not sufficient for evaluating drift detectors in the adversarial concept drift setting. As we want to evaluate the robustness of a drift detector to poisoning attacks, we should attack the data stream with various levels of intensity to determine the breaking point of each algorithm. However, simple evaluation of a performance metric over varying levels of adversarial concept drift intensity does not give us information on how much our algorithm deteriorates over increasingly poisoned data. We assume that we evaluate the robustness of drift detectors in a controlled experimental environment, where we can inject a desired level of adversarial concept drift into any benchmark data stream. Let us denote by $\mathbf{L} = [l_1, \cdots, l_a]$ the set of adversarial poisoning levels, ordered in the ascending order $l_1 < l_a$ from the smallest to the highest level of adversarial drift injection. Following the taxonomy introduced in Section 3, we can understand those levels as: \begin{itemize} \item for instance-based poisoning attacks -- the percentage of instances in a mini-batch considered as adversarial in the data stream, \smallskip \item for concept-based poisoning attacks -- the number of adversarial concepts injected into the data stream. \end{itemize} Inspired by works in noisy data classification \citep{Saez:2016}, we introduce a Relative Loss of Robustness (RLR) that compares the performance of a given algorithm on a clean data stream against its performance on a data stream with $l$-th level of adversarial concept drift injected: \begin{equation} RLR_l = \frac{M_{0} - M_{l}}{M_{0}}. \end{equation} \smallskip \noindent This is a popular approach used to evaluate the impact of noise on classifiers and can be directly adapted to the setting of adversarial drift detection. While it offers a convenient measure over a single level of poisoning, it becomes increasingly difficult to use when we want to evaluate the robustness of an algorithm over multiple poisoning levels. To alleviate this drawback, we propose an aggregated version of RLR measure over all considered adversarial poisoning levels: \begin{equation} RLR = \frac{\sum_{l=1}^{\#\mathbf{L}} \omega_l RLR_l}{\#\mathbf{L}}, \label{eq:rlr} \end{equation} \smallskip \noindent where $\omega_l$ is the importance weight associated to the performance on $l$-the level of adversarial information introduced to data and $\sum_{l=1}^{\#\mathbf{L}} \omega_l = 1$. The weighting part allows the end-user to adjust the measurements accordingly to the analyzed problem. If the user is interested only in the overall robustness of a given method, then all weights can be set to $1/\#L$. However, if it becomes crucial to select a drift detector that can perform the best even under the high intensity of attacks, the user may assign higher weights to higher levels of adversarial drift injection. \section{Experimental study} \label{sec:exp} This experimental study was designed to evaluate the usefulness of the proposed RRBM--DD and answer the following research questions: \medskip \noindent \textbf{RQ1:} Does RRBM-DD algorithm offers improved robustness to adversarial concept drift realized instance-based poisoning attacks? \smallskip \noindent \textbf{RQ2:} Does RRBM-DD algorithm offers improved robustness to adversarial concept drift realized concept-based poisoning attacks? \smallskip \noindent \textbf{RQ3:} Is RRBM-DD capable of preserving its robust characteristics when dealing with sparsely labeled data streams? \smallskip \noindent \textbf{RQ4:} What are the impacts of individual components of RRBM-DD on its robustness to adversarial concept drift? \subsection{Data stream benchmarks} \label{sec:dat} \begin{table}[h] \centering \caption{Properties of artificial and real data stream benchmarks.} \scalebox{0.9}{ \begin{tabular}{llrrrl} \toprule Abbr. & Stream & Instances & Features & Classes & Drift \\ \midrule \multicolumn{6}{l}{\textbf{Artificial data streams}}\\ HYP$_{I}$ & Hyperplane & 1 000 000 & 10 & 2 & incremental\\ LED$_S$ & LED & 1 000 000 & 24 & 10 & sudden\\ RBF$_G$ & RBF & 1 000 000 & 40 & 20 & gradual\\ RBF$_S$ & RBF & 1 000 000 & 20 & 10 & sudden\\ SEA$_G$ & SEA &3 000 000 & 3 & 4 & gradual\\ TRE$_S$ & RandomTree & 2 000 000 & 10 & 6 & sudden\\ \midrule \multicolumn{6}{l}{\textbf{Real data streams}}\\ ecbdl14& Protein Structure Prediction & 9 600 000 & 631 & 2 & mixed\\ higgs &High-energy Physics Classification & 4 954 752 & 28 & 2 & unknown\\ IntelLab&Intel Lab Sensors & 2 313 153 & 6 & 58 & mixed\\ iot& IoT Botnet Attacks& 7 062 606 & 115 & 11 & mixed\\ kddcup & KDD Intrusion Detection & 3 107 709 & 41 & 24 & mixed\\ susy &Supersymmetric Particle Detection& 2 305 347 & 18 & 2 & unknown\\ \bottomrule \label{tab:data} \end{tabular} } \end{table} For the purpose of evaluating the proposed RRBM-DD, we selected 12 benchmark data streams, six of which were generated artificially using MOA environment \citep{Bifet:2010moa} and other six being real-world data streams coming from various domains, such as security, physics, and proteomics. Such a diverse mix allowed us to evaluate the effectiveness of RRBM-DD over a plethora of scenarios. Using artificial data streams allows us to control the specific nature of drift and where it occurs, while real-world streams offer challenging problems that are characterized by a mix of different learning difficulties. Properties of used data stream benchmarks are given in Table~\ref{tab:data}. \subsection{Experimental setup} \label{sec:set} Here, we will present the details of the experimental study design. \smallskip \noindent \textbf{Injection of adversarial concept drift.} As there are no real-world benchmarks for adversarial concept drift, we will inject poisoning attacks into our 12 benchmark data streams with the following procedures: \begin{itemize} \item \textbf{instance-based poisoning attacks} are injected by corrupting a ratio $\mathbf{L}_{inst} \in \{0.05,0.10,0.15,0.20,0.25\}$ of randomly selected instances in the stream by flipping their class labels to a randomly chosen another class. \smallskip \item \textbf{concept-based poisoning attacks} are injected by generating a number $\mathbf{L}_{conc} \in \{10,30,50,70,100\}$ of small artificial concepts of $n = 250$ instances using corresponding MOA data generators. \end{itemize} \smallskip \noindent \textbf{Sparsely labeled data streams.} For the experiment investigating the robustness under limited access to ground truth, we investigate the 12 benchmark data streams with $\{5\%,10\%,15\%,20\%,25\%,30\%\}$ of labeled instances. \smallskip \noindent \textbf{Reference concept drift detectors.} As reference methods to the proposed RRBM-DD, we have selected five state of the art concept drift detectors: Early Drift Detection Method (EDDM) \citep{Garcia:2006}, Exponentially Weighted Moving Average for Concept Drift Detection (ECDD) \citep{Ross:2012}, Fast Hoeffding Drift Detection Method (FHDDM) \citep{Pesaranghader:2016}, Reactive Drift Detection Method (RDDM) \citep{Barros:2017},and Wilcoxon Rank Sum Test Drift Detector (WSTD) \citep{Barros:2018w}. Parameters of all six drift detectors are given in Table~\ref{tab:ddp}. \begin{table}[h!] \centering \caption{Examined drift detectors and their parameters.} \scalebox{0.85}{ \begin{tabular}{lll} \toprule Abbr. & Name & Parameters \\ \midrule EDDM & Early Drift Detection & warning threshold $\alpha_w \in \{0.90,0.92,0.95,0.98\}$\\ & & drift threshold $\alpha_d \in \{0.80,0.85,0.90.0.95\}$\\ & & min. no. of errors $e \in \{10,30,50,70\}$\\ ECDD & EWMA for Drift Detection & differentiation weights $\lambda \in \{0.1,0.2,0.3,0.4\}$\\ & & min. no. of errors $n = \{10,30,50,70\}$\\ FHDDM& Fast Hoeffding Drift Detection & sliding window size $\omega \in \{25,50,75,100\}$\\ & & allowed error $\delta \in \{0.000001,0.00001,0.0001,0.001\}$ \\ RDDM & Reactive Drift Detection & warning threshold $\alpha_w \in \{0.90,0.92,0.95,0.98\}$\\ & & drift threshold $\alpha_d \in \{0.80,0.85,0.90.0.95\}$\\ & & min. no. of errors $e \in \{10,30,50,70\}$\\ & & min. no. of instances $\min \in \{3000,5000,7000,9000\}$\\ & & max. no. of instances $\max \in \{10000,20000,30000,40000\}$\\ & & warning limit $wL \in \{800,1000,1200,1400\}$\\ WSTD & Wilcoxon Rank Sum Test & sliding window size $\omega \in \{25,50,75,100\}$\\ &Drift Detection & warning significance $\alpha_w \in \{0.01,0.03,0.05,0.07\}$\\ & & drift significance $\alpha_d \in \{0.001,0.003,0.005,0.007\}$\\ & & max. no of old instances $\min \in \{1000,2000,3000,4000\}$\\ \midrule RRBM--DD & Robust RBM Drift Detection& mini--batch size $\mathbf{M} \in \{25,50,75,100\}$\\ & & visible neurons $\mathbf{V} = $ no. of features\\ & & hidden neurons $\mathbf{H} \in \{0.25\mathbf{V},0.5\mathbf{V},0.75\mathbf{V},\mathbf{V}\}$ \\ & & class neurons $\mathbf{Z} = $ no. of classes\\ & & learning rate $\eta \in \{0.01,0.03,0.05,0.07\}$\\ & & Gibbs sampling steps $k \in \{1,2,3,4\}$\\ & & robust gradient confidence $\delta \in \{0.90,0.92,0.95,0.98\}$\\ \bottomrule \label{tab:ddp} \end{tabular} } \end{table} \smallskip \noindent \textbf{Parameter tuning.} To offer a fair and thorough comparison, we perform parameter tuning for every drift detector and for every data stream benchmark. As we deal with a streaming scenario, we use self hyper-parameter tuning \citep{Veloso:2018} that is based on online Nelder \& Mead optimization. \smallskip \noindent \textbf{Ablation study.} In order to be able to answer \textbf{RQ4} we perform an ablation study to check the impact of individual introduced components on the robustness of the drift detector. We compare RRBM--DD with its simplified versions with only robust online gradient RBM--DD$_{RG}$, only robust energy function RBM--DD$_{RE}$, and basic RBM--DD with no explicit robustness mechanisms. \smallskip \noindent \textbf{Base classifier.} To ensure fairness in comparison among examined drift detectors they all use Adaptive Hoeffding Decision Tree \citep{Bifet:2009} as a base classifier. \smallskip \noindent \textbf{Evaluation metrics.} As we deal with drifting data streams, we evaluated examined algorithms using prequential accuracy \citep{Hidalgo:2019} and the proposed RLR metric (see Eq.~\ref{eq:rlr}). RLR assumes equal weights assigned to each level of adversarial drift injection. \smallskip \noindent\textbf{Windows.} We used a window size $W = 1000$ for window-based drift detectors and calculating the prequential metrics . \smallskip \noindent\textbf{Statistical analysis.} We used the Friedman ranking test with Bonferroni-Dunn post-hoc for determining statistical significance over multiple comparisons with significance level $\alpha = 0.05$. \subsection{Experiment 1: Evaluating robustness to instance-based poisoning attacks} \label{sec:exp1} The first experiment was designed to evaluate the robustness of RRBM--DD and reference drift detectors to instance-based poisoning attacks. For this purpose, we injected five different ratios of poisoning attacks into 12 benchmark data streams. Figure~\ref{fig:exp1} depicts the effects of varying levels of adversarial concept drift on the prequential accuracy of the underlying classifier, while Table~\ref{tab:rlr1} presents the RLR metric results. Additionally, Figures~\ref{fig:bon1} and \ref{fig:bon2} show the visualizations of Friedman ranking test with Bonferroni-Dunn post-hoc on both used metrics. \begin{figure}[h] \centering \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/hyp.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/led.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/rbfg.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/rbfs.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/sea.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/tre.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/ecb.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/hig.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/int.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/iot.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/kdd.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp1/sus.pdf} \caption{Relationship between prequential accuracy and ratio of injected adversarial concept drift via instance-based poisoning attacks.} \label{fig:exp1} \end{figure} \begin{table}[h] \centering \caption{RLR for RRBM--DD and reference drift detectors under instance-based poisoning attacks.} \begin{tabular}{lcccccc} \toprule Stream & EDDM & ECDD & FHDDM & RDDM & WSTD & RRBM--DD \\ \midrule HYP$_{I}$ & 0.55 & 0.58 & 0.67 & 0.64 & 0.63 & 0.85 \\ LED$_S$ & 0.61 & 0.62 & 0.71 & 0.71 & 0.74 & 0.90 \\ RBF$_G$ & 0.54 & 0.55 & 0.58 & 0.56 & 0.61 & 0.77 \\ RBF$_S$ & 0.49 & 0.47 & 0.50 & 0.54 & 0.52 & 0.73 \\ SEA$_G$ & 0.67 & 0.71 & 0.70 & 0.74 & 0.77 & 0.86 \\ TRE$_S$ & 0.44 & 0.43 & 0.48 & 0.49 & 0.51 & 0.72 \\ ecbdl14& 0.40 & 0.45 & 0.52 & 0.56 & 0.53 & 0.69 \\ higgs & 0.71 & 0.73 & 0.77 & 0.81 & 0.82 & 0.94 \\ IntelLab& 0.41 & 0.44 & 0.46 & 0.48 & 0.49 & 0.69 \\ iot& 0.73 & 0.77 & 0.81 & 0.84 & 0.87 & 0.95 \\ kddcup & 0.63 & 0.60 & 0.67 & 0.65 & 0.69 & 0.83 \\ susy & 0.65 & 0.71 & 0.74 & 0.76 & 0.73 & 0.85 \\ \midrule avg. rank & 5.88 & 4.12 & 3.73 & 3.22 &3.05 & 1.00 \\ \bottomrule \label{tab:rlr1} \end{tabular} \end{table} \begin{figure}[h] \centering \tiny \resizebox{\columnwidth}{!}{ \begin{tikzpicture} \draw (1,0) -- (6,0); \foreach \x in {1,2,3,4,5,6} { \draw (\x, 0) -- ++(0,.1) node [below=0.15cm,scale=0.75] {\tiny \x}; \ifthenelse{\x < 6}{\draw (\x+.5, 0) -- ++(0,.03);}{} } \coordinate (c0) at (1.26,0); \coordinate (c1) at (3.45,0); \coordinate (c2) at (3.99,0); \coordinate (c3) at (4.02,0); \coordinate (c4) at (4.68,0); \coordinate (c5) at (5.28,0); \node (l0) at (c0) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny RRBM-DD}; \node (l1) at (c1) [above left=.15cm and 0.1cm, align=center, scale=0.7] {\tiny WSTD}; \node (l2) at (c2) [above left=.40cm and 0.1cm, align=left, scale=0.7] {\tiny RDDM}; \node (l3) at (c3) [above right=.40cm and 0.1cm, align=center, scale=0.7] {\tiny FHDDM}; \node (l4) at (c4) [above right=.25cm and 0.1cm, align=center, scale=0.7] {\tiny ECDD}; \node (l5) at (c5) [above right=.15cm and 0.1cm, align=left, scale=0.7] {\tiny EDDM}; \fill[fill=gray,fill opacity=0.5] (1.26,-0.08) rectangle (2.05,0.08); \foreach \x in {0,...,5} { \draw (l\x) -| (c\x); }; \end{tikzpicture} } \caption{The Bonferroni-Dunn test for comparison among drift detectors under instance-based poisoning attacks, based on prequential accuracy.} \label{fig:bon1} \end{figure} \begin{figure}[h] \centering \tiny \resizebox{\columnwidth}{!}{ \begin{tikzpicture} \draw (1,0) -- (6,0); \foreach \x in {1,2,3,4,5,6} { \draw (\x, 0) -- ++(0,.1) node [below=0.15cm,scale=0.75] {\tiny \x}; \ifthenelse{\x < 6}{\draw (\x+.5, 0) -- ++(0,.03);}{} } \coordinate (c0) at (1.00,0); \coordinate (c1) at (3.05,0); \coordinate (c2) at (3.22,0); \coordinate (c3) at (3.73,0); \coordinate (c4) at (4.12,0); \coordinate (c5) at (5.88,0); \node (l0) at (c0) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny RRBM-DD}; \node (l1) at (c1) [above left=.15cm and 0.1cm, align=center, scale=0.7] {\tiny WSTD}; \node (l2) at (c2) [above right=.45cm and 0.1cm, align=left, scale=0.7] {\tiny RDDM}; \node (l3) at (c3) [above right=.30cm and 0.1cm, align=center, scale=0.7] {\tiny FHDDM}; \node (l4) at (c4) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny ECDD}; \node (l5) at (c5) [above left=.15cm and 0.1cm, align=left, scale=0.7] {\tiny EDDM}; \fill[fill=gray,fill opacity=0.5] (1.00,-0.08) rectangle (2.05,0.08); \foreach \x in {0,...,5} { \draw (l\x) -| (c\x); }; \end{tikzpicture} } \caption{The Bonferroni-Dunn test for comparison among drift detectors under instance-based poisoning attacks, based on RLR.} \label{fig:bon2} \end{figure} We can see how instance-based poisoning attacks impact both drift detectors and the underlying classifier. For low attack ratios (0.05 and 0.10) we already can observe drops in performance, but all of the examined methods can still deliver acceptable performance. With the increase of poisoning attack ratios, all reference drift detectors start to fail. They cannot cope with such adversarial streams and are not able to select properly the moment for updating the Adaptive Hoeffding Tree classifier. In many cases, the performance starts to approach random decisions, which is a strong indicator of the negative effects that instance-based poisoning attacks have on detectors. This is especially visible in the case of EDDM and ECDD that are the weakest performing ones. RRBM--DD outperforms every single competitor, especially for RLR metric where it is the best algorithm over all 12 benchmarks. By analyzing Figure~\ref{fig:exp1} we can see that RRBM--DD offers significantly higher robustness to increasing levels of adversarial concept drift. For not a single data stream we can observe any sharp decline in performance, even when 25\% of instances in the stream are corrupted by the adversarial attacker. Such a situation can be explained by the way standard drift detectors compute the presence of a valid drift. They use statistics, such as mean values or errors, derived directly from data. This makes them highly susceptible to any adversarial attack, as even small corruption of the data being used to compute drift statistics will result in either incorrectly increased sensitivity to any variations in streams, or inhibits sensitivity to valid concept drift. RRBM--DD avoids this pitfall by being a fully trainable drift detector that uses two robustness inducing mechanisms that filter data before it is updated. This allows RRBM--DD to compute more accurate reconstruction error from mini-batches and use it to correctly react only to valid concept drift. \smallskip \noindent \textbf{RQ1 answer.} Yes, RRBM--DD offers excellent robustness to instance-based poisoning attacks and is not significantly affected by various levels of such adversarial concept drift. \subsection{Experiment 2: Evaluating robustness to concept-based poisoning attacks} \label{sec:exp2} Experiment 2 was designed as a follow-up to Experiment 1. Here, we want to investigate a much more challenging scenario of concept-based poisoning attacks on data streams. For this purpose, we injected five different numbers of adversarial concepts into 12 benchmark data streams. Figure~\ref{fig:exp2} depicts the effects of varying levels of adversarial concept drift on the prequential accuracy of the underlying classifier, while Table~\ref{tab:rlr2} presents the RLR metric results. Additionally, Figures~\ref{fig:bon3} and \ref{fig:bon4} show the visualizations of Friedman ranking test with Bonferroni-Dunn post-hoc on both used metrics. \begin{figure}[h] \centering \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/hyp.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/led.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/rbfg.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/rbfs.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/sea.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/tre.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/ecb.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/hig.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/int.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/iot.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/kdd.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp2/sus.pdf} \caption{Relationship between prequential accuracy and number of injected adversarial concept drift via concept-based poisoning attacks.} \label{fig:exp2} \end{figure} \begin{table}[h] \centering \caption{RLR for RRBM--DD and reference drift detectors under concept-based poisoning attacks.} \begin{tabular}{lcccccc} \toprule Stream & EDDM & ECDD & FHDDM & RDDM & WSTD & RRBM--DD \\ \midrule HYP$_{I}$ & 0.44 & 0.45 & 0.50 & 0.52 & 0.51 & 0.78 \\ LED$_S$ & 0.48 & 0.52 & 0.56 & 0.55 & 0.59 & 0.84 \\ RBF$_G$ & 0.35 & 0.38 & 0.42 & 0.44 & 0.43 & 0.71 \\ RBF$_S$ & 0.27 & 0.28 & 0.30 & 0.33 & 0.32 & 0.68 \\ SEA$_G$ & 0.51 & 0.55 & 0.52 & 0.55 & 0.56 & 0.82 \\ TRE$_S$ & 0.22 & 0.20 & 0.25 & 0.27 & 0.27 & 0.63 \\ ecbdl14& 0.18 & 0.17 & 0.23 & 0.26 & 0.26 & 0.60 \\ higgs & 0.52 & 0.56 & 0.57 & 0.61 & 0.63 & 0.88 \\ IntelLab& 0.24 & 0.26 & 0.25 & 0.30 & 0.32 & 0.65 \\ iot& 0.63 & 0.65 & 0.69 & 0.71 & 0.74 & 0.90 \\ kddcup & 0.39 & 0.35 & 0.44 & 0.40 & 0.47 & 0.76 \\ susy & 0.42 & 0.45 & 0.46 & 0.51 & 0.47 & 0.80 \\ \midrule avg. rank & 5.60 & 4.55 & 3.10 & 3.90 &2.95 & 1.00 \\ \bottomrule \label{tab:rlr2} \end{tabular} \end{table} \begin{figure}[h] \centering \tiny \resizebox{\columnwidth}{!}{ \begin{tikzpicture} \draw (1,0) -- (6,0); \foreach \x in {1,2,3,4,5,6} { \draw (\x, 0) -- ++(0,.1) node [below=0.15cm,scale=0.75] {\tiny \x}; \ifthenelse{\x < 6}{\draw (\x+.5, 0) -- ++(0,.03);}{} } \coordinate (c0) at (1.10,0); \coordinate (c1) at (3.85,0); \coordinate (c2) at (4.50,0); \coordinate (c3) at (3.90,0); \coordinate (c4) at (4.85,0); \coordinate (c5) at (5.20,0); \node (l0) at (c0) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny RRBM-DD}; \node (l1) at (c1) [above left=.15cm and 0.1cm, align=center, scale=0.7] {\tiny WSTD}; \node (l2) at (c2) [above right=.40cm and 0.1cm, align=left, scale=0.7] {\tiny RDDM}; \node (l3) at (c3) [above left=.40cm and 0.1cm, align=center, scale=0.7] {\tiny FHDDM}; \node (l4) at (c4) [above right=.25cm and 0.1cm, align=center, scale=0.7] {\tiny ECDD}; \node (l5) at (c5) [above right=.15cm and 0.1cm, align=left, scale=0.7] {\tiny EDDM}; \fill[fill=gray,fill opacity=0.5] (1.10,-0.08) rectangle (2.55,0.08); \foreach \x in {0,...,5} { \draw (l\x) -| (c\x); }; \end{tikzpicture} } \caption{The Bonferroni-Dunn test for comparison among drift detectors under concept-based poisoning attacks, based on prequential accuracy.} \label{fig:bon3} \end{figure} \begin{figure}[h] \centering \tiny \resizebox{\columnwidth}{!}{ \begin{tikzpicture} \draw (1,0) -- (6,0); \foreach \x in {1,2,3,4,5,6} { \draw (\x, 0) -- ++(0,.1) node [below=0.15cm,scale=0.75] {\tiny \x}; \ifthenelse{\x < 6}{\draw (\x+.5, 0) -- ++(0,.03);}{} } \coordinate (c0) at (1.00,0); \coordinate (c1) at (2.95,0); \coordinate (c2) at (3.85,0); \coordinate (c3) at (3.10,0); \coordinate (c4) at (4.58,0); \coordinate (c5) at (5.56,0); \node (l0) at (c0) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny RRBM-DD}; \node (l1) at (c1) [above left=.15cm and 0.1cm, align=center, scale=0.7] {\tiny WSTD}; \node (l2) at (c2) [above right=.25cm and 0.1cm, align=left, scale=0.7] {\tiny RDDM}; \node (l3) at (c3) [above left=.35cm and 0.1cm, align=center, scale=0.7] {\tiny FHDDM}; \node (l4) at (c4) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny ECDD}; \node (l5) at (c5) [above right=.15cm and 0.1cm, align=left, scale=0.7] {\tiny EDDM}; \fill[fill=gray,fill opacity=0.5] (1.00,-0.08) rectangle (2.55,0.08); \foreach \x in {0,...,5} { \draw (l\x) -| (c\x); }; \end{tikzpicture} } \caption{The Bonferroni-Dunn test for comparison among drift detectors under concept-based poisoning attacks, based on RLR.} \label{fig:bon4} \end{figure} Experiment 2 further confirms the observations made during the analysis of experiment 1. State-of-the-art drift detectors offer no robustness to adversarial attacks and can be very easily fooled or damaged by even a very small number of poisoning attacks. What is very important to notice is the difference in the impact of concept-based poisoning attacks versus their instance-based counterparts. Here we can see the catastrophic effects of injecting adversarial concepts into the stream, as every single reference drift detector converges at a point where it behaves worse than a random guess. This can be interpreted as adversarial data hijacking the updating process of the underlying classifier and forcing it to adapt to the malicious information. RRBM--DD once again offers excellent robustness, while maintaining a very good valid drift detection -- as evident from the high prequential accuracy of Adaptive Hoeffding Tree associated with it. Of course, concept-based poisoning attacks have a stronger effect on RRBM-DD, yet they are not capable of hindering its sensitivity and robustness. The first two experiments highlighted the excellent properties of RRBM-DD when dealing with adversarial concept drift, but it would be very beneficial to understand what exactly is the cause of such a performance. We will analyze this using an ablation study in experiment 4. \smallskip \noindent \textbf{RQ2 answer.} Yes, RRBM-DD can efficiently handle the injection of adversarial concepts, even when they fulfill smoothness and cluster assumptions. This proves that RRBM--DD is not simply insensitive to noisy data, but can handle truly adversarial scenarios with malicious party using crafted poisoning attacks on data. \subsection{Experiment 3: Evaluating robustness under class label sparsity} \label{sec:exp3} The third experiment was designed to investigate the behavior of RRDM--DD under sparse access to class labels. As discussed in Sections~\ref{sec:int} and ~\ref{sec:apa} a common pitfall of many algorithms for learning from data streams lies in the unrealistic assumption that there is unlimited access to labeled instances. It is crucial to acknowledge that any algorithm for data stream mining, be it classifier or drift detector, must be flexible enough to work in scenarios where class labels are sparse. We used 12 benchmark data streams to select six different percentages of labeled instances. The label query procedure was repeated 10 times, in order to avoid impacting the results with selecting easy or difficult instances. This resulted in 60 runs for each out of 12 benchmark streams. Figures~\ref{fig:exp31} and \ref{fig:exp32} present the win-tie-loss plots for comparing the performance of RRBM--DD on sparsely labeled streams under instance-based and concept-based poisoning attacks. Tables~\ref{tab:rlr3} and ~\ref{tab:rlr4} present the RLR metrics for RRDM-DD and reference methods under both types of attacks, while Figures~\ref{fig:bon5} and~\ref{fig:bon6} show the visualizations of the Friedman ranking test with Bonferroni-Dunn post-hoc analysis. \begin{figure}[h!] \centering \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/hyp.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/led.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/rbfg.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/rbfs.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/sea.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/tre.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/ecb.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/hig.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/int.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/iot.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/kdd.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp3/sus.pdf} \caption{Comparison of RRBM--DD with reference drift detectors under instance-based poisoning attacks and sparsely labeled assumption (only 10\% labeled instances) with respect to the number of wins (green), ties (yellow), and losses (red), according to a pairwise F-test with statistical significance level $\alpha = 0.05$. Prequential accuracy used as a metric. 60 runs per data stream were obtained from 6 different labeling budgets, each repeated 10 times with random selection of instances to be labeled. } \label{fig:exp31} \end{figure} \begin{figure}[h!] \centering \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/hyp.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/led.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/rbfg.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/rbfs.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/sea.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/tre.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/ecb.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/hig.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/int.pdf}\vspace*{-1.5cm} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/iot.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/kdd.pdf} \includegraphics[width=0.3\linewidth,trim=2cm 2cm 2cm 2cm,clip]{img/exp32/sus.pdf} \caption{Comparison of RRBM--DD with reference drift detectors under concept-based poisoning attacks and sparsely labeled assumption with respect to the number of wins (green), ties (yellow), and losses (red), according to a pairwise F-test with statistical significance level $\alpha = 0.05$. Prequential accuracy used as a metric. 60 runs per data stream were obtained from 6 different labeling budgets, each repeated 10 times with random selection of instances to be labeled.} \label{fig:exp32} \end{figure} \begin{table}[h] \centering \caption{RLR for RRBM--DD and reference drift detectors under instance-based poisoning attacks and sparsely labeled data. Results averaged over all labeling budgets, presented with standard deviation.} \begin{tabular}{lcccccc} \toprule Stream & EDDM & ECDD & FHDDM & RDDM & WSTD & RRBM--DD \\ \midrule HYP$_{I}$ & 0.47$\pm$0.11 & 0.49$\pm$0.10 & 0.61$\pm$0.12 & 0.55$\pm$0.16 & 0.57$\pm$0.13 & 0.80$\pm$0.08 \\ LED$_S$ & 0.52$\pm$0.09 & 0.51$\pm$0.09 & 0.63$\pm$0.10 & 0.61$\pm$0.14 & 0.63$\pm$0.11 & 0.83$\pm$0.05 \\ RBF$_G$ & 0.40$\pm$0.16 & 0.42$\pm$0.12 & 0.47$\pm$0.09 & 0.45$\pm$0.15 & 0.50$\pm$0.11 & 0.69$\pm$0.09 \\ RBF$_S$ & 0.37$\pm$0.06 & 0.38$\pm$0.05 & 0.41$\pm$0.07 & 0.40$\pm$0.09 & 0.44$\pm$0.06 & 0.63$\pm$0.07 \\ SEA$_G$ & 0.56$\pm$0.12 & 0.62$\pm$0.09 & 0.59$\pm$0.09 & 0.57$\pm$0.14 & 0.66$\pm$0.10 & 0.81$\pm$0.08 \\ TRE$_S$ & 0.30$\pm$0.05 & 0.32$\pm$0.04 & 0.35$\pm$0.06 & 0.32$\pm$0.08 & 0.38$\pm$0.08 & 0.63$\pm$0.04 \\ ecbdl14& 0.33$\pm$0.07 & 0.36$\pm$0.06 & 0.45$\pm$0.09 & 0.42$\pm$0.11 & 0.46$\pm$0.10 & 0.60$\pm$0.05 \\ higgs & 0.58$\pm$0.14 & 0.62$\pm$0.10 & 0.65$\pm$0.12 & 0.64$\pm$0.16 & 0.70$\pm$0.11 & 0.82$\pm$0.07 \\ IntelLab& 0.28$\pm$0.08 & 0.30$\pm$0.06 & 0.34$\pm$0.06 & 0.31$\pm$0.10 & 0.36$\pm$0.08 & 0.60$\pm$0.04 \\ iot& 0.65$\pm$0.09 & 0.68$\pm$0.06 & 0.72$\pm$0.07 & 0.71$\pm$0.11 & 0.77$\pm$0.10 & 0.88$\pm$0.07 \\ kddcup & 0.55$\pm$0.05 & 0.53$\pm$0.09 & 0.57$\pm$0.10 & 0.55$\pm$0.13 & 0.60$\pm$0.10 & 0.77$\pm$0.06 \\ susy & 0.60$\pm$0.11 & 0.63$\pm$0.08 & 0.67$\pm$0.09 & 0.65$\pm$0.13 & 0.68$\pm$0.13 & 0.79$\pm$0.07 \\ \midrule avg. rank & 5.17 & 4.55 & 4.13 & 3.25 & 2.90 & 1.00 \\ \bottomrule \label{tab:rlr3} \end{tabular} \end{table} \begin{table}[h] \centering \caption{RLR for RRBM--DD and reference drift detectors under concept-based poisoning attacks and sparsely labeled data. Results averaged over all labeling budgets, presented with standard deviation.} \begin{tabular}{lcccccc} \toprule Stream & EDDM & ECDD & FHDDM & RDDM & WSTD & RRBM--DD \\ \midrule HYP$_{I}$ & 0.28$\pm$0.07 & 0.29$\pm$0.06 & 0.37$\pm$0.10 & 0.34$\pm$0.13 & 0.37$\pm$0.13 & 0.69$\pm$0.06 \\ LED$_S$ & 0.25$\pm$0.05 & 0.32$\pm$0.05 & 0.44$\pm$0.08 & 0.41$\pm$0.10 & 0.46$\pm$0.08 & 0.75$\pm$0.07 \\ RBF$_G$ & 0.23$\pm$0.06 & 0.26$\pm$0.07 & 0.33$\pm$0.07 & 0.29$\pm$0.12 & 0.34$\pm$0.14 & 0.62$\pm$0.06 \\ RBF$_S$ & 0.18$\pm$0.04 & 0.19$\pm$0.06 & 0.20$\pm$0.04 & 0.18$\pm$0.05 & 0.22$\pm$0.04 & 0.59$\pm$0.04 \\ SEA$_G$ & 0.40$\pm$0.12 & 0.42$\pm$0.13 & 0.44$\pm$0.10 & 0.41$\pm$0.15 & 0.45$\pm$0.12 & 0.74$\pm$0.08 \\ TRE$_S$ & 0.09$\pm$0.03 & 0.11$\pm$0.04 & 0.14$\pm$0.04 & 0.13$\pm$0.04 & 0.17$\pm$0.04 & 0.51$\pm$0.05 \\ ecbdl14& 0.08$\pm$0.02 & 0.07$\pm$0.02 & 0.11$\pm$0.02 & 0.09$\pm$0.03 & 0.13$\pm$0.02 & 0.48$\pm$0.05 \\ higgs & 0.39$\pm$0.10 & 0.40$\pm$0.08 & 0.44$\pm$0.11 & 0.41$\pm$0.13 & 0.48$\pm$0.15 & 0.79$\pm$0.08 \\ IntelLab& 0.12$\pm$0.04 & 0.14$\pm$0.04 & 0.16$\pm$0.05 & 0.13$\pm$0.05 & 0.18$\pm$0.04 & 0.58$\pm$0.09 \\ iot& 0.51$\pm$0.13 & 0.52$\pm$0.16 & 0.56$\pm$0.12 & 0.55$\pm$0.16 & 0.60$\pm$0.13 & 0.81$\pm$0.11 \\ kddcup & 0.23$\pm$0.03 & 0.20$\pm$0.05 & 0.24$\pm$0.05 & 0.19$\pm$0.05 & 0.28$\pm$0.03 & 0.68$\pm$0.05 \\ susy & 0.31$\pm$0.07 & 0.34$\pm$0.07 & 0.36$\pm$0.09 & 0.37$\pm$0.10 & 0.39$\pm$0.10 & 0.70$\pm$0.07 \\ \midrule avg. rank & 5.38 & 4.14 & 4.66 & 3.72 & 2.10 & 1.00 \\ \bottomrule \label{tab:rlr4} \end{tabular} \end{table} \begin{figure}[h] \centering \tiny \resizebox{\columnwidth}{!}{ \begin{tikzpicture} \draw (1,0) -- (6,0); \foreach \x in {1,2,3,4,5,6} { \draw (\x, 0) -- ++(0,.1) node [below=0.15cm,scale=0.75] {\tiny \x}; \ifthenelse{\x < 6}{\draw (\x+.5, 0) -- ++(0,.03);}{} } \coordinate (c0) at (1.00,0); \coordinate (c1) at (2.90,0); \coordinate (c2) at (3.25,0); \coordinate (c3) at (4.13,0); \coordinate (c4) at (4.55,0); \coordinate (c5) at (5.17,0); \node (l0) at (c0) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny RRBM-DD}; \node (l1) at (c1) [above left=.15cm and 0.1cm, align=center, scale=0.7] {\tiny WSTD}; \node (l2) at (c2) [above left=.40cm and 0.1cm, align=left, scale=0.7] {\tiny RDDM}; \node (l3) at (c3) [above right=.40cm and 0.1cm, align=center, scale=0.7] {\tiny FHDDM}; \node (l4) at (c4) [above right=.25cm and 0.1cm, align=center, scale=0.7] {\tiny ECDD}; \node (l5) at (c5) [above right=.15cm and 0.1cm, align=left, scale=0.7] {\tiny EDDM}; \fill[fill=gray,fill opacity=0.5] (1.00,-0.08) rectangle (1.75,0.08); \foreach \x in {0,...,5} { \draw (l\x) -| (c\x); }; \end{tikzpicture} } \caption{The Bonferroni-Dunn test for comparison among drift detectors under instance-based poisoning attacks and sparsely labeled data, based on RLR and all examined labeling ratios.} \label{fig:bon5} \end{figure} \begin{figure}[h] \centering \tiny \resizebox{\columnwidth}{!}{ \begin{tikzpicture} \draw (1,0) -- (6,0); \foreach \x in {1,2,3,4,5,6} { \draw (\x, 0) -- ++(0,.1) node [below=0.15cm,scale=0.75] {\tiny \x}; \ifthenelse{\x < 6}{\draw (\x+.5, 0) -- ++(0,.03);}{} } \coordinate (c0) at (1.00,0); \coordinate (c1) at (2.10,0); \coordinate (c2) at (3.72,0); \coordinate (c3) at (4.66,0); \coordinate (c4) at (4.14,0); \coordinate (c5) at (5.68,0); \node (l0) at (c0) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny RRBM-DD}; \node (l1) at (c1) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny WSTD}; \node (l2) at (c2) [above right=.45cm and 0.1cm, align=left, scale=0.7] {\tiny RDDM}; \node (l3) at (c3) [above right=.15cm and 0.1cm, align=center, scale=0.7] {\tiny FHDDM}; \node (l4) at (c4) [above right=.30cm and 0.1cm, align=center, scale=0.7] {\tiny ECDD}; \node (l5) at (c5) [above right=.15cm and 0.1cm, align=left, scale=0.7] {\tiny EDDM}; \fill[fill=gray,fill opacity=0.5] (1.00,-0.08) rectangle (1.75,0.08); \foreach \x in {0,...,5} { \draw (l\x) -| (c\x); }; \end{tikzpicture} } \caption{The Bonferroni-Dunn test for comparison among drift detectors under concept-based poisoning attacks and sparsely labeled data, based on RLR and all examined labeling ratios.} \label{fig:bon6} \end{figure} Sparse access to class labels significantly impacts state-of-the-art drift detectors. All of them were designed for fully supervised cases and use both feature values and class labels to compute statistics used in drift detection. By limiting the number of labeled instances they obtain, the estimators of used statistics become less and less reliable. Detectors are forced to make decisions based on a small, potentially non-representative sample and thus are much more prone to errors. This is already a very difficult problem, but becomes even more challenging when combined with the presence of adversarial concept drift. RRBM--DD, due to its trainable nature is capable of much better performance even under limited access to class labels. As we track the progress of the stream using regression-based trends, we can still compute them efficiently from a smaller sample size. Furthermore, used robust gradient was designed by its authors to work with smaller data streams \citep{Holland:2019}. \smallskip \noindent \textbf{RQ3 answer.} Yes, RRBM-DD is capable of efficiently handling sparsely labeled data streams, without sacrificing its accuracy and robustness to adversarial concept drift. \subsection{Experiment 4: Ablation study} \label{sec:exp4} The fourth and final experiment was designed in the form of ablation study. Here, we want to switch off different components of RRBM--DD to gain understanding what is the source of its desirable performance and under what specific scenarios which component offers the most improvement to our drift detector. Tables~\ref{tab:rlr5} and~\ref{tab:rlr6} show the LRL metric performance averaged over fully and sparsely labeled data streams for four settings -- the proposed RRBM--DD model, its basic version RBM--DD without any robustness enhancements (discussed in Section 4.1), RBM--DD$_{RG}$ using only robust gradient calculation and RBM--DD$_{RE}$ using only robust energy function for estimating network state. \begin{table}[h] \centering \caption{Ablation results for RRBM--DD according to RLR under instance-based poisoning attacks. Results averaged over fully and sparsely labeled benchmarks, presented with standard deviation.} \begin{tabular}{lcccc} \toprule Stream & RBM-DD & RBM--DD$_{RG}$ & RBM--DD$_{RE}$ & RRBM-DD \\ \midrule HYP$_{I}$ & 0.58$\pm$0.10 & 0.77$\pm$0.09 & 0.64$\pm$0.09 & 0.82$\pm$0.09 \\ LED$_S$ & 0.66$\pm$0.12 & 0.80$\pm$0.07 & 0.72$\pm$0.10 & 0.84$\pm$0.06 \\ RBF$_G$ & 0.52$\pm$0.11 & 0.66$\pm$0.09 & 0.59$\pm$0.10 & 0.72$\pm$0.09 \\ RBF$_S$ & 0.47$\pm$0.08 & 0.58$\pm$0.09 & 0.53$\pm$0.07 & 0.66$\pm$0.08 \\ SEA$_G$ & 0.68$\pm$0.11 & 0.78$\pm$0.10 & 0.74$\pm$0.10 & 0.82$\pm$0.10 \\ TRE$_S$ & 0.41$\pm$0.10 & 0.59$\pm$0.06 & 0.48$\pm$0.08 & 0.65$\pm$0.05 \\ ecbdl14 & 0.48$\pm$0.11 & 0.58$\pm$0.07 & 0.53$\pm$0.09 & 0.61$\pm$0.07 \\ higgs & 0.73$\pm$0.11 & 0.82$\pm$0.09 & 0.77$\pm$0.10 & 0.85$\pm$0.08 \\ IntelLab& 0.38$\pm$0.08 & 0.59$\pm$0.08 & 0.52$\pm$0.08 & 0.66$\pm$0.08 \\ iot & 0.77$\pm$0.10 & 0.86$\pm$0.05 & 0.83$\pm$0.08 & 0.90$\pm$0.05 \\ kddcup & 0.61$\pm$0.11 & 0.72$\pm$0.08 & 0.66$\pm$0.10 & 0.79$\pm$0.07 \\ susy & 0.70$\pm$0.12 & 0.80$\pm$0.09 & 0.73$\pm$0.09 & 0.83$\pm$0.09 \\ \midrule avg. rank & 4.00 & 2.05 & 2.95 & 1.00 \\ \bottomrule \label{tab:rlr5} \end{tabular} \end{table} \begin{table}[h] \centering \caption{Ablation results for RRBM--DD according to RLR under concept-based poisoning attacks. Results averaged over fully and sparsely labeled benchmarks, presented with standard deviation.} \begin{tabular}{lcccc} \toprule Stream & RBM-DD & RBM--DD$_{RG}$ & RBM--DD$_{RE}$ & RRBM-DD \\ \midrule HYP$_{I}$ & 0.38$\pm$0.11 & 0.44$\pm$0.10 & 0.65$\pm$0.06 & 0.72$\pm$0.07 \\ LED$_S$ & 0.50$\pm$0.09 & 0.57$\pm$0.10 & 0.68$\pm$0.12 & 0.78$\pm$0.11 \\ RBF$_G$ & 0.36$\pm$0.15 & 0.45$\pm$0.11 & 0.56$\pm$0.07 & 0.64$\pm$0.08 \\ RBF$_S$ & 0.25$\pm$0.05 & 0.38$\pm$0.05 & 0.50$\pm$0.05 & 0.61$\pm$0.05 \\ SEA$_G$ & 0.43$\pm$0.10 & 0.57$\pm$0.11 & 0.68$\pm$0.10 & 0.78$\pm$0.10 \\ TRE$_S$ & 0.16$\pm$0.04 & 0.31$\pm$0.06 & 0.42$\pm$0.09 & 0.55$\pm$0.08 \\ ecbdl14 & 0.14$\pm$0.04 & 0.29$\pm$0.05 & 0.40$\pm$0.08 & 0.51$\pm$0.07 \\ higgs & 0.51$\pm$0.13 & 0.65$\pm$0.11 & 0.76$\pm$0.10 & 0.83$\pm$0.11 \\ IntelLab& 0.20$\pm$0.04 & 0.41$\pm$0.07 & 0.53$\pm$0.08 & 0.64$\pm$0.08 \\ iot & 0.64$\pm$0.13 & 0.69$\pm$0.12 & 0.74$\pm$0.10 & 0.83$\pm$0.11 \\ kddcup & 0.26$\pm$0.06 & 0.53$\pm$0.05 & 0.62$\pm$0.05 & 0.72$\pm$0.05 \\ susy & 0.37$\pm$0.11 & 0.50$\pm$0.09 & 0.63$\pm$0.07 & 0.75$\pm$0.08 \\ \midrule avg. rank & 4.00 & 2.90 & 2.10 & 1.00 \\ \bottomrule \label{tab:rlr6} \end{tabular} \end{table} The basic RBM--DD performs only slightly better than state-of-the-art drift detectors. This shows that the excellent performance of RRBM--DD in the face of adversarial concept drift cannot be only contributed to its trainable nature or used neural model. One must notice that both gradient and energy function of RRBM--DD offer significant improvements on their own, but in specific conditions. Robust gradient offers a higher boost to robustness when dealing with instance-based poisoning attacks. This can be explained by the scaling approach used in it (see Eq.~\ref{eq:rgd2}--~\ref{eq:rgd4}), as it filters out instances that differ significantly from the core concept of each class. This makes it very robust to instance by instance attacks, as they will not affect significantly the training procedure of RRBM--DD. On the other hand, the robust energy function (see Eq.~\ref{eq:ref1}) offers much better performance when dealing with concept-based poisoning attacks. This can be contributed to the noise model that is embedded in said function. It allows to model not instances but entire noisy distributions, effectively cutting out adversarial concepts (i.e., disjuncts of instances) from strongly impacting the weight update of RRBM-DD. \smallskip \noindent \textbf{RQ4 answer.} RRBM--DD benefits from interplay between both of its robustness enhancing components. They offer diverse, yet mutually complementary functionalities and their combination makes RRDM-DD robust to various types of adversarial attacks. \section{Conclusions and future works} \label{sec:con} \noindent \textbf{Summary.} In this paper, we have presented a novel scenario of learning from data streams under adversarial concept drift. We proposed that two types of change may be present during the stream processing. Valid concept drift represents natural changes in the underlying data characteristics and must be correctly detected in order to allow a smooth adaptation of the model. Adversarial concept drift represents a poisoning attack from a malicious party that aims at hindering or disabling the classification system. We discussed the negative impacts of adversarial drift on classifiers and proposed a taxonomy of two types of attacks: instance-based and concept-based. We examined state-of-the-art concept drift detectors and concluded that none of them is capable of handling adversarial instances. To address this challenging task we proposed a novel approach that is robust to the presence of adversarial instances: Robust Restricted Boltzmann Machine Drift Detector. We presented how this fully trainable neural model can be used for efficient tracking of trends in the stream and accurate drift recognition. We enhanced our drift detector with the improved gradient calculation method and energy function with an embedded noise model. These modifications made our model robust to adversarial concept drift, while still being sensitive to valid drifts. Finally, we have introduced Relative Loss of Robustness, a novel measure for evaluating the performance of drift detectors and other streaming algorithms under adversarial concept drift. \smallskip \noindent \textbf{Main conclusions.} The efficacy of RRBM--DD was evaluated on the basis of an extensive experimental study. The first two experiments compared RRBM--DD with five state-of-the-art drift detectors under instance-based and concept-based poisoning attacks. Obtained results clearly backed-up our observations that none of the existing drift detectors displays robustness to adversarial instances. RRBM--DD offered not only excellent detection rates of valid concept drifts, but also high robustness to all types and intensity levels of adversarial attacks. These characteristics were valid in both fully and sparsely labeled data streams, making RRBM-DD a highly suitable algorithm for a plethora of real-life applications. Finally, we have conducted an ablation study to understand the impact of RRBM-DD components on its robustness. Interestingly, both components were useful in specific tasks. The robust gradient algorithm was contributing most when dealing with instance-based poisoning attacks, while robust energy function offered significant gains for RRBM-DD when handling concept-based poisoning attacks. \smallskip \noindent \textbf{Future works.} RRBM--DD opens several directions for future research. We plan to modify its cost functions in order to tackle the issue of simultaneous adversarial concept drift and dynamic class imbalance, as well as develop deep architectures based on RRBM--DD. \bibliographystyle{spbasic}
{'timestamp': '2020-09-22T02:19:07', 'yymm': '2009', 'arxiv_id': '2009.09497', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09497'}
arxiv
\section{Introduction} \label{sec:intro} Neural machine translation (NMT) \citep{DBLP:journals/corr/SutskeverVL14,DBLP:journals/corr/BahdanauCB14:original} enables end-to-end training of translation models and is known to give state-of-the-art results for a large variety of language pairs. NMT for high-resource language pairs is straightforward: choose an NMT architecture and implementation, and train a model on all existing data. In contrast, for low-resource language pairs, this does not work well due to the inability of neural networks to generalize from small amounts of data. One reason for this is the strong over-fitting potential of neural models \citep{DBLP:conf/emnlp/ZophYMK16:original,koehn-knowles-2017-six}. There are several solutions that address this issue of which the two most effective ones are transfer learning and model regularization. Transfer learning can sometimes be considered as data regularization and comes in the form of monolingual or cross-lingual (multilingual) transfer learning \citep{DBLP:conf/emnlp/ZophYMK16:original, DBLP:conf/icml/SongTQLL19}, pseudo-parallel data generation (back-translation) \citep{sennrich-haddow-birch:2016:P16-11}, or multi-task learning \citep{eriguchi-etal-2017-learning}. On the other hand, model regularization techniques place constraints on the learning of model parameters in order to aid the model to learn robust representations that positively impact model performance. Among existing model regularization methods, dropout \citep{10.5555/2627435.2670313} is most commonly used and is known to be effective regardless of the size of data. We thus focus on designing a technique that can complement dropout especially in an extremely low-resource situation. The most common way to train NMT models is to minimize a softmax cross-entropy loss, i.e., cross-entropy between the softmax distribution and the smoothed label distribution typically represented with a one-hot vector. In other words, the NMT model is trained to produce a softmax distribution that is similar to the label. In high-resource settings, this may never happen due to the diversity of label sequences. However, in low-resource settings, due to lack of the diversity, there is a high chance of this occurring and over-fitting is said to take place. We consider that a simple manipulation of the softmax distribution may help prevent it. This paper presents our investigation into \emph{softmax tempering} \citep{DBLP:journals/corr/HintonVD15} during training NMT models in order to address the over-fitting issue. Softmax tempering is realized by simply dividing the pre-softmax logits with a positive real number greater than 1.0. This leads to a smoother softmax probability distribution, which is then used to compute the cross-entropy loss. Softmax tempering has been devised and used regularly in knowledge distillation \citep{DBLP:journals/corr/HintonVD15,kim-rush-2016-sequence}, albeit for different purposes. We regard softmax tempering as a means of deliberately making the softmax distribution noisy during training with the expectation that this will have a positive impact on the final translation quality. We primarily evaluate the utility of softmax tempering on extremely low-resource settings involving English and 11 languages in the Asian Languages Treebank (ALT) \citep{ALT:16}. Our experiments reveal that softmax tempering with a reasonably high temperature improves the translation quality. Furthermore, it makes the greedy search performance of the models trained with softmax tempering comparable to or better than the performance of the beam search using the models that are trained without softmax tempering, enabling faster decoding. We then expand the scope of our study to high-resource settings, taking the WMT 2019 English-to-German translation task, as well as multilingual settings using the ALT data. We also show that softmax tempering improves the performance of NMT models using recurrently stacked layers that heavily share parameters. Furthermore, we clarify the relationship between softmax tempering and dropout, i.e., the most widely used and effective regularization mechanism. Finally, we analyze the impact of softmax tempering on the softmax distributions and on the gradient flows during training. \section{Related Work} \label{sec:relwork} The method presented in this paper is a training technique aimed to improve the quality of NMT models with a special focus on the performance of low-resource scenarios. Work on knowledge distillation \citep{DBLP:journals/corr/HintonVD15} for training compact models is highly related to our application of softmax tempering. However, the purpose of softmax tempering for knowledge distillation is to smooth the student and teacher distributions which is known to have a positive impact on the quality of student models. In our case, we use softmax tempering to make softmax distributions noisy during training a model from scratch to avoid over-fitting. In the context of NMT, \citet{kim-rush-2016-sequence} did experiment with softmax tempering. However, their focus was on model compression and they did not experiment with low-resource settings. In contrast, our application of softmax tempering does have a strong positive impact on decoding speed because we observed that greedy search performs as well as beam search, similarly to \citet{kim-rush-2016-sequence}. We refer readers to orthogonal methods for speeding up NMT, such as weight pruning \citep{see-etal-2016-compression}, quantization \citep{Lin:2016:FPQ:3045390.3045690}, and binarization \citep{Courbariaux:16, oda-etal-2017-neural}. We regard softmax tempering as a regularization technique, since it adds noise to the NMT model. Thus, it is related to techniques, such as $L_{N}$ regularization \cite{10.1145/1015330.1015435}, dropout \cite{10.5555/2627435.2670313}, and tuneout \cite{miceli-barone-etal-2017-regularization}. The most important aspect of our method is that it is only applied at the softmax layer whereas other regularization techniques add noise to several parts of the entire model. Furthermore, our method is intented to complement the most popular technique, i.e., dropout, and not necessarily replace it. We primarily focus on low-resource language pairs and in this context data augmentation via back-translating additional monolingual data \citep{sennrich-haddow-birch:2016:P16-11} to generate pseudo-parallel corpora is one of the most effective approaches. In contrast, our method does not need any additional data on top of the given parallel data. In the literature, multilingualism has been successfully leveraged for improving translation quality \citep{DBLP:journals/corr/FiratCB16:original,DBLP:conf/emnlp/ZophYMK16:original,dabre-etal-2019-exploiting}, and our method could possibly complement the impact of multilingualism due to its data and language independent nature. Recently, pre-training on monolingual data \citep{devlin-etal-2019-bert,DBLP:conf/icml/SongTQLL19,mao-etal-2020-jass} has been proven to strongly improve the performance of extremely low-resource language pairs. However, this requires enormous time and resources to pre-train large models. In contrast, our method can help improve performance if one does not possess the resources to perform massive pre-training, even though it could also be used on top of pre-training based methods. \section{Softmax Tempering} \label{sec:method} Softmax tempering \citep{DBLP:journals/corr/HintonVD15} consists of two tiny changes in the implementation of the training phase of any neural model used for classification. Assume that $D_{i}\in\mathbb{R}^{v}$ is the output of the decoder for the $i$-th word in the target language sentence, $Y_{i}$, where $v$ stands for the target vocabulary size, and that $P_{i} = P(Y_{i}|Y_{<i},X)={\mathit{softmax}}(D_{i})$ represents the softmax function producing the probability distribution, where $X$ and $Y_{<i}$ indicate the given source sentence and the past decoder output, respectively. Let $L_{i} \in \mathbb{R}^{v}$ be the one-hot reference label for the $i$-th prediction. Then, the cross-entropy loss for the prediction is computed as $\mathit{loss}_{i} = - \langle \log(P_{i}), L_{i} \rangle$, where $\langle \cdot , \cdot \rangle $ is the inner product of two vectors. Let $T\in\mathbb{R}^{+}$ be the temperature hyper-parameter. Then, the prediction with softmax tempering ($P^{\mathit{temp}}_{i} = P^{\mathit{temp}}(Y_{i}|Y_{<i},X)$) and the corresponding cross-entropy loss ($\mathit{loss}_{i}^{\mathit{temp}}$) are formalized as follows. \begin{align} P^{\mathit{temp}}_{i} &= {\mathit{softmax}}(D_{i}/T), \label{eq:prediction}\\ \mathit{loss}_{i}^{\mathit{temp}} &= -\langle \log(P^{\mathit{temp}}_{i}), L_{i} \rangle \cdot T \label{eq:loss} \end{align} By referring to \Eq{prediction}, when $T$ is greater than 1.0, the logits, $D_{i}$, are down-scaled which leads to a smoother probability distribution before loss is computed. The smoother the distribution becomes, the higher its entropy is and hence the more uncertain the prediction is. Because loss is to be minimized, back-propagation will force the model to generate logits to counter the smoothing effect of temperature. During decoding with a model trained in this way, the temperature coefficient is not used and the logits will be such that they yield a sharper softmax distribution compared to those of a model trained without softmax tempering. The gradients are altered by tempering, and we thus re-scale the loss by the temperature as shown in \Eq{loss}. This is inspired by the loss scaling method used in knowledge distillation \citep{DBLP:journals/corr/HintonVD15}, where both the student and teacher's softmaxes are tempered and the loss is multiplied by the square of the temperature. \section{Experiment} \label{sec:exp} To evaluate the effectiveness of softmax tempering, we conducted experiments on both low-resource and high-resource settings. \subsection{Datasets} \label{sec:datasets} We experimented with the Asian Languages Treebank (ALT),\footnote{\url{http://www2.nict.go.jp/astrec-att/member/mutiyama/ALT/ALT-Parallel-Corpus-20190531.zip}} comprising English (En) news articles consisting of 18,088 training, 1,000 development, and 1,018 test sentences manually translated into 11 Asian languages: Bengali (Bn), Filipino (Fil), Indonesian (Id), Japanese (Ja), Khmer (Km), Lao (Lo), Malay (Ms), Burmese (My), Thai (Th), Vietnamese (Vi), and Chinese (Zh). We focused on translation to and from English to each of these 11 languages. As a high-resource setting, we also experimented with the WMT 2019 English-to-German (\unidir{En}{De}) translation task.\footnote{\url{http://www.statmt.org/wmt19/translation-task.html}} For training, we used the Europarl and the ParaCrawl corpora containing 1.8M and 37M sentence pairs, respectively. For evaluation, we used the WMT 2019 development and test sets consisting of 2,998 and 1,997 lines, respectively. \subsection{Implementation Details} \label{sec:implementation} We evaluated softmax tempering on top of the Transformer model \citep{NIPS2017_7181}, because it gives the state-of-the-art results for NMT. More specifically, we employed the following models. \begin{itemize}\itemsep=0mm \item \unidir{En}{XX} and \unidir{XX}{En} ``Transformer Base'' models where XX is an Asian language in the ALT dataset. \item \unidir{En}{De} ``Transformer Base'' and ``Transformer Big'' models. \end{itemize} We modified the code of the Transformer model in the tensor2tensor v1.14. For ``Transformer Base'' and ``Transformer Big'' models, we used the hyper-parameter settings in \emph{transformer\_base\_single\_gpu} and \emph{transformer\_big\_single\_gpu}, respectively where \textbf{label smoothing of 0.1 is used by default}. We used the internal sub-word tokenization mechanism of tensor2tensor with separate source and target language vocabularies of size 8,192 and 32,768 for low-resource and high-resource settings, respectively. We trained our models for each of the softmax temperature values, 1.0 (default softmax), 1.2, 1.4, 1.6, 1.8, 2.0, 3.0, 4.0, 5.0, and 10.0. We used early-stopping on the BLEU score \citep{Papineni:2002:BMA:1073083.1073135} for the development set which was evaluated every after 1k iterations. Our early-stopping mechanism halts training when the BLEU score does not vary by over 0.1 BLEU over 10 consecutive evaluation steps. For decoding, we averaged the final 10 checkpoints, and evaluated beam search with beam sizes (2, 4, 6 ,8, 10, and 12) and length penalties (0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, and 1.4) and greedy search. \begin{table*}[t] \centering \scalebox{.75}{ \begin{tabular}{ll|rrrrrrrrrrr} \hline \multirow{2}{*}{$T$} &\multirow{2}{*}{Decoding} & \multicolumn{11}{c}{En-to-XX} \\ & & \multicolumn{1}{c}{Bn} & \multicolumn{1}{c}{Fil} & \multicolumn{1}{c}{Id} & \multicolumn{1}{c}{Ja} & \multicolumn{1}{c}{Km} & \multicolumn{1}{c}{Lo} & \multicolumn{1}{c}{Ms} & \multicolumn{1}{c}{My} & \multicolumn{1}{c}{Th} & \multicolumn{1}{c}{Vi} & \multicolumn{1}{c}{Zh} \\\hline 1.0 &Greedy & 3.5 & 24.3 & 27.4 & 13.4 & 19.3 & 11.5 & 31.5 & 8.3 & 13.7 & 24.0 & 10.4 \\ 1.0 &Beam & 4.2 & \textbf{25.9} & 28.7 & 15.1 & \textbf{21.5} & \textbf{13.1} & 32.8 & 9.1 & \textbf{16.0} & \textbf{26.6} & 12.1 \\ ${T_{\mathit{opt}}}$ &Greedy & 4.5 & 25.7 & 29.5\dag & 15.5 & 20.7 & 12.2 & 33.7\dag & 9.3 & 15.6 & 25.7 & 12.8\dag \\ ${T_{\mathit{opt}}}$ &Beam & \textbf{4.6}\dag & \textbf{25.9} & \textbf{29.6}\dag & \textbf{15.9}\dag & 21.2 & 12.2 & \textbf{33.8}\dag & \textbf{9.7} & 15.8 & 26.1 & \textbf{13.0}\dag \\ \multicolumn{2}{l|}{Value for ${T_{\mathit{opt}}}$} & 5.0 & 3.0 & 4.0 & 4.0 & 3.0 & 10.0 & 4.0 & 5.0 & 5.0 & 5.0 & 4.0 \\ \hline\hline \multirow{2}{*}{$T$} &\multirow{2}{*}{Decoding} & \multicolumn{11}{c}{XX-to-En} \\ & & \multicolumn{1}{c}{Bn} & \multicolumn{1}{c}{Fil} & \multicolumn{1}{c}{Id} & \multicolumn{1}{c}{Ja} & \multicolumn{1}{c}{Km} & \multicolumn{1}{c}{Lo} & \multicolumn{1}{c}{Ms} & \multicolumn{1}{c}{My} & \multicolumn{1}{c}{Th} & \multicolumn{1}{c}{Vi} & \multicolumn{1}{c}{Zh} \\\hline 1.0 &Greedy & 7.1 & 22.2 & 25.1 & 8.7 & 14.9 & 9.8 & 27.4 & 7.8 & 10.5 & 19.4 & 9.4 \\ 1.0 &Beam & 8.5 & 24.1 & 26.5 & 10.1 & 16.5 & \textbf{11.9} & 28.6 & 9.4 & 12.5 & 21.1 & 11.0 \\ ${T_{\mathit{opt}}}$ &Greedy & 9.1 & 24.7 & 27.5\dag & 11.0\dag & 16.8 & 11.4 & 29.7\dag & 11.7\dag & 12.2 & 21.3 & 11.5 \\ ${T_{\mathit{opt}}}$ &Beam & \textbf{9.3}\dag& \textbf{25.0}\dag & \textbf{27.6}\dag & \textbf{11.3}\dag & \textbf{17.1} & 11.7 & \textbf{29.9}\dag & \textbf{12.0}\dag & \textbf{12.6} & \textbf{21.5} & \textbf{12.1}\dag \\ \multicolumn{2}{l|}{Value for ${T_{\mathit{opt}}}$} & 5.0 & 4.0 & 3.0 & 5.0 & 4.0 & 5.0 & 4.0 & 4.0 & 4.0 & 4.0 & 4.0 \\ \hline \end{tabular}% } \caption{BLEU scores obtained by non-tempered ($T=1.0$) and tempered ($T={T_{\mathit{opt}}}>1.0$) NMT models with greedy and beam search for the ALT \unidir{En}{XX} and \unidir{XX}{En} translation tasks, where XX is one of the Asian languages in the ALT dataset. Best BLEU scores are in bold. ``{\dag}'' marks scores that are significantly ($p\le 0.05$) better than non-tempered model's (oracle) beam search scores.} \label{tab:alt-results-low} \end{table*} \subsection{Evaluation Criteria} We evaluated translation quality of each model using BLEU \citep{Papineni:2002:BMA:1073083.1073135} provided by \emph{SacreBleu} \cite{post-2018-call}. The optimal temperature (${T_{\mathit{opt}}}$) for the tempered model was determined based on greedy search BLEU score on the development set. On the other hand, two hyper-parameters for beam search, i.e., beam size and length penalty, are not searched. The best beam search results reported in this paper are determined after computing BLEU scores on the test set, i.e., oracle. We used statistical significance testing\footnote{\url{https://github.com/moses-smt/mosesdecoder/blob/master/scripts/analysis/bootstrap-hypothesis-difference-significance.pl}} to determine if differences in BLEU are significant. \subsection{Results in Low-Resource Settings} \label{sec:lrresults} \Tab{alt-results-low} shows the greedy and beam search BLEU scores along with the optimal temperature (${T_{\mathit{opt}}}$) for translation to and from Asian languages and compare them against those obtained by non-tempered models. Except for a few language pairs, the greedy search BLEU scores of the best performing tempered models are higher than the beam search BLEU scores of non-tempered models. \Fig{enmsvariation} shows how the greedy and beam search results vary with the temperature, taking \unidir{En}{Ms} translation as an example.\footnote{We show only one translation direction due to lack of space. Kindly, refer to our supplementary material for all translation directions.} As the temperature is raised, the greedy search BLEU score increases and begins approaching the beam search score. At temperature values between 2.0 and 5.0, not only does the greedy search score exceed that of a non-tempered model, but that the greedy and beam search scores are barely any different. However, increasing the temperature beyond 10.0 always has a negative effect on the translation quality, because it leads to a highly smoothed probability distribution, quantified by high entropy, that does not seem to be useful for NMT training. Consequently, we conclude that training with reasonably high temperature (between 2.0 and 5.0), softmax tempering has a positive impact on translation quality for extremely low-resource settings. \begin{figure}[t] \centering \includegraphics[width=.95\columnwidth]{c-greedy/en-ms.pdf} \caption{Greedy and beam search BLEU scores with temperature for \unidir{En}{Ms} translation.} \label{fig:enmsvariation} \end{figure} We also computed the similarity between the greedy and beam search (beam size 4, length penalty 1.0) translations by computing the BLEU score between them, regarding the greedy search results as references. \Tab{beamgreedybleugap} reports on the greedy-beam search similarities for 4 translation directions for several different values of temperature. For non-tempered models, the BLEU scores were around 30 to 60, and as the temperature increases, so does the BLEU score. This indicates that greedy and beam search results grow to be similar and the most likely reason is that training with softmax tempering forces the model to be extremely precise. \begin{table}[t] \centering \scalebox{.75}{ \begin{tabular}{c|cccc} \hline $T$ &\unidir{Vi}{En} &\unidir{En}{Vi} &\unidir{Ja}{En} &\unidir{En}{Ja}\\ \hline 1.0 & 53.4 & 61.5 & 32.7 & 40.5 \\ 2.0 & 72.6 & 79.2 & 53.2 & 59.6 \\ 3.0 & 81.9 & 84.1 & 67.2 & 69.7 \\ 5.0 & 86.7 & 89.4 & 75.4 & 80.0 \\ \hline \end{tabular}% } \caption{Similarity between the beam and greedy search results on the test set, indicated by BLEU score.} \label{tab:beamgreedybleugap} \end{table} \begin{table}[t] \centering \scalebox{.75}{ \begin{tabular}{lll|rr} \hline \multirow{2}{*}{Model} &\multirow{2}{*}{Training} &\multirow{2}{*}{$T$} &\multicolumn{2}{c}{BLEU}\\ &&&Greedy &Beam\\ \hline \multirow{4}{*}{Base} &\multirow{2}{*}{EP} &1.0 &23.6 &25.8\\ &&1.4 &25.5 &\textbf{27.2}\dag\\\cline{2-5} &\multirow{2}{*}{EP+PC} &1.0 &28.2 &29.2\\ &&1.2 &29.1 &\textbf{30.1}\dag\\ \hline \multirow{4}{*}{Big} &\multirow{2}{*}{EP} &1.0 &26.8 &29.4\\ &&1.2 &29.1 &\textbf{30.2}\dag\\\cline{2-5} &\multirow{2}{*}{EP+PC} &1.0 &32.7 &33.7\\ &&1.2 &33.6 &\textbf{34.5}\dag\\ \hline \end{tabular}% } \caption{BLEU scores obtained by non-tempered ($T=1.0$) and tempered ($T={T_{\mathit{opt}}}>1.0$) NMT models for high-resource \unidir{En}{De} translation task trained on Europarl (EP) and ParaCrawl (PC) corpora.} \label{tab:wmt-results-high} \end{table} \begin{table*}[t] \centering \scalebox{.75}{ \begin{tabular}{llll|ccccccccccc} \hline Direction &Model &$T$ &Decoding & Bn & Fil & Id & Ja & Km & Lo & Ms & My & Th & Vi & Zh \\\hline \multirow{8}{*}{Unidirectional} &\multirow{4}{*}{non-RS} &1.0 &Greedy & 3.5 & 24.3 & 27.4 & 13.4 & 19.3 & 11.5 & 31.5 & 8.3 & 13.7 & 24.0 & 10.4 \\ &&1.0 &Beam & 4.2 & \textbf{25.9} & 28.7 & 15.1 & \textbf{21.5} & \textbf{13.1} & 32.8 & 9.1 & \textbf{16.0} & \textbf{26.6} & 12.1 \\ &&${T_{\mathit{opt}}}$ &Greedy & 4.5 & 25.7 & 29.5\dag & 15.5 & 20.7 & 12.2 & 33.7\dag & 9.3 & 15.6 & 25.7 & 12.8 \\ &&${T_{\mathit{opt}}}$ &Beam & \textbf{4.6} & \textbf{25.9} & \textbf{29.6}\dag & \textbf{15.9}\dag & 21.2 & 12.2 & \textbf{33.8}\dag & \textbf{9.7} & 15.8 & 26.1 & \textbf{13.0} \\ \cline{2-15} &\multirow{4}{*}{RS} &1.0 &Greedy & 3.2 & 21.5 & 24.3 & 11.8 & 17.4 & 10.1 & 28.6 & 7.0 & 11.5 & 22.4 & 8.9 \\ &&1.0 &Beam & 3.7 & \textbf{23.7} & 25.8 & \textbf{13.6} & \textbf{19.8} & \textbf{11.8} & 30.4 & 8.2 & \textbf{13.8} & \textbf{24.9} & 10.7 \\ &&${T_{\mathit{opt}}}$ &Greedy & 3.6 & 23.0 & 25.8 & 13.1 & 18.7 & 10.4 & 30.7 & 8.3 & 13.5 & 23.1 & 10.6 \\ &&${T_{\mathit{opt}}}$ &Beam & \textbf{3.9} & 23.4 & \textbf{26.2} & \textbf{13.6} & 19.1 & 11.4 & \textbf{30.9} & \textbf{8.4} & \textbf{13.8} & 23.5 & \textbf{11.2} \\ \hline \multirow{8}{*}{One-to-many} &\multirow{4}{*}{non-RS} &1.0 &Greedy & 6.2 & 24.9 & 27.0 & 18.9 & 23.0 & 14.7 & 30.9 & 12.9 & 19.0 & 27.4 & 14.3 \\ &&1.0 &Beam & 7.1 & 26.5 & 28.6 & 21.1 & 24.7 & 15.5 & 32.1 & 13.8 & 20.6 & 29.5 & 16.2 \\ &&${T_{\mathit{opt}}}$ &Greedy & 7.0 & 27.6\dag & 30.0\dag & 21.2 & 24.4 & 15.5 & 34.2\dag & 14.2 & 20.5 & 30.1 & 16.3 \\ &&${T_{\mathit{opt}}}$ &Beam & \textbf{7.5} & \textbf{28.6}\dag & \textbf{30.3}\dag & \textbf{22.7}\dag & \textbf{25.4} & \textbf{16.2}\dag & \textbf{34.9}\dag & \textbf{15.1}\dag & \textbf{21.9}\dag & \textbf{31.6}\dag & \textbf{17.5}\dag \\ \cline{2-15} &\multirow{4}{*}{RS} &1.0 &Greedy & 6.6 & 26.4 & 28.4 & 19.6 & 23.5 & 14.8 & 32.3 & 13.2 & 19.9 & 28.8 & 14.9 \\ &&1.0 &Beam & \textbf{7.5} & \textbf{28.4} & \textbf{30.0} & \textbf{21.3} & \textbf{25.2} & 16.1 & \textbf{33.9} & 14.3 & \textbf{21.7} & \textbf{30.7} & \textbf{17.2} \\ &&${T_{\mathit{opt}}}$ &Greedy & 6.6 & 26.6 & 28.8 & 19.7 & 23.7 & 14.6 & 32.5 & 13.4 & 20.0 & 28.7 & 15.1 \\ &&${T_{\mathit{opt}}}$ &Beam & 7.1 & 27.0 & 29.5 & 20.9 & 24.6 & \textbf{16.3} & 33.1 & \textbf{14.6} & 21.2 & 30.4 & 16.7 \\ \hline \end{tabular}% } \caption{BLEU scores obtained by unidirectional and one-to-many English-to-Asian NMT models with and without recurrent stacking (RS) of layers and softmax tempering. The values for ${T_{\mathit{opt}}}$ for multilingual models were 1.2 to 2.0, while those for unidirectional model were 3.0 to 5.0, depending on the target language.} \label{tab:rsnmtmlnmt} \end{table*} \subsection{Results in High-Resource Settings} \label{sec:rrresults} \Tab{wmt-results-high} gives the BLEU scores for the high-resource \unidir{En}{De} translation task. The results indicate that compared to the low-resource settings, relatively lower temperature values are effective for improving translation quality. While the improvements in translation quality are not as large as those in the low-resource settings, greedy and beam search improve by 0.8 to 2.3 BLEU points for temperature values around 1.2 to 1.6. We noticed that higher temperature values do bridge the gap between greedy and beam search performances. However, since they also reduce translation quality, we do not recommend using high temperature values in high-resource settings. For the models trained only on the Europarl corpus (EP), the greedy and beam search performances of the Transformer Base model starts approaching those of the Transformer Big model. \subsection{Impact on Training and Decoding Speed} Although training with softmax tempering makes it difficult for a model to over-fit the label distributions, we did not notice any impact on the training time. This indicates that the improvements are unrelated to longer training times. With regard to decoding, in low-latency settings, we can safely use greedy search with tempered models given that it is as good as, if not better than, beam search using non-tempered models. Thus, by comparing the greedy and beam search decoding speeds, we can determine the benefits that softmax tempering brings in low-latency settings. Greedy search decoding of the \unidir{Vi}{En}\footnote{For ALT tasks, decoding times are very similar when translating into English due to it being a multi-parallel corpus.} test set requires 37.6s on average, whereas beam search with beam sizes of 4 and 10 require 56.4s and 138.2s, respectively. For non-tempered models, where beam search scores are higher than greedy search scores by over 2.0 BLEU points, the best BLEU scores are obtained using beam sizes between 4 and 10. Given the improved performance with greedy search, we can decode anywhere from 1.5 to 3.5 times faster. Subjecting softmax tempering to model compression methods, such as weight pruning, might further reduce decoding time. \section{Analysis and Further Exploration} We now focus on an intrinsic and extrinsic analyses of our method by studying its impact on extreme parameter sharing and multilingualism, its relationship to dropout, and finally on the internal working of the models during training. \subsection{Impact on Parameter Sharing Models} Why can regularization improve translation quality? One possible explanation is that the constraints imposed by regularization techniques force the model to more effectively utilize its existing capacity, indicated by the model parameters. This is especially important in low-resource settings. It is thus worth verifying the impact of softmax tempering, a regularization technique, on models with significantly reduced capacity. In particular, we experimented with models that share parameters between the stacked layers, so-called recurrently stacked (RS) models \citep{DBLP:conf/aaai/DabreF19}, known to suffer from reduced translation quality for NMT. While we could have trained shallower models and/or models with small hidden sizes, they inevitably require experiments with combinations of hyper-parameters, i.e., number of layers and hidden size. In contrast, RS models are relatively recent and different from non-RS ones with regards to parameter sharing and thereby simplifying exploration. Compare the first and second blocks of \Tab{rsnmtmlnmt} for non-RS models and their RS counterparts. It is clear that RS models are always weaker than non-RS models, but the greedy search with RS models are largely improved by the tempered training. However, unlike in the case of a non-RS model, the beam search quality either remains the same or degrades in most cases. The major difference between RS and non-RS models is in the number of parameters and we can safely say that RS models simply lack the capacity to strongly benefit from softmax tempering. Nevertheless, the greedy search performance of an RS model with an appropriate temperature setting becomes comparable to a non-RS model trained without softmax tempering. RS models tend to be 50-60\% smaller than non-RS models \citep{DBLP:conf/aaai/DabreF19}. Thus, when one wants RS models for low-memory settings, we recommend to train them with softmax tempering. \subsection{Impact on Multilingualism} By training a multilingual model, we share parameters between multiple language pairs thereby reducing the amount of model capacity available for individual language pairs. Additionally, using multilingual data is a way to simulate a high-resource situation. While softmax tempering is not always useful in unidirectional high-resource translation settings (see \Sec{rrresults}), it may benefit simulated high-resource settings realized though multilingual models for extremely low-resource language pairs. We trained a one-to-many NMT model \citep{DBLP:conf/acl/DongWHYW15} for English to 11 Asian languages by concatenating the training data of the ALT corpus after prepending each source sentence with an artificial token indicating the target language as in \citet{TACL1081}. The ALT corpus is 12-way parallel, and thus the English side contains the same sentences 11 times. We used a vocabulary with 8,192 sub-words\footnote{In our preliminary experiment with a 32,768 sub-word vocabulary for English, we obtained lower BLEU scores than those of unidirectional models. We realized that the reason was that increasing the number of language pairs did not increase the English side vocabulary and thus these sub-words resulted in a word-level vocabulary which negatively affects translation quality.} for English and another one with 32,768 sub-words for all target languages combined. As in \Sec{exp}, we trained Transformer Base models with different values for temperature. Comparing the non-tempered models ($T=1.0$) in the first and third blocks of \Tab{rsnmtmlnmt}, it is clear that multilingual models already outperform corresponding unidirectional models by up to 6.0 BLEU points (\unidir{En}{Ja}), even though \unidir{En}{Id} and \unidir{En}{Ms}, which originally have the highest BLEU scores, suffer slightly. This highlights the utility of multilingualism in itself, since our training data is multi-parallel and introducing a new language pair does not introduce new contents. With softmax tempering, temperature values between 1.2 and 2.0 brought improvements in translation quality by up to 6.8 BLEU points over the best unidirectional models (marked bold in the first block). Note that the optimal temperature values, ${T_{\mathit{opt}}}$, are similar to those in the case of high-resource \unidir{En}{De} translation task. Although multilingualism simulates a high-resource setting, we observed that softmax tempering is more effective compared to a unidirectional modeling in the real high-resource setting. We thus recommend training multilingual models with softmax tempering, especially when the individual language pairs are low-resource. The bottom block of \Tab{rsnmtmlnmt} show results when we push parameter sharing to its extreme limits combining both RS and multilingualism. Comparing them with the third block, multilingual RS models without softmax tempering always outperform its non-RS counterpart by up to 1.9 BLEU points. However, multilingual RS models are negatively impacted by softmax tempering: the greedy search translation quality increases slightly (if at all), while the beam search translation quality degrades. Multilingual models already share parameters for 11 translation directions, significantly lowering the capacity per translation direction than unidirectional models. RS of layers further increases the burden on the multilingual model. Thus, temperature puts further burden on the model's learning which has a negative impact on performance. Ultimately, multilingual tempered models give the best possible translations. We thus recommend to train (a)~multilingual RS models without softmax tempering aiming at extreme compactness or (b)~multilingual non-RS models with softmax tempering for higher translation quality and faster decoding with greedy search. \subsection{Dropout} Softmax tempering is a kind of regularization, since it makes the model predictions noisy during training, aiming to enable better learning. We have so far experimented with softmax tempering in combination with dropout. To this end, we experimented with both low-resource and high-resource settings using softmax tempering with and without dropout to explicitly examine their complementarity. For low-resource settings, we randomly chose \unidir{Bn}{En} and \unidir{Vi}{En} translation directions, and additionally trained unidirectional Transformer Base models using softmax tempering in various temperature settings but without dropout. We also trained Transformer Base and Big models for the \unidir{En}{De} task without dropout. To be precise, to disable dropout, we set attention, embedding, and layer dropouts in the model to zero during training. The results are shown in \Tab{dropoutalt}. It is known that disabling dropout significantly deteriorates the translation quality. However, in our \unidir{Vi}{En} and \unidir{Bn}{En} settings, higher temperature values are able to compensate for the drops. This shows that dropout and softmax tempering are complementary and that the latter acts as a regularizer similarly to the former. Note that softmax tempering alters the softmax layer, whereas dropout is applied throughout the model. This can explain why dropout has a larger impact than softmax tempering. In the high-resource setting, in contrast, dropout does not positively impact on the translation quality. In the context of high-resource NMT, the impact of dropout on the Transformer was never explicitly investigated in detail. In such a situation, the large quantities of data might enable enough regularization. However, in the case of Transformer Base, temperature values of 1.2 to 1.6 tend to improve the greedy search performance when dropout is not used, bridging the performance gap between the Transformer Base and Transformer Big models. This shows that softmax tempering can be an alternative to dropout depending on the setting. This warrants further exploration of the relationship between data regularization and model regularization. \begin{table}[t] \centering \scalebox{.75}{ \begin{tabular}{lll|c@{~~}c@{~~}cc} \hline \multirow{2}{*}{Dropout} & \multirow{2}{*}{$T$} &\multirow{2}{*}{Decoding} &\multirow{2}{*}{\unidir{Bn}{En}} &\multirow{2}{*}{\unidir{Vi}{En}} &\multicolumn{2}{c}{\unidir{En}{De}}\\ &&&&&(Base) &(Big)\\ \hline \multirow{4}{*}{Yes} &1.0 & Greedy & 7.1 & 19.4 & 28.2 & 32.7 \\ &1.0 & Beam & 8.5 & 21.1 & 29.2 & 33.7 \\ &${T_{\mathit{opt}}}$ & Greedy & 9.1 & 21.3 & 29.1 & 33.6 \\ &${T_{\mathit{opt}}}$ & Beam & \textbf{9.3}\dag & \textbf{21.5} & \textbf{30.1}\dag & \textbf{34.5}\dag \\ \hline \multirow{4}{*}{No} &1.0 & Greedy & 2.6 & 17.4 & 29.5 & 33.3 \\ &1.0 & Beam & 3.1 & 19.9 & 30.7 & \textbf{34.5} \\ &${T_{\mathit{opt}}}$ & Greedy & \textbf{3.5} & 20.9\dag & 30.6 & 33.3 \\ &${T_{\mathit{opt}}}$ & Beam & \textbf{3.5} & \textbf{21.1}\dag & \textbf{31.7}\dag & 34.1 \\ \hline \end{tabular}% } \caption{BLEU scores for a subset of translation directions in the ALT tasks and \unidir{En}{De} task with and without dropout and softmax tempering.} \label{tab:dropoutalt} \end{table} \begin{figure*}[t] \centering \begin{subfigure}[t]{\columnwidth} \centering \includegraphics[width=.95\columnwidth]{d-distribution/entropy-w-temp.pdf} \label{fig:entropydistr1} \end{subfigure}% \hfill \begin{subfigure}[t]{\columnwidth} \centering \includegraphics[width=.95\columnwidth]{d-distribution/entropy-wo-temp.pdf} \label{fig:entropydistr2} \end{subfigure}% \caption{Variation of entropy: the left-hand side shows ${\mathit{softmax}}(D_{i}/T)$ in \Eq{prediction} actually used for computing the loss during training, whereas the right-hand side shows ${\mathit{softmax}}(D_{i})$ drawn for this analysis.} \label{fig:entropydistr} \end{figure*} \begin{figure}[t] \centering \includegraphics[width=.95\columnwidth]{d-distribution/gradient.pdf} \caption{Global gradient norms during training models with softmax tempering. } \label{fig:graddistr} \end{figure} \subsection{Temperature and Model Learning} \label{sec:internal} We expected that tempering leads to a smoother softmax and loss minimization using such a softmax makes it sharper as training progresses. With softmax tempering, the model will continue to receive strong gradient updates even during later training stages due to the deliberate perturbation of the softmax distribution. Thus, we confirm whether our model truly behaves this way through visualizing the softmax entropies and gradient values. \Fig{entropydistr} visualizes the variation of softmax entropy averaged over all tokens in a batch during training. The left-hand side shows the entropy of tempered softmax distribution in \Eq{prediction}, where there is no visible differences between charts with different values for temperature, i.e., $T$. Considering that the distribution is tempered with $T$, this indicates that the distribution of logits, $D_{i}$, is sharper when tempered with a higher $T$. The right-hand side plots the entropy of softmax distribution derived from the logits without dividing them by $T$. The lower entropy confirm that the distribution of logits is indeed sharper with higher $T$ and that division by $T$ as in \Eq{prediction} counters the effect of sharpening. This means that the distribution of logits is forced to become sharper and thus produce exactly one word that the model believes the best to generate the rest of the sequence. Given the fact that translation quality is improved by softmax tempering, designing training methods that lead to sharper distribution might be useful. \Fig{graddistr} shows the gradient norms during training with softmax tempering. This revealed that, similarly to ordinary non-tempered training, gradient norms in softmax tempering first increase during the warm-up phase of training and then gradually decrease. However, the major difference is that the norm values significantly decrease for the non-tempered training, whereas they are much higher for training with softmax tempering. Note that we re-scaled the loss for softmax tempering as in \Eq{loss}, which is one reason why the gradient norms are higher. Larger gradient norms indicate that strong learning signals are being back-propagated and this will continue as long as the softmax is forced to make erroneous decisions because of higher temperature values. We can thus conclude that the noise introduced by softmax tempering and subsequent loss re-scaling strongly affect the behavior of NMT models which eventually have an impact on translation quality. \section{Conclusion} In this paper, we explored the utility of softmax tempering for training NMT models. Our experiments in low-resource and high-resource settings revealed that not only does softmax tempering lead to an improvement in the decoding quality but also bridges the gap between greedy and beam search performance. Consequently, we can use greedy search while achieving better translation quality than non-tempered models leading to 1.5 to 3.5 times faster decoding. We also explored the compatibility of softmax tempering with multilingualism and extreme parameter sharing, and explicitly investigated the complementarity of softmax tempering and dropout, where we show that softmax tempering can be an alternative to dropout in high-resource settings, while it is complementary to dropout in low-resource settings. Our analysis of the softmax entropies and gradients during training confirms that tempering gives precise softmaxes while enabling the model to learn with strong gradient signals even during late training stages. In the future, we will explore the effectiveness of softmax tempering in other natural language processing tasks. \section*{Acknowledgments} A part of this work was conducted under the commissioned research program ``Research and Development of Advanced Multilingual Translation Technology'' in the ``R\&D Project for Information and Communications Technology (JPMI00316)'' of the Ministry of Internal Affairs and Communications (MIC), Japan. Atsushi Fujita was partly supported by JSPS KAKENHI Grant Number 19H05660. \bibliographystyle{acl_natbib}
{'timestamp': '2020-09-22T02:14:34', 'yymm': '2009', 'arxiv_id': '2009.09372', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09372'}
arxiv
\section{Aligner Selection and Ensembling} \label{sec:aligner} \subsection{Aligner Descriptions} \label{sec:alignerd} Most available resources for building parallel corpora come in the form of parallel documents which are exact or near-exact translations of one another. Sentence aligners are used to extract parallel sentences from them, which are then used as training examples for MT models. \citet{abdul2012extrinsic} conducted a comparative evaluation of five aligners and showed that the choice of aligner had considerable performance gain by the models trained on the resultant bitexts. They identified three aligners with superior performance: Hunalign \citep{varga2007parallel}, Gargantua \citep{braune2010improved}, and Bleualign \citep{sennrich2010mt}. \iffalse \begin{enumerate} \item \textbf{Hunalign} \citep{varga2007parallel} \item \textbf{Gargantua} \citep{braune2010improved} \item \textbf{Bleualign} \citep{sennrich2010mt} \end{enumerate} \fi \iffalse \begin{enumerate} \item \textbf{Hunalign:} Hunalign \citep{varga2007parallel}, a concatenation of dictionary and length-based alignment algorithms, uses a dictionary to produce a crude translation of the source text into the target texts, and then aligns using sentence length and token similarity metrics. In case a dictionary is absent, it is learned empirically from the data. For our implementation, we used the `BengaliDictionary'\footnote{\url{https://github.com/MinhasKamal/BengaliDictionary}} repository with over 160k entries. \item \textbf{Gargantua:} Gargantua \citep{braune2010improved}, an unsupervised alignment algorithm, uses two passes over the data as follows. It first trains an IBM Model-I \citep{brown1993mathematics}, and then perform a two-step clustering to find one-to-one and many-to-one/one-to-many alignments respectively. \item \textbf{Bleualign:} Bleualign \citep{sennrich2010mt} uses an automatic machine translation of the source texts as an intermediary \iffalse between the source and the target instead of computing alignments between them directly\fi for computing alignments. A modified BLEU \citep{papineni2002bleu} is used as the similarity metric. The main drawback of Bleualign is the need for an external MT system. We used an NMT model trained on the data aligned by the two other aligners and the pre-aligned data already available (detailed in section \ref{tdata}). \end{enumerate} \fi \begin{figure*}[h] \iffalse \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=\textwidth]{figs/2/Precision.pdf} \caption{caption-1} \label{fig:aligner1} \end{subfigure} \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=\textwidth]{figs/2/Recall.pdf} \caption{caption-2} \label{fig:aligner2} \end{subfigure} \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=\textwidth]{figs/2/F1.pdf} \caption{caption-3} \label{fig:aligner3} \end{subfigure} \fi \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=\textwidth]{figs_final/2/Precision.pdf} \caption{Precision vs. Margin} \label{fig:pvm} \end{subfigure} \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=\textwidth]{figs_final/2/Recall.pdf} \caption{Recall vs. Margin} \label{fig:rvm} \end{subfigure} \begin{subfigure}{0.33\textwidth} \centering \includegraphics[width=\textwidth]{figs_final/2/F1.pdf} \caption{$F_1$ Score vs. Margin} \label{fig:fvm} \end{subfigure} \caption{Performance metrics of ensembles with filtering} \label{fig:margin} \end{figure*} However, their results showed performance only in terms of BLEU score, with no indication of any explicit comparison metric between the aligners (e.g., precision, recall). As such, to make an intrinsic evaluation, we sampled 50 documents from four of our sources (detailed in section \ref{sec:docdata}) with their sentence counts on either side ranging from 20 to 150. We aligned sentences from these documents manually (i.e., the gold alignment) and removed duplicates, which resulted in 3,383 unique sentence pairs. We then aligned the documents again with the three aligners using our custom segmenter. Table \ref{tab:hgb} shows performance metrics of the aligners. \iffalse \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Aligner}\\ \hline Hunalign\\ Gargantua\\ Bleualign\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{$F_1$ Score}\\ \hline \textbf{93.21} & 85.82 & \textbf{89.37} \\ 84.79 & 69.32 & 76.28\\ 89.41 & \textbf{87.35} & 88.37\\ \hline \end{tabular} \caption{Performance measures (\%) for the aligners}\label{tab:hgb} \end{table} \fi \subsection{Aligner Ensembling and Filtering} \label{aligneref} From the results in Table \ref{tab:hgb}, it might seem that Hunalign should be the most ideal aligner choice. But upon closer inspection, we found that each aligner was able to correctly align some pairs that the other two had failed to do. Since we had started from a low-resource setup, it would be in our best interest if we could combine the data extracted by all aligners. As such, we `ensembled' the results of the aligners as follows. For each combination of the aligners (4 combinations in total; see Table \ref{tab:ensemble}), we took the union of sentence pairs extracted by each constituent aligner of the said combination for each document. The performance of the aligner ensembles is shown in Table \ref{tab:ensemble}. We concatenated the first letters of the constituent aligners to name each ensemble (e.g., HGB refers to the combination of all three of them). \iffalse \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Ensemble}\\ \hline HG\\ GB\\ BH\\ HGB\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{$F_1$ Score}\\ \hline 83.52 & 88.00 & 85.70\\ 81.11 & 93.20 & 86.73\\ \textbf{86.16} & 94.76 & \textbf{90.26}\\ 78.64 & \textbf{95.13} & 86.10\\ \hline \end{tabular} \caption{Performance measures (\%) for the ensembles}\label{tab:ensemble} \end{table} \fi \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Aligner}\\ \hline Hunalign\\ Gargantua\\ Bleualign\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{F$_1$}\\ \hline \textbf{93.21} & 85.82 & \textbf{89.37} \\ 84.79 & 69.32 & 76.28\\ 89.41 & \textbf{87.35} & 88.37\\ \hline \end{tabular} \caption{Performance metrics of aligners}\label{tab:hgb} \vspace{1em} \begin{tabular}{l} \hline \textbf{Ensemble}\\ \hline HG\\ GB\\ BH\\ HGB\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{F$_1$}\\ \hline 83.52 & 88.00 & 85.70\\ 81.11 & 93.20 & 86.73\\ \textbf{86.16} & 94.76 & \textbf{90.26}\\ 78.64 & \textbf{95.13} & 86.10\\ \hline \end{tabular} \caption{Performance metrics of ensembles}\label{tab:ensemble} \vspace{1em} \begin{tabular}{l} \hline \textbf{Ensemble}\\ \hline L(1.02)\\ HG+L(0.96)\\ GB+L(0.98)\\ BH+L(0.96)\\ HGB+L(0.98)\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{F$_1$}\\ \hline 90.86 & 80.34 & 85.28\\ \textbf{94.09} & 86.86 & 90.33\\ 92.31 & 91.52 & 91.91\\ 91.91 & \textbf{93.60} & \textbf{92.75}\\ 91.52 & 93.23 & 92.37\\ \hline \end{tabular} \caption{Performance metrics of filtered ensembles}\label{tab:fensemble} \end{table} Table \ref{tab:ensemble} shows that BH achieved the best $F_1$ score among all ensembles, even 0.89\% above the best single aligner Hunalign. Ensembling increased the recall of BH by 8.94\% compared to Hunalign, but also hurt precision severely (by 7.05\%), due to the accumulation of incorrect alignments made by each constituent aligner. To mitigate this effect, we used the LASER\footnote{\url{https://github.com/facebookresearch/LASER}} toolkit to filter out incorrect alignments. LASER, a cross-lingual sentence representation model, uses similarity scores between the embeddings of candidate sentences to perform as both aligner \citep{schwenk2019wikimatrix} and filter \citep{chaudhary2019low}. We used LASER as a filter on top of the ensembles, varied the similarity margin \citep{artetxe2018margin} between 0.90 to 1.10 with 0.01 increment, and plotted the performance metrics in Figure \ref{fig:margin}. We also reported the performance of LASER as a standalone aligner (referred to as L in the figure; +L indicates the application of LASER as a filter). The dashed lines indicate ensemble performance without the filter. As Figure \ref{fig:pvm} indicates, ensembles achieve significant gain on precision with the addition of the LASER filter. While recall (Figure \ref{fig:rvm}) doesn't face a significant decline at first, it starts to take a deep plunge when margin exceeds 1.00. We balanced between the two by considering the $F_1$ score (Figure \ref{fig:fvm}). Table \ref{tab:fensemble} shows the performance metrics of LASER and all filtered ensembles for which their respective $F_1$ score is maximized. \iffalse \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Ensemble}\\ \hline L(1.02)\\ HG+L(0.96)\\ GB+L(0.98)\\ BH+L(0.96)\\ HGB+L(0.98)\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{$F_1$}\\ \hline 90.86 & 80.34 & 85.28\\ \textbf{94.09} & 86.86 & 90.33\\ 92.31 & 91.52 & 91.91\\ 91.91 & \textbf{93.60} & \textbf{92.75}\\ 91.52 & 93.23 & 92.37\\ \hline \end{tabular} \caption{Performance measures (\%) for the filtered ensembles}\label{tab:fensemble} \end{table} \fi Table \ref{tab:fensemble} shows that despite being a good filter, LASER as an aligner does not show considerable performance compared to filtered ensembles. The best $F_1$ score is achieved by the BH ensemble with its margin set to 0.96. Its precision increased by 5.75\% while trailing a mere 1.16\% in recall behind its non-filtered counterpart. Compared to single Hunalign, its recall had a 7.78\% gain, while lagging in precision by only 1.30\%, with an overall $F_1$ score increase of 3.38\%. Thus, in all future experiments, we used BH+L(0.96) as our default aligner with the mentioned filter margin. \iffalse \begin{figure*} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth]{figs/2/Precision.pdf} \caption{caption-1} \label{fig:aligner1} \end{subfigure} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth]{figs/1/Precision.pdf} \caption{caption-2} \label{fig:aligner2} \end{subfigure} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth]{figs/2/Recall.pdf} \caption{caption-3} \label{fig:aligner3} \end{subfigure} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth]{figs/1/Recall.pdf} \caption{caption-4} \label{fig:aligner4} \end{subfigure} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth]{figs/2/F1.pdf} \caption{caption-5} \label{fig:aligner5} \end{subfigure} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth]{figs/1/F1.pdf} \caption{caption-6} \label{fig:aligner6} \end{subfigure} \end{figure*} \fi \section{Appendices} \label{sec:appendix} Appendices are material that can be read, and include lemmas, formulas, proofs, and tables that are not critical to the reading and understanding of the paper. Appendices should be \textbf{uploaded as supplementary material} when submitting the paper for review. Upon acceptance, the appendices come after the references, as shown here. \paragraph{\LaTeX-specific details:} Use {\small\verb| \section{Conclusion and Future Works} In this work, we developed a custom sentence segmenter for Bengali, showed that aligner ensembling with batch filtering provides better performance than single sentence aligners, collected a total of 2.75 million high-quality parallel sentences for Bengali-English from multiple sources, trained NMT models that outperformed previous results, and prepared a new test set; thus elevating Bengali from its low-resource status. In future, we plan to design segmentation-agnostic aligners or aligners that can jointly segment and align sentences. We want to experiment more with the LASER toolkit: we used LASER out-of-the-box, we want to train it with our data, and modify the model architecture to improve it further. LASER fails to identify one-to-many/many-to-one sentence alignments, we want to address this. We would also like to experiment with BERT \citep{devlin2018bert} embeddings for similarity search. \iffalse Another issue we want to address is robustness; our model is completely bilingual and fails to produce correct translations when the input contains foreign texts.\fi Furthermore, we wish to explore semi-supervised and unsupervised approaches to leverage monolingual data and explore multilingual machine translation for low-resource Indic languages. \section*{Acknowledgements} We would like to thank the ICT Division, Government of the People's Republic of Bangladesh for funding the project and Intelligent Machines Limited for providing cloud support. \section{Training Data and Batch Filtering} \label{tdata} \begin{table*}[h] \centering \begin{tabular}{l} \hline \textbf{Source}\\ \hline OpenSubs\\ TED\\ SUPara\\ Tatoeba\\ Tanzil\\ AMARA\\ SIPC\\ Glosbe\\ MediaWiki\\ Gnome\\ KDE\\ Ubuntu\\ Globalvoices\\ JW\\ Banglapedia\\ Books\\ Laws\\ HRW\\ Dictionary\\ Wiki Sections\\ Miscellaneous\\ \hline \textbf{Total}\\ \hline \end{tabular} \begin{tabular}{rrrrr} \hline \textbf{\#Pairs} & \textbf{\#Tokens(Bn)} & \textbf{\#Tokens(En)} & \textbf{\#Toks/Sent(Bn)} & \textbf{\#Toks/Sent(En)}\\ \hline 365,837 & 2,454,007 & 2,902,085 & 6.71 & 7.93\\ 15,382 & 173,149 & 195,007 & 11.26 & 12.68\\ 69,533 & 811,483 & 996,034 & 11.67 & 14.32\\ 9,293 & 50,676 & 57,266 & 5.45 & 6.16\\ 5,908 & 149,933 & 164,426 & 25.38 & 27.83\\ 1,166 & 63,447 & 47,704 & 54.41 & 40.91\\ 19,561 & 240,070 & 311,816 & 12.27 & 15.94\\ 81,699 & 1,531,136 & 1,728,394 & 18.74 & 21.16\\ 45,998 & 3,769,963 & 4,205,913 & 81.96 & 91.44\\ 102,078 & 725,297 & 669,659 & 7.11 & 6.56\\ 16,992 & 122,265 & 115,908 & 7.20 & 6.82\\ 5,251 & 22,727 & 22,616 & 4.33 & 4.29\\ 235,106 & 4,162,896 & 4,713,335 & 17.70 & 20.04\\ 546,766 & 9,339,929 & 10,215,160 & 17.08 & 18.68\\ 264,043 & 3,695,930 & 4,643,818 & 14.00 & 17.59\\ 99,174 & 1,393,095 & 1,787,694 & 14.05 & 18.03\\ 28,218 & 644,384 & 801,092 & 22.84 & 28.39\\ 2,586 & 55,469 & 65,103 & 21.44 & 25.17\\ 483,174 & 700,870 & 674,285 & 1.45 & 1.40\\ 350,663 & 5,199,814 & 6,397,595 & 14.83 & 18.24\\ 2,877 & 21,427 & 24,813 & 7.45 & 8.62\\ \hline \textbf{2,751,315} & \textbf{35,327,967} & \textbf{40,739,723} & \textbf{12.84} & \textbf{14.81}\\ \hline \end{tabular} \label{tab:dataset} \caption{Summary of the training corpus.}\label{tab:data} \end{table*} We categorize our training data into two sections: (1) Sentence-aligned corpora and (2) Document-aligned corpora. \subsection{Sentence-aligned Corpora}\label{sec:sent} We used the corpora mentioned below which are aligned by sentences: \begin{enumerate}[label={}, leftmargin=*] \setlength{\itemsep}{1pt} \item \textbf{Open Subtitles 2018} corpus \citep{lison2019open} from OPUS\footnote{\url{opus.nlpl.eu}} \citep{tiedemann2012parallel} \item \textbf{TED} corpus \citep{cettolo2012wit3} \item \textbf{SUPara} corpus \citep{al2012supara} \item \textbf{Tatoeba} corpus from \url{tatoeba.org} \item \textbf{Tanzil} corpus from the Tanzil project\footnote{\url{tanzil.net/docs/tanzil_project}} \item \textbf{AMARA} corpus \citep{abdelali2014amara} \item \textbf{SIPC} corpus \citep{post2012constructing} \item \textbf{Glosbe}\footnote{\url{https://glosbe.com/}} online dictionary example sentences \item \textbf{MediaWiki Content Translations}\footnote{\url{https://w.wiki/RZn}} \item \textbf{Gnome, KDE, Ubuntu} localization files \item \textbf{Dictionary} entries from \url{bdword.com} \item \textbf{Miscellaneous} examples from \url{english-bangla.com} and \url{onubadokderadda.com} \end{enumerate} \subsection{Document-aligned Corpora}\label{sec:docdata} The corpora below have document-level links from where we sentence-aligned them: \begin{enumerate}[label={}, leftmargin=*] \item \textbf{Globalvoices:} Global Voices\footnote{\url{https://globalvoices.org/}} publishes and translates articles on trending issues and stories from press, social media, blogs in more than 50 languages. Although OPUS provides sentence-aligned corpus from Global Voices, we re-extracted sentences using our segmenter and filtered ensemble, resulting in a larger amount of pairs compared to OPUS. \item \textbf{JW:} \citet{agic2019jw300} introduced JW300, a parallel corpus of over 300 languages crawled from \url{jw.org}, which also includes Bengali-English. They used Polyglot \citep{al2013polyglot} for sentence segmentation and Yasa \citep{lamraoui2013yet} for sentence alignment. We randomly sampled 100 sentences from their Bengali-English corpus and found only 23 alignments to be correct. So we crawled the website using their provided instructions and aligned using our segmenter and filtered ensemble. This yielded more than twice the data than theirs. \item \textbf{Banglapedia:} ``Banglapedia: the National Encyclopedia of Bangladesh" is the first Bangladeshi encyclopedia. Its online version\footnote{\url{https://www.banglapedia.org/}} contains over 5,700 articles in both Bengali and English. We crawled the website to extract the article pairs and aligned sentences with our segmenter and filtered ensemble. \item \textbf{Bengali Translation of Books:} We collected translations of more than 100 books available on the Internet with their genres ranging from classic literature to motivational speeches and aligned them using our segmenter and filtered ensemble. \item \textbf{Bangladesh Law Documents:} The Legislative and Parliamentary Affairs Division of Bangladesh makes all laws available on their website.\footnote{\url{bdlaws.minlaw.gov.bd}} \iffalse Laws are first published in Bengali, and their authentic English text is published as Gazettes\footnote{\url{dpp.gov.bd}} later on.\fi Some older laws are also available \iffalse in English \fi under the ``Heidelberg Bangladesh Law Translation Project".\footnote{\url{https://www.sai.uni-heidelberg.de/workgroups/bdlaw/}} \iffalse We collected all laws for which Bengali and English translations were available. \fi Segmenting the laws was not feasible with the aligners in section \ref{sec:alignerd} as most lines were bullet points terminating in semicolons, and treating semicolons as terminals broke down valid sentences. Thus, we made a regex-based segmenter and aligner for these documents. Since most laws were exact translations with an equal number of bullet points under each section\iffalse and subsection \fi, the deterministic aligner yielded good alignment results. \item \textbf{HRW:} Human Rights Watch\footnote{\url{https://www.hrw.org/}} investigates and reports on abuses happening in all corners of the world on their website. We crawled the Bengali-English article pairs and aligned them using our segmenter and filtered ensemble. \item \textbf{Wiki Sections:} Wikipedia is the largest multilingual resource available on the Internet. But most article pairs are not exact or near-exact translations of one another. However, such a large source of parallel texts cannot be discarded altogether. Wikimatrix \citep{schwenk2019wikimatrix} extracted bitexts from Wikipedia for 1620 language pairs, including Bengali-English. But we found them to have issues like foreign texts, incorrect sentence segmentations and alignments etc. As such, we resorted to the original source and only aligned from sections having high similarity. We translated the Bengali articles into English using an NMT model trained on the rest of our data and compared each section of an article against the sections of its English counterpart. We used SacreBLEU \citep{post2018call} score as the similarity metric and only picked sections with score above 20. We then used our filtered ensemble on the resulting matches. \end{enumerate} \subsection{Batch Filtering} LASER uses cosine similarity between candidate sentences as the similarity metric and calculates margin by normalizing over the nearest neighbors of the candidates. \citet{schwenk2019wikimatrix} suggested using a global space, i.e., the complete corpus for neighbor search while aligning, albeit without any indication of what neighborhood to use for filtering. In section \ref{aligneref}, we used local neighborhood on document level and found satisfactory results. So we tested it with a single aligner, Hunalign,\footnote{The optimal margin was found to be 0.95 for Hunalign.} on three large document sources, namely, Globalvoices (GV), JW, and Banglapedia (BP). But the local approach took over a day to filter from about 25k document pairs, the main bottleneck being the loading time for each document. Even with several optimizations, running time did not improve much. The global approach suffered from another issue: memory usage. The datasets were too large to be fit into GPU as a whole.\footnote{We used an RTX 2070 GPU with 8GB VRAM for these experiments.} Thus, we shifted the neighbor search to CPU, but that again took more than a day to complete. Also, the percentage of filtered pairs was quite higher than the local neighborhood approach, raising the issue of data scarcity again. So, we sought the following middle-ground between global and local approach: for each source, we merged all alignments into a single file, shuffled all pairs, split the file into 1k size batches, and then applied LASER locally on each batch, reducing running time to less than two hours. \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Source}\\ \hline GV\\ JW\\ BP\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Document} & \textbf{1k Batch} & \textbf{Global}\\ \hline \textbf{4.05} & 4.60 & 8.03\\ \textbf{6.22} & 7.06 & 13.28\\ \textbf{13.01} & 14.96 & 25.65\\ \hline \end{tabular} \caption{Filtered pairs (\%) for different neighborhoods}\label{tab:yield} \end{table} In Table \ref{tab:yield}, we show the percentage of filtered out pairs from the sources for each neighborhood choice. The global approach lost about twice the data compared to the other two. The 1k batch neighborhood achieved comparable performance with respect to the more fine-grained document-level neighborhood while improving running time more than ten-folds. Upon further inspection, we found that more than 98.5\% pairs from the document-level filter were present in the batched approach. So, in subsequent experiments, we used `Batch Filtering' as standard. In addition to the document-aligned sources, we also used batch filtering on each sentence-aligned corpus in section \ref{sec:sent} to remove noise from them. Table \ref{tab:data} summarizes our training corpus after the filtering. \iffalse \begin{enumerate} \item \textbf{Opensubtitles:} OPUS\footnote{\url{opus.nlpl.eu}} \citep{tiedemann2012parallel} provides a wide plethora of parallel corpora, OpenSubtitles \citep{lison2019open} being one of them. OpenSubtitles creates bitext extracted from movie subtitles from \url{opensubtitles.org}. We use the 2018 version of Opensubtitles in this work. \item \textbf{Globalvoices:} ``Global Voices is an international and multilingual community of bloggers, journalists, translators, academics, and human rights activists"- according to the descriptions on their website.\footnote{\url{globalvoices.org}} Global Voices publishes and translates articles on trending issues and stories from press social media, blogs on more than 50 languages. Though OPUS provides sentences aligned from Global Voices articles, we re-extract sentences using our custom aligner from document pairs, resulting in a larger amount and better quality sentences. \item \textbf{JW:} \citet{agic2019jw300} introduced JW300, a parallel corpus of over 300 languages, including Bengali-English, crawled from \url{jw.org}. They use polyglot \citep{al2013polyglot} for sentence segmentation and tokenization and Yasa aligner \citep{lamraoui2013yet} for sentence alignment. We randomly sampled 100 sentences from the Bengali-English dataset and found only \textcolor{red}{35} alignments to be correct. So we crawled the website using the provided instructions and aligned sentences using our segmenter and custom methods. This yielded more than twice the data than theirs. \item \textbf{TED:} TED\footnote{\url{ted.com}} Conference posts video recordings of talks together with subtitles in English and their translations in more than 80 languages. \citet{cettolo2012wit3} compiled these subtitles for machine translation; we use the Bengali-English pair. \item \textbf{HRW:} Human Rights Watch\footnote{\url{hrw.org}} investigates and reports on abuses happening in all corners of the world on their website. We crawl the Bengali articles and their English counterparts and align them using our custom methods. \item \textbf{SUPara:} \citet{al2012supara} introduced Shahjalal University Parallel (SUPara) corpus, a balanced English-Bengali sentence-aligned parallel corpus consisting of more than 70,000 sentence pairs. \item \textbf{Tatoeba:} Tatoeba\footnote{\url{tatoeba.org}} collects translations of sentences from more than 300 languages. We use their Bengali-English pair from the OPUS collection. \item \textbf{Tanzil:} The Tanzil project\footnote{\url{tanzil.net/docs/tanzil_project}} was launched to produce highly verified translations of Quran on several languages. We aimed to use the Tanzil dataset from OPUS, but a manual evaluation revealed many alignments to be incorrect. So, we used the verse-level alignment from the original web source. This resulted in significantly lower amount of pairs, but correctness was ensured in the process. \item \textbf{QED:} \citet{abdelali2014amara} presented the AMARA corpus, a parallel corpus of educational video subtitles, aligned for 20 languages, including Bengali-English. It is available on OPUS. \item \textbf{Bengali Translation of Books:} We collected translations of more than 100 books available on the Internet with their genres ranging from classic literature to motivational speeches. Most books resulted in a high number of incorrect alignments. We sampled 50 pairs from each book and picked only those that had over 70\% correct alignments. \item \textbf{Bangladesh Law Documents:} The Legislative and Parliamentary Affairs Division of Bangladesh makes all laws of Bangladesh available in their website.\footnote{\url{http://bdlaws.minlaw.gov.bd/}} As per the Bangladeshi law, all laws are first published in Bengali, and their authentic English text is published as Gazettes\footnote{\url{dpp.gov.bd}} later on. Some older laws are also available in English under the ``Heidelberg Bangladesh Law Translation Project".\footnote{\url{sai.uni-heidelberg.de/workgroups/bdlaw/}} We collected all laws for which Bengali and English translations were available. Segmenting the laws wasn't feasible with the aligners we have mentioned as most lines were bullet points that terminated in semicolons and treating semicolons as terminal symbols broke down valid sentences. As such, we made a regex-based segmenter and aligner for the law documents. Since most laws were exact translations with an equal number of bullet points under each section and subsection, the deterministic aligner yielded good alignment results. Only a few post-editing had to be done. \item \textbf{Glosbe:} Glosbe,\footnote{\url{glosbe.com}} an online dictionary that covers all major languages. In addition to translations of words, it provides example sentences on both sides. We crawl the whole dictionary and example sentences for Bengali-English. However, a large number of their data comes from sources mentioned above (e.g. Opensubs, Globalvoices, JW). We removed all such duplicates before adding them to the main set. \item \textbf{Banglapedia:} ``Banglapedia: the National Encyclopedia of Bangladesh" is the first Bangladeshi encyclopedia. It contains over 5700 articles in both Bengali and English and is available online.\footnote{\url{https://www.banglapedia.org/}} We crawl the entire website to extract the article pairs and segment and align sentences with our custom methods. \item \textbf{MediaWiki Content Translations:} To aid machine translation research MediaWiki Content Translation provides data about Wikipedia translation. We use the dump of May 1, 2020, in this work. Noisy translations (e.g. empty target side, source and target same, non-Bengali or non-English translation) were removed by automatic filtering before being added to our corpus. We only use the human translations, not machine-generated ones by Google Translate. \item \textbf{Wiki Sections:} Wikipedia is the largest multilingual resource available on the Internet. But, unfortunately, Wikipedia articles aren't exact or near-exact translations of one another. However, such a large source of parallel texts cannot be discarded altogether. As such, we only aligned sentences from sections having high similarity score. We translated the Bengali articles into English using an NMT model trained on all the data above and compared each section of an article against the sections of that article's English counterpart. We used lowercased SacreBLEU score as the similarity metric and only picked sections with SacreBLEU above 15. We then used our aligner ensemble and filter on the resulting matches. \item \textbf{Miscellaneous:} \textcolor{green}{Abhik} \end{enumerate} \fi \section{Evaluation Data} A major challenge for low-resource languages is the unavailability of reliable evaluation benchmarks that are publicly available. After exhaustive searching, we found two decent test sets and developed one ourselves. They are mentioned below: \begin{enumerate}[label={}, leftmargin=*] \item \textbf{SIPC:} \citet{post2012constructing} used crowdsourcing to build a collection of parallel corpora between English and six Indian languages, including Bengali. Although they are not translated by experts and have issues for many sentences (e.g., all capital letters on English side, erroneous translations, punctuation incoherence between Bn and En side, presence of foreign texts), they provide four English translations for each Bengali sentence, making it an ideal test-bed for evaluation using multiple references. We only evaluated the performance of Bn$\rightarrow$En for this test set. \item \textbf{SUPara-benchmark} \citep{czes-gs42-18}: Despite having many spelling errors, incorrect translations, too short (less than 50 characters) and too long sentences (more than 500 characters), due to its balanced nature having sentences from a variety of domains, we used it for our evaluation. \item \textbf{RisingNews:} Since the two test sets mentioned above suffer from many issues, we created our own test set. Risingbd,\footnote{\url{https://www.risingbd.com/}} an online news portal in Bangladesh, publishes professional English translations for many of their articles. We collected about 200 such article pairs and had them aligned by an expert. We had them post-edited by another expert. We then removed, through automatic filtering, pairs that had (1) less than 50 or more than 250 characters on either side, (2) more than 33\% transliterations or (3) more than 50\% or more than 5 OOV words \citep{guzman2019two}. This resulted in 600 validation and 1000 test pairs; we named this test set ``\textbf{RisingNews}". \end{enumerate} \section*{Acknowledgments} The acknowledgments should go immediately before the references. Do not number the acknowledgments section. Do not include this section when submitting your paper for review.\fi \section{Experiments and Results} \subsection{Pre-processing} Before feeding into the training pipeline, we performed the following pre-processing sequentially: \begin{enumerate}[leftmargin=*] \setlength{\itemsep}{1pt} \item We normalized punctuations and characters that have multiple unicode representations to reduce data sparsity. \item We removed foreign strings that appear on both sides of a pair, mostly phrases from which both sides of the pair have been translated. \item We transliterated all dangling English letters and numerals on the Bn side into Bengali, mostly constituting bullet points. \item Finally, we removed all evaluation pairs from the training data to prevent data leakage. \end{enumerate} At this point, a discussion with respect to language classification is in order. It is a standard practice to use a language classifier (e.g., \citealp{joulin2016bag}) to filter out foreign texts. But when we used it, it classified a large number of valid English sentences as non-English, mostly because they contained named entities transliterated from Bengali side. Fearing that this filtering would hurt translation of named entities, we left language classification out altogether. Moreover, most of our sources are bilingual and we explicitly filtered out sentences with foreign characters, so foreign texts would be minimal. As for the test sets, we performed minimal pre-processing: we applied character and punctuation normalization; and since SIPC had some sentences that were all capital letters, we lowercased those (and those only). \subsection{Comparison with Previous Results} We compared our results with \citet{mumin2019shutorjoma}, \citet{hasanneural}, and \citet{mumin2019neural}. The first work used SMT, while the latter two used NMT models. All of them evaluated on the SUPara-benchmark test set. We used the OpenNMT \citep{klein2017opennmt} implementation of big Transformer model \citep{vaswani2017attention} with 32k vocabulary on each side learnt by Unigram Language Model with subword regularization\footnote{l=32, $\alpha$=0.1} \citep{kudo2018subword} and tokenized using SentencePiece \citep{kudo2018sentencepiece}. To maintain consistency with previous results, we used lowercased BLEU \citep{papineni2002bleu} as the evaluation metric. Comparisons are shown in Table \ref{tab:supara}. \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Model}\\ \hline \citet{mumin2019shutorjoma}\\ \citet{hasanneural}\\ \citet{mumin2019neural}\\ Ours\\ \hline \end{tabular} \begin{tabular}{cc} \hline \textbf{Bn$\rightarrow$En} & \textbf{En$\rightarrow$Bn}\\ \hline 17.43 & 15.27\\ 19.98 & --\\ 22.68 & 16.26\\ \textbf{32.10} & \textbf{22.02}\\ \hline \end{tabular} \caption{Comparison (BLEU) with previous works on SUPara-benchmark test set (\citealp{hasanneural} did not provide En$\rightarrow$Bn scores)}\label{tab:supara} \end{table} Evident from the scores in Table \ref{tab:supara}, we outperformed all works by more than \textbf{9} BLEU points for Bn$\rightarrow$En. Although for En$\rightarrow$Bn the difference in improvement (\textbf{5.5+}) is not that much striking compared to Bn$\rightarrow$EN, it is, nevertheless, commendable on the basis of Bengali being a morphologically rich language. \subsection{Comparison with Automatic Translators} We compared our models' SacreBLEU\footnote{BLEU+case.mixed+numrefs.1+smooth.exp+tok.13a +version.1.4.1 (numrefs.4 for SIPC)} \citep{post2018call} scores with Google Translate and Bing Translator, two most widely used publicly available automatic translators. Results are shown in Table \ref{tab:auto}. \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Model}\\ \textbf{/Translator}\\ \hline Google\\ Bing\\ Ours\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{SUPara} & \textbf{SUPara} & \textbf{SIPC}\\ \textbf{Bn$\rightarrow$En} & \textbf{En$\rightarrow$Bn} & \textbf{Bn$\rightarrow$En}\\ \hline 29.4 & 11.1 & 41.2\\ 24.4 & 10.7 & 37.2\\ \textbf{30.7} & \textbf{22.0} & \textbf{42.7}\\ \hline \end{tabular} \caption{Comparison (SacreBLEU) with automatic translators}\label{tab:auto} \end{table} From Table \ref{tab:auto} we can see that our models have superior results on all test sets when compared to Google and Bing. \subsection{Evaluation on RisingNews} We performed evaluation on our own test set, \textbf{RisingNews}. We show our models' lowercased detokenized BLEU and mixedcased SacreBLEU scores in Table \ref{tab:newstest}. \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Metric\iffalse /Translator\fi}\\ \hline BLEU\\ SacreBLEU\\ \hline \end{tabular} \begin{tabular}{cc} \hline \textbf{Bn$\rightarrow$En} & \textbf{En$\rightarrow$Bn}\\ \hline 39.04 & 27.73\\ 36.1 & 27.7\\ \hline \end{tabular} \caption{Evaluation on \textbf{RisingNews} corpus} \label{tab:newstest} \end{table} We put great care in creating the test set by performing extensive manual and automatic quality control, and believe it is better in quality than most available evaluation sets for Bengali-English. We also hope that our performance on this test set will act as a baseline for future works on Bengali-English MT. In Figure \ref{examples}, we show some example translations from the RisingNews test set. \begin{figure*}[h] \centering \includegraphics{figs_final/Demo_rising_final.pdf} \caption{Sample translations from the RisingNews test set} \label{examples} \end{figure*} \iffalse Results show our model does considerably well of out-of-domain test set and generalizes well compared to Google and Bing. \fi \subsection{Comparison with Human Performance} Remember that SIPC had four reference English translations for each Bengali sentence. We used the final translation as a baseline human translation and used the other three as ground truths (the fourth reference had the best score among all permutations). To make a fair comparison, we evaluated our model's score on the same three references instead of four. Human SacreBLEU score was 32.6, while our model scored 38.0, about \textbf{5.5} points above human judgement. \subsection{Ablation Study of Filtered Ensembles} To validate that our choice of ensemble and filter had direct impact on translation scores, we performed an ablation study. We chose four combinations based on their $F_1$ scores from section \ref{sec:aligner}: \begin{enumerate}[leftmargin=*] \setlength{\itemsep}{1pt} \item Best aligner: \textbf{Hunalign} \item Best aligner with filter: \textbf{Hunalign+L(0.95)} \item Best ensemble: \textbf{BH} \item Best ensemble with filter: \textbf{BH+L(0.96)} \end{enumerate} To ensure apples to apples comparison, we only used data from the parallel documents, i.e., Globalvoices, JW, Banglapedia, HRW, Books, and Wiki sections. Table \ref{tab:ablation} shows SacreBLEU scores along with the number of pairs for these combinations. We used the base Transformer model. \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Aligner}\\ \textbf{/Ensemble}\\ \hline Hunalign\\ H+L(.95)\\ BH\\ BH+L(.96)\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{\#Pairs} & \textbf{SUPara} & \textbf{SIPC}\\ \textbf{(million)} & \textbf{Bn$\rightarrow$En} & \textbf{Bn$\rightarrow$En}\\ \hline 1.35 & 20.5 & 33.2\\ 1.20 & 21.0 & 33.9\\ \textbf{1.64} & 21.0 & 34.0\\ 1.44 & \textbf{22.1} & \textbf{35.7}\\ \hline \end{tabular} \caption{SacreBLEU scores for ablation study}\label{tab:ablation} \end{table} BH+L(.96) performed better than others by a noticeable margin, and the single Hunalign performed the poorest. While only having 73\% pairs compared to BH, H+L(.95) stood almost on par. Despite the superiority in data count, BH could not perform well enough due to the accumulation of incorrect alignments from its constituent aligners. A clearer picture can be visualized through Figure \ref{fig:ablation}. BH+L(.96) mitigated both data shortage and incorrect alignments and formed a clear envelope over the other three, giving clear evidence that the filter and the ensemble complemented one another. \vspace{-2ex} \begin{figure}[h] \centering \includegraphics[width=.5\textwidth]{figs_final/sipcdevLatest.pdf} \caption{SacreBLEU vs Steps on SIPCdev set}\label{fig:ablation} \end{figure} \iffalse \subsection{\textcolor{red}{Human Evaluations}} \textcolor{red}{Not enough time or space left, will work on it during rebuttal period.} \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Model}\\ \hline Google Translate\\ Bing Translate\\ Ours\\ \hline \end{tabular} \begin{tabular}{cc} \hline \textbf{Bn$\rightarrow$En} & \textbf{En$\rightarrow$Bn}\\ \hline \textbf{84.76} & 94.33\\ 20.00 & 20.00\\ 20.00 & 20.00\\ \hline \end{tabular} \caption{Evaluation (BLEU) of SUParatest}\label{tab:human} \end{table} \fi \section{Credits} This document has been adapted by Yulan He from the instructions for earlier ACL and NAACL proceedings, including those for ACL 2020 by Steven Bethard, Ryan Cotterrell and Rui Yan, ACL 2019 by Douwe Kiela and Ivan Vuli\'{c}, NAACL 2019 by Stephanie Lukin and Alla Roskovskaya, ACL 2018 by Shay Cohen, Kevin Gimpel, and Wei Lu, NAACL 2018 by Margaret Michell and Stephanie Lukin, 2017/2018 (NA)ACL bibtex suggestions from Jason Eisner, ACL 2017 by Dan Gildea and Min-Yen Kan, NAACL 2017 by Margaret Mitchell, ACL 2012 by Maggie Li and Michael White, ACL 2010 by Jing-Shing Chang and Philipp Koehn, ACL 2008 by Johanna D. Moore, Simone Teufel, James Allan, and Sadaoki Furui, ACL 2005 by Hwee Tou Ng and Kemal Oflazer, ACL 2002 by Eugene Charniak and Dekang Lin, and earlier ACL and EACL formats written by several people, including John Chen, Henry S. Thompson and Donald Walker. Additional elements were taken from the formatting instructions of the \emph{International Joint Conference on Artificial Intelligence} and the \emph{Conference on Computer Vision and Pattern Recognition}. \section{Electronically-available resources} ACL provides this description and accompanying style files at \begin{quote} \url{https://2020.emnlp.org/downloads/emnlp2020-templates.zip} \end{quote} We strongly recommend the use of these style files, which have been appropriately tailored for the EMNLP 2020 proceedings. \paragraph{\LaTeX-specific details:} The templates include the \LaTeX2e{} source (\texttt{\small emnlp2020.tex}), the \LaTeX2e{} style file used to format it (\texttt{\small emnlp2020.sty}), an ACL bibliography style (\texttt{\small acl\_natbib.bst}), an example bibliography (\texttt{\small emnlp2020.bib}), and the bibliography for the ACL Anthology (\texttt{\small anthology.bib}). \section{Length of Submission} \label{sec:length} The conference accepts submissions of long papers and short papers. Long papers may consist of up to eight (8) pages of content plus unlimited pages for references. Upon acceptance, final versions of long papers will be given one additional page -- up to nine (9) pages of content plus unlimited pages for references -- so that reviewers' comments can be taken into account. Short papers may consist of up to four (4) pages of content, plus unlimited pages for references. Upon acceptance, short papers will be given five (5) pages in the proceedings and unlimited pages for references. For both long and short papers, all illustrations and tables that are part of the main text must be accommodated within these page limits, observing the formatting instructions given in the present document. Papers that do not conform to the specified length and formatting requirements are subject to be rejected without review. The conference encourages the submission of additional material that is relevant to the reviewers but not an integral part of the paper. There are two such types of material: appendices, which can be read, and non-readable supplementary materials, often data or code. Additional material must be submitted as separate files, and must adhere to the same anonymity guidelines as the main paper. The paper must be self-contained: it is optional for reviewers to look at the supplementary material. Papers should not refer, for further detail, to documents, code or data resources that are not available to the reviewers. Refer to Appendices~\ref{sec:appendix} and \ref{sec:supplemental} for further information. Workshop chairs may have different rules for allowed length and whether supplemental material is welcome. As always, the respective call for papers is the authoritative source. \section{Anonymity} As reviewing will be double-blind, papers submitted for review should not include any author information (such as names or affiliations). Furthermore, self-references that reveal the author's identity, \emph{e.g.}, \begin{quote} We previously showed \citep{Gusfield:97} \ldots \end{quote} should be avoided. Instead, use citations such as \begin{quote} \citet{Gusfield:97} previously showed\ldots \end{quote} Please do not use anonymous citations and do not include acknowledgements. \textbf{Papers that do not conform to these requirements may be rejected without review.} Any preliminary non-archival versions of submitted papers should be listed in the submission form but not in the review version of the paper. Reviewers are generally aware that authors may present preliminary versions of their work in other venues, but will not be provided the list of previous presentations from the submission form. Once a paper has been accepted to the conference, the camera-ready version of the paper should include the author's names and affiliations, and is allowed to use self-references. \paragraph{\LaTeX-specific details:} For an anonymized submission, ensure that {\small\verb|\aclfinalcopy|} at the top of this document is commented out, and that you have filled in the paper ID number (assigned during the submission process on softconf) where {\small\verb|***|} appears in the {\small\verb|\def\aclpaperid{***}|} definition at the top of this document. For a camera-ready submission, ensure that {\small\verb|\aclfinalcopy|} at the top of this document is not commented out. \section{Multiple Submission Policy} Papers that have been or will be submitted to other meetings or publications must indicate this at submission time in the START submission form, and must be withdrawn from the other venues if accepted by EMNLP 2020. Authors of papers accepted for presentation at EMNLP 2020 must notify the program chairs by the camera-ready deadline as to whether the paper will be presented. We will not accept for publication or presentation the papers that overlap significantly in content or results with papers that will be (or have been) published elsewhere. Authors submitting more than one paper to EMNLP 2020 must ensure that submissions do not overlap significantly ($>$25\%) with each other in content or results. \section{Formatting Instructions} Manuscripts must be in two-column format. Exceptions to the two-column format include the title, authors' names and complete addresses, which must be centered at the top of the first page, and any full-width figures or tables (see the guidelines in Section~\ref{ssec:title-authors}). \textbf{Type single-spaced.} Start all pages directly under the top margin. The manuscript should be printed single-sided and its length should not exceed the maximum page limit described in Section~\ref{sec:length}. Pages should be numbered in the version submitted for review, but \textbf{pages should not be numbered in the camera-ready version}. \paragraph{\LaTeX-specific details:} The style files will generate page numbers when {\small\verb|\aclfinalcopy|} is commented out, and remove them otherwise. \subsection{File Format} \label{sect:pdf} For the production of the electronic manuscript you must use Adobe's Portable Document Format (PDF). Please make sure that your PDF file includes all the necessary fonts (especially tree diagrams, symbols, and fonts with Asian characters). When you print or create the PDF file, there is usually an option in your printer setup to include none, all or just non-standard fonts. Please make sure that you select the option of including ALL the fonts. \textbf{Before sending it, test your PDF by printing it from a computer different from the one where it was created.} Moreover, some word processors may generate very large PDF files, where each page is rendered as an image. Such images may reproduce poorly. In this case, try alternative ways to obtain the PDF. One way on some systems is to install a driver for a postscript printer, send your document to the printer specifying ``Output to a file'', then convert the file to PDF. It is of utmost importance to specify the \textbf{A4 format} (21 cm x 29.7 cm) when formatting the paper. Print-outs of the PDF file on A4 paper should be identical to the hardcopy version. If you cannot meet the above requirements about the production of your electronic submission, please contact the publication chairs as soon as possible. \paragraph{\LaTeX-specific details:} PDF files are usually produced from \LaTeX{} using the \texttt{\small pdflatex} command. If your version of \LaTeX{} produces Postscript files, \texttt{\small ps2pdf} or \texttt{\small dvipdf} can convert these to PDF. To ensure A4 format in \LaTeX, use the command {\small\verb|\special{papersize=210mm,297mm}|} in the \LaTeX{} preamble (below the {\small\verb|\usepackage|} commands) and use \texttt{\small dvipdf} and/or \texttt{\small pdflatex}; or specify \texttt{\small -t a4} when working with \texttt{\small dvips}. \subsection{Layout} \label{ssec:layout} Format manuscripts two columns to a page, in the manner these instructions are formatted. The exact dimensions for a page on A4 paper are: \begin{itemize} \item Left and right margins: 2.5 cm \item Top margin: 2.5 cm \item Bottom margin: 2.5 cm \item Column width: 7.7 cm \item Column height: 24.7 cm \item Gap between columns: 0.6 cm \end{itemize} \noindent Papers should not be submitted on any other paper size. If you cannot meet the above requirements about the production of your electronic submission, please contact the publication chairs above as soon as possible. \subsection{Fonts} For reasons of uniformity, Adobe's \textbf{Times Roman} font should be used. If Times Roman is unavailable, you may use Times New Roman or \textbf{Computer Modern Roman}. Table~\ref{font-table} specifies what font sizes and styles must be used for each type of text in the manuscript. \begin{table} \centering \begin{tabular}{lrl} \hline \textbf{Type of Text} & \textbf{Font Size} & \textbf{Style} \\ \hline paper title & 15 pt & bold \\ author names & 12 pt & bold \\ author affiliation & 12 pt & \\ the word ``Abstract'' & 12 pt & bold \\ section titles & 12 pt & bold \\ subsection titles & 11 pt & bold \\ document text & 11 pt &\\ captions & 10 pt & \\ abstract text & 10 pt & \\ bibliography & 10 pt & \\ footnotes & 9 pt & \\ \hline \end{tabular} \caption{\label{font-table} Font guide. } \end{table} \paragraph{\LaTeX-specific details:} To use Times Roman in \LaTeX2e{}, put the following in the preamble: \begin{quote} \small \begin{verbatim} \usepackage{times} \usepackage{latexsym} \end{verbatim} \end{quote} \subsection{Ruler} A printed ruler (line numbers in the left and right margins of the article) should be presented in the version submitted for review, so that reviewers may comment on particular lines in the paper without circumlocution. The presence or absence of the ruler should not change the appearance of any other content on the page. The camera ready copy should not contain a ruler. \paragraph{Reviewers:} note that the ruler measurements may not align well with lines in the paper -- this turns out to be very difficult to do well when the paper contains many figures and equations, and, when done, looks ugly. In most cases one would expect that the approximate location will be adequate, although you can also use fractional references (\emph{e.g.}, this line ends at mark $295.5$). \paragraph{\LaTeX-specific details:} The style files will generate the ruler when {\small\verb|\aclfinalcopy|} is commented out, and remove it otherwise. \subsection{Title and Authors} \label{ssec:title-authors} Center the title, author's name(s) and affiliation(s) across both columns. Do not use footnotes for affiliations. Place the title centered at the top of the first page, in a 15-point bold font. Long titles should be typed on two lines without a blank line intervening. Put the title 2.5 cm from the top of the page, followed by a blank line, then the author's names(s), and the affiliation on the following line. Do not use only initials for given names (middle initials are allowed). Do not format surnames in all capitals (\emph{e.g.}, use ``Mitchell'' not ``MITCHELL''). Do not format title and section headings in all capitals except for proper names (such as ``BLEU'') that are conventionally in all capitals. The affiliation should contain the author's complete address, and if possible, an electronic mail address. The title, author names and addresses should be completely identical to those entered to the electronical paper submission website in order to maintain the consistency of author information among all publications of the conference. If they are different, the publication chairs may resolve the difference without consulting with you; so it is in your own interest to double-check that the information is consistent. Start the body of the first page 7.5 cm from the top of the page. \textbf{Even in the anonymous version of the paper, you should maintain space for names and addresses so that they will fit in the final (accepted) version.} \subsection{Abstract} Use two-column format when you begin the abstract. Type the abstract at the beginning of the first column. The width of the abstract text should be smaller than the width of the columns for the text in the body of the paper by 0.6 cm on each side. Center the word \textbf{Abstract} in a 12 point bold font above the body of the abstract. The abstract should be a concise summary of the general thesis and conclusions of the paper. It should be no longer than 200 words. The abstract text should be in 10 point font. \subsection{Text} Begin typing the main body of the text immediately after the abstract, observing the two-column format as shown in the present document. Indent 0.4 cm when starting a new paragraph. \subsection{Sections} Format section and subsection headings in the style shown on the present document. Use numbered sections (Arabic numerals) to facilitate cross references. Number subsections with the section number and the subsection number separated by a dot, in Arabic numerals. \subsection{Footnotes} Put footnotes at the bottom of the page and use 9 point font. They may be numbered or referred to by asterisks or other symbols.\footnote{This is how a footnote should appear.} Footnotes should be separated from the text by a line.\footnote{Note the line separating the footnotes from the text.} \subsection{Graphics} Place figures, tables, and photographs in the paper near where they are first discussed, rather than at the end, if possible. Wide illustrations may run across both columns. Color is allowed, but adhere to Section~\ref{ssec:accessibility}'s guidelines on accessibility. \paragraph{Captions:} Provide a caption for every illustration; number each one sequentially in the form: ``Figure 1. Caption of the Figure.'' ``Table 1. Caption of the Table.'' Type the captions of the figures and tables below the body, using 10 point text. Captions should be placed below illustrations. Captions that are one line are centered (see Table~\ref{font-table}). Captions longer than one line are left-aligned (see Table~\ref{tab:accents}). \begin{table} \centering \begin{tabular}{lc} \hline \textbf{Command} & \textbf{Output}\\ \hline \verb|{\"a}| & {\"a} \\ \verb|{\^e}| & {\^e} \\ \verb|{\`i}| & {\`i} \\ \verb|{\.I}| & {\.I} \\ \verb|{\o}| & {\o} \\ \verb|{\'u}| & {\'u} \\ \verb|{\aa}| & {\aa} \\\hline \end{tabular} \begin{tabular}{lc} \hline \textbf{Command} & \textbf{Output}\\ \hline \verb|{\c c}| & {\c c} \\ \verb|{\u g}| & {\u g} \\ \verb|{\l}| & {\l} \\ \verb|{\~n}| & {\~n} \\ \verb|{\H o}| & {\H o} \\ \verb|{\v r}| & {\v r} \\ \verb|{\ss}| & {\ss} \\ \hline \end{tabular} \caption{Example commands for accented characters, to be used in, \emph{e.g.}, \BibTeX\ names.}\label{tab:accents} \end{table} \paragraph{\LaTeX-specific details:} The style files are compatible with the caption and subcaption packages; do not add optional arguments. \textbf{Do not override the default caption sizes.} \subsection{Hyperlinks} Within-document and external hyperlinks are indicated with Dark Blue text, Color Hex \#000099. \subsection{Citations} Citations within the text appear in parentheses as~\citep{Gusfield:97} or, if the author's name appears in the text itself, as \citet{Gusfield:97}. Append lowercase letters to the year in cases of ambiguities. Treat double authors as in~\citep{Aho:72}, but write as in~\citep{Chandra:81} when more than two authors are involved. Collapse multiple citations as in~\citep{Gusfield:97,Aho:72}. Refrain from using full citations as sentence constituents. Instead of \begin{quote} ``\citep{Gusfield:97} showed that ...'' \end{quote} write \begin{quote} ``\citet{Gusfield:97} showed that ...'' \end{quote} \begin{table*} \centering \begin{tabular}{lll} \hline \textbf{Output} & \textbf{natbib command} & \textbf{Old ACL-style command}\\ \hline \citep{Gusfield:97} & \small\verb|\citep| & \small\verb|\cite| \\ \citealp{Gusfield:97} & \small\verb|\citealp| & no equivalent \\ \citet{Gusfield:97} & \small\verb|\citet| & \small\verb|\newcite| \\ \citeyearpar{Gusfield:97} & \small\verb|\citeyearpar| & \small\verb|\shortcite| \\ \hline \end{tabular} \caption{\label{citation-guide} Citation commands supported by the style file. The style is based on the natbib package and supports all natbib citation commands. It also supports commands defined in previous ACL style files for compatibility. } \end{table*} \paragraph{\LaTeX-specific details:} Table~\ref{citation-guide} shows the syntax supported by the style files. We encourage you to use the natbib styles. You can use the command {\small\verb|\citet|} (cite in text) to get ``author (year)'' citations as in \citet{Gusfield:97}. You can use the command {\small\verb|\citep|} (cite in parentheses) to get ``(author, year)'' citations as in \citep{Gusfield:97}. You can use the command {\small\verb|\citealp|} (alternative cite without parentheses) to get ``author year'' citations (which is useful for using citations within parentheses, as in \citealp{Gusfield:97}). \subsection{References} Gather the full set of references together under the heading \textbf{References}; place the section before any Appendices. Arrange the references alphabetically by first author, rather than by order of occurrence in the text. Provide as complete a citation as possible, using a consistent format, such as the one for \emph{Computational Linguistics\/} or the one in the \emph{Publication Manual of the American Psychological Association\/}~\citep{APA:83}. Use full names for authors, not just initials. Submissions should accurately reference prior and related work, including code and data. If a piece of prior work appeared in multiple venues, the version that appeared in a refereed, archival venue should be referenced. If multiple versions of a piece of prior work exist, the one used by the authors should be referenced. Authors should not rely on automated citation indices to provide accurate references for prior and related work. The following text cites various types of articles so that the references section of the present document will include them. \begin{itemize} \item Example article in journal: \citep{Ando2005}. \item Example article in proceedings, with location: \citep{borschinger-johnson-2011-particle}. \item Example article in proceedings, without location: \citep{andrew2007scalable}. \item Example arxiv paper: \citep{rasooli-tetrault-2015}. \end{itemize} \paragraph{\LaTeX-specific details:} The \LaTeX{} and Bib\TeX{} style files provided roughly follow the American Psychological Association format. If your own bib file is named \texttt{\small emnlp2020.bib}, then placing the following before any appendices in your \LaTeX{} file will generate the references section for you: \begin{quote}\small \verb|\bibliographystyle{acl_natbib}|\\ \verb| \section{Introduction} Recent advances in deep learning \citep{bahdanau2014neural, wu2016google, vaswani2017attention} have aided in the development of neural machine translation (NMT) models to achieve state-of-the-art results in several language pairs. But a large number of high-quality sentence pairs must be fed into these models to train them effectively \citep{koehn2017six}; and in fact lack of such a corpus affects the performance thereof severely. Although there have been efforts to improve machine translation in low-resource contexts, particularly using, for example, comparable corpora \citep{irvine2013combining}, small parallel corpora \citep{gu2018universal} or zero-shot multilingual translation \citep{johnson2017google}, such languages are yet to achieve noteworthy results \citep{koehn2019findings} compared to high-resource ones. Unfortunately, Bengali, the seventh (fifth) most widely spoken language in the world by the number of (native\footnote{\url{https://w.wiki/Psq}}) speakers,\footnote{\url{https://w.wiki/Pss}} has still remained a low-resource language. As of now, only a few parallel corpora for Bengali language are publicly available \citep{tiedemann2012parallel} and those too suffer from poor sentence segmentation, resulting in poor alignments. They also contain much noise, which, in turn, hurts translation quality \citep{khayrallah2018impact}. No previous work on Bengali-English machine translation addresses any of these issues. With the above backdrop, in this work, we develop a customized sentence segmenter for Bengali language while keeping uniformity with the English side segmentation. We experimentally show that better sentence segmentation that maintains homogeneity on both sides results in better alignments. We further empirically show that the choice of sentence aligner plays a significant role in the quantity of parallel sentences extracted from document pairs. In particular, we study three aligners and show that combining their results, which we name `Aligner Ensembling', increases recall. \iffalse We also develop an aligner for some Bengali law documents, where other aligners perform poorly.\fi We introduce `Batch Filtering', a fast and effective method for filtering out incorrect alignments. Using our new segmenter, aligner ensemble, and batch filter, we collect a total of 2.75 million high-quality parallel sentences from a wide variety of domains, more than 2 million of which were not previously available. Training our corpus on NMT models, we outperform previous approaches to Bengali-English machine translation by more than 9 BLEU \citep{papineni2002bleu} points and also show competitive performance with automatic translators. We also prepare a new test corpus containing 1000 pairs made with extensive manual and automated quality checks. Furthermore, we perform an ablation study to validate the soundness of our design choices. \iffalse We summarize our contributions as follows: a custom sentence segmenter for Bengali, aligner ensembling for increasing recall, batch filtering for removing incorrect alignments, a 2.75 million parallel corpus that outperforms previous approaches, and a new test set. \fi \iffalse \begin{enumerate} \item Custom sentence segmenter for Bengali. \item Aligner ensembling for increasing recall. \item Chunked filtering for removing incorrect alignments. \item A 2.75 million parallel corpus that outperforms all previous approaches. \item A new out-of-domain test set. \end{enumerate} \fi We release all our tools, datasets, and models for public use. To the best of our knowledge, this is the first ever large scale study on machine translation for Bengali-English pair. We believe that the insights brought to light through our work may give new life to Bengali-English MT that suffered so far for being low in resources. We also believe that our findings will also help design more efficient methods for other low-resource languages. \section{Introduction} \iffalse The following instructions are directed to authors of papers submitted to EMNLP 2020 or accepted for publication in its proceedings. All authors are required to adhere to these specifications. Authors are required to provide a Portable Document Format (PDF) version of their papers. \textbf{The proceedings are designed for printing on A4 paper.} \fi Recent advances in deep learning \citep{sutskever2014sequence, bahdanau2014neural, vaswani2017attention} have allowed neural machine translation (NMT) models to achieve state-of-the-art results in several language pairs. But these advanced models need a large number of high quality parallel sentence pairs to train effectively \citep{koehn2017six}, and their absence can even hurt results severely. Although there have been efforts to improve translation in low resource contexts using comparable corpora \citep{irvine2013combining}, small parallel corpora \citep{gu2018universal} or zero-shot multilingual translation \citep{johnson2017google}, such languages are yet to achieve noteworthy results \citep{koehn2019findings} compared to high resource ones like English, German, French etc. Bengali, the fifth most widely spoken language in the world by number of native speakers,\footnote{\url{https://w.wiki/Psq}} and seventh by total number of speakers,\footnote{\url{https://w.wiki/Pss}} has unfortunately, still remained a low resource language. As of now, only few parallel corpora for Bengali language in one side are publicly available \citep{tiedemann2012parallel}. Even those corpora suffer from poor sentence segmentation, and thus poor alignments. They also contain much noise which, in turn, hurts translation quality \citep{khayrallah2018impact}. In this paper, we address the shortcomings mentioned above and organize our contributions as follows: \begin{enumerate} \item We develop a customized sentence segmenter for Bengali language while keeping uniformity with the English side segmentation and show better segmentation leads to better sentence alignments. \iffalse We develop a customized sentence segmenter for Bengali language while keeping uniformity with the English side segmentation. We experimentally show that better sentence segmentation that maintain homogeneity on both sides results in better alignments. \fi \item We show that combining the results of multiple aligners increases recall significantly; we call this aligner ensembling.\iffalse We empirically show the choice of sentence aligner plays a significant role in quality and quantity of parallel sentences extracted from document pairs. We study three aligners and show that ensembling their results increases recall. We also develop an aligner for some Bengali law documents, where other available aligners performed poorly. \fi \item We introduce chunked filtering: an effective and fast method for filtering incorrect alignments. \item We collect 2.75 million parallel sentences from a wide variety of domains, which, trained on NMT models, outperforms all previous approaches to Bengali-English translation by a large margin. \iffalse We collect a total of 2.75 million parallel sentences from a wide variety of domains. Trained on NMT models, it outperforms all previous approaches to Bengali-English translation and vice-versa by a large margin.\fi \item We perform evaluation on a new out-of-domain political news article corpus to show generalizability of our model. \iffalse We perform evaluation on an out-of-domain political news article corpus consisting of \textcolor{red}{600} sentence pairs to show generalizability of our model.\fi \end{enumerate} We open-source all our tools, datasets, and models for public use. \section{Related Works} The first initiative towards machine translation for Bengali dates back to the 90s. \citet{sinha1995anglabharti} developed ANGLABHARTI, a rule-based translation system from English to multiple Indian languages, including Bengali. \citet{asaduzzaman2003morphological, dasgupta2004optimal} conducted extensive syntactic analyses to write rules for constructing Bengali parse trees and designed algorithms to transfer between Bengali and English parse trees. Subsequently, \citet{saha2005semantics} reported an example-based machine translation approach for translating news headlines using a knowledge base. \citet{naskar2006phrasal} described a hybrid between rule-based and example-based translation approaches; here terminals would end at phrases that would then be looked up in the knowledge base. The improved translation quality of phrase-based statistical machine translation (SMT) \citep{koehn2003statistical} and the wide availability of toolkits thereof \citep{koehn2007moses} created an increased interest in SMT for Bangali-English. As SMT was more data-driven, specialized techniques were integrated to account for the low amount of parallel data for Bengali-English. Among many, \citet{roy2009semi} proposed several semi-supervised techniques; \citet{haffari2009active} used active learning to improve SMT; \citet{islam2010english} used an additional transliteration module to handle OOV words; \citet{banerjee2018multilingual} introduced \iffalse many-to-one \fi multilingual SMT for Indic languages, including Bengali. Although NMT is currently being hailed as the state-of-the-art, very few works have been done on NMT for the Bengali-English pair. \citet{dandapat2018training} trained a deployable general domain NMT model for Bengali-English using sentences aligned from comparable corpora. They combated the inadequacy of training examples by data augmentation using back-translation \citep{sennrich2015improving}. \citet{hasanneural, mumin2019neural} also showed with limited parallel data available on the web that NMT provided improved translation for Bengali-English pair. \section{Sentence Segmentation} Proper sentence segmentation is an essential \iffalse requirement\fi pre-requisite for sentence aligners to produce coherent alignments. However, segmenting a text into sentences is not a trivial task, since the end-of-sentence punctuation marks are ambiguous. For example, in English, the end-of-sentence period, abbreviations, ellipsis, decimal point, etc. use the same symbol (.). Since either side of a document pair can contain Bengali/English/foreign text, we need a sentence segmenter to produce consistent segmentation \iffalse for both sides \fi in a language-independent manner. \begin{figure}[h] \centering \includegraphics[width=0.5\textwidth]{figs_final/Demo_Ledger.pdf} \caption{Erroneous sentence segmentation by Polyglot} \label{polyglot} \end{figure} Available libraries supporting both Bengali and English \iffalse sentence\fi segmentation, e.g., Polyglot \citep{al2013polyglot}, do not work particularly well for Bengali sentences with abbreviations, which is common in many domains. For instance, Polyglot inaccurately splits the input sentence in Figure \ref{polyglot} \iffalse the sentence ``{\bengali{কাজী মুহম্মদ ওয়াজেদের একমাত্র পুত্র ছিলেন এ. কে. ফজলুল হক।}}" (Kazi Muhammad Wazid's only son was A. K. Fazlul Huq.) into three sentences: 1) ``{\bengali{কাজী মুহম্মদ ওয়াজেদের একমাত্র পুত্র ছিলেন এ.}}" 2) ``{\bengali{কে.}}" 3) ``{\bengali{ফজলুল হক।}}"\fi into three segments, whereas the English side can successfully detect the non-breaking tokens. Not only does this corrupt the first alignment, but also causes the two broken pieces to be aligned with other sentences, creating a chain of incorrect alignments. SegTok,\footnote{\url{https://github.com/fnl/segtok}} a rule-based segmentation library\iffalse written for Indo-European languages \fi, does an excellent job of segmenting English texts. SegTok uses regular expressions to handle many complex cases, e.g., technical texts, URLs, abbreviations. We \iffalse significantly \fi extended SegTok's code to have the same functionality for Bengali texts by adding new rules (e.g., quotations, parentheses, bullet points) and abbreviations identified through analyzing both Bengali and English side of our corpus, side-by-side enhancing SegTok's English segmentation correctness as well. Our segmenter can now address the issues like the example mentioned and provide consistent outputs in a language-agnostic manner. We compared the performance of our segmenter on different aligners against Polyglot. We found that despite the number of aligned pairs decreased by 1.37\%, the total number of words on both sides increased by 5.39\%, making the resulting parallel corpus richer in content than before. This also bolsters our hypothesis that Polyglot creates unnecessary sentence fragmentation. \section{Supplemental Material} \label{sec:supplemental} Submissions may include non-readable supplementary material used in the work and described in the paper. Any accompanying software and/or data should include licenses and documentation of research review as appropriate. Supplementary material may report preprocessing decisions, model parameters, and other details necessary for the replication of the experiments reported in the paper. Seemingly small preprocessing decisions can sometimes make a large difference in performance, so it is crucial to record such decisions to precisely characterize state-of-the-art methods. Nonetheless, supplementary material should be supplementary (rather than central) to the paper. \textbf{Submissions that misuse the supplementary material may be rejected without review.} Supplementary material may include explanations or details of proofs or derivations that do not fit into the paper, lists of features or feature templates, sample inputs and outputs for a system, pseudo-code or source code, and data. (Source code and data should be separate uploads, rather than part of the paper). The paper should not rely on the supplementary material: while the paper may refer to and cite the supplementary material and the supplementary material will be available to the reviewers, they will not be asked to review the supplementary material. \section{Test} \begin{table}[h] \centering \begin{tabular}{l} \hline \textbf{Aligner}\\ \hline Hunalign\\ Gargantua\\ Bleualign\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{$F_1$ Score}\\ \hline \textbf{93.21} & 85.82 & \textbf{89.37} \\ 84.79 & 69.32 & 76.28\\ 89.41 & \textbf{87.35} & 88.37\\ \hline \end{tabular} \caption{Performance measures (\%) for the aligners}\label{tab:hgb} \vspace{1em} \begin{tabular}{l} \hline \textbf{Ensemble}\\ \hline HG\\ GB\\ BH\\ HGB\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{$F_1$ Score}\\ \hline 83.52 & 88.00 & 85.70\\ 81.11 & 93.20 & 86.73\\ \textbf{86.16} & 94.76 & \textbf{90.26}\\ 78.64 & \textbf{95.13} & 86.10\\ \hline \end{tabular} \caption{Performance measures (\%) for the ensembles}\label{tab:ensemble} \vspace{1em} \begin{tabular}{l} \hline \textbf{Ensemble}\\ \hline L(1.02)\\ HG+L(0.96)\\ GB+L(0.98)\\ BH+L(0.96)\\ HGB+L(0.98)\\ \hline \end{tabular} \begin{tabular}{ccc} \hline \textbf{Precision} & \textbf{Recall} & \textbf{$F_1$}\\ \hline 90.86 & 80.34 & 85.28\\ \textbf{94.09} & 86.86 & 90.33\\ 92.31 & 91.52 & 91.91\\ 91.91 & \textbf{93.60} & \textbf{92.75}\\ 91.52 & 93.23 & 92.37\\ \hline \end{tabular} \caption{Performance measures (\%) for the filtered ennsembles}\label{tab:fensemble} \end{table}
{'timestamp': '2020-10-08T02:11:14', 'yymm': '2009', 'arxiv_id': '2009.09359', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09359'}
arxiv
\section{Introduction} There are many situations, spanning art and science, in which the objects under consideration are locally consistent but globally inconsistent, where the terms ``local", ``global", and ``consistent" are used in some intuitive sense but can be made precise in each concrete setting. In art, Escher's~1960 \emph{Ascending and Descending} and~1961 \emph{Waterfall} lithographs are striking depictions of locally consistent but globally inconsistent situations. Closely related to Escher's artwork is the work by L.S.~Penrose and R.~Penrose~\cite{penrose1958impossible} on impossible objects, such as the impossible tribar (see also~\cite{francis2007impossible}). In quantum mechanics, the interplay between local consistency and global inconsistency takes the form of non-locality and contextuality phenomena, where collections of empirical local measurements may not admit a global explanation via a hidden variable; prominent results in this area include Bell's Theorem~\cite{bell1964einstein} and Hardy's paradox~\cite{hardy1992quantum}. In probability theory, there is work on when a given collection of pairwise consistent probability distributions admits a global distribution whose marginal distributions coincide with the given collection~\cite{vorob1962consistent}. In computer science, the interplay between local consistency and global consistency arises in such different areas as constraint satisfaction~\cite{DBLP:books/daglib/0016622}, proof complexity~\cite{ChvatalSzemeredi1988}, and relational databases~\cite{BeeriFaginMaierYannakakis1983}. What do the aforementioned situations have in common and is there a unifying framework behind them? Abramsky~\cite{DBLP:conf/birthday/Abramsky13,DBLP:journals/eatcs/Abramsky14} pointed out that there are formal connections between non-locality and contextuality in quantum mechanics on one side and the universal relation problem in database theory on the other side. The latter is the following decision problem: given a collection~$X_1,\ldots,X_m$ of sets of attributes (that is, names of columns of relations) and a collection~$R_1,\ldots,R_m$ of relations over~$X_1,\ldots,X_m$ (that is,~$X_i$ is the set of the attributes of~$R_i$, for~$i\in [m]$), are the relations~$R_1,\ldots,R_m$ globally consistent? In other words, is there a relation~$R$, called a \emph{universal} relation, over~$X_1\cup \cdots \cup X_m$ such that, for every~$i \in [m]$, the projection~$R[X_i]$ of~$R$ on~$X_i$ is equal to~$R_i$? Clearly, if such a universal relation exists, then the relations~$R_1,\ldots,R_m$ are \emph{pairwise consistent}, i.e.,~$R_i[X_i\cap X_j] = R_j[X_i\cap X_j]$, for all~$i,j \in [m]$, but the converse need not hold. Switching to the quantum mechanics side and by regarding the collection of empirical measurements in~\cite{hardy1992quantum} as a collection of database relations, Hardy's paradox can be viewed as a negative instance of the universal relation problem: the database relations at hand are pairwise consistent, but globally inconsistent. Note that, since experiments are typically repeated, measurements give rise to probabilities. This way, Bell's Theorem~\cite{bell1964einstein} can be viewed as an instance of a collection of probability distributions that are pairwise consistent, but globally inconsistent. As regards unifying frameworks, Abramsky and Brandenburger~\cite{DBLP:journals/corr/abs-1102-0264} used sheaf theory to provide a unified account of non-locality and contextuality. This approach was explored further in~\cite{DBLP:journals/corr/abs-1111-3620,DBLP:conf/csl/AbramskyBKLM15}. As mentioned in the preceding paragraph, pairwise consistency is a necessary, but not sufficient, condition for a collection of relations to be globally consistent. In the setting of relational databases, Beeri, Fagin, Maier, and Yannakakis~\cite{BeeriFaginMaierYannakakis1983} characterized when pairwise consistency is also a sufficient condition for global consistency. If~$X_1,\ldots,X_m$ are sets of attributes, we say that the collection~$X_1,\ldots,X_m$ has the \emph{\ltgc}~if every collection~$R_1,\ldots,R_m$ of pairwise consistent relations over~$X_1,\ldots,X_m$ is globally consistent. The main finding in Beeri et al.~\cite{BeeriFaginMaierYannakakis1983} is that a collection~$X_1,\ldots,X_m$ of sets of attributes has the \ltgc~if and only if the hypergraph with~$X_1,\ldots,X_m$ as hyperedges is acyclic, where the notion of hypergraph acyclicity is a suitable generalization of the notion of graph acyclicity. Observe that the \ltgc~is a semantic property (in the sense that its definition involves relations over the sets of attributes), while acyclicity is a syntactic property (in the sense that it describes a structural property of hypergraphs with no reference to relations). In~\cite{BeeriFaginMaierYannakakis1983}, several other syntactic conditions on hypergraphs were considered, and each was shown to be equivalent to acyclicity. In the setting of probability theory, Vorob'ev~\cite{vorob1962consistent} identified a different syntactic condition on hypergraphs, which we call \emph{Vorob'ev regularity}, and showed that a collection of probability distributions over~$X_1,\ldots,X_m$ has the \ltgc~(suitably adapted to probability distributions) if and only the hypergraph with~$X_1,\ldots,X_m$ as hyperedges is Vorob'ev regular. It is perhaps worth noting that Vorob'ev's paper~\cite{vorob1962consistent} was published much earlier, but Beeri et al.~\cite{BeeriFaginMaierYannakakis1983} were apparently unaware of Vorob'ev's work. It is now natural to ask: is there a common generalization of the above results? This question was investigated by Barbosa in his doctoral thesis~\cite[Chapter VI]{Barbosa-thesis}. Barbosa explored the question in the sheaf-theoretic framework for non-locality and contextuality and showed that hypergraph acyclicity implies the \ltgc~in that framework, but did not obtain the reverse direction. We establish a common generalization of the results by Vorob'ev~\cite{vorob1962consistent} and by Beeri et al.~\cite{BeeriFaginMaierYannakakis1983}. Instead of the sheaf-theoretic framework, we work in the algebraic framework of \emph{positive semirings}, which are commutative semirings with no zero-divisors and with the property that~$a+b=0$ holds for two elements~$a$ and~$b$ of the semiring if and only if~$a=b=0$. Positive semirings were used to study the provenance of relational database queries~\cite{DBLP:conf/pods/GreenKT07} and also the provenance of first-order sentences~\cite{DBLP:journals/corr/abs-1712-01980}; furthermore, commutative semirings were considered by Abramsky~\cite{DBLP:conf/birthday/Abramsky13} in discussing algebraic databases as a generalization of relational databases. Let~$K$ be a positive semiring. As a common generalization of database relations and probability distributions, we consider~$K$-\emph{relations}, i.e., relations over a set of attributes such that each tuple in the relation has an associated element from~$K$ as value. Note that ordinary relations are~$K$-relations where~$K$ is the Boolean semiring, while probability distributions are~$K$-relations with~$K$-values adding to~$1$ and where~$K$ is the semiring of the non-negative real numbers. We introduce natural extensions of the notions of projection of a~$K$-relation, pairwise consistency, global consistency, and the \ltgc~for~$K$-relations. We then show that a collection~$X_1,\ldots,X_m$ of sets of attributes has the \ltgc~for~$K$-relations if and only if the hypergraph with~$X_1,\ldots,X_m$ as hyperedges is acyclic. We also show that a hypergraph is Vorob'ev regular if and only if it is acyclic (this result has been mentioned in passing or has been taken for granted in earlier papers, but we have not found an explicit reference for it). The results by Vorob'ev~\cite{vorob1962consistent} and by Beeri et al.~\cite{BeeriFaginMaierYannakakis1983} then follow as immediate corollaries. While the proof of our main result about the equivalence between hypergraph acyclicity and the \ltgc~for~$K$-relations bears some similarities and analogies with the earlier proofs of its special cases, it also brings in some new concepts and tools that may be of independent interest. We conclude this section by highlighting some of these concepts and tools. To prove that hypergraph acyclicity implies the local-to-global consistency property for~$K$-relations, we introduce a \emph{join} operation on~$K$-relations. We make the case that this is the ``right'' extension to~$K$-relations of the notion of the join of two ordinary relations. In particular, we show that the join of two consistent~$K$-relations witnesses their consistency and also that the basic results about lossless-join decompositions of ordinary relations extend to~$K$-relations. Note that if~$K$ is the semiring of non-negative integers, then the~$K$-relations are precisely the \emph{bags} (also known as \emph{multisets}). Our join operation on bags is, in general, different from the standard bag join used in SQL (for bag operations in SQL, see~\cite{DBLP:books/daglib/0011318}). We point out, however, that unlike the join operation introduced here, the standard bag join does not always witness the consistency of two consistent bags. Furthermore, we show that the join of two consistent probability distributions is the unique probability distribution that maximizes entropy among all probability distributions that witness the consistency of the two probability distributions we started with. To prove that the \ltgc~for~$K$-relations implies hypergraph acyclicity, we need to have a systematic way to produce negative instances of the universal relation problem, such as the instances found in Hardy's paradox and related constructions in the study of non-locality and contextuality. Note that, in our setting, we need the relations in the negative instances to be~$K$-relations where~$K$ is an \emph{arbitrary} positive semiring, instead of ordinary relations over the Boolean semiring or probability distributions over the semiring of nonnegative real numbers; furthermore, we need to be able to produce such negative instance for \emph{any} given cyclic collection~$X_1,\ldots,X_m$ of sets of attributes. For the special cases of ordinary relations and probability distributions, Beeri et al.~\cite{BeeriFaginMaierYannakakis1983} and Vorob'ev~\cite{vorob1962consistent} provided suitable such constructions, which, as far as we can tell, do not generalize to arbitrary positive semirings. For our construction, which works for an arbitrary positive semiring, we adapt an idea that can be traced to Tseitin~\cite{Tseitin1968} in his study of hard-to-prove tautologies in propositional logic. In brief, Tseitin constructed arbitrarily large sets of propositional clauses such that any fixed number of them are satisfiable, but, when taken jointly, they are unsatisfiable. The combinatorial principle underlying Tseitin's construction is the following basic~\emph{parity principle}: for every undirected graph and for every labeling of the vertices of the graph with 0's and 1's with an odd total number of 1's, there is no subset of the edges that touches every vertex a number of times that is congruent to the label of the vertex modulo~$2$. To generalize this to arbitrary cyclic hypergraphs and to arbitrary semirings, we resort to a similar modular counting principle for a modulus~$d \geq 2$ that depends on the structure of the hyperedges~$X_1,\ldots,X_m$. While similar but different variations of Tseitin's construction have been used in other contexts (see, e.g.,~\cite{DBLP:journals/jcss/BussGIP01} and~\cite{DBLP:journals/tcs/AtseriasBD09}), we are not aware of any other construction that simultaneously generalizes the results in Beeri et al.~\cite{BeeriFaginMaierYannakakis1983} and Vorob'ev~\cite{vorob1962consistent}. Furthermore, it is worth noting that our construction contains as a special case the most basic~Popescu-Rorhlich~box~\cite{popescu1994quantum}, which is another well-known example of non-locality and contextuality (see, e.g.,~\cite{DBLP:journals/corr/abs-1102-0264}). Specifically, the support of the Popescu-Rorhlich~box is precisely the special case of our construction in which the hypergraph~$X_1,\ldots,X_m$ is the 4-cycle~$AB,BC,CD,DA$ on the four vertices~$A,B,C,D$. \section{Valued Relations up to Normalization} \label{sec:valuedrelations} In this section we define the notion of \emph{valued relation}, or~\emph{$K$-relation} for a positive semiring~$K$ of values, as a generalization of the database-theoretic notion of relation. We study its most basic properties and discuss some examples. Besides the standard concept of ordinary relation from database theory, two other canonical examples will be the \emph{bags} and the \emph{probability distributions}. \subsection{Definition of Valued Relations and Their Basic Properties} We start by recalling some basic terminology and notation from the theory of databases. While most of our notation is standard and well-established, we refer to the standard textbooks~\cite{DBLP:books/cs/Ullman88} and~\cite{DBLP:books/aw/AbiteboulHV95} for further elaboration. \paragraph{Attributes, Tuples, and Relations} An \emph{attribute}~$A$ is a symbol with an associated set~$\domain(A)$ called its \emph{domain}. If~$X$ is a finite set of attributes, then we write~$\tuples(X)$ for the set of~\emph{$X$-tuples}; i.e.,~$\tuples(X)$ is the set of maps that take each attribute~$A \in X$ to an element of its domain~$\domain(A)$. Note that~$\tuples(\emptyset)$ is non-empty as it contains the \emph{empty tuple}, i.e., the unique map with empty domain. If~$Y \subseteq X$ is a subset of attributes and~$t$ is an~$X$-tuple, then the \emph{projection of~$t$ on~$Y$}, denoted by~$t[Y]$, is the unique~$Y$-tuple that agrees with~$t$ on~$Y$. In particular,~$t[\emptyset]$ is the empty tuple. A \emph{relation over~$X$} is a subset of~$\tuples(X)$; it is a finite relation if it is a finite subset of~$\tuples(X)$. In what follows, we will often refer to such relations as \emph{ordinary} relations to differentiate them from $K$-relations, where $K$ is a positive semiring other than the Boolean semiring. We write~$R(X)$ to emphasize the fact that the relation~$R$ has \emph{schema}~$X$. In this paper all sets of attributes and all relations are finite, so we omit the term. If~$Y \subseteq X$ and~$R$ is a relation over~$X$, then the \emph{projection of~$R$ on~$Y$}, denoted $R[Y]$, is the relation over~$Y$ made of all the projections~$t[Y]$ as~$t$ ranges over~$R$. If~$R$ is a relation over~$X$ and~$S$ is a relation over~$Y$, then their \emph{join}~$R \Join S$ is the relation over~$X \cup Y$ made of all the~$X \cup Y$-tuples~$t$ such that~$t[X]$ is in~$R$ and~$t[Y]$ is in~$S$. If~$X$ and~$Y$ are sets of attributes, then we write~$X\!Y$ as shorthand for the union~$X \cup Y$. Accordingly, if~$x$ is an~$X$-tuple and~$y$ is a~$Y$-tuple with the property that~$x[X \cap Y] = y[X \cap Y]$, then we write~$xy$ to denote the~$X\!Y$-tuple that agrees with~$x$ on~$X$ and on~$y$ on~$Y$. We say that~\emph{$x$ joins with~$y$}, and that~\emph{$y$ joins with~$x$}, to \emph{produce} the tuple~$xy$. \paragraph{Positive Semirings} A \emph{commutative semiring} is a set~$K$ with two binary operations~$+$ and~$\times$ that are commutative, associative, have $0$ and $1$, respectively, as identity elements,~$\times$ distributes over~$+$, and~$0$ \emph{annihilates}~$K$, that is,~$0 \times a = a \times 0 = 0$ holds for all~$a \in K$. We assume that~$0 \not= 1$, that is, the semiring is \emph{non-trivial}. The identity of multiplication~$1$ is also called the \emph{unit} of the semiring. We write multiplication~$a \times b$ by concatenation~$ab$ or with a dot~$a \cdot b$. If there do not exist non-zero~$a$ and~$b$ in~$K$ such that~$a+b=0$, then we say that~$K$ is \emph{plus-positive}. If there do not exist non-zero~$a$ and~$b$ in~$K$ such that~$ab = 0$, then we say that~\emph{$K$ has no zero-divisors}, or that~$K$ is a semiring \emph{without zero-divisors}. A plus-positive commutative semiring without zero-divisors is called \emph{positive}. In the sequel,~$K$ will always denote a non-trivial positive commutative semiring. We introduce some examples. The \emph{Boolean semiring}~$\mathbb{B} = (\{0,1\},\vee,\wedge,0,1)$ has $0$ (false) and $1$ (true) as elements, and disjunction ($\vee$) and conjunction ($\wedge$) as operations. This is a commutative semiring that is plus-positive and has no zero-divisors, hence it is positive; it is not a ring since disjunction does not have an inverse. The non-negative integers~$\mathbb{Z}^{\geq 0}$, the non-negative rationals~$\mathbb{Q}^{\geq 0}$, and the non-negative reals~$\mathbb{R}^{\geq 0}$ with their usual arithmetic operations~$+$ and~$\times$ and their identity elements~$0$ and~$1$ are also positive semirings. In contrast, the full integers~$\mathbb{Z}$, the rationals~$\mathbb{Q}$, or the reals~$\mathbb{R}$ are commutative semirings without zero-divisors that are not plus-positive. The semiring of non-negative integers~$\mathbb{Z}^{\geq 0}$ is also denoted by~$\mathbb{N}$, and it is called the \emph{bag semiring}. For an integer~$m \geq 2$, the semiring~$\mathbb{Z}_m$ of arithmetic mod~$m$, also denoted by~$\mathbb{Z}/m\mathbb{Z}$, is a commutative semiring that is not plus-positive, and that has no zero-divisors if and only if~$m$ is prime;~$\mathbb{Z}_1$ is not even non-trivial. Under the convention that~$0 < 1$, the disjunction~$\vee$ and conjunction~$\wedge$ operations of the Boolean semiring can also be written as~$\max$ and~$\min$, respectively. Semirings over arithmetic ordered domains that combine the~$\max$ or~$\min$ operations with the usual arithmetic operations are called \emph{tropical} semirings. The \emph{min-plus} semiring has the extended reals~$\mathbb{R} \cup \{ +\infty,-\infty \}$ as elements, and the standard operations of minimum and addition for~$+$ and~$\times$, with~$-\infty$ playing the role of the identity for~$\min$. The \emph{positive min-plus} semiring has the extended positive reals~$\mathbb{R}^{\geq 0} \cup \{+\infty\}$ as elements, and again standard minimum and addition for~$+$ and~$\times$, with~$0$ playing the role of identity for~$\min$. The \emph{Viterbi} semiring elements ranging over the unit interval~$[0,1]$, and the standard operations of maximum and multiplication for~$+$ and~$\times$, respectively. The \emph{rational tropical} semirings are based on the extended rational numbers in place of the extended real numbers. \paragraph{Definition of~$K$-relations and Their Marginals} Let~$K = (K^*,+,\times,0,1)$ be a semiring and let~$X$ be a finite set of attributes. A~\emph{$K$-relation over~$X$} is a map~$R : \tuples(X) \rightarrow K$ that assigns a value~$R(t)$ in~$K$ to every~$X$-tuple~$t$ in~$\tuples(X)$. Note that this definition makes sense even if~$X$ is the empty set of attributes; in such a case, a~$K$-relation over~$X$ is simply a single value from~$K$ that is assigned to the empty tuple. Note also that the ordinary relation are precisely the $\mathbb B$-relation, where $\mathbb B$~is the Boolean semiring. The \emph{support} of the~$K$-relation~$R$, denoted by~$\supp(R)$, is the set of~$X$-tuples~$t$ that are assigned non-zero value, i.e., \begin{equation} \supp(R) := \{ t \in \tuples(X) : R(t) \not= 0 \}. \label{def:support} \end{equation} Whenever this does not lead to confusion, we write~$R'$ to denote~$\supp(R)$. Note that~$R'$ is an ordinary relation over~$X$. A~$K$-relation is \emph{finitely supported} if its support is a finite set. In this paper, all~$K$-relations are finitely supported and we omit the term. When~$R'$ is empty we say that~$R$ is the empty~$K$-relation over~$X$. For~$a \in K$, we write~$aR$ to denote the~$K$-relation over~$X$ defined by~$(aR)(t) = aR(t)$ for every~$X$-tuple~$t$. It is always the case that~$\supp(aR) \subseteq \supp(R)$, and, as the proof of the next lemma shows, the reverse inclusion~$\supp(R) \subseteq \supp(aR)$ also holds in case~$a$ is a non-zero element of $K$ and~$K$ has no zero-divisors. If~$t$ is a~$Y$-tuple for some~$Y \subseteq X$, then the \emph{marginal of~$R$ over~$t$} is defined by \begin{equation} R(t) := \sum_{r \in R': \atop r[Y] = t} R(r). \label{eqn:marginal} \end{equation} Accordingly, any~$K$-relation over~$X$ induces a~$K$-relation over~$Y$ for any~$Y \subseteq X$. This~$K$-relation is denoted by~$R[Y]$ and is called the \emph{marginal of~$R$ on~$Y$}. Note that if $R$ is an ordinary relation (i.e., $R$ is a $\mathbb B$-relation), then the marginal $R[Y]$ is the projection of $R$ on $Y$, so the notation for the marginal is consistent with the one introduced for the projection earlier. It is always the case that~$\supp(R[Y]) \subseteq \supp(R)[Y]$, and, as the proof of the next lemma shows, the reverse inclusion also holds in case the semiring~$K$ is plus-positive. From now on, we make the blanket assumption that $K$ is a positive semiring. This hypothesis will not be explicitly spelled out in the statements of the various lemmas in which $K$-relations are mentioned. \begin{lemma} \label{lem:easyfacts1} Let $R(X)$ be a~$K$-relation. The following statements hold: \begin{enumerate} \itemsep=0pt \item For all non-zero elements $a$ in $K$, we have $(aR)' = R'$. \item For all~$Y \subseteq X$, we have~$R'[Y] = R[Y]'$. \item For all $Z \subseteq Y \subseteq X$, we have $R[Y][Z] = R[Z]$. \end{enumerate} \end{lemma} \begin{proof} For~1, the inclusion~$(aR)' \subseteq R'$ holds for all semirings since if~$t \in (aR)'$, then~$aR(t) \not= 0$, so~$R(t) \not= 0$ since~$0$ annihilates~$K$, and hence~$t \in R'$. For the converse, if~$t \in R'$, then~$R(t) \not = 0$, so~$aR(t) \not= 0$ since~$a$ is non-zero and~$K$ has no zero-divisors, and hence~$t \in (aR)'$. For~2, the inclusion~$R[Y]' \subseteq R'[Y]$ is obvious and holds for all semirings. For the converse, assume that~$t \in R'[Y]$, so there exists~$r$ such that~$R(r) \not= 0$ and~$r[Y] = t$. By~\eqref{eqn:marginal} and the plus-positivity of~$K$ we have that~$R(t) \not= 0$. Hence~$t \in R[Y]'$. For~3, we have \begin{equation} R[Y][Z](u) = \sum_{v \in R[Y]': \atop v[Z]=u} R[Y](v) = \sum_{v \in R'[Y]: \atop v[Z]=u} \sum_{w \in R': \atop w[Y]=v} R(w) = \sum_{w \in R': \atop w[Z]=u} R(w) = R[Z](u) \end{equation} where the first equality follows from~\eqref{eqn:marginal}, the second follows from Part~2 of this lemma to replace~$R[Y]'$ by~$R'[Y]$, and again~\eqref{eqn:marginal}, the third follows from partitioning the tuples in~$R'$ by their projection on~$Y$, together with~$Z \subseteq Y$, and the fourth follows from~\eqref{eqn:marginal} again. \end{proof} Some examples follow. \begin{example} \label{ex:examplessemirings} When~$K$ is the Boolean semiring~$\mathbb{B}$, a~$\mathbb{B}$-relation over~$X$ is simply an ordinary relation over~$X$; its support is the relation itself, and its marginals are the ordinary projections. When~$K$ is the bag semiring~$\mathbb{N}$, the~$\mathbb{N}$-relations are called \emph{bags} or \emph{multi-sets}. If~$T$ is a bag and~$t$ is a tuple in its support, then~$T(t)$ is called the \emph{multiplicity} of~$t$ in~$T$. When~$K$ is the semiring of non-negative reals~$\mathbb{R}^{\geq 0}$, the finite~$\mathbb{R}^{\geq 0}$-relations~$T$ that satisfy \begin{equation} T[\emptyset] = \sum_{t \in T'} T(t) = 1 \label{eqn:normalizationequation} \end{equation} are the probability distributions of finite support over the set~$\tuples(X)$ of~$X$-tuples, or, in short, the \emph{probability distributions over~$X$}. Conversely, to every finite non-empty~$\mathbb{R}^{\geq 0}$-relation~$T$ one can associate a probability distribution~$T^*$ through \emph{normalization}; this means that if we set~$N_T := \sum_{t \in T'} T(t)$ and~$n_T = 1/N_T$, then the $\mathbb{R}^{\geq 0}$-relation~$T^* := n_T T$ is a probability distribution. Finally, when~$K$ is the semiring of non-negative rationals~$\mathbb{Q}^{\geq 0}$, the corresponding probability distributions are called \emph{rational} probability distributions. \end{example} \subsection{Equivalence of~$K$-Relations} We introduce a notion of equivalence between two~$K$-relations over the same set of attributes that will play an important role in the later sections of this paper. To motivate this definition, let us look again at the probability distributions seen as the~$\mathbb{R}^{\geq 0}$-relations that satisfy the normalization equation~\eqref{eqn:normalizationequation} from Example~\ref{ex:examplessemirings}. \paragraph{Derivation of the Equivalence Relation} Recall that to every non-empty~$\mathbb{R}^{\geq 0}$-relation~$T$ one can associate a probability distribution~$T^*$ through normalization~$T \mapsto T^*$. More generally, a normalization operation can be defined for any semiring~$K$ that is actually a \emph{semifield}, which is a semiring whose multiplication operation~$\times$ admits an inverse~$\div$. Note that both~$\mathbb{R}^{\geq 0}$ and~$\mathbb{Q}^{\geq 0}$ are semifields. Formally, if~$K$ is a semifield and~$T$ is a non-empty~$K$-relation over a set of attributes~$X$, then we define~$T^*$ as the~$K$-relation defined by~$T^*(t) := (1/N_T) T(t)$ for every~$X$-tuple~$t$, where~$N_T := T[\emptyset] = \sum_{t \in T'} T(t)$, and~$1/N_T$ is the multiplicative inverse of~$N_T$ in the semifield~$K$. Note that~$T$ was assumed non-empty, so~$N_T \not= 0$ since~$K$ is plus-positive, and the multiplicative inverse~$1/N_T$ exists. When~$T$ is the empty~$K$-relation, we let~$T^*$ be the empty~$K$-relation itself. With this definition in hand, still assuming that~$K$ is a semifield, we can define an equivalence relation~$R \equiv S$ to hold between two~$K$-relations~$R$ and~$S$ if and only if~$R^* = S^*$. An important observation that follows from the definitions is that if~$R$ and~$S$ are~$K$-relations over the same set of attributes, then~$R^*=S^*$ holds if and only if~$aR = bS$ for some non-zero~$a$ and~$b$ in~$K$. For the \emph{only if} direction just take~$a = 1/N_R$ and~$b = 1/N_S$ if both~$R$ and~$S$ are non-empty~$K$-relations, and~$a = b = 1$ otherwise. For the \emph{if} direction, assuming that~$R$ and~$S$ are both non-empty~$K$-relations over~$X$, for every~$X$-tuple~$t$ we have \begin{equation} R^*(t) = \frac{1}{N_R} R(t) = \frac{a}{aN_R} R(t) = \frac{b}{bN_S} S(t) = \frac{1}{N_S} S(t) = S^*(t), \end{equation} where the first equality follows from the fact that~$R^*$ is defined from~$R$ through normalization, the second follows from the assumption that~$a$ is non-zero, the third follows from the assumption that~$aR = bS$, so, in particular,~$aR(t) = bS(t)$ and also~$R'=S'$ and~$a N_R = b N_S$, the fourth follows from the assumption that~$b$ is non-zero, and the last follows from the definition of~$S^*$ through normalization. This observation motivates the following definition of the equivalence relation~$\equiv$ for arbitrary positive semirings that are not necessarily semifields. \paragraph{Definition of the Equivalence Relation for Positive Semirings} Let~$K$ be a positive semiring. Two~$K$-relations~$R$ and~$S$ over the same set of attributes are \emph{equivalent up to normalization}, denoted by~$R \equiv S$, if there exist non-zero~$a$ and~$b$ in~$K$ such that~$aR = bS$. It is obvious that~$\equiv$ is reflexive and symmetric. The next lemma collects a few easy facts about~$\equiv$, the first of which states that~$\equiv$ is also transitive, and hence an equivalence relation. We write~$[R]$ for the equivalence class of~$R$ under~$\equiv$. \begin{lemma} \label{lem:easyfacts2} Let~$R(X),S(X),T(X)$ be~$K$-relations over the same set~$X$ of attributes. The following statements hold: \begin{enumerate} \itemsep=0pt \item If $R \equiv S$ and $S \equiv T$, then $R \equiv T$. \item If $R \equiv S$, then $R' = S'$. \item If $R \equiv S$ and $Y \subseteq X$, then $R[Y] \equiv S[Y]$. \end{enumerate} \end{lemma} \begin{proof} For~1, assume that~$a R = b S$ and~$c S = d T$ for non-zero~$a$ and~$b$ in~$K$, and non-zero~$c$ and~$d$ in~$K$. Since~$K$ has no zero-divisors we have that~$ac$ and~$bd$ are non-zero. Moreover, \begin{equation} ac R = ca R = cb S = bc S = bd T, \end{equation} where the first equality is commutativity, the second follows from~$a R = b S$, the third is commutativity, and the last follows from~$c S = d T$. For~2, assume that~$a R = b S$ for non-zero~$a$ and~$b$, and that~$R(t) \not= 0$ for some~$X$-tuple~$t$. Then~$aR(t) \not= 0$ because~$K$ has no zero-divisors, hence~$bS(t) \not= 0$ by the assumption that~$aR = bS$, and~$S(t) \not= 0$ since~$0$ annihilates~$K$. This shows~$R' \subseteq S'$ and the reverse inclusion follows from symmetry. For~3, assume that~$a R = b S$ for non-zero~$a$ and~$b$ and that~$Y \subseteq X$. For every~$Y$-tuple~$u$ we have \begin{equation} a R(u) = a \sum_{r \in R': \atop r[Y] = u} R(r) = \sum_{r \in R' : \atop r[Y] = u} aR(r) = \sum_{r \in R' : \atop r[Y] = u} bS(r) = \sum_{s \in S' : \atop s[Y] = u} bS(r) = b \sum_{s \in S' : \atop s[Y] = u} S(r) = b S(u), \end{equation} where the first equality follows from~\eqref{eqn:marginal}, the second is distributivity, the third follows from the assumption that~$aR = bS$, the fourth follows from point 2 in this lemma, the fifth is again distributivity, and the sixth is~\eqref{eqn:marginal}. \end{proof} \section{Consistency of Two $K$-Relations} \label{sec:tworelations} For ordinary relations~$R(X)$ and~$S(Y)$, there are several different ways to define the concept of~$R$ and~$S$ being \emph{consistent}, and all these concepts turn out to be equivalent to each other. One way is to say that~$R$ and~$S$ arise as the projections~$T[X]$ and~$T[Y]$ of a single relation~$T$ over the union of attributes~$XY$. Another way is to say that~$R$ and~$S$ agree on their projections to the set~$Z = X \cap Y$ of their common attributes. Yet a third way is to say that their ordinary join~$R \Join S$ projects to~$R$ on~$X$ and to~$S$ on~$Y$. In this section, we study the analogous concepts for~$K$-relations with consistency defined up to normalization. Along the way, we will also define a notion of~$\Join$ for two~$K$-relations. \subsection{Consistency of Two $K$-Relations and Their Join} Let~$K$ be an arbitrary but fixed positive semiring. We start with the definition of consistency up to normalization, or more simply, consistency of two~$K$-relations. \paragraph{Consistency Up to Normalization} Let~$R(X)$ and~$S(Y)$ be two~$K$-relations. We say that~$R$ and~$S$ are \emph{consistent} if there is a~$K$-relation~$T(XY)$ such that~$R \equiv T[X]$ and~$S \equiv T[Y]$. We say that~$T$ \emph{witnesses} their consistency. Two equivalence classes~$[R]$ and~$[S]$ of~$K$-relations are \emph{consistent} if their representatives~$R$ and~$S$ are consistent. It is easy to see that this notion of consistency among equivalence classes is well-defined in that it does not depend on the chosen representatives~$R$ and~$S$. Indeed, if~$[R]$ and~$[S]$ are consistent and~$T$ witnesses the consistency of~$R$ and~$S$, then for every~$R_0 \equiv R$ and every~$S_0 \equiv S$, we have that~$T$ also witnesses the consistency of~$R_0$ and~$S_0$, by the transitivity of $\equiv$. Conversely, if~$T_0$ witnesses the consistency of~$R_0 \equiv R$ and~$S_0 \equiv S$, then it also witnesses the consistency of~$R$ and~$S$, again by the transitivity of $\equiv$. \paragraph{Naive Join Operation of Two~$K$-Relations} We want to define a join operation~$R \Join S$ for~$K$-relations~$R$ and~$S$ with the property that if~$R$ and~$S$ are consistent, then their join witnesses the consistency. A natural candidate for such an operation would be to define~$(R \Join S)(t)$ by~$R(t[X]) S(t[Y])$ for every~$XY$-tuple~$t$, where~$X$ and~$Y$ are the sets of attributes of~$R$ and~$S$, respectively. This is the straightforward generalization of the ordinary join of ordinary relations since for the Boolean semiring both definitions give the same operation. Moreover, this is the way the join of bags is defined in SQL (see \cite{DBLP:books/daglib/0011318}). As we show below, however, this naive generalization does not work: in fact, even for bags, the bag defined this way does not always witness the consistency of two consistent bags. \begin{example} \label{ex:naivejoin} Let~$R(AB),S(BC),J(ABC),U(ABC)$ be the four bags given by the following tables of multiplicities (the $\#$-column is the multiplicity): \begin{center} \begin{tabular}{lllllllllllllllllll} $R(AB)$\, \# & \;\;\;\; & $S(BC)$ \# & \;\;\;\; & $J(ABC)$\, \# & \;\;\;\; & $U(ABC)$\, \# \\ \;\;\;\, 1 2 : 6 & & \;\;\; 2 3 : 2 & & \;\;\, 1 2 3 : 12 & & \;\;\;\, 1 2 3 : 6 \\ \;\;\;\, 2 3 : 3 & & \;\;\; 2 4 : 2 & & \;\;\, 1 2 4 : 12 & & \;\;\;\, 1 2 4 : 6 \\ \;\; & & \;\;\; 3 4 : 2 & & \;\;\, 2 3 4 : 6 & & \;\;\;\, 2 3 4 : 6 \end{tabular} \end{center} Consider also the marginals of $J$ and $U$ on $AB$ and $BC$: \begin{center} \begin{tabular}{llllllllllllllllll} $J[AB]$\; \# & \;\;\;\; & $J[BC]$\; \# & \;\;\;\; & $U[AB]$\; \# & \;\;\;\; & $U[BC]$\, \# \\ \;\;\, 1 2 : 24 & & \;\;\, 2 3 : 12 & & \;\;\; 1 2 : 12 & & \;\;\; 2 3 : 6 \\ \;\;\, 2 3 : 6 & & \;\;\, 2 4 : 12 & & \;\;\; 2 3 : 6 & & \;\;\; 2 4 : 6 \\ \;\; & & \;\;\, 3 4 : 6 & & \;\;\; & & \;\;\; 3 4 : 6 \end{tabular} \end{center} The bags~$R$ and~$S$ are consistent since~$U$ witnesses their consistency: $2R = U[AB]$ and~$3S = U[BC]$. The bag~$J$ is actually the naive join of~$R$ and~$S$ defined by~$J(t) = R(t[AB])S(t[BC])$, and there are no non-zero~$a$ and~$b$ in~$\mathbb{N}$ such that~$aR = bJ[AB]$, and also there are no non-zero~$c$ and~$d$ in~$\mathbb{N}$ such that~$c S = dJ[BC]$. \end{example} \noindent This example has shown that the \emph{naive} join need not witness the consistency of~$R$ and~$S$. We need a different way of defining the join operation. \paragraph{Derivation of the New Join Operation} To arrive at the definition of the join operation that will work for arbitrary semirings, we turn again to probability distributions from Example~\ref{ex:examplessemirings} as the motivating example. Recall that a probability distribution is a~$\mathbb{R}^{\geq 0}$-relation that satisfies~\eqref{eqn:normalizationequation}. As in the discussion for defining the equivalence relation, this motivation will generalize to any semifield beyond~$\mathbb{R}^{\geq 0}$. {From} there, generalizing the definition to arbitrary semirings will be a small step. Let~$R(X)$ and~$S(Y)$ be probability distributions. It is easy to see that if~$X$ and~$Y$ were disjoint, then the~$\mathbb{R}^{\geq 0}$ relation given by~$t \mapsto R(t[X])S(t[Y])$ would again be a probability distribution. This, however, fails badly if~$X$ and~$Y$ are not disjoint as can be seen from turning the example bags~$R(AB)$ and~$S(BC)$ from Example~\ref{ex:naivejoin} into probability distributions through normalization (when seen as~$\mathbb{R}^{\geq 0}$-relations). The catch is of course that if~$Z = X \cap Y$ is non-empty, then two independent samples from the distributions~$R$ and~$S$ need not agree on their projections on~$Z$. The solution is to define the join~$R \Join S$ as the probability distribution on~$XY$ that is sampled by the following different process: first sample~$r$ from the distribution~$R$, then sample~$s$ from the distribution~$S$ \emph{conditioned} on~$s[Z] = r[Z]$, finally output the tuple~$rs$ which is well-defined since~$s[Z] = r[Z]$. This leads to the expression \begin{equation} (R \Join_{\mathrm{P}} S)(t) := R(t[X])S(t[Y])/S(t[Z]) \label{eqn:prop1} \end{equation} defined for all~$XY$-tuples~$t$, with convention that~$0/0 = 0$. Observe that, by writing~$r := t[X]$,~$s := t[Y]$,~$u := t[Y\setminus Z]$ and~$v := t[Z]$, the factor~$R(t[X])$ in~\eqref{eqn:prop1} is the probability~$R(r)$ of getting~$r$ in a sample from the distribution~$R$, and the factor~$S(t[Y])/S(t[Z])$ is the probability~$S(s)/S(v) = S(uv)/S(v)$ of getting~$s$ in a sample from the distribution~$S$ conditioned on~$s[Z] = v = r[Z]$. Naturally, we could have equally well considered the reverse sampling process that first samples~$s$ from~$S$, and then samples~$r$ from~$R$ \emph{conditioned} on~$r[Z] = s[Z]$. This would lead to the alternative expression \begin{equation} (R \mathbin{{_\mathrm{P}}\!\!\Join} S)(t) := S(t[X])R(t[Y])/R(t[Z]). \label{eqn:prop2} \end{equation} It is clear from the definitions that~$R \Join_{\mathrm{P}} S = S \mathbin{{_\mathrm{P}}\!\!\Join} R$, but for the two proposals to agree we would need to have~$R[Z] = S[Z]$. Luckily, this can actually be seen to hold in case~$R$ and~$S$ are consistent probability distributions since if~$T$ is a~$\mathbb{R}^{\geq 0}$-relation that satisfies~$T[X] = R$ and~$T[Y] = S$, then also~$T[Z] = R[Z] = S[Z]$ by Part~3 of Lemma~\ref{lem:easyfacts1}. It will follow from the lemmas below that in such a case we also have~$(R\Join S)[X] \equiv R$ and~$(R \Join S)[Y] \equiv S$ for both~$\Join = \Join_{\mathrm{P}}$ and~$\Join = \mathbin{{_\mathrm{P}}\!\!\Join}$, which is what we want. It is clear that the expression in~\eqref{eqn:prop1}, in addition to being defined for~$K = \mathbb{R}^{\geq 0}$, could have been defined for any semiring~$K$ that is actually a semifield where a division operation is available. On the other hand, to obtain an expression that works for arbitrary semirings, we need to eliminate the divisions. A natural approach for this would be to multiply the expression in~\eqref{eqn:prop1} by the product~$\prod_{s \in S[Z]'} S(s[Z])$ of all the values that appear in the denominator. This way, the denominator would cancel, yet the resulting~$K$-relation would remain equivalent up to normalization because the multiplying products do not depend on the tuple~$t$. We are now ready to formally define this. \paragraph{Definition of the Join of Two $K$-Relations} For a~$K$-relation~$T(X)$, a subset~$Z \subseteq X$, and a~$Z$-tuple~$u$, define \begin{equation} c^*_{T,Z} := \prod_{v \in T[Z]'} T(v) \;\;\;\text{ and }\;\;\; c_{T}(u) := \prod_{v \in T[Z]': \atop v \not= u} T(v), \label{eqn:cr} \end{equation} with the understanding that the empty product evaluates to~$1$, the unit of the semiring~$K$. Observe that~$c_{T}(u)$ and~$c^*_{T,Z}$ are always non-zero because~$T[Z]'$ is precisely the set of~$Z$-tuples~$v$ with non-zero~$T(v)$, and~$K$ has no zero-divisors. The \emph{join} of two~$K$-relations~$R(X)$ and~$S(Y)$ is the~$K$-relation over~$XY$ defined, for every~$XY$-tuple~$t$, by \begin{equation} (R \Join S)(t) := R(t[X]) S(t[Y]) c_S(t[X \cap Y]). \label{eqn:joinasymmetric} \end{equation} It is worth noting at this point that the identity~$c^*_{T,Z} = c_T(u) T(u)$ holds, which means that whenever~$K$ is a semifield such as~$\mathbb{R}^{\geq 0}$, we have~$c^*_{T,Z}/T(u) = c_T(u)$ for all~$u \in T[Z]'$, and therefore \begin{equation} R \Join S = c^*_{S[Z]} (R \Join_{\mathrm{P}} S), \label{eqn:coincides} \end{equation} where $\Join_{\mathrm{P}}$ is defined as in~\eqref{eqn:prop1}. Note that, for ordinary relations, the join operation just introduced coincides with the (ordinary) join operation in relational databases. Note also that the definition of~$\Join$ is asymmetric. Thus, on the face of its definition, the join of two~$K$-relations need not be commutative, i.e., there may be $K$-relations $R$ and $S$ such that $R\Join S \not = S\Join R$. As a matter of fact, something stronger holds: in general, $R\Join S \not \equiv S\Join R$; furthermore, as we shall see next, this happens even for bags. Nonetheless, we will show later that~$R \Join S \equiv S \Join R$ does hold in case~$R$ and~$S$ agree on their common marginals; moreover, in that case, both joins $R\Join S$ and $S\Join R$ witness the consistency of $R$ and $S$. The example that follows illustrates the definition of the join and also shows that the join operation need not be commutative, not even up to equivalence. \begin{example} Consider the bags~$R(AB)$ and~$S(BC)$ from Example~\ref{ex:naivejoin}, where they were shown to be consistent using the bag~$U(ABC)$ from the same example. The joins~$V := R \Join S$ and~$W := S \Join R$ defined by~\eqref{eqn:joinasymmetric} are the bags given by the following tables of multiplicities. We display~$V$ and~$W$ alongside their marginals on~$AB$ and~$BC$. \begin{center} \begin{tabular}{lllllllllllllllllllllll} $V(ABC)$\; \# & \; & $W(ABC)$\; \# & \; & $V[AB]$\; \# & \; & $V[BC]$\; \# & \; & $W[AB]$\; \# & \; & $W[BC]$\; \# \\ \;\;\; 1 2 3 : 24 & & \;\;\;\; 1 2 3 : 36 & & \;\;\; 1 2 : 48 & & \;\;\; 2 3 : 24 & & \;\;\;\; 1 2 : 72 & & \;\;\;\; 2 3 : 36 \\ \;\;\; 1 2 4 : 24 & & \;\;\;\; 1 2 4 : 36 & & \;\;\; 2 3 : 24 & & \;\;\; 2 4 : 24 & & \;\;\;\; 2 3 : 36 & & \;\;\;\; 2 4 : 36 \\ \;\;\; 2 3 4 : 24 & & \;\;\;\; 2 3 4 : 36 & & \;\;\; & & \;\;\; 3 4 : 24 & & \;\;\; & & \;\;\;\; 3 4 : 36 \end{tabular} \end{center} For example, the entry~$V(234)$ is computed as~$3\!\cdot\!2\!\cdot\!(2\!+\!2) = 24$ according to the expression~\eqref{eqn:joinasymmetric} that defines the join operation. By inspection, we have that~$8R=V[AB]$ and~$12S=V[BC]$, so~$V$ witnesses the consistency of~$R$ and~$S$, and~$24R = W[AB]$ and~$18S = W[BC]$, so~$W$ also witnesses the consistency of~$R$ and~$S$. Indeed,~$3V = 2W$, which shows that $R\Join S \equiv S\Join R$ holds for these two bags $R$ and $S$. Next, we use the bag~$R$ and another bag~$T$ to show that~$\Join$ need not be commutative, not even up to equivalence. Consider the bag~$T(BC)$ given below by its table of multiplicities together with~$J_1 = R \Join T$ and~$J_2 = T \Join R$: \begin{center} \begin{tabular}{lllllllllllllllllllllll} $T(BC)$\, \# & \; & $J_1(ABC)$\; \# & \; & $J_2(ABC)$\; \# \\ \;\;\;\, 2 3 : 2 & & \;\;\;\; 1 2 3 : 48 & & \;\;\;\; 1 2 3 : 36 \\ \;\;\;\, 2 4 : 2 & & \;\;\;\; 1 2 4 : 48 & & \;\;\;\; 1 2 4 : 36 \\ \;\;\;\, 3 4 : 4 & & \;\;\;\; 2 3 4 : 48 & & \;\;\;\; 2 3 4 : 72 \end{tabular} \end{center} Clearly, there are no non-zero~$a$ and~$b$ in~$\mathbb{N}$ such that~$a J_1 = b J_2$, thus~$R \Join T \not\equiv T \Join R$. Note that the pair of~$K$-relations~$R$ and~$T$ that gave this has~$R[B] \not\equiv T[B]$. This is no coincidence, since, in what follows, we will show that if the two~$K$-relations have equivalent common marginals, then their join is commutative up to equivalence. This was the case, for example, for the pair of bags~$R$ and~$S$ considered also in this example, which had~$R[B] \equiv S[B]$ and~$R \Join S \equiv S \Join R$. \end{example} \paragraph{Properties of the Join Operation} The first property we show about the join of two~$K$-relations is that it is well-defined in the sense that its equivalence class does not depend on the representatives. In other words, we show that the join operation $\Join$ is a congruence with respect to the equivalence relation $\equiv$ on $K$-relations. \begin{lemma} Let $R, R_0$ be two $K$-relations over a set $X$ and let~$S, S_0$ be two $K$-relations over a set $Y$. If~$R \equiv R_0$ and~$S \equiv S_0$, then~$R \Join S \equiv R_0 \Join S_0$. \end{lemma} \begin{proof} Let~$X$ be the set of attributes of~$R$ and~$R_0$, and let~$Y$ be that of~$S$ and~$S_0$. Write~$Z = X \cap Y$. Let~$a$ and~$b$ be non-zero elements in~$K$ such that~$a R = b R_0$, and let~$c$ and~$d$ be non-zero elements in~$K$ such that~$c S = d S_0$. First note that~$R[Z]' = R_0[Z]'$ by Parts~3 and~2 in Lemma~\ref{lem:easyfacts2}. Let~$m$ be the cardinality of~$R[Z]' = R_0[Z]'$ and set~$a^* = a c^m$ and~$b^* = b d^m$. We argue that~$a^* (R \Join S)(t) = b^* (R_0 \Join S_0)(t)$ for every~$XY$-tuple~$t$. Fix an~$XY$-tuple~$t$ and distinguish the cases~$t[Z] \not\in R[Z]'$ from~$t[Z] \in R[Z]'$. In the first case, we have~$R(t[Z])=0$ and hence~$R(t[X]) = 0$ by Part~2 in Lemma~\ref{lem:easyfacts1}, so~$R_0(t[X]) = 0$ by Part~2 in Lemma~\ref{lem:easyfacts2}. It follows that~$(R \Join S)(t) = (R_0 \Join S_0)(t) = 0$ in this case. In the second case, we have~$m \geq 1$ and \begin{align} a^* (R\Join S)(t) = a R(t[X]) \cdot c S(t[Y]) \cdot \prod_{r \in R[Z]' : \atop r \not= t[Z]} c S(r) \label{eqn:onehand} \end{align} on one hand since $a^* = acc^{m-1}$, and \begin{align} b^* (R_0 \Join S_0)(t) = b R_0(t[X]) \cdot d S_0(t[Y]) \cdot \prod_{r \in R_0[Z]': \atop r \not= t[Z]} d S_0(r), \label{eqn:theother} \end{align} on the other since~$b^* = bdd^{m-1}$. The right-hand sides of~\eqref{eqn:onehand}~and~\eqref{eqn:theother} are equal by~$a R = b R_0$ and~$c S = d S_0$, and~$R[Z]'=R_0[Z]'$, so the lemma is proved. \end{proof} Next, we show that the support of the join is the ordinary join of the supports. \begin{lemma} \label{lem:supportsjoin} For all $K$-relations $R$ and $S$, we have that $(R \Join S)' = R' \Join S'$. \end{lemma} \begin{proof} Let~$X$ be the set of attributes of~$R$, and let~$Y$ be that of~$S$. Write~$Z = X \cap Y$ and~$T = R \Join S$. Fix an~$XY$-tuple~$t$. If~$t$ is in~$T'$, then~$T(t) \not= 0$ and in particular~$R(t[X]) \not= 0$ and~$S(t[Y]) \not= 0$ by~\eqref{eqn:joinasymmetric}. It follows that~$t[X]$ is in~$R'$ and~$t[Y]$ is in~$S'$; i.e.,~$t$ is in the relational join of~$R'$ and~$S'$. Conversely, if~$T(t) = 0$, then by~\eqref{eqn:joinasymmetric} again either~$R(t[X])=0$ or~$S(t[Y])=0$ or~$c_S(t[Z]) = 0$ since~$K$ has no zero-divisors. The third case is absurd: we already argued that~$c_S(t[Z]) \not= 0$ since~$S[Z]'$ is precisely the set of~$Z$-tuples~$v$ with~$S(v) \not= 0$. In the first two cases, we can conclude that either~$t[X]$ is not in~$R'$ or~$t[Y]$ is not in~$S'$, so~$t$ is not in their join. \end{proof} The \emph{left semijoin}~$R' \ltimes S'$ of two ordinary relations~$R'(X)$ and~$S'(Y)$ is the set of~$X$-tuples in~$R'$ that join with some~$Y$-tuple in~$S'$, i.e.,~$R' \ltimes S' = (R' \Join S')[X]$. We use Lemma~\ref{lem:supportsjoin} to show that the asymmetric join behaves like a left semijoin up to equivalence, in a strong sense~(with~$a = 1$). \begin{lemma} \label{lem:semijoinlike} For all $K$-relations $R$ and $S$ and all $r \in R' \ltimes S'$, we have that $(R \Join S)(r) = c^*_S R(r)$. \end{lemma} \begin{proof} Let~$X$ and~$Y$ be the sets of attributes of~$R$ and~$S$, respectively, and write~$Z = X \cap Y$ and~$T = R \Join S$. Fix an~$X$-tuple~$r \in R' \ltimes S'$ and write~$u = r[Z]$. We have \begin{equation} T(r) = \sum_{t \in T': \atop t[X]=r} T(t) = \sum_{t \in T':\atop t[X]=r} R(t[X])S(t[Y]) c_S(t[Z]) = c_S(u) R(r) \sum_{t \in T': \atop t[X]=r} S(t[Y]), \label{eqn:firsthah} \end{equation} where the first equality follows from~\eqref{eqn:marginal}, the second follows from~\eqref{eqn:joinasymmetric}, and the third follows from the condition that~$t[X]=r$ because~$Z \subseteq X$ implies~$t[Z]=t[X][Z]=r[Z]=u$. At this point, we use the fact that~$r \in R' \ltimes S'$ and hence~$r \in R'$, together with Lemma~\ref{lem:supportsjoin}, to argue that the map \begin{align} f : & \{ t \in T' : t[X] = r \} \rightarrow \{ s \in S' : s[Z] = u \} :: t \mapsto t[Y] \label{eqn:bijectionh} \end{align} is a bijection. Indeed, since by Lemma~\ref{lem:supportsjoin} each~$t \in T'$ comes from the relational join of~$R'$ and~$S'$, for each~$t \in T'$ such that~$t[X]=r$ there exists~$s \in S'$ with~$t[Y]=s$ and~$s[Z]=t[Y][Z]=t[Z]=t[X][Z]=r[Z]=u$. Clearly this~$s=t[Y]$ is uniquely determined from~$t$. Conversely, if~$s \in S'$ is such that~$s[Z]=u=r[Z]$, then the join tuple~$t$ of~$r$ and~$s$ exists, it is in~$T'$ by Lemma~\ref{lem:supportsjoin} and the fact that~$r \in R'$, and moreover~$t[X] = r$. This~$t$ is uniquely determined from~$s$ (and the fixed~$r$). This proves that~\eqref{eqn:bijectionh} is a bijection. Therefore, continuing from~\eqref{eqn:firsthah}, we have \begin{equation} c_S(u) R(r) \sum_{t \in T': \atop t[X]=r} S(t[Y]) = c_S(u) R(r) \sum_{s \in S': \atop s[Z]=u} S(s) = c_S(u) R(r) S(u). \label{eqn:last} \end{equation} where the first equality follows from the just shown fact that~\eqref{eqn:bijectionh} is a bijection, and the second follows from~\eqref{eqn:marginal}. Recall now that~$u = r[Z]$ and~$r \in R' \ltimes S'$, which means that~$u \in (R' \Join S')[Z]$. In particular,~$u \in S'[Z]$, so~$u \in S[Z]'$ by Part~2 of Lemma~\ref{lem:easyfacts1}. Thus, by~\eqref{eqn:cr}, we have ~$c^*_S = c_S(u) S(u)$, and equations~\eqref{eqn:firsthah} and~\eqref{eqn:last} actually show that~$T(r) = c^*_S R(r)$. \end{proof} Next we show that if two~$K$-relations are consistent in the sense that their marginals on the common attributes are equivalent, then their join commutes up to equivalence. Later we will use this to argue that this sense of consistency in terms of marginals is equivalent to the one defined earlier in this section, and thus that if two~$K$-relations are consistent, then their join commutes up to equivalence. \begin{lemma} \label{lem:commutativeifconsistent} For all~$K$-relations~$R(X)$ and~$S(Y)$, if~$R[X \cap Y] \equiv S[X \cap Y]$, then~$\Join$ commutes on~$R$ and~$S$ up to equivalence, i.e.,~$R \Join S \equiv S \Join R$. \end{lemma} \begin{proof} Write~$Z = X \cap Y$. Let~$a$ and~$b$ be non-zero and such that~$a R[Z]= b S[Z]$. First note that~$R[Z]' = S[Z]'$ by Part~3 and~2 of Lemma~\ref{lem:easyfacts2}. Let~$m$ be the cardinality of $R[Z]' = S[Z]'$. If~$m = 0$, then~$(R \Join S)(t) = R(t[X])S(t[Y]) = S(t[Y])R(t[X]) = (S \Join R)(t)$ for every~$XY$-tuple~$t$, and we are done. Assume then that~$m \geq 1$ and set~$a^* = a^{m-1}$ and~$b^* = b^{m-1}$. We argue that~$b^* (R \Join S)(t) = a^* (S \Join R)(t)$ for every~$XY$-tuple~$t$. Fix an~$XY$-tuple~$t$ and distinguish the cases~$t[Z] \not\in S[Z]'$ from~$t[Z] \in S[Z]'$. In the first case we have~$S(t[Y]) = 0$ by Part~2 of Lemma~\ref{lem:easyfacts1} and it follows that~$b^* (R \Join S)(t) = 0 = a^* (S \Join R)(t)$ in this case. In the second case we have \begin{equation} b^* (R \Join S)(t) = R(t[X])S(t[Y])\prod_{s \in S[Z]': \atop s\not=t[Z]} b S(r) \label{eqn:onehandn} \end{equation} on one hand since $b^* = b^{m-1}$ and $t[Z] \in S[Z]'$, and \begin{equation} a^* (S \Join R)(t) = S(t[Y])R(t[X])\prod_{r \in R[Z]': \atop r\not=t[Z]} a R(r) \label{eqn:otherhandn} \end{equation} on the other since~$a^* = a^{m-1}$ and~$t[Z] \in S[Z]'=R[Z]'$. Now, given hat~$aR(r) = bS(r)$ for every~$Z$-tuple~$r$, the right-hand sides of~\eqref{eqn:onehandn} and~\eqref{eqn:otherhandn} are equal, and the lemma is proved. \end{proof} We are ready to show that the join witnesses the consistency of any two consistent~$K$-relations. Along the way, we also prove that two~$K$-relations are consistent if and only if their marginals on the common attributes are equivalent. This result tells that the join operation on two $K$-relations introduced here possesses most of the desirable properties that the join of ordinary relations in relational databases does. \begin{lemma} \label{lem:characterization} Let~$R(X)$ and~$S(Y)$ be~$K$-relations. The following statements are equivalent: \begin{enumerate} \itemsep=0pt \item[(a)] $R$ and $S$ are consistent. \item[(b)] $R[X \cap Y] \equiv S[X \cap Y]$. \item[(c)] $R'$ and $S'$ are consistent and $R \Join S \equiv S \Join R$. \item[(d)] $R \equiv (R \Join S)[X]$ and $S \equiv (R \Join S)[Y]$. \end{enumerate} \end{lemma} \begin{proof} Write~$Z = X \cap Y$. For~(a) implies~(b), let~$T$ witness that~$R$ and~$S$ are consistent, so~$R \equiv T[X]$ and~$S \equiv T[Y]$. Then, by Part~3 of Lemma~\ref{lem:easyfacts2}, we have~$R[Z] \equiv T[X][Z]$ and~$S[Z] \equiv T[Y][Z]$. Since by Part~3 of Lemma~\ref{lem:easyfacts1} we also have~$T[X][Z] = T[Z] = T[Y][Z]$, we get~$R[Z] \equiv S[Z]$, as was to be shown. For~(b) implies~(c) first apply Part~2 of Lemma~\ref{lem:easyfacts1} followed by Part~2 of Lemma~\ref{lem:easyfacts2} to conclude that~$R'[X \cap Y] = S'[X \cap Y]$ and hence that~$R'$ and~$S'$ are consistent as ordinary relations. By Lemma~\ref{lem:commutativeifconsistent} we also have~$R \Join S \equiv S \Join R$. For~(c) implies~(d) first note that the consistency of~$R'$ and~$S'$ implies that~$R' = R' \ltimes S'$ and~$S' = S' \ltimes R'$. Thus, Lemma~\ref{lem:semijoinlike} gives~$R \equiv (R \Join S)[X]$ and~$S \equiv (S \Join R)[Y]$. Together with the assumption that~$R \Join S \equiv S \Join R$ this also gives~$S \equiv (R \Join S)[Y]$ by Part~3 of Lemma~\ref{lem:easyfacts2}. That~(d) implies~(a) is direct since~(d) says that~$R \Join S$ witnesses the consistency of~$R$ and~$S$. \end{proof} \subsection{Justification of the Join of Two $K$-Relations} In this section, we address the question whether the join operation on two relations that we defined in Section~\ref{sec:tworelations} is well motivated. For the rest of this section, fix a finite set of attributes and let~$\tuples$ denote the set of all tuples over these attributes, which we assume is a computable set through the appropriate encodings. We also assume that the positive semiring~$K$ is a computable structure in the sense that the elements of its domain admit a computable presentation that makes its operations be computable functions. The bag semiring~$\mathbb{N}$, as well as the semiring~$\mathbb{Q}^{\geq 0}$ of non-negative rationals and many others, are of course computable in this sense. Furthermore, we require the equivalence relation~$\equiv$ to be decidable; in other words, we require that the following computational problem is decidable: \begin{center} \emph{Given two~$K$-relations~$R$ and~$S$ over the same set, does~$R \equiv S$ hold?} \end{center} We note that for the bag semiring~$\mathbb{N}$, as well as for the semiring~$\mathbb{Q}^{\geq 0}$ of non-negative rationals, this problem is very easily decidable, even polynomial-time solvable through what we call the \emph{ratio test}: first, check whether~$R' = S'$, and then check whether~$R(t_1)/S(t_1) = R(t_2)/S(t_2)$ holds for every two tuples~$t_1$ and~$t_2$ in~$R' = S'$. \paragraph{Deciding Consistency Despite the Plethora of Witnesses} Let~$R$ and~$S$ denote two~$K$-relations on the sets of attributes~$X$ and~$Y$ and consider the following computational problem: \begin{center} \emph{Given two~$K$-relations~$R$ and~$S$, are~$R$ and~$S$ consistent?} \end{center} For an infinite positive semiring~$K$, such as the bag semiring~$\mathbb{N}$, there is no immediate and a priori reason to think that this problem is algorithmically solvable. The difficulty is that in principle there are infinitely many candidate~$K$-relations to test as witness for consistency, and the arithmetic theory of the natural numbers is highly undecidable. However, what Lemma~\ref{lem:characterization} shows is that the two given~$K$-relations~$R$ and~$S$ are consistent if and only if~the single, finite and explicitly defined~$K$-relation~given by~$R \Join S$ witnesses their consistency. Thus, if~$K$ is a semiring for which the equivalence relation~$\equiv$ is decidable, this can be checked in finite time and the problem is decidable. In the next example, we show that, even for bags, the consistency of two bags may very well be witnessed by infinitely many pairwise inequivalent witnesses. \begin{example} Let~$a$ be a positive integer and let~$R(AB)$,~$S(BC)$ and~$T_a(ABC)$ be the three bags given by the following multiplicity tables, listed alongside the two projections of~$T_a$ on~$AB$ and~$BC$: \begin{center} \begin{tabular}{lllllllllllllllllll} $R(AB)$\, \# & \; & $S(BC)$ \# & \; & $T_a(ABC)$\, \# & \; & $T_a[AB]$\, \# & \; & $T_a[BC]$\, \# \\ \;\;\;\, 0 0 : 1 & & \;\;\; 0 0 : 1 & & \;\;\;\; 0 0 0 : $a$ & & \;\;\;\; 0 0 : $a+1$ & & \;\;\;\; 0 0 : $a+1$ \\ \;\;\;\, 1 0 : 1 & & \;\;\; 0 1 : 1 & & \;\;\;\; 0 0 1 : 1 & & \;\;\;\; 1 0 : $a+1$ & & \;\;\;\; 0 1 : $a+1$ \\ \;\;\;\, & & \;\;\; & & \;\;\;\; 1 0 0 : 1 & & \;\;\;\; & & \;\;\;\; \\ \;\;\;\, & & \;\;\; & & \;\;\;\; 1 0 1 : $a$ & & \;\;\;\; & & \;\;\;\; \end{tabular} \end{center} It is evident that~$T_a[AB] = (a+1)R$ and~$T_a[BC] = (a+1)S$, but~$T_a \not\equiv T_b$ unless~$a = b$. The conclusion is that there are infinitely many different equivalence classes that witness the consistency of~$R$ and~$S$. \end{example} \paragraph{Entropy Maximization} Let us turn our attention again to probability distributions. The canonical representatives of the equivalence classes are the~$\mathbb{R}^{\geq 0}$-relations~$T$ that satisfy~\eqref{eqn:normalizationequation}. We argued already that for such canonical~$\mathbb{R}^{\geq 0}$-relations we have that~$\equiv$ agrees with~$=$. Therefore, the set of canonical~$\mathbb{R}^{\geq 0}$-relations~$T$ that witness the consistency of two given probability distributions~$R(X)$ and~$S(Y)$ can be identified with the set of feasible solutions of a linear program that has one real variable~$x_t$ representing~$T(t)$ for each~$XY$-tuple~$t$ in the join of the supports of~$R$ and~$S$: \begin{equation} \begin{array}{lll} \sum_{t: t[X] = r} x_t = R(r) & \;\;\; & \text{ for each } r \in R', \\ \sum_{t: t[Y] = s} x_t = S(r) & \;\;\; & \text{ for each } s \in S', \\ \sum_{t} x_t = 1 & & \\ x_t \geq 0 & & \text{ for each } t \in R' \Join S'. \\ \end{array} \label{eqn:linearprogram} \end{equation} The set of probability distributions~$P(XY)$ that witness the consistency of~$R$ and~$S$ is thus a polytope~$\mathrm{W}(R,S)$ which is non-empty if and only if~$R$ and~$S$ are consistent. A natural question to ask is whether there is some particular probability distribution in this polytope that is better motivated than any other such probability distribution. For example, following the principle of maximum entropy, we could ask for the probability distribution that maximizes \emph{Shannon's Entropy} (see section~2.1. in~\cite{CoverThomas}) among those that witness the consistency, i.e., we want to maximize \begin{equation} \Entropy_P(XY) = -\sum_{xy \in P(XY)'} P(xy) \log_2(P(xy)) \label{eqn:entropy} \end{equation} subject to the constraint that $P$ is in $\mathrm{W}(R,S)$. Since the entropy is a concave function over the probability simplex (Theorem~2.7.3 in~\cite{CoverThomas}), and since~$\mathrm{W}(R,S)$ is a bounded polytope and hence a compact subset of~$\mathbb{R}^n$ in appropriate dimension~$n$ (unless it is empty), the maximum of~\eqref{eqn:entropy} exists and is achieved at a unique point in~$\mathrm{W}(R,S)$. In our setting, writing~$Z = X \cap Y$, it is perhaps more natural to maximize the \emph{conditional entropy}, i.e., \begin{equation} \Entropy_P(XY|Z) := -\sum_{z \in P(Z)'} P(z) \sum_{xy \in P(XY)'} P(xy|z) \log_2(P(xy|z)), \label{eqn:conditionalentropy} \end{equation} where $P(xy|z) := 0$ if $(xy)[Z] \not= z$ or $P(z) = 0$, and $P(xy|z) := P(xy)/P(z)$ otherwise, with the added convention that $0\log_2(0) = 0$. For being a convex combination of concave functions over the probability simplex, the conditional entropy~$\Entropy_P(XY| Z)$ is again a concave function of~$P$ ranging over~$\mathrm{W}(R,S)$, which means that the maximum also exists and is achieved at a unique point in~$\mathrm{W}(R,S)$. We write~$R \Join_{\mathrm{H}} S$ for the unique probability distribution in~$\mathrm{W}(R,S)$ that achieves the maximum of~\eqref{eqn:entropy} and we write~$R \Join_{\mathrm{CH}} S$ for the one that achieves the maximum of~\eqref{eqn:conditionalentropy}. Note that, a priori, due to the logarithms in the definition of entropy, the probability distributions~$R \Join_{\mathrm{H}} S$ and~$R \Join_{\mathrm{CH}} S$ need not even have rational components. Interestingly, as will follow from the development below, our join operation~$\Join$ applied to consistent probability distributions coincides with both~$\Join_{\mathrm{H}}$ and~$\Join_{\mathrm{CH}}$, up to the equivalence, which means that both~$R \Join_{\mathrm{H}} S$ and~$R \Join_{\mathrm{CH}} S$ \emph{are} indeed rational probability distributions in case~$R$ and~$S$ are themselves rational. We argued already in~\eqref{eqn:coincides} that, for probability distributions~$R$ and~$S$, our join~$R \Join S$ coincides with~$R \Join_{\mathrm{P}} S$ up to equivalence. Moreover, if~$R$ and~$S$ are consistent, then we have~$R[Z]=S[Z]$ for~$Z := X \cap Y$, which means that if we write~$r := t[X]$,~$s := t[Y]$,~$u := t[Z]$, and~$U := R[Z]=S[Z]$, then \begin{equation} (R \Join_{\mathrm{P}} S)(t) = R(r)S(s)/U(u). \label{eqn:identity} \end{equation} This identity implies that~$R \Join_{\mathrm{P}} S$ is a \emph{product extension} of~$R$ and~$S$ in the sense of Malvestuto~\cite{DBLP:journals/dm/Malvestuto88} (see the first paragraph of page~73 in \cite{DBLP:journals/dm/Malvestuto88}), hence~$R \Join_{\mathrm{P}} S$ maximizes entropy as a consequence of Malvestuto's Theorem~8. We reproduce his short proof for completeness. \begin{lemma}[\cite{DBLP:journals/dm/Malvestuto88}] \label{lem:maximizesentropy} If~$R$ and~$S$ are consistent probability distributions, then ~$R \Join_{\mathrm{P}} S = R \Join_{\mathrm{H}} S$. \end{lemma} \begin{proof} Let~$X$ and~$Y$ be the sets of attributes of~$R$ and~$S$, write~$Z = X \cap Y$, and assume that~$R$ and~$S$ are consistent. Let~$U := R[Z] = S[Z]$, where the equality follows from the assumption that~$R$ and~$S$ are probability distributions that are consistent. Write~$P := R \Join_{\mathrm{H}} S$ and~$Q := R \Join_{\mathrm{P}} S$. By~\eqref{eqn:coincides} we have~$Q \equiv R \Join S$, so~$Q$ witnesses the consistency of~$R$ and~$S$ by Lemma~\ref{lem:characterization}. Moreover, by design,~$Q$ is a probability distribution, and so are~$R$ and~$S$ by assumption, so~$Q[Z] = R[Z] = S[Z] = U$. Since~$P$ is also a feasible solution of~\eqref{eqn:linearprogram}, also~$P$ is a probability distribution that witnesses the consistency of~$R$ and~$S$, so~$P[Z] = R[Z] = S[Z] = U$. The conclusion of these is that \begin{align} & P[Z] = Q[Z] = U, \label{eqn:marginalurs1} \\ & P[X] = Q[X] = R, \label{eqn:marginalurs2} \\ & P[Y] = Q[Y] = S. \label{eqn:marginalurs3} \end{align} In particular~$\Entropy_P(XY) \geq \Entropy_Q(XY)$ since~$P$ maximizes~\eqref{eqn:entropy}. We show that~$\Entropy_P(XY) \leq \Entropy_Q(XY)$, from which it will follow that~$P = Q$ since we argued already that the maximum of~\eqref{eqn:entropy} is unique. Let~$\KL(P||Q)$ denote the Kullback-Leibler divergence (see Section~2.3 in~\cite{CoverThomas}) between two probability distributions~$P(X)$ and~$Q(X)$ over the same set of attributes~$X$, which is defined as \begin{equation} \KL(P||Q) := \sum_{x \in P'} P(x)\log(P(x)/Q(x)), \end{equation} with the conventions that~$0\log(0/q)=0$ and~$p\log(p/0) = \infty$. The Information Inequality (Theorem~2.6.3 in~\cite{CoverThomas}) states that~$\KL(P||Q) \geq 0$. Therefore \begin{align} \Entropy_P(XY) & = -\sum_{t \in P'} P(t) \log(P(t)) \leq -\sum_{t \in P'} P(t) \log(Q(t)). \label{eqn:step1} \end{align} Using~\eqref{eqn:identity}, the right-hand side of~\eqref{eqn:step1} equals \begin{equation} \sum_{t \in P'} P(t) \log(U(t[Z]))) -\sum_{t \in P'} P(t)\log(R(t[X])) - \sum_{t \in P'} P(t) \log(S(t[Y])) \label{eqn:threeway} \end{equation} Splitting the set of tuples $t$ in $P'$ by $t[Z]$, the first term in~\eqref{eqn:threeway} rewrites into \begin{align} \sum_{u \in U'} \sum_{t \in P' : \atop t[Z]=u} P(t) \log(U(u)) = \sum_{u \in U'} \log(U(u)) P(u) = \sum_{u \in U'} \log(U(u)) Q(u) \label{eqn:turu1} \end{align} where the first equality follows from~\eqref{eqn:marginal}, and the second follows from~\eqref{eqn:marginalurs1}. Exactly the same argument for the second and third terms in~\eqref{eqn:threeway}, and applying~\eqref{eqn:marginal} to $Q(u)$, $Q(r)$, and $Q(s)$, rewrites~\eqref{eqn:threeway} into \begin{equation} \sum_{t \in Q'} Q(t) \log(U(t[Z]))) - \sum_{t \in Q'} Q(t)\log(R(t[X])) - \sum_{t \in Q'} Q(t) \log(S(t[Y])) \label{eqn:threeway2} \end{equation} and therefore, by~\eqref{eqn:identity}, into \begin{equation} -\sum_{t \in P'} Q(t) \log(Q(t)) = \Entropy_Q(XY). \label{eqn:stepfinal} \end{equation} Combining~\eqref{eqn:step1},~\eqref{eqn:threeway},~\eqref{eqn:threeway2}, and~\eqref{eqn:stepfinal} we get $\Entropy_P(XY) \leq \Entropy_Q(XY)$ as was to be shown. \end{proof} Next, we show that~$\Join_{\mathrm{P}}$ also maximizes conditional entropy; it follows that~$R \Join_{\mathrm{CH}} S = R \Join_{\mathrm{H}} S$. \begin{lemma} \label{lem:maximizesconditionalentropy} If~$R$ and~$S$ are two consistent probability distributions, then~ $R \Join_{\mathrm{P}} S = R \Join_{\mathrm{CH}} S$. \end{lemma} \begin{proof} Let~$X$ and~$Y$ be the sets of attributes of~$R$ and~$S$, write~$Z = X \cap Y$, and assume that~$R$ and~$S$ are consistent. Let~$U := R[Z] = S[Z]$, where the equality follows from the assumption that~$R$ and~$S$ are probability distributions that are consistent. Write~$P := R \Join_{\mathrm{CH}} S$ and~$Q := R \Join_{\mathrm{P}} S$. By~\eqref{eqn:coincides} we have~$Q \equiv R \Join S$, so~$Q$ witnesses the consistency of~$R$ and~$S$ by Lemma~\ref{lem:characterization}. Moreover, by design,~$Q$ is a probability distribution, and so are~$R$ and~$S$ by assumption, hence~$Q[Z] = R[Z] = S[Z] = U$. Since~$P$ is also a feasible solution of~\eqref{eqn:linearprogram}, also~$P$ is a probability distribution that witnesses the consistency of~$R$ and~$S$, hence~$P[Z] = R[Z] = S[Z] = U$. The conclusion of these is that~$P[Z] = Q[Z] = U$ and both~$P$ and~$Q$ are feasible solutions of~\eqref{eqn:linearprogram}. In particular, $\Entropy_P(XY|Z) \geq \Entropy_Q(XY|Z)$ since~$P$ maximizes~\eqref{eqn:conditionalentropy}. We show that~$\Entropy_P(XY|Z) \leq \Entropy_Q(XY|Z)$, from which it will follow that~$P = Q$ since we argued already that the maximum of~\eqref{eqn:entropy} is unique. We introduce a piece of notation. Let~$X_0 := X\setminus Z$ and~$Y_0 := Y\setminus Z$. For each~$Z$-tuple~$u \in U'$ we write~$P_u$ and~$Q_u$ to denote the probability distributions over~$X_0Y_0$ defined by~$P_z(w) := P(wu)/P(u)$ and~$Q_z(w) := Q(wu)/Q(u)$ for every~$X_0Y_0$-tuple~$w$. Using the obvious fact that if~$D(X)$ is a probability distribution over~$X$ and~$Z \subseteq Y \subseteq X$ then~$\Entropy_D(Z) = \Entropy_{D(Y)}(Z)$, we have \begin{align} & \Entropy_P(XY|Z) = \textstyle{\sum_{u \in U'} U(u) \Entropy_{P_u(X_0Y_0)}(X_0Y_0)}, \\ & \Entropy_Q(XY|Z) = \textstyle{\sum_{u \in U'} U(u) \Entropy_{Q_u(X_0Y_0)}(X_0Y_0)}. \end{align} Thus, to prove that~$\Entropy_P(XY|Z) \leq \Entropy_Q(XY|Z)$ it suffices to show that~$\Entropy_{P_u}(X_0Y_0) \leq \Entropy_{Q_u}(X_0Y_0)$ for each~$u \in U'$. Now note that for every~$X_0$-tuple~$r_0$ and every~$Y_0$-tuple~$s_0$, and every~$u \in U'$, we have \begin{align} Q_u(r_0s_0) & = Q(r_0s_0u)/Q(u) = R(r_0u)S(s_0u)/U(u)^2 = R_u(r_0) S_u(s_0), \label{eqn:firstthis} \end{align} where the first follows from the definition of~$Q_u$, the second from~\eqref{eqn:identity} and~$Q(u)=U(u)$, and the third follows from setting~$R_u(r_0) := R(r_0u)/R(u)$ and~$S_u(s_0) := S(s_0u)/S(u)$ and the fact that~$R(u)=S(u)=U(u)$. Now recall that~$P[X] = Q[X] = R$, so~$P_u[X_0] = Q_u[X_0] = R_u$ for every~$u \in U'$, and also~$P[Y] = Q[Y] = S$, so~$P_u[Y_0] = Q_u[Y_0] = S_u$ for every~$u \in U'$. The conclusion is that the marginals of~$P_u$ and~$Q_u$ agree, and those of~$Q_u$ are independent by~\eqref{eqn:firstthis}. It follows that \begin{align} \Entropy_{P_u}(X_0Y_0) & \leq \Entropy_{P_u(X_0)}(X_0) + \Entropy_{P_u(Y_0)}(Y_0) \\ & = \Entropy_{Q_u(X_0)}(X_0) + \Entropy_{Q_u(Y_0)}(Y_0) \\ & = \Entropy_{Q_u}(X_0Y_0) \end{align} where the first follows from~$\KL(P_u(X_0Y_0)||P_u(X_0)P_u(Y_0)) \geq 0$ by the Information Inequality (Theorem~2.6.3 in~\cite{CoverThomas}), the second follows from equal marginals, and the third follows from the fact that~$\KL(Q_u(X_0Y_0)||Q_u(X_0)Q_u(Y_0)) \geq 0$ holds with equality if and only if the marginals~$Q_u(X_0)$ and~$Q_u(Y_0)$ are independent (see again Theorem~2.6.3 in~\cite{CoverThomas}), which we argued is the case for~$Q_u$. \end{proof} The following result is an immediate consequence of Lemmas~\ref{lem:maximizesentropy} and~\ref{lem:maximizesconditionalentropy}. \begin{corollary} Let~$R(X)$ and~$S(Y)$ be probability distributions, and let~$Z = X \cap Y$. If~$R$ and~$S$ are consistent, then the probability distributions~$P$ and~$Q$ among those in~$\mathrm{W}(R,S)$ that maximize entropy~$\Entropy_P(XY)$ and conditional entropy~$\Entropy_Q(XY|Z)$ are equal. Moreover, if~$R$ and~$S$ are rational, then~$P$ and~$Q$ are rational. \end{corollary} Summarizing, we have proved that whenever~$R$ and~$S$ are consistent probability distributions we have~$R \Join S \equiv R \Join_{\mathrm{P}} S$ and $R \Join_{\mathrm{P}} S = R \Join_{\mathrm{H}} S = R \Join_{\mathrm{CH}} S$, which we view as evidence that our definition of $\Join$ is well motivated. \paragraph{Lossless Join Decompositions} We provide further justification for the definition of the join of two~$K$-relations by showing that a decomposed~$K$-relation can be reconstructed (up to equivalence) by joining its decomposed parts, under the same hypothesis that makes it possible to reconstruct an ordinary relation by joining its decomposed parts. This justification for the~$\Join$ operation is valid for an arbitrary positive semiring $K$. Let~$U$ be a set of attributes, let~$P$ be an ordinary relation over~$U$, and let~$V,W$ and~$X,Y$ be pairs of subsets of~$U$. We say that~$P$ \emph{satisfies the functional dependency}~$V \rightarrow W$ if whenever two tuples in~$P$ agree on all attributes in~$V$, then they also agree on all attributes in~$W$. The \emph{decomposition of~$P$ along~$X$ and~$Y$} consists of the projections~$R = P[X]$ and~$S= P[Y]$ of~$P$ on the sets~$X$ and~$Y$, respectively. Such a decomposition is said to be a \emph{lossless-join} decomposition if~$P=R \Join S$, that is, the relation~$P$ can be reconstructed by joining the parts~$R = P[X]$ and~$S= P[Y]$ of the decomposition. The following lemma gives a sufficient condition for a decomposition to be a lossless join one. Even though this lemma is standard textbook material, we include a proof for completeness and comparison with what is to follow. \begin{lemma} \label{prop:lossless} Let~$P$ be an ordinary relation that is decomposed along~$X$ and~$Y$. If~$P$ satisfies the functional dependency~$X\cap Y \rightarrow X\setminus Y$ or~$P$ satisfies the functional dependency~$X\cap Y \rightarrow Y \setminus X$, then this decomposition is lossless-join. \end{lemma} \begin{proof} From the definitions, it follows that we always have~$P \subseteq R\Join S$. Assume that~$P$ satisfies the functional dependency~$X\cap Y \rightarrow X\setminus Y$ (the other case is proved using a symmetric argument). We will show that~$R\Join S \subseteq P$. Let~$t$ be a tuple in~$R\Join S$. It follows that~$t[X] \in R = P[X]$ and~$t[Y] \in S = P[Y]$. Therefore, there are tuples~$t_1$ and~$t_2$ in~$P$, such that~$t[X]=t_1[X]$ and~$t[Y] = t_2[Y]$. Since~$P$ satisfies the functional dependency~$X\cap Y \rightarrow X\setminus Y$ and since~$t_1[X\cap Y] = t[X\cap Y] = t_2[X \cap Y]$, we must have that~$t_1[X\setminus Y]= t_2[X\setminus Y]$. Since~$t[X] = t_1[X]$ and~$t[Y] = t_2[Y]$, it follows that~$t = t_2$, hence~$t \in P$; this completes the proof that~$R\Join S \subseteq P$. \end{proof} It is easy to see that there are lossless-join decompositions of relations that satisfy neither the functional dependencies~$X\cap Y \rightarrow X\setminus Y$ nor the functional dependency~$X\cap Y \rightarrow Y \setminus X$. Thus, Lemma~\ref{prop:lossless} is a sufficient, but not necessary, condition for a decomposition to be a lossless join one. The condition, however, is necessary and sufficient for relations over a schema that satisfy a set functional dependencies. To make this statement precise, we recall a basic definition from relational databases. Let~$U$ be a set of attributes, let~$F$ be a set of functional dependencies between subsets of~$U$, and let~$V\rightarrow W$ be a functional dependency. We say that~$F$ \emph{logically implies}~$V\rightarrow W$, denoted~$F\models V\rightarrow W$ if whenever a relation~$R$ satisfies every functional dependency in~$F$, then~$R$ also satisfies~$V\rightarrow W$. The following is a well known result in relational database theory (see,~e.g.,~Theorem~7.5 in~\cite{DBLP:books/cs/Ullman88}). \begin{theorem} \label{lossless-join:thm} Let~$U$ be a set of attributes, let~$F$ be a set of functional dependencies between subsets of~$U$, and let~$X$ and~$Y$ are two subsets of~$U$. Then the following statements are equivalent: \begin{enumerate} \item[(a)] $F\models X\cap Y \rightarrow X\setminus Y$ or~$F\models X\cap Y\rightarrow Y\setminus X$. \item[(b)] For every relation~$R$ over~$U$ that satisfies every functional dependency in~$F$, it holds that if~$R$ is decomposed along~$X$ and~$Y$, then this decomposition is a lossless-join one. \end{enumerate} \end{theorem} Our next result tells that Lemma~\ref{prop:lossless} extends to decompositions of~$K$-relations, where~$K$ is a positive semiring. We first need to extend the notions appropriately. If~$P$ is a~$K$-relation, then the \emph{decomposition of~$P$ along~$X$ and~$Y$} consists of the marginals~$R=P[X]$ and~$S=P[Y]$. We say that the decomposition is \emph{lossless-join} if~$P \equiv R\Join S$, where~$\Join$ is the join operation on~$K$-relations. \begin{lemma} \label{prop:lossless-gen} Let~$P$ be a~$K$-relation that is decomposed along~$X$ and~$Y$. If the support~$P'$ of~$P$ satisfies the functional dependency~$X\cap Y \rightarrow X\setminus Y$ or~$P'$ satisfies the functional dependency~$X\cap Y \rightarrow Y \setminus X$, then this decomposition is lossless-join. \end{lemma} \begin{proof} For concreteness, let us assume that the attributes of~$P$ are~$ABC$ and that~$P$ is decomposed along~$X = AB$ and~$Y = BC$. The proof remains the same in the general case and with only notational changes. We will show that~$P \equiv R \Join S$, where~$R=P[X]$ and~$S = P[Y]$ . In fact, we will show that~$R\Join S = c^*_{S,X\cap Y} P$. By Part~2 of Lemma~\ref{lem:easyfacts1} we have~$R'=P'[X]$ and~$S'=P'[Y]$. In addition, since~$P'$ satisfies the functional dependency~$X \cap Y \rightarrow X \setminus Y$ or the functional dependency~$X \cap Y \rightarrow Y \setminus X$ we have~$P'= R' \Join S'= (R \Join S)'$, where the first equality follows from Lemma~\ref{prop:lossless} and the second from Lemma~\ref{lem:supportsjoin}. Let~$(a,b,c)$ be a tuple in~$(R\Join S)'$, so in particular~$(a,b,c) \in P'$. By the definition of~$R\Join S$, we have that~$(R \Join S)(a,b,c) = R(a,b)S(b,c)c_S(b)$. We now examine the quantities~$R(a,b)$ and~$S(b,c)$ separately, and for that we distinguish by cases. \bigskip \noindent\textit{Case 1}: The ordinary relation~$P'$ satisfies the functional dependency~$X \cap Y \rightarrow X \setminus Y$, which, in this case, amounts to~$B\rightarrow A$. For $R(a,b)$ we have \begin{equation} R(a,b) = \sum_{c':(a,b,c') \in P'} P(a,b,c') = \sum_{a',c':(a',b,c') \in P'} P(a',b,c') = P(b), \label{eqn:hhg11} \end{equation} where the first follows from~$R = P[X]$ and~\eqref{eqn:marginal}, the second follows from the fact that, since~$P'$ satisfies the functional dependency~$B \rightarrow A$, we must have that~$(a',b,c') \in P'$ implies~$a'=a$, and the third follows from~\eqref{eqn:marginal}. For~$S(b,c)$ we have \begin{equation} S(b,c) = \sum_{a':(a',b,c)\in P'}P(a',b,c) = P(a,b,c), \label{eqn:hhg12} \end{equation} where the first follows from~$S = P[Y]$ and~\eqref{eqn:marginal}, and the second follows from the fact that, since~$P'$ satisfies the functional dependency~$B \rightarrow A$ and~$(a,b,c) \in P'$, we must have that~$(a',b,c) \in P'$ holds if and only if~$a' = a$. \bigskip \noindent \textit{Case 2}: The ordinary relation~$P'$ satisfies the functional dependency~$X \cap Y \rightarrow Y \setminus X$, which, in this case, amounts to~$B\rightarrow C$. Using a similar analysis as in the previous case, for~$S(b,c)$ we have that \begin{equation} S(b,c) = \sum_{a':(a',b,c) \in P'} P(a',b,c) = \sum_{a',c':(a',b,c')} P(a',b,c') = P(b), \label{eqn:hhg21} \end{equation} where the first follows from~$S = P[Y]$ and~\eqref{eqn:marginal}, the second follows from the fact that, since~$P'$ satisfies the functional dependency~$B \rightarrow C$, we must have that~$(a',b,c') \in P'$ implies~$c'=c$, and the third follows from~\eqref{eqn:marginal}. For $R(a,b)$ we have \begin{equation} R(a,b) = \sum_{c':(a,b,c') \in P'} P(a,b,c') = P(a,b,c) \label{eqn:hhg22} \end{equation} where the first follows from~$R = P[X]$ and~\eqref{eqn:marginal}, and the second follows from the fact that, since~$P'$ satisfies the functional dependency~$B \rightarrow C$ and~$(a,b,c) \in P'$ we must have that~$(a,b,c') \in P'$ holds if and only if~$c'=c$. In both cases, it follows that \begin{eqnarray} (R \Join S)(a,b,c) = R(a,b)S(b,c)c_S(b) = P(b) P(a,b,c) c_S(b) = c^*_{P,B} P(a,b,c), \end{eqnarray} where the first follows from~\eqref{eqn:joinasymmetric}, the second follows from~\eqref{eqn:hhg11} and~\eqref{eqn:hhg12} in one case, and from~\eqref{eqn:hhg21} and~\eqref{eqn:hhg22} in the other, and the last follows from~$c^*_{P,B} = c_S(b) P(b)$ by \eqref{eqn:cr} since~$b \in P[B]' = P'[B]$ given that~$(a,b,c) \in P'$ and Part~2 of Lemma~\ref{lem:easyfacts1}. This proves that~$R \Join S = c^*_{P,B} P$, which was to be shown. \end{proof} The last result in this section asserts that the preceding Theorem \ref{lossless-join:thm} extends to decompositions of $K$-relations. \begin{proposition} \label{lossless-join-K:thm} Let $K$ be a positive semiring, let $U$ be a set of attributes, let $F$ be a set of functional dependencies between subsets of $U$, and let $X$ and $Y$ be two subsets of $U$. The following statements are equivalent: \begin{enumerate} \itemsep=0pt \item[(a)] $F\models X\cap Y \rightarrow X\setminus Y$ or $F\models X\cap Y\rightarrow Y\setminus X$. \item[(b)] For every $K$-relation $R$ over $U$ whose support $R'$ satisfies every functional dependency in $F$, it holds that if $R$ is decomposed along $X$ and $Y$, then this decomposition is a lossless-join one. \end{enumerate} \end{proposition} \begin{proof} First, assume that~$F\models X\cap Y \rightarrow X\setminus Y$ or~$F\models X\cap Y\rightarrow Y\setminus X$. Let~$R$ be a be a~$K$-relation whose support~$R'$ satisfies every functional dependency in~$F$. Then~$R'$ satisfies the functional dependency~$X \cap Y \rightarrow X \setminus Y$ or~$R'$ satisfies the functional dependency~$X \cap Y \rightarrow Y \setminus X$. By Lemma~\ref{prop:lossless-gen}, the decomposition of~$R$ along~$X$ and~$Y$ is lossless join. Next, assume that for every~$K$-relation~$R$ over~$U$ whose support~$R'$ satisfies every functional dependency in~$F$, it holds that if~$R$ is decomposed along~$X$ and~$Y$, then this decomposition is a lossless-join one. Let~$P$ be an arbitrary ordinary relation over~$U$ that satisfies every functional dependency in~$F$. We will show that if~$P$ is decomposed along~$X$ and~$Y$, then the decomposition is a lossless join one, hence, by Theorem \ref{lossless-join:thm}, we have that~$F\models X\cap Y \rightarrow X\setminus Y$ or~$F\models X\cap Y\rightarrow Y\setminus X$. Turn~$P$ into a~$K$-relation~$R$ whose support is~$P$ and where all tuples in the support have value~$1$ in~$K$. In other words, consider the~$K$-relation~$R$ such that for every tuple~$t$, we have that~$R(t)=1$ if~$t \in P$, and~$R(t) = 0$ if~$t\not \in P$. By hypothesis, the decomposition of~$R$ along~$X$ and~$Y$ is a lossless join one. Therefore,~$R \equiv R[X] \Join R[Y]$, as~$K$-relations. By Lemma~\ref{lem:supportsjoin} and Part~2 of Lemma~\ref{lem:easyfacts2}, we have that~$R' = R[X]' \Join R[Y]'$, i.e., the support of the join is the join of the supports as ordinary relations. From the definition of~$R$, we have that~$R'=P$; moreover, from Part~2 of Lemma \ref{lem:easyfacts1}, we have that~$R[X]'= R'[X]$ and~$R[Y]'= R'[Y]$. Since~$R'[X] = P[X]$ and~$R'[Y]= P[Y]$, we conclude that~$P = P[X]\Join P[Y]$, thus the decomposition of~$P$ along~$X$ and~$Y$ is a lossless join one, which was to be shown. \end{proof} \section{Consistency of Three or More $K$-Relations} \label{sec:cons-more-than-two} While the definition of consistency of two~$K$-relations has a straightforward generalization to the case of three or more~$K$-relations, not all the related concepts will go through: the join of three or more~$K$-relations will be particularly problematic. We start with the definitions. Let~$K$ be a positive semiring and let~$R_1(X_1),\ldots,R_m(X_m)$ be~$K$-relations. We say that the collection~$R_1,\ldots,R_m$ is \emph{globally consistent} if there is a~$K$-relation~$T$ over~$X_1 \cup \cdots \cup X_m$ such that~$R_i \equiv T[X_i]$ for all~$i \in [m]$. We say that such a~$K$-relation \emph{witnesses} the global consistency of~$R_1,\ldots,R_m$. The equivalence classes~$[R_1],\ldots,[R_m]$ are called \emph{globally consistent} if their representatives~$R_1,\ldots,R_m$ are globally consistent. As in the case of two equivalence classes, it is easy to see using transitivity of~$\equiv$ that this notion is well-defined in that it does not depend on the chosen representatives. We also say that the relations~$R_1,\ldots,R_m$ are \emph{pairwise consistent} if for every~$i,j \in [m]$ we have that~$R_i[X_i]$ and~$R_j[X_j]$ are consistent. From the definitions, it follows that if~$R_1,\ldots,R_m$ are globally consistent, then they are also pairwise consistent. The converse, however, need not be true, in general. In fact, the converse fails even for ordinary relations, that is, for~$\mathbb{B}$-relations, where~$\mathbb{B}$ is the Boolean semiring. For example, it is easy to see that the ordinary relations~$R(AB) = \{00, 11\}$,~$S(BC) = \{01, 10\}$,~$T(AC)= \{00,11\}$ are pairwise consistent but not globally consistent. In the context of relational databases, there has been an extensive study of global consistency for ordinary relations. We present an overview of some of the main findings next. \subsection{Global Consistency in the Boolean Semiring} \label{subsec:cons-boole} For this section~$K$ is the Boolean semiring~$\mathbb{B}$ and therefore~$K$-relations are ordinary relations or, simply, \emph{relations}. Let~$R_1,\ldots, R_m$ be a collection of relations. The \emph{relational join} or, simply, the~\emph{join} of~$R_1,\dots,R_m$ is the relation~$R_1\Join \cdots \Join R_m$ consisting of all~$(X_1\cup \cdots \cup X_m)$-tuples~$t$ such that~$t[X_i]$ belongs to~$R_i$ for all~$i = 1,\ldots,m$. The following facts are well known and easy to prove (e.g., see \cite{DBLP:journals/ipl/HoneymanLY80}): \begin{itemize} \itemsep=0pt \item If $T$ is a relation witnessing the global consistency of $R_1,\ldots,R_m$, then $T \subseteq R_1\Join \cdots \Join R_m$. \item The collection~$R_1,\ldots,R_m$ is globally consistent if and only if~$(R_1\Join \cdots \Join R_m)[X_i]= R_i$ for all~$i = 1,\ldots,m$. \end{itemize} Consequently, if the collection $R_1,\ldots,R_m$ is globally consistent, then the join $R_1\Join \cdots \Join R_m$ is the largest relation witnessing their consistency. As seen earlier, pairwise consistency is a necessary, but not sufficient, condition for global consistency. This was exemplified by three relations~$R,S,T$ with schema~$AB$,~$BC$,~$AC$, respectively. In contrast, it is not hard to see that if the schema of the three relations had been~$AB$,~$BC$,~$CD$, then pairwise consistency would have been a necessary and sufficient condition for the global consistency of any three~$K$-relations over these schema. This raises the question whether it is possible to characterize the set of schema for which pairwise consistency is a necessary and sufficient condition for global consistency. This question was investigated and answered by Beeri, Fagin, Maier, and Yannakakis \cite{BeeriFaginMaierYannakakis1983}. Before describing their results, we need to introduce a number of notions from hypergraph theory. \paragraph{Hypergraphs} A \emph{hypergraph} is a pair $H = (V,E)$, where $V$ is a set of \emph{vertices} and $E$ is a set of \emph{hyperedges}, each of which is a non-empty subset of $V$. Clearly, the undirected graphs without self-loops are precisely the hypergraphs all the hyperedges of which are two-element sets of vertices; such hyperedges are called \emph{edges}. Let~$H = (V,E)$ be a hypergraph. The \emph{reduction} of~$H$, denoted by~$R(H)$, is the hypergraph whose set of vertices is~$V$ itself and whose hyperedges are those hyperedges~$X \in E$ that are not included in any other hyperedge of~$H$. A hypergraph~$H$ is \emph{reduced} if~$H=R(H)$. If~$W \subseteq V$, then the \emph{hypergraph induced by~$W$ on~$H$}, denoted by~$H[W]$, is the hypergraph whose set of vertices is~$W$ and whose hyperedges are the non-empty subsets of the form~$X \cap W$, where~$X \in E$ is a hyperedge of~$H$; in symbols,~$H[W] = (W, \{X \cap W: X \in E\}\setminus \{\emptyset\})$. Every collection~$X_1,\ldots,X_m$ of sets of attributes can be identified with a hypergraph~$H=(V,E)$, where~$V = X_1\cup \cdots \cup X_m$ and~$E =\{X_1,\ldots,X_m\}$. Conversely, every hypergraph~$H = (V,E)$ gives rise to a collection~$X_1,\ldots,X_m$ of sets of attributes, where~$X_1,\dots,X_m$ are the hyperedges of~$H$. For this reason, we can move from collections of sets of attributes to hypergraphs (and vice versa) in a seamless way. In what follows, we will consider several structural properties of hypergraphs that, as shown in \cite{BeeriFaginMaierYannakakis1983}, give rise to necessary and sufficient conditions for pairwise consistency to coincide with global consistency. \paragraph{Acyclic Hypergraphs} We begin by defining the notion of an acyclic hypergraph, which generalizes the notion of an acyclic undirected graph with no self-loops. For this, we need to introduce several auxiliary notions. If~$H$ is a hypergraph and~$u$ and $v$ are vertices of~$H$, then a~\emph{path from~$u$ to~$v$} is a sequence~$Y_1,\ldots,Y_k$ of hyperedges of~$H$, for some positive integer~$k$, such that~$u\in Y_1$ and~$v\in Y_k$, and~$Y_i\cap Y_{i+1}\neq \emptyset$, for all~$i \in [k-1]$. Using the notion of a path, one defines the notions of a \emph{connected component} of a hypergraph and of a \emph{connected} hypergraph in the obvious way. Let~$H=(V,E)$ be a reduced hypergraph and let~$X$ and~$Y$ be two distinct hyperedges of~$H$ with~$X\cap Y \not= \emptyset$. We say that~$X\cap Y$ is an \emph{articulation set} of~$H$ if the number of connected components of the reduction~$R(H[V\setminus (X\cap Y)])$ of~$H[V\setminus (X\cap Y)]$ is greater than the number of the connected components of~$H$. We say that a reduced hypergraph~$H$ is \emph{acyclic} if for every subset~$W$ of vertices of~$H$, if~$R(H[W])$ is connected and has more than one hyperedges, then it has an articulation set. Finally, a hypergraph~$H$ is \emph{acyclic} if its reduction~$R(H)$ is acyclic. Otherwise,~$H$ is \emph{cyclic}. We say that a collection~$X_1,\ldots,X_m$ of sets of attributes is \emph{acyclic} if the hypergraph with hyperedges~$X_1,\ldots,X_m$ is acyclic; otherwise, we say that the collection~$X_1,\ldots,X_m$ is \emph{cyclic}. To illustrate these concepts, consider the set~$V=\{A_1,\ldots,A_n\}$ of vertices and the sets~$E_1$ and~$E_2$ of hyperedges, where~$E_1=\{ \{A_i,A_{i+1}\}: 1\leq i\leq n-1\}$ and~$E_2 = E_1 \cup \{\{A_n,A_1\}\}$. It is not hard to verify that the hypergraph~$H_1=(V,E_1)$ is acyclic, whereas the hypergraph~$H_2=(V,E_2)$ is cyclic as soon as~$n \geq 3$. \paragraph{Conformal and Chordal Hypergraphs} The \emph{primal} graph of a hypergraph~$H = (V,E)$ is the undirected graph that has~$V$ as its set of vertices and has an edge between any two distinct vertices that appear together in at least one hyperedge of~$H$. A hypergraph~$H$ is \emph{conformal} if the set of vertices of every clique (i.e., complete subgraph) of the primal graph of~$H$ is contained in some hyperedge of~$H$. For example, both hypergraphs~$H_1$ and~$H_2$ above are conformal, whereas the hypergraph~$H_3=(V,E_3)$ with~$V=\{A_1,\ldots,A_n\}$ and~$E_3= \{ V\setminus \{A_i\}: 1\leq i\leq n\}$ is not conformal as long as~$n \geq 3$. A hypergraph~$H$ is \emph{chordal} if its primal graph is chordal, that is, if every cycle of length at least four of the primal graph of~$H$ has a chord. For example, the hypergraphs~$H_1$ and~$H_3$ above are chordal, whereas the hypergraph~$H_2$ is not chordal for~$n \geq 4$. Observe that, in case~$n = 3$, the hypergraph~$H_2$ is chordal but not conformal. \paragraph{Running Intersection Property} We say that a hypergraph~$H$ has the \emph{running intersection property} if there is a listing~$X_1,\ldots,X_m$ of all hyperedges of~$H$ such that for every~$i \in [m]$ with~$i \geq 2$, there exists a~$j < i$ such that~$X_i \cap (X_1 \cup \cdots \cup X_{i-1}) \subseteq X_j$. For example, the hypergraph~$H_1$ has the running intersection property with the listing being~$\{A_1,A_2\}, \ldots, \{A_{n-1},A_n\}$, whereas the hypergraphs~$H_2$ and~$H_3$ do not have the running intersection property as long as~$n \geq 3$. \paragraph{Join Trees} A \emph{join tree} for a hypergraph~$H$ is an undirected tree~$T$ with the set~$E$ of the hyperedges of~$H$ as its vertices and such that for every vertex~$v$ of~$H$, the set of vertices of~$T$ containing~$v$ forms a subtree of~$T$, i.e., if~$v$ belongs to two vertices~$X_i$ and~$X_j$ of~$T$, then~$v$ belongs to every vertex of~$T$ in the unique path from~$X_i$ to~$X_j$ in~$T$. For example, the hypergraph~$H_1$ has a join tree (in fact, the join tree is a path) with edges of the form~$\{\{A_i,A_{i+1}\},\{A_{i+1},A_{i+2}\}\}$ for~$i \in [n-2]$, whereas the hypergraphs~$H_2$ and~$H_3$ do not have a join tree for~$n \geq 3$. \paragraph{Graham's Algorithm} Consider the following iterative algorithm on hypergraphs: given a hypergraph~$H=(V,E)$, apply the following two operations repeatedly until neither of the two operations can be applied: \begin{enumerate} \itemsep=0pt \item If~$v$ is a vertex that appears in only one hyperedge~$X_i$ of~$H$, then delete~$v$ from~$X_i$. \item If there are two hyperedges~$X_i$ and~$X_j$ such that~$i\not = j$ and~$X_i\subseteq X_j$, then delete~$X_i$ from~$E$. \end{enumerate} It can be shown that this algorithm has the Church-Rosser property, that is, it produces the same hypergraph independently of the order in which the above two operations are applied. We say that \emph{Graham's algorithm succeeds} on a hypergraph~$H=(V,E)$ if the algorithm, given~$H$ as input, returns the empty hypergraph~$H= (V, \emptyset)$ as output. Otherwise, we say that \emph{Graham's algorithm fails} on~$H$. We also say that~$H$ is \emph{accepted} by Graham's algorithm if the algorithm succeeds on~$H$; otherwise we say that it is \emph{rejected}. For example, Graham's algorithm succeeds on the hypergraph~$H_1$, whereas it fails on the hypergraphs~$H_2$ and~$H_3$ as long as~$n \geq 3$ (in fact, it returns~$H_2$ and~$H_3$, respectively). This algorithm was designed by Graham \cite{Graham79}. A similar algorithm was designed by Yu and Ozsoyoglu \cite{yu1979algorithm}; these two algorithms are often referred to as the GYO Algorithm (see \cite{DBLP:books/aw/AbiteboulHV95}). \paragraph{Local-to-Global Consistency Property} The notions introduced so far can be thought of as ``syntactic" or ``structural" properties that some hypergraphs possess and others do not, because their definitions involve only the vertices and the hyperedges of the hypergraph at hand. In contrast, the next notion is ``semantic", in the sense that its definition also involves relations whose sets of attributes are the hyperedges of the hypergraph at hand. Let~$H$ be a hypergraph and let~$X_1,\dots,X_m$ be a listing of all hyperedges of~$H$. We say that~$H$ has the \emph{\ltgc~for ordinary relations} if every pairwise consistent collection~$R_1(X_1),\ldots,R_m(X_m)$ of relations of schema~$X_1,\ldots,X_m$ is globally consistent. For example, it can be shown that the hypergraph~$H_1$ has the \ltgc~for ordinary relations, whereas the hypergraphs~$H_2$ and~$H_3$ do not have this property as long as~$n \geq 3$. \bigskip We are now ready to state the main result in Beeri, Fagin, Maier, Yannakakis \cite{BeeriFaginMaierYannakakis1983}. \begin{theorem} [Theorem 3.4 in \cite{BeeriFaginMaierYannakakis1983}] \label{thm:BFMY} Let~$H$ be a hypergraph. The following statements are equivalent: \begin{enumerate} \itemsep=0pt \item[(a)] $H$ is an acyclic hypergraph. \item[(b)] $H$ is a conformal and chordal hypergraph. \item[(c)] $H$ has the running intersection property. \item[(d)] $H$ has a join tree. \item[(e)] $H$ is accepted by Graham's algorithm. \item[(f)] $H$ has the \ltgc~for ordinary relations. \end{enumerate} \end{theorem} As an illustration of Theorem \ref{thm:BFMY}, let us return to the hypergraphs $H_1$, $H_2$, $H_3$ encountered earlier. Hypergraph $H_1$ has all six properties in Theorem \ref{thm:BFMY}, whereas hypergraphs $H_2$ and $H_3$ have none of these properties when $n \geq 3$. \subsection{Global Consistency in Arbitrary Positive Semirings} \label{subsec:cons-pos} Let~$K$ be an arbitrary, but fixed, positive semiring. In this section, we investigate some aspects of global consistency for collections of~$K$-relations. As discussed earlier, if~$R_1,\ldots,R_m$ is a globally consistent collection of ordinary relations, then the join~$R_1\Join \cdots \Join R_m$ witnesses the global consistency of~$R_1,\ldots,R_m$ (and, in fact, is the largest such witness). At first, one may expect that a similar result may hold for globally consistent collections~$R_1,\ldots,R_m$ of~$K$-relations. It turns out, however, that the concept of the join of three or more~$K$-relations is problematic, even for the case in which~$K$ is the bag semiring~${\mathbb N}$ of non-negative integers. Note that, using the join of two relations, the join of three~$K$-relations~$R,S,T$ could be defined as either~$R \Join (S \Join T)$ or as~$(R\Join S) \Join T$. The join of ordinary relations is associative, hence these two expressions coincide for ordinary relations. In contrast, there are bags~$R, S, T$ that are globally consistent and such that \begin{equation} R \Join (S \Join T) \not \equiv (R \Join S) \Join T, \end{equation} and neither~$R \Join (S \Join T)$ nor~$(R \Join S) \Join T$ witnesses the global consistency of~$R,S,T$. \medskip \begin{example} \label{exam:triangle} Let~$W(ABC)$ be the bag given by its table of multiplicities below, along with its three marginals $R(AB), S(BC), T(AC)$: \begin{center} \begin{tabular}{ccccccccccccccccccc} $W(ABC)$ \# & \;\;\;\; & $R(AB)$ \# & \;\;\;\; & $S(BC)$ \# & \;\;\;\; & $T(AC)$ \# \\ \;\;\; 1 1 2 : 1 & & \;\; 1 1 : 1 & & \;\; 1 2 : 1 & & \;\; 1 2 : 1 \\ \;\;\; 1 2 3 : 2 & & \;\; 1 2 : 2 & & \;\; 1 4 : 4 & & \;\; 1 3 : 2 \\ \;\;\; 2 1 4 : 4 & & \;\; 2 1 : 4 & & \;\; 2 2 : 2 & & \;\; 2 1 : 3 \\ \;\;\; 2 2 2 : 2 & & \;\; 2 2 : 2 & & \;\; 2 3 : 2 & & \;\; 2 2 : 2 \\ \;\;\; 2 3 1 : 3 & & \;\; 2 3 : 3 & & \;\; 3 1 : 3 & & \;\; 2 4 : 4 \end{tabular} \end{center} By construction the collection of three bags~$R,S,T$ is globally consistent as witnessed by~$W$. We produced~$N_1 := (R \Join S) \Join T$ and~$N_2 := R \Join (S \Join T)$ by computer, along with their marginals on~$AB, BC, AC$. We display two bags~$[N_1]$ and~$[N_2]$ that are in the equivalence classes of~$N_1$ and~$N_2$, respectively, along with the two marginals~$P_1 := [N_1][BC]$ and~$P_2 := [N_2][AB]$ that suffice to verify the claim that neither~$N_1$ nor~$N_2$ witness the consistency of~$R,S,T$: \begin{center} \begin{tabular}{lllllllllllllllllllllllllllll} $[N_1](ABC)$\, \# & \;\;\; & $[N_2](ABC)$\; \# & \;\;\; & $P_1(BC)$\, \# & \;\;\; & $P_2(AB)$\, \# \\ \;\;\;\;\;\;\, 1 1 2 : 14 & & \;\;\;\;\;\;\; 1 1 2 : 1 & & \;\;\;\; 1 2 : 22 & & \;\;\;\; 1 1 : 1 \\ \;\;\;\;\;\;\, 1 2 2 : 7 & & \;\;\;\;\;\;\; 1 2 2 : 5 & & \;\;\;\; 1 4 : 48 & & \;\;\;\; 1 2 : 10 \\ \;\;\;\;\;\;\, 1 2 3 : 21 & & \;\;\;\;\;\;\; 1 2 3 : 5 & & \;\;\;\; 2 2 : 35 & & \;\;\;\; 2 1 : 20 \\ \;\;\;\;\;\;\, 2 1 2 : 8 & & \;\;\;\;\;\;\; 2 1 2 : 4 & & \;\;\;\; 2 3 : 21 & & \;\;\;\; 2 2 : 5 \\ \;\;\;\;\;\;\, 2 1 4 : 48 & & \;\;\;\;\;\;\; 2 1 4 : 16 & & \;\;\;\; 3 1 : 42 & & \;\;\;\; 2 3 : 15 \\ \;\;\;\;\;\;\, 2 2 2 : 28 & & \;\;\;\;\;\;\; 2 2 2 : 5 & & & & & & & & \\ \;\;\;\;\;\;\, 2 3 1 : 42 & & \;\;\;\;\;\;\; 2 3 1 : 15 & & & & & & & & \end{tabular} \end{center} The ratio test shows that~$[N_1]$ and~$[N_2]$ are not equivalent ($14/1 \not= 7/5$), so~$\Join$ is not associative, not even up to equivalence. The ratio test applied to the bags~$P_1(BC)$ and~$S(BC)$ shows that they are not equivalent~($22/1 \not= 48/4$), and the ratio test applied to the bags~$P_2(AB)$ and~$R(AB)$ shows that they are not equivalent~($1/1 \not= 10/2$). Thus, neither~$N_1$ nor~$N_2$ witness the consistency of~$R,S,T$. \end{example} Observe that the collection $AB$, $BC$, $AC$ of the sets of attributes of the relations in Example \ref{exam:triangle} is cyclic. It turns out that this is no accident. Indeed, we show next that if a collection~$X_1,\ldots,X_m$ of sets of attributes is acyclic and if~$R_1(X_1),\ldots,R_m(X_m)$ is a globally consistent collection of~$K$-relations of schema~$X_1,\ldots,X_m$, then a witness of their global consistency can always be built iteratively through joins of two~$K$-relations. In fact, we show something stronger, namely, that it suffices for~$R_1,\ldots,R_m$ to be pairwise consistent~$K$-relations. For stating this lemma we need the following definition. The~\emph{iterated left-join} of the~$K$-relations~$R_1,\ldots,R_m$ is the~$K$-relation \begin{equation} ((\cdots(R_1 \Join R_2) \Join \cdots \Join R_{m-2}) \Join R_{m-1}) \Join R_m, \label{eqn:iteratedjoin} \end{equation} i.e., the sequential join of~$R_1,\ldots,R_m$ with the join operations associated to the left. More formally, the iterated left-join of~$R_1,\ldots,R_m$ is defined by induction on~$m$. For~$m = 1$ it is~$R_1$, and for~$m \geq 2$ it is~$R \Join R_m$ where~$R$ is the iterated left-join of~$R_1,\ldots,R_{m-1}$. \begin{lemma} \label{lem:newlemma} Let~$X_1,\ldots,X_m$ be an acyclic collection of sets of attributes. There exists a permutation~$\pi : [m] \rightarrow [m]$ such that if~$R_1(X_1),\ldots,R_m(X_m)$ are pairwise consistent~$K$-relations of schema~$X_1,\ldots,X_m$, then they are globally consistent, and the iterated left-join of~$R_{\pi(1)},\ldots,R_{\pi(m)}$ witnesses their global consistency. In particular, if they are globally consistent, then the iterated left-join of some permutation of them witnesses their global consistency. \end{lemma} \begin{proof} Assume that~$X_1,\ldots,X_m$ is an acyclic collection of sets of attributes. By Theorem \ref{thm:BFMY}, this collection has the running intersection property, hence there exists a permutation~$\pi : [m] \rightarrow [m]$ such that for every~$i \in [m]$ with~$i\geq 2$, there exists~$j \in [m]$ such that~$\pi(j) < \pi(i)$ and~$X_{\pi(i)} \cap (X_{\pi(1)} \cup \cdots \cup X_{\pi(i-1)}) \subseteq X_{\pi(j)}$. By renaming the sets, we may assume that~$\pi$ is the identity, so for every~$i \in [m]$ with~$i \geq 2$, there is a~$j \in [i-1]$ such that~$X_i \cap (X_1 \cup \cdots \cup X_{i-1}) \subseteq X_j$. Fix a collection of~$K$-relations~$R_1,\ldots,R_m$ for~$X_1,\ldots,X_m$ and assume that they are pairwise consistent. For each~$i \in [m]$, let~$T_i := ((R_{1} \Join \cdots \Join R_{i-2}) \Join R_{i-1}) \Join R_i$ with the joins associated to the left. We show, by induction on~$i = 1,\ldots,m$, that~$T_i$ is a~$K$-relation over~$X_1 \cup \cdots \cup X_i$ that witnesses the consistency of~$R_1,\ldots,R_i$. For~$i = 1$ the claim is obvious since~$T_1 = R_1$. Assume then that~$i \geq 2$ and that the claim is true for smaller indices. Let~$X := X_1 \cup \cdots \cup X_{i-1}$ and let~$j \in [i-1]$ be such that~$X_i \cap X \subseteq X_j$. By induction hypothesis, we know that~$T_{i-1}$ is a~$K$-relation over~$X$ that witnesses the consistency of~$R_1,\ldots,R_{i-1}$. First, we show that~$T_{i-1}$ and~$R_i$ are consistent. By Lemma~\ref{lem:characterization} it suffices to show that~$T_{i-1}[X \cap X_i] \equiv R_i[X \cap X_i]$. Let~$Z = X \cap X_i$, so~$Z \subseteq X_j$ by the choice of~$j$, and indeed~$Z = X_j \cap X_i$. Since~$j \leq i-1$, we have~$R_j \equiv T_{i-1}[X_j]$. By Part~3 of Lemma~\ref{lem:easyfacts2} and Part~3 of Lemma~\ref{lem:easyfacts1}, we have~$R_j[Z] \equiv T_{i-1}[X_j][Z] = T_{i-1}[Z]$. By assumption, also~$R_j$ and~$R_i$ are consistent, and~$Z = X_j \cap X_i$, which by Lemma~\ref{lem:characterization} implies~$R_j[Z] \equiv R_i[Z]$. By transitivity, we get~$T_{i-1}[Z] \equiv R_i[Z]$, hence, by~$Z = X \cap X_i$ and Lemma~\ref{lem:characterization}, the~$K$-relations~$T_{i-1}$ and~$R_i$ are consistent. We show that~$T_i = T_{i-1} \Join R_i$ witnesses the consistency of~$R_1,\ldots,R_i$. Since~$T_{i-1}$ and~$R_i$ are consistent, first note that~$T_{i-1} \equiv T_i[X]$ and~$R_i \equiv T_i[X_i]$ by Lemma~\ref{lem:characterization}. Now fix~$k \leq i-1$ and note that \begin{equation} R_k \equiv T_{i-1}[X_k] \equiv T_i[X][X_k] = T_i[X_k], \end{equation} where the first equivalence follows from the fact that~$T_{i-1}$ witnesses the consistency of~$R_1,\ldots,R_{i-1}$ and~$k \leq i-1$, the second equivalence follows from~$T_{i-1} \equiv T_i[X]$ together with Part~3 of Lemma~\ref{lem:easyfacts2} applied to~$X_k \subseteq X$, and the equality follows again from~$X_k \subseteq X$ and this time from Part~3 of Lemma~\ref{lem:easyfacts1}. Thus, $T_i$ witnesses the consistency of~$R_1,\ldots,R_i$, which was to be shown. \end{proof} In what follows, we explore the interplay between pairwise consistency and global consistency of $K$-relations, aiming to extend Theorem \ref{thm:BFMY} to arbitrary positive semirings. \paragraph{Local-to-Global Consistency Property for~$K$-relations} We extend the notion of local-to-global consistency property from ordinary relations to $K$-relations. Let~$H$ be a hypergraph and let~$X_1,\dots,X_m$ be a listing of all hyperedges of~$H$. We say that~$H$ has the \emph{\ltgc~for~$K$-relations} if every pairwise consistent collection~$R_1(X_1),\ldots,R_m(X_m)$ of~$K$-relations of schema~$X_1,\ldots,X_m$ is globally consistent. \begin{theorem} \label{thm:main} Let $K$ be a positive semiring and let $H$ be a hypergraph. The following statements are equivalent: \begin{enumerate} \itemsep=0pt \item [(a)] $H$ is an acyclic hypergraph. \item [(b)] $H$ has the \ltgc~for $K$-relations. \end{enumerate} \end{theorem} The claim that (a) implies (b) in Theorem~\ref{thm:main} follows directly from the preceding Lemma~\ref{lem:newlemma}. We concentrate on proving that (b) implies (a). To do this, we need four technical lemmas. By Theorem \ref{thm:BFMY}, a hypergraph~$H$ is acyclic if and only if it is conformal and chordal. The first two technical lemmas state, in effect, that the ``minimal" non-conformal hypergraphs, as well as the ``minimal" non-chordal hypergraphs, have very simple forms. \begin{lemma}[\cite{DBLP:journals/csur/Brault-Baron16}] \label{lem:characconf} A hypergraph~$H = (V,E)$ is not conformal if and only if there exists a subset $W$ of $V$ such that~$|W| \geq 3$ and~$R(H[W])=(W,\{W\setminus\{A\} : A \in W\})$, where $R(H[W])$ is the reduction of the hypergraph $H[W]$ induced by $W$. \end{lemma} \begin{proof} The \emph{if} direction is immediate since, given that~$|W| \geq 3$, the set~$W$ forms a clique in the primal graph that is not included in any hyperedge of~$H$; otherwise no~$W\setminus\{A\}$ with~$A \in W$ would be a hyperedge in the reduced hypergraph of~$H[W]$. For the \emph{only if} direction, let~$W$ be a clique in the primal graph of~$H$ that is not included in any hyperedge of~$H$ and that is minimal with this property. Since the two vertices of every edge of the primal graph are included in some hyperedge of~$H$ we have~$|W| \geq 3$. In addition, by minimality of~$W$, each~$W\setminus\{A\}$ with~$A \in W$ is included in some hyperedge~$X$ of~$A$ that does not contain~$W$, so~$X \cap W = W \setminus \{A\}$. This means that each~$W \setminus \{A\}$ is a hyperedge of~$H[W]$, and also of its reduced hypergraph since~$W$ is not included in any hyperedge of~$H$. Conversely, if~$X$ is a hyperedge in~$E$, then there is some~$A\in W$ such that~$X\cap W\subseteq W\setminus \{A\}$. It follows that~$R(H[W])=(W,\{W\setminus\{A\} : A \in W\})$. \end{proof} \begin{lemma} \label{lem:characchord} A hypergraph $H = (V,E)$ is not chordal if and only if there exists a subset $W$ of $V$ such that $|W| \geq 4$ and $R(H[W]) = (W,\{\{A_i,A_{i+1}\} : i \in [n]\})$, where~$A_1,\ldots,A_n$ is an enumeration of $W$ and $A_{n+1} := A_1$. \end{lemma} \begin{proof} The \emph{if} direction is immediate since it implies that the primal graph of~$H$ contains a chordless cycle of length at least four. For the \emph{only if} direction, let~$W$ be the set of vertices of a shortest chordless cycle of length at least four in the primal graph of~$H$. \end{proof} The next two technical lemmas state that the local-to-global consistency property for $K$-relations is preserved under induced hypergraphs, and also under reductions. \begin{lemma} \label{lem:preserv1} If a hypergraph~$H$ has the \ltgc~for~$K$-relations, then for every subset~$W$ of the vertices of~$H$ the hypergraph~$H[W]$ also has the \ltgc~for~$K$-relations. \end{lemma} \begin{proof} Assume that the hypergraph~$H=(V,E)$ has the \ltgc~for~$K$-relations. We will show that, for every vertex~$A\in V$, the hypergraph~$H[V\setminus \{A\}]= (V,\{X\setminus \{A\}: X \in E\})$ also has the \ltgc~for~$K$-relations. The statement of the lemma will follow from iterating this statement over all attributes~$A$ in~$V \setminus W$. Let~$X_1,\ldots,X_m$ be a listing of all hyperedges of~$H$. Fix a vertex~$A$ in~$V$ and write~$Y_i := X_i \setminus \{A\}$ for all~$i \in [m]$. Let~$R_1,\ldots,R_m$ be a collection of pairwise consistent~$K$-relations for~$Y_1,\ldots,Y_m$. Fix an arbitrary value~$u_0$ in the domain~$\domain(A)$ of the attribute~$A$. We define a collection of~$K$-relations~$S_1,\ldots,S_m$ for~$X_1,\ldots,X_m$ as follows. For each~$i \in [m]$ with~$A \not\in X_i$, let~$S_i := R_i$. For each~$i \in [m]$ with~$A \in X_i$, let~$S_i$ be the~$K$-relation over~$X_i$ defined for every~$X_i$-tuple~$t$ by~$S_i(t) := 0$ if~$t(A) \not= u_0$ and by~$S_i(t) := R_i(t[Y_i])$ if~$t(A) = u_0$. We claim that the~$K$-relations~$S_1,\ldots,S_m$ are pairwise consistent. In order to see this, fix~$i,j \in [m]$ and distinguish the two cases whether~$A \not\in X_i X_j$ or~$A \in X_i X_j$: If~$A \not\in X_i X_j$, then~$S_i = R_i$ and~$S_j = R_j$ and therefore~$S_i$ and~$S_j$ are consistent because~$R_i$ and~$R_j$ are consistent. If~$A \in X_i X_j$, then let~$R$ be a~$K$-relation over~$Y_i Y_j$ that witnesses the consistency~$R_i$ and~$R_j$ and let~$S$ be the~$K$-relation over~$X_i X_j$ defined for every~$X_i X_j$-tuple~$t$ by~$S(t) := 0$ if~$t(A) \not= u_0$ and by~$S(t) := R(t[Y_i Y_j])$ if~$t(A) = u_0$. We claim that~$S$ witnesses the consistency of~$S_i$ and~$S_j$. We show that~$S_i \equiv S[X_i]$ and a symmetric argument will show that~$S_j \equiv S[X_j]$. In order to see this, first we argue that~$R[Y_i] = S[Y_i]$. Indeed, for every~$Y_i$-tuple~$r$ we have \begin{align} R(r) = \sum_{s \in R' : \atop s[Y_i] = r} R(s) = \sum_{t \in \tuples(X_i X_j) : \atop t[Y_i] = r, t(A) = u_0} R(t[Y_i Y_j]) = \sum_{t \in S' : \atop t[Y_i] = r} S(t) = S(r), \label{eqn:lsllsggg} \end{align} where the first equality follows from~\eqref{eqn:marginal}, the second follows from the fact that the map~$t \mapsto t[Y_i Y_j]$ is a bijection between the set of~$X_i X_j$-tuples~$t$ such that~$t[Y_i]=r$ and~$t(A) = u_0$ and the set of~$Y_i Y_j$-tuples~$s$ such that~$s[Y_i]=r$, the third follows from the definition of~$S$, and the fourth follows from~\eqref{eqn:marginal}. For later use, let us note that we did not assume that~$i \not= j$ for showing~\eqref{eqn:lsllsggg}. In case~$i = j$, the~$K$-relation~$R_i$ can serve as~$R$, and~$S$ equals~$S_i$, which shows that~$R_i = S_i[Y_i]$. In case~$A \not\in X_i$, we have that~$Y_i = X_i$, hence Equation~\eqref{eqn:lsllsggg} already shows that~$S_i = R_i \equiv R[Y_i] = S[Y_i]$, so~$S_i \equiv S[X_i]$. In case~$A \in X_i$, let~$a,b \in K\setminus\{0\}$ be such that~$a R_i = b R[Y_i]$ and we show~$a S_i = b S[X_i]$. For every~$X_i$-tuple~$r$ with~$r(A) \not= u_0$, we have~$S_i(r) = 0$ and also~$S(r) = \sum_{t : t[X_i] = r} S(t) = 0$ since~$t[X_i] = r$ and~$A \in X_i$ implies~$t(A) = r(A) \not= u_0$. Thus, $a S_i(r) = 0 = b S(r)$ in this case. For every~$X_i$-tuple~$r$ with~$r(A) = u_0$, we have \begin{align} a S_i(r) = a R_i(r[Y_i]) = b R(r[Y_i]) = b S(r[Y_i]), \label{lem:inter} \end{align} where the first equality follows from the definition of~$S_i$ and the assumption that~$r(A) = u_0$, the second follows from the choices of~$a$ and~$b$, and the third follows from~\eqref{eqn:lsllsggg}. Continuing from the right-hand side of~\eqref{lem:inter}, we have \begin{align} b S(r[Y_i]) = b \sum_{t \in S' : \atop t[Y_i] = r[Y_i]} S(t) = b \sum_{t \in S' : \atop t[X_i] = r} S(t) = b S(r), \label{lem:retni} \end{align} where the first equality follows from~\eqref{eqn:marginal}, the second follows from the assumption that~$A \in X_i$ and~$r(A) = u_0$ together with~$S(t) = 0$ in case~$t(A) \not= u_0$, and the third follows from~\eqref{eqn:marginal}. Combining~\eqref{lem:inter} with~\eqref{lem:retni}, we get~$a S_i(r) = b S(r)$ also in this case. This proves that~$S_i \equiv S[X_i]$; a completely symmetric argument proves that~$S_j \equiv S[X_j]$. Since~$S_1,\ldots,S_m$ are pairwise consistent~$K$-relations for~$X_1,\ldots,X_m$, by assumption they are globally consistent. Let~$N$ be a~$K$-relation over~$X_1 \cup \cdots \cup X_m$ that witnesses their consistency. Let~$M := N[Y_1 \cup \cdots \cup Y_m]$ and we argue that~$M$ witnesses the consistency of~$R_1,\ldots,R_m$, which will prove the lemma. Fix~$i \in [m]$ and let~$a,b \in K\setminus\{0\}$ be such that~$a S_i = b S[X_i]$. For every~$Y_i$-tuple~$r$ we have \begin{align} a R_i(r) = a S_i(r) = b N(r) = b M(r), \end{align} where the first follows~$S_i = R_i$ in case~$A \not\in X_i$ and from~\eqref{eqn:lsllsggg} applied to~$i = j$ and~$R = R_i$ in case~$A \in X_i$, the second follows from the choice of~$a$ and~$b$, and the third follows from the choice of~$M$ and Part~3 of Lemma~\ref{lem:easyfacts1}. \end{proof} \begin{lemma} \label{lem:preserv2} If a hypergraph~$H$ has the \ltgc~for~$K$-relations, then the hypergraph~$R(H)$ also has the \ltgc~for~$K$-relations. \end{lemma} \begin{proof} Assume that the hypergraph~$(V,\{X_1,\ldots,X_m\})$ has the local-to-global consistency property for~$K$-relations. We will show that if~$X_m$ is covered by some other hyperedge, i.e.,~$X_m \subseteq X_i$ for some~$i \leq m-1$, then the hypergraph~$(V,\{X_1,\ldots,X_{m-1}\})$ also has the \ltgc~for~$K$ relations. The statement of the lemma will follow from iterating this statement over all hyperedges of~$H$ that are covered by some other hyperedge of~$H$. Let~$R_1,\ldots,R_{m-1}$ be a collection of pairwise consistent~$K$-relations for~$X_1,\ldots,X_{m-1}$. Define~$R_m := R_i[X_m]$. We claim that~$R_1,\ldots,R_m$ are pairwise consistent. It suffices to check that~$R_j$ and~$R_m$ are consistent for any~$j \in [m]$ with~$j \not= m$. By assumption, we know that~$R_j$ and~$R_i$ are consistent, which means that there exists a~$K$-relation~$T$ that witnesses their consistency; we have~$R_j \equiv T[X_j]$ and~$R_i \equiv T[X_i]$. Let~$S := T[X_j X_m]$. We have \begin{equation} R_j \equiv T[X_j] = T[X_j X_m][X_j] = S[X_j], \end{equation} where the first follows from the choice of $T$, the second follows from Part~3 of Lemma~\ref{lem:easyfacts1} and the third follows from the choice of~$S$. Likewise, \begin{equation} R_m = R_i[X_m] \equiv T[X_i][X_m] = T[X_m] = T[X_j X_m][X_m] = S[X_m], \end{equation} where the first equality is by the choice of~$R_m$, the second follows from the choice of $T$, the assumption that~$X_m \subseteq X_i$, and Part~3 of Lemma~\ref{lem:easyfacts2}, the third follows from the assumption that~$X_m \subseteq X_i$ and Part~3 of Lemma~\ref{lem:easyfacts1}, the fourth follows again from Part~3 of Lemma~\ref{lem:easyfacts1}, and the fifth follows from the choice of~$S$. Thus,~$S$ witnesses the consistency of~$R_j$ and~$R_m$. Since~$R_1\ldots,R_m$ are pairwise consistent~$K$-relations for~$X_1,\ldots,X_m$, by assumption they are globally consistent. The same~$K$-relation that witnesses their global consistency also witnesses the global consistency of~$R_1,\ldots,R_{m-1}$, which completes the proof. \end{proof} \paragraph{Generalized Tseitin Construction and Proof of Theorem~\ref{thm:main}} The minimal non-conformal and minimal non-chordal hypergraphs from Lemmas~\ref{lem:characconf} and Lemma \ref{lem:characchord} share the following properties: 1)~all their hyperedges have the same number of vertices, and 2)~all their vertices appear in the same number of hyperedges. For hypergraphs~$H$ that have these properties, we construct a collection~$C(H; K)$ of~$K$-relations that are indexed by the hyperedges of~$H$; these relations will play a crucial role in the proof of Theorem~\ref{thm:main}. Let~$H = (V,E)$ be a hypergraph and let~$d$ and~$k$ be positive integers. The hypergraph~$H$ is called~\emph{$k$-uniform} if every hyperedge of~$H$ has exactly~$k$ vertices. It is called \emph{$d$-regular} if any vertex of~$H$ appears in exactly~$d$ hyperedges of~$H$. For example, the non-conformal hypergraph of Lemma~\ref{lem:characconf} is~$k$-uniform and~$d$-regular for~$k := d := |W|-1$. Likewise, the non-chordal hypergraph of Lemma~\ref{lem:characchord} is~$k$-uniform and~$d$-regular for~$k := d := 2$. For a positive semiring~$K$ and each~$k$-uniform and~$d$-regular hypergraph~$H$ with~$d \geq 2$ and with hyperedges~$E = \{X_1,\ldots,X_m\}$, we construct a collection of~$K$-relations~$C(H; K) := \{ R_1(X_1),\ldots,R_m(X_m) \}$, where~$R_i$ is a~$K$-relation that has attributes~$X_i$. The collection~$C(H; K)$ of these~$K$-relations will turn out to be pairwise consistent but not globally consistent. Note that by the characterization of acyclicity in terms of Graham's algorithm, a hypergraph that is~$k$-uniform and~$d$-regular for some~$k \geq 2$ and~$d \geq 2$ will never be acyclic: Graham's procedure will not even start to remove any hyperedge or any vertex. Hence, the existence of the~$K$-relations~$R_1,\ldots,R_m$ that violates the local-to-global consistency property is compatible with Theorem~\ref{thm:main}. The construction is defined as follows. For each~$i \in [m]$ with~$i \not= m$, let~$R_i$ be the unique unit~$K$-relation over~$X_i$ whose support contains all tuples~$t : X_i \rightarrow \{0,\ldots,d-1\}$ whose total sum~$\sum_{C \in X_i} t(C)$ is congruent to~$0$ mod~$d$; i.e.,~$R(t) := 1$ for each such~$X_i$-tuple, and~$R(t) := 0$ for any other~$X_i$-tuple. For~$i = m$, let~$R_i$ be the unique unit~$K$-relation over~$X_i$ whose support contains all tuples~$t : X_i \rightarrow \{0,\ldots,d-1\}$ whose total sum~$\sum_{C \in X_i} t(C)$ is congruent to~$1$ mod~$d$; i.e., again~$R(t) := 1$ for each such~$X_i$-tuple, and~$R(t) := 0$ otherwise. To show the pairwise consistency of~$R_1,\ldots,R_m$, it suffices, by Lemma~\ref{lem:characterization}, to show that for every two distinct~$i,j \in [m]$, we have~$R_i[Z] \equiv R_j[Z]$, where~$Z := X_i \cap X_j$. In turn, this follows from the claim that for every~$Z$-tuple~$t : Z \rightarrow \{0,\ldots,d-1\}$, we have~$R_i(t) = R_j(t) = N_Z 1 = 1 + \cdots + 1$, the sum of~$N_Z := d^{k-|Z|-1}$ many units of the semiring~$K$. Indeed, since by~$k$-uniformity every hyperedge of~$H$ has exactly~$k$ vertices, for every~$u \in \{0,\ldots,d-1\}$, there are exactly~$N_Z$ many~$X_i$-tuples~$t_{i,u,1},\ldots,t_{i,u,N_Z}$ that extend~$t$ and have total sum congruent to~$u$ mod~$d$. It follows then that~$R_i[Z] = R_j[Z]$ regardless of whether~$n \in \{i,j\}$ or~$n \not\in \{i,j\}$, and hence any two~$R_i$ and~$R_j$ are consistent by Lemma~\ref{lem:characterization}. To argue that the relations~$R_1,\ldots,R_m$ are not globally consistent, we proceed by contradiction. If~$R$ were a~$K$-relation that witnesses their consistency, then it would be non-empty and its support would contain a tuple~$t$ such that the projections~$t[X_i]$ belong to the supports~$R'_i$ of the~$R_i$, for each~$i \in [m]$. In turn this means that \begin{align} & \textstyle{\sum_{C \in X_i} t(C) \;\equiv\; 0 \text{ mod } d}, \;\;\;\;\;\ \text{ for $i \not = m$ } \label{eqn:restlu} \\ & \textstyle{\sum_{C \in X_i} t(C) \;\equiv\; 1 \text{ mod } d}, \;\;\;\;\;\ \text{ for $i = m$. } \label{eqn:a0lu} \end{align} Since by $d$-regularity each $C \in V$ belongs to exactly $d$ many sets $X_i$, adding up all the equations in~\eqref{eqn:restlu} and~\eqref{eqn:a0lu} gives \begin{equation} \textstyle{\sum_{C \in V} dt(C) \;\equiv\; 1 \text{ mod } d}, \end{equation} which is absurd since the left-hand side is congruent to~$0$ mod~$d$, the right-hand side is congruent to~$1$ mod~$d$, and~$d \geq 2$ by assumption. We now have all the tools needed to present the proof of Theorem \ref{thm:main}. \begin{proof}[Proof of Theorem~\ref{thm:main}] As stated earlier, the direction (a) implies (b) follows from Lemma~\ref{lem:newlemma}. For showing that (b) implies (a), let us assume the contrary and then we will derive a contradiction. Let~$H = (V,E)$ be a smallest counterexample to the statement that~(b) implies~(a), meaning that the following three conditions hold: (i)~$H$ is not acyclic, (ii)~$H$ has the local-to-global consistency property for~$K$-relations, and (iii)~$H$ is minimal in the sense that~$n = |V|$ is smallest possible with properties~(i) and~(ii), and among those,~$m = |E|$ is smallest possible. Since~$H$ is not acyclic, we know that~$H$ is either not conformal or not chordal. We distinguish the two cases. \bigskip \noindent\textit{Case 1:}~$H$ is not conformal. By Lemmas~\ref{lem:preserv1} and~\ref{lem:preserv2}, the minimality of~$H$, and Lemma~\ref{lem:characconf}, we have~$n \geq 3$ and~$m = n$; indeed,~$E = \{ V_i : i \in [n] \}$ where~$V_i = V\setminus\{A_i\}$ and~$A_1,\ldots,A_n$ is an enumeration of~$V$. Thus,~$H$ is~$k$-uniform and~$d$-regular for~$k = d = n-1 \geq 2$. The construction~$C(H; K)$ gives a collection of~$K$-relations~$R_1,\ldots,R_n$, where~$R_i$ has attributes~$V_i$, which are pairwise consistent but not globally consistent, which is a contradiction. \bigskip \noindent \textit{Case 2:} $H$ is not chordal. By Lemmas~\ref{lem:preserv1} and~\ref{lem:preserv2}, the minimality of~$H$, and Lemma~\ref{lem:characchord}, we have~$n \geq 4$ and~$m = n$, and indeed~$E = \{ V_i : i \in [n] \}$ where~$V_i = \{ A_i,A_{i+1} \}$ and~$A_1,\ldots,A_n$ is an enumeration of~$V$ with~$A_{n+1} := A_1$. Thus, $H$ is $k$-uniform and $d$-regular for $k = d = 2$. Again, the construction $C(H; K)$ gives a collection of $K$-relations $R_1,\ldots,R_n$, where~$R_i$ has attributes~$V_i$, which are pairwise consistent but not globally consistent, which is a contradiction. \end{proof} An inspection of the proof of Theorem~\ref{thm:main} reveals that actually a stronger result is established. Specifically, let~$H$ be a hypergraph and let~$X_1,\ldots,X_m$ be its hyperedges. The proof of Theorem~\ref{thm:main} shows that if~$H$ is not acyclic, then there are ordinary relations~$R_1(X_1),\ldots,R_m(X_m)$ such that, for every positive semiring~$K$, the unit~$K$-relations~$S_1(X_1),\ldots,S_m(X_m)$ with~$S_i'=R_i$ are pairwise consistent but globally inconsistent. In more informal terms, the proof of Theorem \ref{thm:main} actually shows that if a hypergraph is acyclic, then there is an essentially \emph{uniform} counterexample to the \ltgc~for~$K$-relations that works for all positive semirings~$K$. Before establishing the main result in this paper, we bring into the picture one more notion from hypergraph theory that was introduced by Vorob'ev \cite{vorob1962consistent} in his study of global consistency for probability distributions. \paragraph{Vorob'ev Regular Hypergraphs} A \emph{complex} is a hypergraph~$H=(V,E)$ whose set~$E$ of hyperedges is closed under taking subsets, i.e., if~$X\in E$ and~$Z\subseteq X$, then~$Z\in E$. The \emph{downward closure} of a hypergraph~$H$ is the hypergraph whose vertices are those of~$H$ and whose hyperedges are all the subsets of the hyperedges of~$H$. Clearly, the downward closure of a hypergraph is a complex. Let~$K$ be a complex. Let~$X$ and~$Y$ be two different maximal hyperedges of~$K$, where a hyperedge is \emph{maximal} if it not a proper subset of any other hyperedge. We say that~$X$ yields a maximal intersection with~$Y$ if the intersection~$X \cap Y$ is not a proper subset of the intersection~$X \cap Z$ of some third \footnote{The condition ``third'' is missing in Vorob'ev \cite{vorob1962consistent}, and it is necessary since~$e \cap e'$ is always a proper subset of~$e \cap e''$ whenever~$e = e''$ and~$e$ is maximal.} hyperedge~$Z$ of~$K$. A maximal hyperedge~$X$ of~$K$ is called \emph{extreme in}~$K$ if all maximal intersections of~$X$ with hyperedges of~$K$ are equal. Let~$X$ be an extreme hyperedge in~$K$. The \emph{proper} vertices of~$X$ are those that do not belong to any other maximal hyperedge of~$K$. The \emph{normal subcomplex} of~$K$ corresponding to the extreme edge~$X$ is the subcomplex of~$K$ consisting of all hyperedges of~$K$ that do not intersect the set of proper vertices of~$e$. A subcomplex~$K'$ of~$K$ is called a \emph{normal subcomplex} if it is the normal subcomplex corresponding to some extreme hyperedge of~$K$. A \emph{normal series} of~$K$ is a sequence of subcomplexes \begin{equation} K = K_0 \supset K_1 \supset \cdots \supset K_r \label{eqn:series} \end{equation} of the complex~$K$ in which for every $\ell$ with $1\leq \ell \leq r-1$, the complex~$K_{\ell+1}$ is a normal subcomplex of the complex~$K_\ell$, and the final complex~$K_r$ does not have any extreme hyperedges. We say that~$K$ is \emph{regular} if there exists a normal series of~$K$ in which the last term is the complex without vertices. We say that a hypergraph~$H$ is \emph{Vorob'ev regular} if its downward closure is a regular complex. We will show that a hypergraph is Vorob'ev regular if and only if it is acyclic. This result will follow from the next two lemmas and Theorem \ref{thm:BFMY}. We have not been able to locate a published proof of this result in the literature, even though the equivalence between acyclicity and Vorob'ev regularity has been mentioned in \cite{hill1991relational,DBLP:journals/sigact/Yannakakis96}. \begin{lemma} \label{lem:vor-grah} If~$H$ is a Vorob'ev regular hypergraph, then Graham's algorithm succeeds on~$H$. \end{lemma} \begin{proof} Let~$H$ be a Vorob'ev regular hypergraph. The proof that Graham's algorithm succeeds on~$H$ is by induction on the length of a normal series of the downward closure~$K$ of~$H$. If the length of a normal series of~$K$ is zero, then~$K$ and hence~$H$ itself is the empty hypergraph and there is nothing to prove. Assume then that~$K$ has a normal series that has length at least one, let~$K_1$ be the first subcomplex of~$K$ in the series, and let~$X$ be the extreme hyperedge of~$K$ corresponding to which~$K_1$ is its normal subcomplex. Then~$K_1$ consists of the hyperedges of~$K$ that do not intersect the proper vertices of~$e$. Equivalently,~$K_1$ is obtained from~$K$ by deleting all the proper vertices of~$e$. Since the proper vertices of~$e$ appear in no other maximal hyperedge of~$K$, this means that if we delete the proper vertices of~$e$ from all the hyperedges of~$H$ in which they appear, then we obtain a hypergraph whose downward closure is~$K_1$. Moreover, such a hypergraph~$H_1$ can be obtained from~$H$ by a applying a sequence of operations of Graham's algorithm: first delete all the hyperedges that are proper subsets of~$e$, then delete all the proper vertices of~$X$. Now,~$K_1$ is also Vorob'ev's regular, and its normal series has length one less than that of~$K$. Hence, by induction hypothesis, Graham's algorithm succeeds on~$H_1$, which means that there is a sequence of operations of Graham's algorithm that applied to~$H_1$ yield the empty hypergraph. By concatenating the two sequences of operations, we get a single sequence of operations of Graham's algorithm that starts at~$H$ and yields the empty hypergraph. This proves that Graham's algorithm succeeds on~$H$. \end{proof} \begin{lemma} \label{lem:join-vor} If~$H$ is a hypergraph that has a join tree, then~$H$ is Vorob'ev regular. \end{lemma} \begin{proof} Let~$H$ be a hypergraph that has a join tree. By induction on the number of its hyperedges, we show that~$H$ is Vorob'ev regular. Let~$K$ be the downward closure of~$H$. If~$H$ has no hyperedges, then it is Vorob'ev regular. If~$H$ has just one hyperedge~$X$, then~$X$ is an extreme hyperedge of~$K$ since it yields no maximal intersections at all. It follows that~$K$ is regular since all the vertices of~$e$ are proper, so~$H$ is Vorob'ev regular. Assume now that~$H$ has more than one hyperedges. Let~$X$ be a leaf of the join tree of~$H$, and let~$Y$ be the unique hyperedge of~$H$ such that~$\{X,Y\}$ is an edge of the join tree. We consider the following two cases. \bigskip \noindent \textit{Case 1:} If~$X$ is not a maximal hyperedge, say~$X \subseteq Z$ for some other edge~$Z$ of~$H$, then~$X = X \cap Z \subseteq X \cap Y$ by the connectivity property of the join tree since the unique path from~$X$ to~$Z$ in the tree must pass through~$Y$. Hence, $X \subseteq Y$. Now, let~$H'$ be the hypergraph that results from deleting~$X$ from~$H$. Since~$X \subseteq Y$, the tree that results from trimming the leaf~$X$ from the join tree of~$H$ is a join tree of~$H'$. By induction hypothesis,~$H'$ is Vorob'ev regular. But~$X$ was not maximal in~$H$, so~$H$ and~$H'$ have the same downward closure~$K$, which shows that~$H$ is also Vorob'ev regular. \bigskip \noindent \textit{Case 2:} If~$X$ is a maximal hyperedge of~$H$, then we claim that~$X$ is an extreme hyperedge of~$K$. First,~$X$ is a maximal hyperedge of~$K$ by assumption. Second, we show that~$X$ yields maximal intersection with~$Y$. Indeed, if~$Z$ is a third hyperedge of~$H$, then the unique path from~$X$ to~$Z$ in the join tree goes through~$Y$ and, by the connectivity property of the join tree, every vertex in~$X \cap Z$ belongs to~$Z \cap Y$. So~$X \cap Y$ is not a proper subset of~$X \cap Z$. Next, we show that all maximal intersections of~$X$ are equal to the maximal intersection of~$X$ with~$Y$. Let~$Z$ be a third hyperedge of~$H$ and assume that~$X$ yields a maximal intersection with~$Z$. In particular, $X \cap Z$ is a not a proper subset of~$X \cap Y$. But the connectivity property of the join tree implies~$X \cap Z \subseteq X \cap Y$ since the unique path from~$X$ to~$Z$ in the join tree goes through~$Y$. Thus~$X \cap Z = X \cap Y$. We proved that~$X$ is an extreme hyperedge of~$K$. Now, let~$H'$ be the hypergraph that is obtained from~$H$ by deleting~$X$ and all the vertices that appeared only in~$X$. The normal subcomplex~$K'$ of~$K$ corresponding to~$X$ is the downward closure of~$H'$. If we trim the leaf~$X$ from the join tree of~$H$, we get a join tree of~$H'$ with one node less. It follows from the induction hypothesis that~$H'$ is Vorob'ev regular. Thus~$K'$ is Vorob'ev regular, and so is~$K$ since~$K'$ is a normal subcomplex of it. \end{proof} Lemma \ref{lem:vor-grah}, Lemma \ref{lem:join-vor}, and Theorem \ref{thm:BFMY} imply the following result. \begin{corollary} \label{cor:vorobev} Let $H$ be a hypergraph. The following statements are equivalent: \begin{enumerate} \itemsep=0pt \item[(a)] $H$ is an acyclic hypergraph. \item[(b)] $H$ is a Vorob'ev regular hypergraph. \end{enumerate} \end{corollary} Finally, by combining Theorem \ref{thm:BFMY}, Theorem \ref{thm:main}, and Corollary \ref{cor:vorobev}, we obtain the main result of this paper. \begin{theorem} \label{thm:BFMY-ext} Let $K$ be a positive semiring and let $H$ be a hypergraph. The following statements are equivalent: \begin{enumerate} \itemsep=0pt \item[(a)] $H$ is an acyclic hypergraph. \item[(b)] $H$ is a conformal and chordal hypergraph. \item[(c)] $H$ has the running intersection property. \item[(d)] $H$ has a join tree. \item[(e)] $H$ is accepted by Graham's algorithm. \item[(f)] $H$ is a Vorob'ev regular hypergraph. \item[(g)] $H$ has the \ltgc~for $K$-relations. \end{enumerate} \end{theorem} By applying Theorem~\ref{thm:BFMY-ext} with~$K$ set to the Boolean semiring~$\mathbb{B}$, we obtain the original Beeri-Fagin-Maier-Yannakakis Theorem~\ref{thm:BFMY}. It should be noted that while our proof of Theorem~\ref{thm:BFMY-ext} actually used Theorem~\ref{thm:BFMY} several times, all the uses of~Theorem~\ref{thm:BFMY} made were for arguing that the various syntactic characterizations of hypergraph acyclicity are equivalent. These equivalences can be shown directly without referring to any semantic notion, and for this reason we can say that our proof does \emph{not} rely on the semantic part of Theorem~\ref{thm:BFMY}. In fact, the main construction that we gave in the proof of Theorem~\ref{thm:main} appears to be new and gives an alternative proof of the semantic part of Theorem~\ref{thm:BFMY}: If~$H$ has \ltgc~for ordinary relations, then~$H$ is acyclic. While still different, the construction we gave in the proof of Theorem~\ref{thm:main} is closer to Vorob'ev's proof of his theorem from~\cite{vorob1962consistent} than to the proof of the Theorem~\ref{thm:BFMY} from~\cite{BeeriFaginMaierYannakakis1983}. We discuss this next. \subsection{Consistency of Probability Distributions and Vorob'ev's Theorem} In the rest of this section, we study the consistency of~$K$-relations when the semiring~$K$ is~$\mathbb{R}^{\geq 0}$, i.e., the set of non-negative real numbers with the standard addition and multiplication operations. We place the focus on probability distributions, which, to recall, are nothing but the~$\mathbb{R}^{\geq 0}$-relations~$T$ that satisfy the normalization constraint \begin{equation} T[\emptyset] = \sum_{t \in T'} T(t) = 1. \label{eqn:normalization} \end{equation} Our goal for the rest of this section is to show that the main result of Vorob'ev from \cite{vorob1962consistent} follows from our general result Theorem~\ref{thm:BFMY-ext} about arbitrary positive semirings. \paragraph{Consistency of Probability Distributions} Following~\cite{vorob1962consistent}, we say that two probability distributions~$P(X)$ and~$Q(Y)$ are consistent if there exists a probability distribution~$T(XY)$ such that~$T[X]=P$ and~$T[Y]=Q$. A collection~$P_1(X_1),\ldots,P_m(X_m)$ of probability distributions is~\emph{globally consistent} if there exists a probability distribution~$P(X_1 \cdots X_m)$ such that~$P[X_i] = P_i$ holds for every~$i \in [m]$. The collection is called~\emph{pairwise consistent} if any two distributions in the collection are consistent. We start by showing that, when the probability distributions are presented as~$\mathbb{R}^{\geq 0}$-relations that satisfy~\eqref{eqn:normalization}, this classical notion of consistency of probability distributions coincides with the notion of consistency that we have been studying in this paper. The following basic fact was observed already in~Section~\ref{sec:valuedrelations}. It says that, as~$\mathbb{R}^{\geq 0}$-relations, the probability distributions are the canonical representatives of their equivalence classes under~$\equiv$. We give an even shorter proof in a slightly different language. \begin{lemma} \label{lem:loosevsstrict} For every two probability distributions~$R(X)$ and~$S(X)$ over the same set of attributes~$X$, it holds that~$R \equiv S$ if and only if~$R = S$. \end{lemma} \begin{proof} The \emph{if} direction is trivial. For the \emph{only if} direction, let~$a$ and~$b$ be positive reals such that~$aR(t) = bS(t)$ holds for every~$X$-tuple $t$. Then~$a = aR[\emptyset] = bS[\emptyset] = b$, where the first follows from~\eqref{eqn:normalization}, the second follows from~\eqref{eqn:marginal} and the choice of~$a$ and~$b$, and the third follows from~\eqref{eqn:normalization}. Dividing through by~$a = b \not= 0$, it follows that~$R(t) = S(t)$ holds for every~$X$-tuple~$t$. \end{proof} The next lemma states that any~$\mathbb{R}^{\geq 0}$-relation that witnesses the consistency of a collection of probability distributions is itself a probability distribution. \begin{lemma} \label{lem:closure} For every collection~$R_1,\ldots,R_m$ of probability distributions and every~$\mathbb{R}^{\geq 0}$-relation~$R$, if~$R$ witnesses the global consistency of~$R_1,\ldots,R_m$, then~$R$ is itself a probability distribution. \end{lemma} \begin{proof} For any~$i \in [m]$ we have~$R[X_i] = R_i$, where~$X_i$ is the set of attributes of~$R_i$. By Part~3 of Lemma~\ref{lem:easyfacts1} we have~$R[\emptyset] = R[X_i][\emptyset] = R_i[\emptyset] = 1$, for any~$i \in [m]$; i.e.,~$R$ satisfies~\eqref{eqn:normalization} and is hence a probability distribution. \end{proof} In view of Lemma~\ref{lem:loosevsstrict} and~\ref{lem:closure}, the classical notions of consistency of probability distributions coincides with the notions of consistency of~$K$-relations that we have been studying in this paper when~$K = \mathbb{R}^{\geq 0}$. We are ready to state the \ltgc~for probability distributions. \paragraph{Vorob'ev's Theorem} Let~$H$ be a hypergraph and let~$X_1,\ldots,X_m$ be a listing of all its hyperedges. We say that~$H$ has the \emph{\ltgc~for probability distributions} if every pairwise consistent collection of probability distributions~$P_1(X_1),\ldots,P_m(X_m)$ is globally consistent. One of the main motivations for writing this paper was to obtain a common generalization of the result of Beeri, Fagin, Maier, and Yannakakis stated in Theorem~\ref{thm:BFMY} and the result of~Vorob'ev stated next. \begin{theorem}[Theorem 4.2 in \cite{vorob1962consistent}] \label{thm:vorothm} Let $H$ be a hypergraph. The following statements are equivalent: \begin{enumerate} \itemsep=0pt \item[(a)] $H$ is a Vorob'ev regular hypergraph. \item[(b)] $H$ has the local-to-global consistency property for probability distributions. \end{enumerate} \end{theorem} \begin{proof} By~Lemmas~\ref{lem:loosevsstrict} and~\ref{lem:closure}, conditions~(b) in this Theorem and~(g) in Theorem~\ref{thm:BFMY-ext} for~$K = \mathbb{R}^{\geq 0}$ are equivalent. The result now follows from Theorem~\ref{thm:BFMY-ext} for $K = \mathbb{R}^{\geq 0}$. \end{proof} Some words on the differences between our proof of Theorem~\ref{thm:vorothm} and Vorob'ev's proof of Theorem~4.2 in \cite{vorob1962consistent} are in order. In the direction~(a) implies~(b), except for the minor differences that stem from the use of Lemma~\ref{lem:vor-grah}, our proof is basically the same as Vorob'ev's. The main construct in that proof is the operation on probability distributions that we denoted~$\Join_{\mathrm{P}}$ in equation~\eqref{eqn:prop1}, which appears with different notation as equation~(21) in page 156 of~\cite{vorob1962consistent}. In the direction~(b) implies~(a), again except for the minor differences that stem from the use of Lemma~\ref{lem:join-vor}, our proof has some important similarities with Vorob'ev's, but also one important difference. The similarities lie in the structure of the argument. Vorob'ev first proves that the class of hypergraphs that have the \ltgc~for probability distributions is the \emph{unique} class of hypergraphs that contains those, satisfies certain closure properties, and excludes two concrete families of hypergraphs, that he calls~$\{G_n\}$ and~$\{Z_n\}$ in Theorem~2.2 in page~152 of~\cite{vorob1962consistent}. This characterization we also prove through the combination of Lemmas~\ref{lem:preserv1} and~\ref{lem:preserv2}, which stand for the closure properties, Lemmas~\ref{lem:characconf} and~\ref{lem:characchord}, whose featuring hypergraphs are precisely the hypergraphs~$G_n$ and~$Z_n$ from~\cite{vorob1962consistent}, and the construction~$C(H;K)$ through Case~1 for~$H=G_n$, and Case~2 for~$H=Z_n$, in the proof of Theorem~\ref{thm:main}. Another similarity lies in the way we handle~$Z_n$: both proofs build a cycle of~$K$-relations that implement equality constraints except for one~$K$-relation in the cycle that implements an inequality constraint. The important difference lies in the way we handle~$G_n$. Vorob'ev's proof is a linear-algebraic argument over Euclidean space that requires some non-trivial calculations, while our argument is more combinatorial and arguably simpler as it relies on basic modular arithmetic and the totally obvious fact that~$0 \not\equiv 1$ mod~$d$, for~$d \geq 2$. \section{Concluding Remarks} We conclude by discussing some open problems and directions for future research. \begin{itemize} \item Beeri et al.\ \cite{BeeriFaginMaierYannakakis1983} showed that hypergraph acyclicity is also equivalent to certain semantic conditions other than the \ltgc~for ordinary relations. The existence of a \emph{full reducer} is arguably the most well known and useful such semantic property (see also \cite{DBLP:books/cs/Maier83,DBLP:books/cs/Ullman88}). By definition, a \emph{full reducer} of a hypergraph~$H$ with~$X_1,\ldots,X_m$ as its hyperedges is a program consisting of a finite sequence of semijoin statements of the form~$R_i := R_i\ltimes R_j$ such that if this program is given a collection~$R_1(X_1),\ldots,R_m(X_m)$ of ordinary relations as input, then the output is a collection of globally consistent ordinary relations. It remains an open problem to define a suitable semijoin operation for~$K$-relations and prove (or disprove) that for every positive semiring~$K$, a hypergraph~$H$ is acyclic if and only if~$H$ has a full reducer for~$K$-relations. One of the technical difficulties is that the join operation on two~$K$-relations introduced and studied here is not, in general, associative (in fact, as seen earlier, it is not associative even when~$K$ is the bag semiring of non-negative integers). \item The notion of consistency studied here is based on the notion of equivalence~$\equiv$ of two~$K$-relations. One could define the notion of \emph{strict consistency}, where two~$K$-relations~$R(X)$ and~$S(Y)$ are \emph{strictly consistent} if there is a $K$-relation $T(XY)$ such that $T[X] = R$ and $T[Y]=S$; from there, one can define the notion of \emph{local-to-global strict consistency property} for~$K$-relations. The question is: do the main results presented here hold for strict consistency? In particular, is hypergraph acyclicity equivalent to the local-to-global strict consistency property for~$K$-relations? The crucial obstacle in following the approach we adopted here is that if~$K$ is not a semifield, then it is not clear how to define a join operation on two~$K$-relations that witnesses their strict consistency. Actually, there are bags~$R$ and~$S$ that are strictly consistent, but every bag~$T$ that witnesses their strict consistency (as defined above) has the property that its support~$T'$ is \emph{strictly contained} in the ordinary join~$R' \Join S'$ of the supports~$R'$ and~$S'$. This is in sharp contrast with our join operation, as shown in~Lemma~\ref{lem:supportsjoin}. The simplest such example is the pair of bags~$R(AB) = \{ {12}:{1},\; {22}:{1} \}$ and~$S(BC) = \{ {21}:{1},\; {22}:{1} \}$, whose strict consistency is witnessed by the bags~$T_1(ABC) = \{ {122}:{1},\; {221}:{1} \}$ and~$T_2(ABC) = \{ {121}:{1},\; {222}:{1} \}$, but, as one can easily verify, no other bag. \item Positive semirings have been used in different areas of mathematics and computer science (see, e.g., \cite{golan2013semirings,gondran2008graphs}). In particular, the min-plus semiring has been used in the analysis of dynamic programming algorithms, while the Viterbi semiring has been used in the study of statistical models. It would be interesting to investigate potential applications of the results reported here to semirings other than the Boolean semiring and the semiring of the non-negative real numbers with the standard arithmetic operations. \end{itemize} \paragraph{Acknowledgments} Albert Atserias was partially funded by European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme, grant agreement ERC-2014-CoG 648276 (AUTAR), and by MICCIN grant PID2019-109137GB-C22 (PROOFS). Phokion Kolaitis was partially supported by NSF Grant IIS-1814152. \newpage \bibliographystyle{alpha}
{'timestamp': '2020-09-22T02:18:56', 'yymm': '2009', 'arxiv_id': '2009.09488', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09488'}
arxiv
\section{Introduction} Secure Multi-Party Computation (SMC) \cite{yao1982protocols,shamir1979share} is a paradigm which enables several parties to compute a public function of their own private inputs without ever disclosing their private input. Secure protocols that allow participants to compute such functions require them to share specific pieces of information through different rounds of communication intertwined with local computations, with the aim of guaranteeing the concealment of private values. Specifically, they ensure that no information flows about the private inputs, apart from that which can be inferred from the intended public output. From that notion of security, it follows that the output of any sensible secure computation will reveal \emph{some} information about the private inputs. Although cryptographic protocols have been extensively studied and optimised in the past decades in order to improve their speed and efficiency, this leakage is considered \emph{inevitable} and is commonly referred to as the \emph{acceptable leakage} in the literature, and has thus been largely ignored so far \cite{lindell2009secure,orlandi2011multiparty,% cramer2015secure,aumann2007security}. We believe however, that this is a questionable position and that it is of interest~--~and of importance~--~to raise participants' awareness of this leakage before they decide to engage in an SMC protocol, and to offer them the opportunity to gauge, by themselves, the risk that they would run by entering a computation, rather than imposing this leakage on them. More precisely, we believe that an SMC participant may be concerned by the following questions: is this leakage really acceptable? Is not this statement subjective? Are there objective ways of assessing the acceptability of such leakage, that each person could interpret based on her own expectations? Finally, is this leakage really inevitable? Under which conditions? Some recent works have aimed at proposing some possible answers to those questions. A framework based on Quantitative Information Flow allows one to quantify this acceptable leakage, where the inputs' privacy is evaluated via general entropy-based measures \cite{ah2017secure,ah2018optimal,ah2018optimalArchive}. These measures allow participants to have an objective way of measuring the risks that taking part in a computation would present. These entropy-based measured are generic and can be parametrised so as to capture individual privacy requirements and expectations. Based on this model, different randomising techniques have been proposed in order to enhance participants' privacy while guaranteeing high utility \cite{ah2018optimal,ah2020protecting}. The principle behind those methods is to select a notion of entropy and measure the inputs' privacy via the conditional entropy of an input given the knowledge of the public output. Evaluating the value of those entropy measures requires to browse the whole input space and yields a complexity that is linear in the size of the total input domain. Their combinatorial essence thus does not allow those methods to scale to large inputs spaces. It has been shown that this complexity can be reduced for particular theoretical cases such as for three-party affine computations \cite{ah2019scalable,ah2019scalableArchive}, which allows those methods to scale to large input spaces. Being able to apply these methods to real-world problem requires the possibility to adapt them to real-world functions, and to large input spaces. The aim of this work is to focus on a particular practical application of SMC, namely the \emph{digital goods auctions}, and to scale those privacy analyses to arbitrarily large input spaces. More precisely, we aim at reducing the complexity of those analyses by deriving a closed-form formula for the input's posterior min-entropy in the case of two-party auctions, thus providing a way for assessing the acceptable leakage in two party auctions for any input size. We then notice that deriving a closed-form formula for this entropy is more involved in the presence of three parties. However, as the generic empirical methods are able to compute this entropy for small input spaces, we are mostly interested in evaluating this entropy for large input spaces. For three-party auctions, we thus focus on deriving an asymptotic development of this entropy for large input spaces. Finally, we provide supportive experimental evidence that help us to formulate a conjecture on the asymptotic behaviour of this entropy for large input spaces with any number of parties. This paper is outlined a follows. We discuss some related works in Section \ref{sec:related}. We introduce relevant background in Section \ref{sec:back}. The digital goods auctions are presented in Section \ref{sec:digital}. Section \ref{sec:two} focuses on two-party auctions while three-party auctions are tackled in Section \ref{auction:sec:three}. Our conjecture is supported and formulated in Section \ref{auction:sec:multi}. We discuss our work in Section \ref{sec:discu} and conclude in Section \ref{sec:conclu}. \section{Related Works} \label{sec:related} In this section, we present some relevant domains of cryptography and discuss their relation to our work. \ourparagraph{Secure Multi-party Computation} Secure Multi-party Computation \cite{yao1986generate,yao1982protocols,shamir1979share,% rabin1989verifiable,ben1988completeness,chaum1988multiparty} is a domain of Cryptography that provides advanced protocols which enable several participants to compute a public function of their own private inputs without having to rely on any other trusted third party or any external authority. Those protocols enable the participants to compute a function in a decentralised manner, while ensuring that no information leaks about the private inputs, other than what can be inferred from the public output. The commonly called ``acceptable leakage'' which is further studied in this paper, is the information that can be inferred by an attacker about the private inputs given the knowledge of the public output alone. Secure Multi-Party Computation is not the only domain that is subject to an acceptable leakage. In particular, the results of our work are also applicable to other fields or scenarios that aim at protecting the inputs' privacy and that involve the opening of a public output, such as outsourced computation where a trusted third party is privately sent all the inputs and returns the public output as unique piece of information, or trusted computing where the parties input their secret data into hardware security modules, which then ensure that no unintended information will be accessible to the other parties. We emphasise the fact that our work focuses on the acceptable leakage that may occur in SMC, trusted computing or outsourced computations, and is thus largely orthogonal to the technicalities that SMC protocols may involve. \ourparagraph{Differential Privacy} Differential Privacy (DP) \cite{dwork2008differential,dwork2014algorithmic} formalises privacy concerns and introduces techniques that provide users of a database with the assurance that their personal details will not have a significant impact on the output of the queries performed on the database. More precisely, it proposes mechanisms which ensure that the outcome of the queries performed on two databases differing in at most one element will be statistically indistinguishable. Moreover, minimising the distortion of the outcome of the queries while ensuring privacy is an important trade-off that governs DP. Although DP is particularly suited for quantifying~--~and enhancing~--~privacy in statistical computations involving a large number of parties, its usefulness diminishes when a small number of parties are involved in the computation, or when the output of the computation is meant to be highly dependent on every input value. In a vote or in an auction for example, it would not be sensible to evaluate the privacy of inputs by how independent they are of the output. In general multi-party computations, independence between the output and the inputs is not a desirable property, and we thus need a more meaningful way of quantifying the inputs' privacy, which we discuss in the next paragraph. \ourparagraph{Quantitative Information Flow} The purpose of Quantitative Information Flow (QIF) \cite{smith2009foundations,malacaria2015algebraic} is to provide frameworks and techniques based on information theory and probability theory for measuring the amount of information that leaks from a secret. Different mathematical concepts have emerged in order to convey varied and precise information about a secret: Shannon entropy \cite{BLTJ:BLTJ1338} reflects the minimum number of binary questions required to recover a secret on average, while the min-entropy is an indicator of the probability to guess a secret in one try \cite{smith2011quantifying,cachin1997entropy,smith2009foundations}. Richer measures such as R\'enyi entropy \cite{renyi1961measures} and the $g$-entropy \cite{m2012measuring} have been introduced in order to quantify some specific properties of a secret. Generalised entropies have been proposed in order to unify those different concepts \cite{ah2018optimal,khouzani2016relative}. In this work, we will measure the information gained by an attacker by means of min-entropy, which is used extensively in Cryptography in order to quantify the vulnerability of a secret. Although we selected the conditional min-entropy in order to propose a measure of privacy that can be meaningful in SMC, we believe that it would be interesting to extend and compare our approach to other notions of entropy and possibly other methods for quantifying privacy. \section{Background} \label{sec:back} Let us now present the mathematical model \cite{ah2017secure,ah2018optimal} that we will use to study the notion of privacy in SMC. Let $n$ be a positive integer. Let $x_1, \dots, x_n$ be $n$ integers, belonging to $n$ different parties $P_1, \dots, P_n$ respectively. Let us assume that these parties wish to enter the secure computation of an $n$-ary function $f$ and to compute its output $o = f(x_1, \dots, x_n)$. We are interested in studying the information that opening the output reveals about private inputs. More precisely, let us assume that we wish to study the information that leaks about private input $x_j$. We call it \emph{targeted} input, while the other inputs are called \emph{spectators}' inputs. To this end, we consider each input $x_i$ as a random variable $X_i$ taking values in a domain $D_i$. The output is also assigned a random variable $O$ defined as a composition of random variables $O = f(X_1, \dots, X_n)$. Its domain is denoted by $D_O$. Then the privacy of targeted input $X_j$ will be quantified as the conditional min-entropy of $X_j$ given $O$, defined as: \[ \HH(X_j \mid O) = - \log \V(X_j \mid O) \] where the conditional vulnerability $\V(X_j \mid O)$ is defined as: \begin{equation} \label{eq:vuln_gen} \V(X_j \mid O) = \sum_{o \in D_O} p(O=o) \cdot \max_{x_j \in D_j} p(X_j=x_j\mid O=o) \end{equation} For clarity purposes, we will abuse notation and omit the domains in the summations, and omit the random variable name in the probability notations, when they can be obviously inferred from context. This way, the above vulnerability rewrites as \( \V(X_j \mid O) = \sum_{o} p(o) \cdot \max_{x_j} p(x_j\mid o) \) . We now formulate an assumption that will hold throughout the paper. \begin{assumption} \label{ass:uni} Throughout the paper, we assume that the inputs are uniformly distributed over $\lr{1}{m}$ where $m$ is a positive integer, and where $\lr{1}{m}$ denotes $\{1, \dots, m\}$. \end{assumption} By virtue of Bayes' theorem and Assumption \ref{ass:uni}, the vulnerability from Equation (\ref{eq:vuln_gen}) can be rewritten as: \begin{align} \V &= \sum_o \max_x p(x) \cdot p(o \mid x) \nonumber\\ &= \frac{1}{m} \sum_o \max_x p(o \mid x) \label{auction:eq:vuln} \end{align} We recall that all the values of $p(o \mid x)$ can be computed in $\mathcal{O}(m^n)$, the $\max$ can be computed in $\mathcal{O}(m)$ and the sum in $\mathcal{O}(m^n)$, which quickly becomes intractable as the input size $m$ grows. We thus seek a closed-form formula for $\HH(X \mid O)$. In the next section, we present the function $f$ that is considered in this paper. Sections \ref{sec:two} and \ref{auction:sec:three} then focus on simplifying the expression of $\V$ for this precise function $f$. More precisely, we derive a closed-form formula for $\V$ for two-party auctions. Following the same approach, we notice that deriving an \emph{exact} formula would be more involved in the three-party case. However, our main objective is to be able to provide analyses that scale to \emph{large} input spaces, since empirical, combinatorial, analyses are already able to compute exact values of $\V$ for \emph{small} input spaces~--~and fail to do so for large ones. We then decide to focus on deriving the \emph{asymptotic} behaviour of $\V$ for large values of $m$ in three-party auctions. \section{Digital Goods Auctions} \label{sec:digital} Auctions are part of the practical use cases that can benefit from the security properties provided by Secure Multi-Party Computation. In fact, and as an aside, one of the first practical applications of SMC implemented on a large scale was an auction between several Danish farmers and a producer \cite{bogetoft2009secure}. Indeed, depending on the setting and the rules of the auction, participants may be interested in keeping their bids private in order to protect their economic interests. Resorting to SMC might also enhance fairness between participants and may provide other reassuring guarantees that may be lacking in a traditional auction. A non-exhaustive list of such guarantees are: \begin{itemize} \item The confidentiality of the bids protects the participants' economic position from both the auctioneer and the other participants. \item Protocols that are secure under active adversaries may guarantee the participants that the result has not been falsified. In comparison with traditional methods, this prevents the polling authority from being involved in any kind of corruption. \item In some cases, SMC may offer the benefit that bids from different participants are taken into account simultaneously, whereas some traditional auction types may not. \end{itemize} Although SMC provides the participants with a way of entering all their inputs once and simultaneously, and importantly, without revealing their bids, we know that some information will leak about private bids. In this work, we study a particular case of auctions, known as \emph{digital goods auctions}. This application has also been chosen as a case study in influential papers on Differential Privacy such as McSherry and Talwar's paper on the exponential mechanism \cite{mcsherry2007mechanism}. Let us introduce the principle of a digital goods auction, and explain the different pieces of private information that are being manipulated and the public information that is revealed during such auctions. A digital goods auction involves one seller and $n$ buyers. A seller has an unlimited supply of a certain item or good, that she wants to sell. Each buyer will either buy the item, or refuse to buy it. In particular, a buyer will not buy the item several times. Each buyer $P_i$ will bid a price $x_i$, which is the maximal price that he is willing to pay to buy the item. If the sales price $p$ of the item is greater than $x_i$, then buyer $P_i$ will not buy the item. If $p$ is not greater than $x_i$, then $P_i$ will pay the price $p$ to get the item, which will turn into benefits for the seller. We assume that the seller did not pay anything to acquire the items, so that her total \emph{benefits}~--~also referred to as \emph{budget} or \emph{profit}~--~will equal $pb$ where $p$ is the sales price of the item and $b$ is the number of buyers who can afford it, i.e. $b = |\{ i \in \lr{1}{n} \mid x_i \geq p \}|$. The aim of the auction is to determine the optimal sales price of the item that maximises the seller's benefits. As an aside, if the seller's profits can be maximised with different values of $p$, then we define the auction as retaining the lowest value of $p$, as it will satisfy more participants. The computation of the optimal price of the item can be represented as the following function $f$ described in Algorithm \ref{auction:algo:f}: {\small \begin{algorithm} \hspace*{\algorithmicindent} \textbf{Inputs:} $x_1, \dots, x_n \in \lr{1}{m}$ \\ \hspace*{\algorithmicindent} \textbf{Output:} Auction sales price $p \in \{x_1, \dots, x_n\}$ \vspace{1.5mm} \begin{algorithmic}[1] \Function{$f$}{$x_1, \dots, x_n$} \State sort $x_i$'s in descending order such that $x_1 \geq \dots \geq x_n$ \State \( k \gets \argmax_j j \cdot x_j \) (choose largest possible $k$) \State \Return $x_k$ \EndFunction \end{algorithmic} \caption{Multi-party auction function $f$} \label{auction:algo:f} \end{algorithm} } Choosing the largest possible $k$ means that if the same budget is attainable with different sales prices, we choose the one which enables more participants to buy, e.g. $f(1, 1, 4, 1) = 1$ where the maximal budget can equally be achieved with a sales price of $1$ or $4$, but the former allows $4$ participants to buy whereas the latter allows only one. It is worth noting that the output $o = f(x_1, \dots, x_n)$ necessarily equals one of the input values $x_i$. We can show that the price is not optimal otherwise. Naturally, the buyers' bids $x_i$ constitute private pieces of information that the buyers do not wish to reveal: neither the other buyers nor the seller should be able to learn any information about a particular bid $x_i$ before the opening of the final price $p$. In order to guarantee such a level of privacy, the participants can for example enter an SMC protocol, or resort to a Trusted Execution Environment. On the other hand, the sales price $p$ is the information that is intended to be computed and to be made public. As such, it inevitably reveals some information about the private bids, which is commonly referred to as the acceptable leakage in the SMC literature. One may wish to gauge this acceptable leakage, and in particular may wonder whether this leakage is tolerable in a two-party auction. The aim of the work reported in this paper is to quantify the information that flows about the private bids when the result of the auction~--~i.e. the sales price~--~is revealed. More precisely, we aim at deriving a method for quantifying the bids' privacy that is \emph{scalable} to arbitrarily large input spaces, which previous generic methods were not able to accommodate. Precisely, we now aim at simplifying the expression of $p(o \mid x)$ from Equation (\ref{auction:eq:vuln}), where $x$ represents one targeted input in order to be able to compute it for large values of $m$. \section{Two-Party Auctions} \label{sec:two} In a two-party auction, the function $f$ can be simplified. It is straightforward to see that the sorting procedure and the $\argmax$ function can be written as in the following Algorithm \ref{auction:algo:f2}. {\small \begin{algorithm} \hspace*{\algorithmicindent} \textbf{Inputs:} $x, y \in \lr{1}{m}$ \\ \hspace*{\algorithmicindent} \textbf{Output:} Sales price $p \in \{x, y\}$ \vspace{1.5mm} \begin{algorithmic}[1] \Function{$f$}{$x, y$} \If {$x > y$} { \If {$x > 2y$} \Return $x$ \Else \phantom{\textbf{if} $x > 2y$ \textbf{t}} \Return $y$ \EndIf } \Else ~\comment{$x \leq y$} \If {$y > 2x$} \Return $y$ \Else \phantom{\textbf{if} $x > 2y$ \textbf{t}} \Return $x$ \EndIf \EndIf \EndFunction \end{algorithmic} \caption{Two-party auction function $f$} \label{auction:algo:f2} \end{algorithm} } In order to illustrate and reason about the results of such a function, let us assume that $m=9$ and let us plot the function's outputs on the 2-dimensional array in Table \ref{auction:table:foutputs}. \begin{table} \caption{Outputs of the two-party auction with maximal input $m=9$. } \label{auction:table:foutputs} \ \begin{array}{c|ccccccccc} $\diagbox[width=2.5em,height=2.5em]{$x$}{$y$}$ & 1 & 2 & 3&4&5&6&7&8&9 \\ \hline 1 & 1 & 1 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ 2 & 1 & 2 & 2 & 2 & 5 & 6 & 7 & 8 & 9 \\ 3 & 3 & 2 & 3 & 3 & 3 & 3 & 7 & 8 & 9 \\ 4 & 4 & 2 & 3 & 4 & 4 & 4 & 4 & 4 & 9 \\ 5 & 5 & 5 & 3 & 4 & 5 & 5 & 5 & 5 & 5 \\ 6 & 6 & 6 & 3 & 4 & 5 & 6 & 6 & 6 & 6 \\ 7 & 7 & 7 & 7 & 4 & 5 & 6 & 7 & 7 & 7 \\ 8 & 8 & 8 & 8 & 4 & 5 & 6 & 7 & 8 & 8 \\ 9 & 9 & 9 & 9 & 9 & 5 & 6 & 7 & 8 & 9 \\ \end{array} \] \end{table} Let us now look at the quantity that we wish to compute. In order to compute $\HH(X\mid O)$, we will compute $\max_x p(o\mid x)$ for each output $o$. To do so, we argue that for each output $o$, we have $\max_x p(o\mid x) = p(O=o \mid X=o)$. Indeed, for fixed values of $o$ and $x$, we have: \begin{align*} p(o \mid x) &= \sum_{\substack{y \\ f(x, y) = o}} p(y) \\ &= \sum_{\substack{y \\ f(x, y) = o}} \frac{1}{m} \end{align*} since the inputs are uniformly distributed. Moreover, if $x \neq o$, then this sum can contain \emph{at most} one summand which would correspond to the case where $y=o$, since the output $o$ must equal one of the inputs. On the contrary, if $x=o$ then the sum contains \emph{at least} one summand which corresponds to the case where $y=o$, again because the output must equal one of the inputs. For that reason, we have: \[ \max_x p(o \mid x) = p(o\mid X=o) \] and thus: \begin{align} \V &= \frac{1}{m} \sum_o p(o\mid X = o) \nonumber \\ &= \frac{1}{m^2} \sum_o |\{ y \mid f(o, y) = o \}| \label{eq:vuln_two} \end{align} where $|\cdot|$ denotes the cardinality of a set. We can now illustrate in Table \ref{auction:table:colour} the result of that sum by highlighting in colour all the cells that satisfy the condition $f(o, y) = o$. We gather all the inputs satisfying this condition in a set that we define as $S = \{ (x, y) \in \lr{1}{m}^2 \mid f(x, y) = x \}$. Red cells correspond to the cases where $x>y$ while blue cells to those where $x \leq y$: \begin{table} \caption{Enumerating set $S$ that contains all the input combinations $(x,y)$ that satisfy $f(x, y) = x$. } \centering \vspace{.4\baselineskip} \subfigure[Couloured cells highlight elements of $S$. Red cells correspond to cases where $x > y$. Blue cells include cases where $x \leq y$. ]{\label{auction:table:colour} $ \begin{array}{c|ccccccccc} \multicolumn{10}{c}{} \vspace{-2mm} \\ $\diagbox[width=2.5em,height=2.5em]{$x$}{$y$}$ & 1 & 2 & 3&4&5&6&7&8&9 \\ \hline 1 & \y 1 & \y 1 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ 2 & 1 & \y 2 & \y 2 & \y 2 & 5 & 6 & 7 & 8 & 9 \\ 3 & \cellcolor{red!50} 3 & 2 & \y 3 & \y 3 & \y 3 & \y 3 & 7 & 8 & 9 \\ 4 & \cellcolor{red!50} 4 & 2 & 3 & \y 4 & \y 4 & \y 4 & \y 4 & \y 4 & 9 \\ 5 & \cellcolor{red!50} 5 & \cellcolor{red!50} 5 & 3 & 4 & \y 5 & \y 5 & \y 5 & \y 5 & \y 5 \\ 6 & \cellcolor{red!50} 6 & \cellcolor{red!50} 6 & 3 & 4 & 5 & \y 6 & \y 6 & \y 6 & \y 6 \\ 7 & \cellcolor{red!50} 7 & \cellcolor{red!50} 7 & \cellcolor{red!50} 7 & 4 & 5 & 6 & \y 7 & \y 7 & \y 7 \\ 8 & \cellcolor{red!50} 8 & \cellcolor{red!50} 8 & \cellcolor{red!50} 8 & 4 & 5 & 6 & 7 & \y 8 & \y 8 \\ 9 & \cellcolor{red!50} 9 & \cellcolor{red!50} 9 & \cellcolor{red!50} 9 & \cellcolor{red!50} 9 & 5 & 6 & 7 & 8 & \y 9 \\ \end{array} $ } \hspace{1.5cm} \subfigure[Blue cells have been transposed from Table \ref{auction:table:colour} in order to surface an obvious expression for the cardinality $|S|$. ]{\label{auction:table:tranpose} $ \begin{array}{c|ccccccccc} \multicolumn{10}{c}{} \vspace{-2mm} \\ $\diagbox[width=2.5em,height=2.5em]{$x$}{$y$}$ & 1 & 2 & 3&4&5&6&7&8&9 \\ \hline 1 & \y 1 & 1 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ 2 & \y 1 & \y 2 & 2 & 2 & 5 & 6 & 7 & 8 & 9 \\ 3 & \cellcolor{red!50} 3 & \y 2 & \y 3 & 3 & 3 & 3 & 7 & 8 & 9 \\ 4 & \cellcolor{red!50} 4 & \y 2 & \y 3 & \y 4 & 4 & 4 & 4 & 4 & 9 \\ 5 & \cellcolor{red!50} 5 & \cellcolor{red!50} 5 & \y 3 & \y 4 & \y 5 & 5 & 5 & 5 & 5 \\ 6 & \cellcolor{red!50} 6 & \cellcolor{red!50} 6 & \y 3 & \y 4 & \y 5 & \y 6 & 6 & 6 & 6 \\ 7 & \cellcolor{red!50} 7 & \cellcolor{red!50} 7 & \cellcolor{red!50} 7 & \y 4 & \y 5 & \y 6 & \y 7 & 7 & 7 \\ 8 & \cellcolor{red!50} 8 & \cellcolor{red!50} 8 & \cellcolor{red!50} 8 & \y 4 & \y 5 & \y 6 & \y 7 & \y 8 & 8 \\ 9 & \cellcolor{red!50} 9 & \cellcolor{red!50} 9 & \cellcolor{red!50} 9 & \cellcolor{red!50} 9 & \y 5 & \y 6 & \y 7 & \y 8 & \y 9 \\ \end{array} $} \end{table} The aim is thus to compute the number of coloured cells, which equals the desired values of $\sum_o |\{ y \mid f(o, y) = o \}|$. To do this, we present the following geometric interpretation. Let us ``transpose'' all the cells highlighted in blue. By transposing a cell at location $(i, j)$, we mean discolouring this cell and then colouring its symmetric one at location $(j, i)$. We obtain the array depicted in Table \ref{auction:table:tranpose}. We note that no two cells are coloured with two different colours. From that we can see that: \begin{align*} \sum_o |\{ y \mid f(o, y) = o \}| &= \sum_{k=1}^m k \end{align*} which leads us to the following result. \begin{theorem} \label{auction:thm:h2} In a two-party auction, where the inputs are uniformly distributed over $\lr{1}{m}$, we have: \begin{align*} \HH(X \mid O) &= - \log \frac{m+1}{2m} \end{align*} \end{theorem} \begin{proof} As we argued in Equation (\ref{eq:vuln_two}), we know that: \begin{align*} \V &= \frac{1}{m^2} \sum_o |\{ y \mid f(o, y) = o \}| \end{align*} It thus suffices to compute the cardinality of the following set $S$: \[ S = \{ (x, y) \in \lr{1}{m}^2 \mid f(x, y) = x \} \] Let us express $S$ as the disjoint union of the following two subsets: \begin{align*} S_1 &= \{ (x, y) \in \lr{1}{m}^2 \mid f(x, y) = x \wedge x > y \} \\ S_2 &= \{ (x, y) \in \lr{1}{m}^2 \mid f(x, y) = x \wedge x \leq y \} \end{align*} We note that $S_1$ corresponds to the area highlighted in red in Table \ref{auction:table:colour}, and $S_2$ corresponds to the blue area. The additional ordering on $x$ and $y$ ensures that $\{S_1, S_2\}$ forms a partition of $S$ and thus $|S| = |S_1|+|S_2|$. We can swap both coordinates of the elements of $S_2$ without altering its cardinality. We thus have $|S_2| = |S_2'|$ where we define $S_2'$ as follows: \begin{align*} S_2' &= \{ (x, y) \in \lr{1}{m}^2 \mid f(y, x) = y \wedge y \leq x \} \\ &= \{ (x, y) \in \lr{1}{m}^2 \mid 2y \geq x \wedge y \leq x \} \end{align*} On the other hand, we have: \[ S_1 = \{ (x, y) \in \lr{1}{m}^2 \mid x > 2y \wedge y \leq x \} \\ \] We can see that $S_1$ and $S_2'$ are disjoint and thus $|S_1| + |S_2'| = |S_1 \cup S_2'|$. This union can be rewritten as: \begin{align*} S_1 \cup S_2' &= \{ (x, y) \in \lr{1}{m}^2 \mid (x > 2y \vee 2y \geq x) \wedge y \leq x \} \\ &= \{ (x, y) \in \lr{1}{m}^2 \mid y \leq x \} \end{align*} from which we can infer that \begin{align*} |S_1 \cup S_2'| &= \frac{m(m+1)}{2} \end{align*} and thus: \begin{align*} \HH(X \mid O) &= - \log \frac{m(m+1)}{2m^2} \\ &= - \log \frac{m+1}{2m} \end{align*} \end{proof} We also checked that this formula is experimentally validated by our programs computing $\HH(X \mid O)$ empirically. As we are particularly interested in studying the behaviour of $\HH(X \mid O)$ for large input spaces, we formulate the following corollary. \begin{corollary} \label{auction:coro:2} When $m$ tends towards infinity, $\HH(X \mid O)$ converges and: \[ \lim_{m \to \infty} \HH(X \mid O) = \log 2 \] \end{corollary} \begin{proof} This is an immediate consequence of Theorem \ref{auction:thm:h2}. \end{proof} \section{Three-Party Auctions} \label{auction:sec:three} Let us now consider the case where three parties enter an auction. Algorithm $f$ is adapted in the following Algorithm \ref{auction:algo:f3}. We can see that once the inputs have been sorted, the program simply consists in finding the maximum of $x, 2y$ and $3z$. {\small \begin{algorithm} \hspace*{\algorithmicindent} \textbf{Inputs:} $x, y, z \in \lr{1}{m}$ \\ \hspace*{\algorithmicindent} \textbf{Output:} Sales price $p \in \{x, y, z\}$ \vspace{1.5mm} \begin{algorithmic}[1] \Function{$f$}{$x, y, z$} \State Sort inputs such that $x \geq y \geq z$ \If {$x > 2y$ and $x > 3z$} \Return $x$ \Else \If {$2y > 3z$} \Return $y$ \Else \phantom{\textbf{if} $2y > 3z$ \textbf{t}} \Return $z$ \EndIf \EndIf \EndFunction \end{algorithmic} \caption{Three-party auction function $f$} \label{auction:algo:f3} \end{algorithm} } Before computing $\V$, let us introduce some useful results that we will need in this section. \subsection{Preliminaries} Let us generalise a result that we hinted at in the previous section, and that will be of importance in deriving an algebraic expression for $\HH(X \mid O)$. We claim that substituting the value of one of the inputs to the value of the output does not change the output of $f$. \begin{lemma} \label{auction:lemma:replace} Let $\{x_i\}_i$ be a set of $n$ inputs and let $o$ be a value. Then we have: \begin{equation} f(x_1, x_2, \dots, x_n) = o \implies f(o, x_2, \dots, x_n) = o \end{equation} \end{lemma} \begin{proof} Let us introduce a few notations in order to develop this proof. Let $\{x_i\}_i$ be a set of $n$ inputs and let $o$ and $o'$ two values such that: \begin{align} f(x_1, \dots, x_n) &= o \label{auction:eq:comp1} \\ f(o, x_2, \dots, x_n) &= o' \label{auction:eq:comp2} \end{align} where we will refer to Equation (\ref{auction:eq:comp1}) to scenario 1 while Equation (\ref{auction:eq:comp2}) will be referred to as scenario 2. For sake of convenience, let us introduce another set of inputs $\{x_i'\}_i$ which we define as: \begin{align} x_1' &= o \\ \forall i \in \lr{2}{n} \colon x_i' &= x_i \end{align} so that we can write $f(x_1', \dots, x_n') = o'$. Let $S$ and $S'$ be two subsets of $\lr{1}{n}$ defined as: \begin{align*} S &= \{ i \in \lr{1}{n} \mid x_i \geq o \} \\ S' &= \{ i \in \lr{1}{n} \mid x_i' \geq o' \} \end{align*} In other words, $S$ and $S'$ represent the sets of parties that will get to buy the item in an auction involving the sets of inputs $\{x_i\}_i$ and $\{x_i'\}_i$ respectively. Let $b$ and $b'$ be the seller's benefits in both scenarios, defined as: \begin{align*} b &= |S|\cdot o \\ b' &= |S'| \cdot o' \end{align*} Finally, for input set $\{\xi_i\}_{i}$, subset $\sigma \subseteq \lr{1}{n}$ and value $\omega$, we say that the triple $(\{\xi_i\}_{i}, \sigma, \omega)$ is \emph{qualified} if: \[ \forall j \in \sigma \colon \xi_j \geq \omega \] We can notice that if $(\{\xi_i\}_{i}, \sigma, \omega)$ is qualified, then the seller's benefits in an auction involving inputs $\{\xi_i\}_{i}$ will be no lower than $|\sigma| \cdot \omega$. The intuition of the proof follows. First, there is nothing to show when $o=x_1$. We will prove that if $o<x_1$, then $b'=b$ as $o$ is the optimal price for scenario 2. If $o>x_1$, we will argue that $b' = b+o$ which can only be achieved for $o'=o$. \ourparagraph{Case 1} Let us assume that $o < x_1$. We first argue that $b'=b$. In this case, we have $x_i' \leq x_i$ for all $i$ in $\lr{1}{n}$. For all subset $\sigma \subseteq \{1, \dots, n\}$, if $(\{x_i'\}, \sigma, o')$ is qualified, then $(\{x_i\}, \sigma, o')$ is also qualified. Thus we have $b' \leq b$. Moreover, we know that $(\{x_i'\}, S, o)$ is qualified since $x_1'\geq o$. Hence, $b' \geq b$ and thus $b'=b$. Let us now argue that $o'=o$. We know that $b'$ can be achieved with a sales price of $o$. As the auction function $f$ favours lower sales prices for the same seller's benefits, we know that $o' \leq o$. Let us assume by contradiction that $o' < o$. As argued before, we know that $(\{x_i\}, S', o')$ is qualified. The benefits with inputs $\{x_i\}$ would equal $|S'|\cdot o'$. But we have just shown that $b' = b$ where by definition $b'$ equals $|S' \cdot o'|$. Thus the optimal benefits in scenario 1 would also be achieved with an output value $o'$ satisfying $o' < o$ which is a contradiction. Thus $o'=o$. \ourparagraph{Case 2} Let us assume that $o > x_1$. Let us first argue that $b'=b+o$. We know that $(\{x_i\}, S, o)$ is qualified by definition and thus $(\{x_i'\}, S \cup \{1\}, o)$ is also qualified since $x_1'=o$. Thus $b' \geq (|S| + 1) \cdot o$, or in other words $b' \geq b + o$. Moreover, we know that for all subset $\sigma \subseteq \{1, \dots, n\}$, if $(\{x_i'\}, \sigma, o')$ is qualified, then the triple $(\{x_i\}, \sigma \cap \{2, \dots, n\}, o')$ is also qualified, since $x_i' = x_i$ for all $i$ in $\lr{2}{n}$. Let us now assume by contradiction that $b' > b + o$. As by definition $(\{x_i'\}, S', o')$ is qualified, we know that $(\{x_i\}, S' \cap \lr{2}{n}, o')$ is qualified, too. Thus: \begin{align*} b &\geq (|S'|-1) \cdot o' \\ &\geq |S'| \cdot o' - o' \\ &\geq b' - o' \end{align*} By assumption, this implies: \begin{align*} b > b + o - o' \end{align*} and thus: \begin{align*} o' > o \end{align*} This implies that $1 \notin S'$ and thus $(\{x_i\}, S', o')$ is qualified, which means that $b \geq b'$, which is a contradiction. In conclusion, we have $b' = b+o$. Let us now argue that $o'=o$. We have already mentioned that $b'$ can be achieved with a sales price of $o$, and thus $o' \leq o$. Let us assume by contradiction that $o' < o$. Then we know that $1 \in S'$ (since $x_1'=o$). We also know that as $(\{x_i'\}, S', o')$ is qualified, then $(\{x_i\}, S \setminus \{1\}, o')$ is qualified too. Consequently: \begin{align*} b &\geq (|S'| - 1) \cdot o' \\ &\geq b' - o' \end{align*} As assumed by proof by contradiction that $o' < o$, we thus have $b > b' - o$ and thus: \[ b' < b+o \] which is a contradiction, which concludes the case and the proof. \end{proof} We also recall a result that will be useful for studying the asymptotic behaviour of $\HH(X \mid O)$. \begin{lemma} \label{auction:lemma:sums} Let $n$ be a positive integer and let $a$ and $b$ be positive integer no larger than $n$. Then: \begin{align*} \sum_{k=a}^b k &= \frac{1}{2}(b^2 - a^2) + \mathcal{O}(n) \\ \sum_{k=a}^b k^2 &= \frac{1}{3}(b^3 - a^3) + \mathcal{O}(n^2) \end{align*} \end{lemma} \begin{proof} We recall that we have: \begin{align*} \sum_{k=1}^n k &= \frac{n(n+1)}{2} \\ \sum_{k=1}^n k^2 &= \frac{n(n+1)(2n+1)}{6} \end{align*} Thus for all positive integer $c$ no larger than $n$, we have: \begin{align*} \sum_{k=1}^c k &= \frac{1}{2}c^2 + \mathcal{O}(n) \\ \sum_{k=1}^c k^2 &= \frac{1}{3}c^3 + \mathcal{O}(n^2) \end{align*} And thus as $a$ and $b$ are no larger than $n$: \begin{align*} \sum_{k=a}^b k &= \sum_{k=1}^b k - \sum_{k=1}^a k + \mathcal{O}(n) \\ &= \frac{1}{2}(b^2 - a^2) + \mathcal{O}(n) \\ \sum_{k=1}^n k^2 &= \sum_{k=1}^b k^2 - \sum_{k=1}^a k^2 + \mathcal{O}(n^2) \\ &= \frac{1}{3}(b^3 - a^3) + \mathcal{O}(n^2) \end{align*} where we note that the bounds of the indices in the sums are allowed to differ by 1 since the difference is compensated in the $\mathcal{O}(n)$ and $\mathcal{O}(n^2)$ terms. \end{proof} \subsection{Deriving an Expression for the Input Vulnerability} We are now interested in computing the value of $\V$. For this, we argue again that $\max_x p(o\mid x) = p(o \mid X = o)$. Indeed, we know that for fixed values of $o$ and $x$, we have: \begin{align*} p(o\mid x)&= \sum_{\substack{y, z \\ f(x, y, z) = o}} p(y, z) \\ &= \frac{|\{(y, z) \mid f(x, y, z) = o\}|}{m^2} \end{align*} where we note that in this 3-party setting, the pair $(y,z)$ plays the role of the spectators' input, which comprises two inputs $y$ and $z$. However, Lemma \ref{auction:lemma:replace} ensures that: \[ \forall x \colon |\{(y, z) \mid f(x, y, z) = o\}| \leq |\{(y, z) \mid f(o, y, z) = o\}| \] and thus Equation (\ref{auction:eq:vuln}) becomes: \begin{equation} \label{auction:eq:vuln3} \V = \frac{1}{m^3} \sum_o |\{(y, z) \mid f(o, y, z) = o\}| \end{equation} The aim is thus now to compute the above sum, which can be written as the cardinality of the following set $S$: \[ S = \{ (x, y, z) \mid f(x, y, z) = x \}\] which can be written as the following disjoint union: \[ S = \bigcup_x S^x \] where for all $x$ we define: \[ S^x = \{ (x, y, z) \mid f(x, y, z) = x \} \] Let us partition each set $S^x$ into the following four subsets, that correspond to the different possible input orderings: \begin{align*} S_1^x &= S \cap \{ (x, y, z) \mid x > y \wedge x > z \} \\ S_2^x &= S \cap \{ (x, y, z) \mid y \geq x > z \} \\ S_3^x &= S \cap \{ (x, y, z) \mid z \geq x > y \} \\ S_4^x &= S \cap \{ (x, y, z) \mid x \leq y \wedge x \leq z \} \end{align*} We note that $S_1$ corresponds to the cases where $x_1$ is the largest of $x, y$ and $z$, $S_2$ and $S_3$ includes the cases where $x_1$ is the middle element and $S_4$ depicts the cases where $x_1$ is the smallest item. Let $x$ be in $\lr{1}{m}$. It is immediate to see that $\{ S_1^x, \dots, S_4^x \}$ forms a partition of $S^x$ and thus $|S^x| = |S_1^x|+\dots +|S_4^x|$, and furthermore $|S| = \sum_x |S^x|$. Let us thus focus on the cardinality of those four subsets. \ourparagraph{Case 1} Let $y$ and $z$ be in $\lr{1}{m}$ such that: \begin{align*} x > y \wedge x > z \end{align*} and let us study the membership of $(x, y, z)$ in $S_1^x$. We have: \begin{align*} f(x, y, z) = x \iff {}& (x > 2y \wedge x > 3z) \\{}\vee{}& (x > 3y \wedge x > 2z) \\ \iff {}& (y < \frac{1}{2}x \wedge z < \frac{1}{3}x) \\{}\vee{}& (y < \frac{1}{3}x \wedge z < \frac{1}{2}x) \end{align*} In order to tally the number of different pairs $(y, z)$ that satisfy those conditions, it is helpful to rewrite those systems as the following disjunction: \begin{align*} f(x, y, z) = x \iff {}& (y < \frac{1}{3}x \wedge z < \frac{1}{3}x) \\ {} \vee {}& (y < \frac{1}{3}x \wedge \frac{1}{3}x \leq z < \frac{1}{2}x) \\ {} \vee {}& (\frac{1}{3}x \leq y < \frac{1}{2}x \wedge z < \frac{1}{3}x) \end{align*} The three disjuncts above are disjoint, and the last two disjuncts are symmetrical in $y$ and $z$. We can thus express the cardinality of $S_1^x$ as: \begin{align} |S_1^x| &= \ceil{ \frac{1}{3}x - 1 }^2 + 2\left( \ceil{\frac{1}{2}x} - 1 - \ceil{\frac{1}{3}x} + 1 \right)\left( \ceil{\frac{1}{3}x - 1} \right) \nonumber \\ &= \left( \ceil{\frac{1}{3}x - 1} \right) \left( 2\ceil{\frac{1}{2}x} - \ceil{\frac{1}{3}x} - 1 \right) \label{auction:eq:s1} \end{align} \ourparagraph{Case 2 and 3} Let us now study the cardinality of $S_2^x$. Let $y$ and $z$ be in $\lr{1}{m}$ such that: \begin{align*} y \geq x > z \end{align*} and let us study the membership of $(x, y, z)$ in $S_1^x$. We have: \begin{align*} f(x, y, z) = x &\iff (2x \geq y \wedge 2x > 3z) \\ &\iff (x \leq y \leq 2x \wedge z < \frac{2}{3}x) \end{align*} We can thus express the cardinality of $S_2^x$ depending on which side of $n$, value $2x$ is. If $2x \leq m$, then: \begin{align} |S_2^x| &= (2x - x + 1) \left( \ceil{\frac{2}{3}x} - 1 \right) \nonumber \\ &= (x+1) \left( \ceil{\frac{2}{3}x} - 1 \right) \label{auction:eq:s2a} \end{align} If $2x > m$, then: \begin{align} |S_2^x| &= (m - x + 1) \left( \ceil{\frac{2}{3}x} - 1 \right) \label{auction:eq:s2b} \end{align} By symmetry on $y$ and $z$, we also have $|S_3^x| = |S_2^x|$. \ourparagraph{Case 4} Let us now take $y$ and $z$ in $\lr{1}{m}$ such that: \begin{align*} x \leq y \wedge x \leq z \end{align*} and let us study the membership of $(x, y, z)$ in $S_4^x$. We have: \begin{align*} f(x, y, z) = x \iff {}& (3x \geq 2y \wedge 3x \geq z) \\ {} \vee {}& (3x \geq y \wedge 3x \geq 2z) \\ \iff {} & (x \leq y \leq \frac{3}{2}x \wedge x \leq z \leq 3x) \\ {} \vee {}& (x \leq y \leq 3x \wedge x \leq z \leq \frac{3}{2}x) \end{align*} Rewriting those conditions as disjoint cases, we get: \begin{align*} f(x, y, z) = x \iff {}& (x \leq y \leq \frac{3}{2}x \wedge x \leq z \leq \frac{3}{2}x) \\ {} \vee {}& (x \leq y \leq \frac{3}{2}x \wedge \frac{3}{2}x < z \leq 3x) \\ {} \vee {}& (\frac{3}{2}x < y \leq 3x \wedge x \leq z \leq \frac{3}{2}x) \end{align*} Let us treat those 3 disjoint disjunctions separately. Let $c_1^x, c_2^x$ and $c_3^x$ denote the number of different triples $(x, y, z)$ that satisfy the three above systems respectively, i.e. that: \begin{align*} c_1^x &= \left| \left\{ (x, y, z) \mid x \leq y \leq \frac{3}{2}x \wedge x \leq z \leq \frac{3}{2}x \right\} \right| \\ c_2^x &= \left| \left\{ (x, y, z) \mid x \leq y \leq \frac{3}{2}x \wedge \frac{3}{2}x < z \leq 3x \right\} \right| \\ c_3^x &= \left| \left\{ (x, y, z) \mid \frac{3}{2}x < y \leq 3x \wedge x \leq z \leq \frac{3}{2}x \right\} \right| \\ \end{align*} Let us focus on $c_1^x$ first. If $\frac{3}{2}x \leq m$, then: \begin{equation} \label{auction:eq:c1a} c_1^x = \left( \floor{\frac{3}{2}x} - x + 1 \right)^2 \end{equation} Otherwise, if $\frac{3}{2}x > m$, then: \begin{equation} \label{auction:eq:c1b} c_1^x = (m - x + 1)^2 \end{equation} Let us now focus on $c_2^x$. \begin{equation} \label{auction:eq:c2} c_2^x = \begin{dcases*} \left( 3x - \floor{\frac{3}{2}x} \right) \left( \floor{\frac{3}{2}x} - x + 1 \right) & if $3x\leq m$ \\ \left( m - \floor{\frac{3}{2}x} \right) \left( \floor{\frac{3}{2}x} - x + 1 \right) & if $\frac{3}{2}x\leq m \leq 3x$ \\ 0 & if $\frac{3}{2}x > m$ \end{dcases*} \end{equation} And by symmetry on $y$ and $z$, we have $c_2^x = c_3^x$. Finally, we have $|S_4^x| = c_1^x + c_2^x + c_3^x$. Let us recall that we wished to compute the cardinality of set $S$ in order to fulfil our original aim which was to compute input $x$'s vulnerability $\V$. We have now derived the cardinality of each subset $S_i^x$ for all $i$ in $\lr{1}{4}$ and for all $x$ in $\lr{1}{m}$. Moreover, we have intentionally expressed $S$ as a disjoint union so that: \begin{equation} \label{auction:eq:cardSsum} |S| = \sum_x |S_1^x|+\dots+|S_4^x| \end{equation} The expression that we can derive for $|S|$ in this way involves sums with ceilings and floorings and would thus not immediately lead to a closed-form formula that can be computed in constant time. Indeed, combining Equations (\ref{auction:eq:s1}), (\ref{auction:eq:s2a}), (\ref{auction:eq:s2b}), (\ref{auction:eq:c1a}), (\ref{auction:eq:c1b}) and (\ref{auction:eq:c2}) provides us with a closed-form expression for $|S_1^x|+\dots+|S_4^x|$ for any fixed value of $x$ in $\lr{1}{m}$. Equation (\ref{auction:eq:cardSsum}) then allows us to compute the cardinality $|S|$ by summing those $m$ expressions, which allows us to compute $|S|$ in $\mathcal{O}(m)$ time. However, we recall that for small input spaces, we already have a combinatorial way of computing vulnerability $\V$, and that our major problem is to scale our analyses to \emph{large} input spaces, which is specifically where the combinatorial method fails to scale. For that reason, in the remainder of this report, we will aim at deriving a closed-form formula for the asymptotic behaviour of $|S|$ for large values of input size $m$. \subsection{Asymptotic Behaviour of the Input Vulnerability} In order to do so, we will study the asymptotic behaviour, when $m$ tends towards infinity, of $|S_i^x|$ and $\sum_x |S_i^x|$ for all $i$ in $\lr{1}{4}$ in order to be able to compute that of $|S|$ and thus of $\V$. In this section, the asymptotic behaviour of the cardinality of a set, say $S$, will refer to the asymptotic behaviour of $|S|$ when expressed as a function of $m$, when $m$ tends towards infinity. Let us consider again the expression of $|S_1^x|$ obtained in Equation (\ref{auction:eq:s1}) and let us study its asymptotic behaviour when $m$ is large. We note that $x$ is an integer ranged in $\lr{1}{m}$ and is thus a $\mathcal{O}(m)$. By simplifying the ceiling in the first factor, we have: \begin{align*} \ceil{\frac{1}{3}x -1} &= \frac{1}{3}x + \mathcal{O}(1) \end{align*} \ourparagraph{Case 1} We now recall the entire expression of $|S_1^x|$ obtained in Equation (\ref{auction:eq:s1}) and proceed with a similar reasoning: \begin{align*} |S_1^x| &= \left( \ceil{\frac{1}{3}x - 1} \right) \left( 2\ceil{\frac{1}{2}x} - \ceil{\frac{1}{3}x} - 1 \right) \\ &= \left( \frac{1}{3}x + \mathcal{O}(1) \right) \left( x - \frac{1}{3}x + \mathcal{O}(1) \right) \\ &= \frac{2}{3}x^2 + x \cdot \mathcal{O}(1) \\ &= \frac{2}{3}x^2 + \mathcal{O}(m) \end{align*} We thus obtain: \begin{align*} \sum_x |S_1^x| &= \sum_{x=1}^m \left( \frac{2}{3} x^2 + \mathcal{O}(m) \right) \\ &= \frac{2}{3} \cdot \frac{m(m+1)(2m+1)}{6} + \mathcal{O}(m^2) \\ &= \frac{1}{3^2} m^3 + \mathcal{O}(m^2) \end{align*} \ourparagraph{Case 2 and 3} Let us now study the case of $|S_2^x|$. Based on Equations (\ref{auction:eq:s2a}), then if $2x \leq m$, we have: \begin{align*} |S_2^x| &= (x+1) \left( \ceil{\frac{2}{3}x} - 1 \right) \\ &= \frac{2}{3}x^2 + \mathcal{O}(m) \end{align*} Similarly, if $2x > m$, then Equation (\ref{auction:eq:s2b}) becomes: \begin{align*} |S_2^x| &= (m - x + 1) \left( \ceil{\frac{2}{3}x} - 1 \right) \\ &= \frac{2}{3}mx - \frac{2}{3}x^2 + \mathcal{O}(m) \end{align*} And thus: \begin{align*} \sum_{x=1}^m |S_2^x| &= \sum_{x=1}^{\frac{m}{2}} \left( \frac{2}{3}x^2 + \mathcal{O}(m) \right) + \sum_{x=\frac{m}{2}}^m \left( \frac{2}{3}mx - \frac{2}{3}x^2 + \mathcal{O}(m) \right) + \mathcal{O}(m^2) \end{align*} where we note again that the bounds of the indices in the sums are allowed to differ by 1 since the difference is compensated in the $\mathcal{O}(n^2)$ term. Let us compute each term separately. Using the results recalled in Lemma \ref{auction:lemma:sums}, we have: \begin{align*} \sum_{x=1}^{\frac{m}{2}} \left( \frac{2}{3}x^2 + \mathcal{O}(m) \right) &= \frac{2}{3} \cdot \frac{1}{3} \left( \frac{m}{2} \right)^3 + \mathcal{O}(m^2) \\ &= \frac{1}{2^2 \cdot 3^2} m^3 + \mathcal{O}(m^2) \end{align*} Similarly, we note that $\sum_{x=\frac{m}{2}}^m \mathcal{O}(m) = \mathcal{O}(m^2)$. Moreover, we have: \begin{align*} \sum_{x=\frac{m}{2}}^m \left( \frac{2}{3}mx - \frac{2}{3}x^2 \right) &= \frac{2}{3}m \sum_{x=\frac{m}{2}}^m x - \frac{2}{3} \sum_{x=\frac{m}{2}}^m x^2 + \mathcal{O}(m^2) \\ &= \frac{2m}{2\cdot 3} \left(m^2 - \left( \frac{m}{2} \right)^2\right) - \frac{2}{3^2} \left( m^3 - \left( \frac{m}{2} \right)^3 \right) + \mathcal{O}(m^2) \\ &= \frac{2m}{2\cdot 3} \cdot \frac{3m^2}{2^2} - \frac{2}{3^2} \cdot \frac{7m^3}{2^3} + \mathcal{O}(m^2) \\ &= \frac{m^3}{2^2} - \frac{7m^3}{2^2 \cdot 3^2} + \mathcal{O}(m^2) \\ &= \frac{1}{2\cdot 3^2} m^3 + \mathcal{O}(m^2) \end{align*} Combining the previous two terms, we get: \begin{align*} \sum_{x=1}^m |S_2^x| &= \frac{1}{2^2 \cdot 3^2} m^3 + \frac{1}{2\cdot 3^2} m^3 + \mathcal{O}(m^2) \\ &= \frac{1}{2^2 \cdot 3} m^3 + \mathcal{O}(m^2) \end{align*} By symmetry, we immediately get: \begin{align*} \sum_{x=1}^m ( |S_2^x| + |S_3^x| ) &= \frac{1}{2 \cdot 3} m^3 + \mathcal{O}(m^2) \end{align*} \ourparagraph{Case 4} Let us finally study the asymptotic behaviour of $\sum_x |S_4^x| = \sum_x (c_1^x + c_2^x + c_3^x)$. If $\frac{3}{2}x \leq m$, we know from Equation (\ref{auction:eq:c1a}) that: \begin{align*} c_1^x &= \left( \floor{\frac{3}{2}x} - x + 1 \right)^2 \\ &= \frac{x^2}{2^2} + \mathcal{O}(m) \end{align*} Moreover, if $\frac{3}{2}x > m$, then from Equation (\ref{auction:eq:c1b}): \begin{align*} c_1^x &= (m - x + 1)^2 \\ &= m^2 - 2mx + x^2 + \mathcal{O}(m) \end{align*} Thus: \begin{align*} \sum_{x=1}^m c_1^x &= \sum_{x=1}^{\frac{2}{3}m} \frac{x^2}{2^2} + \sum_{x=\frac{2}{3}m}^m (m^2 - 2mx + x^2) + \mathcal{O}(m^2) \\ &= \frac{1}{2^2\cdot 3} \cdot \frac{2^3 m^3}{3^3} + \frac{m^3}{3} - \frac{2\cdot 5m^3}{2\cdot 3^2} + \frac{19m^3}{3^4} + \mathcal{O}(m^2) \\ &= \frac{m^3}{3^3} + \mathcal{O}(m^2) \end{align*} Similarly, by Equation (\ref{auction:eq:c2}), we have: \[ c_2^x = \begin{dcases*} \frac{3}{4}x^2 + \mathcal{O}(m) & if $3x\leq m$ \\ \frac{xm}{2} - \frac{3}{4}x^2 + \mathcal{O}(m) & if $\frac{3}{2}x\leq m \leq 3x$ \\ 0 & if $\frac{3}{2}x > m$ \end{dcases*} \] Thus: \begin{align*} \sum_{x=1}^m c_2^x &= \sum_{x=1}^{\frac{m}{3}} \frac{3}{4}x^2 + \sum_{x=\frac{m}{3}}^{\frac{2m}{3}} \left( \frac{xm}{2} - \frac{3}{4}x^2 \right) + \mathcal{O}(m^2) \\ &= \frac{3m^3}{4\cdot 3 \cdot 3^3} + \frac{(2^2-1)m^3}{2\cdot 2\cdot 3^2} - \frac{7\cdot 3m^3}{4\cdot 3 \cdot 3^3} + \mathcal{O}(m^2) \\ &= \frac{m^3}{2^2 \cdot 3^3} + \mathcal{O}(m^2) \end{align*} And by symmetry, we have: \begin{align*} \sum_{x=1}^m (c_2^x + c_3^x) &= \frac{m^3}{2 \cdot 3^3} + \mathcal{O}(m^2) \end{align*} And thus: \begin{align*} \sum_{x=1}^m |S_4^x| &= \frac{m^3}{3^3} + \frac{m^3}{2 \cdot 3^3} + \mathcal{O}(m^2) \\ &= \frac{m^3}{2 \cdot 3^2} + \mathcal{O}(m^2) \end{align*} \ourparagraph{Conclusion} And finally: \begin{align} |S| &= \sum_{i=1}^4 |S_i| \nonumber \\ &= \frac{1}{3^2} m^3 + \frac{1}{2 \cdot 3} m^3 + \frac{m^3}{2 \cdot 3^2} + \mathcal{O}(m^2) \nonumber\\ &= \frac{1}{3}m^3 + \mathcal{O}(m^2) \label{auction:eq:cardS} \end{align} Given this analysis, we can now formulate our main result for 3-party auctions. \begin{theorem} \label{auction:thm:h3} We have: \[ \HH(X \mid O) = \log 3 + \mathcal{O} \left(\frac{1}{m}\right) \] \end{theorem} \begin{proof} Equation (\ref{auction:eq:vuln3}) and (\ref{auction:eq:cardS}) yield: \[ \V = \frac{1}{3} + \mathcal{O}\left(\frac{1}{m}\right) \] and manipulating asymptotic developments yields: \begin{align*} \HH &= -\log \left( \frac{1}{3} \left( 1 + \mathcal{O}\left(\frac{1}{m}\right) \right)\right) \\ &= \log 3 -\log \left( 1 + \mathcal{O}\left(\frac{1}{m}\right) \right) \\ &= \log 3 + \mathcal{O}\left(\frac{1}{m}\right) \end{align*}% \end{proof} It follows that $\HH(X \mid O)$ converges when $m$ tends toward infinity and its limit is stated in the following result. \begin{corollary} \label{auction:coro:3} When the input size $m$ tends towards infinity, the value of $\HH(X \mid O)$ converges and: \[ \lim_{m \to \infty} \HH(X \mid O) = \log 3 \] \end{corollary} \begin{proof} This is an immediate consequence of Theorem \ref{auction:thm:h3}. \end{proof} We note that a more precise approximation of $\V$ and $\HH(X \mid O)$ can be obtained by bounding the cardinality of the subsets involved in the computation of $|S|$ with upper and lower bounds. In particular, each flooring and ceiling can be approximated with a range of width 1, and so more involved computation would lead to a more precise result. The results obtained so far led us to conjecture on the asymptotic vulnerability of a targeted input in a general $n$-party auction. \section{Conjecture for Multi-Party Auctions} \label{auction:sec:multi} Let $n$ be a positive integer and let us consider an $n$-party auction. Let $m$ be a positive integer that represents the input size. Let us consider $n$ inputs $x_1, \dots, x_n$ and we recall that the computation of the output of the auction is modelled by function $f$. In light of Corollaries \ref{auction:coro:2} and \ref{auction:coro:3}, we formulate the following conjecture. \begin{conjecture} \label{auction:conj:limit} Let $\HH(X \mid O)$ represent the conditional entropy of one of the inputs, $X$, given the output of the auction $O$. Then $\HH(X \mid O)$ converges when $m$ tends towards infinity and: \[ \lim_{m \to \infty} \HH(X \mid O) = \log n \] \end{conjecture} We note that this conjecture is also verified when $n = 1$ since in the presence of a single party, we have $\HH(X \mid O) = 0$. The results derived in Corollaries \ref{auction:coro:2} and \ref{auction:coro:3} are also consistent with this conjecture. In this section, we provide more evidence which supports our intuition. Let us first generalise a notion introduced in Equation (\ref{auction:eq:vuln3}) that will enable us to express the vulnerability more conveniently. \begin{definition} We define function $c_n\colon \mathbb{N}^* \to \mathbb{N}$ for all positive integer $m$ as: \[ c_n(m) = |\{ (x_1, \dots, x_n) \in \lr{1}{m}^n \mid f(x_1, \dots, x_n) = x_1 \}| \] \end{definition} As discussed in Section \ref{auction:sec:three}, we can easily prove that $\V = \frac{c_n(m)}{m^n}$. The difficulty resides in computing $c_n(m)$ for large values of $m$. Let us first formulate a second conjecture on the shape of function $c_n$. This will help us to reason about its asymptotic behaviour more precisely. \begin{conjecture} \label{auction:conj:shape} There exists a positive rational number $a_n$ in $\mathbb{Q}$ such that: \[ c_n(m) = a_n \cdot m^n + \mathcal{O}(m^{n-1}) \] \end{conjecture} We can see in Section \ref{auction:sec:three} from the way that $c_n(m)$ is constructed that it will comply with the shape aforementioned. Conjecture \ref{auction:conj:limit} is now equivalent to the fact that $a_n = \frac{1}{n}$, for which we will show some empirical supportive evidence. We emphasise the fact that the following reasoning is empirical and does not constitute a proof. As Conjecture \ref{auction:conj:shape} suggests that function $c_n$ behaves like a polynomial of degree $n$ for large values of $m$, we decided to try and interpolate function $c$ with a polynomial of degree at most $n$ via its first 30 values $c_n(1), \dots, c_n(30)$ which we computed empirically. Let us plot the first 30 values of $c_n$ that we computed for $n=2, \dots, 5$. Based on those 20 values, we performed a polynomial regression with a polynomial of degree $n$ respectively, and with a least squares method. The respective interpolating polynomials $P_2, \dots, P_5$ that we empirically obtain are displayed below: \begin{align*} P_2 &= 0.5 x^2 + 0.5 x \\ P_3 &= 0.3334 x^3 + 0.6649 x^2 + 0.3577 x - 0.1987 \\ P_4 &= 0.2499 x^4 + 0.7671 x^3 + 0.3552 x^2 + 1.267 x - 2.231 \\ P_5 &= 0.1995 x^5 + 0.8503 x^4 - 0.6201 x^3 + 14.77 x^2 - 62.27 x + 64.15 \end{align*} where coefficients have been reported with 4 significant figures. By looking at the coefficients of highest degree in the above polynomials, we can see that the empirical values thus obtained for $a_n$ are indeed very close to $\frac{1}{n}$, which supports our Conjecture \ref{auction:conj:limit}. \begin{figure} \centering \subfigure[Case $n=2$. ]{ \begin{tikzpicture}[scale=1] \begin{axis}[ ymin=0, xmin=0, xlabel=$m$, ylabel=prevalence, width=8cm, height=9cm, scaled y ticks=base 10:-2, legend pos=north west] \addplot[mark size=1pt, only marks, blue] table [y=y, x=x]{figuresAuction/2.dat}; \addplot[red] table [y=y, x=x, mark=none]{figuresAuction/2b.dat}; \legend{$c_n(m)$, $P_n(m)$} \end{axis} \end{tikzpicture} \label{auction:fig:n2} }\hfill \subfigure[Case $n=3$. ]{ \begin{tikzpicture}[scale=1] \begin{axis}[ ymin=0, xmin=0, width=8cm, height=9cm, xlabel=$m$, ylabel=prevalence, scaled y ticks=base 10:-3, legend pos=north west] \addplot[mark size=1pt, only marks, blue] table [y=y, x=x]{figuresAuction/3.dat}; \addplot[red] table [y=y, x=x, mark=none]{figuresAuction/3b.dat}; \legend{$c_n(m)$, $P_n(m)$} \end{axis} \end{tikzpicture} \label{auction:fig:n3} } \par\bigskip \par\bigskip \subfigure[Case $n=4$. ]{ \begin{tikzpicture}[scale=1] \begin{axis}[ ymin=0, xmin=0, width=8cm, height=9cm, xlabel=$m$, ylabel=prevalence, scaled y ticks=base 10:-4, legend pos=north west] \addplot[mark size=1pt, only marks, blue] table [y=y, x=x]{figuresAuction/4.dat}; \addplot[red] table [y=y, x=x, mark=none]{figuresAuction/4b.dat}; \legend{$c_n(m)$, $P_n(m)$} \end{axis} \end{tikzpicture} \label{auction:fig:n4} }\hfill \subfigure[Case $n=5$.]{ \begin{tikzpicture}[scale=1] \begin{axis}[ ymin=0, xmin=0, width=8cm, height=9cm, xlabel=$m$, ylabel=prevalence, legend pos=north west] \addplot[mark size=1pt, only marks, blue] table [y=y, x=x]{figuresAuction/5.dat}; \addplot[red] table [y=y, x=x, mark=none]{figuresAuction/5b.dat}; \legend{$c_n(m)$, $P_n(m)$} \end{axis} \end{tikzpicture} \label{auction:fig:n5} } \caption{Polynomial interpolation of empirical values of $c_n$ with theoretical polynomials $P_n$ of degree at most $n$. The first 30 values of $c_n$ were computed empirically, those values were used to perform a polynomial regression with a least squares method. } \end{figure} \section{Discussion} \label{sec:discu} The results obtained and conjectured in this paper suggest that the computational power that an attacker may have should somehow play a role in our approach. Similarly to the differences that have been formally defined between information-theoretic security and computational security in a cryptographic protocol, we may also identify similar nuances in privacy. For example, let us assume that our Conjecture \ref{auction:conj:limit} is correct and that the vulnerability of one input in an $n$-party auction converges towards $\frac{1}{n}$ when the input size $m$ tends to infinity. This would be a poor privacy guarantee, since the prior vulnerability of one input is $\frac{1}{m}$, and $m$ is much larger than $n$. However, this $\frac{1}{n}$ limit would be a \emph{theoretical} value: this means that in theory, an attacker learning the output of an auction has on average a $\frac{1}{n}$ probability of guessing one input in one try if he selects the best guess. But in reality, an attacker with limited computational power might not be able to select the best guess that would offer him a $\frac{1}{n}$ probability of guessing the secret. Our empirical method for computing $c_n(m)$~--~that does not scale to large input spaces~--~does provide, along with the exact value of $c_n(m)$, the best guessing strategy that achieves the expected vulnerability as it explicitly chooses the best guess. However, in the 3-party auction, we solely proved that for a large value of $m$, the input's vulnerability would be close to $\frac{1}{3}$. In particular, we were unable to provide a way for an attacker to select the best guessing strategy given the auction's output. One might thus be interested in considering the potential difference that may exist between the theoretical vulnerability and the computational vulnerability of a secret. \section{Conclusion} \label{sec:conclu} Digital goods auctions are one real world use case that can benefit from the security guarantees that Secure Multi-Party Computation has to offer. One of the main advantages of using SMC is to protect the confidentiality of the participants' bids. As in every application of SMC, private inputs in auctions are subject to acceptable leakage. Although general, combinatorial privacy analyses are able to quantify this leakage for small input spaces, they fail to scale to large input spaces. In this paper, we derived methods for quantifying the acceptable leakage that scales to arbitrarily large input spaces in the particular case of digital goods auctions. We first derived a closed-form formula for the posterior entropy of a targeted input in two-party auctions. We then focused on studying the asymptotic behaviour of this posterior entropy in three-party auctions. This enabled us to formulate a conjecture on the asymptotic behaviour of this acceptable leakage in general $n$-party auctions with large input spaces, which we further supported with empirical observations. \bibliographystyle{plain}
{'timestamp': '2020-09-22T02:20:12', 'yymm': '2009', 'arxiv_id': '2009.09524', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09524'}
arxiv
\section{Introduction} The problem of extracting sparse information from high dimensional data is among the most interesting challenges in theoretical computer science with many applications ranging from computational biology to combinatorial chemistry, neuroscience and natural language processing \cite{guyon2008, hastie2009}. As a specific example, next generation sequencing and, in general, the ongoing technological revolution related to high-throughput technologies in biology pose very stringent requirements to the algorithmic techniques that are supposed to analyze the data that are produced and made publicly available through easily accessible databases. Just to give some orders of magnitude, a typical genetic screening for cancer-related pathologies -- freely available from The Cancer Genome Atlas web site \cite{TCGA} -- involves measurement of activity or genetic sequence variation over $\sim 23,000$ genes measured on patient cohorts that typically count around 1,000 individuals divided into cases and controls (lung and colorectal cancer are an exception, with $\sim 10,000$ individuals screened in each dataset). Here, a typical task is to determine the genotypic signature related to the disease that typically involves $O(10^2)$ genes from 23,000 measured probes. Such problem can be simply formulated in terms of the following classification problem: given the activity and/or the genetic alterations of an individual, find a simple rule involving a small -- possibly the smallest -- subset of genes to assess the probability for the individual to develop the disease. There are two main difficulties in this task: (i) typically genes act in a combinatorial and non linear manner, (ii) individual samples turn out to be statistically very correlated. Historically, the problem of sparse feature selection in classification tasks has been divided into two complementary computational methods \cite{hastie2009}: (i) {\em wrappers} that exploit the learning mechanism to produce a prediction value related score for the sought signature, (ii) {\em filters} where the signature extraction is a data pre-processing, typically unrelated to the classification task. From the point of view of information theory, the problem of sparse feature selection in classification is strictly related to Compressive Sensing (CS), one of the most studied methods for data acquisition, with interesting applications in several other research fields \cite{candes2008,baraniuk2011}. CS was originally proposed as a new low-rate signal acquisition technique for compressible signals \cite{donoho2006, candes2006, candes2008} and is formulated as follows: given $M<N$, a vector $\bm z\in {\mathbb R}^M$ and a linear operator of maximal rank $\mathbf{X}\in{\mathbb R}^{M\times N}$ often referred to as the \emph{measurement} or \emph{sensing} matrix, the CS problem consists in determining the unknown sparse vector $\bm w \in {\mathbb R}^N$ that is linked to its compressed projection $\bm z$ by means of the linear transformation $\bm z =\mathbf{X} {\bm w}$, where $\mathbf{X}$ and $\bm z$ are assumed to be known. Although research in CS has still many open challenges to face, very stringent results are known about the general conditions for the existence and uniqueness of the solution. Among the different algorithms that have been proposed in order to reconstruct efficiently the signal, many use techniques borrowed from the statistical mechanics of disordered systems \cite{ donoho2009, kabashima2009,ganguli2010, krzakala2010}. More recently, the so called 1-bit CS (1BCS) has been proposed as a strategy to deal with the problem of inferring a sparse signal knowing only the sign of the data of the linear measurements: ${\boldsymbol \sigma} = \mathrm{sign} (\mathbf{X} {\bm w})$, where $\mathrm{sign}({\bm z})$ is a vector with elements $z_i/|z_i|$ for $z_i \neq 0$. Besides being of interest for signal transmission related problems where discarding the amplitude of the signal can significantly reduce the amount of information to be stored/relayed \cite{boufounos2008, lee2012}, this problem can also be interpreted in terms of sparse boolean classification tasks. The most widely adopted inference scheme in CS is the so-called LASSO regression or $L_1$-norm minimization \cite{tibshirani1996}, as originally proposed in the context of 1BCS in \cite{boufounos2008}. However, it is clear that the most efficient solution from the point of view of optimal dilution of the problem should be achieved by a $L_0$-pseudonorm, where non-zero parameters are indeed penalized independently of their non-zero value. Unfortunately, dealing with the non-convex $L_0$-regularization is not so simple as it typically leads to phase transitions that make the problem computationally intractable. A practical solution to the problem is to restrict the space of parameters to a discrete set, where effectively the $L_0$-pseudonorm is equivalent to the more amenable $L_1$ case \cite{braunstein2008, braunstein2008b, pagnani2009, bailly2010, molinelli2013}. As far as continuous parameters are concerned, different strategies have been proposed. First, from the statistical physics community side, an approach pursuing this direction consists in a perceptron whose continuous parameters are masked by boolean variables mimicking dilution \cite{kabashima2003, uda2006, kabashima2008, xu2013}. Attempts to characterize theoretically the phase space diagram and the structure of the transition through the replica method have been reported in \cite{lage2009,lage_allerton,lage2013}. Variations of the generalized approximate message passing technique (GAMP) were employed in \cite{onebitAMP}, as it provides a tractable and efficient way to perform minimum mean squared error (MMSE) estimation on the variables to be retrieved when the matrix of patterns is large and Gaussian i.i.d.. However, for more general pattern matrices, GAMP convergence is not guaranteed, which has led to the extension of algorithms of the vector AMP (VAMP) type \cite{VAMP} to generalized linear models \cite{schniter2016vector,grVAMP}, including perceptron learning. On the computer science side, many other algorithms for 1BCS combining the enforcement of sparsity and of sign consistency constraints were also proposed, building upon analogous algorithms developed for standard CS. Examples of methods for error-free sparse signal retrieval from one-bit quantized measurements include greedy approaches which iteratively determine the most appropriate sparse support given the sign measurements, such as matching sign pursuit \cite{MSP}, as well as binary iterative hard thresholding (BIHT) \cite{BIHT}, where an $L_1$-based convex consistency-enforcing objective function minimization is alternated with a thresholding operation that selects the $K$ largest elements. The problem of noisy 1BCS was addressed, for instance, in \cite{AOP,NARFPI,R1BCS}. However, among these examples, only \cite{R1BCS} proposes an algorithm which does not require the prior knowledge of the number of corrupted sign measurements. Here, the one-bit measurement errors are modeled by introducing a sparse vector $\boldsymbol{s}$ whose nonzero components produce the sign mismatches as ${\boldsymbol \sigma} = \mathrm{sign} (\mathbf{X} {\bm w}+\boldsymbol{s})$. The algorithm attempts to identify the sign errors and to retrieve the sparse signal $\bm w$ using a variational expectation-maximization (EM) based inference scheme. In this work we propose a new {\em wrapper} strategy where both the variable selection and the classification tasks are simultaneously performed through Expectation Propagation (EP), an iterative scheme to approximate intractable distributions that was introduced first in the field of statistical physics \cite{opper_gaussian_2000,opper_adaptive_2001} and shortly after in the field of theoretical computer science \cite{minka_expectation_2001}. In analogy to what presented in \cite{braunstein2017} in the context of sampling the space of high dimensional polytopes, we show that, by approximating the computationally intractable posterior distribution $P(\bm w | \boldsymbol \sigma, \bf X)$ through a tractable multivariate probability density $Q(\bm w | \boldsymbol \sigma, \bf X)$, we are able to solve both efficiently and accurately the 1BCS problem. We compare our results to those obtained from the AMP and VAMP based schemes proposed in Refs. \cite{onebitAMP} and \cite{grVAMP}, respectively, and to those given by the EM based approach of Ref. \cite{R1BCS}. We provide the factor graphs associated with these algorithms in Fig. \ref{fig:factor-graphs}. We show through simulations that one of the main strengths of the EP-based approach is that it is effective on a wider family of measurement matrices with respect to other relatively similar algorithms such as VAMP and AMP. The paper has the following structure: after this introduction, in Sec.~\ref{sec:methods} we define the problem, and introduce the EP algorithm. In Sec.~\ref{sec:results} we present extensive numerical simulations both in the noiseless and noisy case. Here both i.i.d. and correlated measurement matrices are analyzed. Finally, in Sec.~\ref{sec:conclusions} we summarize the results of the paper and draw the conclusions. \begin{figure} \centering \begin{subfloat}[]{ \includegraphics[width=0.2\textwidth]{./factor_graph_EP.pdf} \label{fig:EP-FG}} \end{subfloat} \qquad\qquad \begin{subfloat}[]{ \includegraphics[width=0.4\textwidth]{./factor_graph_1bitAMP.pdf} \label{fig:1bitAMP-FG}} \end{subfloat} \\ \begin{subfloat}[]{ \includegraphics[width=0.7\textwidth]{./factor_graph_grVAMP.pdf} \label{fig:grVAMP-FG}} \end{subfloat} \\ \begin{subfloat}[]{ \includegraphics[width=0.85\textwidth]{./factor_graph_R1BCS.pdf} \label{fig:R1BCS-FG}} \end{subfloat} \caption{Factor graphs associated with (a) EP, (b) AMP, (c) grVAMP and (d) R1BCS. Variable nodes are represented as circles and function nodes are represented as squares and the notation has been made consistent with that employed in this paper. (a) Tilted distributions in EP (see Section \ref{subsec:EP} for more details), where $\psi$ denotes the exact prior and $\phi$ the approximated Gaussian prior factors in the EP approximation. (b) Factor graph related to AMP. In 1bitAMP, $\Gamma$ are spike-and-slab priors and $P(\sigma_\mu|\boldsymbol{w},\boldsymbol{x}_\mu)=\Theta(\sigma_\mu\boldsymbol{x}^T_\mu\boldsymbol{w})$. (c) Factor graph related to the grVAMP approximation, where we have emphasized the VAMP and MMSE modules composing the algorithm, $\Gamma$ are the same as in (b) and $P(\sigma_\mu|z_\mu)=\Theta(\sigma_\mu z_\mu)$. In (b) and (c), $\Theta$ denotes the Heaviside theta function. (d) Factor graph of the function appearing in the lower bound maximized in R1BCS. The distributions $p(w_i|\alpha_i)p(\alpha_i)$ and $p(s_\mu|\beta_\mu)p(\beta_\mu)$ are hierarchical Gaussian-inverse-Gamma priors assigned to the weights and to the noise components $s_\mu$, respectively, appearing in ${\boldsymbol \sigma} = \mathrm{sign} (\mathbf{X} {\bm w}+\boldsymbol{s})$. The quantities $\alpha_i$ and $\beta_\mu$ are hyperparameters, whereas the quantities $\delta_\mu$ are variational parameters optimized in the maximization step of the algorithm.} \label{fig:factor-graphs} \end{figure} \section{Methods} \label{sec:methods} \subsection{The diluted perceptron as a linear estimation problem and its statistical mechanics setup} We consider a student perceptron with $N$ input units and continuous weights $\boldsymbol{w}\in\mathbb{R}^N$. We assume that the connections are diluted and that only a fraction $\rho$ of them are nonzero. We also assume that $M$ real-valued patterns $\boldsymbol{x}_{\tau}\in\mathbb{R}^N$ are presented to the perceptron and that a binary label $\sigma_{\tau}$, $\tau=1,\dots,M$ has already been assigned to each of them as a result of the classification performed by a teacher perceptron with sparse continuous weights $\boldsymbol{B}$. The task of the student perceptron is to learn the input/output association based on the examples $(\boldsymbol{x}_{\tau},\sigma_{\tau}),\ \tau=1,\dots, M$ provided by the teacher: \begin{equation} \sigma_{\tau}=\text{sign}(\bm{w}^{T}\bm{x}_\tau),\quad \tau=1,\dots,M, \label{eq:classification} \end{equation} where we use the convention that $\text{sign}(0)=1$. For each example $\tau$, the rule \eqref{eq:classification} is equivalent to the condition: \begin{equation} \left(\sigma_{\tau}\bm{x}_\tau^{T}\right)\bm{w}\geq0\,. \label{eq:consistency_constraint} \end{equation} We now introduce the auxiliary variables, $y_{\tau}:=\left(\sigma_{\tau}\bm{x}^{T}_{\tau}\right)\bm{w}$, and the data matrix: \begin{equation} \mathbf{X_\sigma}=\left(\begin{array}{c} \sigma_{1}\bm{x}^{T}_{1}\\ \sigma_{2}\bm{x}^{T}_{2}\\ \vdots\\ \sigma_{M}\bm{x}^{T}_{M} \end{array}\right)\,. \end{equation} Through the previous definitions, we can define the following linear estimation problem: \begin{equation} \bm{y}=\mathbf{X}_\sigma\bm{w}, \label{eq:perceptronLEP} \end{equation} where the variables to be inferred are both $\bm{y}$ and $\bm{w}$. As we will show below, the positivity constraints in Eq.~\eqref{eq:consistency_constraint} will be enforced in terms of a prior distribution on the $\bm{y}$ variables. The linear estimation problem expressed in Eq. \eqref{eq:perceptronLEP} can be addressed in a Bayesian setting: by introducing the variable vector $\bm{h}=\left(w_{1},\dots,w_{N},y_{1},\dots,y_{M}\right)^T$ and the energy function: \begin{equation} E(\bm{w},\bm{y})=\Vert\bm{y}-\mathbf{X}_\sigma\bm{w}\Vert^{2}=\bm{h}^{T}\mathbf{E^{-1}}\bm{h},\quad\mathbf{E}^{-1}=\left(\begin{array}{cc} \mathbf{X}_\sigma^{T}\mathbf{X}_\sigma & -\mathbf{X}_\sigma^T\\ -\mathbf{X}_\sigma & \mathbf{I} \end{array}\right), \end{equation} the likelihood of the set of $N$ weights of the perceptron can be expressed as the Boltzmann distribution associated with $E(\boldsymbol{w},\boldsymbol{y})$, which reads: \begin{equation} \mathcal{L}(\boldsymbol{w})=P(\sigma_1,\dots,\sigma_M|\boldsymbol{w})=\frac{1}{Z}e^{-\beta E(\boldsymbol{w},\boldsymbol{y})}, \end{equation} where, from a statistical physics standpoint, $\beta$ plays the role of an inverse temperature. In the absence of noise, it is convenient to consider the zero temperature limit of this likelihood $\mathcal{L}(\boldsymbol{w})\xrightarrow{\beta\rightarrow\infty}{\delta(\boldsymbol{y}-\mathbf{X}_\sigma\boldsymbol{w})}$, where $\delta(x)$ denotes the Dirac delta distribution. We also introduce prior distributions in order to encode the constraints to which the variables $w_i$, $i=1,\dots,N$, and $y_\tau$, $\tau=1,\dots,M$, are subject. The sparsity assumption on the weights $\boldsymbol{w}$ are expressed in terms of a spike-and-slab prior \cite{spike-and-slab}: \begin{equation} \Gamma(w_{i})=(1-\rho)\delta(w_{i})+\rho\sqrt{\frac{\lambda}{2\pi}}e^{-\frac{\lambda w_{i}^{2}}{2}},\quad i=1,\dots,N. \label{eq:spike-and-slab} \end{equation} If the labels of the teacher are not corrupted by noise, then the auxiliary variables $\boldsymbol{y}$ need to fulfill the positivity constraint \eqref{eq:consistency_constraint}, which can be expressed in terms of the pseudoprior: \begin{equation} \Lambda(y_{\tau})=\Theta(y_{\tau}),\quad\tau=1,\dots,M. \end{equation} On the other hand, if noise at the output of the teacher perceptron is present, one may assume that the labels provided by the teacher perceptron are assigned according to the following process \cite{nishimori2001}: \begin{equation} \tilde{\sigma}=\begin{cases} \text{sign}(\boldsymbol{B}^T\boldsymbol{x}) & \text{with probability}\quad \eta\\ -\text{sign}(\boldsymbol{B}^T\boldsymbol{x}) & \text{with probability}\quad 1-\eta \end{cases} \end{equation} and that the student receives the altered examples $(\boldsymbol{x}_\mu,\tilde{\sigma}_\mu),\ \mu=1,\dots,M$. In this case, if the process that flips the labels is known, then it may be encoded in the pseudoprior $\Lambda$ as follows: \begin{equation} \Lambda(y_\mu)=\eta\Theta(y_\mu)+(1-\eta)\Theta(-y_\mu). \end{equation} In general, the parameters $\rho$, $\lambda$ and $\eta$ are not known and need to be learned by the student perceptron in the training phase. Finally, by Bayes' rule, the posterior distribution of both weights and auxiliary variables read: \begin{equation} P(\boldsymbol{w},\boldsymbol{y})=\frac{1}{Z_P}\delta(\boldsymbol{y}-\mathbf{X}_\sigma\boldsymbol{w})\prod_{i=1}^{N}\Gamma_i(w_i)\prod_{\tau=1}^{M}\Lambda_\tau(y_\tau). \label{eq:posterior} \end{equation} \subsection{Learning the weights via expectation propagation} \label{subsec:EP} \subsubsection{Zero temperature formulation} We wish to infer the values of the weights by estimating the expectation values of the marginals of the distribution \eqref{eq:posterior}, as this strategy minimizes the associated mean squared error. However, the latter marginalizations are intractable and we need to resort to approximation methods. Here we propose an expectation propagation scheme based on the zero temperature formulation presented in \cite{csep2020} in order to solve the problem. Starting from the linear system $\mathbf{X}_\sigma\bm{w}=\bm{y}$, we notice that it can be written as the homogeneous system: \begin{equation} \mathbf{G}\bm{h}=\bm{0}, \end{equation} where $\mathbf{G}=\left(-\mathbf{X}_\sigma|\mathbf{I}\right)$ and $\mathbf{I}$ is the $M\times M$ identity matrix. The intractable posterior distribution reads: \begin{equation} P(\boldsymbol h)= \frac{1}{Z_P}\delta^M(\mathbf{G}\bm{h})\prod_{i\in W}\Gamma_i(h_i)\prod_{\tau\in Y}\Lambda_\tau(h_\tau), \label{eq:posterior_zerotemp} \end{equation} where $W=\{1,\dots,N\}$, $Y=\{N+1,\dots,N+M\}$ and $\delta^M(\boldsymbol z)$ denotes the $M$-dimensional Dirac delta distribution. We introduce Gaussian approximating factors: \begin{equation} \phi_i(h_i)=\exp\left(-\frac{(h_i-a_i)^2}{2d_i}\right), \label{eq:gaussianfactors} \end{equation} and a fully Gaussian approximation of the posterior distribution \eqref{eq:posterior_zerotemp}, in which all priors $\Gamma$ and $\Lambda$ are replaced by factors of the form \eqref{eq:gaussianfactors}: \begin{equation} Q(\boldsymbol{h})=\frac{1}{Z_Q}\delta^M(\mathbf{G}\bm{h})\prod_{i\in W}\phi(h_i;a_i,d_i)\prod_{\tau\in Y}\phi(h_\tau;a_\tau,d_\tau). \end{equation} $Q(\bm{h})$ can be equivalently expressed as: \begin{equation} Q(\boldsymbol{h})=\frac{1}{Z_Q}\delta^M(\mathbf{G}\bm{h})\exp\left(-\frac{1}{2} (\bm{w} - \bar{\bm{w}})^T \bm \Sigma _W^{-1} (\bm{w} - \bar{\bm{w}})\right), \label{eq:Q_distr} \end{equation} where the covariance matrix $\bm \Sigma _W$ and the mean $\bar{\bm w}$ in Eq. \eqref{eq:Q_distr} are given, respectively, by: \begin{equation} \boldsymbol\Sigma _W^{-1}=\sum_{i\in W}\frac{1}{d_i}\boldsymbol{e}_i \boldsymbol{e}^T_i+\mathbf{X}_\sigma^T \left( \sum_{i\in Y}\frac{1}{d_i}\boldsymbol{e}_i \boldsymbol{e}^T_i \right)\mathbf X_\sigma, \label{eq:cov_Q} \end{equation} and by: \begin{equation} \bar{\bm{w}}= \boldsymbol\Sigma _W\left(\sum_{i\in W}\frac{a_i}{d_i}\boldsymbol{e}_i+\sum_{i\in Y}\frac{a_i}{d_i}\mathbf{X}_\sigma^T \boldsymbol{e}_i \right). \end{equation} Here, $\bm{e}_i$ denotes the $i$-th basis vector of the standard basis of $\mathbb{R}^{N}$ (resp. $\mathbb{R}^{M}$) if $i \in W$ (resp. $i \in Y$). Notice that the marginal distributions of $Q(\boldsymbol h)$ for each variable $h_i$ are also Gaussian, with means $\bar{h}_i$ given by: \begin{equation} \bar{h}_i= \begin{cases} \bar{w}_i, \quad i\in W \\ {\boldsymbol e}_i^T\mathbf{X}_{\sigma} \bar{\boldsymbol{w}}, \quad i\in Y, \end{cases} \end{equation} and variances $\Sigma_{ii}$ given by: \begin{equation} \Sigma_{ii}= \begin{cases} \boldsymbol{e} _i^T \boldsymbol{\Sigma}_W \boldsymbol{e} _i, \quad i\in W, \\ \left( \boldsymbol{e} _i^T \mathbf{X}_\sigma \right) \bm{\Sigma}_W \left(\mathbf{X}_\sigma^{T} \boldsymbol{e} _i \right), \quad i\in Y, \end{cases} \end{equation} where for $i\in Y$ we took advantage of the linear constraints $\bm{y}=\mathbf{X}_\sigma\bm{w}$. Notice that the full $(N+M)\times(N+M)$ covariance matrix $\Sigma$ (whose diagonal entries are defined in the previous equation) reads: \begin{equation} \boldsymbol \Sigma = \left( \begin{array}{cc} \boldsymbol \Sigma _W & \Sigma _W \mathbf{X}_\sigma ^T \\ \mathbf{X}_\sigma \Sigma _W & \mathbf{X}_\sigma \Sigma _W \mathbf{X}_\sigma ^T \end{array} \right). \end{equation} We now introduce $N+M$ tilted distributions $Q^{(i)}(\boldsymbol{h})$ for $i=1,\dots,N+M$. In particular, if $i\in W$, we have: \begin{equation} Q^{(i)}(\boldsymbol{h})=\frac{1}{Z_{Q^{(i)}}}\delta^M(\mathbf{G}\bm{h})\Gamma_i(h_i)\prod_{i\in W\setminus\{i\}}\phi(h_i;a_i,d_i)\prod_{\tau\in Y}\phi(h_\tau;a_\tau,d_\tau), \label{eq:leave-one-out-Gamma} \end{equation} whereas, if $i\in Y$: \begin{equation} Q^{(i)}(\boldsymbol{h})=\frac{1}{Z_{Q^{(i)}}}\delta^M(\mathbf{G}\bm{h})\Lambda_i(h_i)\prod_{i\in W}\phi(h_i;a_i,d_i)\prod_{\tau\in Y\setminus\{i\}}\phi(h_\tau;a_\tau,d_\tau). \label{eq:leave-one-out-Lambda} \end{equation} The tilted distributions can be expressed as the product of one of the priors and a Gaussian cavity distribution: \begin{equation} Q^{(i)}(\boldsymbol{h})=\psi_i(h_i)\Tilde{Q}^{(i)}(\bm{h}), \end{equation} where $\psi\in\{\Gamma,\Lambda\}$ and we have denoted the cavity distribution associated with the $i$-th variable by $\Tilde{Q}^{(i)}$: \begin{equation} \Tilde{Q}^{(i)}(\bm{h}) = \frac{1}{Z_{Q^{(i)}}}\delta^M(\mathbf{G}\bm{h}) \exp\left(-\frac{1}{2} (\bm{w}-\bar{\bm{w}}^{(i)})^T \left(\bm{\Sigma}_W^{(i)}\right)^{-1} (\bm{w}-\bar{\bm{w}}^{(i)})\right). \label{eq:cavity-distr} \end{equation} A factor graph representation of the tilted approximation to the posterior distribution is given in Fig. \ref{fig:EP-FG}. The cavity covariance matrices are given by the following expressions: \begin{equation} \left(\bm{\Sigma}_W^{(i)}\right)^{-1} = \begin{cases} \sum_{j\in W\setminus\{i\}}\frac{1}{d_j}\boldsymbol{e}_j \boldsymbol{e}^T_j+\mathbf{X}_\sigma^T \left( \sum_{j\in Y}\frac{1}{d_j}\boldsymbol{e}_j \boldsymbol{e}^T_j \right)\mathbf X_\sigma, & \mbox{if } i \in W, \\ \sum_{j\in W}\frac{1}{d_j}\boldsymbol{e}_j \boldsymbol{e}^T_j+\mathbf{X}_\sigma^T \left( \sum_{j\in Y\setminus\{i\}}\frac{1}{d_j}\boldsymbol{e}_j \boldsymbol{e}^T_j \right)\mathbf X_\sigma, & \mbox{if } i \in Y. \end{cases} \label{cavity_cov} \end{equation} whereas the cavity means read: \begin{equation} \bar{\bm{w}}^{(i)} = \begin{cases} \boldsymbol\Sigma_W^{(i)}\left(\sum_{j\in W\setminus\{i\}}\frac{a_j}{d_j}\boldsymbol{e}_j+\sum_{j\in Y}\frac{a_j}{d_j}\mathbf{X}_\sigma^T \boldsymbol{e}_j \right), & \mbox{if } i \in W, \\ \boldsymbol\Sigma _W^{(i)}\left(\sum_{j\in W}\frac{a_j}{d_j}\boldsymbol{e}_j+\sum_{j\in Y\setminus\{i\}}\frac{a_j}{d_j}\mathbf{X}_\sigma^T \boldsymbol{e}_j \right), & \mbox{if } i \in Y. \end{cases} \end{equation} Similarly to what we obtained for the marginals of Eq. \eqref{eq:Q_distr}, we have that the marginals of Eq. \eqref{eq:cavity-distr} are Gaussian distributions with means: \begin{equation} \bar{h}^{(i)}_i= \begin{cases} \bar{w}^{(i)}_i, \quad \text{if } i\in W \\ {\boldsymbol e}_i^T\mathbf{X}_{\sigma} \bar{\boldsymbol{w}}^{(i)}, \quad \text{if } i\in Y, \end{cases} \end{equation} and variances: \begin{equation} \Sigma^{(i)}_{ii}= \begin{cases} \boldsymbol{e} _i^T \boldsymbol{\Sigma}^{(i)}_W \boldsymbol{e} _i, \quad \text{if } i\in W, \\ \left( \boldsymbol{e} _i^T \mathbf{X}_\sigma \right) \bm{\Sigma}^{(i)}_W \left(\mathbf{X}_\sigma^{T} \boldsymbol{e} _i \right), \quad \text{if } i\in Y. \end{cases} \end{equation} The yet to be determined means $\bm{a}$ and variances $\bm{d}$ of the Gaussian approximating factors \eqref{eq:gaussianfactors} are determined by minimizing the Kullback-Leibler divergence $D_{KL}(Q^{(i)}||Q)$ for all $i=1,\dots,N+M$. It can be shown that each of these minimizations is equivalent to matching the first and second moments of the tilted and of the fully Gaussian approximated distributions: \begin{equation} \langle h_i \rangle_{Q^{(i)}}=\langle h_i \rangle_{Q},\quad \langle h^2_i \rangle_{Q^{(i)}}=\langle h^2_i \rangle_{Q}. \label{eq:mom_matching} \end{equation} The EP update equations follow from the moment matching conditions \eqref{eq:mom_matching}. In particular, recalling that the marginals of $Q(\bm{h})$ are Gaussian distributions, one can express $a_i$ and $d_i$ in terms of the means and variances of $Q^{(i)}$ and in terms of the means and variances of the associated tilted distributions. Indeed, using the fact that the product of Gaussians is a Gaussian and the moment matching conditions, we obtain the EP update rules for the variances $\bm{d}$ and the means $\bm{a}$: \begin{equation} d_i=\left(\frac{1}{\langle h^2_i \rangle_{Q^{(i)}} - \langle h_i \rangle^2_{Q^{(i)}}}-\frac{1}{\Sigma^{(i)}_{ii}}\right)^{-1}, \label{eq:EP_update1} \end{equation} \begin{equation} a_i=\langle h_i \rangle_{Q^{(i)}}+\frac{d_i}{\Sigma^{(i)}_{ii}}\left(\langle h_i \rangle_{Q^{(i)}}-\bar{h}^{(i)}_i\right), \label{eq:EP_update2} \end{equation} for all $i=1,\dots,N+M$. Following \citep{braunstein2017,csep2020}, the cavity variances $\Sigma^{(i)}_{ii}$ and means $\bar{h}_i^{(i)}$ appearing in Eq. \eqref{eq:EP_update1} and \eqref{eq:EP_update2} can be computed in terms of the variances $\Sigma_{ii}$ and means $\bar{h}_i$ using a low rank update rule: \begin{equation} \Sigma^{(i)}_{ii}=\frac{\Sigma_{ii}}{1-\frac{1}{d_i}\Sigma_{ii}}, \label{eq:low-rank-update-sigma} \end{equation} \begin{equation} \bar{h}_i^{(i)}=\frac{\bar{h}_i-\Sigma_{ii}\frac{a_i}{d_i}}{1-\frac{\Sigma_{ii}}{d_i}}, \label{eq:low-rank-update-mu} \end{equation} which allows to perform only one matrix inversion per iteration. EP repeatedly estimates the vectors $\bm{a}$ and $\bm{d}$ until a fixed point is eventually reached. From a practical point of view, the algorithm returns the means and the variances of the marginal tilted distributions as soon as the convergence criterion: \begin{equation} \varepsilon_t:=\max_i{\left\{\left|\langle h_i\rangle_{Q_t^{(i)}} - \langle h_i\rangle_{Q_{t-1}^{(i)}} \right| + \left|\langle h^2_i\rangle_{Q_t^{(i)}} - \langle h^2_i\rangle_{Q_{t-1}^{(i)}} \right|\right\}}<\varepsilon_{\text{stop}} \end{equation} is fulfilled, where $t$ denotes the current iteration and $\varepsilon_{\text{stop}}$ is a convergence threshold. In particular, the posterior mean value of weights learned by the student perceptron are estimated as given by $\langle w_i \rangle_{Q^{(i)}}$, with a standard deviation equal to $\sqrt{\langle w^2_i \rangle_{Q^{(i)}}-\langle w_i \rangle^2_{Q^{(i)}}}$. The zero temperature formulation of EP presented in this section is computationally advantageous compared to the finite temperature one presented in Appendix \ref{appendix: finite T EP}, as its complexity is dominated by the computation of the $N^2$ scalar products between vectors of length $M$ that appear in the second term of the right-hand side of Eq. \eqref{eq:cov_Q} and by the inversion of the $N\times N$ matrix given by the same equation, resulting in a cost $O(MN^2+N^3)$, rather than $O((N+M)\times(N+M))$. In general, in order to reduce the computational burden related to the inversion of the covariance matrix \eqref{eq:cov_Q}, we perform a Cholesky decomposition before inverting. For more details about the finite temperature formulation of EP, we refer to Appendix \ref{appendix: finite T EP}. \subsection{Moments of the tilted distributions} \subsubsection{Moments of the spike-and-slab prior} In this section, we shall compute the first and second moments of the leave-one-out distributions when the prior is of the spike-and-slab type. We recall the expression of the spike-and-slab prior already introduced in Eq. \eqref{eq:spike-and-slab} for the sake of convenience: \begin{equation} \Gamma(h_{k})=(1-\rho)\delta(h_{k})+\rho\sqrt{\frac{\lambda}{2\pi}}e^{-\frac{1}{2}\lambda h_{k}^{2}},\quad k=1,\dots,N. \end{equation} The marginal tilted distribution of each weight of the student perceptron reads: \begin{equation} Q^{(k)}(h_k)=\frac{1}{Z_{Q^{(k)}}}\tilde{Q}_{k}(h_k)\Gamma(h_{k}), \label{eq:tilted_gamma} \end{equation} where we have introduced the marginalized cavity Gaussian distribution $\tilde{Q}_{k}$: \begin{equation} \tilde{Q}_{k}(h_{k};\mu_{k},\Sigma_{k})=\frac{1}{\sqrt{2\pi\Sigma_{k}}}e^{-\frac{(h_{k}-\mu_{k})^{2}}{2\Sigma_{k}}}. \label{eq:cavity-gaussian} \end{equation} From Eq. \eqref{eq:tilted_gamma}, computing the partition function of the tilted distribution $Q^{(k)}$ yields: \begin{equation} Z_{Q^{(k)}}=(1-\rho)\frac{1}{\sqrt{2\pi\Sigma_{k}}}e^{-\frac{\mu_k^{2}}{2\Sigma_{k}}}+\frac{\rho}{\sqrt{2\pi}}\sqrt{\frac{\lambda}{1+\lambda\Sigma_{k}}}e^{-\frac{1}{2}\frac{\lambda\mu_{k}^{2}}{1+\lambda\Sigma_{k}}}. \end{equation} Finally, the first moment and the second moment of the same distribution are given by: \begin{equation} \langle h_{k}\rangle_{Q^{(k)}}=\frac{1}{Z_{Q^{(k)}}}\frac{\rho}{\sqrt{2\pi}}e^{-\frac{1}{2}\frac{\lambda\mu_k^{2}}{1+\lambda\Sigma_{k}}}\sqrt{\frac{\lambda}{1+\lambda\Sigma_{k}}}\frac{\mu_{k}}{1+\lambda\Sigma_{k}}, \end{equation} and by: \begin{equation} \langle h_{k}^{2}\rangle_{Q^{(k)}}=\frac{1}{Z_{Q^{(k)}}}\frac{\rho}{\sqrt{2\pi}}e^{-\frac{1}{2}\frac{\lambda\mu_{k}^{2}}{1+\lambda\Sigma_{k}}}\sqrt{\frac{\lambda}{1+\lambda\Sigma_{k}}}\left(\frac{\Sigma_{k}+\lambda\Sigma_{k}^{2}+\mu_{k}^{2}}{(1+\lambda\Sigma_{k})^{2}}\right), \end{equation} respectively. \subsubsection{Moments of the theta pseudoprior} We now repeat the same reasoning for the case of the theta pseudoprior, which was defined as: \begin{equation} \Lambda(h_k)=\Theta(h_k),\quad k=N+1,\dots,N+M. \end{equation} The associated tilted distribution of the $k$-th variable is given by: \begin{equation} Q^{(k)}(h_k)=\frac{1}{Z_{Q^{(k)}}}\tilde{Q}_{k}(h_k)\Lambda(h_{k}), \quad k=N+1,\dots,N+M, \label{eq:tilted_lambda} \end{equation} where the expression for $\tilde{Q}_{k}$ is the same as in Eq. \eqref{eq:cavity-gaussian}. The normalization of \eqref{eq:tilted_lambda} is the partition function of the tilted distribution and reads: \begin{equation} Z_{Q^{(k)}}=\frac{1}{2}\left[1+\text{erf}\left(\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right], \end{equation} where $erf$ denotes the error function, defined as: \begin{equation} \text{erf}(x)=\frac{2}{\sqrt{\pi}}\int_0^x e^{-z^2}dz. \end{equation} Computing the first moment of the marginal tilted distribution leads to the expression: \begin{equation} \langle h_k \rangle = \mu_k + \sqrt{\frac{\Sigma_k}{2\pi}}\frac{e^-\frac{\mu^2_k}{2\Sigma_k}}{\Phi\left(\frac{\mu_k}{\sqrt{\Sigma_k}}\right)}=\mu_k\left(1+\frac{R(\alpha_k)}{\alpha_k}\right), \end{equation} where $\Phi(x)=\frac{1}{2}\left[1+\text{erf}\left(\frac{x}{\sqrt{2}}\right)\right]$ is the cumulative density function (CDF) of the standard normal distribution, $R(x)=\frac{1}{\sqrt{2\pi}}\frac{e^{-{x^2/2}}}{\Phi(x)}$ and $\alpha_k=\frac{\mu_k}{\sqrt{\Sigma_k}}$. Finally, concerning the second moment of the marginal tilted distribution, one obtains: \begin{equation} \langle h^2_k \rangle = \mu^2_k+\Sigma_k+\mu_k\sqrt{\Sigma_k}R\left(\alpha_k\right), \end{equation} implying that the variance of $h_k$ w.r.t. the $k$-th marginal tilted distribution can be expressed in a compact way by: \begin{equation} \text{Var}(h_k)=\Sigma_k(1-\alpha_k R(\alpha_k)-R^2(\alpha_k)). \end{equation} \subsubsection{Moments of the theta mixture pseudoprior} When the pseudoprior $\Lambda$ is of the theta mixture type: \begin{equation} \tilde{\Lambda}(h_k)=\eta\Theta(h_k)+(1-\eta)\Theta(-h_k), \quad 0\leq \eta\leq 1, \quad k=N+1,\dots,N+M, \label{eq:ThetaMixturePrior} \end{equation} we have for the partition function $Z_{Q^{(k)}}$ of the tilted distributions \eqref{eq:tilted_lambda}: \begin{equation} Z_{Q^{(k)}}=\eta\left[\frac{1}{2}\text{erfc}\left(-\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right]+(1-\eta)\left[\frac{1}{2}\text{erfc}\left(\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right]=\sqrt{\frac{\pi\Sigma_{k}}{2}}\left[\frac{1}{2}+\left(\eta-\frac{1}{2}\right)\text{erf}\left(\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right]. \end{equation} For the first moment, one obtains: \begin{equation} \begin{split} \langle h_k \rangle_{Q^{(k)}} &= \frac{1}{Z_{Q^{(k)}}} \left\{\frac{\eta}{\sqrt{2\pi\Sigma_k}}\left[\Sigma_k e^{-\frac{\mu^2_k}{2\Sigma_k}}+\mu_k\sqrt{\frac{\pi\Sigma_k}{2}}\text{erfc}\left(-\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right] + \right.\\ &+\left. \frac{1-\eta}{\sqrt{2\pi\Sigma_k}}\left[-e^{-\frac{\mu^2_k}{2\Sigma_k}}+\mu_k\sqrt{\frac{\pi\Sigma_k}{2}}\text{erfc}\left(\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right]\right\}=\\ &= \mu_k+\sqrt{\frac{2\Sigma_k}{\pi}}\frac{(2\eta-1)e^{-\frac{\mu_k^2}{2\Sigma_k}}}{\eta\cdot \text{erfc}\left(-\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)+(1-\eta)\text{erfc}\left(\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)}, \end{split} \end{equation} and the second moment w.r.t. the marginal tilted distribution \eqref{eq:tilted_lambda} reads: \begin{equation} \begin{split} \langle h^2_k \rangle_{Q^{(k)}} &= \frac{1}{Z_{Q^{(k)}}}\left\{\frac{\eta}{\sqrt{2\pi\Sigma_k}}\left[\mu_k\Sigma_k e^{-\frac{\mu_k^2}{2\Sigma_k}}+\sqrt{\frac{\pi\Sigma_k}{2}}\left(\mu_k^2+\Sigma_k\right)\text{erfc}\left(-\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right]+\right. \\ &+\left.\frac{1-\eta}{\sqrt{2\pi\Sigma_k}}\left[-\mu_k\Sigma_k e^{-\frac{\mu_k^2}{2\Sigma_k}}+\sqrt{\frac{\pi\Sigma_k}{2}}\left(\mu_k^2+\Sigma_k\right)\text{erfc}\left(\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)\right]\right\}=\\ &=\mu_k^2+\Sigma_k+\mu_k\sqrt{\frac{2\Sigma_k}{\pi}}\frac{(2\eta-1) e^{-\frac{\mu_k^2}{2\Sigma_k}}}{\eta\cdot\text{erfc}\left(-\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)+(1-\eta)\text{erfc}\left(\frac{\mu_k}{\sqrt{2\Sigma_k}}\right)}. \end{split} \end{equation} \section{Results} \label{sec:results} \subsection{Sparse perceptron learning from noiseless examples} In this section, we will present some results obtained from numerical simulations in the presence of noiseless examples, both in the case where patterns are independent and identically distributed (i.i.d.) and in a simple case of correlated patterns. For the sake of simplicity, in all the situations described in the following, we have chosen a Bayes-optimal setting, where the prior information provided by the spike-and-slab prior mirrors the actual distribution of the weights to be retrieved. First, we performed numerical experiments with i.i.d. patterns drawn from a Gaussian distribution having zero mean and unit variance. As a performance measure, we consider the mean squared error between the normalized weights of the student perceptron at the end of the learning process and those of the teacher perceptron: \begin{equation} \mathrm{MSE}(\boldsymbol{\tilde{w}},\boldsymbol{\tilde{B}})=\frac{1}{N}\sum_{k=1}^{N}{(\tilde{w}_k-\tilde{B}_k)^2}, \label{eq:MSE} \end{equation} where $\boldsymbol{\tilde{w}}=\boldsymbol{w}/\Vert \boldsymbol{w} \Vert$ are the rescaled weights of the student and $\boldsymbol{\tilde{B}}=\boldsymbol{B}/\Vert \boldsymbol{B} \Vert$ denote those of the teacher. In our results, this metric is expressed in decibel (dB) and used to compare expectation propagation to the 1-bit Approximate Message Passing (1bitAMP) algorithm introduced in \cite{onebitAMP} and to the grVAMP algorithm proposed within the unified Bayesian framework of general linear models published in reference \cite{grVAMP}, which the authors show to yield equivalent results to the VAMP algorithm for the generalized linear model described in \cite{schniter2016vector}. We refer to Fig. \ref{fig:1bitAMP-FG} and to Fig. \ref{fig:grVAMP-FG} for the factor graphs related to the 1bitAMP and to the grVAMP approximations, respectively. The computational cost of 1bitAMP is $O(N^2)$, while the cost of grVAMP is $O(N^3)$, as it involves a one-time initial singular value decomposition of $\bf X$. However, since this computation is not needed again in the following part of the algorithm, its cost can be neglected for small enough values of $N$. The remaining part of the grVAMP scheme shares the same per iteration computational cost of 1bitAMP, as both are dominated by a matrix-vector product. We considered the average of the MSE \eqref{eq:MSE} over $N_{samples}=100$ simulations. The simulations correspond to sparse perceptron learning of different instances of the weights of the teacher perceptron, each from a different set of i.i.d. Gaussian patterns fed to the student perceptron. We considered the case in which the total number of weights is $N=128$ and their density level is fixed to $\rho=0.25$. The Gaussian part of the spike and slab prior was set to a standard Gaussian distribution in 1bitAMP, EP and grVAMP. The EP convergence threshold was set to $\epsilon_\text{stop}=10^{-4}$ and the value of the damping parameter of the EP algorithm was set equal to 0.9995 (although good results can be obtained using a lower damping too, e.g. 0.99). The results of the simulations for different values of $\alpha$ are reported in Fig. \ref{fig:iid_patterns} and show that EP, 1-bit AMP and grVAMP based learning from i.i.d. Gaussian patterns have roughly the same performance regardless of the specific value of $\alpha$. The convergence criterion was $10^{-4}$ in the 1-bit AMP simulations and $10^{-8}$ in the grVAMP simulations. All the simulations performed using EP, 1-bit AMP and grVAMP converged within the thresholds we considered. The error bars in Fig. \ref{fig:iid_patterns} were estimated as $\sigma/\sqrt{N_{samples}}$, where $\sigma$ denotes the sample standard deviation of the MSE. \begin{figure} \includegraphics[width=0.6\textwidth]{./EP_vs_AMP_vs_grVAMP_iid.pdf} \caption{$MSE$ resulting from sparse weight learning from i.i.d. patterns using EP, 1-bit AMP and grVAMP based estimation as a function of $\alpha$. The parameters considered for the perceptron are $N=128$ and $\rho=0.25$ and the number of instances is $N_{samples}=100$. All simulations converged and the MSE shown is averaged over all the considered instances. The error bars are estimated as $\sigma/\sqrt{N_{samples}}$, where $\sigma$ is the sample standard deviation of the $MSE$ computed over all the instances. } \label{fig:iid_patterns} \end{figure} \begin{figure} \begin{subfloat}[]{ \includegraphics[width=0.47\textwidth]{./ROCcurves_cor.pdf} \label{fig:EP_vs_grVAMP_ROC_cor}} \end{subfloat} \hfill \begin{subfloat}[]{ \includegraphics[width=0.47\textwidth]{./SensitivityPlot_cor.pdf} \label{fig:EP_vs_grVAMP_SensPlot_cor}} \end{subfloat} \\ \begin{subfloat}[]{ \includegraphics[width=0.6\textwidth]{./EP_vs_grVAMP_cor.pdf} \label{fig:EP_vs_grVAMP_MSE_corr}} \end{subfloat} \caption{Sparse perceptron learning from correlated patterns sampled from a multivariate Gaussian distribution. The values of the parameters are specified in each panel and we set $u=1$. Comparison between grVAMP and EP based learning. (a) ROC curves. (b) Sensitivity plots. For reference, in (a,b) the case of ideal variable selection by the teacher perceptron that provided the examples is also shown. (c) Mean squared error in dB. In each plot, the mean values and the standard deviations are computed over the set of all $N$ instances for which convergence was achieved. The error bars are estimated as $\sigma/\sqrt{N}$, where $\sigma$ is the sample standard deviation over the same set of instances.} \label{fig:EP_vs_grVAMP_cor} \end{figure} We also considered the problem of sparse perceptron learning from correlated patterns drawn from a multivariate normal distribution, in the simple case where the mean is $\boldsymbol m=\boldsymbol{0}$ and the covariance matrix is constructed according to: \begin{equation} \mathbf{S}=\mathbf{Y}^T \mathbf{Y}+\boldsymbol{\Delta}, \label{eq: MVN covariance matrix} \end{equation} where $\mathbf{Y} \in \mathbb{R}^{u\times N}$ is an i.i.d. matrix with entries drawn from a standard univariate Gaussian distribution and $\boldsymbol{\Delta}$ is a diagonal matrix whose eigenvalues are given by the absolute value of i.i.d. random entries drawn from the same distribution. By construction, this matrix is symmetric and positive definite and, therefore, is a proper covariance matrix. The diagonal matrix $\boldsymbol{\Delta}$ is added in order to ensure that $\mathbf{S}$ has full rank. As an extreme case, we choose $u=1$ for the matrix $\mathbf{Y}$. \begin{table} \centering \begin{subfloat}[$N=128$]{ \begin{tabular}{|c|c|c|c|c|} \hline $\alpha$ & $f_{EP}$ & $\sigma_{f_{EP}}$ & $f_{grVAMP}$ & $\sigma_{grVAMP}$ \\ \hline 0.5 & 1 & 0 & 1 & 0\\ \hline 1.0 & 1 & 0 & 0.96 & 0.02 \\ \hline 1.5 & 1 & 0 & 0.89 & 0.03 \\ \hline 2.0 & 1 & 0 & 0.83 & 0.04 \\ \hline 2.5 & 1 & 0 & 0.87 & 0.03 \\ \hline 3.0 & 1 & 0 & 0.87 & 0.03 \\ \hline 4.0 & 1 & 0 & 0.85 & 0.04 \\ \hline 5.0 & 1 & 0 & 0.82 & 0.04 \\ \hline 6.0 & 1 & 0 & 0.80 & 0.04 \\ \hline \end{tabular} \label{subtab:first}} \end{subfloat} \qquad\qquad \begin{subfloat}[$N=256$]{ \begin{tabular}{|c|c|c|c|c|} \hline $\alpha$ & $f_{EP}$ & $\sigma_{f_{EP}}$ & $f_{grVAMP}$ & $\sigma_{grVAMP}$ \\ \hline 0.5 & 0.99 & 0.01 & 1 & 0\\ \hline 1.0 & 0.73 & 0.04 & 0.99 & 0.01 \\ \hline 1.5 & 0.92 & 0.03 & 0.94 & 0.02 \\ \hline 2.0 & 0.96 & 0.02 & 0.88 & 0.03 \\ \hline 2.5 & 0.88 & 0.03 & 0.83 & 0.04 \\ \hline 3.0 & 0.88 & 0.03 & 0.73 & 0.04 \\ \hline 4.0 & 0.92 & 0.03 & 0.80 & 0.04 \\ \hline 5.0 & 0.94 & 0.02 & 0.76 & 0.04 \\ \hline 6.0 & 0.96 & 0.02 & 0.70 & 0.05 \\ \hline \end{tabular} \label{subtab:second}} \end{subfloat} \caption{Fraction of converged trials over a set of 100 different instances of the weights of the teacher perceptron and of the training set of examples. The patterns were sampled from the multivariate Gaussian distribution with covariance matrix \eqref{eq: MVN covariance matrix}. The number of variables is $N=128$ and the density of the weights of the teacher is $\rho=0.25$.} \label{tab: conv_EP_grVAMP_cor} \end{table} We find that even in this case the student perceptron is able to estimate the weights of the teacher, although, under the same values of the parameters $N$, $\rho$ and $\alpha$ of the model and under the same values of the EP parameters (i.e. damping, $\epsilon_\text{stop}$ and maximum number of iterations), the accuracy of the estimation is lower than the one achieved by learning from i.i.d. Gaussian patterns, as one might expect. Still, in the presence of the correlated patterns considered here, expectation propagation based learning proves to be advantageous as compared with other algorithms for 1-bit compressed sensing such as 1bitAMP, whose estimates of the means and variances of the weights to be retrieved diverge. In addition, in the same situation, EP outperforms grVAMP based learning, as shown in fig. \ref{fig:EP_vs_grVAMP} for the set of parameters $N=128$ and $\rho=0.25$. The convergence thresholds of the grVAMP and of the EP algorithms were set to the same values as in the case of learning from i.i.d. Gaussian patterns and further lowering the value of the threshold parameter of grVAMP did not result in a noticeable improvement of the grVAMP results. In the case of EP, the damping factor was set to 0.999 and the maximum number of iterations for convergence was 50000. The fraction of converged trials is shown in table \ref{tab: conv_EP_grVAMP_cor} for both algorithms in the case where $N=128$ and $\rho=0.25$. The EP led student perceptron is more accurate at determining the nonzero weights than the grVAMP led counterpart, as shown by the ROC curves in Fig. \ref{fig:EP_vs_grVAMP_ROC_cor} and by the sensitivity plots of Fig. \ref{fig:EP_vs_grVAMP_SensPlot_cor}. In order to construct these curves, each weight of the teacher was assigned a score given by its probability of being nonzero as estimated by EP and grVAMP. The weights of the teacher were sorted in decreasing order according to these probabilities, which are given by: \begin{equation} P_{k}^{\neq0}=\left(1+\left(\frac{1}{\rho}-1\right)\sqrt{\frac{1+\lambda\Sigma_{k}}{\lambda\Sigma_{k}}}e^{-\frac{\mu_{k}^{2}}{2\Sigma_{k}(1+\lambda\Sigma_{k})}}\right)^{-1}. \label{P_nonzero} \end{equation} In the case of EP, $\mu_k$ and $\Sigma_k$, for $k=1,\dots,N$, are the EP cavity means and variances, whereas, in the case of grVAMP, $\boldsymbol{\mu}$ corresponds to the VAMP quantity $\mathbf{r}_{1k}$ and $\Sigma_k=\gamma_{1k}^{-1}$, where $\gamma_{1k}$ is the quantity that parameterizes the denoiser in VAMP \cite{VAMP} and we used the standard VAMP notation for $\mathbf{r}_{1k}$ and $\gamma_{1k}$, for which the index $k$ refers to the number of the current iteration. In both cases, $\rho$ denotes the density parameter of the spike-and-slab prior. Interestingly, the discrepancy between the accuracy of the two algorithms becomes larger as the number of patterns increases and, as a consequence, the difference between the mean squared errors of the two algorithms increases, as shown in Fig. \ref{fig:EP_vs_grVAMP_MSE_corr}, implying that the EP and the grVAMP approximations are very different in this Gaussian correlated pattern regime. This fact is confirmed by the heterogeneity of the variances $d_k,\quad k=1,\dots,N$ of the approximating univariate Gaussian factors $\phi_k$ when one considers the EP solution for instances where both EP and grVAMP converge. More precisely, it can be seen that the parameters $d_k$ span several orders of magnitude, contrary to VAMP where these variances are constrained to be equal. In each plot in Fig. \ref{fig:EP_vs_grVAMP_cor}, we have shown the average of the quantities considered over the set of the $N_{conv}$ instances for which each algorithm achieved convergence. Accordingly, the error bars were estimated as $\sigma/\sqrt{N_{conv}}$, where $\sigma$ denotes the standard deviation over the same set of instances. A useful additional feature of the EP-based learning approach is the possibility to learn iteratively the value of $\rho$ during the estimation of the weights of the teacher, as, unlike EP, many algorithms for 1-bit compressed sensing assume the density of the signal to be given a priori. The estimation of the density parameter is achieved by minimizing the EP free energy with respect to $\rho$ and yields good results as long as the number of the patterns presented to the student is large enough. We refer to the Appendix for details concerning the EP free energy, its expression for the sparse perceptron learning problem and free energy optimization based learning of the parameters of the prior. We mention here that a similar expectation maximization based strategy can be implemented also in the case of 1bitAMP and grVAMP in order to estimate the density parameter $\rho$. In order to show that our approach allows to estimate the dilution level of the teacher perceptron, we performed a set of $N_{samples}=100$ EP simulations on a system with $N=128$ and $\rho=0.25$, where the density parameter $\rho_0$ of the spike-and-slab prior assigned to each weight variable was randomly initialized by sampling its value from a uniform distribution over the interval $0.05\leq\rho_0\leq 0.95$ and where the learning rate was chosen to be $\delta\rho=10^{-5}$. We show our results in table \ref{tab: learning of rho}. For each value of $\alpha$, we show the average value $\rho_L$ of the density estimate over all samples and its associated statistical uncertainty, which was computed as $\delta\rho_L=\sigma_{\rho_L}/\sqrt{N_{samples}}$, as for these values of the parameters all simulations converged. We also show the relative difference $\Delta\rho/\rho$ between the true value of the density and the estimated one. Since $\Delta\rho\gg \delta\rho_L$, we omit the statistical uncertainty associated with $\Delta\rho$. Finally, we notice that, even when learning from correlated patterns constructed as described above, the student is able to estimate the density level of the weights of the teacher perceptron quite accurately, provided that a sufficient number of patterns is provided to the student perceptron. In table \ref{tab: learning of rho}, we give an example of this fact when the teacher perceptron has $N=128$ weights and density $\rho=0.25$. \begin{table} \centering \begin{tabular}{|c|c|c|c|c|} \hline $\alpha$ & i.i.d. patterns: $\rho_L\pm\delta\rho_L$ & i.i.d. patterns: $\Delta\rho/\rho$ & patterns from MVN: $\rho_L\pm\delta\rho_L$ & patterns from MVN: $\Delta\rho/\rho$ \\ \hline 2 & $0.191 \pm 0.003$ & $0.236$ & $0.161\pm 0.004$ & $0.341$ \\ \hline 3 & $0.220 \pm 0.002$ & $0.121$ & $0.196 \pm 0.004$ & $0.206$\\ \hline 4 & $0.234\pm0.002$ & $0.066$ & $0.207 \pm 0.003$ & $0.182$ \\ \hline 5 & $0.240 \pm 0.002$ & $0.042$ & $0.214 \pm 0.003$ & $0.144$\\ \hline 6 & $0.242 \pm 0.001$ & $0.031$ & $0.223 \pm 0.003$ & $0.115$\\ \hline \end{tabular} \caption{Learning of the density $\rho$ of the weights of the teacher for a perceptron with parameters $N=128$ and $\rho=0.25$. The average and the standard deviation of the learned value of $\rho$ at convergence over all the trials for which convergence was achieved during the training process are denoted by $\rho_L$ and $\delta\rho_L$, respectively. In each trial, the initial condition $\rho_0$ was drawn uniformly from the interval $0.05\leq\rho_0\leq 0.95$.} \label{tab: learning of rho} \end{table} \subsection{Sparse perceptron learning from a noisy teacher} \label{subsec: noisy perceptron} We analyzed the performance of EP based sparse perceptron learning when a small fraction of the examples is mislabeled. The student perceptron is given the a priori information that a certain fraction of the labels is wrongly assigned. As in the noiseless case, we consider a Bayes-optimal setting and therefore we provide the student with such a priori knowledge using the theta mixture pseudoprior introduced in Eq. \eqref{eq:ThetaMixturePrior}. In order to test and evaluate the performance of EP-guided learning in this situation, we compared EP with grVAMP, in which we introduced a theta mixture measure as done in EP, and with the R1BCS algorithm for 1-bit compressed sensing with sign-flip errors proposed by Li et al. \cite{R1BCS}, which is based on an expectation maximization scheme involving both the signal to be retrieved and the noise. In grVAMP, the slab part of the spike-and-slab prior was set to a standard Gaussian distribution. When using R1BCS, we rescaled the pattern matrix so that each column had unit norm and we included a convergence threshold $\varepsilon_{R1BCS}=10^{-4}$. Thus, the R1BCS iterations stop when the estimate $\boldsymbol{w}_{R1BCS}$ of the weights of the teacher is such that $\lVert\boldsymbol{w}_{R1BCS}-\boldsymbol{w}_{R1BCS}^{old}\rVert<\varepsilon_{R1BCS}$. In each experiment, a given number $K_{label}=(1-\eta)M$ of labels were flipped, where $\eta$ is the fraction of unchanged labels. In the EP simulations a damping factor equal to 0.99 and a convergence threshold $\epsilon_{\text{stop}}=10^{-6}$ were used. The parameter $\lambda$ of the spike-and-slab prior was set equal to $10^4$. \begin{figure} \centering \begin{subfloat}[]{ \includegraphics[width=0.46\textwidth]{./ROC_noisy_iid-eta0pt95.pdf} \label{fig:EP_vs_R1BCS_ROC_iid}} \end{subfloat} \hfill \begin{subfloat}[]{ \includegraphics[width=0.46\textwidth]{./SP_noisy_iid-eta0pt95.pdf} \label{fig:EP_vs_R1BCS_SP_iid}} \end{subfloat} \\ \begin{subfloat}[]{ \includegraphics[valign=c,width=0.46\textwidth]{./ROC_noisy_cor-eta0pt95.pdf} \label{fig:EP_vs_R1BCS_ROC_cor}} \end{subfloat} \hfill \begin{subfloat}[]{ \includegraphics[valign=c,width=0.47\textwidth]{./SP_noisy_cor-eta0pt95.pdf} \label{fig:EP_vs_R1BCS_SP_cor}} \end{subfloat} \caption{Sparse perceptron learning from i.i.d. patterns sampled from a standard Gaussian distribution and from correlated patterns sampled from a multivariate Gaussian distribution, with $N=128$, $\rho=0.25$, $u=1$, $\eta=0.95$. A fraction $(1-\eta)$ of the labels are mislabeled. Comparison between R1BCS, grVAMP and EP in terms of their ROC curves (a,c) and of their sensitivity plots (b,d). For reference, the case of ideal variable selection by the teacher perceptron that provided the examples is shown. The plotted quantities are the mean values computed over the set of all $N$ instances and the error bars are estimated as $\sigma/\sqrt{N}$ where $\sigma$ denotes the sample standard deviation over all the instances considered. } \label{fig:EP_vs_R1BCS_iid} \end{figure} We first considered the case of i.i.d. Gaussian patterns drawn from a Gaussian distribution with zero mean and unit variance and, subsequently, the case of correlated patterns drawn from the zero mean multivariate Gaussian distribution with the covariance matrix expressed in \eqref{eq: MVN covariance matrix}, which we already introduced in the noiseless case. For both kinds of patterns, we conducted numerical experiments on a set of 100 different instances. In the case of i.i.d patterns, convergence over all instances was achieved for all three algorithms within the convergence thresholds specified. The same was true in the case of correlated patterns for R1BCS and for EP, whereas grVAMP exhibited a failure rate up to $15\%$ in terms of convergence in the correlated case. In order to assess the variable selection capabilities of EP when attempting to learn the weights of the teacher from these kinds of patterns in the presence of mislabeled examples, we computed the ROC curves and the sensitivity plots related to both the former (Fig. \ref{fig:EP_vs_R1BCS_ROC_iid} and \ref{fig:EP_vs_R1BCS_SP_iid}, respectively) and to the latter kind of patterns (Fig. \ref{fig:EP_vs_R1BCS_ROC_cor} and \ref{fig:EP_vs_R1BCS_SP_cor}, respectively). Such ROC curves and sensitivity plots are associated with the weights of the student after the training phase was completed and were obtained in the case where the number of weights was $N=128$, the density of the weights $\boldsymbol{B}$ of the teacher was $\rho=0.25$ and the fraction of uncorrupted labels was $\eta=0.95$. The ordering criterion for the weights $\boldsymbol{B}$ adopted in the ROC curves in Fig. \ref{fig:EP_vs_R1BCS_ROC_iid} and \ref{fig:EP_vs_R1BCS_ROC_cor} and in the sensitivity plots in Fig. \ref{fig:EP_vs_R1BCS_SP_iid} and \ref{fig:EP_vs_R1BCS_SP_cor} was based on the absolute value of the weights $\boldsymbol{w}$ of the student. In the case of EP and grVAMP, we also plotted the ROC and sensitivity curves according to the sorting criterion based on the score expressed in Eq. \eqref{P_nonzero}, but the results did not exhibit noticeable differences with respect to those obtained using the previous sorting criterion, as the curves in Fig. \ref{fig:EP_vs_R1BCS_iid} mostly overlap. The ROC curves and sensitivity plots associated with EP and grVAMP mostly exhibit similar values for the true positive ratio -- except for large $\alpha$, where the EP values are slightly smaller -- and outperform significatively the ones related to R1BCS in the case of i.i.d. patterns, especially at low values of $\alpha$. This is confirmed by the values of the areas under the curves, as shown in Table \ref{subtab:AUC_EP_vs_R1BCS_iid}, where the maximum relative discrepancy between the AUC is 0.008 when considering EP and grVAMP and 0.03 when considering EP and R1BCS. However, in the case of correlated patterns, the ROC curves and sensitivity plots related to EP are mostly comparable to those associated with R1BCS and yield values of the true positive rate that are systematically larger than the ones of grVAMP, implying that the variable selection properties of EP tend to be affected to a far lesser extent than those of grVAMP in this regime, as confirmed by the AUC reported in table \ref{subtab:AUC_EP_vs_R1BCS_cor} and analogously to what was observed in the noiseless case. In this case, the maximum relative discrepancy between the AUC of EP and of R1BCS is 0.05 and is attained at the lowest value of $\alpha$, namely $\alpha=0.5$, whereas, when considering EP and grVAMP, the relative discrepancy is largest at large values of $\alpha$, its maximum being 0.06 at $\alpha=6$. The mean squared error values associated with the normalized student and teacher are plotted in Fig. \ref{fig:MSE-noisy-case} for both $\eta=0.95$ and $\eta=0.9$ and their values are shown both in dB (main plots) and using a linear scale (insets). In particular, the MSE values reported in Fig. \ref{fig:MSE_noise_iid_0.95} correspond to the ROC curves in Fig. \ref{fig:EP_vs_R1BCS_ROC_iid}. While the MSE of EP is definitely larger than that of grVAMP at large $\alpha$ in the presence of i.i.d. patterns (Fig. \ref{fig:MSE_noise_iid_0.95} and Fig. \ref{fig:MSE_noise_iid_0.9}), it should be noted that the differences of the values involved are very small and are not noticeable on a linear scale. Since the EP approximation is richer than the VAMP one, which, in turn, is due to the fact that EP reduces to VAMP when the approximate univariate prior factors are constrained to have the same variance, and because of the very small errors and differences observed, we believe that such observed discrepancy between grVAMP and EP in the i.i.d. pattern regime at large $\alpha$ is due to numerical effects rather than to intrinsic limitations of the EP scheme. Instead, this is not the case for the differences displayed by the MSE related to EP and grVAMP in Fig. \ref{fig:MSE_noise_cor_0.95} for $\eta=0.95$, which are clearly noticeable on a linear scale as well. The discrepancy involved reflects that observed at the level of the ROC curves shown in Fig. \ref{fig:EP_vs_R1BCS_ROC_cor}. Finally, in the Gaussian correlated scenario, as soon as the noise level affecting the labels becomes large enough, we see that EP and grVAMP yield similar results at all values of $\alpha$, as shown in Fig. \ref{fig:MSE_noise_cor_0.9}. Similarly to R1BCS, EP was able to correctly estimate the noise level affecting the labels. This was achieved by sampling the initial condition $\eta_0$ for the parameter $\eta$ of the theta mixture pseudoprior uniformly from the interval $0.5<\eta<1$ and performing one step of gradient descent on the EP free energy at each EP iteration as described in Appendix \ref{app:prior_param_learning}. In addition, analogously to the noiseless case, it is possible to learn the $\rho$ parameter and we verified that the two parameters can be learned simultaneously. We show the estimated values of the density of the weights and of the consistency level $\eta$ of the labels in the case of i.i.d. patterns in table \ref{subtab:learned_eta_iid} and in the case of Gaussian correlated patterns in table \ref{subtab:learned_eta_cor}. We notice that, analogously to EP, an expectation maximization scheme can be implemented in the case of grVAMP in order to iteratively learn the density parameter $\rho$ of the spike-and-slab prior and the $\eta$ parameter of the theta mixture measure. \begin{table}[tb] \centering \begin{subfloat}[AUC (i.i.d. patterns) \label{subtab:AUC_EP_vs_R1BCS_iid}]{ \footnotesize \centering \begin{tabular}{|c|c|c|c|} \hline $\alpha$ & $AUC_{EP}$ & $AUC_{grVAMP}$ & $AUC_{R1BCS}$\\ \hline $ 0.5 $ &$ 0.621 \pm 0.005 $ & $ 0.627 \pm 0.005 $ & $ 0.595 \pm 0.005 $ \\ \hline $ 1.0 $ &$ 0.706 \pm 0.005 $ & $ 0.710 \pm 0.005 $ & $ 0.682 \pm 0.004 $ \\ \hline $ 1.5 $ &$ 0.770 \pm 0.005 $ & $ 0.777 \pm 0.005 $ & $ 0.746 \pm 0.005 $ \\ \hline $ 2.0 $ &$ 0.806 \pm 0.005 $ & $ 0.809 \pm 0.005 $ & $ 0.792 \pm 0.004 $ \\ \hline $ 2.5 $ &$ 0.835 \pm 0.004 $ & $ 0.840 \pm 0.004 $ & $ 0.824 \pm 0.005 $ \\ \hline $ 3.0 $ &$ 0.860 \pm 0.004 $ & $ 0.865 \pm 0.005 $ & $ 0.854 \pm 0.004 $ \\ \hline $ 4.0 $ &$ 0.893 \pm 0.004 $ & $ 0.899 \pm 0.004 $ & $ 0.887 \pm 0.004 $ \\ \hline $ 5.0 $ &$ 0.913 \pm 0.004 $ & $ 0.920 \pm 0.004 $ & $ 0.91 \pm 0.004 $ \\ \hline $ 6.0 $ &$ 0.927 \pm 0.003 $ & $ 0.936 \pm 0.003 $ & $ 0.923 \pm 0.003 $ \\ \hline \end{tabular}} \end{subfloat} \qquad \begin{subfloat}[AUC (patterns from MVN) \label{subtab:AUC_EP_vs_R1BCS_cor}]{ \footnotesize \centering \begin{tabular}{|c|c|c|c|} \hline $\alpha$ & $AUC_{EP}$ & $AUC_{grVAMP}$ & $AUC_{R1BCS}$\\ \hline $ 0.5 $ &$ 0.588 \pm 0.006 $ & $ 0.579 \pm 0.006 $ & $ 0.559 \pm 0.005 $ \\ \hline $ 1.0 $ &$ 0.661 \pm 0.005 $ & $ 0.628 \pm 0.006 $ & $ 0.641 \pm 0.006 $ \\ \hline $ 1.5 $ &$ 0.727 \pm 0.006 $ & $ 0.685 \pm 0.006 $ & $ 0.694 \pm 0.006 $ \\ \hline $ 2.0 $ &$ 0.732 \pm 0.007 $ & $ 0.696 \pm 0.006 $ & $ 0.734 \pm 0.006 $ \\ \hline $ 2.5 $ &$ 0.775 \pm 0.007 $ & $ 0.719 \pm 0.006 $ & $ 0.775 \pm 0.006 $ \\ \hline $ 3.0 $ &$ 0.788 \pm 0.007 $ & $ 0.742 \pm 0.007 $ & $ 0.793 \pm 0.006 $ \\ \hline $ 4.0 $ &$ 0.834 \pm 0.007 $ & $ 0.788 \pm 0.006 $ & $ 0.828 \pm 0.005 $ \\ \hline $ 5.0 $ &$ 0.856 \pm 0.006 $ & $ 0.807 \pm 0.006 $ & $ 0.851 \pm 0.006 $ \\ \hline $ 6.0 $ &$ 0.882 \pm 0.005 $ & $ 0.825 \pm 0.007 $ & $ 0.885 \pm 0.005 $ \\ \hline \end{tabular}} \end{subfloat} \caption{ (a) AUC scores associated with the ROC curves shown in Fig. \ref{fig:EP_vs_R1BCS_ROC_iid}, which correspond to EP, grVAMP and R1BCS based classification from i.i.d. Gaussian patterns in the presence of label noise, with $\eta=0.95$. (b) AUC scores associated with the ROC curves shown in Fig. \ref{fig:EP_vs_R1BCS_ROC_cor}, which correspond to EP, grVAMP and R1BCS based classification from multivariate Gaussian patterns in the presence of label noise, with $\eta=0.95$. } \label{tab:EP_vs_R1BCS_iid} \end{table} \begin{figure} \centering \begin{subfloat}[]{ \includegraphics[valign=c,width=0.46\textwidth]{./noisy-iid-eta0pt95-MSE.pdf} \label{fig:MSE_noise_iid_0.95}} \end{subfloat} \hfill \begin{subfloat}[]{ \includegraphics[valign=c,width=0.46\textwidth]{./noisy-iid-eta0pt9-MSE.pdf} \label{fig:MSE_noise_iid_0.9}} \end{subfloat} \\ \begin{subfloat}[]{ \includegraphics[valign=c,width=0.46\textwidth]{./noisy-cor-eta0pt95-MSE.pdf} \label{fig:MSE_noise_cor_0.95}} \end{subfloat} \hfill \begin{subfloat}[]{ \includegraphics[valign=c,width=0.46\textwidth]{./noisy-cor-eta0pt9-MSE.pdf} \label{fig:MSE_noise_cor_0.9}} \end{subfloat} \caption{Sparse perceptron learning from $(1-\eta)M$ mislabeled examples: comparison between EP, grVAMP and R1BCS in terms of their mean squared errors in the case of (a) i.i.d. Gaussian patterns, $\eta=0.95$, (b) i.i.d. Gaussian patterns, $\eta=0.9$, (c) Gaussian correlated patterns, $\eta=0.95$ and (d) Gaussian correlated patterns, $\eta=0.9$. In all figures, $N=128$ and $\rho=0.25$. The mean squared errors plotted are averaged over the set of all $N$ instances and the error bars are estimated as $\sigma/\sqrt{N}$ where $\sigma$ denotes the sample standard deviation over all the instances considered.} \label{fig:MSE-noisy-case} \end{figure} \begin{table} \begin{subfloat}[i.i.d. patterns \label{subtab:learned_eta_iid}]{ \footnotesize \centering \begin{tabular}{|c|c|c|c|c|} \hline $\alpha$ & $\rho_L$ & $\Delta\rho/\rho$ & $\eta_L$ & $\Delta\eta/\eta$\\ \hline 2.5 & $ 0.229 \pm 0.004 $ & 0.08 & $ 0.964 \pm 0.001 $ & 0.02\\ \hline 3.0 & $ 0.234 \pm 0.003 $ & 0.07 & $ 0.957 \pm 0.003 $ & 0.007\\ \hline 4.0 & $ 0.247 \pm 0.004 $ & 0.01 & $ 0.9584 \pm 0.0005 $ & 0.009\\ \hline 5.0 & $ 0.249 \pm 0.003 $ & 0.003 & $ 0.9561 \pm 0.0007 $ & 0.006\\ \hline 6.0 & $ 0.252 \pm 0.003 $ & 0.007 & $ 0.9544 \pm 0.0004 $ & 0.005\\ \hline \end{tabular}} \end{subfloat} \qquad \begin{subfloat}[patterns from MVN \label{subtab:learned_eta_cor}]{\adjustbox{valign=c}{ \centering \footnotesize \begin{tabular}{|c|c|c|c|c|} \hline $\alpha$ & $\rho_L$ & $\Delta\rho/\rho$ & $\eta_L$ & $\Delta\eta/\eta$\\ \hline 2.5 & $ 0.206 \pm 0.006 $ & 0.2 & $ 0.951 \pm 0.002 $ & 0.0006\\ \hline 3.0 & $ 0.208 \pm 0.006 $ & 0.2 & $ 0.953 \pm 0.001 $ & 0.003\\ \hline 4.0 & $ 0.228 \pm 0.005 $ & 0.09 & $ 0.953 \pm 0.001 $ & 0.003\\ \hline 5.0 & $ 0.23 \pm 0.005 $ & 0.08 & $ 0.9526 \pm 0.0005 $ & 0.003\\ \hline 6.0 & $ 0.236 \pm 0.004 $ & 0.05 & $ 0.9529 \pm 0.0004 $ & 0.003\\ \hline \end{tabular}}} \end{subfloat} \caption{Values of the $\eta$ parameter of the theta mixture pseudoprior estimated by the student perceptron during the training phase when using EP to learn the weights of the teacher (a) from i.i.d. Gaussian patterns and (b) from multivariate Gaussian patterns in the case $N=128$. The estimated value of $\eta$ is denoted as $\eta_L$, the true value being $\eta=0.95$, whereas the true value of the density parameter of the spike-and-slab prior was given by $\rho=0.25$. } \end{table} One important limitation of the R1BCS algorithm as compared with EP (and grVAMP) is that it involves both the inversion of a $N\times N$ matrix and of a $M\times M$ matrix at each iteration. As a consequence, the computational complexity of R1BCS is dominated by $O((1+\alpha^3)N^3)$ operations. Therefore, from a computational point of view, EP is especially advantageous as compared to R1BCS when the number of patterns in the training set is large, as, in the EP formulation proposed in this paper, the computational cost is of order $O((1+\alpha)N^3)$. However, in the large $N$ regime, grVAMP will be faster than EP (and R1BCS) as the only operation that is $O(N^3)$ needs to be performed only once, whereas in EP the operations with cubic cost must be performed at each iteration. In fact, while the VAMP part in grVAMP is faster than EP for the sizes simulated in this paper, we recall that the grVAMP algorithm is composed of two modules (see also Fig. \ref{fig:grVAMP-FG}) implemented as two nested loops: the external loop corresponds to a minimum mean squared error estimation of the linear projection vector $\boldsymbol{z}=\mathbf{X}\boldsymbol{w}$, where $\mathbf{X}$ denotes the matrix of the patterns, under a Gaussian prior and a likelihood having the same functional form of the $\Lambda$ pseudoprior used in EP, whereas the inner loop consists of a VAMP module running on a standard linear model, whose measurement vector is given by the current estimate of $\boldsymbol{z}$, for a predefined number of iterations. We show the running times of R1BCS, EP and grVAMP in Table \ref{tab:runtime_noisy} for the simulated size $N=128$. All the simulations were performed in parallel on a HP Proliant server with 64 cores clocked at 2.1GHz. In grVAMP, the maximum number of iterations of the outer MMSE module loop was set to 1000, while the number of iterations of the inner VAMP module was set to 2000. The comparisons shown in Table \ref{tab:runtime_noisy} are only meant to give an idea of the running times observed for the implementations that we used, which can be found at \texttt{https://github.com/abraunst/GaussianEP} for EP, \texttt{https://github.com/mengxiangming/glmcode} for grVAMP and \texttt{https://github.com/livey/R1BCS} for R1BCS. In particular, grVAMP was adapted by introducing the theta mixture measure and parameters were set in each algorithm as explained in this section. As the VAMP estimation is repeated for every iteration of the external loop, the running times related to grVAMP appear to be larger than those related to EP. \begin{table}[h!tb] \begin{subfloat}[i.i.d. patterns \label{subtab:runtime_noisy_iid}]{\adjustbox{valign=c}{ \centering \footnotesize \begin{tabular}{|c|c|c|c|} \hline $\alpha$ & $t_{EP}$ (s) & $t_{grVAMP}$ (s) & $t_{R1BCS}$ (s)\\ \hline 0.5 & $ 2.7 \pm 0.2 $ & $ 126.7 \pm 0.8 $ & $ 6.5 \pm 0.2 $ \\ \hline 1.0 & $ 2.6 \pm 0.03 $ & $ 134.6 \pm 0.9 $ & $ 12.0 \pm 0.3 $ \\ \hline 1.5 & $ 3.74 \pm 0.04 $ & $ 147.0 \pm 1.0 $ & $ 22.2 \pm 0.5 $ \\ \hline 2.0 & $ 5.65 \pm 0.08 $ & $ 159.0 \pm 1.0 $ & $ 47.6 \pm 1.0 $ \\ \hline 2.5 & $ 6.97 \pm 0.09 $ & $ 175.7 \pm 1.0 $ & $ 94.9 \pm 2.0 $ \\ \hline 3.0 & $ 8.3 \pm 0.1 $ & $ 212.9 \pm 20.0 $ & $ 150.9 \pm 3.0 $ \\ \hline 4.0 & $ 10.2 \pm 0.1 $ & $ 258.3 \pm 10.0 $ & $ 373.4 \pm 7.0 $ \\ \hline 5.0 & $ 12.2 \pm 0.1 $ & $ 311.6 \pm 10.0 $ & $ 628.0 \pm 10.0 $ \\ \hline 6.0 & $ 15.6 \pm 0.2 $ & $ 353.9 \pm 10.0 $ & $ 1052.9 \pm 20.0 $ \\ \hline \end{tabular}}} \end{subfloat} \qquad \begin{subfloat}[patterns from MVN \label{subtab:runtime_noisy_cor}]{\adjustbox{valign=c}{ \centering \footnotesize \begin{tabular}{|c|c|c|c|} \hline $\alpha$ & $t_{EP}$ (s) & $t_{grVAMP}$ (s) & $t_{R1BCS}$ (s)\\ \hline 0.5 & $ 2.7 \pm 0.2 $ & $ 139.2 \pm 2.0 $ & $ 6.7 \pm 0.2 $ \\ \hline 1.0 & $ 3.7 \pm 0.1 $ & $ 155.7 \pm 2.0 $ & $ 14.4 \pm 0.4 $ \\ \hline 1.5 & $ 4.8 \pm 0.1 $ & $ 206.8 \pm 20.0 $ & $ 27.0 \pm 0.7 $ \\ \hline 2.0 & $ 6.2 \pm 0.2 $ & $ 289.0 \pm 40.0 $ & $ 53.6 \pm 1.0 $ \\ \hline 2.5 & $ 7.7 \pm 0.2 $ & $ 236.3 \pm 20.0 $ & $ 105.8 \pm 3.0 $ \\ \hline 3.0 & $ 9.5 \pm 0.3 $ & $ 294.3 \pm 30.0 $ & $ 158.5 \pm 4.0 $ \\ \hline 4.0 & $ 11.4 \pm 0.3 $ & $ 366.9 \pm 40.0 $ & $ 379.4 \pm 8.0 $ \\ \hline 5.0 & $ 14.1 \pm 0.4 $ & $ 423.5 \pm 40.0 $ & $ 592.7 \pm 10.0 $ \\ \hline 6.0 & $ 15.9 \pm 0.4 $ & $ 498.5 \pm 50.0 $ & $ 1057.2 \pm 20.0 $ \\ \hline \end{tabular}}} \end{subfloat} \caption{Running time related to the EP and R1BCS based sparse perceptron learning from (a) i.i.d. Gaussian patterns and from (b) Gaussian patterns from multivariate normal distribution with covariance matrix given by Eq. \eqref{eq: MVN covariance matrix} ($u=1$) in the presence of label noise, with $\eta=0.95$ and damping factor equal to 0.99 in the case of EP. The uncertainty on these values was estimated as $\sigma/\sqrt{N_{conv}}$, where $\sigma$ is the sample standard deviation over the set of converged trials and $N_{conv}$ is the number of converged simulations.} \label{tab:runtime_noisy} \end{table} \subsection{Correlated patterns generated by a recurrent neural network} As an example of diluted network with correlated inputs, we consider a network of $N$ randomly diluted perceptrons without self-loops. We will denote the $i$-th row of the weight matrix $\mathbf{W}\in \mathbb{R}^{N\times(N-1)}$ as $\boldsymbol{w}_i$. Each entry of $\boldsymbol{w}_i$ is the weight of an incoming link of the $i$-th perceptron. Each perceptron receives binary inputs $\boldsymbol{x}$ generated according to a Glauber dynamics at zero temperature. We considered both the case of synchronous update of the patterns at each time step and the case where the binary inputs are updated asynchronously. In the case of synchronous update, starting from an initial random vector $\boldsymbol{x}_0=\text{sign}(\boldsymbol{\xi}_0)$, where $\boldsymbol{\xi}_0\sim \mathcal{N}(\boldsymbol{\xi};\boldsymbol{0},\mathbf{I})$ at discrete time $t=0$ and given a pattern $\boldsymbol{x}^t$ at time $t$, each perceptron computes its output at time $t+1$ according to: \begin{equation} z_{i}^{t}=\boldsymbol{w}_i^{T}\boldsymbol{x}_{\backslash i}^{t}, \label{eq:recnet_measurements} \end{equation} and to: \begin{equation} x_{i}^{t+1}=\text{sign}\left(z_{i}^{t}\right), \label{eq:recnet_patterns} \end{equation} where $\boldsymbol{x}_{\backslash i}^{t}$ denotes the vector of outputs produced by all perceptrons except the $i$-th one at time $t$. The patterns at time $t+1$ are given by the set of outputs resulting from Eq. \eqref{eq:recnet_measurements} and Eq. \eqref{eq:recnet_patterns}. While in principle such a recurrent network dynamics could become trapped in a limit cycle when coupled to a synchronous update rule for the patterns, in practice this never happened when generating such patterns from a recurrent network of $N=128$ diluted perceptrons, each of which having dilution level $\rho=0.25$. In the case of asynchronous updates, at each time step one perceptron $i$ is selected at random and, given a pattern $\boldsymbol{x}^t$ at time $t$, the $i$-th component of the pattern vector at time $t+1$ is computed according to Eq. \eqref{eq:recnet_measurements} and Eq. \eqref{eq:recnet_patterns}, while all other components are left unchanged. In order to tune the degree of correlation of the patterns, we generated them in such a way that two sets of patterns at consecutive times have a given Hamming distance. In order to do so, we ran the Glauber dynamics of the recurrent network as described and updated the patterns asynchronously, but only stored their configuration when the desired Hamming distance between the candidate set of patterns at time $t+1$ and the set of patterns at time $t$ was achieved. We consider the noiseless case and analyze the performance of training all the perceptrons of a student network of the same type of the network that generated the patterns using both EP and grVAMP. We tested the two methods on a network with $N=128$ perceptrons and density parameter of each perceptron given by $\rho=0.25$. We considered both the case where the patterns are generated with the synchronous update rule presented above and the case of asynchronous update. In both cases, the damping parameter of EP was set to 0.999 and the convergence threshold was set to $10^{-4}$ for both EP and grVAMP. In addition, the Gaussian part of the spike-and-slab prior was set to a standard normal distribution in both EP and grVAMP. When considering patterns generated with a synchronous update, both algorithms achieved convergence during the training task for all perceptrons of the recurrent network. We evaluated the ROC curves and the reconstruction error associated with the correct/incorrect selection of the nonzero weights at the level of single perceptron by considering the whole network and computing the average and the standard deviation of the relevant quantities (i.e. the MSE, the fraction of false positives and the fraction of true positives) over all the perceptrons of the student network. Both algorithms were able to select the same fraction of relevant weights, as shown by the vertical portion of the corresponding ROC curves in Fig. \ref{fig:EP_vs_grVAMP_ROC_synchr}, which were constructed by sorting the weights according to their absolute value, in decreasing order. As a consequence, both grVAMP and EP showed comparable values for the MSE between the weights estimated by the student perceptrons and the ones of the corresponding teachers as a function of $\alpha$. Besides, similar values of the MSE were obtained for both algorithms by generating weakly correlated patterns according to an asynchronous generative process and including the generated vector of patterns in the training set only after a full sweep of $N$ updates, i.e. one for each perceptron of the teacher recurrent network. In this situation, the convergence rate of grVAMP was still very large ($\geq 95\%$) at all values of $\alpha$. We show the values of the MSE obtained from these two kinds of weakly correlated patterns in Fig. \ref{fig:EP_vs_grVAMP_full_sweep}. We repeated the same numerical experiments with patterns generated performing an asynchronous update of the perceptron outputs and fixing $d_{H}(\boldsymbol{x}_{t+1},\boldsymbol{x}_{t})=10$, corresponding to a Pearson correlation coefficient $r_{Pearson}=0.84$ between pattern vectors at consecutive times. In this case, the observed convergence rate within the student network was significantly lower for grVAMP than for EP. Although the performance of EP and grVAMP were comparable when considering the subset of perceptrons whose grVAMP guided learning tasks converged (not shown), the ROC curves \ref{fig:EP_vs_grVAMP_ROC_asynchr} and MSE values \ref{fig:EP_vs_grVAMP_SensPlot_asynchr} obtained from these experiments, as evaluated over the $N$ perceptrons of the student network regardless of their convergence status at the end of the training task, show that grVAMP is not able to accurately estimate the weights of the teacher when it fails to converge. The fraction of perceptrons of the recurrent network whose training task successfully converged is plotted in the inset of Fig. \ref{fig:EP_vs_grVAMP_SensPlot_asynchr} for both EP and grVAMP. These results strongly suggest that the observed convergence failure of grVAMP is related to the degree of correlation of the patterns presented to the student. \begin{figure} \begin{subfloat}[]{ \includegraphics[width=0.47\textwidth]{./ROC_sorted_by_prob_recnet_synchr.pdf} \label{fig:EP_vs_grVAMP_ROC_synchr}} \end{subfloat} \hfill \begin{subfloat}[]{ \includegraphics[width=0.47\textwidth]{./EP-grVAMP-full-sweep.pdf} \label{fig:EP_vs_grVAMP_full_sweep}} \end{subfloat} \\ \begin{subfloat}[]{ \includegraphics[width=0.47\textwidth]{./recurrent_net_asynchr10_ROC.pdf} \label{fig:EP_vs_grVAMP_ROC_asynchr}} \end{subfloat} \hfill \begin{subfloat}[]{ \includegraphics[width=0.47\textwidth]{./recurrent_net_asynchr10_MSE.pdf} \label{fig:EP_vs_grVAMP_SensPlot_asynchr}} \end{subfloat} \caption{Comparison between grVAMP and EP based sparse perceptron learning from correlated patterns generated by a recurrent network according to a Glauber dynamics. The case of \emph{weakly correlated} patterns and that of \emph{strongly correlated} patterns are shown in panels (a,b) and in panels (c,d), respectively. The number of perceptrons in the network is $N=128$ and the density of the weights of each perceptron is $\rho=0.25$. In each plot, the mean values and the uncertainties were evaluated over the whole set of $N$ perceptrons. The error bars were estimated as $\sigma/\sqrt{N}$, where $\sigma$ is the sample standard deviation computed over the set of $N$ trained student perceptrons. (a) ROC curves related to the estimated topology of the learned weights of each perceptron for several values of $\alpha$ when patterns are synchronously updated. All $N$ perceptrons achieved convergence during the training task. (b) MSE (in dB) associated with the synchronously updated patterns of (a) and with the asynchronous one in which patterns are included in the training set only after each perceptron was selected to yield the corresponding update (`full sweep'). (c) ROC curves related to the estimated topology of the weights learned from asynchronously updated patterns for several values of $\alpha$. The Hamming distance between sets of patterns at consecutive times was chosen equal to 10. (d) MSE (in dB) corresponding to the case of the patterns considered in (c). The fraction of perceptrons of the recurrent network whose training tasks achieved convergence is shown in the inset.} \label{fig:EP_vs_grVAMP} \end{figure} We verified that the student perceptrons were able to estimate the density of the weights of the teacher perceptrons quite accurately while learning the classification rule of the teacher from this kind of patterns using EP and we checked that it is still possible to estimate the parameter $\eta$ of the theta mixture pseudoprior during the training phase if a fraction of the labels are corrupted by noise, provided that the noise level $1-\eta$ is not too large, similarly to what we observed in the noisy case with i.i.d. patterns and with the correlated patterns drawn from a multivariate normal distribution analyzed in section \ref{subsec: noisy perceptron} of the paper. We provide the estimated noise level in the noisy scenario where $\eta=0.9$ as well as some examples of the estimated values of the density at large values of $\alpha$ in table \ref{tab:parameter_learning_recnet}. The estimate of the parameter $\eta$ proves to be fairly accurate in the case of patterns generated with a synchronous update rule, but is overestimated in the case where the patterns are generated using an asynchronous update rule, as shown in table \ref{subtab:eta_learn_EP_recnet}. \begin{table} \begin{subfloat}[\label{subtab:eta_learn_EP_recnet}]{ \centering \footnotesize \begin{tabular}{|c|c|c|c|c|} \hline $\alpha$ & $\eta_L$, synchr. update & $\Delta\eta/\eta$, synchr. update & $\eta_L$, asynchr. update $(d_H=10)$ & $\Delta\eta/\eta$, asynchr. update\\ \hline 0.5 & $0.86 \pm 0.02$ & $0.05$ & $0.979 \pm 0.004$ & $0.09$\\ \hline 1.0 & $0.96 \pm 0.01$ & $0.06$ & $0.9945 \pm 0.0009$ & $0.1$\\ \hline 1.5 & $0.927 \pm 0.007$ & $0.03$ & $0.991 \pm 0.001$ & $0.1$\\ \hline 2.0 & $0.899 \pm 0.008$ & $0.001$ & $0.983\pm 0.001$ & $0.09$\\ \hline 2.5 & $0.893 \pm 0.007 $ & $0.008$ & $0.975\pm 0.001$ & $0.08$\\ \hline 3.0 & $0.901 \pm 0.001 $ & $0.001$ & $0.967 \pm 0.001$ & $0.07$\\ \hline 4.0 & $0.9036 \pm 0.0008$ & $0.004$ & $0.950 \pm 0.001$ & $0.06$\\ \hline 5.0 & $0.9087 \pm 0.0008$ & $0.01$ & $0.946 \pm 0.001$ & $0.05$\\ \hline 6.0 & $0.9108 \pm 0.0006$ & $0.01$ & $0.9389 \pm 0.0008$ & $0.04$\\ \hline \end{tabular}} \end{subfloat} \\ \begin{subfloat}[\label{fig:recurrent net learned density noiseless}]{ \begin{tabular}{|c|c|c|} \hline Value of $\alpha$ & Estimated $\rho^\text{synchr}$ & Estimated $\rho^\text{asynchr},\ d_H=10$\\ \hline $4.0$ & $0.224 \pm 0.002$ & $0.208 \pm 0.002$\\ \hline $5.0$ & $0.233 \pm 0.002$ & $0.223 \pm 0.002$\\ \hline $6.0$ & $0.237 \pm 0.001$ & $0.231 \pm 0.001$\\ \hline \end{tabular}} \end{subfloat} \caption{(a) Estimate of the parameter $\eta$ of the theta mixture pseudoprior resulting from perceptron learning from the same patterns with label noise. The true unknown value of $\eta$ is 0.9. (b) Estimated value of the density of the weights of single perceptrons in the network at large alphas, both in the case of synchronously updated patterns and in the case of asynchronous update with fixed Hamming distance $d_H=10$ between patterns at consecutive time steps, without label noise. In both (a) and (b), $N=128$ and $\rho=0.25$.} \label{tab:parameter_learning_recnet} \end{table} \section{Conclusions} \label{sec:conclusions} In this paper we have proposed an expectation propagation based strategy for efficient 1-bit compressed sensing reconstruction, whose computational complexity is dominated by $O((1+\alpha)N^3)$ elementary operations. We analyzed the behavior in the zero temperature case and assuming that the patterns are generated by a teacher having the same structure as the student. The performance of the algorithm has been extensively tested under several conditions. For i.i.d. patterns generated by a Gaussian distribution of zero mean and unit variance, the algorithm performance are on par with two other state-of-the art algorithms: 1bitAMP \cite{onebitAMP} and grVAMP \cite{grVAMP}. However, in the correlated Gaussian pattern case, where 1bitAMP fails to converge, EP outperforms grVAMP both in terms of accuracy and specificity. Moreover, both in the i.i.d. and correlated Gaussian case, EP is able to learn with remarkable accuracy the density $\rho$ of the weights of the teacher during the retrieval task. This feature of variational method (EP, 1bitAMP, grVAMP, etc.) puts them at an advantage over other algorithms for 1-bit compressed sensing which require that the dilution level is known and provided among their inputs. We then tested the robustness of EP reconstruction against noise. To do so, we mislabeled a fraction $(1 - \eta )$ of the examples and compared EP with grVAMP and with the R1BCS algorithm \cite{R1BCS} for 1-bit compressed sensing with sign-flip. Again, as in the noiseless case discussed above, we first considered the i.i.d pattern case and then the correlated Gaussian pattern case. The ROC curves and the sensitivity plots associated with EP, grVAMP and R1BCS allow to conclude that the variable selection properties displayed by the three algorithms are not very different in the case of i.i.d. patterns. However, in the case of correlated Gaussian patterns and as long as the noise level affecting the labels is small enough, while on the one hand EP appears to be mostly comparable to R1BCS, on the other hand it systematically and consistently outperforms grVAMP regardless of the specific value of $\alpha$. In addition to the estimation of the density parameter, which we mentioned above in the case of sparse perceptron learning from noiseless examples, EP was able to successfully retrieve the noise level affecting the labels by including in the algorithm an analogous optimization strategy consisting in one step of gradient descent on the EP free energy at each iteration. One important limitation of R1BCS in comparison with EP, is the computational complexity: while the computational complexity of EP is $O((1+\alpha)N^3)$ (at least in the zero temperature case), R1BCS scales as $O((1+\alpha^3)N^3)$ Therefore, from a computational point of view, EP turns out to be especially advantageous in the large $\alpha$ regime as compared to R1BCS, but does not scale as well as grVAMP (and of course 1bitAMP) in terms of simulation time as a function of $N$. Finally, we explored a more realistic scenario for ``temporally'' correlated patterns generated by a recurrent network of $N$ randomly diluted perceptrons both in the case of synchronous and asynchronous update schemes. First, we compared the performance of EP and grVAMP in the noiseless case. The first striking observation is the poor performance of grVAMP in terms of percentage of patterns for which the iterative strategy converges. While EP converges basically on all the presented sets of patterns, the convergence rate drops to less than 20\% for a large interval of $\alpha$ values for grVAMP. EP in this regime shows a remarkable performance both in terms accuracy and sensitivity and is still able to learn the parameters of the priors fairly well. Taken together, these results show that EP is a competitive algorithmic scheme with very good variable selection properties, particularly when one cannot rely on the statistical independence of the entries of the pattern matrix. An important point of strength of the algorithm is the possibility to infer {\it online} the optimal dilution of the problem using a maximum likelihood data-driven iterative strategy, whereas, for other competitive strategies, the dilution is a fixed parameter to set on the basis of some prior knowledge about the problem. In addition, we have shown that the same maximum likelihood online strategy can be used to learn the consistency level of the labels when they are affected by noise. As for the limitations of EP, the main disadvantage is given by its cubic computational complexity, which makes it slower as compared with algorithms such as 1bitAMP and implementations of generalized VAMP. Furthermore, we found that, while EP was able to deal with the task of learning from noisy examples, a not too large level of noise was needed in order for the algorithm to learn the target classification rule with an acceptable accuracy. Finally, although in this work convergence was generally achieved within the thresholds we specified, it is well known that EP can suffer from numerical instabilities that prevent it from converging to its true fixed points. As a consequence, we expect that the results presented in this paper may not be the best results obtainable by means of the EP approximation. Attempting to better understand the convergence properties of EP in the settings presented in this paper as well as in other scenarios will be the object of future work. \begin{acknowledgments} AB, AP, and MP acknowledge funding from INFERNET, a European Union's Horizon 2020 research and innovation program under the Marie Sk\l{}odowska-Curie grant agreement No 734439, and from the SmartData@Polito interdepartmental center for data science of Politecnico di Torino. \end{acknowledgments}
{'timestamp': '2021-02-02T02:14:49', 'yymm': '2009', 'arxiv_id': '2009.09545', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09545'}
arxiv
\section{Introduction}\label{sec:intro} Recently,the mobile device with LiDAR sensor, \textit{e.g.} Ipad Pro4, has been released and Apple has announced that it will release Apple Glass. After the VR industry emerged, it has been receiving a lot of attention from the academia and the public about virtual environments such as VR, AR, and MR around the world~\cite{iotj16lv,etri}. Bringing the real world into virtual reality is another area of VR. The way to implement it is to use a sensor (\textit{e.g.} Microsoft's Azure Kinect, Intel's RealSense, etc.) to get an RGB-D image. The information obtained from the sensor is made into a mesh or point cloud through registration process which convert RGB-D image to point cloud (RGBXYZ) and data pre-processing using the platform((\textit{e.g.} Unity, Unreal Engine or Open3D). After that, rendering is done through a data rendering platform (\textit{e.g.} Hologram, Light Field, or VR). This paper supposes a method that restores the data received from the vision sensor into a complete point cloud and render it, using Azure Kinect as a vision sensor, preprocessing data using Open3D, and rendering it in WebVR. \section{Sensing and Data-Processing} A video of a total of 240 frames was obtained by photographing a room, and this was extracted as a color image and a depth image pair. Azure Kinect, an RGB-D sensor, was used for shooting, and data was obtained using Azure Kinect SDK. Fig.~\ref{dataprocess} is a comprehensive representation of data processing. From the extracted $240$ color images, depth images, and pinhole camera intrinsic matrix, $240$ point clouds are created and mapped to $240$ nodes. Divide all the consecutive nodes by $N$ and group them. The nodes can be expressed as follows: \begin{algorithm}[t!] \caption{ICP-Registration} \begin{algorithmic}[1] \State {\textbf{Input:} The set of RGB-D nodes $\mathcal{A} = \left\{ a_1, \dots, a_m , \dots, a_M \right\}$}, $N$ : the number indicating how many node pairs to divide. \State {\textbf{Output:} The set of point clouds $\mathcal{P} = \left\{ p_1, \dots, p_k, \dots, p_K \right\}$} \Statex \textit{s.t.} $M = N\dot K$ \textit{where} $M,K$ and $N \in \mathcal{N}^1$ \State \textbf{Initialize:} {$\mathcal{P} \leftarrow \left\{\right\}$, $\mathcal{T}=\left\{\right\}$} \State \textbf{Definition:} $s$: source node index, $t$: target node index \textit{s.t.} $ 1 \leq s < t < s + N \leq M$ \Statex {} \State \textbf{for} $s$ in range $M$: \State \hspace{2em} $a_s$ : source node \State \hspace{2em} \textbf{for} $t$ in range $[s, \min(s+ N, M))$: \State \hspace{4em} $a_t$ : target node \State \hspace{4em} $\hat{a}_{s,t} \triangleq T_{s,t}\cdot a_t$ \State \hspace{4em} $T^*_{s,t}\leftarrow \underset{T_{s,t}}{\arg\min}(|a_s-\hat{a}_{s,t}|)$ \State \hspace{4em} $\mathcal{T} \leftarrow \mathcal{T}\cup T^*_{s,t}$ \State \hspace{2em} \textbf{end} \State \textbf{end} \Statex {} \State \textbf{with} Jacobian RGBD odometry method(Input = $\mathcal{A}, \mathcal{T}$) \State \hspace{2em} \textbf{optimize} pose graph \textbf{then} \State \hspace{2em} \textbf{get} $\mathcal{P}$ \State \textbf{end} \end{algorithmic} \label{alg:icp} \end{algorithm} \begin{equation} \nonumber \mathcal{A}=\left\{a_1 ,a_2,…,a_M \right\} \end{equation} And for the above node set, suppose that source and target nodes exist. $a_s$ and $a_t$ represent a source node and a target node, respectively. $s$ and $t$ represent the indexes of the source node and the target node, respectively, which are following $1 \leq s < t < s + N \leq M$. For the source node $a_s$ and the target node $a_t$, there is an edge $T_{s,t}$ that satisfies as follow: \begin{equation} \nonumber \hat{a}_{s,t} \triangleq T_{s,t} \cdot a_t \end{equation} And $\hat{a}_{s,t}$ can be obtained through the following equation: \begin{equation} \nonumber T^*_{s,t} \leftarrow \underset{T_{s,t}}{\arg\min}(|a_s-\hat{a}_{s,t}|) \end{equation} \begin{equation} \nonumber \hat{a}_{s,t} \leftarrow T^*_{s,t} \cdot a_{t} \end{equation} where $T^*_{s,t}$ makes $|a_s- T_{s,t}\cdot a_t|$ minimum value. The set of edges for all $a_s$ and $a_t$ can be expressed as follows: \begin{equation} \nonumber \mathcal{T}=\left\{T_{s,t} | 1 \leq s < t < s + N \leq M, s,t\in N^1 \right\} \end{equation} \begin{figure*}[t!] \centering \includegraphics[page=1, width=1\linewidth]{figure/ov_all.png} \caption{Data processing overview.} \label{dataprocess} \end{figure*} \begin{figure*}[h!] \centering \includegraphics[page=1, width=1\linewidth]{figure/p.png} \caption{Point cloud when local registration is completed.} \label{fig:local} \end{figure*} Since the received RGB-D data is large, down-sampling is performed for each data in order to reduce the amount of computation to obtain the pose graph. Then, proceed with pose graph optimization using \textit{Jacobian RGB-D odometry} method ~\cite{stein2011}. When the optimal pose graph is obtained, a linear transformation operation is taken for each node and edge, and the position and phase are matched for $N$ consecutive point clouds. As a result, $K$ point clouds can be obtained where $K = \lceil240/N\rceil$. The set of point clouds is denoted as $\mathcal{P} = \left\{ p_1, \dots, p_k, \dots, p_K \right\}$. And it can be shown in Fig ~\ref{fig:local}. This process is called ICP-Registration. \begin{figure*}[t!] \centering \includegraphics[page=1, width=1.5\columnwidth]{figure/p5.png} \\ \caption{The result of global registration.} \label{fig:global} \end{figure*} \begin{figure*}[h!] \centering \includegraphics[page=1, width=1.5\columnwidth]{figure/vr.png} \\ \caption{The result of rendering the point cloud using \textit{Three.js}.} \label{fig:vr} \end{figure*} After that, ICP-registration is performed for the $K$ point clouds $\mathcal{P}$ that have been locally registered in the similar way as above to match the location and image of the entire frame. For all natural numbers $k$ where $0<k<K$, define a possible set of $S_{k,k+1}\triangleq(p^s_k, p^t_{k+1})$ as follows. \begin{equation}\nonumber \mathcal{S}\triangleq\left\{S_{1,2}, \cdots, S_{k,k+1}, \cdots, S_{K-1,K}\right\} \end{equation} For all $S_{k,k+1}$, calculate the transformation matrix $V_{k,k+1}$ which minimizes the distances between two point clouds $p^s_k$ and $p^t_{k+1}$. The set of transformation matrices is expressed as follows. \begin{equation} \nonumber \mathcal{V}\triangleq\left\{V_{1,2}, \cdots, V_{k,k+1}, \cdots, V_{K-1,K}\right\} \end{equation} A series of processes is called as global registration that obtains only one point cloud by performing pose graph optimization using the transformation matrix set $\mathcal{V}$ and the point cloud set $\mathcal{P}$ ~\cite{Zhou2014}~\cite{Zhou2016}. And it can be checked through Fig ~\ref{fig:global}. As a result, it is possible to obtain a 3D color map (\textit{i.e}, one completed point cloud) for the captured image. The \textit{Jacobian RGB-D odometry} method was used for ICP-registration, and the process of ICP-registration is shown in Algorithm~\ref{alg:icp}. The tools/libraries used in the experiment are the python 3.6.5, OpenCV 4.2.0, numpy 1.19 and \textit{Open3D} 1.0.0 ~\cite{6631104}~\cite{Zhou2018}. \section{VR Rendering} \textit{Three.js} is a library that renders 3D images on a website ~\cite{noauthororeditor2015threejs}. In addition, it supports image rendering for VR devices, through which WebVR can be implemented. The point cloud can be loaded by through \textit{PCDLoader}, a built-in function of Three.js that can load pcd file. Then if \textit{VRButton}, a module that can render pcd file into VR device, is used, it is possible to show point cloud via VR. Fig.~\ref{fig:vr} represents the result of rendering using \textit{Three.js}. \section{Conclusions And Future Work} We showed the process of receiving RGB-D values from Azure Kinect, obtaining a complete point cloud using \textit{Open3D}, and implementing WebVR through \textit{Three.js}. As shown in Fig.~\ref{fig:global} and ~\ref{fig:vr}, the limitation of this paper is that we could not solve the empty space of point cloud. If solving for empty spaces, and if a point cloud with high resolution can be obtained, it presents the possibility of development that can be applied to hologram and light field technologies. \section*{Acknowledgment} This research was supported by IITP grant funded by the Korea government (MSIP) (No. 2017-0-00068, A Development of Driving Decision Engine for Autonomous Driving using Driving Experience Information). J. Kim is the corresponding author of this paper. \bibliographystyle{IEEEtran}
{'timestamp': '2020-09-22T02:14:13', 'yymm': '2009', 'arxiv_id': '2009.09357', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09357'}
arxiv
\section{Data Normalization} \label{sec:data_normalization} First, we provide the exact normalization of state variables performed before the open-loop learning task is executed. Before training and inducing the non-linear decision tree (NLDT), features in the dataset are normalized using the following equation: \begin{equation} \widehat{x_i} = 1 + (x_i - x_i^{\min})/(x_i^{\max} - x_i^{\min}), \end{equation} where $x_i$ is the original value of the $i$-th feature, $\widehat{x_i}$ is the normalized value of the $i$-th feature, $x_i^{\min}$ and $x_i^{\max}$ are minimum and maximum value of $i$-th feature as observed in the training dataset. This normalization will make every feature $x_i$ to lie within $[1,2]$. This is done to ensure that $x_i=0$ is avoided to not cause a division by zero error. \section{Open Loop NLDT Pruning and Tree Simplification} The NLDT representing our interpretable AI is induced using successive heirarchical spliting algorithm. A dedicated bilevel approach is used to derive the split rule for each conditional node, i.e., if a child node created after the split is still impure (with its impurity $I > \tau_I$), it is subjected to further split. Initially, we allow the tree to grow to a pre-specified maximum depth of $d_{max}$. The resulting tree is fairly complicated with about hundreds of split nodes. Thus, we simplify this tree further to lower depths and remove redundant splits by pruning them. Lower depth trees are relatively simpler than the full grown depth $d_{max}$ tree and also have better generalizability. \section{Problems Used in the Study} In this section, we provide a detail description of the four environments used in this study. \subsection{CartPole Environment} The CartPole problem comprises of four state variables: 1) $x$-position ($x \rightarrow x_0$), velocity in +ve $x$ direction ($v \rightarrow x_1$), angular position from vertical ($\theta \rightarrow x_2$) and angular velocity ($\omega \rightarrow x_3$) and is controlled by applying force towards \emph{left} (Action 0) or \emph{right} (Action 1) to the cart (Figure~\ref{fig:cart_pole_env}). The objective is to balance the inverted pendulum (i.e. $-24\deg \le \theta \le 24\deg$) while also ensuring that the cart doesn't fall off from the platform (i.e. $-4.8 \le x \le 4.8$). For every time step, a reward value of 1 is received while $\theta$ is within $\pm 24\deg$. The maximum episode length is set to 200 time steps. A deep neural network (DNN) controller is trained on the \emph{CartPole} environment using the PPO algorithm \cite{schulman2017proximal}. \begin{figure}[hbt] \begin{subfigure}{0.46\linewidth} \centering\includegraphics[width=\linewidth]{figures/cart_pole.png} \caption{CartPole environment.} \label{fig:cart_pole_env} \end{subfigure}\ \begin{subfigure}{0.51\linewidth} \vspace{-3mm} \begin{subfigure}{\linewidth} \centering \includegraphics[width = \linewidth]{figures/1d_car_following_discrete.png} \caption{CarFollowing environment.} \label{fig:car_following_env} \end{subfigure} \\[2mm] \begin{subfigure}{\linewidth} \centering \includegraphics[width = 0.75 \linewidth]{figures/lunar_lander_env.png \caption{LunarLander environment.} \label{fig:lunar_lander_env} \end{subfigure} \end{subfigure} \caption{Other three control problems.} \label{fig:3problems} \end{figure} \subsection{CarFollowing Environment} As mentioned in the main paper, we have developed a discretized version of the car following problem discussed in \cite{nageshrao2019interpretable} (illustrated in Figure~\ref{fig:car_following_env}), wherein the task is to follow the car in the front which moves with a random acceleration profile (between $-1 m/s^2$ and $+1 m/s^2$) and maintain a safe distance of $d_{safe} = 30 m$ from it. The rear car is controlled using two discrete acceleration values of $+1 m/s^2$ (Action~0) and $-1m/s^2$ (Action~1). The car-chase episode terminates when the relative distance $d_{rel} = x_{front} - x_{rel}$ is either zero (i.e. collision case) or is greater than 150 m. At the start of the simulation, both the cars start with the initial velocity of zero. A DNN policy for CarFollowing problem was obtained using a double Q-learning algorithm \cite{van2015deep}. The reward function for the CarFollowing problem is shown in Figure~\ref{fig:car_following_reward}, indicating that a relative distance close to 30 m produces the highest reward. \begin{figure}[hbt] \centering \includegraphics[width = 0.9\linewidth]{figures/car_following_reward.png} \caption{Reward function for CarFollowing environment.} \label{fig:car_following_reward} \end{figure} It is to note here that unlike the CartPole control problem, where the dynamics of the system was deterministic, the dynamics of the CarFollowing problem is not deterministic due to the random acceleration profile with which the car in the front moves. This randomness introduced by the unpredictable behaviour of the front car makes this problem more challenging. \subsection{MountainCar Environment} A car starts somewhere near the bottom of the valley and the goal of the task is to reach the flag post located on the right up-hill with non-negative velocity (Figure~\ref{fig:m-car}). The fuel is not enough to directly climb the hill and hence a control strategy needs to be devised to move car back (left up-hill), leverage the potential energy and then accelerate it to eventually reach the flag-post within 200 time steps. The car receives the reward value of $-1$ for each time step, until it reaches the flag-post where the reward value is zero. The car is controlled using three actions: \emph{accelerate left} (Action 0), \emph{do nothing} (Action~1) and \emph{accelerate right} (Action~2) by observing its state which is given by two state-variables: \emph{$x$ position $\rightarrow x_0$} and \emph{velocity $v \rightarrow x_1$}. We use the SARSA algorithm \cite{rummery1994line} with tile encoding to derive the black-box AI controller, which is represented in form of a tensor, which has a total of $151,941$ elements. \begin{figure}[hbtp] \centering \includegraphics[width=0.6\linewidth]{figures/m-car.png} \caption{MountainCar Environment.} \label{fig:m-car} \end{figure} \subsection{LunarLander Environment} This problem is motivated form a classic problem of design of a rocket-controller. Here, the state of the lunar-lander is expressed with eight state variables, of which six can assume continuous real values, while the rest two are categorical, and can assume a Boolean value (Figure~\ref{fig:lunar_lander_env}). The first six state variables indicate the ($x,y$) position, and velocity and angular orientation and angular velocity of the lunar-lander. The two Boolean state variables provides the indication regarding the left-leg and right-leg contact of lunar-lander with the ground terrain. The lunar-lander is controlled using four actions: Action~0 $\rightarrow$ \emph{do nothing}, Action~1 $\rightarrow$ \emph{fire left engine}, Action~2 $\rightarrow$ \emph{fire main engine} and Action~3 $\rightarrow$ \emph{fire right engine}. The black-box DNN based controller for this problem is trained using the PPO algorithm \cite{schulman2017proximal} and involves two hidden layers of 64 nodes each. \section{Differences between Open-loop and Closed-loop Searches} The overall search procedure described in Figure~3 in the main paper clearly indicated that it is a two-step optimization procedure. In the first optimization procedure, an open-loop NLDT (NLDT$_{OL}$) is evolved using a bilevel optimization approach applied recursively to derive split-rule $f(\mathbf{x})$ at each conditional node. Here, each training datapoint consists of a time-instant state-action pair obtained using oracle policy $\pi_{oracle}$. One of the objective function of the overall bilevel algorithm is the minimization of the weighted Gini-score ($F_L$, Eq.~6 in main paper), which quantifies the \emph{purity} of nodes created after the split. This measure can also serve as a \emph{proxy} to indicate the error between predicted action and the AI-model action. For a node $P$, the Gini-score is computed as \begin{equation} {\rm Gini}(P) = 1 - \mathlarger{\sum_{i = 1}^c \left(\frac{N_i}{N}\right)^2}, \label{eq:gini} \end{equation} where $N$ is the total number of datapoints in node $P$ and $N_i$ is the number of datapoints present in node $P$ which belongs to \emph{action}-$i$. As can be seen from Eq.~\ref{eq:gini}, the computation of Gini-score is computationally cheap and fast. This eventually makes the computation of $F_L$ (Eq.~6 in main paper) to be cheap and fast, a feature which is desired for any bilevel-algorithm since for each solution member in the \emph{upper-level} of the search, a dedicated full run of \emph{lower-level} optimization is performed and if the lower-level objective function is computationally taxing then it will make the overall bilevel algorithm extremely slow. Additionally, it is to note here that every rule structure ($f_j(\mbox{${\mathbf x}$})$) starting from the root node ($j=0$) is optimized independently by using a subset of the training data dictated by the completed NLDT thus far. Nowhere in the development of the NLDT$_{OL}$, any closed-loop evaluation function (such as, a cumulative reward function of completing the task, or success rate of completion) is used in the optimization process. The structure of the NLDT$_{OL}$ and structure of every rule (with its mathematical structure and coefficients/biases associated with each rule) are evolved. Due to the vastness of the search space of this optimization task, we developed a computationally efficient bilevel optimization procedure composing of a computationally cheap and fast lower-level objective. The two levels allow the structure of each rule and the associated coefficients and biases to be learnt in a hierarchical manner. This is also possible due to recent advances in nonlinear optimization using hybrid evolutionary and point-based local search algorithms \cite{dhebar2020interpretable}. On the contrary, the closed-loop optimization restricts its search to a fixed NLDT structure (which is either identical to NLDT$_{OL}$ or a part of it from the root node, as illustrated in Figure~\ref{fig:nldt_lunar_lander_all}), but modifies the coefficients and biases of all rules simultaneously in order to come up with a better closed-loop performance. Here, an entire episode (a series of time-instance state-action pairs from start ($t=0$) to finish ($t=T$)) can be viewed as a \emph{single} datapoint. As an objective function, the average of cumulative-reward collected across 20 episodes, each with a random starting state $S_0$ is used to make a better evaluation of the resulting NLDT. Due to this aspect, the computational burden is more, but the search process stays in a single level. We employ an efficient real-parameter genetic algorithm with standard parameter settings \cite{deb1995simulated,deb2005multi}. To make the search more efficient, we include the NLDT$_{OL}$ (or its part, as the case may be) in the initial population of solutions for the closed-loop search. The differences between the two optimization tasks are summarized in Table~\ref{tab:diff}. As discussed, both optimization tasks have their role in the overall process. While evaluation of a solution in the open-loop optimization is computationally quicker, it does not use a whole episode in its evaluation process to provide how the resulting rule or NLDT perform on the overall task. The goal here is to maximize the state-action match with the true action as prescribed by $\pi_{oracle}$. This task builds a complete NLDT structure from nothing by finding an optimized rule for every conditional node. The use of a bilevel optimization, therefore, is needed. On the other hand, keeping a part (or whole) of the NLDT$_{OL}$ structure fixed, the closed-loop optimization fine-tunes all associated rules to maximize the cumulative reward $R_{total}$. A closed-loop optimization alone on \emph{episodic} time-instance data to estimate $R_{total}$ will not be computationally tractable in complex problems. \begin{table*}[hbt] \caption{Differences between open-loop and closed-loop optimization problems.} \label{tab:diff} \centering\begin{tabular}{|l|p{2.5in}|p{2.5in}|}\hline Entity & Open-loop Optimization & Closed-loop Optimization \\ \hline Goal & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Find each rule-structure $f_j(\mbox{${\mathbf x}$})$ one at a time from root node $j=0$\end{tabular} & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Find overall NLDT simultaneously\end{tabular} \\ \hline Variables & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Nonlinear structure $B_{ij}$ for $i$-th term for every $j$-th rule, coefficients $w_{ij}$, and biases $\theta_j$\end{tabular} & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Coefficients $w_{ij}$ and biases $\theta_j$ for all rules ($j$) in the NLDT\end{tabular} \\ \hline Each training data & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}State-action pair ($\mbox{${\mathbf x}$}^t$-$\mbox{${\mathbf a}$}^t$) for each time-instance $t$\end{tabular} & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Randomly initialized $M$ Episodes comprising of state-action-reward triplets ($\mbox{${\mathbf x}$}^t$-$\mbox{${\mathbf a}$}^t$-$r_t$, for $t=1,\ldots,T$) for each simulation\end{tabular} \\ \hline Objective function & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Weighted Gini-score (mismatch in actions)\end{tabular} & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Average cumulative reward value\end{tabular} \\ \hline Optimization method & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Bilevel optimization: Upper-level by customized evolutionary algorithm and lower-level by regression\end{tabular} & \begin{tabular}{@{\hspace{1pt}}p{2.5in}}Single-level genetic algorithm\end{tabular} \\ \hline Termination condition & \begin{tabular}{@{\hspace{1pt}}p{2.5in}} Upper level (Change in fitness $< 0.01\%$ for consecutive 5 generations in Upper level GA, with maximum 100 generations).\\ Lower level (Change in fitness $< 0.01\%$ for consecutive 5 generations, with maximum 50 generations). \end{tabular} & 30 generations \\ \hline Outcome & NLDT$_{OL}$ & NLDT* \\ \hline \end{tabular} \end{table*} \section{Additional Results} \subsubsection{NLDT for CarFollowing Problem} The NLDT$_{OL}$ obtained for the CarFollowing problem is shown in Figure~\ref{fig:nldt_CarFollowing}. \begin{figure}[hbt] \centering \includegraphics[width = 0.8\linewidth]{figures/nldt_CarFollowing.png} \caption{NLDT$_{OL}$ for the CarFollowing problem. Normalization constants are: $x^{\min}$ = [0.25, -7.93, -1.00], $x^{\max}$ = [30.30, 0.70, 1.00].} \label{fig:nldt_CarFollowing} \end{figure} The rule-set is provided in its natural if-then-else form in Algorithm~\ref{algo:CarFollowing}. \begin{algorithm} \addtocontents{loa}{\vskip 14.4pt} \caption{Ruleset corresponding to NLDT$_{OL}$ (Figure~\ref{fig:nldt_CarFollowing}) of the CarFollowing problem.} \label{algo:CarFollowing} \eIf{$0.63 \widehat{x_{0}} - 0.87 \widehat{x_{1}}^{-2}\widehat{x_{2}} - 1.00 \le 0$} { \eIf{$0.96 \widehat{x_{1}}^{-3} - 0.58 \widehat{x_{0}} + 1.00 \le 0$}{Action = 1}{Action = 0} } {Action = 1} \end{algorithm} Recall that the physical meaning of state variables is: $x_0 \rightarrow d_{rel}$ (relative distance between front car and rear car), $x_1 \rightarrow v_{rel}$ (relative velocity between front car and rear car) and $x_2 \rightarrow a$ (acceleration value ($-1$ or $+1$ m/s$^2$) at the previous time step). Action = 1 stands for acceleration and Action = 0 denotes deceleration of the rear car in the next time step. From the first rule (Node~0), it is clear that if the rear car is close to the front car ($\widehat{x_0} \approx 1$), the root function $f_0(\mbox{${\mathbf x}$})$ is never going to be positive for any value of relative velocity or previous acceleration of the rear car (both $\widehat{x_1}$ and $\widehat{x_2}$ lying in [1,2]). Thus, Node~4 (Action = 1, indicating acceleration of the rear car in the next time step) will never be invoked when the rear car is too close to the front car. Thus for $\widehat{x_0} \approx 1$, the control always passes to Node~1. A little analysis will also reveal that for $\widehat{x_0} \approx 1$, the rule $f_1(\mbox{${\mathbf x}$}) > 0$ for any relative velocity $\widehat{x_1} \in [1,2]$. This means that when the two cars are relatively close, only Node~3 gets fired to decelerate (Action = 0) the rear car. This policy is intuitively correct, as the only way to increase the gap between the cars is for the controlled rear car to be decelerating. However, when the rear car is far away for which $\widehat{x_0} \approx 2$, Action~1 (Node~4) gets fired if $\widehat{x_1} > 1.829\sqrt{\widehat{x_2}}$. If the rear car was decelerating in the previous time step (meaning $\widehat{x_2} = 1$), the obtained NLDT recommends that the rear car should accelerate if $\widehat{x_1} \in [1.829, 2]$, or when the magnitude of the relative velocity is small, or when $x_1 \in [-0.776, 0.700] m/s$. This will help maintain the requisite distance between the cars. On the other hand, if the rear car was already accelerating in the previous time step ($\widehat{x_2} = 2$), Node~4 does not fire, as $\widehat{x_1}$ can never be more than $1.829\sqrt{2}$ and the control goes to Node~1 for another check. Thus, the rule in Node~0 makes a fine balance of the rear car's movement to keep it a safe distance away from the front car, based on the relative velocity, position, and previous acceleration status. When the control comes to Node~1, Action~1 (acceleration) is invoked if $\widehat{x_1} \geq 0.96/(0.58\widehat{x_0}-1)$. For $\widehat{x_0} \approx 2$, this happens when $\widehat{x_1} > 1.817$ (meaning that when the magnitude of the relative velocity is small, or $x_1 \in [-0.879, 0.700] m/s$), the rear car should accelerate in the next time step. For all other negative but large relative velocities $x_1 \in [-7.930, 0.879] m/s$), meaning the rear car is rushing to catch up the front car, the rear car should decelerate in the next time step. From the black-box AI data, our proposed methodology is able to obtain a simple decision tree with two nonlinear rules to make a precise balance of movement of the rear car and also allowing us to understand the behavior of a balanced control strategy. \begin{figure*}[htbp] \centering \includegraphics[width=0.95\linewidth]{figures/NLDT_LunarLander_all.png} \caption{NLDT-6 (with 26 rules) and other lower depth NLDTs for the LunarLander problem. Lower depth NLDTs are extracted from the depth-6 NLDT. Each node has an associated node-id (on top) and a node-class (mentioned in bottom within parenthesis). Table~6 in main paper provides results on closed-loop performance obtained using these trees \emph{before} and \emph{after} applying re-optimization on rule-sets using the closed-loop training procedure.} \label{fig:nldt_lunar_lander_all} \end{figure*} \subsection{LunarLander Problem} One of the NLDT$_{OL}$s induced using the open-loop supervised training is shown in Figure~\ref{fig:nldt_lunar_lander_all}. The performance of this NLDT$_{OL}$ was presented in the main paper. It has a depth of 6 and it involves a total of 26 rules. The figure also shows how this 26-rule NLDT$_{OL}$ can be pruned to smaller sized NLDTs (such as, NLDT-5, NLDT-4, NLDT-3, NLDT-2) starting from the root node. A compilation of results corresponding to these trees regarding their closed-loop performance before and after re-optimizing them using the closed-loop training is shown in Table~6 of the main paper. The main paper has also presented a four-rule NLDT*-3 obtained by a closed-loop training of the above NLDT-3. \begin{comment} \begin{table*}[hbt] \setcellgapes{5pt} \makegapedcells \centering \caption{Rulesets for NLDT*-3 for LunarLander. Change these tables.} \label{tab:nldt_equations_LunarLander} \begin{tabular}{|@{\hspace{1pt}}c@{\hspace{1pt}}|@{\hspace{1pt}}c@{\hspace{1pt}}|}\hline {\bf Node} & {\bf Rule before Re-optimization}\\\hline 0 & $\left| - 0.45 \hat{x_{1}}^{-3}\hat{x_{3}} - 0.57 \hat{x_{6}}^{-1}\hat{x_{7}}^{-1} + 0.97 \hat{x_{6}}^{-3} - 0.35 \right| - 0.57 $ \\\hline 1 & $\left|0.41 \hat{x_{0}}^{-1}\hat{x_{2}}^{-1} + 0.30 \hat{x_{4}}\hat{x_{7}}^{-2} - 0.63 \hat{x_{5}}^{-1} - 0.90 \right| - 0.73 $ \\\hline 2 & $\left| - 0.33 \hat{x_{3}}^{2} + 0.70 \hat{x_{1}}^{-3} - 0.54 \right| - 0.86 $ \\\hline 48 & $0.98 \hat{x_{0}}^{-3} - 0.21 $ \\\hline \end{tabular}% ~ {\small\begin{tabular}{|@{\hspace{1pt}}H@{\hspace{1pt}}c@{\hspace{1pt}}|}\hline 0 & $\left| - 0.44 \hat{x_{1}}^{-3}\hat{x_{3}} - 0.59 \hat{x_{6}}^{-1}\hat{x_{7}}^{-1} + 0.97 \hat{x_{6}}^{-3} - 0.35 \right| - 0.57 $ \\\hline 1 & $\left|0.41 \hat{x_{0}}^{-1}\hat{x_{2}}^{-1} + 0.30 \hat{x_{4}}\hat{x_{7}}^{-2} - 0.67 \hat{x_{5}}^{-1} - 0.90 \right| - 0.73 $ \\\hline 2 & $\left| - 0.33 \hat{x_{3}}^{2} + 0.70 \hat{x_{1}}^{-3} - 0.54 \right| - 0.78 $ \\\hline 48 & $0.98 \hat{x_{0}}^{-3} - 0.20 $ \\\hline \end{tabular}} \end{table*} \end{comment} To demonstrate the efficacy and repeatability of our proposed approach, we perform another run of the open-loop and closed-loop training and obtain a slightly different NLDT*-3, which is shown in Figure~\ref{fig:nldt_LunarLander_new}. \begin{figure}[htbp] \centering \includegraphics[width = 0.8\linewidth]{figures/nldt_3_LunarLander_new_topology.png} \caption{Topology of Depth-3 NLDT$^{(P)}_{OL}$ obtained from a different run on the LunarLander problem. The equations corresponding the conditional-nodes before and after re-optimization are provided in Table~\ref{tab:LunarLander_new_rules}.} \label{fig:nldt_LunarLander_new} \end{figure} This NLDT also has four rules, which are shown in Table~\ref{tab:LunarLander_new_rules}. Four rules rules at the pruned NLDT$^{(P)}_{OL}$ (Depth 3) are also shown in the table for a comparison. \begin{table*}[htbp] \setcellgapes{5pt} \makegapedcells \centering \caption{NLDT rules before and after the closed-loop training for LunarLander problem, for which NLDT* is shown in Figure~\ref{fig:nldt_LunarLander_new}. Video at {\textcolor{blue}{\url{https://youtu.be/DByYWTQ6X3E}}} shows the simulation output of the performance of NLDTs with rule-sets mentioned in this table. Respective minimum and maximum state variables are $x^{\min}$ = [-0.38, -0.08, -0.80, -0.88, -0.42, -0.85, 0.00, 0.00], $x^{\max}$ = [0.46, 1.52, 0.80, 0.50, 0.43, 0.95, 1.00, 1.00], respectively.} \label{tab:LunarLander_new_rules} \begin{tabular}{|c|c|}\hline {\bf Node} & {\bf Rules before Re-optimization (Depth-3 NLDT$^{(P)}_{OL}$)}\\\hline 0 & $\left| - 0.23 \widehat{x_{0}}\widehat{x_{2}}^{-1}\widehat{x_{6}}^{-1}\widehat{x_{7}}^{-1} - 1.00 \widehat{x_{1}}^{-1}\widehat{x_{6}} - 0.79 \widehat{x_{0}}^{-1}\widehat{x_{1}}^{-1}\widehat{x_{6}}^{2} + 0.83 \right| - 0.85 $ \\\hline 1 & $0.17 \widehat{x_{2}}^{-1} - 0.64 \widehat{x_{3}}\widehat{x_{7}}^{-1} + 0.90 \widehat{x_{1}}^{-2}\widehat{x_{6}}^{-2}\widehat{x_{7}}^{-3} + 0.29 $ \\\hline 2 & $0.82 \widehat{x_{7}}^{-1} + 0.52 \widehat{x_{0}}^{-1}\widehat{x_{4}}\widehat{x_{6}}^{-1} - 0.59 \widehat{x_{4}}^{-1} - 0.95 $ \\\hline 6 & $\left| - 0.16 \widehat{x_{4}}^{-3}\widehat{x_{6}}^{-3}\widehat{x_{7}} - 0.86 \widehat{x_{0}}\widehat{x_{5}}^{-1}\widehat{x_{6}}^{-3} + 1.00 \widehat{x_{4}}\widehat{x_{6}}^{-1} - 0.70 \right| - 0.26 $ \\\hline \end{tabular} \vspace{5pt} \begin{tabular}{|c|c|}\hline {\bf Node} & {\bf Rules after Re-optimization (Depth-3 NLDT*)}\\\hline 0 & $\left| - 0.39 \widehat{x_{0}}\widehat{x_{2}}^{-1}\widehat{x_{6}}^{-1}\widehat{x_{7}}^{-1} - 0.96 \widehat{x_{1}}^{-1}\widehat{x_{6}} - 0.12 \widehat{x_{0}}^{-1}\widehat{x_{1}}^{-1}\widehat{x_{6}}^{2} + 0.89 \right| - 0.80 $ \\\hline 1 & $0.17 \widehat{x_{2}}^{-1} - 0.78 \widehat{x_{3}}\widehat{x_{7}}^{-1} + 0.90 \widehat{x_{1}}^{-2}\widehat{x_{6}}^{-2}\widehat{x_{7}}^{-3} + 0.35 $ \\\hline 2 & $0.82 \widehat{x_{7}}^{-1} + 0.52 \widehat{x_{0}}^{-1}\widehat{x_{4}}\widehat{x_{6}}^{-1} - 0.59 \widehat{x_{4}}^{-1} - 0.96 $ \\\hline 6 & $\left| - \left(1.3 \times 10^{-3}\right)\widehat{x_{4}}^{-3}\widehat{x_{6}}^{-3}\widehat{x_{7}} - 0.86 \widehat{x_{0}}\widehat{x_{5}}^{-1}\widehat{x_{6}}^{-3} + 0.65 \widehat{x_{4}}\widehat{x_{6}}^{-1} - 0.42 \right| - 0.26 $ \\\hline \end{tabular} \end{table*} It can be noticed that the re-optimization of NLDT through closed-loop training (Section~5.2 in main paper)) modifies the values of coefficients and biases, however the basic structure of all four rules remains intact. \subsection{10-link ManAction Vs Time Plots} Action Vs. time plot obtained using NLDT* (SQP), NLDT* (RGA) and DNN for a 10-link serial manipulator problem is shown in Figure~\ref{fig:10_link_plots} \begin{figure*}[t!] \centering \begin{subfigure}[b]{0.3\textwidth} \centering \includegraphics[width=\textwidth]{figures/planar_manipulator_10_DNN.pdf} \caption{DNN} \label{fig:10_link_DNN} \end{subfigure} \hfill \begin{subfigure}[b]{0.3\textwidth} \centering \includegraphics[width=\textwidth]{figures/planar_manipulator_10_classical.pdf} \caption{NLDT* (SQP)} \label{fig:10_link_SQP} \end{subfigure} \hfill \begin{subfigure}[b]{0.3\textwidth} \centering \includegraphics[width=\textwidth]{figures/planar_manipulator_10_rga.pdf} \caption{NLDT* (RGA)} \label{fig:10_link_RGA} \end{subfigure} \caption{Action Vs. Time plot for 10-Link manipulator problem. Figure~\ref{fig:10_link_SQP} provides the plot for NLDT* which is obtained from the NLDT$_{OL}$ trained using SQP algorithm in lower-level. Similarly, Figure~\ref{fig:10_link_RGA} provides the plot for NLDT* which is obtained from the NLDT$_{OL}$ trained using RGA algorithm in lower-level.} \label{fig:10_link_plots} \end{figure*} This is a slightly difficult problem to solve than the 5-link version since it involves twice the number of state variables. Interestingly, the search for NLDT* provides us with the simplest solution to this problem to lift the end-effector to the desired height of 2 units above the base. The simplest solution here is to give a constant torque in one direction as shown in Figure~\ref{fig:10_link_SQP}. However, for this problem the best closed-loop performance in terms of cumulative reward (see Table~8 in main paper) is obtained using the control strategy corresponding to NLDT* (RGA) (Figure~\ref{fig:10_link_RGA}). Here too, for most of the states, only one action is required, and occasionally other actions are invoked. \section{Introduction} Control system problems are increasingly being solved by using modern reinforcement learning (RL) and other machine learning (ML) methods to find an autonomous agent (or controller) to provide an optimal action $A_t$ for every state variable combination $S_t$ in a given environment at every time step $t$. Execution of the output \emph{action} $A_t$ takes the object to the next \emph{state} $S_{t+1}$ in the environment and the process is repeated until a termination criteria is met. The mapping between input \emph{state} $S_t$ and output \emph{action} $A_t$ is usually captured through an artificial intelligence (AI) method. In the RL literature, this mapping is referred to as \emph{policy} $(\pi(S): \mathbb{S} \rightarrow \mathbb{A})$, where $\mathbb{S}$ is the \emph{state space} and $\mathbb{A}$ is the \emph{action space}. Sufficient literature exists in efficient training of these RL \emph{policies} \cite{schulman2015trust, schulman2017proximal, lillicrap2015continuous, mnih2016asynchronous, senda2014acceleration, koga2014stochastic, xu2014clustering}. While these methods are efficient at training the AI policies for a given control system task, the developed AI policies, captured through complicated networks, are complex and non-interpretable. Interpretability of AI policies is important to a human mind due to several reasons: (i) they help provide a better insight and knowledge to the working principles of the derived policies, (ii) they can be easily deployed with a low fidelity hardware, (iii) they may also allow an easier way to extend the control policies for more complex versions of the problem. While defining interpretability is a subjective matter, a number of past efforts have attempted to find interpretable AI policies with limited success \cite{murdoch2019interpretable, lipton2018mythos}. In this work, we aim at generating policies which are \emph{relatively} interpretable and simple as compared to the black-box AI counterparts such as DNN. In the remainder of this paper, we first present the main motivation behind finding interpretable policies in Section~\ref{sec:motivation}. A few past studies in arriving at interpretable AI policies is presented in Section~\ref{sec:past}. In Section~\ref{sec:nldt}, we review a recently proposed nonlinear decision tree (NLDT) approach in the context of arriving at relatively interpretable AI policies. The overall open-loop and closed-loop NLDT policy generation methods are described in Section~\ref{sec:overall}. Results on four control system problems are presented in Section~\ref{sec:results}. Next, a new benchmark problem is proposed to conduct a scale-up study of our algorithm in Section~\ref{sec:scale_up}. Finally, conclusions and future studies are presented in Section~\ref{sec:conclusions}. Supplementary document provides further details. \section{Motivation for the Study} \label{sec:motivation} Various data analysis tasks, such as classification, controller design, regression, image processing, etc., are increasingly being solved using artificial intelligence (AI) methods. These are done, not because they are new and interesting, but because they have been demonstrated to solve complex data analysis tasks without much change in their usual frameworks. With more such studies over the past few decades \cite{lipton2018mythos}, they are faced with a huge challenge. Achieving a high-accuracy solution does not necessarily satisfy a curious domain expert, particularly if the solution is not interpretable or explainable. A technique (whether AI-based or otherwise) to handle data well is no more enough, researchers now demand an explanation of why and how they work \cite{ahmad2018interpretable, goodman2017european}. \begin{comment} \begin{figure}[hbtp] \centering \includegraphics[width=0.7\linewidth]{figures/m-car.png} \caption{MountainCar Problem.} \label{fig:m-car} \end{figure} \end{comment} Consider the MountainCar control system problem (see Supplementary document for details), which has been extensively studied using various AI methods \cite{sutton1996generalization, peters2010relative, smart2000practical}. The problem has two state variables (position $x_t$ along $x$-axis and velocity $v_t$ along positive $x$-axis) at every time instant $t$ which would describe the state of the car at $t$. Based on the state vector $S_t = (x_t, v_t)$, a policy $\pi(S)$ must decide on one of the three actions $A_t$: decelerate ($A_t=0$) along positive $x$-axis with a pre-defined value $-a$, do nothing ($A_t=1$), or accelerate ($A_t=2$) with $+a$ in positive $x$-axis direction. The goal of the control policy $\pi(S)$ is to take the under-powered car (it does not have enough fuel to directly climb the mountain and reach the destination) over the right hump in a maximum of 200 time steps starting anywhere at the trough of the landscape. Physical laws of motion are applied and a policy $\pi(S)$ has been trained to solve the problem. The RL produces a black-box policy $\pi_{oracle}(S)$ for which an action $A_t \in [0,1,2]$ will be produced for a given input $S_t = (x_t, v_t) \in \mathbb{R}^2$. \begin{figure}[hbt] \begin{subfigure}{0.49\linewidth} \centering \includegraphics[width = 1.07\linewidth]{figures/MountainCar_RL_State.png \caption{Using $\pi_{oracle}$.} \label{fig:m-car-RL} \end{subfigure}\ \begin{subfigure}{0.49\linewidth} \centering \includegraphics[width = 1.07\linewidth]{figures/MountainCar_NLDT_State.png \caption{Using NLDT.} \label{fig:m-car-NLDT} \end{subfigure} \caption{State-action combinations for MountainCar prob.} \label{fig:mountain_motivation} \end{figure} Figure~\ref{fig:m-car-RL} shows the state-action combinations obtained from 92 independent successful trajectories (amounting to total of 10,000 time steps) leading to achieving the goal using a pre-trained deterministic black-box policy $\pi_{oracle}$. The $x$-location of the car and its velocity can be obtained from a \emph{point} on the 2D plot. The color of the point $S_t = (x_t, v_t)$ indicates the action $A_t$ suggested by the oracle policy $\pi_{oracle}$ ($A_t=0$: blue, $A_t=1$: orange, and $A_t=2$: green). If a user is now interested in understanding how the policy $\pi_{oracle}$ chooses a correct $A_t$ for a given $S_t$, one way to achieve this would be through an interpretable policy function $\pi_{int}(S_t)$ as follows: \begin{align} \pi_{int}(S_t) &= \left\{\begin{array}{ll} 0, & \mbox{if $\phi_0(S_t)$ is \emph{true}},\\ 1, & \mbox{if $\phi_1(S_t)$ is \emph{true}},\\ 2, & \mbox{if $\phi_2(S_t)$ is \emph{true}}, \end{array}\right. \label{eq:m-car-rule} \end{align} where $\phi_i(S_t): R^2\rightarrow \{0,1\}$ is a Boolean function which partitions the state space $\mathbb{S}$ into two sub-domains based on its output value and for a given state $S_t$, exactly one of $\phi_i(S_t)$ is \emph{true}, thereby making the policy $\pi_{int}$ deterministic. If we re-look at Figure~\ref{fig:m-car-RL} we notice that the three actions are quite mixed at the bottom part of the $x$-$v$ plot (state space). Thus, the partitioning Boolean functions $\phi_i$ need to be quite complex in order to have $\phi_0(S_t)=$~\emph{true} for all \emph{blue} points, $\phi_1(S_t) =$~\emph{true} for all \emph{orange} points and $\phi_2(S_t)=~$\emph{true} for all \emph{green} points. What we address in this study is an attempt to find an {\em approximated\/} policy function $\pi_{int}(S_t)$ which may not replicate and explain all 100\% time instance data corresponding to the oracle black-box policy $\pi_{oracle}(S_t)$ (Figure~\ref{fig:m-car-RL}), but it is fairly interpretable to explain close to 100\% data. Consider the state-action plot in Figure~\ref{fig:m-car-NLDT}, which is generated with a \emph{relatively} simple and \emph{relatively} interpretable policy $\pi_{int}(S_t) = \{i|\phi_i(S_t) \text{ is \emph{true}}, i = 1,2,3\}$ obtained by our proposed procedure as shown below: \begin{equation} \begin{array} {rcl} \phi_0(S_t) &=& \neg\psi_1(S_t), \\ \phi_1(S_t) &=& \left(\psi_1(S_t) \land \neg\psi_2(S_t)\right), \\ \phi_2(S_t) &=& \left(\psi_1(S_t) \land \psi_2(S_t)\right), \end{array} \label{eq:m_car} \end{equation} where $\psi_1(S_t) = |0.96-0.63/\widehat{x_t}^2+0.28/\widehat{v_t}-0.22\widehat{x_t}\widehat{v_t}| \leq 0.36$, and $\psi_2(S_t) = |1.39-0.28\widehat{x_t}^2-0.30\widehat{v_t}^2| \leq 0.53$ represent black and orange boundaries, respectively. Here, $\widehat{x_t}$ and $\widehat{v_t}$ are normalized state variables (see Supplementary document for details). The action $A_t$ predicted using the above policy does not match the output of $\pi_{oracle}$ at some states (about 8.1\%), but from our experiments we observe that it is still able to drive the mountain-car to the destination goal located on the right hill in 99.8\% episodes. \begin{comment} \begin{figure}[hbt] \centering \includegraphics[width = 0.8\linewidth]{figures/MountainCar_NLDT_State.png \caption{Approximate State-action combinations obtained using NLDT.} \label{fig:m-car-NLDT} \end{figure} \end{comment} \begin{comment} \begin{table*}[hbtp] \setcellgapes{5pt} \makegapedcells \centering \caption{Binary-split NLDT rules ($f_i(\mbox{${\mathbf x}$})$) for the mountain-car problem. These rules are obtained on the normalized feature space (see Section~\ref{sec:data_normalization}). $x^{min}$ = [-1.20, -0.06], $x^{max}$ = [0.50, 0.06].} \begin{tabular}{|c|c|}\hline {\bf Node} & {\bf Rule}\\\hline 0 & $\left| - 0.22 \hat{x_{0}}\hat{x_{1}} + 0.28 \hat{x_{1}}^{-1} - 0.63 \hat{x_{0}}^{-2} + 0.96 \right| - 0.36 $ \\\hline 1 & $\left| - 0.30 \hat{x_{1}}^{2} - 0.28 \hat{x_{0}}^{2} + 1.39 \right| - 0.53 $ \\\hline \end{tabular} \label{tab:mountain_car_binar_split_nldt} \end{table*} \end{comment} \begin{comment} $\psi_1(S_t) = |0.69v_t+0.72/(x_t^3v_t^3)-0.81| \leq 0.31$, $\psi_2(S_t) = |-0.76x_t-0.78/(x_t^2v_t)+1.04| \leq 0.35$, $\psi_3(S_t) = |0.88/x_t^2+1/v_t^3-0.89| \leq 0.46$, and $\psi_4(S_t) = |-0.03/x_t^2+0.18x_t^3v_t-1| \leq 0.04$. \end{comment} Importantly, the policies are relatively simpler than the corresponding the black-box policy $\pi_{oracle}$ and amenable to an easier understanding of the relationships between $x_t$ and $v_t$ to make a near perfect control. Since the explanation process used the data from $\pi_{oracle}$ as the universal truth, the derived relationships will also provide an explanation of the working of the black-box policy $\pi_{oracle}$. A more gross approximation to Figure~\ref{fig:m-car-RL} by more simplified relationships ($\phi_i$) may reduce the overall \emph{open-loop} accuracy of matching the output of $\pi_{oracle}$. Hence, a balance between a good interpretability and a high \emph{open-loop} accuracy in searching for Boolean functions $\phi_i(S_t)$ becomes an important matter for such an interpretable AI-policy development study. \begin{comment} There is another important issue which is pertinent for any time-series control problem. An accuracy estimate for each time series data from truth (like what was discussed above, which we refer here as `open-loop' accuracy) is different from the `closed-loop' accuracy which indicates the success rate of arriving at the final goal with a series of state-action decisions. Thus, closed-loop accuracy is a measure of the entire times series state-action decisions, rather than a single state-action decision at a particular time step. Although some decisions may be different from the truth data, but the entire system is able to recover from the errors and is finally able to reach the goal. For the above MountainCar problem, by not following the complex relationships between state-action combinations in the bottom-left part of Figure~\ref{fig:m-car-RL} and using a more smooth relationship approximated in Figure~\ref{fig:m-car-NLDT}, we are still able to achieve 99.8\% closed-loop success, while the open-loop success was 90.83\%. When this happens, we not only have an interpretable control system, but a system which has an excellent closed-loop accuracy. We discuss more about this issue in Section~\ref{sec:m_das_results}. \end{comment} In this paper, we focus on developing a search procedure for arriving at the $\psi$-functions (see Eq.~\ref{eq:m_car}) and their combinations for different discrete action systems. The structure of the policy $\pi_{int}(S_t)$ shown in Eq.~\ref{eq:m-car-rule} resembles a decision tree (DT), but unlike a standard DT, it involves a nonlinear function at every non-leaf node, requiring an efficient nonlinear optimization method to arrive at reasonably succinct and accurate functionals. The procedure we propose here is generic and is independent of the AI method used to develop the black-box policy $\pi_{oracle}$. \section{Related Past Studies} \label{sec:past} \input{literature} \section{Nonlinear Decision Tree (NLDT) Approach}\label{sec:nldt} In this study, we use a direct mathematical rule generation approach (presented in Eq.~\ref{eq:m_car}) using a nonlinear decision tree (NLDT) approach \cite{dhebar2020interpretable}, which we briefly describe here. The intention is to model a relatively simple policy $\pi_{int}$ to approximate and explain the pre-trained black-box policy $\pi_{oracle}$ using the labelled state-action data generated using $\pi_{oracle}$. Decision trees are considered a popular choice due to their interpretability aspects. They are intuitive and each decision can be easily interpreted. However, in a general scenario, regular decision trees often have complicated topology since the rules at each conditional node can assume only axis parallel structure $x_i \le \tau$ to make a split. On the other end, single rule based classifiers like support vector machines (SVMs) have just one rule which is complicated and highly nonlinear. Keeping these two extremes in mind, we develop a nonlinear decision tree framework where each conditional node can assume a nonlinear functional form while the tree is allowed to grow by recursively splitting the data in conditional nodes, similar to the procedure used to induce regular decision trees. In our case of replicating a policy $\pi_{oracle}$, the conditional node captures a nonlinear control logic and the terminal leaf nodes indicate the \emph{action}. This is schematically shown in Figure~\ref{fig:binary_split_nldt}. In the binary-split NLDT, used in this study, a conditional node is allowed to have exactly two splits as shown in Figure~\ref{fig:binary_split_nldt}. \begin{figure}[hbt] \centering \includegraphics[width = 0.9\linewidth]{figures/binary_split_nldt.png} \caption{Schematic of a binary-split NLDT.} \label{fig:binary_split_nldt} \end{figure} The non-linear split rule $f(\mathbf{x})$ at each conditional node is expressed as a weighted sum of power laws: \begin{align} f(\mathbf{x}) = \begin{cases} \sum_{i=1}^pw_iB_i + \theta_1, \quad \mbox{if $m = 0$},\\ \left|\sum_{i=1}^pw_iB_i + \theta_1\right| - |\theta_2|, \quad \mbox{if $m = 1$}, \end{cases} \label{eq:binary_split_rule} \end{align} where power-laws $B_i$ are given as $ B_i = \prod_{j=1}^d x_j^{b_{ij}}$ and $m$ indicates if an absolute operator should be present in the rule or not. In Section~\ref{sec:nldt_open_loop}, we discuss procedures to derive values of exponents $b_{ij}$, weights $w_i$, and biases $\theta_i$. \section{Overall Approach} \label{sec:overall} The overall approach is illustrated in Figure~\ref{fig:iai_rl_flowchart}. \begin{figure*}[hbt] \centering \includegraphics[width = 0.9\linewidth]{figures/iai_rl_flowchart.png} \caption{A schematic of the proposed overall approach.} \label{fig:iai_rl_flowchart} \end{figure*} First, a dedicated black-box policy $\pi_{oracle}$ is trained from the actual environment/physics of the problem. This aspect is not the focus of this paper. Next, the trained policy $\pi_{oracle}$ (Block 1 in the figure) is used to generate labelled training and testing datasets of \emph{state-action} pairs from different time steps. We generate two types of training datasets: \emph{Regular} -- as they are recorded from multiple episodes\footnote{an \emph{episode} is one simulation run.}, and \emph{Balanced} -- \emph{selected} from multiple episodes to have almost equal number of \emph{states} for each action, where an \emph{episode} is a complete simulation of controlling an object with a policy over multiple time steps. Third, the labelled training dataset (Block 2) is used to find the NLDT (Block 3) using the recursive bilevel evolutionary algorithm described in Section~\ref{sec:nldt_open_loop}. We call this an open-loop NLDT (or, NLDT$_{OL}$), since it is derived from a labelled state-action dataset generated from $\pi_{oracle}$, without using any overall reward or any final goal objective in its search process, which is typically a case while doing reinforcement learning. Use of labelled state-action data in supervised manner allows a faster search of NLDT even with a large dataset as compared to constructing the NLDT from scratch through reinforcement learning by interacting with the environment to maximize the cumulative rewards \cite{verma2018programmatically}. Next, in an effort to make the overall NLDT interpretable while simultaneously ensuring better closed-loop performance, we prune the NLDT by taking only the top part of NLDT$_{OL}$ (we call NLDT$^{(P)}_{OL}$ in Block 4) and \emph{re-optimize} all non-linear rules within it for the weights and biases using an efficient evolutionary optimization procedure to obtain final NLDT* (Block 5). The re-optimization is done here with closed-loop objectives, such as the cumulative reward function or closed-loop completion rate. We briefly discuss the open-loop training procedure of inducing NLDT$_{OL}$ and the closed-loop training procedure to generate NLDT* in next sections. \subsection{Open-loop Training} \label{sec:nldt_open_loop} A labelled state-action dataset is first created using a pre-trained black-box policy $\pi_{oracle}$. Since we are dealing with discrete-action control problems, the underlying imitation task of replicating the behavior of $\pi_{oracle}$ using the labelled state-action data translates to a \emph{classification} problem. We train NLDT discussed in Section~\ref{sec:nldt} to fit the state-action data through supervised learning. Nonlinear split-rule $f(\mathbf{x})$ at each conditional node (Figure~\ref{fig:binary_split_nldt} and Eq.~\ref{eq:binary_split_rule}) is derived using a dedicated bilevel optimization algorithm \cite{bilevel-review}, where the upper level searches the \emph{template} of the non-linear rule and the corresponding lower level focuses at estimating optimal values of \emph{weights/coefficients} for optimal split of data present in the conditional node. The optimization formulation for deriving a non-linear split rule $f(\mathbf{x})$ (Eq.~\ref{eq:binary_split_rule}) at a given conditional node is given below: \begin{equation} \hspace*{-2mm}\begin{array}{rl} \text{Minimize}& F_U(\mathbf{B},m,\mathbf{w}^{\ast}, \boldsymbol{\theta}^{\ast}), \\ \text{subject to} & (\mathbf{w}^{\ast}, \boldsymbol{\theta}^{\ast}) \in {\rm argmin}\left\{F_L(\mathbf{w}, \boldsymbol{\theta})|_{(\mathbf{B}, m)} \big| \right. \\ & \quad F_L(\mathbf{w}, \boldsymbol{\theta})|_{(\mathbf{B},m)} \leq \tau_I,\\ & \quad \left. -1\leq w_i \leq 1, \ \forall i,\ \boldsymbol{\theta} \in [-1,1]^{m+1}\right\},\\ & m \in \{0,1\}, b_{ij} \in {\cal Z}, \end{array} \label{eq:bilevel_formulation_binary_split} \end{equation} where ${\cal Z}$ is a set of exponents allowed to limit the complexity of the derived rule structure. In thus study, we use ${\cal Z}=\{-3,-2,-1,0,1,2,3\}$. The objective $F_U$ quantifies the complexity of the non-linear rule by enumerating the number of terms present in the equation of the rule $f(\mathbf{x})$ as shown below: \begin{align} \label{eq:simplification_metric} & F_U(\mathbf{B},m,\mathbf{w}^{\ast}, \boldsymbol{\theta}^{\ast}) = \sum_{i=1}^{p}\sum_{j=1}^{d}g(b_{ij}), \end{align} where $g(\alpha) = 1$, if $\alpha \ne 0$, zero otherwise. $m$ indicates the presence or absence of a modulus operator and $\mathbf{w}$ and $\boldsymbol{\theta}$ encodes rule weights $w_i$ and biases $\theta_i$ respectively. The lower level objective function $F_L$ quantifies the net impurity of child nodes resulting from the split. Impurity $I$ of a node $P$ is computed using a Gini-score: $\text{Gini}(P) = 1 - \sum_i^c\left(\frac{N_i}{N}\right)^2$, where $N$ is the total number of points present in the node and $N_i$ represents number of points belonging to class $i$. Datapoints present in node $P$ gets distributed into two non-overlapping subsets based on their split function value. Datapoints with $f(\mathbf{x}) \le 0$ go to the left child node $L$ and rest go to the right child node $R$. The lower level objective function $F_L$ which quantifies the quality of this split is then given by \begin{equation} \small F_L(\mathbf{w}, \boldsymbol{\theta})|_{(\mathbf{B}, m)} = \left(\frac{N_L}{N_P}\text{Gini}(L) + \frac{N_R}{N_P}\text{Gini}(R)\right)_{(\mathbf{w},\boldsymbol{\theta},\mathbf{B},m)}. \label{eq:F_L_binary_split} \end{equation} The $\tau_I$ parameter in Eq.~\ref{eq:bilevel_formulation_binary_split} represents maximum allowable net-impurity (Eq.~\ref{eq:F_L_binary_split}) of child nodes. The resulting child nodes obtained after the split undergo another split and the process continues until one of the termination criteria is met. More details regarding the bilevel-optimization algorithm \cite{bilevel-review} to derive split-rule $f_i(\mathbf{x})$ at $i$-th conditional node in NLDT can be found in \cite{dhebar2020interpretable}. After the entire NLDT is found, in this study, a pruning and tree simplification strategy (see Supplementary Document for more details) is applied to reduce the size of NLDT in an effort to improve on the interpretability of the overall rule-sets. This entire process of inducing NLDT from the labelled state-action data results into the open-loop NLDT -- NLDT$_{OL}$. NLDT$_{OL}$ can then be used to explain the behavior of the oracle policy $\pi_{oracle}$. We will see in Section~\ref{sec:results} that despite being not 100\% accurate in imitating $\pi_{oracle}$, NLDT$_{OL}$ manages to achieve respectable closed-loop performance with 100\% completion rate and a high cumulative reward value. Next, we discuss the closed-loop training procedure to obtain NLDT*. \subsection{Closed-loop Training \label{sec:closed_loop_training} The intention behind the closed-loop training is to enhance the closed-loop performance of NLDT. It will be discussed in Section~\ref{sec:results} that while closed-loop performance of NLDT$_{OL}$ is at par with $\pi_{oracle}$ on control tasks involving two to three discrete actions, like CartPole and MountainCar, the NLDT$_{OL}$ struggles to autonomously control the agent for control problems such as LunarLander having more states and actions. In closed-loop training, we fine-tune and re-optimize the weights $\mathbf{W}$ and biases $\boldsymbol{\Theta}$ of an entire NLDT$_{OL}$ (or pruned NLDT$_{OL}$, i.e. NLDT$^{(P)}_{OL}$ -- block 4 in Figure~\ref{fig:iai_rl_flowchart}) to maximize its closed-loop fitness ($F_{CL}$), which is expressed as the average of the cumulative reward collected across $M$ episodes: \begin{equation} \begin{array}{rl} \text{Maximize} & F_{CL}(\mathbf{W}, \boldsymbol{\Theta}) = \mathlarger{\frac{1}{M}\sum_{i = 1}^M R_e (\mathbf{W}, \boldsymbol{\Theta})},\\ \mbox{Subject to} & \mathbf{W} \in [-1,1]^{n_w}, \boldsymbol{\Theta} \in [-1,1]^{n_{\theta}}, \end{array} \label{eq:closed_loop} \end{equation} where $n_w$ and $n_{\theta}$ are total number of weights and biases appearing in entire NLDT and $M = 20$ in our case. \begin{comment} \section{Experiments: AIM and Procedure}\label{sec:results} In this work, we conduct experiments to demonstrate the performance of IAI-NLDT on four control problems. Efficacy of the proposed approach of inducing interpretable NLDT is shown on two \emph{types} of control tasks involving discrete actions as listed below: \begin{itemize} \item Binary Discrete Action Space (B-DAS): The agent in these control tasks is allowed to have exactly two discrete actions. Problems considered for this task are CartPole and CarFollowing as shown in Figures~\ref{fig:cart_pole_env} and \ref{fig:car_following_env}, respectively. \item Multiple Discrete Action Space (M-DAS): Action space of agent in these control tasks involves three or more discrete actions. Environments considered for this task are MountainCar and LunarLander as shown in Figures~\ref{fig:m-car} and \ref{fig:lunar_lander_env}, respectively. \end{itemize} \end{comment} \begin{comment} \begin{figure}[hbt] \begin{subfigure}{0.46\linewidth} \centering\includegraphics[width=\linewidth]{figures/cart_pole.png} \caption{CartPole environment.} \label{fig:cart_pole_env} \end{subfigure}\ \begin{subfigure}{0.51\linewidth} \begin{subfigure}{\linewidth} \centering \includegraphics[width = \linewidth]{figures/1d_car_following_discrete.png} \caption{CarFollowing environment.} \label{fig:car_following_env} \end{subfigure} \\[2mm] \begin{subfigure}{\linewidth} \centering \includegraphics[width = 0.75 \linewidth]{figures/lunar_lander_env.png \caption{LunarLander environment.} \label{fig:lunar_lander_env} \end{subfigure} \end{subfigure} \caption{Three control problems.} \label{fig:3problems} \end{figure} \end{comment} \begin{comment} \subsubsection{Creation of Regular Dataset} For creating a regular dataset of $n_{total}$ datapoints, the sequential state-action data from different episodes is stored through the interaction of trained black-box AI with the corresponding environment. Since the datapoint (state-action pair) is stored for each time-step in sequencial manner (if the episode terminates and the collected number of datapoints is less than $n_{total}$, then a new episode is invoked and the process of data collection repeats), there is no explicit control on the number of datapoints which will fall into a particular action category. Hence, the resulting data distribution might have an inherent bias. This bias in data distribution is more evident for environments involving more than two actions as shown in Table~\ref{tab:class_distribution}. \begin{table}[hbt] \centering \caption{Class Distribution of Regular Training Datasets for different problems. For each row, the $i$-th number in second column represents the number of datapoints belonging to $i$-th action.} \label{tab:class_distribution} \begin{tabular}{|c|c|c|}\hline {Problem} & {\#Classes} & {Class Distribution}\\\hline CartPole & 2 & $4997; 5003$ \\\hline CarFollowing & 2 & $5237; 4763$ \\\hline MountainCar & 3 & $3452; 495; 6053$ \\\hline LunarLander & 4 & $3661; 1650; 3779; 910$ \\\hline \end{tabular} \end{table} Since some of the \emph{actions} have lesser representation in the training dataset, it might negatively affect the closed-loop performance of the NLDT. To investigate this effect of bias, we create datasets with near-uniform distribution across all actions/classes. The procedure to create this balanced (or almost balanced) dataset is discussed next. \subsubsection{Creation of Balanced Dataset} In order to create uniform or near-uniform distributed data across all actions in the dataset of $n_{total}$ datapoints, data creation procedure similar to the one discussed above is implemented, i.e. data is stored from sequential time-steps. However, if the number of datapoints for a particular action reaches a threshold limit of $\ceil{\frac{n_{total}}{n_{actions}}}$ (where $n_{actions}$ is the total number of discrete actions and $\ceil{x}$ indicates the \emph{round-up} function), no further datapoints are collected for that action. It is to note that data for other actions (for which number of collected datapoints is still less than the prescribed threshold value) is still collected from sequential time-steps until total $n_{total}$ datapoints are collected. The \emph{regular} and \emph{balanced} data creation method is used to to create \emph{training} datasets only. Testing datasets are created with the \emph{regular} dataset creation approach. Also, since for binary action spaces, the distribution is fairly uniform (Table~\ref{tab:class_distribution}), we don't create balanced training datasets for these environments (i.e. CartPole and CarFollowing). \end{comment} \section{Results}\label{sec:results} In this section, we present results obtained by using our approach for control tasks on four problems: (i) CartPole, (ii) CarFollowing, (iii) MountainCar, and (iv) LunarLander. The first two problems have two discrete actions, third problem has three discrete actions, and the fourth problem has four discrete actions. The open-loop statistics are reported using scores of training and testing accuracy on labelled state-action data generated from $\pi_{oracle}$. For quantifying the closed-loop performance, we use two metrics: (i) \emph{Completion Rate} which gives a measure on the number of episodes which are successfully completed, and (ii) \emph{Cumulative Reward} which quantifies how \emph{well} an episode is executed. Fore each problem, 10 runs of open-loop training are executed using 10,000 training datapoints. Open-loop statistics obtained from these 10 independent runs of 10,000 training and 10,000 test data each are reported. We choose the median performing NLDT$_{OL}$ for closed-loop analysis. We run 50 batches with 100 episodes each and report statistics of completion-rate and cumulative reward for NLDT* obtained after closed-loop training of median performing NLDT$_{OL}$. \subsection{CartPole Problem} This problem comprises of four state variables and two discrete actions. Details regarding this problem are provided in the Supplementary document. The oracle DNN controller is trained using the PPO algorithm \cite{schulman2017proximal}. Table~\ref{tab:cartpole_training_data_size} shows the performance of NLDT on training datasets of different sizes. It is observed that NLDT trained with 5,000 and 10,000 data-points shows a robust open-loop performance and also produces $100\%$ closed-loop performance. Keeping this in mind, we keep the training data size of 10,000 fixed across all control problems discussed in this paper. The obtained NLDT$_{OL}$s has about two rules with on an average three terms in the derived policy function. \begin{table*}[hbt] \caption{Effect of training data size to approximate performance of NLDT$_{OL}$ on CartPole problem.} \label{tab:cartpole_training_data_size} \centering \begin{tabular}{|@{\hspace{2pt}}c@{\hspace{2pt}}|c|@{\hspace{2pt}}c@{\hspace{2pt}}|c|c||@{\hspace{3pt}}c@{\hspace{3pt}}|c|}\hline \begin{tabular}{c} {Training}\\ {Data Size} \end{tabular} & \begin{tabular}{c} {Training}\\ {Accuracy} \end{tabular} & \begin{tabular}{c} {Test. Accuracy}\\ {(Open-loop)} \end{tabular} & \begin{tabular}{c} \# \\ Rules \end{tabular} & \begin{tabular}{c} Rule \\ Length \end{tabular} & \begin{tabular}{c} {Cumulative}\\ {Reward, Max=200} \end{tabular} & \begin{tabular}{c} {Compl. Rate}\\ {(Closed-loop)} \end{tabular}\\\hline 100 & $\mathbf{97.00 \pm 1.55} $ & $ 82.79 \pm 2.40 $ & $1.50 \pm 0.50$ & $\mathbf{3.30 \pm 0.93}$ & $199.73 \pm 0.32$ & $95.00 \pm 5.10$ \\\hline 500 & $ 95.54 \pm 1.53 $ & $79.66 \pm 3.10$ & $1.90 \pm 0.54$ & $3.88 \pm 0.60$ & $175.38 \pm 2.61$ & $51.00 \pm 5.10$ \\\hline 1,000 & $ 91.90 \pm 0.87 $ & $ 90.59 \pm 1.87 $ & $1.80 \pm 0.40$ & $4.05 \pm 1.04$ & $\mathbf{200.00 \pm 0.00}$ & $\mathbf{100 \pm 0.00}$ \\\hline 5,000 & $ 92.07 \pm 1.28 $ & $ 92.02 \pm 1.27 $ & $1.70 \pm 0.46$ & $4.25 \pm 0.90$ & $\mathbf{200.00 \pm 0.00}$ & $\mathbf{100 \pm 0.00}$ \\\hline 10,000 & $ 91.86 \pm 1.25 $ & $ \mathbf{92.05 \pm 1.10} $ & $\mathbf{1.30 \pm 0.46}$ & $4.45 \pm 1.56$ & $\mathbf{200.00 \pm 0.00}$ & $\mathbf{100 \pm 0.00}$ \\\hline \end{tabular} \end{table*} Interestingly, the same NLDT (without closed-loop training) also produces $100\%$ closed-loop performance by achieving the maximum cumulative reward value of 200. \subsubsection{NLDT for CartPole Problem} One of the NLDT$_{OL}$ obtained for the CartPole environment is shown in Figure~\ref{fig:nldt_CartPole} in terms of normalized state variable vector $\widehat{\mbox{${\mathbf x}$}}$. \begin{figure}[hbt] \centering \includegraphics[width = 0.75\linewidth]{figures/nldt_CartPole.png} \caption{CartPole NLDT$_{OL}$ induced using 10,000 training samples. It is 91.45\% accurate on the testing dataset but has 100\% closed loop performance. Normalization constants are: $\mbox{${\mathbf x}$}^{\min}$ = [-0.91, -0.43, -0.05, -0.40], $\mbox{${\mathbf x}$}^{\max}$ = [1.37, 0.88, 0.10, 0.45].} \label{fig:nldt_CartPole} \end{figure} The respective policy can be alternatively stated using the programmable \texttt{if-then-else} rule-structure as shown in Algorithm~\ref{algo:nldt_CartPole}: \begin{algorithm} \addtocontents{loa}{\vskip 14.4pt} \caption{CartPole Rules. Normalization constants are: $x^{min}$ = [-0.91, -0.43, -0.05, -0.40], $x^{max}$ = [1.37, 0.88, 0.10, 0.45].} \label{algo:nldt_CartPole} \eIf{$\left| - 0.18 \widehat{x_{0}}\widehat{x_{2}}^{-2} - 0.63 \widehat{x_{3}}^{-2} + 0.67 \right| - 0.24 \le 0$} {Action = 0} {Action = 1} \end{algorithm} A little manipulation will reveal that for a correct control startegy, Action~0 must be invoked if following condition is true: \[2.39\leq \left(\frac{\widehat{x_0}}{\widehat{x_2}^2}+\frac{3.50}{\widehat{x_3}^2}\right) \leq 5.06,\] otherwise, Action~1 must be invoked. First, notice that the above policy does not require the current velocity ($\widehat{x_1}$) to determine the left or right action movement. Second, for small values of angular position ($\widehat{x_2} \approx 1$) and angular velocity ($\widehat{x_3}\approx 1$), i.e. the pole is falling towards left, the above condition is always true. That is, the cart should be pushed towards left, thereby trying to stabilize the pole to vertical position. On the other hand, if the pole is falling towards right (large values of $\widehat{x_2}\approx 2$ and $\widehat{x_3} \approx 2$), the term in bracket will be smaller than 2.39 for all $\widehat{x_0} \in [1,2]$, and the above policy suggests that Action~1 (push the cart towards right) must be invoked. When the pole is falling right, a push of the cart towards right helps to stabilize the pole towards its vertical position. These extreme case analyses are intuitive and our policy can be explained for its proper working, but what our NLDT approach is able to find is a precise rule for all situations of the state variables to control the Cart-Pole to a stable configuration, mainly using the blackbox-AI data. \subsection{CarFollowing Problem} We have developed a discretized version of the car following problem discussed in \cite{nageshrao2019interpretable}. The objective here is to control the rear car and follow a randomly moving car using acceleration or braking actions. This problem involves three state variables and two discrete actions. More details regarding this problem are provided in the Supplementary document. The oracle policy was obtained using a double Q-learning algorithm \cite{van2015deep}. The reward function for the CarFollowing problem is shown in the Supplementary document, indicating that a relative distance close to 30$m$ produces the highest reward. Results for the CarFollowing problem are shown in Table~\ref{tab:nldt_OL_car_following}. An average open-loop accuracy of 96.53\% is achieved with at most three rules, each having 3.28 terms on an average. \begin{table}[hbt] \centering \caption{Results on CarFollowing problem.} \label{tab:nldt_OL_car_following} \begin{tabular}{|Hp{1cm}|p{1cm}|p{1cm}@{\hspace{2pt}}|Hp{1cm}@{\hspace{2pt}}|p{1cm}@{\hspace{2pt}}||p{1cm}@{\hspace{2pt}}|}\hline {Prob.} & {Train. Acc.} & {Test. Acc.} & {Depth} & {Total Nodes} & {\# Rules} & {Rule Length} & {Compl. Rate} \\ \hline CarFollowing & $96.41 \pm 1.97 $ & $ 96.53 \pm 1.90 $ & $ 1.90 \pm 0.30 $ & 5 & $2.40 \pm 0.66$ & $3.28 \pm 0.65$ & $100 \pm 0.00$\\ \hline \end{tabular} \end{table} \begin{comment} \begin{table}[hbt] \centering \caption{Comparison of DNN and NLDT* reward value for CarFollowing}. \label{tab:car_following_rewards} \begin{tabular}{|c|c|c|}\hline {Controller} & {Best} & {Avg $\pm$ Std}\\\hline DNN & {174,265.94} & $173,797.06 \pm 171.32$ \\\hline NLDT & 174145.15 & $\mathbf{173867.86 \pm 16.48}$\\\hline \end{tabular} \end{table} \end{comment} For this problem, we apply the closed-loop re-optimization (Blocks~4 and 5 to produce Block~6 in Figure~\ref{fig:iai_rl_flowchart}) on the entire NLDT$_{OL}$. As shown Table~\ref{tab:car_following_re_opt}, NLDT* is able to achieve better closed-loop performances (100\% completion rate and slightly better average cumulative reward). Figure~\ref{fig:car1d_rel_dist} shows that NLDT* adheres the 30$m$ gap between the cars more closely than original DNN or NLDT$_{OL}$. \begin{table}[hbtp] \centering \caption{Closed-loop performance analysis after re-optimizing NLDT for CarFollowing problem (k $= 10^3$).} \label{tab:car_following_re_opt} \begin{tabular}{|@{\hspace{2pt}}c@{\hspace{2pt}}|c@{\hspace{2pt}}|c|c@{\hspace{2pt}}|}\hline \multirow{2}{*}{AI} & \multicolumn{2}{c|}{Cumulative Reward} & \multirow{2}{*}{Compl. Rate} \\\cline{2-3} & Best & {Avg $\pm$ Std} & \\\hline DNN & 174.16k & $173.75$k $ \pm 20.95$ & $\mathbf{100 \pm 0.00}$ \\\hline NLDT$_{OL}$ & 174.15k & $173.87$k $ \pm 16.48$ & $\mathbf{100 \pm 0.00}$ \\\hline NLDT* & {\bf 179.76k} & $\mathbf{179.71}${\bf k} $\mathbf{ \pm 0.95}$ & $\mathbf{100 \pm 0.00}$\\ \hline \end{tabular} \end{table} \begin{figure}[hbt] \centering \includegraphics[width = 0.9\linewidth]{figures/Car1D_rel_dist_plot.pdf} \caption{Relative distance plot for CarFollowing.} \label{fig:car1d_rel_dist} \end{figure} The NLDT corresponding to the CarFollowing problem and its physical interpretation are provided in the Supplementary document. Results of NLDT's performance on problems with two discrete actions (Tables~\ref{tab:cartpole_training_data_size}, \ref{tab:nldt_OL_car_following} and \ref{tab:car_following_re_opt}) indicate that despite having a noticeable mismatch with the open-loop output of the oracle black-box policy $\pi_{oracle}$, the closed-loop performance of NLDT is at par or at times better than $\pi_{oracle}$. This observation suggests that certain state-action pairs are not of crucial importance when it comes to executing the closed-loop control and, therefore, errors made in predicting these state-action events do not affect and deteriorate the closed-loop performance. \subsection{MountainCar Problem} This problem comprises of two state-variables to capture $x$ position and velocity of the car. The task is to use three actions and drive an under-powered car to the destination (see Supplementary Document for more details). Compilation of results of the NLDT$_{OL}$ induced using training datasets comprising of different data distributions (\emph{regular} and \emph{balanced}) is presented in Table~\ref{tab:mountain_car}. A state-action plot obtained using $\pi_{oracle}$ and one of the NLDT policy corresponding to the first row of Table~\ref{tab:mountain_car} is provided in Figures~\ref{fig:m-car-RL} and \ref{fig:m-car-NLDT}, respectively. It is observed that about $8\%$ mismatch in the open-loop performance (i.e. testing accuracy in Table~\ref{tab:mountain_car}) comes from the lower-left region of state-action plot (Figures~\ref{fig:m-car-RL} and \ref{fig:m-car-NLDT}) due to highly non-linear nature of $\pi_{oracle}$. Despite having this mismatch, the NDLT policy is able to achieve close to $100\%$ closed-loop control performance with an average of 2.4 rules having 2.97 terms. \begin{table}[hbt] \centering \caption{Results on MountainCar problem.} \label{tab:mountain_car} \begin{tabular}{|@{\hspace{2pt}}p{5mm}|@{\hspace{2pt}}p{1cm}|@{\hspace{2pt}}p{1cm}|@{\hspace{2pt}}p{1cm}@{\hspace{2pt}}|@{\hspace{2pt}}Hp{1cm}@{\hspace{2pt}}|@{\hspace{2pt}}p{1cm}@{\hspace{2pt}}||p{1cm}@{\hspace{2pt}}|}\cline{1-7}\cline{8-8} {Data} & {Train. Acc.} & {Test. Acc.} & {Depth} & {Total Nodes} & {\# Rules} & {Rule Length} & {Compl. Rate} \\ \cline{1-7}\cline{8-8} Reg. & $ {\bf 91.28} \pm {\bf 0.57} $ & $ {\bf 91.18} \pm {\bf 0.35} $ & $ 2.00 \pm 0.00 $ & 5 & ${\bf 2.40} \pm {\bf 0.49}$ & ${\bf 2.97} \pm {\bf 0.41}$ & $99.00 \pm 1.71$\\ \cline{1-7}\cline{8-8} Bal. & $ 81.45 \pm 7.36 $ & $ 87.23 \pm 1.10 $ & $ {\bf 1.90} \pm {\bf 0.30} $ & 9 & $2.80 \pm 0.60$ & $3.07 \pm 0.42$ & $\mathbf{100} \pm \mathbf{0.00}$\\ \cline{1-7}\cline{8-8} \end{tabular} \end{table} Also, NLDT trained on balanced dataset (2nd row of Table~\ref{tab:mountain_car}) is able to achieve 100\% closed-loop performance and involves about three control rules with an average 1.67 terms in each rule. \subsection{LunarLander Problem} The task in this problem is to control the lunar-lander using four discrete actions and successfully land it on the lunar terrain. The state of the lunar-lander is expressed with eight state variables, of which six are continuous, and two are categorical. More details for this problem are provided in the Supplementary document. \begin{table}[hbt] \centering \caption{NDLT$_{OL}$ with depths 3 and 6 for LunarLander.} \label{tab:lunar_lander_result} \begin{tabular}{|@{\hspace{2pt}}p{5mm}|@{\hspace{2pt}}c@{\hspace{2pt}}|@{\hspace{1pt}}p{1cm}@{\hspace{5pt}}|@{\hspace{2pt}}p{1cm}@{\hspace{5pt}}|@{\hspace{2pt}}Hp{1cm}@{\hspace{2pt}}|@{\hspace{2pt}}p{1cm}@{\hspace{2pt}}||@{\hspace{2pt}}p{1cm}@{\hspace{5pt}}|}\cline{1-7}\cline{8-8} {Data} & {Depth} & {Train. Acc.} & {Test. Acc.} & {Total Nodes} & {\# Rules} & {Rule Length} & {Compl. Rate} \\ \cline{1-7}\cline{8-8} Reg. & 3 & $ 79.17 \pm 1.78 $ & $ 76.36 \pm 3.36 $ & 13 & $5.60 \pm 0.49$ & $5.59 \pm 0.75$ & $14.00 \pm 5.93$ \\\hline Bal. & 3 & $ 69.83 \pm 2.82 $ & $ 66.58 \pm 2.03 $ & 9 & $4.40 \pm 0.66$ & $5.79 \pm 1.31$ & $42.00 \pm 4.40$ \\\hline\hline Reg. & 6 & $ {\bf 87.43} \pm {\bf 0.65} $ & $ {\bf 81.74} \pm {\bf 0.91} $ & 61 & $34.70 \pm 2.83$ & $4.94 \pm 0.34$ & $48.00 \pm 2.77$ \\\hline Bal. & 6 & $ 81.74 \pm 1.78 $ & $ 71.52 \pm 1.24 $ & 53 & $25.70 \pm 5.83$ & $5.17 \pm 0.37$ & $\mathbf{93.00} \pm \mathbf{3.30}$\\\hline \end{tabular} \end{table} \begin{table*}[!hbt] \caption{Closed-loop performance on LunarLander problem with and without re-optimization on 26-rule NLDT$_{OL}$. Number of rules are specified in brackets for each NLDT and total parameters for the DNN is marked.} \label{tab:newopt_results} \centering \begin{tabular}{|@{\hspace{3pt}}c@{\hspace{3pt}}|@{\hspace{3pt}}c@{\hspace{3pt}}|@{\hspace{3pt}}c@{\hspace{3pt}}|@{\hspace{3pt}}c@{\hspace{3pt}}|@{\hspace{3pt}}c@{\hspace{3pt}}|@{\hspace{3pt}}c@{\hspace{3pt}}||c@{\hspace{3pt}}|}\hline {Re-Opt.} & {NLDT-2 (2)} & {NLDT-3 (4)} & {NLDT-4 (7)} & {NLDT-5 (13)} & {NLDT-6 (26)} & {DNN (4,996)}\\\hline % \multicolumn{7}{|c|}{Cumulative Reward}\\\hline {Before} & $-1675.77 \pm 164.29$ & $42.96 \pm 13.83$ & $54.24 \pm 27.44$ & $56.16 \pm 23.50$ & $\mathbf{169.43 \pm 23.96}$ & \multirow{2}{*}{$247.27 \pm 3.90$}\\\cline{1-6} {After} & $-133.95 \pm 2.51$ & $231.42 \pm 17.95$ & $\mathbf{234.98 \pm 22.25}$ & $182.87 \pm 21.92$ & $214.94 \pm 17.31$ & \\\hline % \multicolumn{7}{|c|}{Completion Rate}\\\hline {Before} & $0.00 \pm 0.00$ & $51.00 \pm 3.26$ & $82.00 \pm 9.80$ & $79.00 \pm 7.66$ & $\mathbf{93.00 \pm 3.30}$ & \multirow{2}{*}{$94.00 \pm 1.96$}\\\cline{1-6} {After} & $48.00 \pm 7.38$ & $96.00 \pm 2.77$ & $\mathbf{99.00 \pm 1.71}$ & $93.00 \pm 7.59$ & $94.00 \pm 4.45$ & \\\hline \end{tabular} \end{table*} Table~\ref{tab:lunar_lander_result} provides the compilation of results obtained using NLDT$_{OL}$. In this problem, while a better open-loop performance occurs for regular dataset, a better closed-loop performance is observed when the NLDT open-loop training is done on the balanced dataset. Also, NLDT$_{OL}$ with depth three are not adequate to achieve high closed-loop performance. The best performance is observed using balanced dataset where NLDT$_{OL}$ achieves 93\% episode completion rate. A specific NLDT$_{OL}$ with 26 rules each having about 4.15 terms is shown in the Supplementary Document. It is understandable that a complex control task involving many state variables cannot be simplified or made interpretable with just one or two control rules. Next, we use a part of the NLDT$_{OL}$ from the root node to obtain the pruned NLDT$^{(P)}_{OL}$ (step `B' in Figure~\ref{fig:iai_rl_flowchart}) and re-optimize all weights ($\mathbf{W}$) and biases ($\boldsymbol{\Theta}$) using the procedure discussed in Section~\ref{sec:closed_loop_training} (shown by orange box in Figure~\ref{fig:iai_rl_flowchart}) to find closed-loop NLDT*. Table~\ref{tab:newopt_results} shows that for the pruned NLDT-3 which comprises of the top three layers and involves only four rules of original 26-rule NLDT$_{OL}$ (i.e. NLDT-6), the closed-loop performance increases from 51\% to 96\% (NLDT*-3 results in Table~\ref{tab:newopt_results}) after re-optimizing its weights and biases with closed-loop training. The resulting NLDT with its associated four rules are shown in Figure~\ref{fig:nldt_3_lunar_lander}. \begin{comment} \begin{table}[hbt] \centering \caption{Rulesets for NLDT*-3 for LunarLander.} \label{tab:nldt_equations_LunarLander} {\small\begin{tabular}{|@{\hspace{1pt}}H@{\hspace{1pt}}c@{\hspace{1pt}}|}\hline 0 & $\left| - 0.44 \hat{x_{1}}^{-3}\hat{x_{3}} - 0.59 \hat{x_{6}}^{-1}\hat{x_{7}}^{-1} + 0.97 \hat{x_{6}}^{-3} - 0.35 \right| - 0.57 $ \\\hline 1 & $\left|0.41 \hat{x_{0}}^{-1}\hat{x_{2}}^{-1} + 0.30 \hat{x_{4}}\hat{x_{7}}^{-2} - 0.67 \hat{x_{5}}^{-1} - 0.90 \right| - 0.73 $ \\\hline 2 & $\left| - 0.33 \hat{x_{3}}^{2} + 0.70 \hat{x_{1}}^{-3} - 0.54 \right| - 0.78 $ \\\hline 48 & $0.98 \hat{x_{0}}^{-3} - 0.20 $ \\\hline \end{tabular}} \end{table} \end{comment} \begin{figure}[hbt] \centering \includegraphics[width = 0.9\linewidth]{figures/nldt_3_lunar_lander.png} \caption{Final NLDT*-3 for LunarLander prob. $\widehat{x_i}$ is a normalized state variable (see Supplementary Document).} \label{fig:nldt_3_lunar_lander} \end{figure} As shown in Table~\ref{tab:newopt_results}, the NLDT* with just two rules (NLDT-2) is too simplistic and does not recover well after re-optimization. However, the NLDT*s with four and seven rules achieve a near 100\% closed-loop performance. Clearly, an NLDT* with more rules (NLDT-5 and NLDT-6) are not worth considering since both closed-loop performances and the size of rule-sets are worse than NLDT*-4. Note that DNN produces a better reward, but not enough completion rate, and the policy is more complex with 4,996 parameters. Figure~\ref{fig:closed_loop_training_plot} shows the closed-loop training curve for generating NLDT* from Depth-3 NLDT$^{(P)}_{OL}$. The objective is to maximize the closed-loop fitness (reward) $F_{CL}$ (Eq.~\ref{eq:closed_loop}) which is expressed as the average of the cumulative reward $R_{e}$ collected over $M$ episodes. \begin{figure}[hbt] \centering \includegraphics[width = 0.8\linewidth]{figures/closed_loop_fitness_plot.pdf} \caption{Closed-loop training plot for finetuning the rule-set corresponding to depth-3 NLDT$^{(P)}_{OL}$ to obtain NLDT* for LunarLander problem.} \label{fig:closed_loop_training_plot} \end{figure} It is evident that the cumulative reward for the best-population member climbs to the target reward of 200 at around 25-th generation and the average cumulative reward of the population also catches up the best cumulative reward value with generations. To check the repeatability of our approach, another run for generating NLDT$_{OL}$ and NLDT* is executed. The resulting NLDT and corresponding equations are provided in the Supplementary document. A visualization of the real-time closed-loop performance obtained using this new NLDT for two different rule-sets (i.e. before applying re-optimization and after applying the re-optimization through closed-loop training) is shown in \url{https://youtu.be/DByYWTQ6X3E}. It can be observed in the video that the closed-loop control executed using the Depth-3 NLDT$^{(P)}_{OL}$ comprising of rules obtained directly from the open-loop training (i.e. without any re-optimization) is able to bring the LunarLander close to the target. However the LunarLander hovers above the landing pad and the Depth-3 NLDT$^{(P)}_{OL}$ is unable to land it in most occasions. Episodes in these cases are terminated after the flight-time runs out. On the other hand, the Depth-3 NLDT* comprising of rule-sets obtained after re-optimization through closed-loop training is able to successfully land the LunarLander. \section{Scale-up Study and Improvization on Acrobot Control Problem} \label{sec:scale_up} In this section, we investigate how the overall algorithm can be made more efficient in terms of -- \emph{training time} and \emph{scalability}. To this purpose, we introduce a benchmark problem of planar serial manipulator (PSM). This problem is inspired from the classical Acrobot control problem \cite{sutton1996generalization}. A schematic of the PSM problem is provided in Figure~\ref{fig:planar_serial_m}. \begin{figure}[hbtp] \centering \includegraphics[width=0.4\linewidth]{figures/planar_serial_manipulator.png} \caption{Planar Serial Manipulator (PSM) benchmark problem.} \label{fig:planar_serial_m} \end{figure} The state space for the PSM problem (Figure~\ref{fig:planar_serial_m}) comprises of angular position $\theta_i$ and angular velocity $\omega_i$ of each joint. Thus, for a $n$-link manipulator involving $n$ revolute joints, the state space would be $2n$ dimensional. The motor is located at the last joint of the manipulator and is actuated using three torque values: $-\tau$, $0$ and $\tau$. Each link is of 1 unit length and has its center-of-mass at its geometric center. The motor is assumed to be massless for the sake of simplicity. The base of the manipulator is located at $(0,0,0)$ and the motion of the PSM is limited to the XZ plane. There is a downward gravitational pull ($g$) of 10 units (i.e. -10 along vertical Z axis). Torque is applied along the Y-axis. The task in this problem is to take the end-effector (i.e. tip of the last link, Z-coordinate $z_E$) of the PSM to a desired height of $H$ units by supplying torque to the motor located at the last joint (joint between $(n-1)$-th and $n$-th link). The difficulty of this benchmark problem can be adjusted by \begin{enumerate} \item changing the number of links, \item changing the value of desired height level $H$, \item changing the value of torque $\tau$, and \item placing extra motors at other joints. \end{enumerate} We simulate the mechanics of the planar serial manipulator using \emph{PyBullet} \cite{coumans2020}: a Python based physics engine. In our work, we provide two case-scenarios by focusing at the first three points of the above list. As mentioned before, by changing the number of links, the dimension of the state-space changes. The dimension of the action-space depends on the number of motors used. In the present work, we keep the number of motors fixed to one, having three discrete actions. The details regarding two environments which are created and studied in this section are summarized in Table~\ref{tab:manipulator_env_details}. \begin{table}[hbt] \caption{Details regarding custom designed Planar Serial Manipulator (PSM) environments.} \label{tab:manipulator_env_details} \centering \begin{tabular}{|c|c|c|c|}\hline \textbf{Env. Name} & \begin{tabular}{c} \textbf{Motor} \\ \textbf{Torque} ($\tau$) \end{tabular} & \begin{tabular}{c} \textbf{Desired} \\ \textbf{Height} ($H$) \end{tabular} & \begin{tabular}{c} \textbf{\# State} \\ \textbf{Vars.} \end{tabular}\\\hline 5-Link PSM & 1,000 & $+2$ & 10\\\hline 10-Link PSM & 2,000 & $+2$ & 20\\\hline \end{tabular} \end{table} The reward function $r(\mathbf{x},A)$ is given by the following equation: \begin{align} r(\mathbf{x}) = \begin{cases} -1 - \left(\frac{H + 1 - z_E}{n + H + 1}\right)^2, \quad \text{ if $z_E < H$,}\\ 100, \quad \text{ if $z_E \geq$ H.} \end{cases} \end{align} The minimum value for $z_E$ is $-n$ when the entire manipulator is stretched to its full length and all joint angles (i.e. $\theta_i$) are at 0 deg. At the beginning of an episode, joint angles $\theta_i$ of the manipulator are randomly initialized between $-5$~deg and $+5$~deg, and the angular velocities $\omega_i$ are initialized to a value between $-0.5$~rad/sec and $+0.5$~rad/sec. In next sections, we discuss results obtained on the above two custom designed environments by using different procedures of inducing NLDE$_{OL}$. The black-box AI (DNN) is trained using the PPO algorithm \cite{schulman2017proximal}. The resulting DNN has two hidden layers of 64 nodes each and has total 5699 parameters thereby making it massively un-interpretable. \subsection{Ablation Study for Open-loop Training} In this section, we launch two separate studies related to open-loop training procedure (see Figure~\ref{fig:iai_rl_flowchart}). It is seen in Section~\ref{sec:nldt_open_loop} that the open-loop training is conducted using a hierarchical bilevel-optimization algorithm, which is discussed at length in \cite{dhebar2020interpretable}. A dedicated bilevel-optimization algorithm is invoked to derive the split-rule $f(\mathbf{x})$ at a given conditional node. The upper-level search is executed using a discrete version of a genetic algorithm and the lower-level search is realized through an efficient real-coded genetic algorithm (RGA). Evolutionary algorithms are in general considered robust and have a potential to conduct more global search. However, being population driven, their search-speed is often less than that of classical optimization algorithms. In this section, we study the effect of replacing the real-coded algorithm with a classical \emph{sequential quadratic programming} (SQP) optimization algorithm in the lower-level of the overall bilevel algorithm for obtaining NLDT$_{OL}$. Later, closed-loop training based on real-coded genetic algorithm is applied to NLDT$_{OL}$ to obtain NLDT* by re-optimizing the real valued coefficients of NLDT$_{OL}$ (Section~\ref{sec:closed_loop_training}). We use the \emph{SciPy} \cite{2020SciPy-NMeth} implementation of SQP. The initial point required for this algorithm is obtained using the mixed dipole concept \cite{bobrowski2000induction, kretowski2004evolutionary,krketowski2005global, dhebar2020interpretable}. For analysis, we induce the NLDT$_{OL}$ of depth-3 on the balanced training dataset of 10,000 datapoints. The testing dataset also comprises of 10,000 datapoints. Comparison of accuracy scores and average training time of inducing NLDT$_{OL}$ by using SQP and RGA algorithm at lower-level is provided in Table~\ref{tab:open_loop_stats}. For a given procedure (SQP or RGA) the best NLDT$_{OL}$ from 10 independent runs is chosen and is re-optimized using closed-loop training (Section~\ref{sec:closed_loop_training}). Statistics regarding closed-loop performance of NLDT* is shown in the last two columns of Table~\ref{tab:open_loop_stats}. It is to note here that the closed-loop training is done using the real-coded genetic algorithm (RGA) discussed in Section~\ref{sec:closed_loop_training}. \begin{table*}[hbt] \caption{Comparing performance of different lower-level optimization algorithms. For comparison, closed-loop performance of the original DNN policy is also reported.} \label{tab:open_loop_stats} \centering \begin{tabular}{|@{\hspace{1pt}}c@{\hspace{1pt}}|c|c|c||c|@{\hspace{2pt}}c@{\hspace{2pt}}|}\hline & \multicolumn{3}{c||}{\textbf{Open-Loop} NLDT$_{OL}$} & \multicolumn{2}{c|}{\textbf{Closed-Loop} NLDT*}\\\hline \begin{tabular}{c} \textbf{Algo.} \\ \textbf{Name} \end{tabular} & \begin{tabular}{c} \textbf{Training} \\ \textbf{Accuracy} \end{tabular} & \begin{tabular}{c} \textbf{Testing} \\ \textbf{Accuracy} \end{tabular} & \begin{tabular}{c} \textbf{Training} \\ \textbf{Time (s)} \end{tabular} & \begin{tabular}{c} \textbf{Cumulative} \\ \textbf{Reward} \end{tabular} & \begin{tabular}{c} \textbf{Completion} \\ \textbf{Rate} \end{tabular}\\\hline \multicolumn{6}{|c|}{5-Link Manipulator} \\\hline SQP & $62.46 \pm 2.01$ & $\mathbf{69.34 \pm 5.39}$ & $\mathbf{15.29 \pm 4.95}$ & $\mathbf{-146.81 \pm 8.53}$ & $\mathbf{96.00 \pm 2.77}$ \\\hline RGA & $\mathbf{71.14 \pm 1.77}$ & $69.17 \pm 4.39$ & $1091.56 \pm 319.18$ & $-152.64 \pm 6.62$ & $99.00 \pm 1.71$ \\\hline \textit{DNN} & NA & NA & NA & $-183.35 \pm 12.22$ & $89.00 \pm 5.19$ \\\hline\hline \multicolumn{6}{|c|}{10-Link Manipulator}\\\hline SQP & $56.57 \pm 1.00$ & $55.64 \pm 3.58$ & $\mathbf{39.27 \pm 11.63}$ & $-318.82 \pm 15.52$ & $\mathbf{96.00 \pm 3.92}$\\\hline RGA & $\mathbf{65.84 \pm 0.85}$ & $\mathbf{62.60 \pm 3.09}$ & $2860.96 \pm 789.49$ & $\mathbf{-281.88 \pm 9.38}$ & $95.00 \pm 4.31$ \\\hline \textit{DNN} & NA & NA & NA & $-325.86 \pm 4.63$ & $85.88 \pm 1.94$ \\\hline \end{tabular} \end{table*} It can be observed from the results that open-loop training done with SQP in lower-level is about 70 times faster than the training done using RGA at the lower level. However, the training done with RGA has a better overall open-loop performance. Thus, if the task is to closely mimic the behavior of black-box AI or if only a high classification accuracy is desired (in case of classification problems), then RGA is the recommended algorithm for lower-level optimization to obtain NLDT$_{OL}$. However, NLDT* obtained after re-optimizing NLDT$_{OL}$ corresponding to SQP and RGA have similar closed-loop completion rate (last column of Table~\ref{tab:open_loop_stats}). This implies that despite low open-loop accuracy scores, the open-loop training done using SQP in lower-level is able to successfully determine the template of split-rules $f(\mathbf{x})$ and the topology of NLDT, which upon re-optimization via closed-loop training algorithm can fetch a decent performing NLDT*. During open-loop training, the search on weights and coefficients using SQP is possibly not as perfect as compared to the one obtained through RGA, however, the re-optimization done through closed-loop training can compensate this shortcoming of SQP algorithm and produce NLDT* with a respectable closed-loop performance. Additionally, in either cases, the NLDT* obtained always has a better closed-loop performance than the original black-box DNN policy. This observation suggests that it is preferable to use SQP in lower-level during open-loop training to quickly arrive at a rough structure of NLDT$_{OL}$ and then use closed-loop training to derive a high performing NLDT*. \subsection{Closed-loop Visualization} In this section, we provide a visual insight into the closed-loop performance of DNN and NLDT* which we derived in the previous section. In our case, the frequency of the simulation is set to 240Hz, meaning that the transition to the next state is calculated using the time-step of 1/240 seconds. Geometrically speaking, this implies that the Euclidean distance between states from neighboring time-steps would be small. The AI (DNN or NLDT*) outputs the action value of 0 ($-\tau$ torque), 1 ($0$ torque) or 2 ($+\tau$ torque) for a given input state. Action Vs Time plots corresponding to different closed-loop simulation runs obtained by using DNN, NLDT* (SQP)\footnote{NLDT* (SQP) indicates that the corresponding NLDT$_{OL}$ was derived using the SQP algorithm in the lower-level} and NLDT* (RGA)\footnote{NLDT* (RGA) indicates that the corresponding NLDT$_{OL}$ was derived using the RGA algorithm in the lower-level} as controllers is shown in Figure~\ref{fig:5_link_plots} for 5-link manipulator problem (plots for 10-link PSM are provided in the Supplementary document). \begin{figure*}[hbtp] \centering \begin{subfigure}[b]{0.32\linewidth} \centering \includegraphics[width=\linewidth]{figures/planar_manipulator_5_DNN.pdf} \caption{DNN} \label{fig:5_link_DNN} \end{subfigure} \hfill \begin{subfigure}[b]{0.32\linewidth} \centering \includegraphics[width=\linewidth]{figures/planar_manipulator_5_classical.pdf} \caption{NLDT* (SQP)} \label{fig:5_link_SQP} \end{subfigure} \hfill \begin{subfigure}[b]{0.32\linewidth} \centering \includegraphics[width=\linewidth]{figures/planar_manipulator_5_rga.pdf} \caption{NLDT* (RGA)} \label{fig:5_link_RGA} \end{subfigure} \caption{Action Vs. Time plot for 5-Link manipulator problem. Figure~\ref{fig:5_link_SQP} provides the plot for NLDT* which is obtained from the NLDT$_{OL}$ trained using SQP algorithm in lower-level. Similarly, Figure~\ref{fig:5_link_RGA} provides the plot for NLDT* which is obtained from the NLDT$_{OL}$ trained using RGA algorithm in lower-level.} \label{fig:5_link_plots} \end{figure*} Certain key observations can be made by looking at the plots in Figure~\ref{fig:5_link_plots}. The control output for DNN is more erratic, with sudden jerks as compared to the control output of NLDT*~(SQP) and NLDT*~(RGA). The performance of NLDT* in Figures~\ref{fig:5_link_SQP} and \ref{fig:5_link_RGA} is smooth and regular. This behaviour can be due to the involvement of a relatively simpler non-linear rule set (as compared to the complicated non-linear rule represented by DNN) which are captured inside NLDT*. This is equivalent to the observation we made for the mountain car problem in Figures~\ref{fig:m-car-RL} and \ref{fig:m-car-NLDT}, wherein the black-box AI had a very erratic behavior for the region of state-space in the lower-half of the state-action plot, while the output of NLDT was more smooth. Additionally, it was seen in Table~\ref{tab:open_loop_stats} that the NLDT* (irrespective of how its predecessor NLDT$_{OL}$ was obtained, i.e. either through SQP or RGA in lower-level) showed better closed-loop performance than the parent DNN policy. This observation implies that simpler rules expressed in the form of a nonlinear decision tree have better generalizability, thereby giving more robust performance for randomly initialized control problems. A careful investigation to the plots in Figure~\ref{fig:5_link_SQP} and \ref{fig:5_link_RGA} reveals that only two out of three allowable actions are required to efficiently execute the given control task of lifting the end-effector of a 5-link serial manipulator. This concept will be used to re-engineer the NLDT*, a discussion regarding which is provided in the next section. \subsection{Reengineering NLDT*} \label{sec:re_engineering_nldt} It is seen in action-time plots in Figure~\ref{fig:5_link_SQP} and Figure~\ref{fig:5_link_RGA} that not all actions are required to perform a given control task. Also, it may be possible that while performing a closed-loop control using NLDT, not all branches and nodes of NLDT are visited. Thus, the portion of the NLDT which is not being utilized or is getting utilized very rarely can be pruned and the overall NLDT architecture can be made simpler. To illustrate this idea, we consider the NLDT which is derived for the 5-link manipulator problem. The topology of the best performing NLDT$_{OL}$ (SQP) for the 5-link manipulator problem is shown in Figure~\ref{fig:5_link_NLDT_OL}. \begin{figure}[hbt] \centering \begin{subfigure}[b]{\linewidth} \centering \includegraphics[width = \linewidth]{figures/planar_manipulator_5_classical_nldt_open_loop.png} \caption{NLDT$_{OL}$} \label{fig:5_link_NLDT_OL} \end{subfigure}% \vspace{5pt} \begin{subfigure}[b]{0.85\linewidth} \centering \includegraphics[width = \linewidth]{figures/planar_manipulator_5_classical_nldt_closed_loop.png} \caption{NLDT*} \label{fig:5_link_NLDT_CL} \end{subfigure}% \caption{NLDTs for 5-Link Manipulator problem.} \label{fig:nldt_re_engineering} \end{figure} As mentioned before, this NLDT$_{OL}$ is trained on a balanced training dataset which is generated by collecting state-action pairs using the oracle DNN controller. In the figure, for each node, the information regarding its node-id, class distribution (given in square parenthesis) and the most dominating class is provided. Other than the root-node (Node 0), all nodes are colored to indicate the dominating class, however, it is to note that only the class associated to leaf-nodes carry the actual meaning while predicting the action for a given input state. This NLDT$_{OL}$ comprises of four split-rules in total. The class-distribution for each node is obtained by counting how many datapoints from the balanced training dataset visited a given node. Thus, the root node comprises of all datapoints (total 10,000), which are then scattered according to the split-rules present at each conditional node. Figure~\ref{fig:5_link_NLDT_CL} provides topology of NLDT* which is obtained after re-optimizing NLDT$_{OL}$ of Figure~\ref{fig:5_link_NLDT_OL} using closed-loop training. As discussed in Sections~\ref{sec:nldt_open_loop} and \ref{sec:closed_loop_training}, the topology of the tree and the structure of non-linear rules is identical for both: NLDT$_{OL}$ and NDLT*. However, the weights and biases of NLDT* are updated to enhance the closed-loop control performance. Similar to NLDT$_{OL}$ of Figure~\ref{fig:5_link_NLDT_OL}, the information regarding node id and class-distribution is provided for all the nodes of NLDT* in Figure~\ref{fig:5_link_NLDT_CL}. However, the data distribution in NLDT* is obtained by using the actual state-action data from closed-loop simulations, wherein NLDT* is used as a controller. Total 10,000 datapoints are collected in form of sequential states-action pairs from closed-loop simulation runs which are executed using NLDT*. As can be seen in the root node of NLDT* (Figure~\ref{fig:5_link_NLDT_CL}), out of 10,000 states visited during closed-loop control, action 0 ($-\tau$ torque) was chosen by NLDT* for total 7,736 states and action 2 ($+\tau$ torque) was chosen for 2,264 states. In none of the states visited during closed-loop control was action 1 (no torque) chosen. This is consistent with what we have observed in the Action Vs Time plot in Figure~\ref{fig:5_link_SQP}, wherein most of the time action 0 was executed, while there was no event where action 1 was executed. The flow of these 10,000 state-action pairs through NLDT* and their corresponding distribution in each node of NLDT* is provided in Figure~\ref{fig:5_link_NLDT_CL}. It can be observed that Node~5, Node~4 and Node~8 of NLDT* are never visited during closed-loop control. This implies that splits at Node~2, Node~1 and Node~6 are redundant. Thus, the part of NLDT* shown in red-box in Figure~\ref{fig:5_link_NLDT_CL} can be pruned and the overall topology of the tree can be simplified. The pruned NLDT* will involve only one split (occurring at Node~0) and two leaf nodes: Node~1 and Node~6. However, it is to note here that we need to re-assign class-labels to the newly formed leaf nodes (i.e. Node~1 and Node~6) based on the data-distribution from closed-loop simulations. The old class-labelling for the Node~1 and Node~6 was done based on the open-loop data (Figure~\ref{fig:5_link_NLDT_OL}). Using the new class distribution corresponding to NLDT* (Figure~\ref{fig:5_link_NLDT_CL}), Node~1 is re-labelled with Class-2 and Node~6 with Class-0. The pruned version of NLDT* of Figure~\ref{fig:5_link_NLDT_CL} is provided in Figure~\ref{fig:5_link_NLDT_CL_pruned} (here nodes are re-numbered, with Node~6 of NLDT* in Figure~\ref{fig:5_link_NLDT_CL} re-numbered to Node~2 in the pruned NLDT* as shown in Figure~\ref{fig:5_link_NLDT_CL_pruned}). \begin{figure}[htb] \centering \includegraphics[width = 0.7\linewidth]{figures/planar_manipulator_5_classical_nldt_closed_loop_pruned.png} \caption{Pruned version of NLDT* (Figure~\ref{fig:5_link_NLDT_CL}) for 5-link manipulator problem.} \label{fig:5_link_NLDT_CL_pruned} \end{figure} The split-rule corresponding to the root-node is also shown. Interestingly, out of 10 total state-variables, only 2 are used to decide which action to execute for closed-loop control: $x_1$ corresponds to the angular position of the second link and $x_9$ variable corresponds to the angular velocity of the last joint. The above rule indicates a single and interpretable relationship: action~2 must be invoked when $\widehat{x}_9 \leq \sqrt[3]{\left(1.885 - 0.115/\widehat{x}_1^3\right)}$, otherwise action~0 must be invoked. This NLDT* corresponds to a cumulative reward of $-139.78 \pm 7.65$ and performs at $99.00 \pm 1.71$\% completion rate, which provides a remarkably simple interpretation of the control strategy for this apparently complex problem. \section{Conclusions}\label{sec:conclusions} In this paper, we have proposed a two-step strategy to arrive at hierarchical and relatively interpretable rulesets using a nonlinear decision tree (NLDT) concept to facilitate an explanation of the working principles of AI-based policies. The NLDT training phases use recent advances in nonlinear optimization to focus its search on rule structure and details describing weights and biases of the rules by using a bilevel optimization algorithm. Starting with an open-loop training, which is relatively fast but uses only time-instant state-action data, we have proposed a final closed-loop training phase in which the complete or a part of the open-loop NLDT is re-optimized for weights and biases using complete episode data. Results on four popular discrete action problems have amply demonstrated the usefulness of the proposed overall approach. This proof-of-principle study encourages us to pursue a number of further studies. First, the scalability of the NLDT approach for challenging large-dimensional state-action space problems must now be explored. A previous study on NLDT \cite{dhebar2020interpretable} on binary classification of dominated versus non-dominated data in multi-objective problems was successfully extended to 500-variable problems. While it is encouraging, the use of customization methods for initialization and genetic operators using problem heuristics and/or recently proposed {\em innovization\/} methods \cite{deb2006innovization} in the upper level problem can be tried. Second, this study has used a computationally fast open-loop accuracy measure as the fitness for evolution of the NLDT$_{OL}$. This is because, in general, an NLDT$_{OL}$ with a high open-loop accuracy is likely to achieve a high closed-loop performance. However, we have observed here that a high closed-loop performance is achievable with a NLDT$_{OL}$ having somewhat degraded open-loop performance, but re-optimized using closed-loop performance metrics. Thus, a method to identify the crucial (open-loop) states from the AI-based controller dataset that improves the closed-loop performance would be another interesting step for deriving NLDT$_{OL}$. This may eliminate the need for re-optimization through closed-loop training. Third, a more comprehensive study using closed-loop performance and respective complexity as two conflicting objectives for a bi-objective NLDT search would produce multiple trade-off control rule-sets. Such a study can, not only make the whole search process faster due to the expected similarities among multiple policies, they will also enable users to choose a single policy solution from a set of accuracy-complexity trade-off solutions.
{'timestamp': '2021-04-07T02:26:09', 'yymm': '2009', 'arxiv_id': '2009.09521', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09521'}
arxiv
\section{Introduction} \label{sec:intro} The Ethernet Alliance foresees a strong demand for Tb/s data throughput for data centers and mobile networks \cite{ethernetroadmap2019}. In the wireless domain, the Horizon 2020 project \textit{Enabling Practical Wireless Tb/s Communications with Next Generation Channel Coding} (EPIC) \cite{epic} considers three well-known forward error correction (FEC) schemes turbo \cite{Berrou1993}, Low Density Parity Check (LDPC) \cite{Gallager1962}, \cite{MacKay1996} and polar codes \cite{Arikan2009} for extremely high speed beyond 5G applications. This paper aims to present an efficient polar code implementation to meet Tb/s throughput demand. Polar codes have attracted a significant interest from both academia and industry and recently they have been adopted for the protection of the control channel in the enhanced mobile broadband (eMBB) service for the fifth generation (5G) cellular wireless technology \cite{gppNR}. Polar codes are a unique family of FEC schemes which can theoretically achieve capacity in broad class of channels using a low-complexity successive cancellation (SC) decoder \cite{Arikan2009}, \cite{Sasaoglu2009}. To improve error correction performance of SC algorithm at moderate data block lengths, many algorithms are proposed with most popular one being SC-list (SCL) \cite{Tal2015}. SCL algorithm can track a list of possible decision candidates and can achieve near ML performance with this additional complexity. Other SC based decoding algorithms SC-flip (SCF) \cite{Afisiadis2014} and Soft-cancellation (SCAN) \cite{Fayyaz2014} use an iterative approach to correct decision errors of SC. Using multiple iterations or multiple parallel decoders make these algorithms much more power hungry at Tb/s data rates. The sequential processing nature of SC limits parallelism within decoder but promotes pipelined approach for Tb/s throughput. There are some high-throughput and pipelined SC implementations \cite{Zhang2013}, \cite{Dizdar2016}, \cite{Giard2015}, \cite{Giard2016} in literature. These implementations can only achieve a few Gb/s throughput, even if the unrolled implementations \cite{Giard2015}, \cite{Giard2016} take advantage of a set of shortcuts \cite{Yazdi2011}, \cite{Sarkis2014}, \cite{Hanif2017} for speeding up the SC decoder. For a higher throughput, discrete quantization of soft-information \cite{Shah2019} and register reduction/balancing (R-RB) \cite{Sural2019} methods have been proposed. In \cite{Sural2019}, Tb/s throughput for polar SC decoder have been investigated. A generic problem identified for Tb/s throughput regime is power density caused by excessive switching activity in a limited core area. This work proposes an optimized SC (OPSC) decoder architecture based on pipelining and unrolling techniques. The OPSC decoder has low implementation complexity thanks to careful register balancing and adaptive log-likelihood ratio (LLR) quantization (AQ) scheme. This scheme takes LLR distribution of each polar code segment as input and optimizes bit precision of internal LLRs. In addition to that OPSC utilizes R-RB method to optimize clock frequency by flattening time delay of pipeline stages. The post-placement-routing (post-P\&R) results at 16nm FinFet ASIC technology show that OPSC decoder achieves 1.2 Tb/s coded throughput (corresponds to 1 Tb/s data throughput) on 0.79 mm$^2$ area with 0.95 pJ/bit energy efficiency. \subsection{Summary of the achievements} \label{sec:achievements} \begin{itemize} \item OPSC decoder and a channel simulator capable of simulating very low error rates are implemented on FPGA to verify RTL code and measure error correction performance at very low BER. The FPGA implementation results show that OPSC decoder achieves 200 Gb/s throughput and $1.1 \times 10^{-13}$ bit error rate (BER) at 8 dB Eb/No. \item OPSC decoder exploits AQ and R-RB methods to reduce design area and power. \item To the best of our knowledge, OPSC decoder is the first polar decoder that exceeds 1 Tb/s throughput on ASIC based on post-P\&R results. \item The results also show that OPSC decoder archives 0.95 pJ/bit energy efficiency at 0.79 mm$^2$ area. \end{itemize} The outline of this paper is as follows. Section \ref{sec:polar_codes_and_sc} gives a short summary of polar coding and introduces the SC decoding with shortcuts and AQ. Section \ref{sec:architecture_general} presents the proposed decoder architecture including pipeline depth optimization. Section \ref{sec:fpga_verification} presents FPGA verification and communication performance of the proposed decoder. Section \ref{sec:asic_implementation} presents ASIC implementation details and show comparison with state-of-the-art implementations. Finally, Section \ref{sec:conclusion} summarizes the main results with a brief conclusion. \section{Polar Codes and SC Decoding Algorithm} \label{sec:polar_codes_and_sc} \subsection{Polar codes} \label{sec:polar_code_review} Polar codes are a class of linear block codes that exists with a block length $N=2^n$ for every $n\ge 1$. A polar transform matrix $G_N = G^{\otimes n}$ is the $n^{\text{th}}$ Kronecker power of a generator matrix $G =\begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix}$. An input transform vector $u_N$ consists of a user data set $u_{\cal A}$ to carry the user data $d_K$ with $K$ dimention and a redundancy (frozen) set $u_{{\cal A}^c}$ to carry the frozen bits fixed to zero. The polar-encoded codeword $x_N$ is simply obtained as $x_N = u_N G_N$. We refer to \cite{Arikan2009} for a complete description of the polar coding technique. \subsection{SC Decoding Algorithm with Shortcuts} \label{sec:sc_algorithm} The data flow diagram of SC algorithm with certain shortcuts is shown in Fig. \ref{fig:sc_shortcut_diagram}. At the start of decoding, channel log-likelihood ratio (LLR) vector $\ell_N$ is given to the input. For an AWGN channel $W$ with the variance $\sigma^2$, i$^{\text{th}}$ ($1 \leq i \leq N$) encoded symbol $x_i$ and received symbol $y_i$, a channel LLR vector $\ell_i$ is \begin{align} \ell_i &= \ln \left( \frac{W(y_i|x_i=0)}{W(y_i|x_i=1)} \right) \nonumber \\ &= \ln \left( \frac{e^{\frac{-(y_i-1)^2}{2\sigma^2}}}{\sqrt{2\pi\sigma^2}}\right) - \ln \left( \frac{e^{\frac{-(y_i+1)^2}{2\sigma^2}}}{\sqrt{2\pi\sigma^2}} \right) \nonumber \\ &= \frac{-(y_i-1)^2}{2\sigma^2}-\frac{-(y_i+1)^2}{2\sigma^2} \nonumber \\ &= \frac{2y_i}{\sigma^2}\text{,} \nonumber \end{align} where $W(y_i|x_i)$ is the channel transition probability density function. The forward LLR calculation module consists of F and G functions to calculate the inputs $\ell_M$ for the first and the second half of a polar code, where $M$ is the recursive block length parameter. Initially, $M=N$ and there are $M/2$ size-$2$ $\text{F}_2$ and $\text{G}_2$ functions (denoted as $\text{F}_{M/2}$ and $\text{G}_{M/2}$) at each recursion. The function $\text{F}_2(\ell_1, \ell_2)$ for any two LLR values $\ell_1$ and $\ell_2$ is defined as \begin{align} \text{F}_2(\ell_1, \ell_2) = \operatorname{sgn}(\ell_1 \ell_2)\operatorname{min}(|\ell_1|,|\ell_2|) \text{.} \nonumber \end{align} The function $\text{G}_2(\ell_1, \ell_2, \hat{z})$ with a hard decision (HD) feedback $\hat{z}$ is \begin{align} \text{G}_2(\ell_1, \ell_2, \hat{z}) &= {(1-2\hat{z})}{\ell_1} + \ell_2 \text{.} \nonumber \end{align} After a bunch of F and G function iterations, the SC decoder becomes ready for making hard decisions using certain shortcuts. These shortcuts are named as Rate-0 (R0), Rate-1 (R1), SPC and REP (first introduced in \cite{Sarkis2014}) for easily decodable polar code segments. For R0 shortcut all values are assigned to 0. For R1 shortcut a simple threshold function is used to assign 0 for positive LLRs and 1 for negative LLRs. Moreover, Wagner \cite{Silverman1954} and MAP \cite{Fossorier1999} decoders are employed for SPC and REP nodes, respectively. After one of these shortcuts is activated, the backward HD module (can also be named as partial-sum update logic - PSUL) takes the HD estimate $\hat{u}_M$ and calculates the feedback $\hat{z}_{M/2}$ for the G functions. This module utilizes $M/2$ XOR ($\oplus$) functions at each iteration. After all polar code segments are decoded, the final HD estimate $\hat{u}_N$ is calculated. and the estimated user data $\hat{d}_K$ is extracted from $\hat{u}_N$ at the end of decoding operation. \begin{figure} \centering \begin{pspicture}(0,0)(8,7) \rput(0,-1){ \rput(5.7,1.8){$\hat{d}_K$} \rput(1,1.8){$\hat{u}_N$} \rput(2.3,7.5){$\ell_N$} \rput(1,6.2){$\hat{z}_{M/2}$} \rput(7,7){\fontsize{7pt}{7pt}$M=M/2$} \rput(7,7.4){$\ell_M$} \rput(4,6.25){$\ell_M$} \rput(5.2,6.2){{\fontsize{7pt}{7pt}$M=M/2$}} \rput(2.6,3.75){$\hat{u}_M$} \rput(1.3,3.7){{\fontsize{7pt}{7pt}$M=2M$}} \rput(3.45,4.7){\fontsize{8pt}{8pt}$\hat{u}_M$} \psline[linestyle=dashed,linewidth=0.03](4,4.2)(3.8,3.5) \psline[linestyle=dashed,linewidth=0.03](4.4,4.2)(4.6,3.5) \rput(1,0){ \psline[linestyle=dashed,linewidth=0.03](4,4.2)(3.8,3.5) \psline[linestyle=dashed,linewidth=0.03](4.4,4.2)(4.6,3.5)} \rput(2,0){ \psline[linestyle=dashed,linewidth=0.03](4,4.2)(3.8,3.5) \psline[linestyle=dashed,linewidth=0.03](4.4,4.2)(4.6,3.5)} \rput(3,0){ \psline[linestyle=dashed,linewidth=0.03](4,4.2)(3.8,3.5) \psline[linestyle=dashed,linewidth=0.03](4.4,4.2)(4.6,3.5)} \rput(0.2,-1.4){ \psframe(3.6,3.7)(4.4,4.9) \psline{->}(4,3.8)(4,4.8)\psline{<->}(3.6,3.8)(4.4,3.8) \psline[linestyle=dashed,linewidth=0.02](3.6,4)(4.4,4) \rput(4.2,4.2){\fontsize{6pt}{6pt}$0$}} \rput(-1.8,-1.4){ \psframe(6.6,3.7)(7.4,4.9) \psline{->}(7,3.8)(7,4.8)\psline{<->}(6.6,3.8)(7.4,3.8) \psline[linestyle=dashed,linewidth=0.02](7,4.4)(6.6,4.4)\psline[linestyle=dashed,linewidth=0.02](7,4)(7.4,4) \rput(7.2,4.4){\fontsize{6pt}{6pt}$1$}\rput(6.8,4){\fontsize{6pt}{6pt}$0$}} \psframe(5.8,3.5)(6.6,2.3) \rput(6.2,2.9){\begin{tabular}{c} \fontsize{6pt}{6pt}$\text{Wagner}$ \\ {\fontsize{6pt}{6pt}$\text{Decoder}$}\end{tabular}} \rput(1,0){ \psframe(5.8,3.5)(6.6,2.3) \rput(6.2,2.9){\begin{tabular}{c} \fontsize{6pt}{6pt}$\text{MAP}$ \\ {\fontsize{6pt}{6pt}$\text{Decoder}$}\end{tabular}}} \rput(0,0.3){ \psellipse(0.8,7)(0.8,0.4)\rput(0.8,7){Input} \psline{->}(1.6,7)(3.5,7)} \rput(6.4,-1.5){ \psellipse(0.8,3)(0.8,0.4)\rput(0.8,3){Output}} \rput(0,-1){ \psframe(2,2)(5,3) \rput(3.5,2.5){User data extraction}} \psline(6.1,7.2)(8,7.2) \psline(8,7.215)(8,4.5) \psline{->}(8.015,4.5)(7.7,4.5) \psline{->}(3.7,4.5)(3.2,4.5) \psline(0.6,4.8)(0.1,4.8) \psline(0.1,4.785)(0.1,6) \psline(0.085,6)(2,6) \psline(2,5.985)(2,7) \psline{->}(1.985,7)(3.5,7) \psline(0.6,4.5)(0.1,4.5) \psline(0.1,4.515)(0.1,1.5) \psline{->}(0.085,1.5)(2,1.5) \psline{->}(5,1.5)(6.4,1.5) \rput(-2.2,5.75){ \rput(7,2){Forward LLR calc.} \rput(6,1.05){G} \rput(8,1.05){G} \psframe(5.8,0.85)(6.2,1.25) \psframe(7.8,0.85)(8.2,1.25) \rput(6,1.5){F} \rput(8,1.5){F} \psframe(5.8,1.3)(6.2,1.7) \psframe(7.8,1.3)(8.2,1.7) \rput(7,1.25){\fontsize{9pt}{9pt}$M/2$} \psline[linestyle=dotted,linewidth=0.08](6.3,1.05)(7.7,1.05) \psline[linestyle=dotted,linewidth=0.08](6.3,1.5)(7.7,1.5) \psframe(5.7,0.75)(8.3,1.8) \psline(8.3,1)(8.5,1) \psline(8.5,1.015)(8.5,0.3) \psline(8.515,0.3)(5.5,0.3) \psline(5.5,0.285)(5.5,1.015) \psline{->}(5.5,1)(5.7,1) \rput(7,0.1){Iterate until shortcut}} \rput(3.7,4){ \rput(2,1.2){Hard-decision (HD) making} \psframe(0,0)(4,1) \psframe(0.1,0.2)(0.9,0.8) \rput(0.5,0.5){R0} \rput(1,0){\psframe(0.1,0.2)(0.9,0.8) \rput(0.5,0.5){R1}} \rput(2,0){\psframe(0.1,0.2)(0.9,0.8) \rput(0.5,0.5){SPC}} \rput(3,0){\psframe(0.1,0.2)(0.9,0.8) \rput(0.5,0.5){REP}}} \rput(-5.1,3.25){ \rput(7,2){Backward HD calc.} \rput(2,-3){\pscircle(4,4){0.2} \psline(3.9,4)(4.1,4) \psline(4,3.9)(4,4.1)} \rput(4,-3){\pscircle(4,4){0.2} \psline(3.9,4)(4.1,4) \psline(4,3.9)(4,4.1)} \rput(2,-2.5){\pscircle(4,4){0.2} \psline(3.9,4)(4.1,4) \psline(4,3.9)(4,4.1)} \rput(4,-2.5){\pscircle(4,4){0.2} \psline(3.9,4)(4.1,4) \psline(4,3.9)(4,4.1)} \rput(7,1.25){\fontsize{9pt}{9pt}$M/2$} \psline[linestyle=dotted,linewidth=0.08](6.3,1.01)(7.7,1.01) \psline[linestyle=dotted,linewidth=0.08](6.3,1.5)(7.7,1.5) \psframe(5.7,0.75)(8.3,1.8) \psline{<-}(8.3,1)(8.5,1) \psline(8.5,1.015)(8.5,0.3) \psline(8.515,0.3)(5.5,0.3) \psline(5.5,0.285)(5.5,1.015) \psline(5.5,1)(5.7,1) \rput(7,0.1){Iterate until feedback}} } \end{pspicture} \caption{Data flow diagram of polar SC decoding algorithm with shortcuts} \label{fig:sc_shortcut_diagram} \end{figure} A formal representation of SC algorithm with shortcuts is shown in Algorithm \ref{sc_algorithm}. $v_M$ is the indicator vector of the frozen coordinates for length-$M$ polar code segments. The i$^\text{th}$ element of $v_M$ is defined as \begin{equation} v_i = \begin{cases} 1, & \mbox{if } i \in {\cal A}^c \nonumber \\ 0, & \mbox{if }i \in {\cal A} \text{.} \nonumber \end{cases} \end{equation} When $v_M$ is all one, the R0 shortcut is calculated. When $v_M$ is all zero, the R1 shortcut is calculated using a threshold function on LLRs. Both F and G functions are used element-wise for odd $\ell_M^{\text{odd}}$ and even $\ell_M^{\text{even}}$ elements of $\ell_M$ vector. \SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up} \SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress} \SetKwInOut{Input}{input}\SetKwInOut{Output}{output} \SetArgSty{textnormal} \begin{algorithm} \renewcommand{\algorithmicrequire}{\textbf{Inputs :}} \renewcommand{\algorithmicensure}{\textbf{Output:}} \algorithmicrequire{ $\ell_M$, $v_M$, $M$} \text{ } \algorithmicensure{ $\hat{u}_M$}\\ \uIf(\tcp*[f]{R0, R=0}){$v_M= 1$ }{ $\hat{u}_M = \text{d}(\ell_M$, $v_M= 1) = 0$\\ } \uElseIf(\tcp*[f]{R1, R=1}){$v_M=0$ }{ $\hat{u}_M =\text{d}(\ell_M$, $v_M= 0)$ \\ } \uElseIf{$M \leq N_{\text{LIM}}$ \bf{and} $v_1= 1$ \bf{and} $v_2^M= 0$ }{ $\hat{u}_M = \text{d}(\ell_M$, $v_M= 0)$ \tcp*[f]{Wagner dec.} \\ $p = \text{mod}(\sum_{i=1}^M\hat{u}_i,2)$ \tcp*[f]{R = (M-1)/M} \\ $r = \text{argmin}(\mid \ell_M \mid$)\\ $\hat{u}_r = \hat{u}_r \oplus p$\\ } \uElseIf{$M \leq N_{\text{LIM}}$ \bf{and} $v_1^{M-1}= 1$ \bf{and} $v_M=0$ }{ $\hat{u}_M = \text{d}(\sum_{i=1}^M\ell_i, v = 0)$ \tcp*[f]{MAP dec. R = 1/M} \\ } \Else(\tcp*[f]{Conventional SC $\forall$ R}){ $l_{M/2} = \text{F}(\ell_M^{\text{odd}}$, $\ell_M^{\text{even}}$) \tcp*[f]{Fig. \ref{fig:f2}} \\ $\hat{z}_{M/2} = \text{SC}(l_{M/2}$, $v_M^{\text{odd}}$, $\frac{M}{2})$\\ $r_{M/2} = \text{G}(\ell_M^{\text{odd}}$, $\ell_M^{\text{even}}$, $\hat{z}_{M/2})$ \tcp*[f]{Fig. \ref{fig:g2}} \\ $\hat{x}_{M/2} = \text{SC}(r_{M/2}$, $v_M^{\text{even}}$, $\frac{M}{2}$)\\ $\hat{u}_M^{\text{odd}} = \hat{z}_{M/2}$ $\oplus$ $\hat{x}_{M/2}$ \tcp*[f]{Backward HD}\\ $\hat{u}_M^{\text{even}} = \hat{x}_{M/2}$\\ } \uIf(\tcp*[f]{User data extraction}){$M = N$ }{ $\hat{u}_K = u_{\cal A}$ \\ \Return {$\hat{u}_K$} } \Else(\tcp*[f]{Decode remaining code segments}){ \Return {$\hat{u}_M$} } \caption{SC with shortcuts} \label{sc_algorithm} \end{algorithm} \subsubsection{Shortcuts for ($N=1024,K=854$) polar code} \label{sec:shortcuts} For a specific implementation of polar codes, code parameters are selected as $N=1024$, $K=854$, $R= \frac{5}{6}$ . The selected polar code is constructed using Density Evolution algorithm \cite{Tal2013} at 6.5 dB target Es/No. The number of shortcuts for this code is shown in Table \ref{table:list_of_shortcuts}. Due to high code rate, R1 and SPC shortcuts appear more frequent than R0 and REP shortcuts. SPC and REP shortcuts are not allowed to be greater than $N_{\text{LIM}} = 32$ by design choice to keep the target clock frequency high. There are also other shortcuts discovered in \cite{Hanif2017}, however such shortcuts are not employed in this work due to negligible hardware gain in our target polar code. \begin{table}[ht] \centering \caption{Number of shortcuts in (1024,854) OPSC decoder } \label{table:list_of_shortcuts} \begin{tabular}{cccccc} \hline \multirow{2}{*}{Node Length} & \multicolumn{5}{c}{Shortcuts} \\ & R0 & R1 & SPC & REP & Total \\ \hline 2 & 2 & 2 & - & - & 4 \\ 4 & 2 & 4 & 8 & 10 & 24 \\ 8 & 1 & 3 & 6 & 3 & 13 \\ 16 & 1 & 3 & 3 & 2 & 9 \\ 32 & 1 & 6 & 4 & - & 3 \\ 64 & - & 3 & - & - & 7 \\ 128 & - & 1 & - & - & 1 \\ Total & 68 & 604 & 256 & 96 & 1024 \\ \hline \end{tabular} \end{table} Due to using shortcuts, F/G function and XOR gate gains are shown in Table \ref{table:fg_gain}. In standard SC decoder architecture, there are $N/2=512$ F$_2$ and G$_2$ functions at each polar code segment. Therefore, total number of required F$_2$ and G$_2$ functions are $N \log N= 10,240$. It reduces to 5276 after applying shortcuts. The gain is mostly caused by the smaller polar code segments. The number of F$_2$ functions are not equal to G$_2$ functions for small segments due to R0 shortcuts. For these specific nodes, G functions are used with all zero decision feedback. Furthermore, the required XOR gates for PSUL reduces from $N/2 \log N= 5120$ to 2672. \begin{table}[ht] \centering \caption{F/G function and XOR gate gain due to shortcuts} \label{table:fg_gain} \begin{tabular}{ccccc} \hline \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Node \\ Length\end{tabular}} & \multicolumn{3}{c}{Number of F/G functions} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}XOR gates\\ in PSUL\end{tabular}} \\ & F & G & Total & \\ \hline 4 & - & 2 & 4 & 2 \\ 8 & 11 & 13 & 96 & 13 \\ 16 & 12 & 13 & 200 & 13 \\ 32 & 10 & 11 & 336 & 11 \\ 64 & 10 & 11 & 672 & 11 \\ 128 & 7 & 7 & 896 & 7 \\ 256 & 4 & 4 & 1024 & 4 \\ 512 & 2 & 2 & 1024 & 2 \\ 1024 & 1 & 1 & 1024 & 1 \\ Total & 2604 & 2672 & 5276 & 2672 \\ \hline \end{tabular} \end{table} \subsubsection{Adaptive quantization of the LLRs} \label{sec:adapt_quantization} Adaptive quantization is an optimization method to reduce hardware complexity by decreasing LLR bit precision of internal data paths in the SC decoder. Instead of storing and processing LLRs with a constant number of bits, a variable number of bits is used for each polar code segment. During SC decoding of polar codes, the polarization phenomenon becomes effective. As polarization increases, resolution can be decreased without losing performance and representing polarized code segments with constant quantization bits becomes inefficient. As polarization increases reliability, resolution of LLR can be decreased. Unlike using lookup tables as in \cite{Shah2019} for the computation of LLRs, we use input LLR distribution statistics of each polar code segment and apply the given F and G functions with an optimized bit precision. Adaptive quantization scheme for (1024,854) polar code is shown in Fig. \ref{fig:adaptive_quantization}. The number of quantization bits are written on the lines between polar code segments. With the adaptive quantization, the memory complexity is reduced by 15.1\% while having 4.25 bit average LLR bit precision compared to the SC decoder with 5-bit regular quantization levels. It further reduces combinational logic complexity and enables shallower pipeline depth. \begin{figure}[htbp] \centering \psscalebox{0.65}{ \psset{arrowscale=1} \psset{unit=0.8cm} \psset{xunit=1,yunit=1} \begin{pspicture}(-2,-1.1)(12,11.1) \rput(5,5){ \psset{arrows=->} \pstree[treemode=R,levelsep=20ex]{\Tframe{(1024,854)}} {\pstree[treemode=R]{\Tframe{(512,361)}\taput{5}} {\pstree[treemode=R]{\Tframe{(256,131)}\taput{5}} {\Tframe{(128,36) }\taput{5} \Tframe{(128,95) }\taput{4} } \pstree[treemode=R]{\Tframe{(256,230)}\taput{4}} {\Tframe{(128,103)}\taput{4} \Tframe{(128,127)}\taput{3} } } \pstree[treemode=R]{\Tframe{(512,493)}\trput{4}} {\pstree[treemode=R]{\Tframe{(256,238)}\taput{4}} {\Tframe{(128,111)}\taput{4} \Tframe{(128,127)}\taput{3} } \pstree[treemode=R]{\Tframe{(256,255)}\taput{3}} {\Tframe{(128,127)}\taput{3} \Tframe{(128,128)}\taput{1} } } } } \end{pspicture} } \caption{Adaptive quantization of the constituent codes of SC(1024,854) for $128 \leq M \leq 1024$. The number of quantization bits are written on the lines.} \label{fig:adaptive_quantization} \end{figure} \section{OPSC Decoder Architecture} \label{sec:architecture_general} The proposed OPSC decoder architecture exploits pipelining and unrolling techniques to achieve Tb/s data rate while keeping implementation complexity in check. The enabling methods for OPSC decoder are as follows. \begin{itemize} \item Systematic polar code for improved BER performance. \item Min-sum decoding for simpler arithmetic operations with small area and power dissipation. \item Adaptive quantization of internal LLRs to reduce computational and memory complexity. \item Bit-reversed order computation to operate on neighboring LLRs. \item Unrolled and pipelined architecture for high throughput. \item Fully-parallel SC architecture with multi-bit hard decisions using shortcuts. \item R-RB using pipeline depth optimization for minimum delay and power. Pipeline depth of OPSC decoder is optimized as 158 for FPGA and 60 for ASIC. \end{itemize} The OPSC decoder denoted as $\text{OPSC}(N,K)$, consists of two sub-decoders which have the same block length $\frac{N}{2}$ with a different payload $K_i = \frac{N}{2} R_i$. In general, $\text{OPSC}(N,K)$ is decoded in four steps: calculation of F functions, $\text{OPSC}_1(\frac{N}{2},K_1)$, calculation of G functions and $\text{OPSC}_2(\frac{N}{2},K_2)$. AQ is applied after F and G functions to reduce LLR bit resolution from Q to Q' bits. For example, the recursive OPSC decoder architecture for $N=16$, $K=9$ polar code segment is shown in Fig. \ref{fig:sc_architecture}. Choice of lower layer code rates is exemplary. The $\ell_{16}$ LLRs at the input with $16 \times Q$ bits are stored during processing duration of $\text{OPSC}(8,2)$ decoder (denoted as $\mathcal{L}(\text{OPSC}_1)$) until $\hat{z}_8$ becomes ready at the input of function block G. Likewise, $\hat{z}_8$ is stored until $\hat{x}_8$ is ready. Buffer memory structure is used to access data faster than other alternatives such as SRAM. \begin{figure}[htbp] \centering \psscalebox{0.75}{ \begin{pspicture}(-0.4,1.4)(10.3,8.4) \rput(-0.3,0){ \psdots[linecolor=black,dotsize=3pt](1,7) \psdots[linecolor=black,dotsize=3pt](7.2,7) \psline{->}(0,7)(1.2,7) \rput(0.6,8.1){$\text{OPSC}(16,9)$} \rput(0.5,7.35){$\ell_{16}$} \rput(0.5,6.75){\fontsize{7pt}{7pt}\selectfont$16\times{Q}$} \psline[linewidth=0.5pt](0.45,6.9)(0.55,7.1) \psframe(1.2,6.6)(2,7.4) \rput(1.6,7){F$_8$} \psline{->}(1,7)(1,6) \psframe(0.2,6)(1.8,4) \psline(0.2,5.8)(1.8,5.8) \psline(0.2,5.6)(1.8,5.6) \psline(0.2,4.2)(1.8,4.2) \psdots[linecolor=black,dotsize=5pt](1,4.55) \psdots[linecolor=black,dotsize=5pt](1,4.9) \psdots[linecolor=black,dotsize=5pt](1,5.25) \rput{90}(0,5){Buffer Memory} \psline(1,4)(1,2.6) \psline{->}(1,2.6)(1.2,2.6) \psframe(1.2,2.2)(2,3) \rput(1.6,2.6){G$_8$} \psline{->}(2,7)(3.2,7) \psline[linewidth=0.5pt](2.55,6.9)(2.65,7.1) \rput(2.6,7.35){$\ell_{8}$} \rput(2.6,6.75){\fontsize{7pt}{7pt}\selectfont$8\times{Q}$} \psframe(3.2,6)(3.8,8) \rput{90}(3.5,7){AQ} \psline{->}(2,2.6)(3.2,2.6) \psline[linewidth=0.5pt](2.55,2.5)(2.65,2.7) \rput(2.6,2.95){$r_{8}$} \rput(2.6,2.35){\fontsize{7pt}{7pt}\selectfont$8\times{Q}$} \rput(7.6,2.35){\fontsize{7pt}{7pt}\selectfont$8$} \rput(7.6,6.75){\fontsize{7pt}{7pt}\selectfont$8$} \rput(9.9,2.5){\fontsize{7pt}{7pt}\selectfont$16$} \psframe(3.2,1.6)(3.8,3.6) \rput{90}(3.5,2.6){AQ} \psline{->}(3.8,7)(5,7) \rput(4.4,7.35){$\ell'_{8}$} \rput(4.4,6.75){\fontsize{7pt}{7pt}\selectfont$8\times{Q'}$} \psline[linewidth=0.5pt](4.35,6.9)(4.45,7.1) \psline[linewidth=0.5pt](4.35,2.5)(4.45,2.7) \rput(4.4,2.95){$r'_{8}$} \rput(4.4,2.35){\fontsize{7pt}{7pt}\selectfont$8\times{Q'}$} \psline{->}(3.8,2.6)(5,2.6) \psframe(5,6)(7,8) \rput(6,7){$\text{OPSC}_1(8,2)$} \psframe(5,1.6)(7,3.6) \rput(6,2.6){$\text{OPSC}_2(8,7)$} \psline(7,7)(8.2,7) \psline(7.2,7)(7.2,3.8) \psline(7.2,3.8)(1.6,3.8) \psline{->}(1.6,3.8)(1.6,3) \rput(7.65,7.3){$\hat{z}_8$} \psline[linewidth=0.5pt](7.55,6.9)(7.65,7.1) \psline{->}(8.2,7)(8.2,6) \psline(7.8,5.8)(8.6,5.8) \psline(7.8,5.6)(8.6,5.6) \psline(7.8,4.2)(8.6,4.2) \psframe(7.8,4)(8.6,6) \psdots[linecolor=black,dotsize=5pt](8.2,4.55) \psdots[linecolor=black,dotsize=5pt](8.2,4.9) \psdots[linecolor=black,dotsize=5pt](8.2,5.25) \rput{90}(7.6,5){Buffer Memory} \psline(7,2.6)(8.2,2.6) \psline(8.2,4)(8.2,3) \psline{->}(8.2,2.6)(9,2.6) \psline{->}(8.2,3)(9,3) \rput(7.65,2.9){$\hat{x}_8$} \psline[linewidth=0.5pt](7.55,2.5)(7.65,2.7) \psframe(9,2)(9.6,3.6) \rput{90}(9.3,2.8){PSUL} \psline[linewidth=0.5pt](9.9,2.7)(10,2.9) \rput(9.95,3.15){$\hat{u}_{16}$} \psbrace[nodesepB=5.5pt](1.85,4)(1.85,6){$\mathcal{L}(\text{OPSC}_{1})$} \psbrace[nodesepB=5.5pt](8.65,4)(8.65,6){$\mathcal{L}(\text{OPSC}_{2})$} \psframe[linestyle=dashed](-0.4,1.4)(10.9,8.4) \psline(0,7)(-0.4,7) \psline{->}(9.6,2.8)(10.9,2.8) } \end{pspicture} } \caption{OPSC(16,9) architecture} \label{fig:sc_architecture} \end{figure} Similar hardware architecture is utilized to decode all polar code segments recursively. When shortcuts are detected, $\text{OPSC}_1$ and $\text{OPSC}_2$ blocks are replaced. For example, $\text{OPSC}_2(8,7)$ is replaced with an SPC shortcut. \subsection{Building blocks of the OPSC decoder architecture} \label{sec:architecture} The basic building blocks of OPSC decoder are F and G functions. F$_N$ function consists of $N/2$ copies of F$_2$ function shown in Fig. \ref{fig:f2}. The F$_2$ function contains a compare-and-select (C\&S) logic and an XOR gate. \begin{figure}[ht] \centering \begin{pspicture}(0.5,2.5)(5,5) \psset{unit=0.5cm} \rput(0,1){ \rput(0,2){\logicxor[ninputs=2]{0}(5,5){}} \psset{unit=1cm} \psline{->}(0.8,2.8)(3,2.8) \psline{->}(0.5,2.2)(3,2.2) \psline{->}(0,4.25)(3,4.25) \psline{->}(0,3.75)(3,3.75) \psline(4.25,4)(5.6,4) \psline(0.8,4.25)(0.8,2.8) \psline(0.5,3.75)(0.5,2.2) \rput(0.3,4.45){$\ell_1$} \rput(0.3,3.95){$\ell_2$} \psdots[linecolor=black,dotsize=3pt](0.8,4.25) \psdots[linecolor=black,dotsize=3pt](0.5,3.75) \rput(1.8,4.45){$\text{sgn}(\ell_1)$} \rput(1.8,3.95){$\text{sgn}(\ell_2)$} \rput(4.92,4.2){$\text{sgn}(\ell_3)$} \rput(2,3){$\left|\ell_1\right|$} \rput(2,2.4){$\left|\ell_2\right|$} \rput(5,2.75){$\left|\ell_3\right|$} \psline(5.6,2.5)(5.6,4) \psline(4,2.5)(5.6,2.5) \psframe(3,2)(4,3)\rput(3.5,2.5){C$\&$S} \psdots[linecolor=black,dotsize=3pt](5.6,4) \psline{->}(5.6,4)(6.3,4) \rput(6,4.2){$\ell_3$} } \end{pspicture} \caption{F$_2$ function.}\label{fig:f2} \end{figure} G$_2$ function is shown in Fig. \ref{fig:g2}. The G$_2$ function contains an adder, a subtractor and a multiplexer. The select input $\hat{z}$ of the multiplexer may have longer delay than the $\ell_1' + \ell_2'$ and $\ell_2' - \ell_1'$ inputs due to XOR gate chain in PSUL. To avoid timing problems, both results are calculated and the correct one is chosen. Since LLRs are stored in sign-magnitude form, the G$_2$ function also utilizes two sign-magnitude to twos-complement converters (S2C) at the input and a twos-complement to sign-magnitude converter (C2S) at the output. \begin{figure}[ht] \centering \begin{pspicture}(0.5,4.5)(6,8) \rput(0,3.5){ \psline{->}(0,4.35)(0.5,4.35) \psline{->}(0,3.25)(0.5,3.25) \rput(0.25,4.65){$\ell_1$} \rput(0.25,3.5){$\ell_2$} \rput(-0.5,1.5){\psframe(1,1.5)(2,2)\rput(1.5,1.75){S2C}} \rput(-0.5,2.6){\psframe(1,1.5)(2,2)\rput(1.5,1.75){S2C}} \rput(1.75,4.65){$\ell_1'$} \rput(1.75,3.5){$\ell_2'$} \rmultiput{ \psline(1.5,1.5)(1.5,1) \psline(1.5,2.6)(2.2,2) \psline(1.5,2.1)(1.5,2.6) \psline(1.5,2.1)(1.8,1.8) \psline(1.5,1.5)(1.8,1.8) \psline(1.5,1)(2.2,1.6) \psline(2.2,1.6)(2.2,2)}(1,0)(1,2) \psline{->}(1.5,4.35)(2.5,4.35) \psline{->}(1.5,3.25)(2.5,3.25) \psline(1.75,3.25)(1.75,1.25) \psline(2,4.35)(2,2.35) \psline{->}(1.75,1.25)(2.5,1.25) \psline{->}(2,2.35)(2.5,2.35) \psdots[linecolor=black,dotsize=3pt](2,4.35) \psdots[linecolor=black,dotsize=3pt](1.75,3.25) \psline(3.2,1.8)(3.4,1.8)\psline(3.4,3.8)(3.4,3.1)\psline{->}(3.4,3.1)(3.8,3.1) \psline(3.2,3.8)(3.4,3.8)\psline(3.4,1.8)(3.4,2.3)\psline{->}(3.4,2.3)(3.8,2.3) \rput(0,-0.25){ \rput(4,3.4){1} \rput(4,2.6){0} \psline(3.8,2.25)(3.8,3.75) \psline(3.8,2.25)(4.25,2.5) \psline(3.8,3.75)(4.25,3.5) \psline(4.25,2.5)(4.25,3.5)} \psline{->}(4,4)(4,3.4)\rput(4,4.2){$\hat{z}$} \psline{->}(4.25,2.75)(4.75,2.75) \psframe(4.75,2.5)(5.75,3)\rput(5.25,2.75){C2S} \psline{->}(5.75,2.75)(6.25,2.75)\rput(6,3){$\ell_3$} \rput(2.7,4.2){$-$} \rput(2.7,3.4){$+$} \rput(2.7,2.2){$+$} \rput(2.7,1.4){$+$} } \end{pspicture} \caption{G$_2$ function.}\label{fig:g2} \end{figure} \subsubsection{Complexity analysis} \label{sec:memory_complexity} The time complexity of fully-parallel standard SC decoder is \begin{align} T_\text{N} &= 2 T_{\text{N}/2} + 2 \nonumber = \sum_{i=1}^n 2^{i} = 2N-2 =\Theta (N) \text{.}\nonumber \end{align} The memory complexity of unrolled and fully-pipelined standard SC decoder is \begin{align} M_\text{N} &= 2 M_{\text{N}/2} + (Q+0.5)(N^2-N) + NQ \nonumber \\ &=(Q+0.5)\big((2-2^{-\log N}) N^2 - N \log N - N\big) \nonumber \\ &\qquad + QN\log N \nonumber \\ &= \Theta (N^2 Q) \nonumber \text{.} \end{align} where $M_2 = 2Q + 1$. This formula shows that in the most general case, memory complexity increases almost quadratically with $N$. This memory is dominantly used in buffers, where soft decision values are stored. Size of these buffers decreases significantly after applying AQ and R-RB as shown in Table \ref{table:memory_details}. The final memory complexity of OPSC decoder is significantly smaller than the conventional SC decoder. \subsection{Register reduction/balancing} \label{sec:register_balancing} Pipeline stages are important to shorten the critical path and, thus, increase the clock frequency. However, excessive pipeline stages may also increase memory complexity. To reduce the pipeline depth, we merge a set of consecutive short paths of the SC decoder as much as possible based on the combinational delay from timing simulations. Register reduction is challenging for SC decoding algorithm due to its sequential essence. We overcome this problem by estimating delay of each computation and exploiting shortcuts for parallel processing. This method enables the decoder to perform multiple calculations within a single clock cycle with remarkably reduced latency and memory consumption. Table \ref{table:memory_details} shows that LLR buffer memory of OPSC decoder is reduced from 1.1 Mb to 380 Kb using R-RB at $Q=5$ bits. After applying R-RB, the pipeline depth becomes 60. The results include shortcuts without AQ. Applying the proposed AQ scheme in Fig. \ref{fig:adaptive_quantization} further reduces the LLR buffer memory to 361 Kb. Including PSUL memory, total buffer memory becomes 380 Kb. The memory gain of AQ is marginal, because R-RB scheme has already reduced the memory significantly. \begin{table}[ht] \centering \caption{Buffer memory of OPSC decoder} \label{table:memory_details} \begin{tabular}{ccccc} \hline \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Node \\ Length\end{tabular}} & \multicolumn{2}{c}{\begin{tabular}[c]{@{}c@{}}Buffer memory\\ depth w/o R-RB\end{tabular}} & \multicolumn{2}{c}{\begin{tabular}[c]{@{}c@{}}Buffer memory\\ depth with R-RB \end{tabular}} \\ & LLR & PSUL & LLR & PSUL \\ \hline 4 & - & 18 & - & - \\ 8 & 22 & 29 & - & 5 \\ 16 & 44 & 36 & 15 & 14 \\ 32 & 60 & 44 & 20 & 15 \\ 64 & 76 & 50 & 29 & 22 \\ 128 & 93 & 49 & 29 & 21 \\ 256 & 103 & 53 & 34 & 20 \\ 512 & 103 & 46 & 37 & 17 \\ 1024 & 112 & - & 41 & - \\ Total size & 1.1 Mb & 49 Kb & 380 Kb & 19 Kb \\ \hline \end{tabular} \end{table} \section{FPGA Verification and Performance} \label{sec:fpga_verification} Error correction performance of OPSC decoder was verified on Xilinx (xcvu37p-fsch2892-2L-e-es1) FPGA demo board. To attain real-time verification, FPGA architecture is developed for both polar systematic encoder and OPSC decoder. The rest of this section presents FPGA test platform and error correction performance of OPSC decoder. \subsection{FPGA test platform} \label{sec:fpga_test_platform} Polar decoder implementations were verified on FPGA test platform shown in Fig. \ref{fig:fpga_test}. The test platform supports 200 Gb/s information throughput at 234 MHz clock frequency. A linear feedback shift register (LFSR) array generates $K=854$ bit pseudo random data for each transmitted polar codeword. A systematic polar encoder generates $N=1024$ bit encoded data from the pseudo random data. The encoded data, $x_i$, consists of 854 systematic bits and 170 parity bits, where both bits are mapped to BPSK symbols ($s_i$) using the mapping rule in Eq. \ref{bpsk_map_rule}. The symbols are accumulated with the additive white Gaussian noise (AWGN) generated by a build-in Gaussian random number generator. BPSK demodulator generates LLR values with $Q=5$ bits in the form of sign-magnitude. The polar SC decoder processes LLRs and produces information bit estimates, which are compared with the original data to produce error statistics. \begin{figure} \centering \begin{pspicture}(0,0)(7.5,5) \psframe(0,3.5)(1.5,4.5)\rput(0.75,4){\begin{tabular}{c} Data\\Source \end{tabular}} \psline{->}(1.5,4)(2.5,4) \psframe(2.5,3.2)(4.5,4.8)\rput(3.5,4){\begin{tabular}{c} 200 Gb/s \\Polar \\ Encoder \end{tabular}} \psline{->}(4.5,4)(5.5,4) \psframe(5.5,3.5)(7.1,4.5)\rput(6.3,4){\begin{tabular}{c} BPSK\\Mapper \end{tabular}} \psline{->}(6.3,3.5)(6.3,3) \psframe(5.5,2)(7.1,3)\rput(6.3,2.5){\begin{tabular}{c} AWGN\\Channel \end{tabular}} \psline{->}(6.3,2)(6.3,1.5) \psframe(5.5,0)(7.1,1.5)\rput(6.3,0.75){\begin{tabular}{c} SISO \\LLR \\ Demapper \end{tabular}} \psline{->}(5.5,0.75)(4.5,0.75) \psframe(2.5,0)(4.5,1.6)\rput(3.5,0.8){\begin{tabular}{c} \textbf{200 Gb/s} \\ \textbf{OPSC} \\ \textbf{Decoder} \end{tabular}} \psline{->}(2.5,0.75)(1.5,0.75) \psframe(0,0)(1.5,1.5)\rput(0.75,0.75){\begin{tabular}{c} Error\\Statistics \end{tabular}} \end{pspicture} \caption{Block diagram of FPGA test platform}\label{fig:fpga_test} \end{figure} \begin{equation} \label{bpsk_map_rule} s_i = \begin{cases} 1, & \mbox{if } x_i = 0 \\ -1, & \mbox{otherwise.} \end{cases} \end{equation} \subsection{FPGA performance results} \label{sec:fpga_performance} The frame error statistics in Fig. \ref{fig:sc_fer} show that the FPGA implementation of OPSC decoder causes less than 0.1 dB performance loss compared to floating-point software simulation (without AQ). The performance loss is caused by 5-bit quantization of LLRs on FPGA. The proposed AQ scheme causes almost 0.1 dB more performance loss, which is tolerable due to hardware implementation gains. \begin{figure}[ht] \centering \includegraphics[scale=0.7]{scFer} \caption{FER performance of (1024,854) polar code} \label{fig:sc_fer} \end{figure} BER performance results in Fig. \ref{fig:sc_ber} show that a coding gain of $13.93 - 7.72 = 6.21$ dB is attained at $10^{-12}$ BER relative to uncoded transmission. \begin{figure}[ht] \centering \includegraphics[scale=0.7]{scBer} \caption{BER performance of (1024,854) polar code} \label{fig:sc_ber} \end{figure} FPGA implementation results of polar encoder and OPSC decoder are shown in Table \ref{table:resource_utilization_fpga}. Both encoder and decoder have 234 MHz clock frequency. To support this frequency, OPSC decoder utilizes register array memory in the form of LUT for storing internal LLRs. The received LLRs are stored in 143 block random access memory (BRAM) with 16K capacity. The results also show that OPSC decoder utilizes only 7.34 \% of the FPGA in terms of LUT consumption. OPSC decoder can fit low-cost FPGA boards such as Xilinx Artix-7. \begin{table}[ht] \centering \caption{FPGA resource utilization} \label{table:resource_utilization_fpga} \begin{tabular}{ccccc} \hline & LUT & FF & Power (mW) & Latency (ns) \\ \cline{2-5} Polar encoder & 1848 & 1825 & 36 & 8.5 \\ OPSC decoder & 95653 & 50843 & 2373 & 672 \\ \hline \end{tabular} \end{table} \FloatBarrier \section{ASIC Implementation} \label{sec:asic_implementation} This section presents ASIC implementation procedure and results. The general information about the ASIC implementation is as follows. \begin{itemize} \item The TSMC 16nm CMOS logic FinFet library (BWP16P90) is used for RTL synthesis and backend implementation. \item The process-voltage-temperature (PVT) values are 0.8 V and \ang{25}C. Although timing is satisfied at 0.7 V at the end of RTL synthesis, 0.8 V is chosen for backend implementation to make timing closure easier. \item The logic cells with a set of thresholds RVT, LVT, OPT-LVT and ULVT are used. \item The setup and hold time of each design are verified for typical, worst-C, worst-RC, best-C and best-RC design corners. \item The power results are estimated accurately by generating signal activity factors using a testbench. The testbench simulates consecutive decoding of 1000 codewords transmitted at 0-9dB Eb/No. For each Eb/No value 100 codewords are tested. \item To achieve timing-clean results, a noticeable number of buffers and inverters have been added to the design. \item The final implementation results are obtained at the end of a timing-clean P\&R. \end{itemize} \subsection{Synthesis} \label{sec:synthesis} The 0.8V TSMC 16nm logic FinFET plus 1P13M process is used for implementation. Physical synthesis is performed with Cadence Genus. The OPSC has been implemented for a clock frequency of 1.2 GHz. To cope with the high clock frequency, retiming has been adopted to move the pipeline registers across the combinatorial logic. In addition, during synthesis fine-grained clock gating has been performed to reduce the dynamic power. Initially, OPSC decoder was synthesized with 0.7V and 0.8V supply voltages at 1.2 GHz clock frequency. Synthesis results in Table \ref{table:synthesis_voltage_results} show that 73 paths have timing violations at 0.7V. These violations can be fixed by reducing clock frequency or increasing the number of pipeline stages. The former is not possible to achieve our Tb/s throughput target. The latter increases the number of DFF and therefore complexity of clock distribution network. This may cause routing problems at backend implementation stage. Since we want to keep pipeline depth as small as possible,the backend study is performed for only OPSC decoder at 0.8V. \begin{table}[ht] \centering \caption{Synthesis results of OPSC decoder at 0.7V and 0.8V supply voltages} \label{table:synthesis_voltage_results} \begin{tabular}{cccccc} \hline \begin{tabular}[c]{@{}c@{}}Supply\\ Voltage\\ (V)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Cell\\ Area\\ (um$^2$)\end{tabular} & \begin{tabular}[c]{@{}c@{}}\# of \\ DFF\end{tabular} & \begin{tabular}[c]{@{}c@{}}WNS\\ (ps)\end{tabular} & \begin{tabular}[c]{@{}c@{}}TNS\\ (ps)\end{tabular} & \begin{tabular}[c]{@{}c@{}}\# of \\ violating\\ paths\end{tabular} \\ \hline 0.8 & 462,386 & 397,030 & 0 & 0 & 0 \\ 0.7 & 468,132 & 395,935 & -5.7 & -166.3 & 73 \\ \hline \end{tabular} \end{table} \subsection{Floorplan} \label{sec:asic_floorplan} Physical floorplan for OPSC decoder is shown in Fig. \ref{fig:sc_floorplan}. Input and output pins are placed at top and bottom of the chip, respectively. Rectangular shape is adopted to increase area utilization under flat placement. The total area of the chip is $(1.255)(0.63) = 0.79$ mm$^2$. \begin{figure}[ht] \centering \includegraphics[scale=0.45]{floorplan} \caption{Physical floorplan of the OPSC decoder} \label{fig:sc_floorplan} \end{figure} \subsection{Placement and Routing} \label{sec:placement_clock_tree_routing} Virtual silicon tape out is a technique to conceptually validate on silicon without making a real tape out. It consists of going through all the implementation and signoff phases and doing all the simulations required to validate the design without send it to the fabrication. In this study, we have completed virtual silicon design flow up to post-place-and-route stage with timing closure. The physical implementation on this design was done with Cadence INNOVUS tool, using the exact same libraries as the synthesis and using the signoff timing recommendations provided by TSMC for OCV. Timing is closed only on SSG0.72V and TT0.8V corners in all temperatures. We also followed all the recommendations in terms of power and layout signoff. Additional cells added through different steps of the implementation is shown in Table \ref{table:implementation_added_cells}. \begin{table}[ht] \centering \caption{Additional cells at post-place, post-cts and post-route steps} \label{table:implementation_added_cells} \begin{tabular}{cccc} \hline & Post-place & Post-cts & Post-route \\ \cline{2-4} Density & 60.48 & 66.95 & 67.49 \\ Cells to fix setup/transition & 596 & 6119 & 450 \\ Latency average & N/A & 600 ps & 600 ps \\ Cells added to fix hold & N/A & 110452 & 116018 \\ \hline \end{tabular} \end{table} The spread of cells across libraries are shown in Table \ref{table:implementation_spread_cells}. \begin{table}[ht] \centering \caption{Cell types of OPSC decoder} \label{table:implementation_spread_cells} \begin{tabular}{ccccc} \hline \multicolumn{1}{l}{} & RVT & LVT & OPT-LVT & ULVT \\ \cline{2-5} Number of cells & 637,149 & 207,964 & 234 & 61,618 \\ \% of cells & 70.27 & 22.94 & 0.03 & 6.8 \\ \hline \end{tabular} \end{table} \subsection{ASIC implementation results} \label{sec:asic_results} The implementation results of the OPSC decoder in Table \ref{table:implementation_details} show that the decoder utilizes 906K instances in 0.5 mm$^2$ cell area. Even after our optimizations, the design is still register dominated due to deeply pipelined architecture to cope with 1.2 GHz clock frequency. Since register cells are usually larger than the other cells, 70\% of the area is occupied by registers. The second largest area belongs to combinational logic to process LLRs and produce hard decisions. The total power dissipation is 1.2 W, while the leakage power is only 2.4 mW. The registers clocked at 1.2 GHz has 52.8\% of the total power dissipation. Hold-fix and setup-fix buffers also have significant low power dissipation. \begin{table}[ht] \centering \caption{Implementation results of the OPSC decoder} \label{table:implementation_details} \begin{tabular}{ccccccc} \cline{1-7} \multirow{2}{*}{Cell type} & \multicolumn{2}{c}{Instances} & \multicolumn{2}{c}{Area} & \multicolumn{2}{c}{Power} \\ & Value & \% & um$^2$ & \% & mW & \% \\ \hline \multicolumn{1}{c}{Registers} & 401,132 & 44.2 & 357,327 & 69.8 & 616.2 & 52.8 \\ \multicolumn{1}{c}{Inverters} & 29,575 & 3.3 & 4,055 & 0.8 & 35.3 & 3.0 \\ \multicolumn{1}{c}{Buffers} & 154,379 & 17.0 & 52,087 & 10.2 & 261.4 & 22.4 \\ \multicolumn{1}{c}{Clk. latches} & 353 & 0.04 & 453 & 0.1 & 6.0 & 0.5 \\ \multicolumn{1}{c}{Comb. logic} & 321,292 & 35.4 & 97,683 & 19.1 & 248.6 & 21.3 \\ \multicolumn{1}{c}{Total} & 906,731 & 100 & 511,605 & 100 & 1,167 & 100 \\ \hline \end{tabular} \end{table} \subsection{ASIC implementation comparison with other high throughput polar decoders} \label{sec:results_comparison} A comparison of the proposed OPSC decoder implementation with the state-of-the-art polar SC decoder implementations is shown in Table \ref{table:synthesis_comparison}. The results are scaled to the same 0.8V supply voltage and 16nm process technology for a fair comparison. As for common scaling factors given in \cite{Wong2010}, the area is scaled in proportion to the square of the process ratio; the power is scaled in proportion to the square of voltage ratio and linear to process ratio; energy efficiency is scaled in proportion to the square of the process ratio times the square of the voltage ratio. The synthesis results show that OPSC decoder has a noticeable area efficiency, energy efficiency, and latency advantage compared to others. The unrolled implementation \cite{Gross2017} provides immense throughput at high clock frequency; however, it consumes too much power. The combinational decoder implementation \cite{Dizdar2017} is favorable in terms of power and power density; however, it has extremely low throughput to satisfy the high throughput requirements of certain applications. \begin{table} \centering \caption{Synthesis results comparison with the high throughput polar decoders} \label{table:synthesis_comparison} \begin{tabular}{@{}lccc@{}} \hline \textbf{Implementation} & This work & \cite{Gross2017} & \cite{Dizdar2017} \\ \textbf{ASIC Technology} & 16nm & 28nm & 90nm \\ \textbf{Block Length} & 1024 & 1024 & 1024 \\ \textbf{Code Rate} & 0.83 & 0.5 & Flex. \\ \textbf{Supply Voltage} (V) & 0.8 & 1.0 & 1.3 \\ \hline \textbf{Coded Throughput} (Gb/s) & 1229 & 1275 & 2.6 \\ \textbf{Frequency} (MHz) & 1200 & 1245 & 2.5\\ \textbf{Latency} ($\mu$s) & 0.05 & 0.29 & 0.40$^\dagger$ \\ \textbf{Latency} (Clock Cycles) & 60 & 365 & 1 \\ \textbf{Area} (mm\textsuperscript{2}) & 0.47 & 4.63 & 3.21\\ \textbf{Power} (mW) & 1072 & 8793 & 191 \\ \hline \multicolumn{4}{l}{Scaled to 16nm and 0.8V using the common scaling factors in \cite{Wong2010}. }\\ \hline \textbf{Coded Throughput} (Gb/s) & 1229 & \textbf{2231} & 14.4 \\ \textbf{Frequency} (MHz) & 1200 & \textbf{2179} & 14 \\ \textbf{Latency} ($\mu$s) & \textbf{0.05} & 0.17 & 0.07 \\ \textbf{Area} (mm\textsuperscript{2}) & 0.47 & 1.51 & \textbf{0.10}\\ \textbf{Area Eff.} (Gb/s/mm\textsuperscript{2}) & \textbf{2590} & 1477 & 142 \\ \textbf{Power} (mW) & 1072 & 3216 & \textbf{13} \\ \textbf{Power Density} (mW/mm\textsuperscript{2})& 2260 & 2128 & \textbf{126} \\ \textbf{Energy Eff.} (pJ/bit) & \textbf{0.87} & 1.44 & 0.89 \\ \hline \multicolumn{4}{l}{$^\dagger$Not presented in the paper, calculated from the presented results} \\ \end{tabular} \end{table} The comparison of the post-P\&R results of this work with the results of fabricated ASICs is shown in Table \ref{table:fabrication_comparison}. The scaled results show that this work has ultra-low latency and it can achieve Tb/s throughput under a reasonable area and power budget. The area efficiency result of this work is more than 10 times greater than the others. It is remarkable for this work to achieve 1.2 W power and 0.95 pJ/bit energy efficiency at 16nm FinFet technology. \begin{table} \centering \caption{Implementation results comparison with fabricated ASICs} \label{table:fabrication_comparison} \begin{tabular}{@{}lccc@{}} \hline \textbf{Implementation} & This work$^\dagger$ & \cite{Giard2017} & \cite{Liu2018} \\ \textbf{ASIC Technology} & 16nm & 28nm & 16nm \\ \textbf{Block Length} & 1024 & 1024 & 32768 \\ \textbf{Code Rate} & 0.83 & 0.85 & 0.85 \\ \textbf{Supply Voltage} (V) & 0.8 & 0.9 & 0.9 \\ \hline \textbf{Coded Throughput} (Gb/s) & 1229 & 9.23 & 4.44 \\ \textbf{Frequency} (MHz) & 1200 & 451 & 1000\\ \textbf{Latency} ($\mu$s) & 0.05 & 0.63 & - \\ \textbf{Latency} (CCs) & 60 & 283 & - \\ \textbf{Area} (mm\textsuperscript{2}) & 0.79 & 0.35 & 0.35\\ \textbf{Power} (mW) & 1167 & 10.6 & - \\ \hline \multicolumn{4}{l}{Scaled to 16nm and 0.8V using the common scaling factors in \cite{Wong2010}. }\\ \hline \textbf{Coded Throughput} (Gb/s) & \textbf{1229} & 16.16 & 4.44 \\ \textbf{Frequency} (MHz) & \textbf{1200} & 789 & 1000 \\ \textbf{Latency} ($\mu$s) & \textbf{0.05} & 0.36 & - \\ \textbf{Area} (mm\textsuperscript{2}) & 0.79 & \textbf{0.11} & 0.35\\ \textbf{Area Eff.} (Gb/s/mm\textsuperscript{2}) & \textbf{1554} & 143 & 12.7 \\ \textbf{Power} (mW) & 1167 & \textbf{5} & - \\ \textbf{Power Density} (mW/mm\textsuperscript{2})& 1473 & \textbf{43} & - \\ \textbf{Energy Eff.} (pJ/bit) & 0.95 & \textbf{0.30} & - \\ \hline \multicolumn{4}{l}{$^\dagger$Post-P\&R results are given for this work.}\\ \end{tabular} \end{table} \section{Conclusion} \label{sec:conclusion} In this paper, an optimized implementation of SC decoder based on AQ and R-RB methods is proposed for polar codes. These methods not only reduce implementation complexity, power and area but also enable Tb/s throughput on ASIC. Hardware architectures of (1024,854) OPSC decoder are developed for FPGA and ASIC. For FGPA, 200 Gb/s throughput is achieved and hardware verification of OPSC decoder is completed by measuring $1.1 \times 10^{-13}$ BER at 8 dB Eb/No. The ASIC implementation results show that OPSC decoder achieves 1.2 Tb/s coded throughput, 1554 Gb/s/mm\textsuperscript{2} area efficiency and 0.95 pJ/b energy efficiency. When OPSC decoder is compared with other fabricated ASICs for polar codes, it has 16 times more throughput, 7.2 times less latency and 10 times better area efficiency than the best alternative implementation. \section*{Acknowledgment} This work has been supported by EPIC project funded by the European Union's Horizon 2020 research and innovation programme under grant agreement No 760150. The authors would like to thank Prof. Norbert Wehn and Mr. Claus Kestel for useful discussions and comments. \FloatBarrier
{'timestamp': '2020-09-22T02:15:12', 'yymm': '2009', 'arxiv_id': '2009.09388', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09388'}
arxiv
\section{INTRODUCTION} Disaster areas, such as regions affected by earthquakes and floods, experience great disruption to communication and power infrastructure. This presents challenges in coordinating searches for survivors and dispersing relief teams to those locations. Teams of mobile robots have proved to be useful for exploring and mapping environments in disaster response scenarios \cite{michael2014collaborative,burgard2005coordinated,nagatani2013emergency}. However, such robots are subject to constraints on the payloads that they can carry, including power sources, sensors, embedded processors, actuators, and communication devices for transmitting information to other agents and/or to a command center. In addition, many multi-robot control strategies rely on a communication network for coordination. Centralized exploration strategies like \cite{simmons2000coordination} rely on constant communication between agents and a central node. However, these strategies do not scale well with the number of agents, since the communication bandwidth becomes a bottleneck with increasing agent population size. Moreover, such strategies suffer from a single point of failure, i.e., a disruption to the central node causes loss of communication for all the agents. \begin{figure}[t] \centering \includegraphics[width=0.35\textwidth]{five_agent_top_view_simulation.png} \caption{Overhead view of problem scenario, simulated in Gazebo 9 \cite{koenig2004design}. Multiple aerial robots, flying at different heights, search for a target represented by the magenta box using a Markov chain motion model.} \label{fig:gazebo_environment} \end{figure} These drawbacks can be overcome by employing decentralized exploration strategies that involve only local communication between agents. However, communication can become unreliable as the number of agents increases \cite{howard2006experiments}, and the connectivity of the communication network may be disrupted in some applications by the environment \cite{husain2013mapping} or by the movement of agents outside of communication range. Decentralized multi-agent control strategies that employ communication networks often require the agents to reach {\it consensus} on a particular variable. Achieving consensus is the problem of arriving at a common output variable or global property from measurements by distributed agents with local communication, without the need for a supervisory agent (leader or central processor) \cite{spanos2005dynamic}. Consensus problems have been studied in the cases of static or fixed network topologies \cite{ren2007information} and dynamic or switching network topologies \cite{spanos2005dynamic}, directed and undirected communication graphs \cite{ren2004consensus}, random networks \cite{mesbahi2010graph}, and mobile networks with communication delays \cite{olfati2004consensus}. Consensus algorithms for multi-robot rendezvous, e.g. \cite{parasuraman2018multipoint,yu2020synthesis,fox2006distributed,vincent2008distributed}, are an example of such a strategy on a dynamic network. The robot controllers drive the robots to meet at a common location in order to enable their information exchange via local communication. However, such strategies restrict exploration since the robots must aggregate at a common location. Distributed consensus for merging individual agents' information has been previously used for multi-agent search, e.g. \cite{hu2012multiagent}; however, it requires a connected communication network. Although random mobility models are commonly used in multi-robot exploration, e.g. \cite{martinez2012brownian,wagner1998robotic,winfield2000distributed}, few works consider consensus problems for agents that perform probabilistic search strategies, and thus have randomly time-varying communication networks. To address this problem, we present and analyze a probabilistic multi-agent search strategy that is based on a distributed consensus protocol. The proposed strategy is decentralized and asynchronous and relies on only limited communication among agents. Thus, it can be employed in applications, such as disaster response scenarios, where it is infeasible to maintain a connected communication network, rendezvous, or communicate with a central node. The agents move according to a discrete-time discrete-state (DTDS) Markov chain model on a finite spatial grid, as illustrated in \autoref{fig:gazebo_environment}. We consider only static features here, which represent persistent characteristics of the target(s) that the agents are searching for in the environment. The main contributions of this paper are the following: \begin{enumerate} \item We prove that agents with a DTDS Markov motion model and local communication will achieve consensus, in an \textit{almost sure} sense, on the presence of a static feature of interest in a bounded environment. \item Our proof does not require the assumption that the agent communication network remain connected over a non-zero finite time interval, as assumed in \cite{RageshTRO2020} for a similar consensus problem over a time-varying network.\footnote{This assumption implies the existence of a uniform upper bound on the interval between successive meeting times of any two agents, which is not guaranteed for agents that evolve stochastically on a finite connected state space.} \end{enumerate} We validate our theoretical results with Monte Carlo simulations in MATLAB and with 3D physics simulations performed in Gazebo 9 \cite{koenig2004design} using the Robot Operating System (ROS). From the simulation results, we empirically characterize the dependence of the expected time until consensus on the number of agents, the grid size, and the agent density, which can be used to guide the selection of the number of agents to search a given environment. The remainder of the paper is organized as follows. Section \ref{sec:ProbStatement} presents the problem formulation, and Section \ref{sec:DSMC} describes the probabilistic motion model of the agents. Section \ref{sec:ConsensusBasedSearch} proves that all agents will reach consensus on the presence of the feature under our stochastic search strategy. Section \ref{sec:Sim} presents example implementations of our strategy in numerical and 3D physics simulations and discusses the results. Section \ref{sec:ConcFutre} concludes and suggests future work. \section{PROBLEM STATEMENT} \label{sec:ProbStatement} We consider an unknown, bounded environment that contains a finite, non-zero number of static features of interest, indexed by the set $\mathcal{I} \subset \mathbb{Z}_+$, where $\mathbb{Z}_+$ is the set of positive integers. A set of $N$ agents, indexed by the set $\mathcal{N} = \{1,2,...,N\}$, explore the environment using a random walk strategy. We assume that each agent can localize itself in the environment and can detect a feature within its sensing range. When an agent $a \in \mathcal{N}$ detects a feature at discrete time $k$, it associates a scalar {\it information state} $\xi_{a}[k] \in \mathbb{R}_{\geq 0}$ with its current position. The vector of information states for all agents at time $k$ is denoted by $\boldsymbol{\xi}[k]$. Defining $\mathcal{U}(0,1)$ as the uniform probability distribution on the interval $[0,1]$, the initial information state of each agent $a$ is specified {\it a priori} as $\xi_a[0] \sim \mathcal{U}(0,1)$. The agent can communicate its information state $\xi_{a}[k]$ at time $k$ to all agents within a disc of radius $r_{comm} \in (0,\delta]$, where $\delta$ is the maximum communication radius. We define these agents as the set of {\it neighbors} of agent $a$ at time $k$, denoted by $\mathcal{N}_k^a$. In addition, we assume that the agents can avoid obstacles during their exploration. Since the agents are constantly moving, the set of agents with which they can communicate changes over time. The time evolution of this communication network is determined by the random walks of the agents throughout the bounded environment. This approach uses low communication bandwidth, since each agent only transmits a scalar value associated with each feature that it detects. We discretize the environment, as shown in \autoref{fig:MotionStrategy_Visual}, into a square grid of nodes spaced at a distance $d$ apart. The set of nodes is denoted by $\mathcal{S} \subset \mathbb{Z}_+$. We define $S = | \mathcal{S} |$. Let $\mathcal{G}_{s} = (\mathcal{V}_{s}, \mathcal{E}_{s})$ be an undirected graph associated with this finite spatial grid, where $\mathcal{V}_{s}$ is the set of nodes and $\mathcal{E}_{s}$ is the set of edges $(i,j)$ that signify pairs of nodes $i,j \in \mathcal{V}_s$ between which agents can travel. We refer to these pairs of nodes as {\it neighboring nodes}. Each agent performs a random walk on this grid, moving from its current node $i$ to a neighboring node $j$ at the next time step with transition probability $p_{ij}$. Let $Z_k^a \in \mathcal{S}$ be a random variable that represents the index of the node that an agent $a \in \mathcal{N}$ occupies at the discrete time $k$. For each agent $a$, the probability mass function $\pi_k \in \mathbb{R}^{1 \times S }$ of $Z_k^a$ evolves according to a DTDS Markov chain: \begin{equation} \pi_{k+1} = \pi_{k} \mathbf{P}, \label{eqn:DiscreteStateTransitionDynamics} \end{equation} where the {\it state transition matrix} $\mathbf{P} \in \mathbb{R}^{S \times S}$ has elements $p_{i j} \in [0, 1]$ at row $i \in \mathcal{S}$ and column $j \in \mathcal{S}$. We assume that no prior information about possible search locations is available. To cover the search area uniformly, each agent is deployed from a random node on the spatial grid. These initial agent positions are chosen independently of one another and are identically distributed according to the probability mass function $\pi_{0}$, defined as a discrete uniform distribution over the set of nodes. We define $\xi^{r} \in \mathbb{R}_{\geq 0}$ as a scalar {\it reference information state} that is associated with the set of nodes $\mathcal{Z}^{r} \subset \mathcal{S}$ from which an agent can detect a feature. In this work, we consider environments with a single feature of interest. We now define another graph that models the time-varying communication topology of the agents as they move along the spatial grid. Let $\mathcal{G}_c[k] = (\mathcal{V}_{c},\mathcal{E}_{c}[k])$ be an undirected graph in which $\mathcal{V}_{c} = \mathcal{N}$, the set of agents, and $\mathcal{E}_{c}[k]$ is the set of all pairs of agents $(a,b) \in \mathcal{N} \times \mathcal{N}$ that can communicate with each other at time $k$. Let $\mathbf{M}[k] \in \mathbb{R}^{\it {N} \times \it {N}}$ be the {\it adjacency matrix} with elements $m_{ab}[k] = 1$ if $(a,b) \in \mathcal{E}_c[k]$ and $m_{ab}[k] = 0$ otherwise. We define $\mathbf{L}[k] \in \mathbb{R}^{N \times N}$ as the graph Laplacian, whose elements are $l_{ab}[k] = \sum_{b=1}^{N} m_{ab}[k] = deg(v_a)$ if $a = b$ and $l_{ab}[k] = -m_{ab}[k]$ if $a \neq b$. Given the agent dynamics \eqref{eqn:DiscreteStateTransitionDynamics} on the spatial grid, each agent $a$ updates its information state at each time $k$ according to a consensus protocol similar to one developed in \cite{ren2008consensus}. This update is based on the agent's current information; the information from all its neighboring agents, of which there are at most $d_{max} = N-1$; and the reference information state: \begin{equation} \begin{split} \xi_{a} [k+1] = \xi_{a}[k] - \alpha \sum_{b \in \mathcal{N}^a_k} l_{ab}[k](\xi_{a}[k] - \xi_{b}[k]) \\ - ~ g_{a} (\xi_{a}[k] - \xi^{r}) , \end{split} \label{eqn:ReferenceStateInforamtionDynamicsAgentswise} \end{equation} where $a,b \in \mathcal{N}$; $\alpha$ is a constant, chosen such that $\alpha \in (0,\frac{1}{d_{max}})$ \cite{olfati2004consensus}; and $g_{a}$ is defined as: \begin{equation} g_{{a}} = \begin{cases} 1, & Z_{k}^{a} \in \mathcal{Z}^{r} \\ 0, & {\rm otherwise} \end{cases} \end{equation} In the next two sections, we will show that when agents move on the spatial grid according to \eqref{eqn:DiscreteStateTransitionDynamics} and exchange information with their neighbors according to \eqref{eqn:ReferenceStateInforamtionDynamicsAgentswise}, they achieve {\it average consensus} on their information states, defined as follows: \begin{definition} We say that the vector $\boldsymbol{\xi}[k]$ converges almost surely to average consensus if \begin{align} \boldsymbol{\xi}[k]~ \overset{a.s}{\rightarrow} ~ \xi^{r} \mathbf{1}, \end{align} \label{def:DirectedGraphAverageConsensus} where $\mathbf{1} \in \mathbb{R}^{N \times 1}$ is a vector of ones. \end{definition} This implies that the agents' individual information states will eventually converge to a common information state that indicates the presence of the object being searched. We define $\mathcal{T}_{c}$ as the time $k$ at which every agent's information state $\xi_a[k]$ reaches $\xi^{r}$ within a small tolerance $\epsilon$, where $0 \leq \epsilon \ll 1$; i.e., $|\xi_a[\mathcal{T}_{c}] - \xi^r| < \epsilon$ for all agents $a \in \mathcal{N}$. We consider $\mathcal{T}_{c}$ to be the time at which the agents reach consensus. \begin{algorithm}[t] \SetAlgoLined \DontPrintSemicolon \SetNoFillComment \textbf{Input:} $\alpha, g_a, \epsilon, \xi^r$; $\xi_a[0] \sim \mathcal{U}(0,1)$; $Z^a_0 \gets i \in \mathcal{S}$ \\ \textbf{Output:} $k, \xi_a[k]$ for which $|\xi_a[k] - \xi^r| \leq \epsilon$ \\ $k \leftarrow 0$ \\ \While{$|\xi_a[k] - \xi^r| > \epsilon$}{ sum1 $\leftarrow 0$ \\ sum2 $\leftarrow 0$ \\ \ForAll{$b \in \mathcal{N}^a_k$} {\tcc{agents $a$, $b$ communicate} sum1 $\leftarrow$ sum1 $- ~\alpha l_{ab}[k](\xi_{a}[k] - \xi_{b}[k])$ \\} \If{$i \in \mathcal{Z}^r$} {\tcc{agent $a$ detects feature} sum2 $\leftarrow - g_a (\xi_{a}[k] - \xi^r)$ \\} $\xi_{a}[k+1] \leftarrow \xi_{a}[k]$ + sum1 + sum2 \\ $Z_{k+1}^a \leftarrow j$, $(i,j) \in \mathcal{E}_s$, with probability $p_{ij}$ \\ $i \leftarrow j$ \\ $k \leftarrow k+1$ \\ \caption{Control strategy for agent $a \in \mathcal{N}$} \label{alg:consensus_pseudo_code} } \end{algorithm} \begin{figure}[t] \centering \begin{tikzpicture}[scale=0.7] \draw [step=1cm, thin, gray!50] (0,0) grid (10,10); \filldraw[color=black] (5,5) circle (0.1) \node[right] (i) at (4.8,4.5) {$m=Z^1_k=Z^2_k$}; \node [quadcopter top,fill=white,draw=red,minimum width=0.5cm, rotate=45] at (3.0,1.0) {}; \node[fill=red,regular polygon, regular polygon sides=3,inner sep=2.5pt] at (2.0,1) {}; \node[above] at (1.5,0.0) {$Z^1_0=i$}; \node[star,star points=8, fill=magenta,draw=black] at (8.1,7.9){}; \node [quadcopter top,fill=white,draw=orange,minimum width=0.5cm, rotate=45] at (5,9) {}; \node[fill=orange,regular polygon, regular polygon sides=3,inner sep=2.5pt] at (5,8) {}; \node[above] at (4.2,7) {$Z^2_0 = j$}; \draw[->,color=red, thick] (2,1) -- (1,1); \draw[->,color=red, thick] (1,1) -- (1,2); \draw[->,color=red, thick] (1,2) -- (2,2); \draw[->,color=red, thick] (2,2) -- (2,3); \draw[->,color=red, thick] (2,3) -- (2,4); \draw[->,color=red, thick] (2,4) -- (3,4); \draw[->,color=red, thick] (3,4) -- (4,4); \draw[->,color=red, thick] (4,4) -- (4,5); \draw[->,color=red, thick] (4,5) -- (5,5); \draw[->,color=orange, thick] (5,8) -- (6,8); \draw[->,color=orange, thick] (6,8) -- (7,8); \draw[->,color=orange, thick] (7,8) -- (8,8); \draw[->,color=orange, thick] (8,8) -- (8,7); \draw[->,color=orange, thick] (8,7) -- (7,7); \draw[->,color=orange, thick] (7,7) -- (7,6); \draw[->,color=orange, thick] (7,6) -- (6,6); \draw[->,color=orange, thick] (6,6) -- (6,5); \draw[->,color=orange, thick] (6,5) -- (5,5); \node [quadcopter top,fill=white,draw=black, minimum width=1.0cm, rotate=45] at (8,2) {}; \draw [->, color=black, thick] (8,3) -- node[right] {up} (8,4); \draw [->, color=black, thick] (7,2) -- node[below]{left} (6,2); \draw [->, color=black, thick] (8,1) -- node[right]{down} (8,0); \draw [->, color=black, thick] (9,2) -- node[below]{right} (10,2); \end{tikzpicture} \caption{Illustration of our multi-agent search strategy, showing sample paths for two quadrotors (orange and red) on a square grid. The quadrotors search the environment for a static target (the magenta star) as they perform a random walk on the grid.} \label{fig:MotionStrategy_Visual} \end{figure} The implementation of this probabilistic search strategy on each agent is described in the pseudo code shown in Algorithm \ref{alg:consensus_pseudo_code}. We illustrate the strategy for a scenario with two quadrotors in \autoref{fig:MotionStrategy_Visual}. The quadrotors start at the spatial grid nodes indexed by $i$ and $j$ and move on the grid according to the DTDS Markov chain dynamics in \eqref{eqn:DiscreteStateTransitionDynamics}. The figure shows sample paths of the quadrotors. The orange quadrotor detects the feature, indicated by a magenta star, when it moves to a node in the set $\mathcal{Z}^r$ (at these nodes, the feature is within the quadrotor's sensing range). The quadrotors meet at grid node $m$ after $k=9$ time steps and exchange information according to \eqref{eqn:ReferenceStateInforamtionDynamicsAgentswise}. They stop the search if their information states are within $\epsilon$ of $\xi^r$; otherwise, they continue to random-walk on the grid. \section{Analysis of the Markov Chain Model of Agent Mobility}\label{sec:DSMC} Consider the DTDS Markov chain that governs the probability mass function of the state $Z_k^{a}$, defined as the location of agent $a$ at time $k$ on the spatial grid that represents the environment. Then, the time evolution of the agent $a$'s movement in this finite state space can be expressed by using the Markov property as follows: \begin{equation} \begin{split} Pr(Z_{k+1}^{a} = j ~|~ Z_{k}^{a} = i, Z_{k-1}^{a} = m, \ldots, Z_0^{a} = l ) \\ = Pr(Z_{k+1}^{a} = j ~|~ Z_k^{a} = i), \end{split} \label{eqn:Markov_property} \end{equation} where the second expression is the probability with which an agent at node $j$ transitions to node $i$ at time $k+1$, and $m,l \in \mathbb{Z}_+$. \subsection{State Transition Matrix} The Markov chain \eqref{eqn:DiscreteStateTransitionDynamics} is expressed in terms of the \textit{state transition matrix} $\mathbf{P}$. The time invariant matrix $\mathbf{P}$ is defined by the state space of the spatial grid representing the discretized environment. Hence, the Markov chain is $\textit{time-homogeneous}$, which implies that $Pr(Z^a_{k+1} = j ~|~ Z^a_k = i)$ is the same for all agents at all times $k$. The entries of $\mathbf{P}$, which are the state transition probabilities, can therefore be defined as \begin{equation} p_{ij}= Pr(Z_{k+1}^{a} = j ~|~ Z_{k}^{a} = i),~ \forall i,j \in \mathcal{S}, ~k \in \mathbb{Z}_+, ~\forall a \in \mathcal{N}. \label{eqn:TransitionProbabilityMatHomogenousMC} \end{equation} \begin{comment} \begin{figure}[h] \centering \begin{tikzpicture} \node[style={circle,fill=orange!20}] (a1) at (0,0) {$i$}; \node[style={circle,fill=orange!20}] (a2) at (2,0) {$j$}; \node[style={circle,fill=orange!20}] (a3) at (4,0) {$l$}; \node[] (a4) at (5,0){}; \draw[->,style={draw=black}] (a1) -- node[above]{$p_{i j}$} (a2); \draw[->,style={draw=black}] (a2) -- node[above]{$p_{j l}$} (a3); \draw[->,style={draw=black}] (a1) to [in=160, out=100,looseness=5] node[above] {$p_{i i}$} (a1); \draw[->,style={draw=black}] (a2) to [in=160, out=100,looseness=5] node[above] {$p_{j j}$} (a2); \draw[->,style={draw=black}] (a3) to [in=160, out=100,looseness=5] node[above] {$p_{l l}$} (a3); \end{tikzpicture} \caption{Markov Transition Probability \spr{(I think that this should be shown in Fig. 4, not as a separate figure)}} \label{fig:MarkovianTransition} \end{figure} \end{comment} Since each agent chooses its next node from a uniform distribution, these entries can be computed as \begin{equation} p_{ij} =\begin{cases} \frac{1}{d_{i}+1}, & (i,j) \in \mathcal{E}_{s}, \\ 0, & $otherwise$, \end{cases} \label{eqn:TransitionMat_Elements} \end{equation} where $d_{i}$ is the degree of the node $i \in \mathcal{S}$, defined as $d_i = 2$ if $i$ is a corner of the spatial grid, $d_i = 3$ if it is on an edge between two corners, and $d_i = 4$ otherwise. Since each entry $p_{ij} \geq 0$, we use the notation $\mathbf{P} \geq 0$. We see that $\mathbf{P}^{m} \geq 0$ for $m \geq 1$. Hence, $\mathbf{P}$ is a \textit{non-negative matrix.} Using Theorem 5 in \cite{grimmett2001probability}, we can conclude that the state transition matrix $\mathbf{P}$ is a stochastic matrix. \subsection{Stationary Distribution} A stationary distribution of a Markov chain is defined as follows. \begin{definition}(Page 227 in \cite{grimmett2001probability}) The vector $\pi \in \mathbb{R}^{S}$ is called a stationary distribution of a Markov chain if $\pi$ has entries such that: \begin{enumerate} \item $\pi_{j} \geq 0$ $~~\forall j \in \mathcal{S} $ and $\sum_{j=1}^{S} \pi_{j} =1$ \item $\pi \mathbf{P} = \pi $ \end{enumerate} \end{definition} Thus, if $\pi$ is a stationary distribution, we can say that $\forall k \in \mathbb{Z}_+$, \begin{equation} \pi \mathbf{P}^{k} = \pi. \label{eqn:StationaryDist} \end{equation} From the construction of the Markov chain \eqref{eqn:DiscreteStateTransitionDynamics}, each agent has a positive probability of moving from any node $i \in \mathcal{S}$ to any other node $j \in \mathcal{S}$ of the spatial grid in a finite number of time steps. As a result, the Markov chain $Z_k^{a}$ is an {\it irreducible} Markov chain, and therefore $\mathbf{P}$ is an irreducible matrix. From Lemma 8.4.4 (Perron-Frobenius) in \cite{horn1990matrix}, we know that there exists a real unique positive left eigenvector of $\mathbf{P}$. Moreover, since $\mathbf{P}$ is a stochastic matrix, its spectral radius $\rho(\mathbf{P})$ is equal to 1. Therefore, we can conclude that this left eigenvector is the stationary distribution of the corresponding DTDS Markov chain. We will next apply the following theorem. \begin{theorem} (Theorem 21.12 in \cite{levin2017markov}) An irreducible Markov chain with transition matrix $\mathbf{P}$ is positive recurrent if and only if there exists a probability distribution $\pi$ such that $\pi \mathbf{P} = \pi$. \label{thm:PositiveRecurecurrenceThm} \end{theorem} Since we have shown that the Markov chain is {\it irreducible} and has a stationary distribution $\pi$, which satisfies $\pi \mathbf{P} = \pi$, we can conclude from Theorem \ref{thm:PositiveRecurecurrenceThm} that the Markov chain is {\it positive recurrent}. Thus, all states in the Markov chain are positive recurrent, which implies that each agent will keep visiting every state on the finite spatial grid infinitely often. \section{Analysis of Consensus on Agents' Information States}\label{sec:ConsensusBasedSearch} The dynamics of all agents' movements on the spatial grid can be modeled by a composite Markov chain with states defined as $\mathbf{Z}_k = (Z^1_k, Z^2_k, ..., Z^N_k) \in \mathcal{M}$, where $\mathcal{M} = \mathcal{S}^{\mathcal{N}}$. Note that $S = |\mathcal{S}|$ and $|\mathcal{M}| = S^N$. We define an undirected graph $\hat{\mathcal{G}} = (\hat{\mathcal{V}},\hat{\mathcal{E}})$ that is associated with the composite Markov chain. The vertex set $\hat{\mathcal{V}}$ is the set of all possible realizations $\hat{\imath} \in \mathcal{M}$ of $\mathbf{Z}_k$. The notation $\hat{\imath}(a)$ represents the $a^{th}$ entry of $\hat{\imath}$, which is the spatial node $i \in \mathcal{S}$ occupied by agent $a$. We define the edge set $\hat{\mathcal{E}}$ of the graph $\hat{\mathcal{G}}$ as follows: $(\hat{\imath},\hat{\jmath}) \in \hat{\mathcal{E}}$ if and only if $(\hat{\imath}(a),\hat{\jmath}(a)) \in \mathcal{E}_s$ for all agents $a \in \mathcal{N}$. Let $\mathbf{Q} \in \mathbb{R}^{ | \mathcal{M}| \times |\mathcal{M}|}$ be the state transition matrix associated with the composite Markov chain. The elements of $\mathbf{Q}$, denoted by $q_{\hat{\imath} \hat{\jmath}}$, are computed from the transition probabilities defined by Equation \eqref{eqn:TransitionMat_Elements} as follows: \begin{equation} q_{\hat{\imath} \hat{\jmath}} = \prod_{a=1}^{N} p_{\hat{\imath}(a) \hat{\jmath}(a)}, ~~~~ \forall \hat{\imath}, \hat{\jmath} \in \mathcal{M}. \label{eqn:TransitionRatesProductState} \end{equation} In the above expression, $q_{\hat{\imath} \hat{\jmath}}$ is the probability that in the next time step, each agent $a$ will move from spatial node $\hat{\imath}(a)$ to node $\hat{\jmath}(a)$. \begin{comment} \begin{figure}[h] \centering \begin{tikzpicture}[scale=.5,auto=center \node[style={circle,fill=blue!20}] (a1) at (0,0) {1}; \node[style={circle,fill=blue!20}] (a2) at (0,1.5) {2}; \node[text width=2.5cm, text centered](alabel) at (0,3) {$\mathcal{N} =2$}; \node[style={circle,fill=red!20}] (i1) at (3,1) {$\textit{i}$}; \node[style={circle,fill=red!20}] (i2) at (5,1) {$\textit{j}$}; \node[style={circle,fill=red!20}] (i3) at (7,1) {$\textit{l}$}; \node[text width=5cm, text centered](glabel) at (6,3) { $\mathcal{G}_s$:=($\mathcal{V}_s,\mathcal{E}_s)$:}; \draw (a1) (a2); \draw[<->,style={draw=black}] (i1) -- (i2); \draw[<->,style={draw=black}] (i2) -- (i3); \node[] at (-0.5,-2.0) {$\mathcal{\hat{G}}$:=($\mathcal{\hat{V}},\mathcal{\hat{E}})$:}; \node [style={circle,fill=green!30!white}] (a1i1a2i1) at (3,-2) {$(i,i)$}; \node (ghatv1) at (3,-0.5) {$\hat{i}$}; \node [style={circle,fill=green!30!white}] (a1i1a2i2) at (6,-2) {$(i,j)$}; \node (ghatv2) at (6,-0.5) {$\hat{j}$}; \node [style={circle,fill=green!30!white}] (a1i1a2i3) at (9,-2) {$(i,l)$}; \node (ghatv3) at (9,-0.5) {$\hat{l}$}; \node (ghatend) at (11,-2){}; \draw[->,style={draw=black}] (a1i1a2i1) -- node[above,midway]{$q_{\hat{i},\hat{j}}$} (a1i1a2i2); \draw[->,style={draw=black}] (a1i1a2i2) -- node[above,midway]{$q_{\hat{j},\hat{l}}$} (a1i1a2i3); \draw[style={draw=black, dashed}] (a1i1a2i3) -- (ghatend); \draw[->,style={draw=black}] (a1i1a2i1) to [loop, in=250, out=210,looseness=3] node[below] {$q_{\hat{i},\hat{i}}$} (a1i1a2i1); \draw[->,style={draw=black}] (a1i1a2i2) to [loop, in=250, out=210,looseness=3] node[below] {$q_{\hat{j},\hat{j}}$} (a1i1a2i2); \draw[->,style={draw=black}] (a1i1a2i3) to [loop, in=250, out=210,looseness=3] node[below] {$q_{\hat{l},\hat{l}}$} (a1i1a2i3); \end{tikzpicture} \caption{Composite graph $\mathcal{\hat{G}}$ showing 2 agents (blue circles) \spr{(I don't think that you need the blue circles; you can just say that there are 2 agents)} move on the graph $\mathcal{G}_s$ shown in \autoref{fig:MarkovianTransition}.} \label{fig:Q_Mat_elem_Vis} \end{figure} \end{comment} \begin{figure}[h] \centering \begin{tikzpicture} \node[style={circle,fill=orange!20}] (a1) at (0,0) {$i$}; \node[style={circle,fill=orange!20}] (a2) at (2,0) {$j$}; \node[style={circle,fill=orange!20}] (a3) at (4,0) {$l$}; \node[] (a4) at (5,0){}; \draw[<->,style={draw=black}] (a1) -- node[above]{$p_{i j}$} (a2); \draw[<->,style={draw=black}] (a2) -- node[above]{$p_{j l}$} (a3); \draw[<->,style={draw=black}] (a1) to [in=160, out=100,looseness=5] node[above] {$p_{i i}$} (a1); \draw[->,style={draw=black}] (a2) to [in=160, out=100,looseness=5] node[above] {$p_{j j}$} (a2); \draw[->,style={draw=black}] (a3) to [in=160, out=100,looseness=5] node[above] {$p_{l l}$} (a3); \end{tikzpicture} \caption{A graph $\mathcal{G}_s = (\mathcal{V}_s,\mathcal{E}_s)$ defined on the set of spatial nodes $\mathcal{V}_s = \{i,j,l\}$. The arrows signify directed edges between pairs of distinct nodes or self-edges. The edge set of the graph is $\mathcal{E}_s = \{(i,i), (j,j), (l,l), (i,j), (j,l)\}$. } \label{fig:MarkovianTransition} \end{figure} \begin{figure}[h] \centering \begin{tikzpicture}[scale=.5,auto=center] \node [style={circle,fill=green!30!white}] (a1i1a2i1) at (0,0) {$(i,i)$}; \node (ghatv1) at (0,1.7) {$\hat{i}$}; \node [style={circle,fill=green!30!white}] (a1i1a2i2) at (5,0) {$(i,j)$}; \node (ghatv2) at (5,1.7) {$\hat{j}$}; \node [style={circle,fill=green!30!white}] (a1i1a2i3) at (10,0) {$(i,l)$}; \node (ghatv3) at (10,1.7) {$\hat{l}$}; \node (ghatend) at (13,0){}; \draw[<->,style={draw=black}] (a1i1a2i1) -- node[above,midway]{$q_{\hat{i},\hat{j}}$} (a1i1a2i2); \draw[<->,style={draw=black}] (a1i1a2i2) -- node[above,midway]{$q_{\hat{j},\hat{l}}$} (a1i1a2i3); \draw[style={draw=black, dashed}] (a1i1a2i3) -- (ghatend); \draw[<->,style={draw=black}] (a1i1a2i1) to [loop, in=250, out=210,looseness=3] node[below] {$q_{\hat{i},\hat{i}}$} (a1i1a2i1); \draw[<->,style={draw=black}] (a1i1a2i2) to [loop, in=250, out=210,looseness=3] node[below] {$q_{\hat{j},\hat{j}}$} (a1i1a2i2); \draw[->,style={draw=black}] (a1i1a2i3) to [loop, in=250, out=210,looseness=3] node[below] {$q_{\hat{l},\hat{l}}$} (a1i1a2i3); \end{tikzpicture} \caption{A subset of the composite graph $\mathcal{\hat{G}}=(\mathcal{\hat{V}},\mathcal{\hat{E}})$ for 2 agents that move on the graph $\mathcal{G}_s$ shown in \autoref{fig:MarkovianTransition}.} \label{fig:Q_Mat_elem_Vis} \end{figure} For example, consider a set of two agents, $\mathcal{N} = \{1,2\}$, that move on the graph $\mathcal{G}_s$ as shown in \autoref{fig:MarkovianTransition}. The agents can stay at their current node in the next time step or travel between nodes $i$ and $j$ and between nodes $j$ and $l$, but they cannot travel between nodes $i$ and $l$. \autoref{fig:Q_Mat_elem_Vis} shows a subset of the resulting composite graph $\mathcal{\hat{G}}$. The set of nodes in the graph $\hat{\mathcal{G}}$ is $\hat{\mathcal{V}} = \{(i,i), (i,j), (i,l), (j,i), (j,j), (j,l), (l,i), (l,j), (l,l)\}$. Each node in $\hat{\mathcal{V}}$ is labeled by a single index $\hat{\imath}$, e.g., $\hat{\imath} = (i,j)$, with $\hat{\imath}(1) = i$ and $\hat{\imath}(2) = j$. Due to the connectivity of the spatial grid defined by $\mathcal{E}_s$, we can for example identify $((i,j),(i,l))$ as an edge in $\hat{\mathcal{E}}$, but not $((i,j),(l,l))$. Since $N = 2$ and $S = 3$, we have that $|\mathcal{M}| = 3^2 = 9$. For each $\hat{\imath},\hat{\jmath} \in \hat{\mathcal{V}}$, we can compute the transition probabilities in $\mathbf{Q} \in \mathbb{R}^{9 \times 9}$ from Equation \eqref{eqn:TransitionRatesProductState}as follows: \begin{eqnarray} q_{\hat{\imath} \hat{\jmath}} & = Pr\left(\mathbf{Z}_{k+1} = \hat{\jmath} ~|~ \mathbf{Z}_{k} = \hat{\imath} \right) = p_{\hat{\imath}(1)\hat{\jmath}(1)}p_{\hat{\imath}(2)\hat{\jmath}(2)}, \nonumber \\ & \hspace{3cm} ~k \in \mathbb{Z}_+. \label{eqn:ProductSpaceTransitionProb} \end{eqnarray} We now define $\boldsymbol{\hat{\xi}}[k] = [\xi_1[k] ~~\xi_2[k] ~~\ldots~~ \xi_N[k] ~~\xi^r]^T \in \mathbb{R}^{N+1}$ as an augmented information state vector. The dynamics of information exchange among the agents modeled by Equation \eqref{eqn:ReferenceStateInforamtionDynamicsAgentswise} can then be represented in matrix form as follows: \begin{equation} \boldsymbol{\hat{\xi}}[k+1] = \mathbf{H}[k] \boldsymbol{\hat{\xi}}[k], \label{eqn:RefUpdateMatrixNotation} \end{equation} where $\mathbf{H}[k] \in \mathbb{R}^{(N+1) \times (N+1)}$ is defined as \begin{equation} \mathbf{H}[k]= \begin{bmatrix} ~\mathbf{I} - \alpha \mathbf{L}[k] + \hspace{0.5mm} diag(\mathbf{d}) & ~~ -\mathbf{d} ~ \\ ~\mathbf{0} & ~~ 1 ~ \end{bmatrix} \label{eqn:RefTrackingUpdateMtrix} \end{equation} in which $\mathbf{d} = [g_{1} ~ g_{2} ~ \ldots ~ g_{N}]^T$, $\mathbf{0} \in \mathbb{R}^{1 \times N}$ is a vector of zeros, and $\mathbf{I} \in \mathbb{R}^{N \times N}$ is the identity matrix. We associate Equation \eqref{eqn:RefUpdateMatrixNotation} with a graph $\mathcal{G}_{r}[k]$, an expansion of the graph $\mathcal{G}_c[k]$ that includes information flow from the feature nodes $\mathcal{Z}^r$ to agents that occupy these nodes. Here we consider the feature as an additional agent $a_f = N+1$, which remains fixed. Let $\mathcal{G}_{r}[k] = (\mathcal{V}_{r},\mathcal{E}_{r}[k])$ be a directed graph in which $\mathcal{V}_{r} = \mathcal{N} \cup a_f$, the set of agents and the feature, and $\mathcal{E}_{r}[k] = \mathcal{E}_c[k] ~\cup~ \mathcal{E}_f[k],$ where $\mathcal{E}_f[k]$ is the set of agent-feature pairs $(a,a_f)$ for which $Z_{k}^{a} \in \mathcal{Z}^{r}$ at time $k$. In this graph, information flows in one direction from the feature nodes to all agents that occupy a feature node on the finite spatial grid at time $k$. In addition, information flows bidirectionally between agents that are neighbors at time $k$. We now prove the main result of this paper in the following theorem, which shows that all agents will track the reference feature in the environment almost surely and in a distributed fashion. \begin{theorem} Consider a group of $N$ agents whose information states evolve according to Equation \eqref{eqn:RefUpdateMatrixNotation}. The information states of all agents will converge to the reference information state $\xi^r$ almost surely. \label{thm:DirectedMarkovianConsensus} \end{theorem} \begin{proof} Suppose that at an initial time $k_0$, the locations of the $N$ agents on the spatial grid are represented by the node $\hat{\imath} \in \hat{\mathcal{V}}$. Consider another set of agent locations at a future time $k_0 + k$, represented by the node $\hat{\jmath} \in \hat{\mathcal{V}}$. The transition of the agents from configuration $\hat{\imath}$ to configuration $\hat{\jmath}$ in $k$ time steps corresponds to a random walk of length $k$ on the composite Markov chain $\mathbf{Z}_k$ from node $\hat{\imath}$ to node $\hat{\jmath}$. It also corresponds to a random walk by each agent $a$ on the spatial grid from node $\hat{\imath}(a)$ to node $\hat{\jmath}(a)$ in $k$ time steps. By construction, the graph $\mathcal{G}_s$ is strongly connected and each of its nodes has a self-edge. Thus, there exists a discrete time $n>0$ such that, for each agent $a$, there exists a random walk on the spatial grid from node $\hat{\imath}(a)$ to node $\hat{\jmath}(a)$ in $n$ time steps. Consequently, there always exists a random walk of length $n$ on the composite Markov chain $\mathbf{Z}_k$ from node $\hat{\imath}$ to node $\hat{\jmath}$. Therefore, $\mathbf{Z}_k$ is an irreducible Markov chain. All states of an irreducible Markov chain belong to a single communication class. In this case, all states are \textit{positive recurrent}. As a result, each state of $\mathbf{Z}_k$ is visited infinitely often by the group of agents. Moreover, because the composite Markov chain is irreducible, we can conclude that $\cup_{k \in \mathbb{Z}_+} \mathcal{G}_c[k] = \mathcal{G}_0$, where $\mathcal{G}_0$ is the complete graph on the set of agents $\mathcal{N}$, and therefore that $\cup_{k \in \mathbb{Z}_+} \mathcal{G}_r[k]$ contains a directed spanning tree with $\xi^{r}$ as the fixed root. Since this union of graphs has a spanning tree, we can apply Theorem 3.1 in \cite{matei2009consensus} to conclude that the information state of each agent will converge to $\xi^{r}$ almost surely. The notation $\theta(k)$ and $F_{\theta(k)}$ in \cite{matei2009consensus} corresponds to our definitions of $\mathbf{Z}_k$ and $\mathbf{H}[k]$, respectively. \qed \end{proof} \section{Simulation Results}\label{sec:Sim} We validate the result on average information consensus in Theorem \ref{thm:DirectedMarkovianConsensus} with numerical simulations in MATLAB and 3D physics-based software-in-the-loop (SITL) simulations developed in ROS-Melodic and Gazebo 9 \cite{koenig2004design}. In the simulations, multiple agents perform random walks on a finite spatial grid according to the dynamics in Equation \eqref{eqn:DiscreteStateTransitionDynamics}. Each grid is defined as a square lattice with $c = \sqrt{S}$ nodes on each side, where the distance between neighboring nodes is $d = 1$ m. The state transition probabilities $p_{ij}$ of the corresponding graph $\mathcal{G}_s$ are defined according to Equation \eqref{eqn:TransitionMat_Elements}. Since our largest simulated agent population is $N=14$, and the parameter $\alpha$ must be less than $\frac{1}{d_{max}} = \frac{1}{N-1}$ \cite{olfati2004consensus}, we set $\alpha = \frac{1}{14-1} \approx 0.08$. The tolerance $\epsilon$ defining the time until consensus was set to 0.01. All simulations were run on a desktop computer with 16 GB of RAM and an Intel Xeon 3.0 GHz 16 core processor with an NVIDIA Quadro M4000 graphics processor. \subsection{Numerical Simulations} We performed large ensembles of Monte Carlo simulations to investigate the effect of the number of agents $N$, the spatial grid dimension $c$, and the resulting agent density $N/c^2$ on the expected time until the agents reach consensus, i.e., agree that the feature of interest is present. Quantifying the effect of these factors is necessary in order to determine the number of agents that should search a given area. This would help first responders to optimally distribute resources for searching a disaster-affected environment. Each agent is modeled as a point mass that can move between adjacent nodes on the graph $\mathcal{G}_s$, as illustrated in \autoref{fig:MotionStrategy_Visual}. We assume that the agents can localize on $\mathcal{G}_s$. The set of neighbors $\mathcal{N}^a_k$ of an agent $a$ at time $k$ consists of all agents that occupy the same spatial node as agent $a$ at that time. The feature can by detected by an agent located at nodes $\mathcal{Z}^r = \{ 4, 5, 6\}$ of the spatial grid, and the reference information state of the feature is defined as $\xi^r = 1$. To investigate the dependence of the expected time to reach consensus, $\mathbb{E}[\mathcal{T}_c]$, on the number of agents $N$ and the spatial grid dimension $c$, we simulated scenarios with different combinations of $N \in \{2, 3, \ldots, 14\}$ and $c \in \{5, 8, 10, 12, 15, 20\}$ meters. For each scenario, we ran 1000 simulations with random initial agent positions and computed the mean time $\mu$ at which the agents reached consensus. \autoref{fig:SurfacePlotConsensus} plots the values of $\mu$ versus $N$ and $c$ for each simulated scenario, and \autoref{fig:mu_vs_agent_density} plots $\mu$ versus the corresponding agent density, $N/c^2$. We observe from these figures that a decrease in the agent density results in an increase in $\mu$. This can be attributed to low agent encounter rates with other agents and with feature nodes at low agent densities. Using the curve fitting toolbox in MATLAB and data from \autoref{fig:mu_vs_agent_density} we see that there is an exponential relation between $\mathbb{E}[\mathcal{T}_c]$ and $N/c^2$ given by $\mathbb{E}[\mathcal{T}_c] =ae^{-b\frac{N}{c^2}}$ with $a=0.008,b=-15.84$. \autoref{fig:mu_vs_agent_density} shows that the expected time until consensus does not decrease appreciably for agent densities above approximately $N/c^2 = 0.05$. Thus, for a given grid size $c^2$, it may not be necessary to deploy more than about $\lceil 0.05c^2 \rceil$ agents ($0.05c^2$ rounded up to the next integer) to search the area. \begin{figure}[t] \centering \includegraphics[scale=0.55]{Surf_plot_consensus.eps} \caption{Mean time (s) until consensus is reached, $\mu$, versus number of agents $N$ and spatial grid dimension $c$. Each value of $\mu$ is averaged over 1000 Monte Carlo simulations of scenarios with the corresponding values of $N$ and $c$.} \label{fig:SurfacePlotConsensus} \end{figure} \begin{figure}[t] \centering \includegraphics[scale=0.55]{Time_to_consensus_vs_agent_denisty.eps} \caption{Mean time (s) until consensus is reached, $\mu$, versus agent density $N/c^2$ for the simulation data plotted in \autoref{fig:SurfacePlotConsensus}.} \label{fig:mu_vs_agent_density} \end{figure} For selected combinations of $N$ and $c$, we also computed the standard deviation $\sigma$ of the time to reach consensus over the corresponding 1000 simulations. \autoref{fig:Temporal_mean_with_agent_size} plots $\mu \pm \sigma$ versus $N$ for a fixed grid dimension $c = 5$, and \autoref{fig:Temporal_mean_with_grid_size} plots $\mu \pm \sigma$ versus $c$ for a fixed number of agents $N=5$. \autoref{fig:Temporal_mean_with_agent_size} shows that for a relatively small grid size ($c=5$), both $\mu$ and $\sigma$ do not vary substantially with $N$. Thus, a small number of agents would be sufficient to search such an environment, since increasing the agent density would not significantly speed up the search or reduce the variability in time until consensus. \autoref{fig:Temporal_mean_with_grid_size} indicates that for a fixed group size of $N=5$ agents, both $\mu$ and $\sigma$ increase monotonically with the size of the grid. This trend suggests that more agents should be deployed if the predicted time until consensus and/or the variability in this time is too high for a given environment. We illustrate the agents' consensus dynamics with two cases of the simulation runs. Figure \ref{fig:consenus_plots_matlab} plots the time evolution of the agent information states for each case. In the first case, $N =2$ agents traverse a spatial grid with dimension $c=3$. From \autoref{fig:StateTrackingConsensus2N_3X3}, we see that the time until consensus, i.e. the time at which both agents' information states converge within $\epsilon$ of the reference state $\xi^r = 1$, is approximately 160 s. We also simulate $N = 5$ agents that traverse a spatial grid with dimension $c=10$. \autoref{fig:StateTrackingConsensus5N_10X10} shows that the time until consensus has increased to about 570 s in this case, which is within one standard deviation $\sigma$ of the mean consensus time $\mu$ computed from our Monte Carlo analysis, as shown in \autoref{fig:Temporal_mean_with_grid_size} for $c=10$. \begin{figure}[h!] \begin{subfigure}{0.5\textwidth} \centering \includegraphics[trim = 0.2cm 0 0 0, width=\textwidth,height=0.6\textwidth]{Expected_consensus_time_for_different_team_size.eps} \caption{} \label{fig:Temporal_mean_with_agent_size} \end{subfigure} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[trim = 0.2cm 0 0 0, width=\textwidth,height=0.6\textwidth]{Expected_consensus_time_for_different_grid_size.eps} \caption{} \label{fig:Temporal_mean_with_grid_size} \end{subfigure} \caption{Time until consensus is reached, averaged over 1000 Monte Carlo simulations of scenarios with (a) varying numbers of agents $N$ and grid dimension $c = 5$; (b) varying $c$ and $N = 5$. The circles mark mean times $\mu$, and the error bars show standard deviations $\sigma$.} \label{fig:consensusTimeVariation} \end{figure} We also studied the effect on $\mathbb{E}[\mathcal{T}_c]$ of uncertainty in the agents' identification of the feature nodes (i.e., $\xi^r$ is a random variable), which may arise in practice due to factors such as sensor noise, occlusion of features, and inter-agent communication failures. We ran 1000 Monte Carlo simulation runs, for each of two scenarios, all with $N=5$ agents moving on a spatial grid with dimension $c = 5$ m. For each scenario, \autoref{tab:Consensus_MC_analysis2} shows the mean $\mu$ and standard deviation $\sigma$ of the time until the agents reach consensus. To investigate the effect of uncertainty in feature identification, we specified that agents either perfectly identify the feature, in which case $\xi^r = 1$, or obtain noisy measurements of the feature, for which $\xi^{r} \sim \mathrm{N}(1,0.02)$. From \autoref{tab:Consensus_MC_analysis2}, we observe that the addition of noise to the agents' measurements of the feature results in an increase in both $\mu$ and $\sigma$. However, despite information uncertainty, the agents successfully achieve consensus. \begin{table}[t] \centering \begin{tabular}{| c | c | c |} \hline Reference information & Time until consensus is reached (s) \\ state & $\mu \pm \sigma$ \\ \hline $\xi^{r} =1$ & 140 $\pm$ 35 \\ \hline $\xi^{r} \sim \mathrm{N}(1,0.02)$ & 175 $\pm$ 68 \\ \hline \end{tabular} \caption{Time until consensus is reached ($\mu \pm \sigma$), computed from 1000 Monte Carlo simulations of scenarios with $N=5$, $c=5$ and different values of $\xi^r$} \label{tab:Consensus_MC_analysis2} \end{table} \begin{figure}[t] \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth,height=0.5\textwidth]{Information_Driven_Consensus_2_Agents.eps} \caption{} \label{fig:StateTrackingConsensus2N_3X3} \end{subfigure} \begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\textwidth,height=0.5\textwidth]{Information_consensus_N_agent_10x10grid.eps} \caption{} \label{fig:StateTrackingConsensus5N_10X10} \end{subfigure} \caption{Time evolution of the agent information states $\xi_a[k]$ in simulations of (a) $N=2$ agents moving on a 3$\times$3 grid; (b) $N=5$ agents moving on a 10$\times$10 grid.} \label{fig:consenus_plots_matlab} \end{figure} \begin{figure}[t!] \centering \begin{subfigure}{0.5\textwidth} \includegraphics[height=0.5\textwidth, width=\textwidth]{Gazebo_2_ag_33_run.eps} \caption{} \label{fig:Gazebo_sim_2_AG_3x3} \end{subfigure} \begin{subfigure}{0.5\textwidth} \includegraphics[height=0.5\textwidth, width=\textwidth]{Gazebo_5_ag_55_run.eps} \caption{} \label{fig:Gazebo_sim_5_AG_5x5} \end{subfigure} \caption{Time evolution of the robot information states $\xi_a[k]$ in Gazebo simulation runs of (a) $N=2$ robots moving on a 3$\times$3 grid; (b) $N=5$ robots moving on a 5$\times$5 grid.} \label{fig:Gazebosims} \end{figure} \subsection{3D Physics Simulations} We also tested our search strategy in physics-based simulations. A snapshot of the Gazebo simulation environment is shown in \autoref{fig:gazebo_environment}. The agents are modeled as quadrotors with a plus frame configuration. We assume that the agents can accurately localize in the environment using onboard inertial and GPS sensors. The analysis of our probabilistic consensus strategy under localization uncertainty is beyond the scope of this paper. We also assume that the feature of interest is known to be present in the environment, but its location is unknown. Each quadrotor is equipped with a downward-facing RGB camera with a resolution of $1080 \times 720$. The feature of interest is modeled as a magenta box, which the agents detect from their camera images using a color-based classifier. We added zero-mean Gaussian noise with standard deviation $0.07$ to the photometric intensity in the camera sensor model. We also used a standard plumb bob distortion model to account for camera lens distortion. The quadrotors are spaced 0.5 m apart in altitude in order to prevent collisions. The altitude difference causes slight disparities in the quadrotors' field-of-view (FOV), but this does not significantly affect the performance of the search strategy. We simulated two scenarios: $N=2$ robots at altitudes $0.5$ m and $1$ m traversing a $3 \times 3$ grid, and $N=5$ robots at altitudes between $1$ m and $3$ m traversing a $5 \times 5$ grid. The video attachment (also online at \url{https://youtu.be/j74jeWQ0HM0}) shows a simulation run of the second scenario. \autoref{fig:Gazebo_sim_2_AG_3x3} and \autoref{fig:Gazebo_sim_5_AG_5x5} plot the time evolution of the agent information states over a single simulation run of each scenario. The information states sometimes display steep drops in value, as in the plots of $\xi_2$ and $\xi_4$ in \autoref{fig:Gazebo_sim_5_AG_5x5} from 50 s to 70 s. These drops can be attributed to the following factors: (1) an agent updates its information state with states communicated by its neighbors, according to the consensus protocol; (2) an agent that is at the feature node stops detecting the feature below when another agent at a lower altitude enters its field of view, occluding the feature; (3) spurious measurements like false positives may have been introduced by an agent's sensors. Despite the unmodeled effects of the second and third factors on the information states, the agents still successfully reach consensus during the Gazebo simulations. We see that the time until consensus is reached in \autoref{fig:Gazebo_sim_2_AG_3x3} and \autoref{fig:Gazebo_sim_5_AG_5x5} is about 210 s and 250 s, respectively. The delays in these times compared to the times in the Monte Carlo simulations in \autoref{fig:consensusTimeVariation} can be attributed to the second and third factors described above and to the inertia of the quadrotor, which affect the Gazebo simulations but not the Monte Carlo simulations. \section{Conclusion and Future Work}\label{sec:ConcFutre} In this paper, we have presented a probabilistic search strategy for multiple agents with local sensing and communication capabilities. The agents explore a bounded environment according to a DTDS Markov motion model and share information with neighboring agents. We proved that the agents achieve consensus almost surely on the presence of a static feature of interest in the environment. Thus, agents that do not detect the feature through direct measurement will eventually recognize its presence through information exchange with other agents. Importantly, this result does not require any assumptions on the connectivity of the agents' communication network. Thus, the search strategy is suitable for applications in which network connectivity is difficult to maintain, such as disaster scenarios. We investigated the performance of our strategy in both numerical and physics-based simulations. In future work, we will extend this probabilistic search strategy to enable the agents to localize the target(s) in the environment using distributed consensus methods. We also plan to experimentally implement our strategy on aerial robots equipped with RGB-D cameras and utilize more robust feature classifiers, such as SURF \cite{bay2008speeded}, for identification of features. We propose to use 5G WiFi modules for inter-robot communication in order to facilitate high-bandwidth data exchange.
{'timestamp': '2020-09-22T02:20:32', 'yymm': '2009', 'arxiv_id': '2009.09537', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09537'}
arxiv
\section{Introduction} Neural text generation is one of the extensively studied tasks of natural language processing (NLP), as it forms the basis for dialogue systems~\cite{chen2017survey}, machine translation~\cite{chaudhary2018machine}, and text summarization~\cite{kryscinski2019neural}. However, often monotonous or dull, texts generated from existing methods do not fully reflect the rich diversity and expression in human language~\cite{welleck2019neural}. In particular, models tend to overproduce words frequently appearing in the data, while hardly utilizing informative words \cite{dinan2020second}. Even pre-training techniques on large corpora fail to resolve the issue~\cite{holtzman2019curious}. Possible causes for text degeneration have been illuminated, such as a defect specific to model architectures~\cite{vig2018deconstructing} or the discrepancy between training data and a true distribution~\cite{holtzman2018learning, jiang2019improving}. Recently, the emphasis has been placed on investigating the flaws in the maximum likelihood objective~\cite{holtzman2019curious}. Concretely, the likelihood training pays little attention to the top ranks in terms of the target token probabilities~\cite{welleck2019neural}, or maximizing likelihood itself does not adequately reflect human language processing~\cite{holtzman2019curious}. Therefore, with the maximum likelihood-based training, models learn to produce tokens frequently appearing in the data more often. We argue, however, that the primary reason behind the sub-optimal performance of the likelihood objective is essentially the imbalanced token distribution inherent in natural language. Natural language is extremely skewed in distribution, where the top hundred most frequently-used (top-100) words occupy nearly half of the total corpus~\cite{fagan2011introduction} following the Zipf's law~\cite{zipf1949human}. Training a classifier with the inherently imbalanced data on the maximum likelihood estimation (MLE) leads to biased classification boundaries in favor of majority classes~\cite{khan2019striking}. In other words, models play a difficult role in learning with the imbalanced label (i.e., token) distribution~\cite{he2008improving}. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figure/main} \caption{Illustrations for working mechanisms of the two proposed modules, MefMax and F$^2$-Softmax. (A) Once unique tokens are sorted by frequency, MefMax (Section~\ref{sec:mme}) groups them to a set of frequency classes. The frequency distributions of the grouped tokens are more uniform than the distribution of the full vocabulary set. (B) With the frequency class assigned, token generation is decomposed into (i) predicting the frequency class, and (ii) generating the target token from the given frequency class.} \label{fig:main} \end{figure*} We hypothesize that text generation can be enriched by balancing out the training data distribution. To this end, we introduce F$^2$-Softmax (Fig.~\ref{fig:main}(B), Section~\ref{sec:f2s}), which factorizes the probability distribution of the target token into a product of two conditional probabilities of (i) frequency class, and (ii) token from the target frequency class. It ensures training over balanced data, since the frequency classes are designed to have the distribution close to uniformity, and token distributions within a class are confined to subsets of vocabularies grouped with similar frequencies. To this end, all unique tokens are assigned to a frequency class prior to the training, by our novel \textit{mean efficiency maximization} (MefMax; Fig.~\ref{fig:main}(A), Section~\ref{sec:mme}). MefMax evaluates and maximizes the class-labeling performance with the normalized entropy (i.e., efficiency), having the probability distributions to be learned as uniform as possible. We conduct extensive performance evaluations on seven relevant metrics that quantify the diversity and quality of generated texts. In terms of the diversity of generated texts, our approach significantly outperforms not only the MLE baseline~\cite{radford2019language} but also other diversity-promoting alternatives \cite{welleck2019neural,jiang2019improving}. We also achieve state-of-the-art results on most of the quality performances. \section{Related Works} \subsection{Diversity-promoting Text Generation} In the field of neural text generation, prior studies either take a training-based approach or a decoding-based approach to promote the diversity in the generated texts. \paragraph{Training-based Approach.} In dialogue generation, stimulating models to generate texts that share high mutual information with the contexts~\cite{li2016diversity} has shown to improve the diversity of output tokens by adding a maximum mutual information (MMI) constraint to the standard likelihood objective. Meanwhile, FACE~\cite{jiang2019improving} dynamically weights the cross-entropy losses based on target token frequencies, to prevent excessive weight-updates of some frequently used words. In another line of works for language modeling, text diversity has been promoted by a learning-to-cooperate framework in which multiple discriminators cooperate to reach a common goal~\cite{holtzman2018learning}. Also, the unlikelihood training strategy penalizes repetition with auxiliary loss terms \cite{welleck2019neural}. Such works are orthogonal to ours since F$^2$-Softmax focuses on decomposing the softmax function without employing an auxiliary loss or loss re-scaling. \paragraph{Decoding-based Approach.} One of the widely used decoding tactics for promoting the diversity and richness of texts is stochastic decoding. Top-\textit{k} sampling stochastically samples the next token from the top-\textit{k} candidates in the predicted probability distribution~\cite{fan2018hierarchical}. Another pillar of stochastic decoding is nucleus sampling, which selects the next token from the top-\textit{p} portion of the probability mass~\cite{holtzman2019curious}. Other studies include beam blocking~\cite{paulus2017deep} in which the probabilities of tokens are set to zero if they were to create repeating n-grams, diverse beam search~\cite{vijayakumar2018diverse} which integrates dissimilarity terms into beam scores. Iterative beam search~\cite{kulikov2019importance} enhances diverse beam search with multiple iterations of beam search with different search spaces. These techniques are agnostic about model architecture or training methods. Our approach can be harmonically combined with the above techniques. \subsection{Softmax Decomposition} Decomposing the softmax function has long been studied in language modeling. Goodman (\citeyear{goodman2001classes}) decomposed the softmax function using a two-level hierarchy. This idea was generalized to deeper hierarchies in a later study~\cite{mnih2009scalable}. Approaches to construct softmax hierarchies have followed, such as utilizing word clusters obtained from \textit{k}-means algorithms \cite{le2011structured} or implementing Huffman coding with word frequencies \cite{mikolov2013efficient}. Furthermore, dynamic programming has been applied to obtain an optimal set of word classes with minimal computational costs for calculating the softmax function~\cite{zweig2013speed}. The same process has also been streamlined to fit into modern GPU environments~\cite{grave2017efficient}. These techniques bear a resemblance to ours for the use of softmax decomposition. However, our goal is fundamentally different: we aim to balance the data distribution in training, whereas previous approaches share the primary goal of reducing computational costs. \subsection{Imbalanced Classification} That we assign tokens to classes of balanced distribution shares a similar goal with overcoming imbalanced classification in computer vision domains. One of the widely adopted techniques for imbalanced classification is re-sampling, which includes removing examples from the majority classes (under-sampling) and adding samples for the minority classes (over-sampling) \cite{buda2018systematic}. Techniques for over-sampling include interpolating samples from neighboring samples~\cite{chawla2002smote} and adaptively synthesizing samples~\cite{he2008adasyn}. Cost-sensitive learning dynamically re-weights costs based on sample difficulties~\cite{dong2017class} or effective number of samples~\cite{cui2018large}. Other studies for the data imbalance problem consider metric learning~\cite{huang2016learning}, knowledge transfer~\cite{wang2017learning}, and Bayesian estimation~\cite{khan2019striking}. \section{Methods} \subsection{Maximum Likelihood} The goal of language modeling is to learn a model $\hat{p}(\mathbf{x})$ which best describes a joint probability distribution $p(\mathbf{x})$, where $\mathbf{x} = [x_1,\ldots, x_T]$ is a sequence of tokens and $x_i \in \mathcal{V}$ is a token from a vocabulary set. In an auto-regressive manner, $p(\mathbf{x})$ can be factorized into a product of conditional probabilities of tokens; $p(\mathbf{x}) = \prod_tp(x_t|\mathbf{x_{<t}})$. A conventional approach for the training is to maximize log-likelihood of a sequence $\mathbf{x}$ as the following: \begin{equation} \mathcal{L}_{\text{MLE}}(\hat{p}, \mathbf{x}) = \sum_{t=1}^{T}\log\hat{p}(x_t|\mathbf{x}_{<t}). \end{equation} \subsection{F$^2$-Softmax} \label{sec:f2s} We propose to factorize the posterior $\hat{p}(x_t|\mathbf{x_{<t}})$ into a product of two conditional probabilities: \begin{equation} \hat{p}_(x_t|\mathbf{x}_{<t}) = \hat{p}_{1}(c_t|\mathbf{x}_{<t})\times \hat{p}_{2}(x_t|c_t,\mathbf{x}_{<t}), \label{fs} \end{equation} where $c_t \in \mathcal{C}$ denotes a frequency class label assigned to the token $x_t$ given the global frequency of the token in a corpus, belonging to a set of frequency classes $\mathcal{C}$. Following Eq. (\ref{fs}), the updated objective $\mathcal{L}_{F^2}(\hat{p})$ is then formulated as: \begin{equation} \begin{aligned} \label{f^2fs} &\mathcal{L}_{F^2}(\hat{p}, \mathbf{x})\\ &= \sum_{t=1}^{T}[\log\hat{p}_{1}(c_t|\mathbf{x}_{<t}) + \log\hat{p}_{2}(x_t|c_t,\mathbf{x}_{<t})]. \end{aligned} \end{equation} The objective is thus learning how to classify the target frequency of the token and selecting the exact token given the target frequency class. The factorized probabilities $\hat{p}_{1}(c_t|\mathbf{x}_{<t})$ and $\hat{p}_{2}(x_t|c_t,\mathbf{x}_{<t})$ are defined empirically using softmax functions: \begin{equation} \label{eq1} \begin{split} \hat{p}_{1}(c_t|\mathbf{x}_{<t}) & = \frac{\exp(\mathbf{h}_{t-1}\cdot\mathbf{u}^{c_t})}{\Sigma_{m \in \mathcal{C}}\exp(\mathbf{h}_{t-1}\cdot\mathbf{u}^{m})} \\ \hat{p}_{2}(x_t|c_t,\mathbf{x}_{<t}) & =\frac{\exp(\mathbf{h}_{t-1}\cdot\mathbf{o}^{x_t})}{\Sigma_{n \in \mathcal{V}_{c_t}}\exp(\mathbf{h}_{t-1}\cdot\mathbf{o}^{n})}, \end{split} \end{equation} where $\mathbf{h}_{t-1}$ is a hidden state of the context $\mathbf{x}_{<t}$; $\mathbf{o}^i$ and $\mathbf{u}^j$ can be viewed as output embedding vectors for $i \in \mathcal{V}_{c_t}$ and $j \in \mathcal{C}$, respectively, while $\mathcal{V}_{c_t}$ is a subset of vocabularies assigned to the class $c_t$. Note that $\hat{p}_{2}(x_t|c_t,\mathbf{x}_{<t})$ is computed from the narrowed pool of tokens $\mathcal{V}_{c_t}$ rather than the full vocabularies set $\mathcal{V}$. Since classes are differentiated based on the token frequency, tokens with the same class have similar frequencies. It ensures within-class frequency distribution of tokens is closer to uniform than that of the full vocabulary set. \subsection{MefMax for Class Optimization} \label{sec:mme} The more uniform a label distribution is, the less likely decision boundaries are biased in favor of frequent classes. Therefore, we aim to maximize the degree of uniformity of frequency distributions for both (\RNum{1}) tokens within each class and (\RNum{2}) classes themselves (i.e., the sum of token frequencies within each class), to avoid the class imbalance problem~\cite{buda2018systematic} over the course of training. It is formalized as follows: \begin{equation} \label{argmax} \mathcal{C}^{'} = \argmax_\mathcal{C} [ \mathcal{U(\mathcal{C})} + \frac{1}{\abs{\mathcal{C}}}\sum_{i \in \mathcal{C}}\mathcal{U}(\mathcal{V}_{i})] , \end{equation} where $\mathcal{U}$ is a function that measures the uniformity of the frequency distribution of a given set. While any tests of uniformity can be used as $\mathcal{U}$, we adopt \textit{Shannon's entropy}~\cite{shannon1948mathematical}. The entropy is a decent proxy for measuring the uniformity~\cite{dudewicz1981entropy}. \paragraph{Normalized Entropy.} Since the number of samples affects the entropy, entropy cannot be directly used. To marginalize the effect of the sample size, we use \textit{efficiency}, which is also known as the normalized entropy \cite{wijesekera1997shannon}, defined as: \begin{equation} \mathcal{U(\mathbf{k})} = -\sum_{k_i \in \mathbf{k}}\frac{p(k_i)\log(p(k_i))}{\log (\abs{\mathbf{k}})}. \end{equation} It is equivalent to the ratio of the entropy to the maximum entropy, if the data were perfectly uniform. By applying the efficiency to Eq. (\ref{argmax}), our objective is to find a set of classes and their vocabularies such that their \textit{mean efficiency} is maximized. \paragraph{Greedy Approach.} The remaining issue is the computational overhead since the cost for exploring all possible class boundaries grows exponentially with the vocabulary size, not to mention the challenge of finding the optimal number of classes. To improve computational efficiency, we employ a straightforward greedy mechanism. It is based on the assumption that the mean efficiency is maximized when each class has approximately the same total frequency size. This assumption allows us to reduce our objective to optimizing the number of classes. Given a sorted vocabulary set $\mathcal{V}'$ and a candidate number of classes $K$, we divide classes so that each class has the same $1/K$ of total frequency. The optimal number of classes is the one that maximizes the mean efficiency. Algorithm~\ref{algo} shows the complete pseudo-code. Computation time is linear to the vocabulary size. \begin{algorithm}[t] \small \caption{Pseudo-code for MefMax}\label{algo} \hspace*{\algorithmicindent} \textbf{Inputs :} Array $\mathcal{V}'$ of length $n$ sorted by the decreasing order of token frequency \\ \hspace*{\algorithmicindent} \textbf{Outputs :} Number of classes, class boundary tokens \begin{algorithmic}[1] \State $\mathcal{V}'$ $ \gets $ $\mathcal{V}'$ / sum($\mathcal{V}'$) \Comment{get relative frequencies} \State maxMeanEfficiency $ \gets $ 0 \State maxClassNum $ \gets 1 / \mathcal{V}'[0] $ \For{$K$ in [1, 2, ..., maxClassNum]} \State $B$ $\gets $ empty list \Comment{lists for candidate boundaries} \State tar $\gets 1/K $ \Comment{target frequency} \State cum, idx $\gets 0, 0 $ \Comment{cumulative frequency \& index} \While{tar $\leq$ 1} \Comment{compute candidate boundaries} \State cum $\gets$ cum + $\mathcal{V}'$[idx++] \If{cum $\geq$ tar} \State tar $\gets$ tar + $1/K$ \State $B$.append(idx) \EndIf \EndWhile \State meanEfficency $\gets $ mean efficiency based on $B$ \If{maxMeanEfficiency $<$ meanEfficency} \State maxMeanEfficiency $\gets$ meanEfficency \State $Out \gets B$ \EndIf \EndFor \State \Return {len($Out$), $Out$} \end{algorithmic} \end{algorithm} \subsection{Decoupled Decoding} \label{sec:DD} For the decoding stage, we decouple $\hat{p}_{1}$ from $\hat{p}$ in Eq.~(\ref{fs}) by first selecting a single frequency class from $\hat{p}_{1}$ and then generating the next token based on the selected class. For the target class $c_t=i$ sampled from the distribution $\hat{p}_1(c_t|\mathbf{x}_{<t})$, the probability for the next token is defined as: \begin{equation} \hat{p}^{'}(x_t|\mathbf{x}_{<t}) = \begin{cases} \hat{p}_{2}(x_t|c_t=i, \mathbf{x}_{<t}) & \text{if } x_t \in \mathcal{V}_i\\ 0 & \text{otherwise}. \end{cases} \label{dd} \end{equation} The target class can be sampled in both deterministic or stochastic manners, depending on decoding strategies. We found that the advantages of training balanced data distributions can be fully leveraged by sequentially performing tasks of frequency class prediction and token generation from the selected class. \section{Experiments} \subsection{Training and Evaluation Details} \label{sec:experimental_details} In this section, experimental details are illustrated. Exact hyperparameter settings and data statistics are described in Appendix. \subsubsection{Datasets} Two datasets that differ in language and text types are selected for the implementations. \\ \textbf{Wikitext-103} \footnote{\url{https://s3.amazonaws.com/research.metamind.io/wikitext/wikitext-103-v1.zip}} is a collection of English articles extracted from Wikipedia. Containing more than 100 million words, it is widely regarded as a benchmark dataset for language modeling. \\ \textbf{Melo-Lyrics} is a Korean lyrics dataset we crawled from multiple music streaming websites, including Soribada\footnote{\url{https://www.soribada.com}}, Genius\footnote{\url{https://genius.com}}, etc. Tokens in lyrics show a distribution largely different from general articles; for instance, repeated phrases are abundant in lyrics. Therefore it provides an additional unique angle for model evaluations and comparisons. It includes approximately 478 thousand songs with 51 million words in total. \subsubsection{Model Architecture} We use the Transformer \cite{vaswani2017attention}, an architecture well-suited for neural text generation \cite{lewis2019bart,welleck2019neural}. Specifically, we apply the Transformer decoder used in the GPT-2 model \cite{radford2019language}. Input texts are tokenized with the byte pair encoding \cite{sennrich2016neural}. \subsubsection{Baseline Models} For the baseline, we consider maximum likelihood estimation (MLE), a standard approach for text generation. Also compared are alternative models for promoting text diversities, including recently proposed FACE\footnote{\url{https://github.com/ShaojieJiang/FACE}} \cite{jiang2019improving} and unlikelihood training\footnote{\url{https://github.com/facebookresearch/unlikelihood_training}} (UL) \cite{welleck2019neural}. FACE improves text diversity by dynamically scaling losses, while the latter employs auxiliary losses. \subsubsection{Training} Training is carried out on a single GPU environment with 24GB of memory. We set all hyperparameters equal for all approaches by tuning them based on the validation losses of the MLE baseline for fair comparisons. We additionally optimize approach-specific hyperparameters of diversity-promoting baselines. \subsubsection{Generation} We generate texts for the evaluation by completing sequences from prefixes. Specifically, we batchify a test set, select the first 50 tokens from each batch as prefixes, and guide models to generate a continuation of 100 tokens from the prefixes. The experiments include both deterministic and stochastic decoding. We apply greedy search for deterministic decoding, and use top-\textit{k} sampling for stochastic decoding. \begin{table*}[t] \small \centering \begin{subtable}{\textwidth} \centering \begin{tabular}{l|l|l|lll|lll|lll|l|l} \toprule[0.3ex] \multirow{2}{0cm}{\diagbox[innerwidth=1.8cm]{Models}{Metrics}} & \textbf{PPL} & \textbf{KLD} & \multicolumn{3}{c|}{\textbf{MS-Jaccard}} & \multicolumn{3}{c|}{\textbf{Self-BLEU}} & \multicolumn{3}{c|}{\textbf{Distinct}} & \textbf{Rep} & \textbf{Uniq} \\ & & & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} &\multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3}&& \\ \toprule \toprule \textbf{MLE} & \bf{24.7} & 1.51 & 52.1& 35.6 & 24.3 & 93.4 & 83.2 & 69.7 & 45.1 & 71.9 & 83.0 & 0.67 & 8.48k \\ \textbf{FACE} & 29.7 & 1.26 & 53.3& 33.2 & 21.7 & 92.3 & 76.5 & 57.6 & 53.4 & 77.1 & 85.5 & 2.1 & 10.3k \\ \textbf{UL-token} & 25.8 & 1.28 & 54.3& 36.7 & 24.8 & 93.7 & 82.4 & 68.1 & 50.0 & 77.3 & 87.1 & 0.39 & 10.2k \\ \textbf{UL-token+seq} & 27.5 & 1.33 & 50.6 & 35.4 & 23.5 & \bf{95.3} & 83.4 & 66.9 & 57.6 & 86.6 & 94.2 & \bf{0.11} & 10.6k \\ \hline \rule{0pt}{2.4ex} \textbf{F$^{2}$-Softmax} & 25.6 & \bf{0.62} & \bf{67.4}& \bf{42.4} & \bf{26.4} & 93.3 & \bf{71.9} & \bf{48.1} & \bf{65.7} & \bf{89.7} & \bf{94.4} & 0.33 & \bf{15.7k} \\ \toprule Human & - & - & - & - & - & 95.2 & 74.1 & 50.9 & 69.1& 92.1 & 95.8 & 0.11 & 15.2k \\ \end{tabular} \subcaption[]{Wikitext-103} \vspace{0.3cm} \end{subtable} \begin{subtable}{\textwidth} \centering \begin{tabular}{l|l|l|lll|lll|lll|l|l} \toprule[0.3ex] \multirow{2}{0cm}{\diagbox[innerwidth=1.8cm]{Models}{Metrics}} & \textbf{PPL} & \textbf{KLD} & \multicolumn{3}{c|}{\textbf{MS-Jaccard}} & \multicolumn{3}{c|}{\textbf{Self-BLEU}} & \multicolumn{3}{c|}{\textbf{Distinct}} & \textbf{Rep} & \textbf{Uniq} \\ & & & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} &\multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3}&& \\ \toprule \textbf{MLE} & \bf{13.1} & 0.34 & 67.6&47.3 & 32.4 & \bf{97.5} & 83.1 & 62.2 & 56.3 & 75.5 & 84.0 & 1.1 & 22.4k \\ \textbf{FACE} & 13.9 & 0.39 & 60.3 & 41.5 & 28.3 & \bf{97.5} & 82.0 & 60.2 & 58.6 & \bf{78.1} & 86.5 & 0.9 & 22.7k \\ \textbf{UL-token} & 13.8 & 0.39 &62.4 & 43.6 & 29.6 & 98.2 &84.0 & 64.2 & 61.0 & 78.3 & 84.7 & 0.3 & 22.8k \\ \textbf{UL-token+seq} & 16.6 & 0.45 &58.3& 39.4 & 25.7 & 98.7 & 79.1 & 57.1 & 67.2 & 90.7 & 95.0 & 0.07 & 22.3k \\ \hline \rule{0pt}{2.4ex} \textbf{F$^{2}$-Softmax} & 13.2 & \bf{0.13} & \bf{78.8}& \bf{52.4} & \bf{34.4} &\bf{97.5} & \bf{76.1} & \bf{50.3} & \bf{64.0} & 78.7 & \bf{83.9} & \bf{2.5} & \bf{25.2k} \\ \toprule Human & - & - & - & - & - & 97.5& 76.6 & 53.2 & 62.5 & 77.5 & 82.5 & 2.1 & 27.9k \\ \end{tabular} \subcaption[]{Melo-Lyrics} \end{subtable} \caption{Quantitative comparisons of F$^{2}$-Softmax with baseline models. Top-\textit{k} sampling strategy with the \textit{k} size of 3 and 20 are used for Wikitext-103 and Melo-Lyrics, respectively, across all models. UL-token imposes a token-level penalty, and UL-token+seq considers both token- and sequence-level penalties. PPL, KLD, and Rep are abbreviated notations for perplexity, KL-Divergence, and Repetition, respectively. Numbers $n\in (1,2,3)$ in column headers under MS-Jaccard, Self-BLEU, and Distinct refer to $n$-grams. Boldface scores denote the performances closest to humans. F$^{2}$-Softmax outperforms compared baselines in most of the cases. Results on various \textit{k} sizes are reported in Appendix.} \label{main_res} \end{table*} \subsubsection{Evaluation Metrics} \label{sec:evaluation metrics} From seven total quantitative metrics we adopt to evaluate our model, Perplexity~\cite{bengio2003neural}, KL-Divergence~\cite{kullback1997information}, and MS-Jaccard~\cite{alihosseini2019jointly} are closely related to the \textit{likelihood} of generated texts. The other four metrics, namely Self-BLEU~\cite{zhu2018texygen}, Distinct-n~\cite{li2016diversity}, Repetition~\cite{holtzman2019curious}, and Uniq~\cite{welleck2019neural} measure the text \textit{diversity}. \\ \textbf{Perplexity} quantifies the prediction difficulty over the next token. It is regarded as a general performance metric for text generation. \\ \textbf{KL-Divergence} measures the difference between two probability distributions. We use unigram distributions of the generated texts and the test data. \\ \textbf{MS-Jaccard} computes the similarity between the model's output and the ground truths by matching \textit{n}-grams. \\ \textbf{Self-BLEU} evaluates the inter-text diversity by computing BLEU \cite{papineni2002bleu} score for each generated text by regarding other outputs as reference. \\ \textbf{Distinct-\textit{n}} quantifies the intra-text diversity based on distinct \textit{n}-grams in each text. \\ \textbf{Repetition} examines whether texts are stuck in repetitive loops. \\ \textbf{Uniq} quantifies the richness of models using the number of unique generated tokens. \subsection{Quantitative Comparisons} \label{sec:quantitative_comparisons} In this section, we report the scores computed from fully-trained models on the two benchmarks, Wikitext-103 and Melo-Lyrics, compared against baselines. Table~\ref{main_res} shows the results of stochastic decoding, while the results of deterministic decoding are reported in Table \ref{app:greedy_table}. \subsubsection{Stochastic Decoding} \paragraph{Wikitext-103.} The desired qualities we aim for a text generation model is to generate human-like texts with a wide spectrum of token choices. Coupled with top-\textit{k} sampling, our F$^{2}$-Softmax achieves both goals by outperforming baselines with nearly all metrics compared, and closely approaching the human gold standard. As shown in Table~\ref{main_res}(a), our model is particularly effective in capturing the token diversity in the corpus. Notably, F$^{2}$-Softmax significantly improves both Self-BLEU and Distinct performances, having relative gaps to the human gold standard of 3.4\% and 3\%, respectively. The performance gaps of the second-best scores are 6.5\% (FACE) and 8.1\% (UL-token+seq), respectively. A surprising result is that F$^{2}$-Softmax improves Rep performance by 50\% over MLE, without an explicit penalty on repeating tokens. Another seminal contribution is the 30\% relative increase in unique tokens used for the generation, from the previously state-of-the-art level of 10.6k to 15.7k, as shown by the Uniq metric. This level closely reflects the human use of 15.2k tokens. In PPL, which reflects the likelihood of the generated texts, the diversity-promoting baselines tend to perform worse than MLE, presumably due to the trade-offs between the diversity and the likelihood of texts. In contrast, F$^{2}$-Softmax maintains the smallest performance drop on PPL. F$^{2}$-Softmax also improves KLD and MS-Jaccard by 59\% and 19\% over MLE, respectively, which are large margins compared to the other comparatives. \paragraph{Melo-Lyrics.} Significant performance gains of F$^{2}$-Softmax are also observed in lyrics generation in Table~\ref{main_res}(b). The diversity-promoting baselines display severer degradation in PPL, KLD, and MS-Jaccard compared to the Wikitext-103 dataset. Especially, their repetition levels are significantly different from that of the ground truth data. We attribute this observation to the distinctive characteristics of lyrics, in which the same phrases are rhythmically repeated throughout the songs in the form of chorus or hook. Thus, for lyrics dataset, forcing models to discourage reusing previously used tokens may adversely affect the likelihood of the generated texts. Since F$^{2}$-Softmax helps models to diversify the output without an explicit regularization, models learn to generate well-thought-out tokens from the diversified token pool of 25.2k (Uniq), with state-of-the-art performances in KLD, MS-Jaccard, Self-BLEU, Distinct, and Rep. \begin{table*}[ht] \small \centering \label{app:stoc} \begin{subtable}{\textwidth} \centering \begin{tabular}{l|l|l|lll|lll|lll|l|l} \toprule[0.3ex] \multirow{2}{0cm}{\diagbox[innerwidth=1.8cm]{Models}{Metrics}} & \textbf{PPL} & \textbf{KLD} & \multicolumn{3}{c|}{\textbf{MS-Jaccard}} & \multicolumn{3}{c|}{\textbf{Self-BLEU}} & \multicolumn{3}{c|}{\textbf{Distinct}} & \textbf{Rep} & \textbf{Uniq} \\ & & & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} &\multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3}&& \\ \toprule \toprule \textbf{MLE} & \bf{24.7} & 2.17 & 45.6& 29.9 & 20.5 & 92.8& 83.6 & 73.2 & 31.4 & 48.8 & 57.8 & 18.3 & 6.23k \\ \textbf{FACE} & 29.7 & 1.67 & 47.9 & 29.9 & 19.8 & 89.6& \bf{73.6} & \bf{57.3} & 38.4& 54.3 & 62.0 & 21.0 & 8.03k \\ \textbf{UL-token} & 25.8 & 1.88 & 47.2 &30.7 & 20.9 & 92.9& 83.7 & 73.3 & 37.1& 56.3& 65.6 & 12.8 & 7.66k \\ \textbf{UL-token+seq} & 27.5 & 2.06 & 41.5& 26.9 & 18.4 & \bf{95.6} & 86.6 & 74.2 & \bf{49.9}& \bf{78.1} & \bf{89.8} & \bf{0.3} & 8.33k \\ \hline \textbf{F$^{2}$-Softmax} & 25.6 & \bf{1.63} & \bf{49.0}& \bf{31.2} & \bf{21.0} & 90.2 & 78.7 & 66.3 & 36.3 &54.6 & 63.8 & 12.5 & \bf{9.08k} \\ \toprule Human & - & - & - & - & - & 95.2 & 74.1 & 50.9 & 69.1& 92.1 & 95.8 & 0.11 & 15.2k \\ \end{tabular} \subcaption[]{Wikitext-103} \vspace{0.3cm} \end{subtable} \begin{subtable}{\textwidth} \centering \begin{tabular}{l|l|l|lll|lll|lll|l|l} \toprule[0.3ex] \multirow{2}{0cm}{\diagbox[innerwidth=1.8cm]{Models}{Metrics}} & \textbf{PPL} & \textbf{KLD} & \multicolumn{3}{c|}{\textbf{MS-Jaccard}} & \multicolumn{3}{c|}{\textbf{Self-BLEU}} & \multicolumn{3}{c|}{\textbf{Distinct}} & \textbf{Rep} & \textbf{Uniq} \\ & & & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} & \multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3} &\multicolumn{1}{c}{$n$=1} & \multicolumn{1}{c}{$n$=2} &\multicolumn{1}{c|}{$n$=3}&& \\ \toprule \textbf{MLE} & \bf{13.1} & 0.46 & 64.5 & 44.2 & 31.6 & 91.4& 71.8 & 51.5 & 22.0& 26.7 & 28.5 & 67.7 & 20.4k \\ \textbf{FACE} & 13.9 & 0.51 & 57.7& 39.6 & 22.8 & 92.3 & 72.5 & 55.6 &25.3 & 32.0 & 36.1 & 39.1 & \bf{21.7k} \\ \textbf{UL-token} & 13.8 & 0.51 & 62.8 & 42.7 & 30.7 & 92.3 & \bf{73.0} & \bf{53.5} & 21.8 & 26.4 & 28.5 & 66.6 & 20k \\ \textbf{UL-token+seq} & 16.6 & 0.74 &50.6 & 34.1 & 23.9 & \bf{95.7}& 78.7 & 56.3 & \bf{29.6} & \bf{52.2} & \bf{57.1} & \bf{25.1} & 19.9k \\ \hline \textbf{F$^{2}$-Softmax} & 13.2 & \bf{0.38} & \bf{67.4} & \bf{45.1} & \bf{31.7} & 90.4 & 66.6 & 43.1 & 21.5& 26.0 & 28.0& 66.9 & 21.3k \\ \toprule Human & - & - & - & - & - & 97.5& 76.6 & 53.2 & 62.5 & 77.5 & 82.5 & 2.1 & 27.9k \\ \end{tabular} \subcaption[]{Melo-Lyrics} \end{subtable} \caption{Evaluation results on the greedy sampling. The abbreviations are the same as Table \ref{main_res}.} \label{app:greedy_table} \end{table*} \subsubsection{Deterministic Decoding} In deterministic decoding, there is no clear method that outperforms the others in all of the metrics. For example, UL-token+seq exhibits the best performance in Distinct and Rep, while presenting the worst score in MS-Jaccard. Similarly, FACE improves Self-BLEU in exchange for performance loss on PPL and MS-Jaccard. Since we have seven metrics to compare, we conduct pair-wise evaluations between the compared methods, in which a method outperforms the other when a majority of metrics record higher. Our approach beats compared methods seven out of eight times (Table \ref{app:comp}). This result supports the supremacy of our approach regardless of the choice of decoding strategies. However, deterministic decoding does not see the same amount of benefits obtained from stochastic decoding. We empirically find from our analyses that argmax operation in deterministic settings may harm the diversity when target class probabilities are nearly evenly distributed. We plan to delve deeper into our approach to improve our approach further. \begin{figure}[t] \includegraphics[width=.95\linewidth]{figure/wd.png} \caption{Frequency distribution comparisons on the Wikitext-103 test set. Tokens in each group are defined based on the frequency mass of the training set. Tokens occupying the top 40\% of the frequency mass are assigned to \textit{frequent}, while those corresponding to the bottom 10\% are classified to \textit{very rare}.} \label{fig:token distribution} \end{figure} \begin{figure*}[t] \includegraphics[width=0.95\textwidth]{figure/tot.png} \caption{Bigram performance on the Melo-lyrics test set with different numbers of classes. Green and brown lines indicate models with tokens are distributed based on frequency mass and token size, respectively. Blue dotted lines and star marks represent the MLE baseline and the choice of MefMax, respectively.} \label{abl-MefMax} \end{figure*} \subsection{Learning Balanced Distribution} \label{sec:Learning_Balanced_Distribution} The characteristic markers of monotonous texts are an overproduction of frequently used tokens and under-representation of rare tokens. To compare how models differentially generate tokens from frequent and rare tokens, we count the number of generated tokens corresponding to four defined categories of \textit{frequent}, \textit{medium}, \textit{rare} and \textit{very rare}. Tokens in each category are predefined from the Wikitext-103 training set. Fig.~\ref{fig:token distribution} plots the distribution results. MLE produces \textit{frequent} tokens 34\% more than human, while under-producing \textit{rare} and \textit{very rare} tokens by 40\%. The unlikelihood training baselines (UL-token, UL-token+seq) improve the diversity against MLE, but their results are relatively far from the real distribution. FACE manages to regulate a disproportionate use of \textit{frequent} tokens, but it fails to generate adequate amount of \textit{very rare} tokens. Generation results of our F$^{2}$-Softmax are closest to the gold standard, with the differences in \textit{frequent} and \textit{rare} tokens falling within 6\%. \subsection{Ablation Studies} \label{sec:Ablation} In this section, we justify the pivotal roles of MefMax (Section~\ref{sec:mme}) and the decoupled decoding strategy (Section~\ref{sec:DD}). In order to assess contributions toward the final performances, we conduct a series of ablation tests. Stochastic decoding is used for the ablation studies. \subsubsection{Ablation on MefMax} MefMax finds a desirable number of classes, intending to balance the frequency distribution of tokens between classes. Does MefMax help achieve better generation results than possible variants of class assignment? We answer this question by comparing the final performances against two simpler variants of MefMax. We name the first variant as \textit{fixed-eq-token} in which tokens are distributed in \textit{equal} numbers to a \textit{fixed} number of classes. The second variant, \textit{fixed-eq-freq}, also assumes a fixed number of classes, but tokens are assigned to minimize the difference in the frequency distribution between classes. Fig.~\ref{abl-MefMax} presents the results. Clearly, \textit{fixed-eq-freq} outperforms \textit{fixed-eq-token}. It indicates that a decomposition of the softmax function without consideration of the data distribution (i.e., frequency distribution) aggravates both the likelihood and token diversity performances, regardless of the number of classes. For \textit{fixed-eq-token}, we find that models tend to overclassify the target class to the first class, which contains most of the total frequency, having most tokens generated from a fraction of the total vocabulary. This finding also justifies the hypothesis that balanced data distribution is an important factor in text generation. Assigning classes based on the frequency (i.e., \textit{fixed-eq-freq}) continues to improve MS-Jaccard and Self-BLEU until the number of classes reaches the class choice of MefMax. With a larger number of classes than the choice, performances either plateau or decrease, demonstrating that MefMax is capable of selecting the optimal class size. Interestingly, perplexity significantly deteriorates when the number of classes exceeds the optimal number decided by MefMax. \begin{table}[t] \small \begin{tabular}{lccccc} \toprule Model & \begin{tabular}[c]{@{}c@{}}\footnotesize{Decoupled}\\ \footnotesize{Decoding} \end{tabular} &KLD & MSJ & SB & Uniq \\ \hline \rule{0pt}{2.4ex} \multirow{2}{0cm}{\textbf{F$^{2}$-Softmax}}\hspace{3em} & O &0.13 & 52.4 & 76.1 & 25.2k \\ & $\times$&0.31 & 47.4 & 81.9 & 22.6k \\ \hline \rule{0pt}{2.4ex} \textbf{MLE} & $\times$ & 0.34 & 47.3 & 83.1 & 22.4k \\ \bottomrule \end{tabular} \caption{Ablation study on the decoupled decoding. MSJ and SB stand for MS-Jaccard and Self-BLEU, respectively. Scores are measured on bigram level.} \label{wodd} \end{table} \subsubsection{Ablation on Decoupled Decoding} Decoupled decoding formalized in Eq. (\ref{dd}) fully leverages the benefits of F$^2$-Softmax by sequentially performing the frequency class prediction and token generation tasks. Table \ref{wodd} reports the results from an ablation test on the decoupled decoding. To ablate the decoupled decoding, we use a full posterior in Eq. (\ref{fs}). We observe significant performance gaps, meaning that the decoupled decoding is an indispensable component of our model. Notably, even without the decoupled decoding, our model maintains better performances than the MLE baseline. \begin{table*}[t] \small \begin{tabularx}{\textwidth}{l X c} \toprule[0.3ex] \textbf{Model} & \textbf{Texts} & \textbf{VR} (\%) \\ \toprule[0.15ex] Prefix & = Robert Boulter = Robert Boulter is an English film, television and theatre actor. He had a guest-starring role on the television series The Bill in 2000. This was followed by a starring role in the play Herons written & \\ \hline\hline \textbf{MLE} & for the television series The Bill in 2001. \textbf{\textcolor{green}{Boul}}ter was cast in the role of Robert \textbf{\textcolor{green}{Boul}}ter on the television series The Bill in 2002. The character was first cast in the role of Robert \textbf{\textcolor{green}{Boul}}ter in the 2003 film The Bill in a series of short stories about the life of a man. = = Personal life = = \textbf{\textcolor{green}{Boul}}ter is a \textbf{\textcolor{cadmiumred}{vegetarian}} & 6.7 \\ \hline \textbf{FACE} & by John \textbf{\textcolor{cadmiumyellow}{Landis}} in 2001 . His role in the play was also played by John Lloyd , who played a fictional character in The Bill . \textbf{\textcolor{green}{Boul}}ter played a leading role in The Bill in 2002 and played a leading role in The Bill in 2004 . In 2006 he starred as a supporting actor in The Bill , a film adaptation of John Wayne 's play The \textbf{\textcolor{fuchsiapink}{Nut}}ty Professor in which & 4 \\ \hline \multirow{2}{0cm}{\textbf{UL-token}} & in 2002 by the BBC. \textbf{\textcolor{green}{Boul}}ter was cast by the BBC, playing a young Englishmen in a \textbf{\textcolor{cadmiumred}{pub}} in the fictional town of Bristol. He appeared in the 2006 BBC drama series, The Bill, in which he was cast as the lead character. He played the role of Peter \textbf{\textcolor{blue}{Gabriel}}, an Englishman who is portrayed in a television serial killer. \textbf{\textcolor{green}{Boul}}ter is & 5.3 \\ \hline \multirow{2}{0cm}{\textbf{UL-token+seq}} & and directed by David Lloyd. \textbf{\textcolor{green}{Wins}}let was a director for \textbf{\textcolor{green}{Wins}}let 's comedy-drama, The New \textbf{\textcolor{cadmiumyellow}{Yorker}}. He starred in several of his films, and was also the first actor to appear in multiple films. He played the role in the film 's second part in the 2002 \textbf{\textcolor{blue}{HBO}} series The \textbf{\textcolor{fuchsiapink}{Adventures}} of Bob \textbf{\textcolor{purple}{Marley}} (which premiered in 2001) and was written by David & 8 \\ \hline \textbf{F$^{2}$-Softmax} & by Philip \textbf{\textcolor{cadmiumyellow}{Glass}} in 2003. He co-starred as the male fictionalised father with a woman named Anne \textbf{\textcolor{blue}{Hutchinson}}, an \textbf{\textcolor{cadmiumred}{eccentric}} lawyer who discovers that his family had \textbf{\textcolor{cadmiumred}{vanished}} in the previous film. \textbf{\textcolor{green}{Boul}}ter's performance in A Day in Yellow \textbf{\textcolor{fuchsiapink}{Cell}} is considered a turning point in his career. He received an Academy Award nomination for Best Actor in 2004. \textbf{\textcolor{green}{Boul}}ter appeared in several films & \textbf{9.3} \\ \toprule[0.15ex] \end{tabularx} \caption{Generated texts on the Wikitext-103 test set. A prefix from the first batch was selected to avoid cherry-picking. \textbf{VR} denotes the ratio of \textit{very rare} tokens (see Section~\ref{sec:Learning_Balanced_Distribution} for the definition) against the text length. While all colored and bold-faced tokens indicate \textit{very rare} tokens, \textbf{\textcolor{green}{green}} color denotes repeated tokens, and \textbf{\textcolor{cadmiumred}{red}} color is reserved for non-pronoun words.} \label{generated} \end{table*} \subsection{Qualitative Comparisons} \label{sec:Qualitative_Comparisons} To further examine the generation quality, we sample texts from the trained models. Table \ref{generated} compares the generated texts from the same prefix. The results suggest that all trained models are capable of generating texts semantically coherent to the prefix. However, they differ in rare token usage patterns. While our F$^{2}$-Softmax exhibits the highest usage of rare tokens, we observe two issues from the baselines. The first is that models tend to repeat the same rare token across all sentences after its first appearance (MLE). The other issue is that generated rare tokens are mostly pronouns (UL-token-seq). Unlike the baselines, F$^{2}$-Softmax utilizes the broadest range of rare tokens with significantly less, but more likely, repetitions. Further, F$^{2}$-Softmax is shown to be adept at utilizing non-pronoun rare tokens, such as `eccentric' or `vanished'. \section{Conclusion} In this paper, we proposed F$^{2}$-Softmax, a simple but effective method for better learning the rich diversity in text. F$^{2}$-Softmax encourages models to diversify text generation by readjusting class formation and motivating models to learn a more balanced token distribution. Quantitative and qualitative analyses validate the diversity-promoting performances of our approach. Since it can be quickly adopted to replace the traditional likelihood objective, we believe in broader applicability of F$^{2}$-Softmax. Thus, future work involves extending the method to other related tasks, such as machine translation and text summarization, and investigating the potential gains from transfer learning. \section*{Acknowledgments} This work was supported by Institute of Information \& Communications Technology Planning \& Evaluation (IITP) grant funded by the Korea government (MSIT) (No. 2020-0-01371, Development of brain-inspired AI with human-like intelligence)
{'timestamp': '2020-10-06T02:19:13', 'yymm': '2009', 'arxiv_id': '2009.09417', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09417'}
arxiv
\section{Introduction} \label{sec:intro} \vspace{-0.10in} \emph{Document analytics} refers to data analytics tasks that derive statistics, patterns, insights or knowledge from textual documents (e.g., system log files, emails, corpus). It is important for many applications, from web search to system diagnosis, security, and so on. Document analytics applications are time-consuming, especially as the data they process keep growing rapidly. At the same time, they often need a large amount of space, both in storage and memory. A common approach to mitigating the space concern is data compression. Although it often reduces the storage usage by several factors, compression does \emph{not} alleviate, but actually worsens, the time concern. In current document analytics frameworks, compressed documents have to be decompressed before being processed. The decompression step lengthens the end-to-end processing time. This work investigates the feasibility of efficient data analytics on compressed data \emph{without} decompressing it. Its motivation is two-fold. First, it could avoid the decompression time. Second, more importantly, it could save some processing. Space savings by compression fundamentally stems from repetitions in the data. If the analytics algorithms could leverage the repetitions that the compression algorithm already uncovers, it could avoid unnecessary repeated processing, and hence shorten the processing time significantly. Compression takes time. But many datasets (e.g., government document archives, electronic book collections, historical Wikipedia datasets \cite{wikipedia}) are used for various analytics tasks by many users repeatedly. For them, the compression time is well justified by the repeated usage of the compression results. \cred{ This article presents Text Analytics Directly on Compression (TADOC), which enables direct document analytics on compressed textual data. } We base TADOC on a specific compression algorithm named {\em Sequitur}~\cite{nevill1997identifying} for the hierarchical structure of its compression results (Section~\ref{sec:premise}). We introduce the concept of {\em compression-based direct processing}, and analyze its challenges (Section~\ref{sec:challenges}). Through studies on a set of core algorithms used in document analytics, we discover a set of solutions and insights on tackling those challenges. These insights range from algorithm designs to data structure selections, scalable implementations, and adaptations to various problems and datasets. We draw on several common document analytics problems to explain our insights, and provide the first set of essential guidelines and techniques for effective compression-based document analytics (Section~\ref{sec:solutions}). Our work yields an immediately-usable artifact, the \\ \texttt{CompressDirect} library, which offers a set of modules to ease the application of our guidelines. Our library provides implementations of six algorithms frequently used in document analytics, in sequential, parallel, and distributed versions, which can be directly plugged into existing applications to generate immediate benefits. \cred{ We further discuss how TADOC and its associated CompressDirect library can be effectively applied to real-world data analytics applications. We demonstrate the process on four applications, {\em word co-occurrence}~\cite{matsuo2004keyword,pennington2014glove}, \ {\em term frequency-inverse document frequency}~\cite{joachims1996probabilistic}, {\em word2vec}~\cite{rong2014word2vec,googleWord2Vec}, and {\em latent Dirichlet allocation} (LDA) \cite{blei2003latent}. Our evaluation validates the efficacy of our proposed techniques in saving both space and time on six analytics kernels. For six common analytics kernels, compared to their default implementation on uncompressed datasets, TADOC reduces storage usage by \reduceRatioAVG{} and memory usage by \memSavingAVG{}, and at the same time, speeds up the analytics by \singleAVG{} for sequential runs, and by \distriAVG{} for Spark-based distributed runs. On four real-world applications, TADOC reduces storage usage by 92.4\% and memory usage by 26.1\%, and yields 1.2X speedup over the original applications, on average. } A prior work, Succinct~\cite{agarwal2015succinct}, offers a way to enable efficient queries on compressed data. This work complements it by making complex document analytics on compressed data efficiently. Data deduplication~\cite{monge1996field} saves storage space, but does \emph{not} save repeated processing of the data. \cg{ Our preliminary work has been presented in~\cite{zhang2018efficient}. } Overall, this work makes the following contributions: \begin{itemize}[noitemsep,nolistsep] \item \cred{It presents an effective method for enabling high performance complex document analytics directly on compressed data, and realizes the method on the {\em Sequitur} compression algorithm. } \item It unveils the challenges of performing {\em compression-based document analytics} and offers a set of solutions, insights, and guidelines. \item It validates the efficacy of the proposed techniques, demonstrates their significant benefits in both space and time savings, and offers a library for supporting common operations in document analytics. \item \cred{ It demonstrates that TADOC can be effectively applied to real-world document analytics applications, bringing 92.4\% storage space savings and 1.2X performance improvement. } \end{itemize} \iffalse The remainder of this paper is organized as follows. Section~\ref{sec:premise} reviews compression algorithms and typical document analytics. Section~\ref{sec:challenges} describes the compression-based direct processing and challenges. Section~\ref{sec:solutions} provides the guidelines and techniques in details. Section~\ref{sec:library} shows the implementation. Section~\ref{sec:advanced} discusses how to support the advanced document analytics. Section~\ref{sec:evaluation} shows the evaluation results. Section~\ref{sec:related} discusses related work. Section~\ref{sec:conclusion} gives the conclusion. \fi \section{Premises and Background} \label{sec:premise} \vspace{-0.12in} \cred{ Operating directly on grammar-compressed data is an active research area in recent years~\cite{navarro2016compact,sadakane2007succinct}, which will be discussed in Section~\ref{sec:related}. In this section, we present the premises and background of Sequitur compression algorithm and typical document analytics. } \vspace{-0.10in} \vspace{-0.15in} \subsection{Sequitur Algorithm} \label{subsec:sequitur} \vspace{-0.15in} There are many compression algorithms for documents, such as LZ77~\cite{ziv1977universal}, suffix array~\cite{navarro2016compact}, and their variants. Our study focuses on Sequitur~\cite{nevill1997identifying} since its compression results are a natural fit for direct processing. Sequitur is a recursive algorithm that infers a hierarchical structure from a sequence of discrete symbols. For a given sequence of symbols, it derives a context-free grammar (CFG), with each rule in the CFG reducing a repeatedly appearing string into a single rule ID. By replacing the original string with the rule ID in the CFG, Sequitur makes it output CFG more compact than the original dataset. Figure~\ref{fig:SequiturExample} illustrates Sequitur compression results. Figure~\ref{fig:SequiturExample} (a) shows the original input, and Figure~\ref{fig:SequiturExample} (b) shows the output of Sequitur in a CFG form. The CFG uncovers both the repetitions in the input string and the hierarchical structure. It uses R0 to represent the entire string, which consists of substrings represented by R1 and R2. The two instances of R1 in R0 reflect the repetition of ``a b c a b d'' in the input string, while the two instances of R2 in R1 reflect the repetition of ``a b'' in the substring of R1. The output of Sequitur is often visualized with a directed acyclic graph (DAG), as Figure~\ref{fig:SequiturExample} (c) shows. The edges indicate the hierarchical relations among the rules. \begin{figure} \center \includegraphics[width=1\linewidth]{figures/sequitur/sequitur7.pdf} \vspace{-0.24in} \caption{A compression example with Sequitur.} \label{fig:SequiturExample} \vspace{0.01in} \vspace{0.01in} \vspace{-0.1in} \vspace{-2.0mm} \vspace{-2.0mm} \end{figure} Dictionary encoding is often used to represent each word with a unique non-negative integer. A dictionary stores the mapping between integers and words. We represent each rule ID with a unique integer greater than $N$, where $N$ is the total number of unique words contained in the dataset. Figure~\ref{fig:SequiturExample} (d) gives the numerical representations of the words and rules in Figure~\ref{fig:SequiturExample} (a,b), while Figure~\ref{fig:SequiturExample} (e) shows the CFG in numerical form. Sequitur provides compression ratios similar to those of other popular algorithms (e.g., Gzip)~\cite{nevill1996inferring}. Its compression process is relatively slow, but our technique is designed for datasets that are \emph{repeatedly} used by many users. For them, compression time is \emph{not} a main concern as the compression results can be used many times by different users for various tasks. Such datasets are common, ranging from book collections to historical Wikipedia pages~\cite{wikipedia}, government document archives, archived collections (e.g., of a law firm), historical news collections, and so on. Sequitur has several properties that make it appealing for our use. First, the CFG structure in its results makes it easy to find repetitions in input strings. Second, its output consists of the direct (sequences of) input symbols rather than other indirect coding of the input (e.g., \emph{distance} used in LZ77~\cite{ziv1977universal} and suffix array~\cite{navarro2016compact}). These properties make Sequitur a good fit for materializing the idea of compression-based direct processing. \subsection{Typical Document Analytics} \label{sec:example} \vspace{-0.01in} \vspace{-0.10in} Before presenting the proposed technique, we first describe three commonly-performed document analytics tasks. They each feature different challenges that are typical to many document analytics, offering examples we use in later sections for discussion. \noindent{\bf{Word Count}}\hspace{.1in} \textit{Word count}~\cite{blumenstock2008size,pennebaker2001linguistic,ahmad2012puma} is a basic algorithm in document analytics, which is widely used in applications like document classification, clustering, and theme identification. It counts the total appearances of every word in a given dataset, which may consist of a number of files. \begin{itemize}[noitemsep,nolistsep] \item Input: \{file1, file2, file3, file4, file5, ...\} \item Output: <word1, count1>, <word2, count2>, ... \end{itemize} \noindent{\bf{Inverted Index}}\hspace{.1in} \textit{Inverted index}~\cite{ahmad2012puma} builds word-to-file index for a document dataset. It is worth noting that in some implementations of \textit{inverted index}, some extra operations are involved (e.g., getting and storing the term frequency) during the construction of the word-to-file index~\cite{zobel2006inverted}. The implementation in our study is pure in computing only word-to-file index as the purpose is to demonstrate how TADOC can be used for various tasks. (We have a separate benchmark, \emph{term vector}, for computing term frequencies.) \iffalse \cred{ \noindent{\bf{Inverted Index}}\hspace{.1in} \textit{Inverted index}~\cite{ahmad2012puma} builds the word-to-file index for a document dataset. Please note that in real application scenarios~\cite{zobel2006inverted}, \textit{inverted index} could involve more information such as the word frequency. Because in this paper, \textit{inverted index} is only a demonstration case for using the TADOC technique, we only use its simplest form. The input of \textit{inverted index} is a set of files, and the output is the mappings between the words and the files. Unlike \textit{word count}, \textit{inverted index} distinguishes between files on its output. } \fi \iffalse \noindent{\bf{Inverted Index}}\hspace{.1in} \textit{Inverted index}~\cite{zobel2006inverted,ahmad2012puma,cutting1989optimization,yan2009inverted} builds a word-to-file index for a document dataset. It is widely used in search engines. The input of \textit{inverted index} is a set of files, and the output is the mappings between words and files. Unlike \textit{word count}, \textit{inverted index} distinguishes between files on its output. \fi \begin{itemize}[noitemsep,nolistsep] \item Input: \{file1, file2, file3, file4, file5, ...\} \item Output: <word1, <file1>{}>, <word2, <file13>{}>, ... \end{itemize} \noindent{\bf{Sequence Count}}\hspace{.1in} \textit{Sequence count}~\cite{ahmad2012puma,zernik1991lexical,lebart1998classification} counts the number of appearances of every $l$-word sequence in each file, where $l$ is an integer greater than 1. In this work, we use $l$=3 as an example. \textit{Sequence count} is very useful in semantic, expression, and sequence analysis. Compared to \textit{word count} and \textit{inverted index}, \textit{sequence count} not only distinguishes between different files, but also discerns the order of consecutive words, which poses more challenges for processing (Section~\ref{sec:challenges}). \begin{itemize}[noitemsep,nolistsep] \item Input: \{file1, file2, file3, file4, file5, ...\} \item Output: <word1\_word2\_word3, file1, count1>, ... \end{itemize} \section{TADOC and its Challenges} \label{sec:challenges} \vspace{-0.10in} In this section, we present the concept of TADOC, including its basic algorithms and the challenges for materializing it effectively. \vspace{-0.20in} \subsection{TADOC} \label{sec:idea} \vspace{-0.10in} \cred{ TADOC is a technique that supports various text analytics tasks directly on compressed data without decompression. The compression is not task-specific. For example, we compress text files using TADOC, and the compressed data can be used directly to support text analytics tasks such as \emph{word count} and \emph{inverted index}. The basic concept of compression-based document analytics is to leverage the compression results for \emph{direct processing} while avoiding unnecessary repeated processing of repeated content in the original data. } \iffalse The basic concept of compression-based document analytics is to leverage the compression results for \emph{direct processing}, while avoiding unnecessary repeated processing of repeated content in the original data. \fi The results from Sequitur make this basic idea easy to materialize. Consider a task for counting word frequencies in input documents. We can do it directly on the DAG from Sequitur using a postorder (children before parents) traversal, as Figure~\ref{fig:wcExample} shows. After the DAG is loaded into memory, the traversal starts. At each node, it counts the frequency of each word that the node directly contains and calculates the frequencies of other words it indirectly contains---in its children nodes. For instance, when node R1 in Figure~\ref{fig:wcExample} is processed, direct appearances of ``c'' and ``d'' on its right-hand-side (\textit{rhs}) are counted, while, the frequencies of words ``a'' and ``b'' are calculated by multiplying their frequencies in R2 by two---the number of times R2 appears on its \textit{rhs}. When the traversal reaches the root R0, the algorithm produces the final answer. \begin{figure}[!h] \centering \includegraphics[width=1\linewidth]{figures/sequitur/concept_postorder2.pdf} \caption{A DAG from Sequitur for ``a b c a b d a b c a b d a b a'', and a postorder traversal of the DAG for counting word frequencies.}\label{fig:wcExample} \vspace{-0.20in} \end{figure} Because the processing leverages the compression results, it naturally avoids repeated processing of repeated content. The repeated content needs to be counted only once. For instance, even though the substring ``a b'' (R2) appears five times in the original string, the processing only counts its frequency once. It is counted when the algorithm processes R2; the results are reused for the two appearances of R2 when R1 is processed; similarly, R1's results (and also R2's) are reused when R0 is processed. \cred{ The procedure of postorder traversal for word counting is described in Algorithm~\ref{wordCountAlt1}, \texttt{wordcount-V1}. The algorithm associates with each rule a local table {\it locTbl}. During the data loading time (line \ref{wordCountAlt1:line:load} in Algorithm~\ref{wordCountAlt1}), when reading in each rule in the CFG, the algorithm records in the {\it locTbl} of that rule the frequency of each rule and each word appearing on the right-hand side of that rule. } \vspace{-0.20in} \begin{algorithm}[!h] \caption{\texttt{wordcount-V1}} \label{wordCountAlt1} \begin{algorithmic}[1] \algrenewcommand\textproc{} \State init()\Comment{nullify elements of Boolean array $done$} \State G=LoadMergeGraph(I)\Comment{Load compressed dataset $I$, build the graph with edges between two nodes merged into one; each node has a local table $locTbl$, initialized with the numbers of each subrule and each word's appearances on the right-hand side of the rule represented by that node.} {\label{wordCountAlt1:line:load}} \State countWords(G.root) \Procedure{countWords}{$id$}\Comment{$id$: a rule ID} \For{\texttt{each subRule $i$ in rule $id$}} \If {$!done[i]$} \State countWords\texttt{($i$)} \EndIf \EndFor \For{\texttt{each subRule $i$ in rule $id$}} \State $n$=$rule[id].locTbl[i]$\Comment freq of $i$ in rule $id$ \For{\texttt{each word $w$ in the $locTbl$ of rule $i$}} \State {\texttt{$rule[id].locTbl[w]$ += $n*rule[i].locTbl[w]$}}\Comment{fold the counts into the parent node} \EndFor \EndFor \State {$done[id] = true$} \EndProcedure \end{algorithmic} \end{algorithm} \vspace{-0.20in} \cred{ To analyze the complexity of Algorithm~\ref{wordCountAlt1}, we first define four concepts in the DAG. } \cred{ \emph{Reachable}: In the DAG, if a path exists from node $r_i$ to node $r_j$, then we say node $r_j$ is reachable from $r_i$. } \cred{ \emph{Reachable node set}: In the DAG, all the reachable nodes from node $r_i$ form a reachable node set of $r_i$. } \cred{ \emph{Reachable edge set}: In the DAG, the out edges of all the nodes in node $r_i$'s reachable node set form the reachable edge set of node $r_i$. } \cred{ \emph{Reverse reachable node set}: After all the edges in the DAG are reversed, all the reachable nodes from node $r_i$ form a reverse reachable node set of node $r_i$. } \cred{ \emph{Reverse reachable edge set}: After all the edges in the DAG are reversed, the out edges of all the nodes in node $r_i$'s reachable node set form the reachable edge set of node $r_i$. } \cred{ The time complexity of Algorithm~\ref{wordCountAlt1} is dominated by two parts: 1) building a local table in each rule (lines 1-2), and 2) accumulating the word counts from the local table to the root (note that all the reverse reachable edges need to be traversed). For the first part, all the elements in each rule need to be analyzed, so the complexity involved in building the local table is $n_e\ast k$, where $n_e$ is the average number of elements for the nodes and $k$ is the number of nodes in the DAG. For the second part, assume the number of elements in the local word table of node $i$ is $n_i$ and the number of edges in the reverse reachable edge set of the node $i$ is $e_i$, then the complexity in accumulating the word counts from the node $i$ to the root is $n_i\ast e_i$. Based on the analysis, the time complexity of Algorithm~\ref{wordCountAlt1} is $O(n_e\ast k+ \sum_{0}^{k-1}(n_i\ast e_i))$. The space complexity of Algorithm~\ref{wordCountAlt1} is $O(s+g+k\ast l)$, where $s$ is the size of the DAG, $g$ is the global table size, $k$ is the number of nodes in the DAG, and $l$ is the average size of the local tables. } The example illustrates the essence of the general algorithm of our TADOC method: \noindent \includegraphics[width=.5\textwidth]{figures/basicAlg2} We name the three main operations {\em local processing}, {\em data integration}, and {\em data propagation} respectively. Document analytics is converted into a graph traversal process. Such a traversal process leverages the structure of the input documents captured by Sequitur, and embodies information reuse to avoid repeated processing of repeated content. In terms of application scope, TADOC is designed for document analytics applications that can be expressed as DAG traversal-based problems on the compressed datasets, where the datasets do \emph{not} change frequently. Such applications would fit and benefit most from our approach. \vspace{-0.20in} \subsection{Challenges} \label{sec:complexity} \vspace{-0.10in} Effectively materializing the concept of TADOC faces a number of challenges. As Figure~\ref{fig:overview} shows, these challenges center around the tension between reuse of results across nodes and the overheads in saving and propagating results. Reuse saves repeated processing of repeated content, but at the same time, requires the computation results to be saved in memory and propagated throughout the graph. The key to effective TADOC is to maximize the reuse while minimizing the overhead. \begin{figure}[!h] \vspace{-0.15in} \center \includegraphics[width=.5\textwidth]{figures/complexities} \vspace{-0.20in} \caption{Overview of the challenges and solutions.}\label{fig:overview} \vspace{-0.20in} \end{figure} Our problem is complicated by the complexities imposed by the various analytics problems, the large and various datasets, and the demand for scalable performance. We summarize the most common challenges as follows: \begin{itemize}[noitemsep,nolistsep] \item {\em Unit sensitivity}. \textit{Word count} regards the entire input dataset as a single bag of words. Yet, in many other document analytics tasks, the input dataset is regarded as a collection of some units (e.g., files). For instance, \textit{inverted index} and \textit{sequence count} try to get some statistics in each file. The default Sequitur compression does \emph{not} discern among files. How to support unit sensitivity is a question to be answered. \item {\em Order sensitivity}. The way that results are propagated in the example of \textit{word count} in Figure~\ref{fig:wcExample} neglects the appearance order of words in the input documents. A challenge is how to accommodate the order for applications (e.g., \textit{sequence count}) that are sensitive to the order. This is especially tricky when a sequence of words span across the boundaries of multiple nodes (e.g., the ending substring ``a b a'' in Figure~\ref{fig:SequiturExample} spans across nodes R2 and R0). \item {\em Data attributes}. The attributes of input datasets, such as the number of files, the sizes of files, and the number of unique words, may sometimes substantially affect the overhead and benefits of a particular design for TADOC. For instance, when solving \textit{inverted index}, one method is to propagate through the graph the list of files in which a word appears. This approach could be effective if there are a modest number of files, but would incur large propagation overheads otherwise, since the list to propagate could get very large. Thus, datasets with different properties could demand a different design in what to propagate and the overall traversal algorithm. \item {\em Parallelism barriers.} For large datasets, parallel or distributed processing is essential for performance. However, TADOC introduces some dependencies that form barriers. In Figure~\ref{fig:wcExample}, for instance, because nodes R1 and R0 require results from the processing of R2, it is difficult for them to be processed concurrently with R2. \end{itemize} A naive solution to all these challenges is to decompress data before processing. However, doing so loses most benefits of compression. We next present our novel solutions to the challenges. \section{Guidelines and Techniques} \label{sec:solutions} \vspace{-0.15in} This section presents our guidelines, techniques, and software modules for easing programmers' jobs in implementing efficient TADOC. \vspace{-0.25in} \subsection{Solution Overview} \vspace{-0.15in} The part outside the challenge circle in Figure~\ref{fig:overview} gives an overview of the solutions to the challenges. Because of the close interplay between various challenges, each of our solution techniques simultaneously relates with multiple challenges. They all contribute to our central goal: maximizing reuse while minimizing overhead. The first solution technique is about the design of the graph traversal algorithm, emphasizing the selection of the traversal order and the information to propagate to adapt to different problems and datasets (Section~4.2). The second is about data structure design, which is especially useful for addressing unit sensitivity (Section~4.2). The third is on overcoming the parallelism barriers through coarse-grained parallel algorithm design and automatic data partition (Section~4.3). The fourth addresses order sensitivity (Section~4.4). The other three are some general optimizations to be applied at compression time and graph loading time, useful for both reducing the processing overhead and maximizing the compression ratio (Section~4.5). For these techniques, we have developed some software modules to assist programmers in using the techniques. In the rest of this section, we describe each of the techniques along with the corresponding modules. \vspace{-0.25in} \subsection{Adaptive Traversal Order} \label{sec:order} \vspace{-0.15in} The first of the key insights we learned through our explorations is that graph traversal order significantly affects the efficiency of TADOC. Its influence is coupled with the information that the algorithm propagates through the graph during the processing. The appropriate traversal order choice depends on the characteristics of both the problems and the datasets. In this part of paper, we first draw on \textit{word count} and \textit{inverted index} as two examples to explain this insight, and then present the derived guideline and a corresponding software module to assist developers. Through the way, we will also explain some basic operations needed to handle unit sensitivity of document analytics. \vspace*{.1in} \noindent \textit{\cred{An Alternative Algorithm for \textit{Word Count}}} \cred{ Figure~\ref{fig:wcExample} has already shown how \textit{word count} can be done through a postorder traversal of the CFG. Doing so can yield a decent speedup by saving computation (e.g., 1.4X on a 2.1GB {\em Wikipedia} dataset~\cite{wikipedia}, which is dataset E in Section~\ref{subsec:evaluationEva}). However, we find that if we change the traversal to preorder (parents before children), the speedups can almost double. } \cred{ Figure~\ref{fig:wcExample2} illustrates this alternative design. It consists of two main steps. The first step calculates the total frequency with which each rule appears in the entire dataset (\circled{1} to \circled{3} in Figure~\ref{fig:wcExample2}). This step is done through a preorder traversal of the graph: Parent nodes pass their total frequencies to their children, from which the children nodes can calculate their total frequencies. Let $f(r)$ be the computed frequency of rule $r$. With this step done, the second step (\circled{4} in Figure~\ref{fig:wcExample2}) just needs to enumerate all the rules once. No graph traversal is needed. When it processes rule $r$, it calculates $f_r(w)=c_r(w)\ast f(r)$, where, $c_r(w)$ is the directly observable frequency of the word $w$ on the right-hand side of rule $r$ (i.e., without considering the subrules of $r$), and $f_r(w)$ is the total directly observable frequency of $w$ due to all occurrences of rule $r$. Let $f(w)$ be the frequency of word $w$. The algorithm adds $f_r(w)$ into $f(w)$, the accumulated frequency of $w$. So when the enumeration of all rules is done, the total count of every word is produced. For example, $f_0(a)$ is 1, $f_1(a)$ is 0, and $f_2(a)$ is 5, so $f(a)$ is 6. } \cred{ Based on the idea, we implement \texttt{wordcount-V2}, shown in Algorithm~\ref{wordCountv3}. It consists of two main steps. The first step (lines 5 to 14) calculates the frequencies of each rule, and the second step (lines 16 to 20) goes through the words on the right-hand side of each rule to obtain the accumulated total frequency of each word. The first step propagates the {\it fq} of each node to its children in a preorder (parents before children) traversal of the graph. Note that a node's {\it fq} should be propagated to its children only after its {\it fq} is fully ready---that is, all its parents' {\it fq}s have been folded into its {\it fq}. Algorithm~\ref{wordCountv3} uses a queue \textit{workQue} to ensure that: a rule is enqueued only when its {\it fq} has been updated $k$ times, where $k$ is the number of its parents (line 10 in Algorithm~\ref{wordCountv3}). Compared to \texttt{wordcount-V1}, this version needs to propagate only an integer {\it fq} between nodes, significantly reducing the runtime overhead. } \begin{figure}[!h] \centering \includegraphics[width=1\linewidth]{figures/sequitur/concept_preorder2.pdf} \vspace{-0.20in} \caption{\cred{Illustration of a preorder traversal algorithm for \textit{word count} on the same string as Figure~\ref{fig:wcExample} deals with. The weights on an edge between two nodes (say, $node_x$ to $node_y$) indicate the total appearances of $node_y$'s rule due to all appearances of $node_x$'s rule.}}\label{fig:wcExample2} \vspace{-0.20in} \end{figure} \begin{algorithm} \caption{\texttt{wordcount-V2}} \label{wordCountv3} \begin{algorithmic}[1] \algrenewcommand\textproc{} \State $G=LoadMergeGraph(I)$\Comment{same as in Algorithm~\ref{wordCountAlt1} including setting up {\it locTbl} for each rule; additionally, each rule has a field {\it fq} set to 0, $updates$ set to 0} \State $rule[G.root].fq=1$ \State \texttt{init $workQue$ to empty} \State \texttt{$\mathit{workQue}$.enque($\mathit{G.root}$)} \While{\texttt{!$\mathit{workQue}$.empty()}}\Comment{Calculate frequencies} \State \texttt{$\mathit{head}$ = $\mathit{workQue}$.deque()} \For{\texttt{each subRule $i$ in rule $\mathit{head}$}} \State $rule[i].fq+=rule[head].fq\ast rule[head].locTbl[i]$ \State {\texttt{$\mathit{rule[i].updates}$++}} \If {$\mathit{rule[i].updates}$ == $\mathit{rule[i].inEdges}$}\Comment{Done with updating its {\it fq}, ready to be propagated to its children} \State {\texttt{$\mathit{workQue}$.enque($\mathit{i}$)}} \EndIf \EndFor \EndWhile \State $init(wordCounts)$\Comment{all zeros} \For{\texttt{each rule $i$}}\Comment{accumulate word's frequency} \For{\texttt{each word $w$ in $\mathit{rule[i]}$}} \State {\texttt{$wordCounts[w]$ += $rule[i].locTbl[w]\ast rule[i].fq$}} \EndFor \EndFor \end{algorithmic} \end{algorithm} \vspace{-0.15in} \cred{ The time complexity of Algorithm~\ref{wordCountv3} is dominated by two parts: 1) building a local table in each rule, and 2) calculating the accumulated frequency for each rule. The first part is the same as the first part in the complexity analysis of Algorithm~\ref{wordCountAlt1}. For the second part, the rule frequency is transmitted from the root to the children, cumulatively; each edge is passed only once, so the complexity of this part is the number of edges $d_G$. Therefore, the time complexity of Algorithm~\ref{wordCountv3} is $O(n_e\ast k+ d_G)$, which is much simpler than the complexity of Algorithm~\ref{wordCountAlt1}. The space complexity of Algorithm~\ref{wordCountv3} is also $O(s+g+k\ast l)$, where $s$ is the size of the DAG, $g$ is the global table size, $k$ is the number of nodes in the DAG, and $l$ is the average size of the local tables. } \cred{ This alternative algorithm achieves a much larger speedup (2.0X versus 1.4X on dataset E of {\em Wikipedia} in Section~\ref{subsec:evaluationEva}) than the postorder algorithm does. The reason is that it needs to propagate only an integer---the node's frequency---from a node to its children, while the postorder algorithm in Figure~\ref{fig:wcExample} needs to propagate the frequencies of all the words the node and the node's successors contain. This example illustrates the importance of traversal order and the information to propagate for the efficiency of TADOC. } \vspace*{.1in} \textit{\cred{Traversals for \textit{Inverted Index}}} \cred{ The appropriate traversal order depends on both the analytic tasks and datasets. We illustrate this point by describing two alternative traversal algorithms designed for \textit{inverted index}. } Recall that the goal of \textit{inverted index} is to build a mapping from each word to the list of files in which it appears. Before we discuss the different traversal orders, we note that the objective of this analytics task requires discerning one file from another. Therefore, in the Sequitur compression results, file boundaries should be marked. To do so, we introduce a preprocessing step, which inserts some special markers at file boundaries in the original input dataset. As these markers are all distinctive and differ from the original data, in the Sequitur compressed data, they become part of the root rule, separating the different files, as the ``spt1'' and ``spt2'' in Figure~\ref{fig:indexing} illustrate. (This usage of special markers offers a general way to handle unit sensitivity.) \begin{figure}[!h] \vspace{-0.20in} \centering \includegraphics[width=.95\linewidth]{figures/analytics/indexing} \caption{Sequitur compression result with file separators (``spt1'' and ``spt2'' are two file separators). }\label{fig:indexing} \vspace{-0.20in} \end{figure} We next explain both preorder and postorder designs for \textit{inverted index}. In the \emph{preorder} design, the first step propagates the set of the IDs of the files that contain the string represented by the node, instead of the frequencies of rules. For instance, in Figure~\ref{fig:indexing}, the {\it fileSet} of rule \texttt{R2} is \{file0, file1\}, and rule \texttt{R3} is \{file2\}. Because both rule \texttt{R2} and \texttt{R3} have rule \texttt{R4} as one of their subrules, during the preorder graph traversal, the {\it fileSet} of rule \texttt{R4} is updated to the union of their {\it fileSet}s as \{file0, file1, file2\}. So, after the first step, every rule's {\it fileSet} consists of the IDs of all the files containing the string represented by that rule. The second step goes through each rule and builds the inverted indices by outputting the {\it fileSet} of each word that appears on the right-hand side of that rule. \cred{ The algorithm of preorder \textit{inverted index} is shown in Algorithm~\ref{invertedIdxExample1}. Initialization part transmits the file information to the level-2 nodes, and places the level-2 nodes into the queue (lines~\ref{alg:inv1:a} to \ref{alg:inv1:b}). After initialization, level-2 nodes are ready to propagate the file information to the nodes in lower levels. Next, the algorithm propagates the file information so that each rule contains the file IDs it appears in (lines~\ref{alg:inv1:c} to \ref{alg:inv1:d}). It uses a queue: each rule transmits its file IDs to its children (lines~9 to 13), and places the children that finish gathering file IDs into the queue (lines~14 to 17). Finally, the algorithm goes through the words and files for each rule to build the word-to-file index (lines~\ref{alg:inv1:e} to \ref{alg:inv1:f}). } \begin{algorithm} \caption{\texttt{\cred{invertedindex-V1}}} \label{invertedIdxExample1} \begin{algorithmic}[1] \algrenewcommand\textproc{} \State $G=LoadMergeGraph(I) \State \texttt{init $workQue$ to empty} \For{\texttt{each file $i$ in the root rule $0$}} {\label{alg:inv1:a}} \State {\texttt{$initLevel2Nodes()$}}\Comment{Insert file info from the root and insert level-2 nodes into $workQue$} \EndFor {\label{alg:inv1:b}} \While{\texttt{!$workQue$.empty()}} {\label{alg:inv1:c}} \State {\texttt{$head$ = $workQue$.deque()}} \For{\texttt{each subRule $i$ in rule $head$}} \For{\texttt{each file $j$ in rule $i$}} \If {\texttt{$j$ not in $rule[i].fileSet$}} \State {$rule[i].fileSet$.insert($j$)} \EndIf \EndFor \State {\texttt{$rule[i].updates$++}} \If {$rule[i].updates == rule[i].inEdges$} \State {\texttt{$workQue$.enque(i)}} \EndIf \EndFor \EndWhile {\label{alg:inv1:d}} \For{\texttt{each rule $i$ in $\mathit{rules}$}} {\label{alg:inv1:e}} \For{\texttt{each word $j$ in $\mathit{rule[i]}$}} \For{\texttt{each file $k$ in $\mathit{rule[i]}$}} \State {\texttt{insert $(j,k)$ into $result$}} \EndFor \EndFor \EndFor {\label{alg:inv1:f}} \end{algorithmic} \end{algorithm} \cred{ The complexity of Algorithm~\ref{invertedIdxExample1} is dominated by two parts: 1) transmitting the file information from the root to all the children, and 2) collecting the word-to-file relations from each rule to the global table. For the first part, in the root, each rule element $h_i$ belongs to a file, and the file information needs to be transmitted to all the reachable nodes of rule $h_i$. Assuming the number of rule elements in the root is $h_G$, and the number of the reachable edges of $h_i$ is $u_i$. } \cb{ Then, the time complexity of the first part is $O(\sum_{i=0}^{h_G-1}u_i)$. For the second part, assume that node $r_i$ belongs to $v_i$ files, and the number of elements in node $r_i$ is $n_i$. Then, the time complexity of the second part is $O(\sum_{i=0}^{k-1}(v_i\ast n_i))$. Therefore, the time complexity of Algorithm~3 is $O(\sum_{i=0}^{h_G-1}u_i+ \sum_{i=0}^{k-1}(v_i\ast n_i))$. The space complexity of Algorithm~3 is also $O(s+g+k\ast l_{2lev})$, where $s$ is the size of the DAG, $g$ is the global table size, $k$ is the number of nodes in the DAG, and $l_{2lev}$ is the average size of the double-layered bitmaps (detailed in Section~\ref{sec:forCompression}). } The \emph{postorder} design recursively folds the set of words covered by a node into the word sets of their parent node. The folding follows a postorder traversal of the graph and stops at the immediate children of the root node (called {\it level-2 nodes}.) The result is that every level-2 node has a {\it wordSet} consisting of all the words contained by the string represented by that node. From the root node, it is easy to label every level-2 node with a {\it fileSet}---that is the set of files that contain the node (and hence each word in its {\it wordSet}). Going through all the level-2 nodes, the algorithm can then easily output the list of containing files for each word, and hence yield the inverted indices. \cred{ Algorithm~\ref{invertedIndexExample2} depicts postorder \textit{inverted index}. It consists of two main steps. The first step (lines \ref{alg:inv2:a} to \ref{alg:inv2:b}) performs word transmission in postorder to the level-2 nodes. Different from Algorithm~\ref{wordCountv3} of \texttt{wordcount-V2}, the algorithm only needs to record the word without its frequency. Because level-2 nodes contain all the word information needed, the second step only needs the root rule and the level-2 nodes to generate the inverted index (lines \ref{alg:inv2:c} to \ref{alg:inv2:d}). } \begin{algorithm} \caption{\texttt{\cred{invertedindex-V2}}} \label{invertedIndexExample2} \begin{algorithmic}[1] \algrenewcommand\textproc{} \State $G=LoadMergeGraph(I) \For{\texttt{each subrule $i$ in the root rule $0$}} {\label{alg:inv2:a}} \State {postorderTraverse($i$)} \EndFor {\label{alg:inv2:b}} \For{\texttt{each file $i$ in the root rule $0$}} {\label{alg:inv2:c}} \State {generateIndex($i$, $result$)}\Comment{Using root and level-2 nodes to generate the result} \EndFor {\label{alg:inv2:d}} \Procedure{postorderTraverse}{$id$ \For{\texttt{each subRule $i$ in rule $id$}} \If {$!done[i]$} \State postorderTraverse\texttt{($i$)} \EndIf \EndFor \For{\texttt{each subRule $i$ in rule $id$}} \For{\texttt{each word $w$ in the $locTbl$ of rule $i$}} \State {$rule[id].locTbl[w] = true$} \EndFor \EndFor \State {$done[id] = true$} \EndProcedure \end{algorithmic} \end{algorithm} \cred{ The complexity of Algorithm~\ref{invertedIndexExample2} is dominated by two parts: 1) transmitting the word set from the leaf to the level-2 nodes, and 2) collecting the word-to-file relations from the root and the level-2 nodes. For the first part, the process is similar to Algorithm~1 and has the same complexity of $O(n_e\ast k+ \sum_{0}^{k-1}(n_i\ast e_i))$, where $n_e$ is the average number of elements for the nodes, $k$ is the number of nodes, $n_i$ is the number of elements in the local word table of node $i$, and $e_i$ is the number of edges in the reverse reachable edge set of node $i$ in the DAG. For the second part, the number of words contained in each level-2 node depends on the input, and in the worst-case scenario, each level-2 node includes all vocabularies, whose number is $y$. Hence, the complexity of the second part is $h_G\ast y$, where $h_G$ is the number of rule elements in the root. Therefore, the time complexity of Algorithm~4 is $O(n_e\ast k+ \sum_{0}^{k-1}(n_i\ast e_i)+h_G\ast y)$. The space complexity of Algorithm~4 is $O(s+g+k\ast l)$, where $s$ is the size of the DAG, $g$ is the global table size, $k$ is the number of nodes in the DAG, and $l$ is the average size of the local tables. } The relative performance of the two designs depends on the dataset. For a dataset with many small files, the preorder design tends to run much slower than postorder (e.g., 1.2X versus 1.9X speedup over processing the original dataset directly on dataset D in Section~\ref{subsec:evaluationEva}, {\em NSF Research Award Abstracts} dataset~\cite{Lichman:2013}), because the file sets it propagates are large. On the other hand, for a dataset with few large files, the preorder design tends to be a better choice as the postorder design has to propagate large {\it wordSets}. It is worth noting that \textit{word count} can also be implemented in both preorder and postorder, and preorder is a more efficient choice. \vspace*{.1in} \noindent \textit{Guidelines and Software Module} Our experience leads to the following two guidelines for implementing TADOC. {\bf Guideline I:} Try to minimize the footprint size of the data propagated across the graph during processing. {\bf Guideline II:} Traversal order is essential for efficiency. It should be selected to suit both the analytics task and the input datasets. These guidelines serve as principles for developers to follow during their implementations of the solutions for their specific analytics tasks. Traversal order is worth further discussion. The execution time with either order mainly consists of the computation time $\mathit{t_{compute}}$ and the data propagation time $\mathit{t_{copy}}$. The former is determined by the operations performed on a node, while the latter by the amount of data propagated across nodes. Their values in a given traversal order are affected by both the analytics task and the datasets. Directly modeling $\mathit{t_{compute}}$ and $\mathit{t_{copy}}$ analytically is challenging. We instead provide support to help users address the challenge through machine learning models. For a given analytics problem, the developer may create multiple versions of the solution (e.g., of different traversal orders). We use a decision tree model to select the most suitable version. To build the model, we specify a list of features that potentially affect program performance. According to the decision tree algorithm, these features are automatically selected and placed on the right place of the decision tree via the training process. For training data, we use some small datasets that have similar characteristics to the target input. We develop a software module, {\em OrderSelector}, which helps developers to build the decision tree for version selection. The developer can then specify these versions in the configuration file of {\em OrderSelector} as candidates, and provide a list of representative inputs on which the program can run. They may also specify some (currently Python) scripts for collecting certain features of a dataset that are potentially relevant to the selection of the versions. This step is optional as {\em OrderSelector} has a set of predefined data feature collection procedures, including, for instance, the size of an original dataset, the size of its Sequitur CFG, the number of unique words in a dataset, the number of rules, and the number of files. These features are provided as metadata at the beginning of the Sequitur compressed data or its dictionary, taking virtually no time to read. With the configuration specified, {\em OrderSelector} runs all the versions on each of the representative input to collect their performance data (i.e., running time) and dataset features. It then invokes an off-the-shelf decision tree construction tool (scikit-learn~\cite{pedregosa2011scikit}) on the data to construct a decision tree for version selection. The decision tree is then used in the production mode of {\em OrderSelector} to invoke the appropriate version for a given compressed dataset. Figure~\ref{fig:decisionTree} shows the decision tree obtained on {\em inverted index} based on the measurements of the executions of the different versions of the program on 60 datasets on the single node machine (Table~\ref{configurations}). The datasets were formed by sampling the documents contained in the five datasets in Section~\ref{sec:evaluation}. They have various features: numbers of files range from 1 to 50,000, median file sizes range from 1KB to 554MB, and vocabulary sizes range from 213 to 3.3Million. The decision tree favors postorder traversal when the average file size is small (<2860 words) and preorder otherwise. (The two versions of preorder will be discussed in Section~\ref{sec:forCompression}). In five-fold cross validation, the decision tree predicts the suitable traversal order with a 90\% accuracy. \begin{figure}[!h] \centering \includegraphics[width=.85\linewidth]{figures/minor/decisionTreeV2} \vspace{-0.10in} \caption{Decision tree for choosing traversal order. }\label{fig:decisionTree} \vspace{-0.30in} \end{figure} \subsection{Coarse-Grained Parallelism and Data Partitioning} \label{sec:parallelism} \vspace{-0.15in} To obtain scalable performance, it is important for TADOC to effectively leverage parallel and distributed computing resources. As Section~\ref{sec:challenges} mentions, some dependencies are introduced between processing steps in either preorder or postorder traversals of CFGs, which cause extra challenges for a parallel implementation. We have explored two ways to handle such dependencies to parallelize the processing. The first is \emph{fine-grained partitioning}, which distributes the nodes of the DAG to different threads, and inserts fine-grained communication and synchronization among the threads to exchange necessary data and results. This method can potentially leverage existing work on parallel and distributed graph processing~\cite{gonzalez2012powergraph,petroni2015hdrf,carbone2015apache,martella2015practical,malewicz2010pregel,xin2013graphx}. For instance, PowerGraph~\cite{gonzalez2012powergraph}, exploits the power-law property of graphs for distributed graph placement and representation, and HDRF~\cite{petroni2015hdrf} is a streaming vertex-cut graph partitioning algorithm that considers vertex degree in placement. The second is a \emph{coarse-grained partitioning} method. At compression time, this method partitions the original input into a number of segments, then performs compression and analytics on each segment in parallel, and finally assembles the results if necessary. The coarse-grained method may miss some compression opportunities that exist across segments (e.g., one substring appears in two segments). However, its coarse-grained partitioning helps avoid frequent synchronization among threads. Our experimental results show that on datasets of non-trivial sizes, the coarse-grained method significantly outperforms the fine-grained method in both performance and scalability. It is also easier to implement, for both parallel and distributed environments. For a parallel system, the segments are distributed to all cores evenly. For a distributed system, they are distributed to all nodes evenly, and then distributed to the cores within each node. Load balance among threads or processes is essential for high parallel or distributed performance. Thus, the coarse-grained method requires balanced partitioning of input datasets among threads or processes. The partitioning can be done at the file level, but it sometimes requires even \emph{finer} granularity such that a file is split into several sections, where each section is assigned to a thread or process. \vspace*{.1in} \noindent \textit{Guideline and Software Module} Our experience leads to the following guideline. {\bf Guideline III:} Coarse-grained distributed implementation is preferred, especially when the input dataset exceeds the memory capacity of one machine; data partitioning for load balance should be considered, but with caution if it requires the split of a file, especially for unit-sensitive or order-sensitive tasks. Dataset partitioning is important for balancing the load of the worker threads in coarse-grained parallelization. Our partitioning mechanism tries to create subsets of files rather than splitting a file because there is extra cost for handling a split file, especially for unit-sensitive or order-sensitive tasks. To assist with this process, we develop a software module. When the module is invoked with the input dataset (a collection of files) and the intended number of worker threads, it returns a set of partitions and a metadata structure. Resilient distributed dataset (RDD) is the basic fault-tolerant data unit in Spark~\cite{zaharia2010spark}. The metadata structure records the mapping relations among RDDs, files, and file sections. In the workload partitioning process, file splitting is considered only when a file exceeds a size threshold, $h_{split}$, and causes significant load imbalance (making one partition exceed the average workload per worker by 1/4). $h_{split}$ is defined as $\mathit{S_{total}}/2n_w$, where $\mathit{S_{total}}$ is the total dataset size, and $\mathit{n_w}$ is the number of workers. The module 1) ensures that all workers process similar amounts of work and 2) avoids generating small fragments of a file by tolerating some disparity in the partition sizes. For applications that require additional file or word sequence information, our partitioning mechanism records some extra information, such as which file a section belongs to, the sequence number of the section in the file, and so on. Such information is necessary for a thread to know which section of which file it is processing, which is useful for a later stage that merges the results. \vspace{-0.30in} \subsection{Handling Order Sensitivity} \label{sec:treatment2orderSen} \vspace{-0.10in} As Section~\ref{sec:challenges} mentions, tasks that are sensitive to the appearance order of words pose some special challenges. \textit{Sequence count}, for instance, requires extra processing to handle 1) sequences that may span across multiple Sequitur rules (i.e., nodes in the DAG) and 2) order of words covered by different rules. The order sensitivity challenge (detailed in Section~3.2) 1) calls for certain constraints on the visiting order of the rules in the Sequitur grammar, and 2) demands the use of extra data structures to handle sequences across rules. In our explorations, we found that the order sensitivity challenge can be addressed through a two-level table design with a depth-first graph traversal. The depth-first traversal of the graph ensures that the processing of the data observes the appearing order of words in the original dataset. During the traversal, we use a global table to store the results that require cross-node examinations, and a local table to record the results directly attainable from the right hand side of the rule in a node. Such a design allows the visibility of results across nodes, and at the same time, permits reuse of local results if a rule appears many times in the dataset. We take \textit{sequence count} as an example to illustrate our solution. Algorithm~\ref{alg:seqCount} shows the pseudo-code. The Sequitur design decides that the scanning process is similar to the depth-first graph traversal, but the difference is that a sequence counting is integrated into the scanning process. The general idea is to perform a depth-first traversal (line 5); the word sequences that cross rules are stored in the global table, while the word sequences within a rule are stored in the local table of each rule. When the traversal is finished, we integrate the local tables from different rules to the global table (lines 6-7). The \texttt{seqCount} function is used to process the rules, while the \texttt{process} function is used to process the words. The depth-first graph traversal is embodied by the recursive function \texttt{seqCount} (lines 10 and 15 in Algorithm~\ref{alg:seqCount}). It uses an $l$-element first-in first-out queue (\texttt{q}) to store the most-recently-seen $l$ words. In function \texttt{process}, the most recent word is pushed into \texttt{q}, and this newly formed sequence in \texttt{q} is then processed, resulting in an increment in the counters in either the local table \texttt{locTbl} (line 27) if the sequence does not span across rules, or otherwise, in the global table \texttt{gloTbl} (line 24). The traversal may encounter a rule multiple times if the rule or its ancestors are referenced multiple times in the DAG. The Boolean variable \texttt{locTblReady} of a rule tracks whether the \texttt{locTbl} of the rule is ready to be reused, thus saving time. Note that in line 21, we also need to record the rule $r$, since we need to identify whether the words in $q$ are from multiple rules. \iffalse Algorithm~\ref{alg:seqCount} shows the pseudo-code. The depth-first graph traversal is embodied by the recursive function \texttt{seqCount} (lines 10 and 15 in Algorithm~\ref{alg:seqCount}). It uses an $l$-element first-in first-out queue (\texttt{q}) to store the most-recently-seen $l$ words. In function \texttt{process}, the most recent word is pushed into \texttt{q}, and then this newly formed sequence in \texttt{q} is processed, resulting in the incrementing of the counters in either the local table (\texttt{locTbl} (line 27)) if the sequence does not span across rules, or otherwise, in the global table \texttt{gloTbl} (line 24). The traversal may encounter a rule multiple times if the rule or its ancestors are referenced multiple times in the DAG. The Boolean variable \texttt{locTblReady} of a rule tracks whether the \texttt{locTbl} of the rule has been built such that rebuildings can be avoided. \fi \begin{algorithm} \caption{Count $l$-word Sequences in Each File} \label{alg:seqCount} \small \begin{algorithmic}[1] \algrenewcommand\textproc{} \State $G=LoadData(I)$\Comment{load compressed data I; each rule has an empty $locTbl$ and a false boolean $locTblReady$} \State \texttt{allocate $gloTbl$ and an $l$-element long FIFO queue {\it q}} \For{\texttt{each file $f$}} \State $s=segment(f, G.root)$\Comment{Get a segment of the right-hand side of the root rule covering file $f$} (e.g., first three nodes in Figure~\ref{fig:indexing} for file0) \State $seqCount(s)$ \State $calfq(s)$\Comment {calculate the frequency {\it fq} of each rule in $s$} \State $cmb(s)$\Comment{integrate into $gloTbl$ the $locTbl$ (times {\it fq}) of each rule subsumed by $s$} \State \texttt{output $gloTbl$ and reset it and {\it q}} \EndFor \Function{seqCount}{$s$} \For{\texttt{each element $e$ in $s$ from left to right}} \If {\texttt{$e$ is a word}} \State $process(e, s)$ \Else \State $seqCount(e)$ \Comment{recursive call that materializes depth-first traversal of G} \EndIf \EndFor \State $s.locTblReady=true$ \EndFunction \Function{process}{$e$, $r$} \State {\it q}$.enqueue(e, r)$\Comment{evict the oldest if full} \State \texttt{return if {\it q} is not full} \Comment{Need more words to form an $l$-element sequence} \If {\texttt{words in {\it q} are from multiple rules}} \State $gloTbl[\mathit{q.content}]++$ \Else \If {!$r.locTblReady$}\Comment {avoid repeated processing} \State $r.locTbl[\mathit{q.content}]++$ \EndIf \EndIf \EndFunction \end{algorithmic} \end{algorithm} Figure~\ref{fig:sequenceCountExa} demonstrates how Algorithm~\ref{alg:seqCount} works on an input word sequence whose DAG is shown in Figure~\ref{fig:indexing}. The words in the first 3-word sequence \circled{1} correspond to two different rules in the DAG (R1 and R4). This sequence is a cross-node sequence and the algorithm stores its count into a global table. The next 3-word sequence \circled{2} corresponds to only R4, and is hence counted in a local table. The next two sequences \circled{3}, \circled{4} both correspond to two instances of R4, and are both cross-node sequences. Thus, they are counted in the global table. The bottom sequence \circled{5} is the same as the second sequence \circled{2}; the algorithm does \emph{not} recount this sequence, but directly reuses the entry in the local table of R4. \begin{figure} \includegraphics[width=.98\linewidth]{figures/analytics/sequenceCount.pdf} \centering \vspace{-0.10in} \caption{Illustration of how Algorithm~\ref{alg:seqCount} processes an input sequence (DAG in Figure~\ref{fig:indexing}) for counting 3-word long sequences.} \label{fig:sequenceCountExa} \vspace{-0.20in} \end{figure} The key for the correctness of Algorithm~\ref{alg:seqCount} is that the depth-first traversal visits \emph{all} words in the \emph{correct} order, i.e., the original appearance order of the words. We prove it as follows (``content of a node'' means the text that a node covers in the original document.) \emph{Lemma 1}: If the content of every child node of a rule $r$ is visited in the correct order, the content of $r$ is visited in the correct order. \emph{Proof:} Line 11 in Algorithm~\ref{alg:seqCount} ensures that the elements in rule $r$ are visited in the correct order. The condition of this lemma ensures that the content inside every element (if it is a rule) is also visited in the correct order. The correctness of the lemma hence follows. \emph{Lemma 2}: The content of every leaf node is visited in the correct order. \emph{Proof:} A leaf node contains no rules, only words. Line 11 in Algorithm~\ref{alg:seqCount} ensures the correct visiting order of the words it contains. The correctness hence follows. \emph{Lemma 3}: The depth-first traversal by Algorithm~\ref{alg:seqCount} of a DAG G visits all words in an order consistent with the appearance order of the words in the original document G. \emph{Proof:} A basic property of a DAG is that it must have at least one topological ordering. In such an ordering, the starting node of every edge occurs earlier in the ordering than the ending node of the edge. Therefore, for an arbitrary node in G, its children nodes must appear \emph{after} that node in the topological ordering of G. Let $n_{-1}$ be the last non-leaf node in the ordering. \emph{Lemma 2} entails that all the nodes after $n_{-1}$ must be visited in the correct order as they are all leaf nodes, and \emph{Lemma 1} entails that the content of $n_{-1}$ must be visited in the correct order. The same logic leads to the same conclusion on the second to the last non-leaf node, then the third to the last, and so on, until the first node---that is, the root node. As the content of the root node is the entire document, \emph{Lemma 3} follows, by induction. With \emph{Lemma 3}, it is easy to see that all $l$-long sequences in the original document goes through the FIFO queue \texttt{q} in Algorithm~\ref{alg:seqCount}. The algorithm uses the two tables \texttt{locTbl} and \texttt{gloTbl} to record the counts of every sequence in \texttt{q}. Function \texttt{cmb} folds all information together into the final counts. The computational complexity of Algorithm~\ref{alg:seqCount} depends mainly on two functions, \texttt{seqCount} and \texttt{process}. The complexity of \texttt{seqCount} is determined by the total number of times rules are visited, which is also the total number of times edges are traversed in the DAG. In reality, especially with coarsening to be described in Section~\ref{sec:forCompression}, the overhead of \texttt{seqCount} is much smaller than the overhead of \texttt{process}. The complexity of Algorithm~\ref{alg:seqCount} is practically dominated by \texttt{process}, which has a complexity of $O(w)$. $w$ is the number of words in the input documents. The time savings of Algorithm~\ref{alg:seqCount} over the baseline of direct processing on the original data (i.e., without using our method) comes from avoiding repeatedly counting the sequences that do \emph{not} span across rules. Thus, the amount of savings is proportional to $m/n$, where $m$ is the number of repeated local sequences and $n$ is the total number of sequences. The space complexity of Algorithm~\ref{alg:seqCount} is $O(s+g+k\ast l)$, where, $s$ is the size of the DAG, $g$ is the global table size, $k$ is the number of nodes in the DAG, and $l$ is the average size of the local tables. \vspace*{.1in} \noindent \textit{Guideline} {\bf Guideline IV:} For order-sensitive tasks, consider the use of depth-first traversal and a two-level table design. The former helps the system conform to the word appearance order, while the latter helps with result reuse. The global and local tables can be easily implemented through existing template-based data structures in C++ or other languages. Hence, there is no specific software module for the application of this guideline. The coarsening module we describe next provides important performance benefits on top of this guideline. \vspace{-0.20in} \subsection{Other Implementation-Level Optimizations} \label{sec:forCompression} \vspace{-0.10in} We introduce three extra optimizations. They are mostly implementation-level features that are useful for deploying TADOC efficiently. \vspace{1.0mm} \noindent {\bf Double-layered bitmap}. As Guideline I says, minimizing the footprint of propagated data is essential. In our study, we find that when dealing with unit-sensitive analytics (e.g., \textit{inverted index} and \textit{sequence count}), double-layered bitmap is often a helpful data structure for reducing the footprint. \cred{ Double-layered bitmap in this study is a data structure that includes level one and level two, and is used to store information about which files the rule belongs to in an efficient manner. Level one is a data structure used to point to the locations for storing the file information in level-2 bitmaps for a given rule. Level two is the data structure of bit vectors that actually store which files the rule belongs to. In detail, as Figure~\ref{fig:2levelBitMap} illustrates, level two contains a number of $N$-bit vectors (where $N$ is a configurable parameter), while level one contains a pointer array and a level-1 bit vector. The pointer array stores the starting address of the level-2 bit vectors, while the level-1 bit vector is used for fast checks to determine which bit vector in level 2 contains the bit corresponding to the file that is being queried. If a rule is contained in only a subset of files whose bits correspond to some bits in several level-2 vectors, the level two of the bitmap associated with that rule would then contain only those several vectors, and most elements in the pointer array would be null. The number of elements in the first-level arrays and vectors of the double-layered map is only $1/N$ of the number of files. For example, assume that $N$ is four and there are 12 files. The rule belongs to $file0$, $file1$, $file3$, $file4$, and $file5$. Then, in level one, $bit0$ and $bit1$ are \emph{true}, while $bit2$ is \emph{false}; $P0$ and $P1$ have pointer addresses and the value of $P2$ is \emph{NULL}. In level two, } \cb{ the first bit vector is ``1101'' ($file0$, $file1$, and $file3$), the second bit vector is ``1100'' ($file4$ and $file5$), and there is no bit vector that relates to $P2$. } \iffalse Double-layered bitmap is a data structure that has been used in many tasks. Our contribution is in recognizing its benefits for TADOC. Recall that in the preorder design of \textit{inverted index} in Section~\ref{sec:order}, we need to propagate file sets across nodes. One possible design is that each node uses a {\em set} structure to store file IDs. However, frequent querying of and insertions to the set limit the performance of graph traversal. An alternative is that each node uses a {\em bit-vector}, with each bit corresponding to a file: 1 for file presence, 0 otherwise. Although a bit vector representation converts slow set operations with fast bit operations, it incurs large space overhead when there are many files, as every node needs such a vector, and the length of the vector equals the total number of files. We find a double-layered bitmap to be effective in addressing the problem. It is inspired by the use of similar data structures in page table indexing of operating systems~\cite{silberschatz2014operating} and indexing mechanisms for graph query~\cite{cai2017provenance}. As Figure~\ref{fig:2levelBitMap} illustrates, level two contains a number of $N$-bit vectors (where $N$ is a configurable parameter) while level one contains a pointer array and a level-1 bit vector. The pointer array stores the starting address of the level-2 bit vectors, while the level-1 bit vector is used for fast checks to determine which bit vector in level 2 contains the bit corresponding to the file that is queried. If a rule is contained in only a subset of files, whose bits correspond to some bits in several level-2 vectors, then the level two of the bitmap associated with that rule would contain only those several vectors, and most elements in the pointer array would be null. The number of elements in the first-level arrays and vectors of the double-layered map is only $1/N$ of the number of files. \fi \begin{figure}[!h] \vspace{-0.18in} \centering \includegraphics[width=1\linewidth]{figures/zwift/2levBitMap.pdf} \vspace{-0.20in} \caption{A double-layered bitmap for footprint minimization and access efficiency.} \label{fig:2levelBitMap} \vspace{-0.28in} \end{figure} Time-wise, the double-layered bitmap provides most of the efficiency benefits of the one-level bit vector compared to the use of the set mechanism. Even though it incurs one possible extra pointer access and one extra bit operation compared to the use of one-level bit vectors, its total memory footprint is much smaller, which contributes to better cache and TLB performance. As Figure~\ref{fig:decisionTree} shows, the selection between the use of single-layer bitmap and double-layered bitmap can be part of the traversal order selection process. The decision tree in Figure~\ref{fig:decisionTree} favors double-layered bitmap when the average file size is greater than 2860 words and the number of files is greater than 800. (The benefits are confirmed experimentally in Section~\ref{sec:evaluation}). It is easy to see that the double-layered bitmap can be used in other applications with unit sensitivity as well. If the unit is a class of articles, for instance, one just needs to change the semantics of a bit to represent the class. \iffalse \noindent {\bf Double compression}. \textit{Double compression} is an optimization we find helpful for the compression step. Compared to some other compression algorithms, our Sequitur-based method is based on words and it does \emph{not} always get the highest compression rates. To solve this issue, we first compress the original dataset with Sequitur and then run ``gzip'' (or other methods with high compression rates) on the output of Sequitur. \fi \noindent {\bf Double compression}. \textit{Double compression} is an optimization we have found helpful for the compression step. Compared with some other compression algorithms, our Sequitur-based method is based on words and it does \emph{not} always obtain the highest compression rates. To solve this issue, we first compress the original dataset with Sequitur and then run ``gzip'' on the output of Sequitur. Note that ``gzip'' can be replaced with other methods with high compression rates, such as \texttt{zstd}~\cite{zstd} (\texttt{zstd} has a good compression ratio and is extremely fast at decompression). Considering the current universality that almost all platforms are equipped with \texttt{gzip}, we shall still keep \texttt{gzip} as our default double-compression tool, but other compression tools are also supported in this work. The result is often even more compact than the ``gzip'' result on the original dataset. To process the data, one only needs to decompress the ``gzip'' result to recover the Sequitur result. Because Sequitur result is usually much smaller than the original dataset, it takes much less time to recover the Sequitur result than the original dataset does. The decompression of the ``gzip'' result adds only a very small marginal overhead, as shown later. \noindent {\bf Coarsening}. The third optimization relates to data loading time. It is called {\em coarsening}, a transformation to the Sequitur DAG. Through it, the nodes or edges in the graph can represent the accumulated information of a set of nodes or edges. Specifically, we have explored two coarsening methods: edge merging and node coarsening. {\em Edge merging} merges the edges between two nodes in the DAG into one, and uses a weight of the edge to indicate the number of original edges. Merging loses the order of words, but helps reduce the size of the graph and hence the number of memory accesses in the graph traversal. It is helpful to analytics tasks that are insensitive to word order (e.g., \textit{word count} and \textit{inverted index}). {\em Node coarsening} inlines the content of some small rules (which represent short strings) into their parent rules; those small nodes can then be removed from the graph. It reduces the size of the graph, and at the same time, reduces the number of substrings spanning across nodes, which is a benefit especially important for analytics on word sequences (e.g., \textit{sequence count}). Coarsening adds some extra operations, but the time overhead is negligible if it is performed during the loading process of the DAG. On the other hand, it can save memory usage and graph traversal time, as reported in the next section. \vspace*{.05in} \noindent \textit{Guideline and Software Module} {\bf Guideline V:} When dealing with analytics problems with unit sensitivity, consider the use of double-layered bitmap if unit information needs to be passed across the CFG. To simplify developers' job, we create a collection of double-layered bitmap implementations in several commonly used languages (Java, C++, C). Developers can reuse them by simply including the corresponding header files in their applications. Besides double-layered bitmap, another operation essential for handling unit sensitivity is the insertion of special markers into the documents to indicate unit boundaries when we do the compression as Section~\ref{sec:order} mentions. {\bf Guideline VI:} {\em Double compression} and {\em coarsening} help reduce space and time cost, especially when the dataset consists of many files. They also enable that the thresholds be determined empirically (e.g., through decision trees). We create two software modules to assist developers in using our guideline. One module is a library function that takes original dataset as input, and conducts Sequitur compression on it, during which, it applies dictionary encoding and {\em double compression} automatically. In our implementation, this module and the partitioning module mentioned in Section~\ref{sec:parallelism} are combined into one compression module such that the input dataset first gets integer indexed, then partitioned, and finally compressed. The combination ensures that a single indexing dictionary is produced for the entire dataset; the common dictionary for all partitions simplifies the result merging process. Our other module is a data loading module. When this module is invoked with coarsening parameters (e.g., the minimum length of a string a node can hold), it loads the input CFG with coarsening automatically applied. \vspace{-0.25in} \subsection{Short Summary} \vspace{-0.10in} The six guidelines described in this section capture the most important insights we have learned for unleashing the power of TADOC. They provide the solutions to all the major challenges listed in Section~\ref{sec:complexity}: Marker insertion described in Section~\ref{sec:order} and Guideline V together address unit sensitivity, Guideline IV order sensitivity, Guideline II data attributes challenge, Guideline III parallelism barriers, while Guidelines I and VI provide general insights and common techniques on maximizing the efficiency. The described software modules are developed to simplify the applications of the guidelines. They form part of the \texttt{CompressDirect} library, described next. \section{C\MakeLowercase{ompress}D\MakeLowercase{irect} Library} \label{sec:library} \vspace{-0.10in} We create a library named \texttt{CompressDirect} for two purposes. The first is to ease programmers' burden in applying the six guidelines when developing TADOC for an analytics problem. To this end, the first part of \texttt{CompressDirect} is the collection of the software modules described in the previous section. The second purpose is to provide a collection of high performance implementations of some frequently-performed document analytics tasks, which can directly help many existing applications. Specifically, the second part of \texttt{CompressDirect} consists of six high-performance modules. \texttt{Word count}~\cite{ahmad2012puma} counts the number of each word in all of the input documents. \texttt{Sort}~\cite{huang2011hibench} sorts all the words in the input documents in lexicographic order. \texttt{Inverted index}~\cite{ahmad2012puma} generates a word-to-document index that provides the list of files containing each word. \texttt{Term vector}~\cite{ahmad2012puma} finds the most frequent words in a set of documents. \texttt{Sequence count}~\cite{ahmad2012puma} calculates the frequencies of each three-word sequence in every input file. \texttt{Ranked inverted index}~\cite{ahmad2012puma} produces a list of word sequences in decreasing order of their occurrences in each document. These modules are essential for many text analytics applications. For each of these modules, we implement three versions: sequential, parallel, and distributed. The first two versions are written in C/C++ (with Pthreads~\cite{nichols1996pthreads} for parallelization), and the third is in Scalar on Spark~\cite{zaharia2010spark}. Our implementation leverages the functions contained in the first part of the library, which are the software modules described in Section~\ref{sec:solutions}. A DAG is loaded into memory before it is processed. Large datasets are partitioned first with each partition generating a DAG that fits into the memory. The data structures used for processing are all in memory. Using a Domain Specific Language may further ease the programming difficulty, as elaborated in a separate work~\cite{zhang2018zwift}. We next report the performance of our implementations. \section{\cred{Supporting Advanced Document Analytics}} \label{sec:advanced} \vspace{-0.10in} \cred{ In this section, we explore opportunities to apply TADOC to advanced document analytics. We apply TADOC to three advanced document analytics applications: {\em word co-occurrence}~\cite{matsuo2004keyword,pennington2014glove}, \emph{term frequency-inverse document frequency} (TFIDF)~\cite{joachims1996probabilistic}, {\em word2vec}~\cite{rong2014word2vec,googleWord2Vec}, and {\em latent Dirichlet allocation} (LDA)~\cite{blei2003latent}. } \vspace{-0.25in} \subsection{\cred{Word Co-Occurrence}} \vspace{-0.10in} \cred{ Word co-occurrence is the frequency of the occurrence of two words alongside each other in a text corpus. Because it can be regarded as a semantic proximity indicator, word co-occurrence is widely used in linguistics, content analysis, text mining, and thesauri construction. In general, word co-occurrence research aims to analyze similarities between word pairs and patterns, and thus discovers latent linguistic patterns and structures in representations. Word co-occurrence can be transformed into a word co-occurrence matrix, as shown in Figure~\ref{fig:wordcooccur}. The rows and columns represent unique words, and the numbers in the matrix denote the frequency at which $word_i$ co-occurs with $word_j$. For example, in Figure~\ref{fig:wordcooccur}, $word_0$ co-occurs with $word_1$ six times but does not co-occur with $word_2$. } \begin{figure}[!h] \center \includegraphics[width=0.9\linewidth]{figures/advancedExp/cooccur.pdf} \vspace{-0.10in} \caption{\cred{Word co-occurrence matrix example.}} \label{fig:wordcooccur} \vspace{-0.23in} \end{figure} \cred{ The TADOC technique can be applied as a data provider. Because word co-occurrence only pertains to the frequency of adjacent words, we can reuse the word co-occurrences in each rule. A similar process also occurs in \emph{sequence count}. Several optimizations can occur in this process. In linguistics, due to grammar and rules, many words do not appear together; hence, most of the elements in a matrix could be zero, and the word co-occurrence data can be stored in a sparse matrix format, such as the compressed sparse row (CSR) and coordinate (COO) storage format~\cite{fengTKDE}. In addition, a word co-occurrence matrix is a symmetric matrix when the word order is unnecessary, in which case we store only the upper triangular part of the matrix. We only need to coordinate our program interface with the corresponding word co-occurrence program interface. } \cred{ In this paper, we use the word co-occurrence in GloVe~\cite{pennington2014glove} for validation. The word co-occurrence matrix generated by this implementation is a mixture of dense and sparse matrices, as shown in Figure~\ref{fig:glove}. The dense part represents frequent words that have a large number of occurrences; these words are more likely to co-occur with other words, and are therefore stored in a dense matrix. The parameter $vocab\_size$ denotes the size of the dense matrix, which can be adjusted by users. The sparse part represents words that have a small number of occurrences, and therefore uses a sparse matrix format. Notably, GloVe uses a coordinate (COO) format for these sparse matrices. } \begin{figure}[!h] \vspace{-0.20in} \center \includegraphics[width=0.9\linewidth]{figures/advancedExp/glovec.pdf} \vspace{-0.10in} \caption{\cred{Word co-occurrence matrix in GloVe.}} \label{fig:glove} \vspace{-0.20in} \end{figure} \cred{ TADOC can be applied in the construction of dense and sparse matrices. To separate words and build the two matrix parts, the co-occurrence implementation first counts the frequency of each word, and then calculates which words should be arranged in the dense matrix part. The \texttt{CompressDirect} library directly provides word counts from the compressed format, which is more efficient than providing these counts from the original uncompressed data. Because the word count in \texttt{CompressDirect} reuses the redundant information, it saves both computation and IO time. } \vspace{-0.20in} \subsection{TFIDF} \vspace{-0.10in} \cred{ TFIDF~\cite{joachims1996probabilistic} is a statistical method used to evaluate the importance of a word to a document in the corpus. The importance of a word increases proportionally with the frequency of the word in the document, but it decreases inversely with the frequency of the word in the corpus. TFIDF is a commonly used weighting technique for information retrieval and text mining, and has been widely used in search engines as a measurement of the correlation between text and users. Figure~\ref{fig:tfidf} shows an example of TFIDF; $score_{i,j}$ exhibits the importance of $word_i$ to $document_j$. } \begin{figure}[!h] \center \vspace{-0.20in} \includegraphics[width=0.95\linewidth]{figures/advancedExp/tfidf.pdf} \vspace{-0.10in} \caption{TFIDF model.} \label{fig:tfidf} \vspace{-0.20in} \end{figure} \cred{ TFIDF consists of two parts: term frequency (TF), and inverse document frequency (IDF). $TF(i,j)$ refers to the frequency of a given word $i$ that appears in document $j$. $IDF_i$ is a measurement of the general importance of word $i$, as shown in Equation~\ref{eq:idf}. In Equation~\ref{eq:idf}, $\left | D \right |$ is the number of documents, and $DF_i$ is the number of documents in which word $i$ appears at least once. }\cb{ Given this definition of IDF, } \cred{ when a word occurs in a small number of files, its importance is large; when the word occurs in many files, its importance is small. } \begin{equation}\label{eq:idf} { IDF_i=log(\frac{\left | D \right |}{DF_i}) } \end{equation} \cred{ In the TFIDF algorithm, the $score_{i,j}$ of word $i$ to document $j$ is calculated using Equation~\ref{eq:tfidf}. Intuitively, word $i$ is important for document $j$ if the former occurs frequently in the latter, but the importance of word $i$ decreases if the word occurs in many documents. } \begin{equation}\label{eq:tfidf} { score_{i,j}=TF(i,j)\cdot IDF_i } \end{equation} \cred{ TADOC can be used in the TFIDF algorithm. The library \texttt{CompressDirect} generates the TF for each document, and the TF generation process is similar to that of the \texttt{term vector}. Because \texttt{CompressDirect} supports the \texttt{inverted index}, we can first execute the \texttt{inverted index} to calculate $DF$, and then use the intermediate results to calculate the $IDF$ for each file. } \iffalse TADOC can be used in the TFIDF algorithm. The library \texttt{CompressDirect} generates the TF for each document, and the TF generation process is similar to that of the \texttt{term vector}. In addition, because \texttt{CompressDirect} supports the \texttt{inverted index}, the IDF is easily calculated. Using TADOC in TFIDF saves both computation time and memory usage due to the data reuse. \fi \cred{ To validate the efficiency of TADOC on TFIDF, we implement TFIDF~\cite{joachims1996probabilistic} using both the original data (baseline) and the compressed data. The TFIDF algorithm can be divided into two stages. In the first stage, TF and IDF are calculated. Specifically, we calculate the word frequency in each document in the dataset to obtain TF; meanwhile, we record the inverted word-to-document index, which can be used to obtain IDF. In the second stage, the TFIDF values are calculated using both TF and IDF, which are represented as the scores in Figure~\ref{fig:tfidf}. } \cred{ The difference between the use of TFIDF with and without TADOC lies in the first stage. In the baseline, we need to process words sequentially in the original files to generate TF and IDF. In the \texttt{CompressDirect} version, the word frequencies and inverted index of each file are obtained by traversing the DAG, during which deduplication occurs in the reuse of rules, thus saving both space and computation time. The second stages of the baseline and the \texttt{CompressDirect} version are the same. } \vspace{-0.20in} \subsection{Word2vec} \vspace{-0.10in} \cred{ Word2vec~\cite{rong2014word2vec} is a shallow two-layer neural network that converts words from documents to feature vectors, as shown in Figure~\ref{fig:word2vec}. The input of word2vec is a bag of text documents, and its outputs are feature vectors used to describe the words in the text corpus. The vector output of word2vec can be used as input in many applications, such as long short-term memory (LSTM)~\cite{chiu2016named} and recommendation systems~\cite{vasile2016meta}, since this output represents words in a limited number of feature dimensions by numbers. Originally, word2vec was designed to process text data, but its applicability has been extended beyond the text corpus scope; word2vec has applications in non-text patterns such as genes~\cite{koiwa2017extraction}, code~\cite{popov2017malware}, and social media~\cite{xu2017new}. In this work, we mainly concentrate on the text document corpus. } \begin{figure}[!h] \center \includegraphics[width=1\linewidth]{figures/advancedExp/word2vecExp.pdf} \vspace{-0.20in} \caption{Word2vec example.} \label{fig:word2vec} \vspace{-0.20in} \end{figure} \cred{ The goal of word2vec is to use a vector to represent each word; the dimension of the vector is limited, but the vector can represent the meaning of the word with precise properties. As shown in Figure~\ref{fig:word2vec}, the input to the network is a one-hot encoded vector for a word; the length of the vector is equal to the number of unique words, and the vector of the index represents the corresponding word in the vocabulary. The neurons in the hidden layer represent different features, so the neuron size is equal to the size of the word vector. The output layer can be regarded as a probability vector; each element represents the probability that a word appears around the input word; hence, the probability vector length is equal to the vocabulary size. Notably, once the training has finished, we only need the word vector trained in the hidden layer, and the neuron network itself is useless; further studies can be conducted with the generated word vectors. } \cred{ TADOC can be applied in the construction of the input vector. Building the input vector from the compressed data with \texttt{CompressDirect} is more efficient than building the input vector from the original data, not only due to the smaller storage size. In real word2vec implementations, the input vector is more complex than the input vector illustration in Figure~\ref{fig:word2vec}, and words need to be encoded according to different specifications. Those coding specifications are usually related to word frequency, and TADOC can efficiently provide the required word frequencies. } \cred{ We use the word2vec in~\cite{googleWord2Vec} for validation. In this implementation, before training, word2vec has a preprocessing step, during which word2vec loads input data into the system and then encodes words. In the encoding process, Huffman coding~\cite{sharma2010compression} is used for the words; first, words are sorted according to their frequency, and then shorter codes are assigned to words with higher frequencies. In the next training step, Huffman codes are used instead of the words. As for TADOC, Sequitur-compressed data can be used as input in the preprocessing step of word2vec. Because word2vec needs the word frequency for Huffman coding, the \texttt{CompressDirect} library provides the word counts in addition to the word sequence. } \vspace{-0.20in} \subsection{Latent Dirichlet Allocation (LDA)} \label{sec:lda} \vspace{-0.10in} \cred{ LDA~\cite{blei2003latent} is a generative probabilistic model that is popular in machine learning and natural language processing, where it is used to provide the subjects of documents in a probability form. LDA is an unsupervised learning algorithm; it does not require manual labeling. The only information that users need to provide is the number of specified topics for the given documents. In addition, for each topic, LDA can provide relevant words (these words define the abstracted topic). The graphical model representation of LDA is shown in Figure~\ref{fig:lda}. } \begin{figure}[!h] \vspace{-0.20in} \center \includegraphics[width=0.9\linewidth]{figures/advancedExp/ldaExp.pdf} \vspace{-0.10in} \caption{LDA model. The parameters $\alpha$ and $\beta$ usually have default values, so only the documents and the number of specified topics are input to LDA.} \label{fig:lda} \vspace{-0.20in} \end{figure} \cred{ LDA assumes that documents are generated by latent topics, and each topic is characterized by a word distribution, which explains why a bag of words appears in a given document. The LDA model consists of five major components. The parameter $\alpha$ relates to the topic-document distribution; the topic distribution for documents, $\theta$, follows a Dirichlet distribution with parameter $\alpha$. The topic distribution for words, $Z$, follows a multinomial distribution of $\theta$. The words observed in a document, $W$, are determined by both $Z$ and $\beta$. In general, $\alpha$ and $\beta$ are corpus-level parameters, $\theta$ is a document-level variable, and $Z$ and $W$ are word-level variables that can be sampled in each document. In the training process of LDA, the posterior distribution of latent variables of $\theta$ and $Z$ are estimated given $W$, $\alpha$, and $\beta$. } \cred{ The compressed data using TADOC can be directly applied to the input preprocessing of LDA. The inputs to LDA are isolated words. LDA is based on the ``bag-of-words'' assumption, that is, the order of words in a document can be neglected. TADOC generates word counts by efficiently traversing the DAG, which means that the required input data is provided in a very effective manner. } \cred{ We use the LDA in~\cite{plda} as the evaluation platform. In this LDA implementation, the training process consists of two stages. The first stage is a preprocessing stage; the original input needs to be preprocessed into a sparse representation. The sparse representation stores each document in one line. In each line, each word and its word count are stored sequentially as <$word_i$,$count_i$>. The second stage is a training process. This stage uses the preprocessed data in the first stage and trains the probabilistic model mentioned in Section~\ref{sec:lda} to estimate parameters. In addition, the LDA implementation~\cite{plda} provides a parameter that controls the number of iterations in the training process; in our evaluation, we set this parameter to ten. } \cred{ TADOC can be applied in the first stage. The baseline version processes the original input data into the required sparse format, while the \texttt{CompressDirect} version provides the word counts in the required format directly from the compressed data. In addition, because LDA adopts a ``bag-of-words'' assumption in which word order does not need to be maintained, we can simply use the word counts in \texttt{CompressDirect} in this stage. For the second stage, the baseline and the \texttt{CompressDirect} version have the same procedure. } \vspace{-0.20in} \subsection{Other Advanced Document Analytics} \vspace{-0.10in} \cred{ TADOC can be applied to other advanced document analytics. To realize the high-level goals of advanced document analytics such as LSTM, the original raw text first needs to be converted into a vector format. }\cb{ For this purpose, word2vec can be used with TADOC, as we already demonstrated. After the conversion, these vectors have high-level usage models, } \cred{ which are independent from our technique. These independent techniques only use in-memory data structures without accessing the input raw data again, which is orthogonal to the problem we are addressing. Therefore, our technique can be used to support these advanced uses of document analytics, especially at the raw text processing stage. } \section{Evaluation} \label{sec:evaluation} \vspace{-0.10in} Using the six algorithms listed at the end of the previous section, we evaluate the efficacy of the proposed Sequitur-based document analytics for both space and time savings. The baseline implementations of the six algorithms come from existing public benchmark suites, \texttt{Sort} from HiBench~\cite{huang2011hibench} and the rest from Puma~\cite{ahmad2012puma}. We report performance in both sequential and distributed environments. For a fair comparison, the original and optimized versions are all ported to C++ for the sequential experiments and to Spark for the distributed experiments. The benefits are significant in both space savings and time savings. Compared to the default direct data processing on {\em uncompressed} data, our method speeds up the data processing by more than a factor of two in most cases, and at the same time, saves the storage and memory space by a factor of 6 to 13. After first explaining the methodology of our experimental evaluation, we next report the overall time and space savings, and then describe the benefits coming from each of the major guidelines we have described earlier in the paper. \vspace{-0.20in} \subsection{Methodology} \label{subsec:evaluationEva} \vspace{-0.10in} \noindent {\bf Evaluated Methods} We evaluate three methods for each workload-dataset combination. The ``baseline'' method processes the dataset directly, as explained at the beginning of this section. The ``CD'' method is our version using \textit{TADOC}. The input to ``CD'' is the dataset compressed using ``double compression'' (i.e., first compressed by Sequitur then compressed by Gzip). The ``CD'' method first recovers the Sequitur compression result by undoing the Gzip compression, and then processes the Sequitur-compressed data directly. The measured ``CD'' time covers all the operations. The ``gzip'' method represents existing decompression-based methods. It uses Gzip to compress the data. At processing time, it recovers the original data and processes it. \vspace{1.6mm} \noindent \textbf{Datasets} We use five datasets for evaluations, shown in Table~\ref{table:dataset}. They consist of a range of real-world documents of varying lengths, structures and content. The first three, \texttt{A, B, C}, are large datasets from Wikipedia~\cite{wikipedia}, used for tests on clusters. \texttt{Dataset D} is NSF Research Award Abstracts (NSFRAA) from UCI Machine Learning Repository~\cite{Lichman:2013}, consisting of a large number (134,631) of small files. \texttt{Dataset E} is a collection of web documents downloaded from the Wikipedia database~\cite{wikipedia}, consisting of four large files. \begin{table}[!h] \vspace{-0.20in} \centering \caption{Datasets (``size'': original uncompressed size).} \vspace{-0.10in} \resizebox{\linewidth}{!}{ \begin{tabular}{lrrrr} \hline Dataset & \multicolumn{1}{c}{Size} & \multicolumn{1}{c}{File \#} & \multicolumn{1}{c}{Rule \#} & \multicolumn{1}{c}{Vocabulary Size} \\\hline A & 50GB & 109 & 57,394,616 & 99,239,057 \\ B & 150GB & 309 & 160,891,324 & 102,552,660 \\ C & 300GB & 618 & 321,935,239 & 102,552,660 \\ D & 580MB & 134,631 & 2,771,880 & 1,864,902 \\ E & 2.1GB & 4 & 2,095,573 & 6,370,437 \\\hline \end{tabular} } \label{table:dataset} \vspace{-0.20in} \end{table} The sizes shown in Table~\ref{table:dataset} are the original dataset sizes. They become about half as large after dictionary encoding (Section~\ref{subsec:sequitur}). The data \emph{after} encoding is used for all experiments, including the baselines. \vspace{1.6mm} \noindent \textbf{Platforms} The configurations of our experimental platforms are listed in Table~\ref{configurations}. For the distributed experiments, we use the \texttt{Spark Cluster}, a 10-node cluster on Amazon EC2~\cite{amazon2010amazon}, and the three large datasets. The cluster is built with an HDFS storage system~\cite{borthakur2008hdfs}. The Spark version is 2.0.0 while the Hadoop version is 2.7.0. For the sequential experiments, we use the \texttt{Single Node} machine on the two smallest datasets. \begin{table}[!h] \centering \caption{Experimental platform configurations.} \vspace{-0.10in} \resizebox{\linewidth}{!}{ \begin{tabular}{lll} \hline Platform & Spark Cluster& Single Node \\\hline OS & Ubuntu 16.04.1 &Ubuntu 14.04.2 \\ GCC & 5.4.0 & 4.8.2 \\ Node\# & 10 & 1 \\ CPU &Intel E5-2676v3 & Intel i7-4790 \\ Cores/Machine & 2 & 4 \\ Frequency & 2.40GHz & 3.60GHz \\ MemorySize/Machine & 8GB & 16GB \\\hline \end{tabular} } \label{configurations} \end{table} \vspace{-0.30in} \subsection{Time Savings} \label{sec:speedups} \vspace{-0.10in} \subsubsection{Overall Speedups} \label{sec:speedupDistributed} \vspace{-0.10in} Figure~\ref{fig:largerDataSets} reports the speedups that the different methods obtain compared to the default method on the three large datasets \texttt{A, B, C}, all run on the Spark Cluster. \begin{figure}[!h] \vspace{-0.10in} \centering \includegraphics[width=1\linewidth]{figures/evaluation/cdPerformanceRes/large2/res.pdf} \vspace{-0.15in} \caption{Performance of different methods on large datasets running on the Spark Cluster, normalized to the performance of the baseline method.} \label{fig:largerDataSets} \vspace{-0.20in} \end{figure} The size of a file in these datasets, in most cases, ranges from 200MB to 1GB. In the implementations of all methods, each file's data form a processing unit (an RDD in Spark), resulting in coarse-grained parallelism. In both the baseline and \texttt{CD} methods, each machine in the cluster automatically grabs the to-be-processed RDDs one after another, processes them, and finally merges the results. The two versions differ in whether an RDD is formed on the uncompressed or compressed data, and how an RDD is processed. Because the total size of the uncompressed datasets \texttt{B} and \texttt{C} exceeds the aggregate memory of the cluster, a newly-loaded RDD reuses the memory of an already-processed RDD. \texttt{Word count} and \texttt{sort} use the preorder traversal, \texttt{inverted index} and \texttt{term vector} use the postorder traversal, and \texttt{sequence count} and \texttt{ranked inverted index} use the depth-first traversal and the two-level table design of Guideline IV in Section~\ref{sec:treatment2orderSen}. Because the three datasets all consists of very large files, the data-sensitivity of order selection does not affect our methods of processing.\footnote{ Section~\ref{sec:detailBen} shows the sensitivity on the other two datasets, D and E.} All the programs use the coarse-grained parallelization. For the coarsening optimization, \texttt{word count}, \texttt{sort}, \texttt{inverted index}, and \texttt{term vector} use \emph{edge merging}, because they do not need to keep the order of words. \texttt{Sequence count} and \texttt{ranked inverted index} use \emph{node coarsening}, because node coarsening reduces the number of substrings spanning across nodes, thereby increasing the reuse of local data. We empirically set 100 as the node coarsening threshold such that each node contains at least 100 items (subrules and words) after coarsening. The average speedups with our \texttt{CD} method are \ZavgSpeedupAadd{}X, \ZavgSpeedupBadd{}X, and \ZavgSpeedupCadd{}X on the three datasets. \texttt{Inverted index} and \texttt{term vector} show the largest speedups. These two programs are both unit sensitive, producing analytics results for each file. \texttt{CD} creates an RDD partition (the main data structure used in Spark) for the compressed results of each file, but the baseline method cannot because some of the original files exceed the size limit of an RDD partition in Spark---further partitioning of the files into segments and merging of the results incur some large overhead. Programs \texttt{word count} and \texttt{sort} are neither unit sensitive nor order sensitive. \texttt{Sort} has some extra code irrelevant to the \texttt{CD} optimizations, and hence shows a smaller overall speedup. Programs \texttt{sequence count} and \texttt{ranked inverted index} are both about word sequences in each file; the amount of redundant computations to save is the smallest among all the programs. \cred{ The \texttt{gzip} method incurs only 1-14\% \emph{slowdown} due to the extra decompression time, and TADOC with double compression can still achieve significant performance benefits compared to the original version without compression, which proves the effectiveness of our double compression techniques. } \iffalse In contrast to the large speedups obtained with the \texttt{CD} method, the \texttt{gzip} method provides 1-14\% \emph{slowdown} due to the extra decompression time. The decompression time could be partially hidden if a background thread does the decompression while the main thread processes the already-decompressed parts. However, doing so does \emph{not} make the \texttt{gzip} method faster than the baseline as the data processing part is still the same as that in the baseline method. \fi Figure~\ref{fig:singleNode} reports the overall speedups on the two smaller datasets on the single-node server. \texttt{CD} provides significant speedups on them as well, while the \texttt{gzip} method causes even more slowdown. The reason is that the computation time on the small datasets is little and hence the decompression overhead has a more dominant effect on the overall time. We discuss the time breakdowns in more detail next. \begin{figure}[!h] \vspace{-0.15in} \center \includegraphics[width=1\linewidth]{figures/evaluation/zwiftPerformanceRes/sequential2/sequential.pdf} \vspace{-0.15in} \caption{Performance of different methods normalized to the baseline method on the Single Node machine.} \label{fig:singleNode} \vspace{-0.20in} \end{figure} \cred{ \texttt{CD} on the single node server can also benefit from parallelism. With coarse-grained parallelism, the computation time can be further reduced. We implement a parallel \texttt{CD} version, and its performance results are shown in Figure~\ref{fig:parallelVersion}. For comparison, we also integrate the technique of coarse-grained parallelism into \texttt{gzip}. With coarse-grained parallelism, both \texttt{gzip} and \texttt{CD} gain performance benefits, \ and the average performance speedup of \texttt{CD} reaches \parallelAVG{}. } \begin{figure}[!h] \vspace{-0.20in} \center \includegraphics[width=1\linewidth]{figures/evaluation/parallelPerformanceJournal/res.pdf} \vspace{-0.15in} \caption{\cred{ Parallel performance of different methods normalized to the baseline method on the Single Node machine.} } \label{fig:parallelVersion} \vspace{-0.25in} \end{figure} \vspace{-0.20in} \subsubsection{Time Breakdowns} \label{sec:timebd} \vspace{-0.10in} The right eight columns in Table~\ref{table:sequentialPerformance} report the time breakdowns on datasets D and C, the smallest and the largest ones. Execution on D happens on the Single-Node server and that on C on the Spark Cluster. The time breakdown shows that \texttt{CD} experiences a much shorter I/O time than \texttt{gzip} does. This is because \texttt{CD} needs to load only the compressed data into memory while \texttt{gzip} needs to load the decompressed data. Although the data loading time of \textbf{CD} is shorter than that of the \textbf{gzip} method, the data loading time only occupies a small proportion of the whole execution time. The major benefits of TADOC come from the effective data reuse. \begin{table*}[!h] \centering \caption{Time breakdown (seconds) and memory savings.} \vspace{-0.10in} \label{table:sequentialPerformance} \resizebox{\linewidth}{!}{ \begin{tabular}{llrcrrrrrrrr} \hline & & \multicolumn{2}{c}{Memory} & \multicolumn{2}{c}{I/O Time} & \multicolumn{2}{c}{Init Time} & \multicolumn{2}{c}{Compute Time} & \multicolumn{2}{c}{Total Time} \\ \hline & Benchmark & gzip (MB) & \multicolumn{1}{c|}{CD savings (\%)} & \multicolumn{1}{c}{gzip} & \multicolumn{1}{c|}{CD} & \multicolumn{1}{c}{gzip} & \multicolumn{1}{c|}{CD} & \multicolumn{1}{c}{gzip} & \multicolumn{1}{c|}{CD} & \multicolumn{1}{c}{gzip} & \multicolumn{1}{c}{CD} \\ \cline{2-12} & word count & 1157.0 & \multicolumn{1}{c|}{88.8} & 4.0 & \multicolumn{1}{r|}{2.6} & 14.1 & \multicolumn{1}{r|}{4.5} & 0.4 & \multicolumn{1}{r|}{0.3} & 18.5 & 7.4 \\ \multirow{1}{*}{dataset D} & sort & 1143.0 & \multicolumn{1}{c|}{88.7} & 4.0 & \multicolumn{1}{r|}{2.6} & 15.0 & \multicolumn{1}{r|}{6.1} & 0.4 & \multicolumn{1}{r|}{0.3} & 19.4 & 8.9 \\ data size: 0.9 GB & inverted index & 1264.7 & \multicolumn{1}{c|}{79.5} & 4.0 & \multicolumn{1}{r|}{2.6} & 13.4 & \multicolumn{1}{r|}{4.0} & 11.1 & \multicolumn{1}{r|}{6.2} & 28.5 & 12.8 \\ CD size: 132 MB & term vector & 1272.1 & \multicolumn{1}{c|}{71.0} & 4.0 & \multicolumn{1}{r|}{2.6} & 13.3 & \multicolumn{1}{r|}{7.4} & 4.1 & \multicolumn{1}{r|}{3.3} & 21.4 & 13.2 \\ storage saving: 84.7\% & sequence count & 1734.3 & \multicolumn{1}{c|}{47.3} & 4.0 & \multicolumn{1}{r|}{2.6} & 13.8 & \multicolumn{1}{r|}{4.1} & 50.4 & \multicolumn{1}{r|}{58.3} & 68.1 & 65.0 \\ & ranked inverted index & 1734.3 & \multicolumn{1}{c|}{47.3} & 4.0 & \multicolumn{1}{r|}{2.6} & 13.9 & \multicolumn{1}{r|}{4.4} & 138.7 & \multicolumn{1}{r|}{141.5} & 156.6 & 148.4 \\ \hline & word count & 177920.0 & \multicolumn{1}{c|}{89.5} & 571.5 & \multicolumn{1}{r|}{131.5} & 3120.0 & \multicolumn{1}{r|}{840.0} & 900.0 & \multicolumn{1}{r|}{780.0} & 4591.5 & 1751.5 \\ \multirow{1}{*}{dataset C} & sort & 177920.0 & \multicolumn{1}{c|}{89.5} & 511.5 & \multicolumn{1}{r|}{131.5} & 2940.0 & \multicolumn{1}{r|}{780.0} & 1500.0 & \multicolumn{1}{r|}{1200.0} & 4951.5 & 2111.5 \\ data size: 144.4 GB & inverted index & 180638.0 & \multicolumn{1}{c|}{88.1} & 596.1 & \multicolumn{1}{r|}{120.0} & 4140.0 & \multicolumn{1}{r|}{600.0} & 1380.0 & \multicolumn{1}{r|}{480.0} & 6116.1 & 1200.0 \\ CD size: 11 GB & term vector & 184138.0 & \multicolumn{1}{c|}{86.5} & 571.5 & \multicolumn{1}{r|}{131.5} & 3540.0 & \multicolumn{1}{r|}{660.0} & 1560.0 & \multicolumn{1}{r|}{780.0} & 5671.5 & 1571.5 \\ storage saving: 92.4\% & sequence count & 205117.8 & \multicolumn{1}{c|}{77.6} & 672.9 & \multicolumn{1}{r|}{320.0} & 5820.0 & \multicolumn{1}{r|}{3780.0} & 1380.0 & \multicolumn{1}{r|}{1500.0} & 7872.9 & 5600.0 \\ & ranked inverted index & 205117.8 & \multicolumn{1}{c|}{77.6} & 672.9 & \multicolumn{1}{r|}{260.0} & 7020.0 & \multicolumn{1}{r|}{5280.0} & 3600.0 & \multicolumn{1}{r|}{3480.0} & 11292.9 & 9020.0 \\ \hline \end{tabular} } \vspace{-0.15in} \end{table*} Even if I/O time is not counted, \texttt{CD} still outperforms \texttt{gzip} substantially. This is reflected in \texttt{CD}'s shorter times in all other parts of the time breakdowns. For instance, \texttt{CD}'s initialization step takes about 1/3 to 1/2 of that of \texttt{gzip}. This is because \texttt{gzip} requires significant time to produce the completely decompressed data. In most cases, the actual data processing part of \texttt{CD} (i.e., the ``compute time'' column in Table~\ref{table:sequentialPerformance}) is also much shorter than that of \texttt{gzip}, thanks to \texttt{CD}'s avoidance of the repeated processing of content that appears \emph{multiple} times in the input datasets.\footnote{The processing time in \texttt{gzip} is the same as in the baseline method since they both process the decompressed data. } The exceptions are \texttt{sequence count} and \texttt{ranked inverted index} on dataset \texttt{D}. These two programs are both unit and order sensitive. Dataset \texttt{D}, which consists of many small files, does \emph{not} have many repeated word sequences, so obtaining performance improvement on it is even harder. However, even for these two extreme cases, the overall time of \texttt{CD} is still shorter than that of \texttt{gzip} because of \texttt{CD}'s substantial savings in the I/O and initialization steps. We conclude that our \texttt{CD} method greatly reduces execution time on many workloads and datasets. \vspace{-0.20in} \subsection{Space Savings} \label{sec:space} \vspace{-0.10in} Table~\ref{table:sec6compression} reports the compression ratio, which is defined as {\it size(original)/size(compressed)}. In all methods that use compression, the datasets are already dictionary-encoded. Compression methods apply to both the datasets and the dictionary. The CD- row shows the compression ratios from Sequitur alone. Sequitur's compression ratio is 2.3--3.8, considerably smaller than the ratios from Gzip. However, with the double compression technique, \texttt{CD}'s compression ratio is boosted to 6.5--14.1, which is greater than the Gzip ratios. Gzip results \emph{cannot} be used for direct data processing, but Sequitur results can, which enables \texttt{CD} to bring significant time savings as well, as reported in Section~\ref{sec:speedups}. \begin{table}[!h] \centering \caption{Compression ratios.} \vspace{-0.10in} \begin{tabular}{l|lllll|l}\hline & \multicolumn{5}{c|}{Dataset} & \\ Version & A & B & C & D & E & AVG \\ \hline default & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 \\ gzip & 9.3 & 8.9 & 8.5 & 5.9 & 8.9 & 8.3 \\ CD & 14.1 & 13.3 & 13.1 & 6.5 & 11.9 & 11.8 \\ CD- & 3.1 & 3.2 & 3.8 & 2.3 & 2.8 & 3.0 \\\hline \end{tabular}\\ \scriptsize{CD-: Sequitur without double compression.} \label{table:sec6compression} \end{table} The ``Memory'' columns in Table~\ref{table:sequentialPerformance} report the memory savings by ``\texttt{CD}'' compared to the memory usage by the \texttt{gzip} method. Because \texttt{CD} loads and processes much less data, it reduces memory usage by \memSavingAVG{}. This benefit is valuable considering the large pressure modern analytics pose to the memory space of modern machines. The smaller memory footprint also helps \texttt{CD} to reduce memory access times. \vspace{-0.20in} \subsection{\cred{Evaluation of Advanced Document Analytics}} \vspace{-0.10in} \subsubsection{\cred{Time Benefits}} \vspace{-0.10in} \cb{ In this section, we measure the performance of TADOC in the four applications described in Section~\ref{sec:advanced}. We show the execution time benefits in Figure~\ref{fig:advancedSpeedup}. As introduced in Section~\ref{subsec:evaluationEva}, the baseline is the execution time of the original implementation, which directly processes the original non-compressed dataset. \texttt{gzip} uses Gzip to compress the original data, and during processing time, it needs to decompress the compressed data before data processing. \texttt{CD} is the version using TADOC, which also includes a gunzip stage. We use the speedup over the baseline as the metric to quantify time benefits. The \texttt{gzip} version suffers from data decompression overheads, so we focus on the analysis of the \texttt{CD} version of TADOC. } \begin{figure}[!h] \vspace{-0.15in} \center \includegraphics[width=1\linewidth]{figures/evaluation/advanced/res.pdf} \vspace{-0.15in} \caption{ \cred{ Performance of different methods normalized to the baseline of the advanced document analytics applications.} } \label{fig:advancedSpeedup} \vspace{-0.35in} \end{figure} \cred{ In Figure~\ref{fig:advancedSpeedup}, \texttt{CD} yields 1.2X speedup on average over the baseline. Among the four applications, TFIDF experiences a performance benefit greater than 30\%. The reason for this result is that these applications can be divided into two stages, namely, data preprocessing and processing, and TADOC is mainly used in the data preprocessing stage; the preprocessing stage may account for different proportions of the total execution time. The time breakdown is shown in Table~\ref{tbl:advancedBreakdown}, where the last column represents the proportion of preprocessing time. Data preprocessing accounts for 44.6\% (\texttt{D}) and 64.7\% (\texttt{E}) of execution time for TFIDF. For word co-occurrence, data preprocessing accounts for 35.4\% (\texttt{D}) and 21.3\% (\texttt{E}) of execution time. The preprocessing proportion of these two applications is high compared to that of the other applications, and additionally, the decompression process of \texttt{CD} is shorter than that of \texttt{gzip}. Therefore, TFIDF and word co-occurrence have relatively high performance speedups. } \begin{table}[!h] \centering \caption{\cred{Time breakdown for advanced applications.}} \vspace{-0.10in} \resizebox{\linewidth}{!}{% \begin{tabular}{ccccc} \hline & Benchmark & Preprocessing & Total & Occupancy \\ & & (s) & Time (s) & (\%) \\ \hline D & TFIDF & 5.6 & 12.6 & 44.6 \\ & wordCoOccur & 9.6 & 27.2 & 35.4 \\ & LDA & 20.3 & 448.9 & 4.5 \\ & word2vec & 7.0 & 2082.6 & 0.3 \\ \hline E & TFIDF & 7.4 & 11.5 & 64.7 \\ & wordCoOccur & 5.5 & 25.9 & 21.3 \\ & LDA & 14.9 & 502.9 & 3.0 \\ & word2vec & 7.0 & 2864.0 & 0.2 \\ \hline \end{tabular}% } \label{tbl:advancedBreakdown} \vspace{-0.20in} \end{table} \cred{ In general, when the data preprocessing and decompression stages account for a high proportion of the total execution time, TADOC has significant performance benefits; otherwise, the execution time of TADOC is lower than but closer to the original execution time. } \subsubsection{ \cred{ Storage and Memory Benefits }} \vspace{-0.15in} \cb{ We evaluate the storage and memory benefits of TADOC on advanced analytics workloads. } \cred{ Storage savings are the same as those in the results in Section~\ref{sec:space}. Compared to the original datasets, \texttt{CD} reaches 6.5 and 11.9 compression ratios for datasets \texttt{D} and \texttt{E}, respectively, which implies that TADOC brings more than 90\% storage reduction. } \cred{ Memory savings are shown in Table~\ref{tbl:advancedMem} and range from 0.6\% to 76.2\%. They vary considerably because different applications use different auxiliary data structures. For example, for TFIDF, the algorithm is simple, and we only need to develop data structures for storing the TF and IDF. In contrast, for LDA, although the ``bag-of-words'' paradigm used in preprocess relies on only word frequencies, } the training stage involves \cb{many intermediate data} structures in model construction, which decreases TADOC's memory benefits. \begin{table}[!h] \vspace{-0.2in} \caption{\cred{Memory savings for advanced applications.}} \vspace{-0.1in} \centering \resizebox{\linewidth}{!}{% \begin{tabular}{cccc} \hline & Benchmark & Original (MB) & Memory Savings (\%) \\ \hline D & TFIDF & 1617.0 & 60.5 \\ & wordCoOccur & 1679.0 & 17.7 \\ & LDA & 2552.4 & 0.6 \\ & word2vec & 772.3 & 17.1 \\ \hline E & TFIDF & 1459.4 & 76.2 \\ & wordCoOccur & 1881.0 & 15.2 \\ & LDA & 3883.6 & 3.4 \\ & word2vec & 911.0 & 18.4 \\ \hline \end{tabular}% } \label{tbl:advancedMem} \vspace{-0.2in} \end{table} \vspace{-0.20in} \subsection{When Inverted Index is Used} \label{sec:cdWithInvertedIdx} \vspace{-0.10in} In some cases, practitioners store an inverted index~\cite{zhang2001supporting,whang2002inverted,mitsui1993information} with the original dataset. Doing so helps accelerate some analytics tasks. This approach can be combined with TADOC by attaching an inverted index of the original documents with the Sequitur compression result. We call these two schemes Original+index and CD+index. For tasks where inverted index can be used (e.g., the first four benchmarks), some intermediate results can be obtained directly from inverted index to save time. For the other tasks (e.g., \texttt{sequence count}, \texttt{ranked inverted index}), Original+index has to fall back to the original text for analysis, and CD+index provides 1.2X-1.6X speedup due to its direct processing on the Sequitur DAG. Besides its performance benefits, CD+index saves about 90\% space over the Original+index as Table~\ref{tbl:spaceCost} reports. \begin{table}[!h] \vspace{-0.20in} \centering \caption{Space usage of the original datasets and CD with inverted-index.} \vspace{-0.10in} \label{tbl:spaceCost} \resizebox{\linewidth}{!}{ \begin{tabular}{ccrrrrr} \hline Usage & Dataset & \multicolumn{1}{c}{A} & \multicolumn{1}{c}{B} & \multicolumn{1}{c}{C} & \multicolumn{1}{c}{D} & \multicolumn{1}{c}{E} \\ \hline Memory & Original+Index & 32,455 & 92,234 & 184,469 & 1,387 & 1,406 \\ (MB) & CD+Index & 3,693 & 10,405 & 20,806 & 413 & 197 \\ \hline Storage & Original+Index & 37,990 & 78,438 & 154,214 & 1,115 & 1,559 \\ (MB) & CD+Index & 2,873 & 6,066 & 11,965 & 211 & 140 \\ \hline \end{tabular} \vspace{-0.20in} } \end{table} \vspace{-0.40in} \subsection{More Detailed Benefits} \label{sec:detailBen} \vspace{-0.10in} In this part, we briefly report the benefits coming from each of the major guidelines we described in Section~\ref{sec:solutions}. The benefits of {\em adaptive traversal order} (Guideline I and II) are most prominent on benchmarks \texttt{inverted index} and \texttt{term vector}. Using adaptive traversal order, the \texttt{CD} method selects postorder traversal when processing dataset \texttt{D} and preorder on datasets \texttt{A, B, C, E}. We show the performance of both preorder and postorder traversals for \texttt{inverted index} and \texttt{term vector} in Figure~\ref{fig:preposttermvector}. Using decision trees, \texttt{CD} successfully selects the better traversal order for each of the datasets. For instance, on \texttt{inverted index}, \texttt{CD} picks postorder on dataset \texttt{D}, which outperforms preorder by 1.6X, and it picks preorder on dataset \texttt{E}, which outperforms postorder by 1.3X. \begin{figure}[!h] \vspace{-0.2in} \centering \includegraphics[width=1\linewidth]{figures/evaluation/fusion2/res.pdf} \vspace{-0.15in} \caption{Performance of preorder and postorder for \texttt{inverted index} and \texttt{term vector}.} \label{fig:preposttermvector} \vspace{-0.20in} \end{figure} {\em Double compression} (Guideline VI) provides substantial space benefits as we have discussed in Section~\ref{sec:forCompression}. However, since double compression needs to recover the Sequitur results from the compressed data before processing, it incurs some overhead. Our experiments show that this overhead is outweighed by the overall time benefits of \texttt{CD}. We tried to implement a fine-grained parallel version of \texttt{CD} for benchmark \texttt{word count}. It breaks the CFG into a number of partitions and uses multiple threads to process each partition in parallel. Even though this version took us several times the effort we spent on the {\em coarse-grained parallel} version (Guideline III), its performance was substantially worse (e.g., 50\% slower on dataset \texttt{D}). {\em Double-layered bitmap} (Guideline V) helps \emph{preorder} processing on datasets that contain many (>800) files of medium size (>2860 words per Figure~\ref{fig:decisionTree}.) Among the 60 datasets involved in the decision tree experiments in Section~\ref{sec:order}, 10 of them works best with double-layered bitmap based preorder. They get 2\%-10\% performance benefits compared to single-layered bitmap based preorder traversal. Besides double-layered bitmap, we experiment with other alternative data structures, including \emph{red-black tree}~\cite{cormen2009introduction}, \emph{hash set}~\cite{cormen2009introduction}, and \emph{B-tree}~\cite{btreeImplementation}. Table~\ref{comparison2lev} reports the performance of preorder \texttt{inverted index} when these data structures are used in place of double-layered bitmap in each of the DAG node. The experiment uses dataset D and the Single-Node server in Table~\ref{configurations}. Double-layered bitmap is fast to construct as it uses mainly bit operations. The query time for double-layered bitmap has a complexity of $O(1)$. Some of the alternative data structures (e.g., B-tree) yield a shorter processing time, but suffer a longer construction process (i.e., initialization in Table~\ref{comparison2lev}). \begin{table}[!h] \vspace{-0.2in} \centering \caption{Performance and time breakdown of different data structure achieves for inverted-index.} \vspace{-0.10in} \label{comparison2lev} \resizebox{\linewidth}{!}{ \begin{tabular}{cccc} \hline Data Structure & Initialization (s) & Computation (s) & Total (s) \\ \hline 2LevBitMap & 14.96 & 3.08 & \bf{18.04} \\ redBlackTree & 39.33 & 3.56 & \bf{42.89} \\ hash set & 25.34 & 4.32 & \bf{29.67} \\ B-tree & 18.87 & 2.29 & \bf{21.16} \\ \hline \end{tabular} } \vspace{-0.25in} \end{table} Finally, \emph{coarsening} (Guideline VI) shows clear benefits for \texttt{CD} on benchmarks \texttt{ranked inverted index} and \texttt{sequence count}. For instance, compared to no coarsening, it enables the CD-based \texttt{ranked inverted index} program to achieve 5\% extra performance improvement on dataset \texttt{E}. The benefits of Guideline IV has been reported in Section~\ref{sec:treatment2orderSen} and are hence omitted here. \vspace{-0.2in} \subsection{Compression Time and Applicability} \label{sec:compressTimeApp} \vspace{-0.10in} \cred{ The time taken to compress the datasets using sequential Sequitur ranges from 10 minutes to over 20 hours. Using a parallel or distributed Sequitur with accelerators (e.g., as in~\cite{DBLP:conf/asplos/BoroumandGKASTK18,DBLP:conf/micro/PekhimenkoSKXMGKM13}) can potentially shorten the compression time substantially. Note that this article focuses on how to use the compressed data to support various analytics tasks such as word count; we do not further discuss the compression process. } \cred{ In general, our technique is designed for document analytics that can be expressed as a DAG traversal-based problem on datasets that do \emph{not} change frequently. Moreover, our discussion has focused on applications that normally require scanning the entire dataset, as illustrated by the analytics problems used in our evaluation. It is not designed for regular expression queries or scenarios where data frequently changes. We note that the proposed technique can also benefit advanced document analytics. The initial part of many advanced document analytics is to load documents and derive some representations (e.g., natural language understanding) to characterize the documents such that later processing can efficiently work on these representations. One example is email classification, where TADOC can help to accelerate the construction of the feature vectors (e.g., word frequency vectors) required for classification. For the applications that cannot be expressed as a DAG traversal-based problem, TADOC can be used as a storage technique. For example, to compute Levenshtein distance between a pair of words~\cite{levenshtein1966binary}, the required words can be extracted from the compressed data~\cite{9101809}, and then, the application of Levenshtein edit distance can be performed on the extracted words. } \iffalse The time to compress the datasets using sequential Sequitur ranges from 10 minutes to over 20 hours. When double compression is employed, Sequitur and Gzip take 94\% and 6\% of the compression time on average. Using parallel or distributed Sequitur with accelerators can potentially shorten the compression time substantially. We repeat that our technique is designed for datasets that are \emph{repeatedly used by many users}. For them, compression time is \emph{not} a main concern as the compression results can be used for many times by different users for various analytics tasks. Our discussion has focused on applications that normally require scanning the entire dataset. In general, our method is applicable if the text analytics problem can be turned into a DAG traversal-based problem, as illustrated by the six analytics problems used in our evaluation. Another type of common tasks involve queries that require random accesses to some locations in the dataset. Such tasks are much simpler to support, e.g., by adding some appropriate index to the Sequitur results. Such tasks are already be supported by other recent techniques (e.g., Succinct~\cite{agarwal2015succinct}), and hence are not the focus of our paper. In general, our technique is designed for document analytics that can be expressed as a DAG traversal-based problem on datasets that do \emph{not} change frequently. It is \emph{not} designed for regular expression queries or scenarios where data frequently changes. We note that the proposed technique can benefit advanced document analytics as well. The initial part of many advanced document analytics is to load documents and derive some representations (e.g., \emph{natural language understanding}) to characterize the documents, such that later processing can efficiently work on these representations. An example is email classification, where TADOC can help accelerate the construction of the feature vectors (e.g., word frequency vectors) required for classification. \fi \section{Related Work} \label{sec:related} \vspace{-0.10in} To our knowledge, this is the first work to enable \emph{efficient} direct document analytics on compressed data. The work closest to \texttt{CompressDirect} is Succinct~\cite{agarwal2015succinct,khandelwal2016blowfish}, which enables efficient queries on compressed data in a database. These two techniques are complementary to each other. Succinct is based on index and suffix array~\cite{navarro2016compact}, an approach employed in other works as well~\cite{agarwal2015succinct,burrows1994block,ferragina2005indexing,grossi2004indexing,ferragina2009compressed}. \texttt{CompressDirect} and these previous studies differ in both their applicability and main techniques. First, Succinct is mainly for the database domain while \texttt{CompressDirect} is for general document analytics. Succinct is designed mainly for search and random access of local queries. Even though it could possibly be made to work on some of the general document analytics tasks, its efficiency is much less than \texttt{CompressDirect} on such tasks as those tasks are not its main targets. For instance, \texttt{word count} on dataset \texttt{E} takes about 230 seconds with Succinct, but only 10.3 seconds with \texttt{CompressDirect}, on the single node machine in Table~\ref{configurations}. Second, Succinct and \texttt{CompressDirect} use different compression methods and employ different inner storage structures. Succinct compresses data in a flat manner, while \texttt{CompressDirect} uses Sequitur to create a DAG-like storage structure. The DAG-like structure allows \texttt{CompressDirect} to efficiently perform general computations for all items in the documents, even in the presence of various challenges from files or word sequences, as described in Section~\ref{sec:complexity}. \cred{ Note that Sequitur can be replaced by other context-free compression techniques. For example, Re-Pair, proposed by Larsson and Moffat~\cite{larsson2000off}, is an offline dictionary-based compression algorithm. Re-Pair can be regarded as a compromise in terms of compression time and compression ratio, which could be a potential alternative compression algorithm. Larson and Moffat~\cite{reparurl} offer a high-quality Re-Pair implementation. Ga{\'n}czorz and others~\cite{ganczorz2017improvements} further improve the Re-Pair grammar compressor by involving penalties. } \iffalse \cred{ Re-Pair, proposed by Larsson and Moffat~\cite{larsson2000off}, which is an offline dictionary-based compression algorithm, could be a potential alternative compression algorithm. Larson and Moffat~\cite{reparurl} offered a high-quality Re-Pair implementation. Ga{\'n}czorz and others~\cite{ganczorz2017improvements} further improved the Re-Pair grammar compressor by involving penalties; the improved Re-Pair can generate higher compression ratio. } \fi \cred{ Traditional approaches to compression-based analytics use indexes, suffix arrays, and suffix trees~\cite{navarro2016compact,agarwal2015succinct,burrows1994block,ferragina2005indexing,grossi2004indexing,ferragina2009compressed,farruggia2014bicriteria,ferragina2009bit,ferragina2009compressed,gog2014theory}. Suffix trees~\cite{navarro2016compact,sadakane2007compressed} are traditional compact data structures; they consume less storage space while enabling analytics on compressed data. However, research~\cite{hon2004practical,kurtz1999reducing} shows that optimized representations consume larger memory even more than the size of the input. Burrows-Wheeler Transform~\cite{ferragina2005indexing,burrows1994block} and suffix arrays~\cite{manber1993suffix} are milestones in the development of compact representations, but experiments~\cite{hon2004practical} still show that they cannot solve the large memory consumption issue. FM-indexes~\cite{wikipediaFMIndex,ferragina2000opportunistic,ferragina2001experimental,ferragina2001experimental2,ferragina2005indexing} and Compressed Suffix Array~\cite{grossi2003high,grossi2005compressed,sadakane2000compressed,sadakane2002succinct,sadakane2003new} are two efficient alternatives that further reduce the memory space consumption, and, based on these technologies, Agarwal and others propose Succinct~\cite{agarwal2015succinct}. Our method, TADOC, is different from these methods; we provide a grammar-based approach, which provides new insight to the domain of compression-based data analytics. } \cred{ There are many works on grammar compression and operations on grammar-encoded strings~\cite{rytter2004grammar,charikar2005smallest,gagie2012faster,bille2015random,bille2015finger,brisaboa2019gract,ganardi2019balancing,takabatake2017space}. Rytter~\cite{rytter2004grammar} survey the complexity issues involved in grammar compression, LZ-Encodings, and string algorithms. Charikar and others~\cite{charikar2005smallest} study the limit of the smallest context-free grammar to generate a given string and analyze the bound approximation ratios for well-known grammar-based compression algorithms, including Sequitur. Gagie and others~\cite{gagie2012faster} develop a novel grammar-based self-indexing method for highly-repetitive strings such as DNA sequences. Bille and others~\cite{bille2015random} study how to perform random access to grammar-compressed data. SOLCA~\cite{takabatake2017space} is a novel fully-online grammar compression algorithm that targets online use cases. } \iffalse \cred{ Currently, there are many works about grammar compression and operations on grammar-encoded strings. Rytter~\cite{rytter2004grammar} surveyed the complexity issues among grammar compression, LZ-Encodings, and string algorithms. Charikar and others~\cite{charikar2005smallest} studied the limit of the smallest context-free grammar to generate a given string, and analyzed the bound approximation ratios for well-known grammar-based compression algorithms including Sequitur. Gagie and others~\cite{gagie2012faster} developed a novel grammar-based self-indexing for highly repetitive strings such as DNA sequences. Bille and others~\cite{bille2015random} studied how to perform random access to grammar-compressed data. Then, Bille and others~\cite{bille2015finger} further explored the random access with \emph{finger search} property, which means that a random access depends on the distance between a index (\emph{finger}) and an index. Brisaboa and others~\cite{brisaboa2019gract} proposed GraCT, a grammar-based compssed index, to utilize the spatio-temporal properties for trajectory data. Ganardi and others~\cite{ganardi2019balancing} solved an open problem that, for a context-free grammar whose size is $m$ and can produce string $w$ of length $n$, the grammar can be transformed to a context-free grammar for $w$ whose size is $O(m)$ and $O$(log$n$)-depth derivation tree. } \cred{ SOLCA~\cite{takabatake2017space} is a novel fully-online grammar compression algorithm, which targets online situations. } \fi \cred{ There is a large body of literature on inverted index compression. Petri and Moffat~\cite{petri2018compact} explore general-purpose compression tools for compact inverted index storage. Moffat and Petri~\cite{moffat2018index} apply two-dimensional contexts and the byte-aligned entropy coding of asymmetric numeral systems to index compression. Pibiri and others~\cite{pibiri2019fast} develop a fast dictionary-based compression approach, DINT, for inverted indexes. Pibiri and Venturini~\cite{pibiri2019techniques} survey the encoding algorithms for inverted index, including single integers, a sorted list of integers, and the inverted index. Pibiri and others~\cite{pibiri2020compressed} propose compressed indexes for fast searching of large RDF datasets. Oosterhuis and others~\cite{oosterhuis2018potential} apply the recursive graph bisection in document reordering, which is an essential preprocessing phase in building indexes. Furthermore, Mackenzie and others~\cite{mackenzie2019compressing} use machine learned models to replace common index data structures. These works mainly consider how to compress the inverted index. Different from inverted index compression, TADOC focuses on how to perform analytics directly on compressed data without decompression, such as building inverted indexes directly on compressed data. } \iffalse \cred{ Moreover, there is a huge literature on inverted index compression. Petri and Moffat~\cite{petri2018compact} explored general-purpose compression tools for compact inverted index storage. Moffat and Petri~\cite{moffat2018index} applied two-dimensional contexts and the byte-aligned entropy coding of asymmetric numeral systems to index compression. Pibiri and others~\cite{pibiri2019fast} developed a fast dictionary-based compression approach, DINT, for inverted indexes. Pibiri and Venturini~\cite{pibiri2019techniques} surveyed the encoding algorithms for inverted index, including single integers, sorted list of intergers, and the whole inverted index. Pibiri and others~\cite{pibiri2020compressed} proposed compressed indexes for fast search of large RDF datasets. Oosterhuis and others~\cite{oosterhuis2018potential} applied the recursive graph bisection in document reordering, which is an essential preprocessing phase in building indexes. Furthermore, Mackenzie and others~\cite{mackenzie2019compressing} used machine learned models to replace common inindex data structures. These works mainly considers how to compress the invertec index. Different from the inverted index compression, TADOC focuses on how to perform analytics directly on compressed data without decompression, such as building inverted indexes directly on compressed data. } \fi \iffalse rang TKDE Other prior work tries to enable query processing over encrypted data~\cite{tu2013processing} for security. They do not detect or avoid processing repeated elements in documents. In storage systems, deduplication is a technique used for minimizing the storage of repeated contents~\cite{guo2011building,monge1996field,navarro2001guided}. Since deduplication is a technique that works only at the storage level, it does \emph{not} help document analytics to avoid repeatedly processing the content. For space savings, \texttt{CompressDirect} and deduplication work at two different computing layers, and are hence complementary to each other, applicable together. When we integrate multiple data sources, {\em data cleaning} can be used to detect and remove some redundant data present in different sources~\cite{rahm2000data}. Recent work~\cite{ding2017generalizations} eliminates redundant computations in document clustering and top-K document retrieval through the application of triangle inequality. However, none of these tasks compress data or support analytics on compressed data. \fi \cred{ Since its development~\cite{nevill1997compression,nevill1997identifying,nevill1997linear}, Sequitur has been applied to various tasks, including program and data pattern analysis~\cite{chilimbi2001efficient,chilimbi2002dynamic,larus1999whole,lau2005motivation,law2003whole,lin2005supporting,walkinshaw2010using}. Lau and others~\cite{lau2005motivation} use Sequitur in code analysis to search some program patterns. Chilimbi~\cite{chilimbi2001efficient} uses Sequitur as a representation to quantify and exploit data reference locality for program optimization. Larus~\cite{larus1999whole} proposes an approach called whole program paths (WPP), which leverages Sequitur to capture and represent dynamically executed control flow. Law and others~\cite{law2003whole} propose a whole program path-based dynamic impact analysis and related compression based on Sequitur. Chilimbi and others~\cite{chilimbi2002dynamic} use Sequitur for fast detection of hot data streams. Walkinshaw and others~\cite{walkinshaw2010using} apply Sequitur to the comprehension of program traces at varying levels of abstraction. Lin and others~\cite{lin2005supporting} extend Sequitur as a new XML compression scheme for supporting query processing. We are not aware of prior usage of Sequitur to support direct document analytics on compressed data, as we propose. } \section{Conclusion} \label{sec:conclusion} \vspace{-0.10in} \cred{ We propose a new method, TADOC, to enable high performance document analytics on compressed data. By enabling efficient direct processing on compressed data, our method reduces storage space by \reduceRatioAVG{} and memory usage by \memSavingAVG{}, while also speeding up the analytics by \singleAVG{} on sequential systems, and \distriAVG{} on distributed clusters. We present how the proposed method can be materialized on Sequitur, a compression method that produces hierarchical grammar-like representations. } We discuss the major challenges in applying the method to various document analytics tasks, and provide a set of guidelines for developers to avoid potential pitfalls in applying TADOC. In addition, we produce a library named \texttt{CompressDirect} to help ease the required development effort in using TADOC. Our results demonstrate the promise of TADOC in various environments, ranging from sequential to parallel and distributed systems. \vspace{-0.20in} \subsubsection{ \cred{Word Co-Occurrence} } In the evaluation, we compare the co-occurrence using TADOC with the compressed datasets \texttt{D} and \texttt{E}, and the original co-occurrence with the related uncompressed datasets. We use default parameters in the comparison. Experiment shows that TADOC saves 35.5\% time on average in execution; the original implementation needs 33.3 seconds for dataset \texttt{D} and 42.4 seconds for dataset \texttt{E}, while ours using \texttt{CD} only needs 25.0 (\texttt{D}) and 22.8 (\texttt{E}) seconds. The performance benefit mainly comes from the data reuse in TADOC. \subsubsection{\cred{TFIDF}} In the evaluation, we test the TFIDF using dataset \texttt{D} and \texttt{E}. The baseline version needs 16.0 seconds for processing dataset \texttt{D}, and 18.9 seconds for \texttt{E}. When using \texttt{CD}, we only need 9.9 seconds for dataset \texttt{D}, and 8.4 seconds for \texttt{E}, which implies that TADOC brings about 46.3\% performance benefits. \subsubsection{ \cred{Word2vec} } We conduct experiments on dataset \texttt{D} and \texttt{E}. The original preprocessing time are 29.1 (\texttt{D}) and 37.4 (\texttt{E}) seconds, while the preprocessing time with \texttt{CD} are 7.0 (\texttt{D}) and 7.1 (\texttt{E}) seconds. Experiments show that TADOC saves 78.7\% preprocessing time. The training time of word2vec is much longer than the processing time (2085.1 seconds for \texttt{D} and 2895.2 seconds for \texttt{E}). Although the time savings are small compared to the long training time, the word2vec can still enjoy the space benefit since it can directly read the input from the compressed data. \subsubsection{\cred{LDA}} We compare the LDA using \texttt{CD} with the baseline on the single node server with dataset \texttt{D} and \texttt{E}. In the first stage, for dataset \texttt{D}, the time of LDA using \texttt{CD} and without using \texttt{CD} are 20.3 and 45.8 seconds separately, while for dataset \texttt{E}, the time using and without using \texttt{CD} are 14.9 and 67.4 seconds, which indicates that TADOC saves 66\% preprocessing time on average. We further analyze the IO time and computation time in this stage, and experiment shows that \texttt{CD} saves 88.0\% IO time and 61.7\% computation time. The second stage takes 426 (\texttt{D}) and 485 (\texttt{E}) seconds for both baseline and \texttt{CD}, because they process the same data. With training process involved, the time benefit is not that much. However, we can still enjoy the large space benefits from the compressed format of \texttt{CD}.
{'timestamp': '2020-09-22T02:17:18', 'yymm': '2009', 'arxiv_id': '2009.09442', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09442'}
arxiv
\section{Introduction} Multiple human parsing~\cite{Gong_eccv2018_pgn}~\cite{Li_arxiv2017_mhparser}~\cite{Yang_cvpr2019_parsingrcnn} is a fundamental task in multimedia and computer vision, which aims to segment various human parts and associate each part with the corresponding instance. It plays a crucial role in applications in human-centric analysis and potential down-stream applications, such as person re-identification~\cite{Li_cvpr2018_harmonious}~\cite{Miao_iccv2019_pose}, action recognition~\cite{Girdhar_nips2017_attpool}, human-object interaction~\cite{Chao_iccv2015_hico}~\cite{Qi_eccv2018_learning}~\cite{Gkioxari_cvpr2018_interacnet}, and virtual reality~\cite{Hsieh_mm2019_fashion}. Due to the successful development of convolutional neural networks~\cite{Russakovsky_ijcv2015_imagenet}~\cite{He_cvpr2016_resnet}, great progress has been made in multiple human parsing. Current state-of-the-art methods can be categorized into bottom-up, one-stage top-down, and two-stage top-down methods. The bottom-up methods~\cite{Gong_eccv2018_pgn}~\cite{Gong_cvpr2019_graphonomy}~\cite{He_aaai2020_grapyml} regard multiple human parsing as a fine-grained semantic segmentation task, which predicts the category of each pixel and grouping them into corresponding human instance. This series of methods will have better performance in semantic segmentation metrics, but poor in instance parsing metrics, especially easy to confuse adjacent human instances. Unlike bottom-up methods, the one-stage top-down~\cite{Yang_cvpr2019_parsingrcnn}~\cite{Qin_bmvc2019_unified} and two-stage top-down methods~\cite{Ruan_aaai2019_ce2p}~\cite{Liu_mm2019_braidnet}~\cite{Ji_arxiv2019_sematree} locate each instance in the image plane, and then segment each human parts independently. The difference between one-stage and two-stage is whether the detector is trained together with the sub-network used to segment the human part in an end-to-end manner. Compared with the bottom-up, the top-down methods are very flexible, which can easily introduce enhancement modules or train with other human analysis tasks (such as pose estimation~\cite{Xiao_eccv2018_simple}, dense pose estimation~\cite{Guler_cvpr2018_densepose}~\cite{Yang_cvpr2019_parsingrcnn} or clothing parsing~\cite{Pongsate_pami2014_retrieving}) jointly. So it has become the mainstream research direction of multiple human parsing. But the human parts segmentation of each instance is independent and cannot make full use of context information, so the segmentation of some small scale human parts and human contours still needs to be improved. In addition, it is worth noting that neither bottom-up or top-down methods have a good way to evaluate the quality of predicted instance parsing maps. Resulting in many low-quality results that cannot be filtered. \begin{figure*}[t] \begin{center} \includegraphics[width=0.90\linewidth]{figures/intro.png} \end{center} \caption{Comparison of results between Parsing R-CNN and RP R-CNN on CIHP dataset. The first row is the ground-truth, the second row is the results of Parsing R-CNN, and the third is the predictions of RP R-CNN.} \label{fig:intro} \end{figure*} In this paper, we are devoted to solving the problem of missing global semantic information in top-down methods, and evaluating the quality of predicted instance parsing maps accurately. Therefore, we propose Renovating Parsing R-CNN (RP R-CNN), which introduces a global semantic enhanced feature pyramid network and a parsing re-scoring network to renovate the pipeline of top-down multiple human parsing. The global semantic enhanced feature pyramid network (GSE-FPN) is built on the widely used FPN~\cite{Lin_cvpr2017_fpn}. We up-sample the multi-scale features generated by FPN to the same scale and fuse them. Using the global human parts segmentation to supervise and generate the global semantic feature, then fusing the global semantic feature with FPN features on the corresponding scales. GSE-FPN encourages the semantic supervision signal to directly propagate to the feature pyramid, so as to strengthen global information of learned multi-scale features. Global semantic enhanced features are passed to the Parsing branch through the RoIAlign~\cite{He_iccv2017_maskrcnn} operation, ensuring that each independent human instance can still perceive the global semantic information, thereby improving the parsing performance of small targets, human contours, and easily confused categories. On this basis, the parsing re-scoring network (PRSN) is used to sense the quality of instance parsing maps and gives accurate scores. The score of instance parsing map is related to filtering low-quality results and sorting of instances, which is very important in the measurement of method and practical application. However, almost all the top-down methods use the score of detected bounding-box to represents the quality of instance parsing map~\cite{Ruan_aaai2019_ce2p}~\cite{Yang_cvpr2019_parsingrcnn}. This will inevitably bring great deviation, because the score of bounding-box can only indicate whether the instance is human or not, while the score of the instance parsing map needs to express the segmentation accuracy of each human part, and there is no direct correlation between them. The proposed PRSN is a very lightweight network, taking the feature map and heat map of each human instance as input, using MSE loss to regress the mean intersection over union (mIoU) between the prediction and ground-truth. During inference, we use the arithmetic square root of predicted mIoU score multiply box classification score as human parsing final score. Extensive experiments are conducted on two challenging benchmarks, CIHP~\cite{Gong_eccv2018_pgn} and MHP-v2~\cite{Zhao_mm2018_mhpv2}, demonstrating that our proposal RP R-CNN significantly outperforms the state-of-the-art for both bottom-up and top-down methods. As shown is Figure~\ref{fig:intro}, RP R-CNN is more accurate in segmenting small parts and human edges, and the predicted parsing scores can better reflect the quality of instance parsing maps. The main contributions of this work are summarized as follows: \begin{itemize} \item A novel RP R-CNN is proposed to solve the issue of missing global semantic information and inaccurate scoring of instance parsing maps in top-down multiple human parsing. \item We introduce an effective method to improve the multiple human parsing results by fusing global and instance-level human parts segmentation. \item The proposed RP R-CNN achieves state-of-the-art on two challenging benchmarks. On CIHP \texttt{val} set, RP R-CNN yields 2.0 points mIoU and 7.0 points AP$^\text{p}_\text{50}$ improvements compared with Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn}. On MHP-v2 \texttt{val} set, RP R-CNN outperforms Parsing R-CNN by 13.9 points AP$^\text{p}_\text{50}$ and outperforms CE2P~\cite{Ruan_aaai2019_ce2p} by 6.0 points AP$^\text{p}_\text{50}$, respectively. \end{itemize} Our code and models of RP R-CNN are publicly available. \section{Related Work} \noindent\textbf{Multi-Scale Feature Representations.} Multi-scale feature is widely used in computer vision tasks~\cite{Lin_cvpr2017_fpn}~\cite{Kirillov_cvpr2019_pfpn}~\cite{Long_cvpr2015_fcn}~\cite{Xiao_eccv2018_upernet}. Long {\em et al.}~\cite{Long_cvpr2015_fcn} combine coarse, high layer information with fine, low layer information to generate fine features with high resolution, which greatly promotes the development of semantic segmentation. Lin {\em et al.}~\cite{Long_cvpr2015_fcn} present the feature pyramid network (FPN), and adopt it in object detection, greatly improve the performance of the small object. FPN is a feature pyramid with high-level semantics throughout, through top-down pathway and lateral connections. With the success of FPN, some researches introduce it into other tasks. Panoptic feature pyramid network (PFPN)~\cite{Kirillov_cvpr2019_pfpn} is proposed by Kirillov {\em et al.} and applied to panoptic segmentation. PFPN up-samples the feature pyramids and fuse them to the same spatial resolution, then a semantic segmentation branch is attached to generate high-resolution semantic features. However, the computation cost of PFPN is too large, and it only has a single scale semantic feature. Our GSE-FPN solves the above problems well, which adopts a lightweight up-sampling method, and use the global semantic feature to enhance the multi-scale feature. \noindent\textbf{Instance Scoring.} Scoring the predicted instance is a challenging question. The R-CNN series~\cite{Girshick_iccv2015_fast-rcnn}~\cite{Ren_nips2015_faster-rcnn} of object detection approaches use the object classification score as the confidence of detection results. Recent studies~\cite{Jiang_eccv2018_iounet}~\cite{Tan_iccv2019_ltr}~\cite{Zhu_arxiv2020_cpm} believe that it cannot accurately reflect the consistency between the predicted bounding-box and the ground-truth. Jiang {\em et al.}~\cite{Jiang_eccv2018_iounet} present the IoU-Net, which adopts a IoU-prediction branch to predict the IoU between the predicted bounding box and the corresponding ground truth. Tan {\em et al.}~\cite{Tan_iccv2019_ltr} propose the Learning-to-Rank (LTR) model to produce a ranking score, which is based on IoU to indicate the ranks of candidates during the NMS step. Huang {\em et al.}~\cite{Huang_cvpr2019_msrcnn} consider the difference between classification score and mask quality is greater in instance segmentation. They proposed Mask Scoring R-CNN, which uses a MaskIoU head to predict the quality of mask result. Different from these studies, this work analyzes and solves the inaccurate scoring of instance parsing maps for the first time. The proposed PRSN is concise yet effective, and reducing the gap between score and instance parsing quality. \noindent\textbf{Multiple Human Parsing.} Before the popularity of convolutional neural network, some methods~\cite{Yamaguchi_cvpr2012_parsing}~\cite{Luo_iccv2013_pedestrian}~\cite{Yang_cvpr2014_clothing-co-parsing} using hand-crafted visual features and low-level image decompositions have achieved considerable results on single human parsing. However, limited by the representation ability of features, these traditional methods can not be well extended to multiple human parsing. With the successful development of convolutional neural networks~\cite{Russakovsky_ijcv2015_imagenet}~\cite{Alex_nip2012_alexnet}~\cite{He_cvpr2016_resnet} and open source of large-scale multiple human parsing datasets~\cite{Gong_eccv2018_pgn}~\cite{Zhao_mm2018_mhpv2}, some recent researches~\cite{Gong_eccv2018_pgn}~\cite{Ruan_aaai2019_ce2p}~\cite{Yang_cvpr2019_parsingrcnn} have achieved remarkable results in instance-level multiple human parsing. Gong {\em et al.}~\cite{Gong_eccv2018_pgn} present the part grouping network (PGN), which is a typical bottom-up method for instance-level multiple human parsing. PGN reformulates multiple human parsing as semantic part segmentation task and instance-aware edge detection task, the former is used to assign each pixel as human part and the latter is used to group semantic part into different human instances. Ruan {\em et al.}~\cite{Ruan_aaai2019_ce2p} rethink and analyze the problems of feature resolution, global context information and edge details in human parsing task, and propose Context Embedding with Edge Perceiving (CE2P) framework for single human parsing. CE2P is a very successful two-stage top-down method, and wins the 1st places on three tracks in the 2018 2nd LIP Challenge. Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} is proposed by Yang {\em et al.}, which is a one-stage top-down method for multiple human parsing. Based on the in-depth analysis of human appearance characteristics, Parsing R-CNN has made an effective extension on region-based approaches~\cite{Girshick_iccv2015_fast-rcnn}~\cite{Ren_nips2015_faster-rcnn}~\cite{Lin_cvpr2017_fpn}~\cite{He_iccv2017_maskrcnn} and significantly improved the performance of human parsing. Our work is based on the Parsing R-CNN framework, firstly introducing the global semantic information and reducing the gap between score and instance parsing quality for the top-down methods. \section{Renovating Parsing R-CNN} Our goal is to solve the issue of missing global semantic information and inaccurate scoring of instance parsing map in top-down multiple human parsing pipeline. In this section, we will introduce the motivation, architecture, and components of RP R-CNN in detail. \begin{table*}[t] \centering \small \tabcolsep 0.04in \scalebox{0.88}{ \begin{tabular}{c|ccc|cccc} Backbones & GT-box & GT-parsing & GT-score & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline \multirow{4}{*}{R50-FPN} & & & & 56.2 & 64.6 & 54.3 & 60.9 \\ \cline{5-8} & \checkmark & & & ${58.4}_{\color{red}(+2.2)}$ & ${58.0}_{\color{blue}(-6.6)}$ & ${51.5}_{\color{blue}(-2.8)}$ & ${62.3}_{\color{red}(+1.4)}$ \\ & &\checkmark& & ${87.8}_{\color{red}(+31.6)}$ & ${91.4}_{\color{red}(+26.8)}$ & ${83.6}_{\color{red}(+29.3)}$ & ${90.6}_{\color{red}(+29.7)}$ \\ & & &\checkmark & ${57.4}_{\color{red}(+1.2)}$ & ${73.7}_{\color{red}(+9.1)}$ & ${60.8}_{\color{red}(+6.5)}$ & ${60.9}_{(+0.0)}$ \\ \end{tabular} } \caption{Upper bound analysis of instance-level multiple human parsing via using ground-truth. All models are trained on CIHP \texttt{train} set and evaluated on CIHP \texttt{val} set. We replace the Bbox branch output with ground-truth box, replace the Parsing branch output with ground-truth segmentation or replace the instance score with ground-truth IoU, respectively. The results suggest that there is still room for improvement in human parsing and scoring.} \label{tab:upper_bound} \end{table*} \subsection{Motivation} In the top-down multiple human parsing pipeline, the network outputs three results: bounding-box, instance parsing map and parsing score. The importance of three outputs to the network performance is different. We take Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} as baseline, and make an upper bound analysis of the three outputs. As shown in Table~\ref{tab:upper_bound}, we replace the predicted bounding-box with ground-truth, the multiple human parsing increases by 2.2 points mIoU~\cite{Long_cvpr2015_fcn}, but AP$^\text{p}_\text{50}$ and AP$^\text{p}_\text{vol}$~\cite{Zhao_mm2018_mhpv2} decrease. But when we replace the corresponding network output with the ground-truth of parsing map and mIoU, all the evaluation metrics have significant improvements. In particular, after the adoption of ground-truth parsing map, each evaluation metric has increased by about 30 points. These experimental results show that the accuracy of bounding-box has no significant impact on the multiple human parsing performance.However, the predicted parsing map and score still have a lot of room for improvement and not been paid enough attention by current studies. This is the motivation for our work. \begin{figure*}[t] \begin{center} \includegraphics[width=0.98\linewidth]{figures/rp_rcnn.pdf} \end{center} \caption{RP R-CNN architecture. The input image is fed into a backbone with Global Semantic Enhanced FPN~\cite{Lin_cvpr2017_fpn} to generate RoIs via RPN~\cite{Ren_nips2015_faster-rcnn} (not shown in the figure) and RoI features via RoIAlign~\cite{He_iccv2017_maskrcnn}. The global human parts segmentation is used to supervise and generate the global semantic feature. The BBox branch is standard component of Faster R-CNN which is used to detect human instance. The Parsing branch is mainly composed of GCE module~\cite{Yang_cvpr2019_parsingrcnn} and Parsing Re-Scoring Network for predicting parsing maps and mIoU scores.} \label{fig:rp_rcnn_arch} \end{figure*} \subsection{Architecture} As illustrated in Figure~\ref{fig:rp_rcnn_arch}, the proposed RP R-CNN involves four components: Backbone, GSE-FPN, Detector (RPN and BBox branch), and Parsing branch with PRSN. The settings of Backbone and Detector are the same as Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn}. The GSE-FPN is attached to the Backbone to generate multi-scale features with global semantic information. The Parsing branch consists of GCE module, parsing map output and Parsing Re-Scoring Network. \subsection{Global Semantic Enhanced Feature Pyramid Network} RoIAlign~\cite{He_iccv2017_maskrcnn} aims to obtain the features of a specific region on the feature map, so that each instance can be processed separately. However, this makes the instance unable to directly perceive the global (context) information in branch. Global representation is crucial for human parsing, because we not only need to distinguish human body and background, but also give each pixel corresponding category through understanding the pose and recognizing the clothes the person wears~\cite{Gong_cvpr2019_graphonomy}. Therefore, the information about the environment and objects around the human body is helpful for network learning. Some methods~\cite{Zeng_pami2017_gbd} perceive more valuable information by changing the area selected by RoIPool/RoIAlign. Different from these, we hope that by explicitly enhancing the global semantic representation of multi-scale features before RoIAlign. As a concrete example, the proposed GSE-FPN are illustrated in Figure~\ref{fig:sfpn}, we adopt group normalization~\cite{Wu_eccv2018_gn} and ReLU activation~\cite{Nair_icml2010_relu} after each convolutional layer. \begin{figure*}[t] \begin{center} \includegraphics[width=0.70\linewidth]{figures/sfpn.pdf} \end{center} \caption{Global semantic enhanced feature pyramid network (GSE-FPN). Circle is used to represent the feature map, and the circle thickness of circle is used to represent the spatial scale. The semantic segmentation loss is omitted here.} \label{fig:sfpn} \end{figure*} \noindent\textbf{High-resolution Feature.} For semantic segmentation, high-resolution feature is necessary for generating high-quality results. Dilated convolution is an effective operation, which is adopted by many state-of-the-art semantic segmentation methods~\cite{Yu_iclr2016_dilated}~\cite{Zhao_cvpr2017_pspnet}~\cite{Chen_arxiv2017_deeplabv3}. But dilated convolution substantially increases computation cost, and limits the use of multi-scale features. To keep the efficiency of network, and generate high-resolution features, we extend the multi-scale outputs of FPN~\cite{Lin_cvpr2017_fpn}. Specifically, we up-sample the FPN generated multi-scale features to the scale of `$P$2' level by bilinear interpolation, which is 1/4 resolution of the original image. Each feature map is followed by a 1$\times$1 256-d convolutional layer for aligning to the same semantic space, then these feature maps are fused together to generate high-resolution features. \noindent\textbf{Global Semantic Feature.} As shown in Figure~\ref{fig:sfpn}, we stack four 3$\times$3 256-d convolutional layers after the high-resolution features to generate global semantic feature. Such a design is simple enough, but also can improve the representation ability of the network. In fact, we have tried some popular enhancement modules for semantic segmentation tasks, such as PPM~\cite{Zhao_cvpr2017_pspnet} and ASPP~\cite{Chen_arxiv2017_deeplabv3}~\cite{Chen_eccv2018_deeplabv3plus}, but experiments show that these modules are not helpful to improve human parsing performance. A 1$\times$1 $C$-dimension ($C$ is the category number) convolutional layer is attached to the global semantic feature to predict human part segmentation. \noindent\textbf{Multi-scale Features Fusion.} Through the above structure, we can get high-resolution global semantic feature. It is well known that semantic representation can bring performance gains to bounding-box classification and regression~\cite{He_iccv2017_maskrcnn}~\cite{Chen_cvpr2019_htc}. Therefore, we down-sample the global semantic feature to the scales of $P$3$\sim$$P$6, and use element-wise sum to fuse them with the same scale FPN features. The generated new features are called global semantic enhanced multi-scale features, and denoted as $S$2$\sim$$S$6. We follow the Proposals Separation Sampling~\cite{Yang_cvpr2019_parsingrcnn} strategy that the $S$2$\sim$$S$6 level features are adopted for extracting region features for BBox branch and only $S$2 level is used for Parsing branch. \subsection{Parsing Re-Scoring Network} Parsing Re-Scoring Network (PRSN) aims to predict accurate mIoU score for each instance parsing map, and can be flexibly integrated into the Parsing branch. \noindent\textbf{Concise and Lightweight Design.} PRSN follows the concise and lightweight design, which will not bring too much computation cost to model training and inference. PRSN receives two inputs, one is the $N$$\times$512$\times$32$\times$32 dimension parsing feature map, the other is the $N$$\times$$C$$\times$128$\times$128 dimension segmentation probability map ($N$ is the number of RoIs, $C$ is the category number). A max pooling layer with stride = 4 and kernel = 4 is adopted to make the probability map has the same spatial scale with parsing feature map. The down-sampled probability map and parsing feature map are concatenated together, then followed by two 3$\times$3 128-d convolutional layers. A final global average pooling layer, two 256-d fully connected layers, and MSE loss to regress the mIoU between the predicted instance parsing map and ground-truth. \noindent\textbf{IoU-aware Ground-truth.} We define the mIoU between the predicted instance parsing map and matched ground-truth as regression target for PRSN. The common Parsing branch can output the segmentation probability map of each human instance, and calculate the loss with the segmentation ground-truth through a cross entropy function. Therefore, the mIoU between them can be calculated directly in the existing framework. It is worth noting that since the instance parsing ground-truth depends on the predicted region of Bbox branch, there is some deviation from the true location of human instance. However, we find that this deviation does not affect the effect of the predicting parsing score, so we do not make corrections to this deviation. \subsection{Training and Inference} \begin{figure*}[t] \begin{center} \includegraphics[width=0.70\linewidth]{figures/seg_infer.pdf} \end{center} \caption{Combination strategy for generating semantic segmentation results. ` $\parallel$ ' symbol represents element-wise OR operation.} \label{fig:seg_infer} \end{figure*} As we introduce new supervision into RP R-CNN, there are some changes in the training and inference phases compared with the common methods~\cite{Yang_cvpr2019_parsingrcnn}~\cite{Qin_bmvc2019_unified}. \noindent\textbf{Training.} There are three losses for global human parts segmentation and Parsing branch: ${\cal{L}}_{\text{sem}}$ (segmentation loss), ${\cal{L}}_{\text{par}}$ (parsing loss), ${\cal{L}}_{\text{res}}$ (re-scoring loss). The segmentation loss and parsing loss are computed as a per-pixel cross entropy loss between the predicted segmentation and the ground-truth labels. We use the MSE loss as re-scoring loss. We have observed that the losses from three tasks have different scales and normalization policies. Simply adding them degrades the overall performance. This can be corrected by a simple loss re-weighting strategy. Considering the losses of the detection sub-network, the whole network loss ${\cal{L}}$ can be written as: \begin{equation} \label{loss_whole} \begin{aligned} {\cal{L}} = {\cal{L}}_{\text{rpn}} + {\cal{L}}_{\text{bbox}} + \lambda_\text{p} {\cal{L}}_{\text{par}} + \lambda_\text{s} {\cal{L}}_{\text{sem}} + \lambda_\text{r} {\cal{L}}_{\text{res}}. \end{aligned} \end{equation} The ${\cal{L}}_{\text{rpn}}$ and ${\cal{L}}_{\text{bbox}}$ are losses of RPN and BBox branch, each of which is composed of classification loss and box regression loss. By tuning $\lambda_\text{p}$, $\lambda_\text{s}$ and $\lambda_\text{r}$, it is possible to make the network converge to optimal performance. \begin{table*}[t] \centering \small \tabcolsep 0.04in \scalebox{0.94}{ \begin{tabular}{c|c|cccc} Dataset & Method & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline \multirow{3}{*}{CIHP} & Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} & 56.3 & 63.7 & 53.9 & 60.1 \\ & Parsing R-CNN (our impl.) & 56.2 & 64.6 & 54.2 & 60.9 \\ \cline{2-6} & $\Delta$ & \emph{-0.1} & \emph{+0.9} & \emph{+0.4} & \emph{+0.8} \\ \hline \multirow{3}{*}{MHP-v2} & Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} & 36.2 & 24.5 & 39.5 & 37.2 \\ & Parsing R-CNN (our impl.) & 35.5 & 26.6 & 40.3 & 37.9 \\ \cline{2-6} & $\Delta$ & \emph{-0.7} & \emph{+2.1} & \emph{+0.8} & \emph{+0.7} \\ \end{tabular} } \caption{Results of Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} on the CIHP and MHP-v2 datasets. `our impl.' denotes our implementation of Parsing R-CNN, which uses GN~\cite{Wu_eccv2018_gn} in Parsing branch to stabilize the training.} \label{tab:baseline} \end{table*} \noindent\textbf{Inference.} For network inference, we select top 100 candidate bounding-boxes per image from the human detection results. These candidates are fed into Parsing branch to predict instance parsing map and mIoU score. However, the mIoU score is only trained by positive samples, which leads to the lack of the ability to suppress negative samples. So we fuse mIoU score ${\cal{S}}_{\text{iou}}$ and classification score ${\cal{S}}_{\text{cls}}$ to generate the final parsing score ${\cal{S}}_{\text{parsing}} = \sqrt{{\cal{S}}_{\text{cls}} * {\cal{S}}_{\text{iou}}}$. In addition, we also find that the global human parts segmentation results are complementary to the Parsing branch result, the former has higher recall for each foreground, and the latter has better details. Thus, when generating semantic segmentation results, we adopt a new combination strategy, as shown in Figure~\ref{fig:seg_infer}. We filter out the low quality results based on the ${\cal{S}}_{\text{parsing}}$, and then generate instance-level human parts segmentation (b) $\emph{instance-level}$. The instance-level (b) was and global human parts segmentation (a) $\emph{global}$ do element-wise OR operation to get the final result (c) $\emph{combine}$. It is worth noting that if the results of (a) and (b) are different at the same pixel, and both of them are predicted as non-background category, we directly adopt the results of (b). This is because the (b) has a more accurate perception of the human parts inside each instance. \section{Experiments} In this section, we describe experiments on multiple human parsing of RP R-CNN. All experiments are conducted on the CIHP~\cite{Gong_eccv2018_pgn} and MHP-v2~\cite{Zhao_mm2018_mhpv2} datasets. We follow the Parsing R-CNN evaluation protocols. Using mean intersection over union (mIoU)~\cite{Long_cvpr2015_fcn} to evaluate the human part segmentation. And using average precision based on part (AP$^\text{p}$)~\cite{Zhao_mm2018_mhpv2} as instance evaluation metric(s). \subsection{Implementation Details} \begin{table*}[t] \centering \tabcolsep 0.08in \scalebox{0.94}{ \begin{tabular}{c|c|cccc} $\lambda_\text{p}$ & AP$^\text{bbox}$ & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline 0.0 & \textcolor{gray}{69.1} & -- & -- & -- & -- \\ \hline 0.5 & \textcolor{gray}{67.7} & 55.9 & 64.4 & 53.7 & 59.9 \\ 1.0 & \textcolor{gray}{68.5} & 55.9 & 63.9 & 53.8 & 60.6 \\ \textbf{2.0} & \textcolor{gray}{68.3} & \textbf{56.2} & \textbf{64.6} & \textbf{54.3} & \textbf{60.9} \\ 3.0 & \textcolor{gray}{67.8} & 55.9 & \textbf{64.6} & 54.2 & 60.7 \\ \end{tabular} } \caption{Weight ($\lambda_\text{p}$) of parsing loss. All models are trained on CIHP \texttt{train} set and evaluated on CIHP \texttt{val} set (with $\lambda_\text{s} = 0.0$ and $\lambda_\text{r} = 0.0$).} \label{tab:parsing_loss_weight} \end{table*} \begin{table}[t] \tabcolsep 0.04in \begin{minipage}{0.48\linewidth} \scalebox{0.94}{ \begin{tabular}{c|c|cccc} $\lambda_\text{s}$ & AP$^\text{bbox}$ & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline 0.0 & \textcolor{gray}{69.1} & \textcolor{gray}{56.2} & \textcolor{gray}{64.6} & \textcolor{gray}{54.3} & \textcolor{gray}{60.9} \\ \hline 0.5 & \textcolor{gray}{67.9} & 57.0 & 65.1 & 54.6 & 61.1 \\ 1.0 & \textcolor{gray}{67.7} & 57.8 & 66.5 & 55.0 & 61.7 \\ \textbf{2.0} & \textcolor{gray}{67.4} & \textbf{58.2} & \textbf{67.4} & \textbf{55.5} & \textbf{62.1} \\ 3.0 & \textcolor{gray}{67.1} & 58.0 & 67.4 & 55.3 & 61.8 \\ \hline $\Delta$ & &\emph{+2.0} & \emph{+2.8} & \emph{+1.2} & \emph{+1.2} \\ \end{tabular} } \caption{Weight ($\lambda_\text{s}$) of semantic segmentation loss (with $\lambda_\text{r} = 0.0$).} \label{tab:semseg_loss_weight} \end{minipage} \hfill \begin{minipage}{0.48\linewidth} \scalebox{0.94}{ \begin{tabular}{c|c|cccc} $\lambda_\text{s}$ & AP$^\text{bbox}$ & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline 0.0 & \textcolor{gray}{69.1} & \textcolor{gray}{56.2} & \textcolor{gray}{64.6} & \textcolor{gray}{54.3} & \textcolor{gray}{60.9} \\ \hline 0.5 & \textcolor{gray}{68.2} & 56.3 & 70.1 & 57.4 & 61.1 \\ \textbf{1.0} & \textcolor{gray}{68.3} & \textbf{56.4} & \textbf{70.3} & \textbf{57.6} & \textbf{61.3} \\ 2.0 & \textcolor{gray}{68.2} & 56.3 & 70.2 & 57.5 & \textbf{61.3} \\ 3.0 & \textcolor{gray}{68.1} & 56.2 & \textbf{70.3} & 57.5 & 61.1 \\ \hline $\Delta$ & &\emph{+0.2} & \emph{+5.7} & \emph{+3.3} & \emph{+0.4} \\ \end{tabular} } \caption{Weight ($\lambda_\text{r}$) of re-scoring loss (with $\lambda_\text{s} = 0.0$).} \label{tab:rescore_loss_weight} \end{minipage} \end{table} \begin{table*}[t] \centering \small \tabcolsep 0.08in \scalebox{0.94}{ \begin{tabular}{l|ccc} Inference methods & mIoU & Pixel acc. & Mean acc. \\ \hline baseline & 56.2 & 89.3 & 67.0 \\ \hline (a) semseg & 50.2 & 88.0 & 61.3 \\ (b) parsing & 57.4 & 89.8 & 67.1 \\ \textbf{(c) combine} & \textbf{58.2} & \textbf{90.2} & \textbf{69.0} \\ \hline $\Delta$ & \emph{+2.0} & \emph{+0.9} & \emph{+2.0} \\ \end{tabular} } \caption{Semantic segmentation results of different inference methods on CIHP dataset. All models are trained on \texttt{train} set and evaluated on \texttt{val} set.} \label{tab:semseg_infer} \end{table*} \noindent\textbf{Training Setup.} All experiments are based on Pytorch on a server with 8 NVIDIA Titan RTX GPUs. We use 16 batch-size (2 images per GPU) and adopt ResNet50~\cite{He_cvpr2016_resnet} as backbone. The short side of input image is resized randomly sampled from [512, 864] pixels, and the longer side is limited to 1,400 pixels; inference is on a single scale of 800 pixels. Each image has 512 sampled RoIs for Bbox branch and 16 sampled RoIs for Parsing branch. For CIHP dataset, there are 135,000 iterations (about 75 epochs) of the training process, with a learning rate of 0.02 which is decreased by 10 at the 105,000 and 125,000 iteration. For MHP-v2 dataset, the max iteration is half as long as the CIHP dataset with the learning rate change points scaled proportionally. \noindent\textbf{Parsing R-CNN Re-Implementation.} In order to better illustrate the advantages of RP R-CNN, we have re-implemented Parsing R-CNN according to the original paper~\cite{Yang_cvpr2019_parsingrcnn}. We find that the training of Parsing R-CNN is not very stable. We solve this issue by adding group normalization~\cite{Wu_eccv2018_gn} after each convolutional layer of Parsing branch. As shown in Table~\ref{tab:baseline}, our re-implemented Parsing R-CNN achieves comparable performance with original version both on CIHP and MHP-v2 datasets. Therefore, this work takes our re-implemented Parsing R-CNN as the baseline. \begin{table*}[t] \centering \small \tabcolsep 0.04in \scalebox{0.94}{ \begin{tabular}{c|cc|cccc} Methods & GSE-FPN & PRSN & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline \multirow{4}{*}{RP R-CNN} & & & 56.2 & 64.6 & 54.3 & 60.9 \\ \cline{4-7} & \checkmark & & ${58.2}_{\color{red}(+2.0)}$ & ${67.4}_{\color{red}(+2.8)}$ & ${55.5}_{\color{red}(+1.2)}$ & ${62.1}_{\color{red}(+1.2)}$ \\ & &\checkmark & ${56.4}_{\color{red}(+0.2)}$ & ${70.3}_{\color{red}(+5.7)}$ & ${57.6}_{\color{red}(+3.3)}$ & ${61.3}_{\color{red}(+0.4)}$ \\ &\checkmark&\checkmark & ${58.2}_{\color{red}(+2.0)}$ & ${71.6}_{\color{red}(+7.0)}$ & ${58.3}_{\color{red}(+4.0)}$ & ${62.2}_{\color{red}(+1.3)}$ \\ \end{tabular} } \caption{Ablations of RP R-CNN on CIHP dataset. All models are trained on \texttt{train} set and evaluated on \texttt{val} set.} \label{tab:ablation_cihp} \end{table*} \begin{table*}[t] \centering \small \tabcolsep 0.04in \scalebox{0.94}{ \begin{tabular}{c|cc|cccc} Methods & GSE-FPN & PRSN & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline \multirow{4}{*}{RP R-CNN} & & & 35.5 & 26.6 & 40.3 & 37.9 \\ \cline{4-7} & \checkmark & & ${37.3}_{\color{red}(+1.8)}$ & ${28.9}_{\color{red}(+2.3)}$ & ${41.1}_{\color{red}(+0.8)}$ & ${38.9}_{\color{red}(+1.0)}$ \\ & &\checkmark & ${35.7}_{\color{red}(+0.2)}$ & ${39.6}_{\color{red}(+13.0)}$ & ${44.9}_{\color{red}(+4.6)}$ & ${38.2}_{\color{red}(+0.3)}$ \\ &\checkmark&\checkmark & ${37.3}_{\color{red}(+1.8)}$ & ${40.5}_{\color{red}(+13.9)}$ & ${45.2}_{\color{red}(+4.9)}$ & ${39.2}_{\color{red}(+1.3)}$ \\ \end{tabular} } \caption{Ablations of RP R-CNN on MHP-v2 dataset. All models are trained on \texttt{train} set and evaluated on \texttt{val} set.} \label{tab:ablation_mhp} \end{table*} \subsection{Ablation Studies} In this sub-section, we assess the effects of different settings and components on RP R-CNN by details ablation studies. \noindent\textbf{Loss Weights.} To combine our GSE-FPN with PRSN in Parsing R-CNN, we need to determine how to train a single, unified network. Previous studies demonstrate that multi-task training is often challenging and can lead to degraded results~\cite{Kendall_cvpr2018_mtl}. We also observe that adding the losses of all tasks directly will not give the best results. But grid searching three hyper-parameters ($\lambda_\text{p}$, $\lambda_\text{s}$ and $\lambda_\text{r}$) is very inefficient, so we first determine $\lambda_\text{p}$, and then determine $\lambda_\text{s}$ and $\lambda_\text{r}$ separately to improve efficiency. As shown in Table~\ref{tab:parsing_loss_weight}, we find that the network performance is the best when $\lambda_\text{p} = 2.0$. We consider the group normalization layer makes the network convergence more stable, so that a proper large loss weight will bring higher accuracy. Table~\ref{tab:semseg_loss_weight} shows that $\lambda_\text{s} = 2.0$ is the proper loss weight for semantic segmentation. Although increasing the weight of global human parts segmentation loss will slightly reduce the accuracy of human detection, the overall performance is improved. Table~\ref{tab:rescore_loss_weight} shows that the re-scoring task is not sensitive to the loss weight, and its loss scale is smaller than other losses, so it has no significant impact on the optimization of other tasks in multi-task training. To sum up, we choose $\lambda_\text{p} = 2.0$, $\lambda_\text{s} = 2.0$ and $\lambda_\text{r} = 1.0$ as the loss weights of Eqn.(\ref{loss_whole}). \noindent\textbf{Inference Methods.} The combination inference method proposed in Figure~\ref{fig:seg_infer} utilizes the complementarity of global human parts segmentation and Parsing branch results, and we give the detailed results in Table~\ref{tab:semseg_infer}. The performance of using (a) $\emph{semseg}$ or (b) $\emph{parsing}$ alone is poor. The combination method (c) $\emph{combine}$ can significantly improve the metrics of semantic segmentation, and outperforms the baseline by 2 points mIoU. \begin{table*}[t] \centering \small \tabcolsep 0.04in \scalebox{0.75}{ \begin{tabular}{c|l|l|c|cccc} Dataset & Methods & Backbones & Epochs & mIoU & AP$^\text{p}_\text{50}$ & AP$^\text{p}_\text{vol}$ & PCP$_\text{50}$ \\ \hline \multirow{18}{*}{CIHP~\cite{Gong_eccv2018_pgn}} & \multicolumn{2}{c|}{Bottom-Up} &\\ \cline{2-8} & PGN$^\dagger$~\cite{Gong_eccv2018_pgn} & ResNet101 & $\sim$80 & 55.8 & 34.0 & 39.0 & 61.0 \\ & DeepLab v3+~\cite{Chen_eccv2018_deeplabv3plus} & Xception & 100 & 58.9 & -- & -- & -- \\ & Graphonomy~\cite{Gong_cvpr2019_graphonomy} & Xception & 100 & 58.6 & -- & -- & -- \\ & GPM~\cite{He_aaai2020_grapyml} & Xception & 100 & 60.3 & -- & -- & -- \\ & Grapy-ML~\cite{He_aaai2020_grapyml} & Xception & 200 & 60.6 & -- & -- & -- \\ \cline{2-8} & \multicolumn{2}{c|}{Two-Stage Top-Down} &\\ \cline{2-8} & M-CE2P~\cite{Ruan_aaai2019_ce2p} & ResNet101 & 150 & 59.5 & -- & -- & -- \\ & BraidNet~\cite{Liu_mm2019_braidnet} & ResNet101 & 150 & 60.6 & -- & -- & -- \\ & SemaTree~\cite{Ji_arxiv2019_sematree} & ResNet101 & 200 & 60.9 & -- & -- & -- \\ \cline{2-8} & \multicolumn{2}{c|}{One-Stage Top-Down} &\\ \cline{2-8} & Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} & ResNet50 & 75 & 56.3 & 63.7 & 53.9 & 60.1 \\ & Parsing R-CNN$^\dagger$~\cite{Yang_cvpr2019_parsingrcnn} & ResNeXt101 & 75 & 61.1 & 71.2 & 56.5 & 67.7 \\ & Parsing R-CNN (our impl.) & ResNet50 & 75 & 56.2 & 64.6 & 54.3 & 60.9 \\ & Unified~\cite{Qin_bmvc2019_unified} & ResNet101 & $\sim$37 & 55.2 & 51.0 & 48.0 & -- \\ & RP R-CNN (ours) & ResNet50 & 75 & 58.2 & 71.6 & 58.3 & 62.2 \\ & RP R-CNN (ours)$^*$ & ResNet50 & 150 & 60.2 & 74.1 & 59.5 & 64.9 \\ & \textbf{RP R-CNN (ours)}$^*$$^\dagger$ & \textbf{ResNet50} & 150 & \textbf{61.8} & \textbf{77.2} & \textbf{61.2} & \textbf{70.5} \\ \hline \multirow{12}{*}{MHP-v2~\cite{Zhao_mm2018_mhpv2}}& \multicolumn{2}{c|}{Bottom-Up} &\\ \cline{2-8} & MH-Parser~\cite{Li_arxiv2017_mhparser} & ResNet101 & -- & -- & 17.9 & 36.0 & 26.9 \\ & NAN~\cite{Zhao_mm2018_mhpv2} & -- & $\sim$80 & -- & 25.1 & 41.7 & 32.2 \\ \cline{2-8} & \multicolumn{2}{c|}{Two-Stage Top-Down} &\\ \cline{2-8} & M-CE2P~\cite{Ruan_aaai2019_ce2p} & ResNet101 & 150 & \textbf{41.1} & 34.5 & 42.7 & \textbf{43.8} \\ & SemaTree~\cite{Ji_arxiv2019_sematree} & ResNet101 & 200 & -- & 34.4 & 42.5 & 43.5 \\ \cline{2-8} & \multicolumn{2}{c|}{One-Stage Top-Down} &\\ \cline{2-8} & Mask R-CNN~\cite{He_iccv2017_maskrcnn} & ResNet50 & -- & -- & 14.9 & 33.8 & 25.1 \\ & Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} & ResNet50 & 75 & 36.2 & 24.5 & 39.5 & 37.2 \\ & Parsing R-CNN (our impl.) & ResNet50 & 75 & 35.5 & 26.6 & 40.3 & 37.9 \\ & RP R-CNN (ours) & ResNet50 & 75 & 37.3 & 40.5 & 45.2 & 39.2 \\ & \textbf{RP R-CNN (ours)}$^*$ & \textbf{ResNet50} & 150 & 38.6 & \textbf{45.3} & \textbf{46.8} & \textbf{43.8} \\ \end{tabular} } \caption{Multiple human parsing on the CIHP and MHP-v2 datasets. $^*$ denotes longer learning schedule. $^\dagger$ denotes using test-time augmentation.} \label{tab:sota} \end{table*} \noindent\textbf{Ablations on RP R-CNN.} In Table~\ref{tab:ablation_cihp}, we perform the additional ablations of RP R-CNN on CIHP dataset. We observe that GSE-FPN is very helpful to the global human parts segmentation, which yields 2.0 points mIoU improvement. In addition, the global semantic feature also improves the instance metrics, AP$^\text{p}_\text{50}$, AP$^\text{p}_\text{vol}$ and PCP$_\text{50}$ increase 2.8, 1.2 and 1.2 points respectively. With PRSN, the improvements of instance metrics are very significant, AP$^\text{p}_\text{50}$ improves 5.7 points, and AP$^\text{p}_\text{vol}$ improves 3.3 points. With GSE-FPN and PRSN, our proposed RP R-CNN achieves 58.2 mIoU and 71.6 AP$^\text{p}_\text{50}$ on CIHP. The additional ablations on MHP-v2 dataset is shown in Table~\ref{tab:ablation_mhp}. Through GSE-FPN and PRSN, the performance of human parsing is also significant improved. Particularly, AP$^\text{p}_\text{50}$ and AP$^\text{p}_\text{vol}$ are raised considerably by PRSN, 13.0 points and 4.6 points, respectively. \begin{figure*}[t] \begin{center} \includegraphics[width=0.42\linewidth]{figures/iou_boxscore.png} \includegraphics[width=0.42\linewidth]{figures/iou_rescore.png} \end{center} \caption{Comparisons of ground-truth IoU vs. bbox score (\textbf{Left}) and ground-truth IoU vs. parsing score (\textbf{Right}) on CIHP dataset. All models are trained on \texttt{train} set and evaluated on \texttt{val} set.} \label{fig:correlation} \end{figure*} \subsection{Comparison with State-of-the-Arts} We evaluate RP R-CNN on the CIHP and MHP-v2 datasets and compare the results to state-of-the-art including bottom-up and one-stage/two-stage top-down methods, shown in Table~\ref{tab:sota}. On CIHP dataset, our proposed RP R-CNN achieves 58.2 mIoU and 71.6 AP$^\text{p}_\text{50}$, which surpasses Parsing R-CNN~\cite{Yang_cvpr2019_parsingrcnn} in all respects. Compared with PGN~\cite{Gong_eccv2018_pgn}, the performance advantage of RP R-CNN is huge, and AP$^\text{p}_\text{50}$ is even 37.6 points ahead. With longer learning schedule (150 epochs), RP R-CNN achieves compared performance with one-stage top-down methods, {\em e.g.} M-CE2P and BraidNet. Even though we have adopted a lighter backbone (ResNet50 vs. ResNet101). Finally, using test-time augmentation, RP R-CNN with RestNet50 achieves state-of-the-art performance on CIHP. On MHP-v2 dataset, RP R-CNN achieves excellent performance. We can observe that our RP R-CNN outperforms Parsing R-CNN consistently for all the evaluation metrics. And compared with M-CE2P, RP R-CNN yields about 10.8 point AP$^\text{p}_\text{50}$ and 4.1 points AP$^\text{p}_\text{vol}$ improvements. With RestNet50 backbone, it gives new state-of-the-art of 45.3 AP$^\text{p}_\text{50}$, 46.8 AP$^\text{p}_\text{vol}$ and 43.8 PCP$_\text{50}$. \subsection{Analysis and Discussion} \noindent\textbf{Effect of Parsing Re-Scoring Network.} Figure~\ref{fig:correlation} shows that the correlation between mIoU of the predicted parsing map with the matched ground-truth and the bbox/parsing score. As shown, the parsing score has better correlation with the ground-truth, especially for high-quality parsing map. However, it is difficult to score low-quality parsing map, which is the source of some false positive detections. Therefore, the evaluation of low-quality prediction is still a problem to be solved. \noindent\textbf{Qualitative results.} We visualize multiple human parsing results of RP R-CNN in Figure~\ref{fig:qresults}. We can observe that RP R-CNN has a good applicability to dense crowds and occlusions. In addition, the parsing score predicted by RP R-CNN reflects the quality of the parsing map. \begin{figure*}[t] \begin{center} \includegraphics[width=0.8\linewidth]{figures/visual.png} \end{center} \caption{Qualitative results of RP R-CNN on the CIHP and MHP-v2 datasets.} \label{fig:qresults} \end{figure*} \section{Conclusions} In this paper, we proposed a novel Renovating Parsing R-CNN (RP R-CNN) model for solving the issue of missing global semantic information and inaccurate scoring of parsing result in top-down multiple human parsing. By explicitly introducing global semantic enhanced multi-scale features and learning the mIoU between instance parsing map and matched ground-truth, our RP R-CNN outperforms previous state-of-the-art methods consistently for all the evaluation metrics. In addition, we also adopt a new combination strategy, which improves the results of multiple human parsing by global semantic segmentation and instance-level semantic segmentation. We hope our effective approach will serve as a cornerstone and help the future research in multiple human parsing. \clearpage \bibliographystyle{splncs04}
{'timestamp': '2020-09-22T02:17:21', 'yymm': '2009', 'arxiv_id': '2009.09447', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09447'}
arxiv
\section{Proofs} \subsection{Proof of Proposition~\ref{prop_2}} \label{proof:prop2} \begin{proof} Perfect reconstruction $\Rightarrow$: $\forall \omega, \forall x \in \omega$, $x= \sum_{k=1}^{h} \left \langle x, a^{E}_k[\omega] \right \rangle a^{D}_k[\omega]$. We have $\forall \omega, \forall x \in \omega$ \begin{align*} \sum_k \left \langle x, a^{E}_k[\omega] \right \rangle a^{D}_k[\omega] & = \sum _{k=1}^{h} \left \langle \sum_{k'=1}^{h} \left \langle x, a^{E}_{k'}[\omega] \right \rangle a^{D}_{k'}[\omega] , a^{E}_k[\omega] \right \rangle a^{D}_k[\omega] \\ & = \sum_k \sum_{k'=1}^{h} \left \langle x, a^{E}_{k'}[\omega] \right \rangle \left \langle a^{D}_{k'}[\omega], a^{E}_k[\omega] \right \rangle a^{D}_k[\omega] \end{align*} $\iff A^{D}_{\omega} A^{E}_{\omega} x = A^{D}_{\omega} A^{D^{T}}_{\omega} A^{E^{T}}_{\omega} A^{E}_{\omega} x$ since $A^{D}_{\omega}A^{E}_{\omega}$ is injective on the region (as per perfect reconstruction condition) it implies that $ A^{D^{T}}_{\omega} A^{E^{T}}_{\omega} = I_h$, where $I_h$ is the identity matrix of dimension $h \times h$ \end{proof} \subsection{Proof of Corrolary~\ref{cor:corrolary_reconst}} \label{proof:corrolary1} \begin{proof} For a $2$-layers ReLU autoencoder network, we have the following affine spline parameters $\forall x \in \omega$: \begin{align*} a_{k'}^{E}[\omega] = 1_{\left \{ W^{1^T}_{k',.} x >0 \right \} } W^{1}_{k',.} \\ a_{k}^{D}[\omega] = \begin{pmatrix} 1_{\left \{ W^{2^T}_{1,.} \boldsymbol{z} >0 \right \} } \\ \vdots \\ 1_{\left \{ W^{2^T}_{d,.} \boldsymbol{z} >0 \right \} } \\ \end{pmatrix} \cdot W^2_{.,k} \end{align*} where $\cdot$ defines here the elementwise vector multiplication. Now, \begin{align*} \left \langle a_k^D[\omega] , a^{E}_{k'}[\omega] \right \rangle & = \left \langle Q^2_{\omega} W^2_{.,k}, 1_{\left \{ W^{1^T}_{k',.} x >0 \right \}} W^{1}_{k',.} \right \rangle \\ & = 1_{ \left \{ W^{1^T}_{k',.} x >0 \right \} } W^{2^T}_{.,k} Q^2_{\omega} W^{1}_{k',.} \\ &= 1_{ \left \{ W^{1^T}_{k',.} x>0 \right \} } W^{2^T}_{.,k} \begin{pmatrix} 1_{ \left \{ W^{2^T}_{1,.} \boldsymbol{E}(x)>0 \right \} } W^{1}_{k',1} \\ \vdots \\ 1_{ \left \{ W^{2^T}_{n,.} \boldsymbol{E}(x)>0 \right \} } W^{1}_{k',d} \\ \end{pmatrix} \\ & = 1_{ \left \{ W^{1^T}_{k',.} x>0 \right \} } \left ( \sum_{i=1}^{d} W^{2}_{i,k} W^{1}_{k',i} 1_{ \left \{ W^{2^T}_{i,.} \boldsymbol{E}(x)>0 \right \} } \right ) \end{align*} \end{proof} \subsection{Proof of Theorem~\ref{prop:oneisenough}} \label{proof:cor1} \begin{proof} For both cases, we recall that we assume that $\forall \theta, x(\theta) \neq 0 $. In fact, relaxing such assumption would lead to a degenerated case where the interpolant can be constant and equal to $0$. In practice this assumption is more than realistic as the '$0$-datum' is usually not part of any dataset. Let's first consider the case $k=1$. \\ \\ We know that the solution of $\frac{d\boldsymbol{f}(\theta)}{d \theta} =G\boldsymbol{f}$ is $\boldsymbol{f}(\theta) = \exp(\theta G) \boldsymbol{f}(0)$. Now it is clear that if $\exists \theta_1$ such that $\boldsymbol{f}(\theta_1) = \boldsymbol{x}(\theta_1)$, then $\boldsymbol{f}(0) = \boldsymbol{x}(0)$, and therefore, $\boldsymbol{f}(\theta) = \exp(\theta G ) \boldsymbol{x}(0) = \boldsymbol{x}(\theta)$, $\forall \theta$. \\ \\ Now for the case $k=2$, \\ \\ Let $y(\theta) = \frac{d f(\theta)}{d \theta}$, then we have \[ \frac{ d \boldsymbol{y}(\theta)}{d \theta} = G \boldsymbol{y}(\theta), \] which solution is \[ \boldsymbol{y}(\theta) = \exp(\theta G) \boldsymbol{y}(0). \] Thus, $\frac{d \boldsymbol{f}}{d \theta} = \exp(\theta G) \frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0}$. Now since \[\exp(\theta G) G\frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0} = \sum_{n \geq 0} \frac{G^{n}}{n!} G \frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0} = \sum_{n \geq 0} G \frac{G^{n}}{n!} \frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0} = G \exp(\theta G) \frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0} \] we have that, \[ \boldsymbol{f}(\theta) = \exp(\theta G) G^{-1} \frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0} +c \boldsymbol{1}, \] where $c \in \mathbb{R}$ and $\boldsymbol{1}$ denotes the $d$-dimensional vector of $1$. Let's now add the interpolation condition, that is \[ \exists \theta_1, \theta_2, \text{ s.t. } \boldsymbol{f}(\theta_1) = \boldsymbol{x}(\theta_1), \; \; \boldsymbol{f}(\theta_2) = \boldsymbol{x}(\theta_2) \] Which is equivalent to \[ \left\{\begin{matrix} \exp(\theta_1 G) G^{-1}\frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0} + c \boldsymbol{1}= \exp(\theta_1G) x(0) \\ \exp(\theta_2 G) G^{-1}\frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0} + c \boldsymbol{1}= \exp(\theta_2G) x(0) \\ \end{matrix}\right. \] Which implies that, $\frac{d \boldsymbol{f}(\theta)}{d \theta }|_{\theta=0}= Gx(0)$ and that $c=0$. Therefore, \[ \boldsymbol{f}(\theta) = \exp(\theta G) x(0) = x(\theta), \forall \theta \] \end{proof} \subsection{Proof of Proposition~\ref{prop:theta_1}} \label{proof:cortheta_1} \begin{proof} \begin{align*} \left \| \boldsymbol{D}(\theta) - (I+\sum_{k=1}^h \epsilon_k G_k) \boldsymbol{D}(\theta') \right \|_2^2 &= \left \| \boldsymbol{D}(\theta) - \boldsymbol{D}(\theta') - \sum_{k=1}^h \epsilon_k G_k \boldsymbol{D}(\theta') \right \|_2^2 \\ & = \left \langle \boldsymbol{D}(\theta) - \boldsymbol{D}(\theta') , \boldsymbol{D}(\theta) - \boldsymbol{D}(\theta') \right \rangle \\ & \; \;\;\;\;\; \;\;\;\;\; -2 \left \langle \boldsymbol{D}(\theta) - \boldsymbol{D}(\theta'), \sum_{k=1}^h \epsilon_k G_k \boldsymbol{D}(\theta') \right \rangle \\ & \; \; \; \;\;\;\;\;\;\;\;\;\; + \left \langle \sum_{k=1}^h \epsilon_k G_k \boldsymbol{D}(\theta'), \sum_{k=1}^h \epsilon_k G_k \boldsymbol{D}(\theta') \right \rangle, \end{align*} Now, $\forall j \in \left \{1,\dots, h \right \}$ \begin{align*} \frac{\delta \left \|\boldsymbol{D}(\theta) - \boldsymbol{D}(\theta') - \sum_{k=1}^{h} \epsilon_k G_k \boldsymbol{D}(\theta') \right \|^2_{2}}{\delta \epsilon_j} & = -2 (\boldsymbol{D}(\theta)-\boldsymbol{D}(\theta'))^T G_j \boldsymbol{D}(\theta') + 2 \sum_{k=1}^h \epsilon_k \boldsymbol{D}(\theta')^T G_k^T G_j \boldsymbol{D}(\theta'), \end{align*} setting $\frac{\delta \left \|\boldsymbol{D}(\theta) - \boldsymbol{D}(\theta') - \sum_{k=1}^{h} \epsilon_k G_k \boldsymbol{D}(\theta') \right \|^2_{2}}{\delta \epsilon_j} =0$, for all $j$ we obtain \[ \epsilon^* = \begin{pmatrix} \left \| G_1 \boldsymbol{D}(\theta') \right \|_2^2 & \dots & \boldsymbol{D}(\theta')^T G_h^T G_1 \boldsymbol{D}(\theta') \\ \vdots & \ddots & \vdots \\ \boldsymbol{D}(\theta')^T G_1^T G_h \boldsymbol{D}(\theta') & \dots & \left \| G_h \boldsymbol{D}(\theta') \right \|_2^2 \end{pmatrix}^{-1} \begin{pmatrix} (\boldsymbol{D}(\theta) - \boldsymbol{D}(\theta'))^T G_1 \boldsymbol{D}(\theta') \\ \vdots \\ (\boldsymbol{D}(\theta) - \boldsymbol{D}(\theta'))^T G_h \boldsymbol{D}(\theta') \end{pmatrix} \], and we have that \[ \begin{pmatrix} \left \| G_1 \boldsymbol{D}(\theta') \right \|_2^2 & \dots & \boldsymbol{D}(\theta')^T G_h^T G_1 \boldsymbol{D}(\theta') \\ \vdots & \ddots & \vdots \\ \boldsymbol{D}(\theta')^T G_1^T G_h \boldsymbol{D}(\theta') & \dots & \left \| G_h \boldsymbol{D}(\theta') \right \|_2^2 \end{pmatrix} = \begin{pmatrix} G_1 \boldsymbol{D}(\theta') \\ \vdots \\ G_h \boldsymbol{D}(\theta') \end{pmatrix}^T \begin{pmatrix} G_1 \boldsymbol{D}(\theta') \\ \vdots \\ G_h \boldsymbol{D}(\theta') \end{pmatrix} \] which is thus a positive definite matrix. \end{proof} \subsection{Proof of Proposition~\ref{prop:theta_2}} \label{proof:cortheta_2} \begin{proof} Given $J_{\omega'}[\boldsymbol{D}]= A^{D}_{\omega'} $ and $ J_{\omega}[\boldsymbol{D}] = A^{D}_{\omega}$, we have \begin{align*} \left \| A_{\omega'}^{D} - A_{\omega}^{D} - \sum_{k=1}^{h} \epsilon_k G_k A_{\omega}^{D} \right \|^2_{F} & = \Tr ( (A_{\omega'}^{D} - A_{\omega}^D -\sum_{k=1}^{h} \epsilon_k G_k A^{D}_{\omega}) \odot (A_{\omega'}^{D} - A_{\omega}^D -\sum_{k=1}^{h} \epsilon_k G_k A^{D}_{\omega}) 1 1^T ) \\ & = \text{Tr} ( A^{D}_{\omega'} \odot A^{D}_{\omega'} - A^{D}_{\omega'} \odot A^{D}_{\omega} - A^{D}_{\omega'} \odot (\sum_{h=1}^{k} \epsilon_k G_k A^{D}_{\omega}) + A^{D}_{\omega} \odot A^{D}_{\omega} \\ & \hspace{.5cm} \; \: - A^{D}_{\omega} \odot A^{D}_{\omega'} + A^{D}_{\omega} \odot (\sum_{h=1}^{k} \epsilon_k G_k A^{D}_{\omega})- (\sum_{h=1}^{k} \epsilon_k G_k A^{D}_{\omega}) \odot A^{D}_{\omega'} \\ & \hspace{.5cm} \; \: + (\sum_{h=1}^{k} \epsilon_k G_k A^{D}_{\omega}) \odot A^{D}_{\omega} + (\sum_{h=1}^{k} \epsilon_k G_k A^{D}_{\omega}) \odot (\sum_{h=1}^{k} \epsilon_k G_k A^{D}_{\omega}) ) 1 1^T ). \end{align*} Now, $\forall j \in \left \{1,\dots,h \right \}$ \begin{align*} \frac{\delta \left \| A_{\omega'}^{D} - A_{\omega}^{D} - \sum_{k=1}^{h} \epsilon_k G_k A_{\omega}^{D} \right \|^2_{F}}{\delta \epsilon_j} & = 2 \Tr ( (G_j A^{D}_{\omega}) \odot (A^{D}_{\omega} - A^{D}_{\omega'} + \sum_{k=1}^{h} G_k A^{D}_{\omega} 1 1^{T})) \\ & = 2 \Tr (G_j A^{D}_{\omega} \odot (A^{D}_{\omega}- A^{D}_{\omega'}) 1 1^{T}) \\ & \hspace{.5cm} + 2 \sum_{k=1}^{h} \epsilon_k \Tr( (G_j A^{D}_{\omega} \odot G_k A^{D}_{\omega}) 11^T), \end{align*} setting $\frac{\delta \left \| A_{\omega'}^{D} - A_{\omega}^{D} - \sum_{k=1}^{h} \epsilon_k G_k A_{\omega}^{D} \right \|^2_{F}}{\delta \epsilon_j}=0$ for all $j$ and rearranging in matrix form gives \[ \epsilon^* = \tiny{ \begin{pmatrix} \sum_{i}\|G_1 [A_{\omega}^D]_{.,i}\|_2^2 & \dots & \sum_i \langle G_1 [A_{\omega}^D]_{.,i},G_h [A_{\omega}^D]_{.,i}\rangle \\ \vdots & \ddots & \vdots\\ \sum_i \langle G_h [A_{\omega}^D]_{.,i},G_1 [A_{\omega}^D]_{.,i}\rangle & \dots & \sum_{i}\|G_h [A_{\omega}^D]_{.,i}\|_2^2 \end{pmatrix}^{-1} \begin{pmatrix} \sum_i \langle G_1 [A_{\omega}^D]_{.,i},[A_{\omega'}^D]_{.,i} - [A_{\omega}^D]_{.,i}) \\ \vdots \\ \sum_i \langle G_h [A_{\omega}^D]_{.,i},[A_{\omega'}^D]_{.,i} - [A_{\omega}^D]_{.,i})\end{pmatrix}} ,\] and we have that \[ \tiny{ \begin{pmatrix} \sum_{i}\|G_1 [A_{\omega}^D]_{.,i}\|_2^2 & \dots & \sum_i \langle G_1 [A_{\omega}^D]_{.,i},G_h [A_{\omega}^D]_{.,i}\rangle \\ \vdots & \ddots & \vdots\\ \sum_i \langle G_h [A_{\omega}^D]_{.,i},G_1 [A_{\omega}^D]_{.,i}\rangle & \dots & \sum_{i}\|G_h [A_{\omega}^D]_{.,i}\|_2^2 \end{pmatrix} = \sum_{i=1}^{h} \begin{bmatrix} G_1 [A_{\omega}^D]_{.,i}\\ \vdots \\ G_h [A_{\omega}^D]_{.,i} \end{bmatrix}^T \begin{bmatrix} G_1 [A_{\omega}^D]_{.,i}\\ \vdots \\ G_h [A_{\omega}^D]_{.,i} \end{bmatrix}}, \] therefore it is the sum of positive definite matrices. For the case h=1, we have that \begin{align*} \left \| a_{\omega'}^{D} - a_{\omega}^{D} - \epsilon G a_{\omega}^{D} \right \|^2 & = \left \langle a_{\omega'}^{D} , a_{\omega'}^{D}\right \rangle - 2 \left \langle a_{\omega'}^{D}, a_{\omega}^{D} \right \rangle + \left \langle a_{\omega}^{D}, a_{\omega}^{D} \right \rangle \\ & \hspace{1cm} + 2 \left \langle \epsilon G a_{\omega}^{D}, a_{\omega}^{D} - a_{\omega'}^{D} \right \rangle + \left \langle \epsilon G a_{\omega}^{D}, \epsilon G a_{\omega}^{D} \right \rangle, \end{align*} thus, \begin{align*} \frac{\delta \left \| a_{\omega'}^{D} - a_{\omega}^{D} - \epsilon G a_{\omega}^{D} \right \|^2}{\delta \epsilon} = a_{\omega}^{D^T} G^T (a_{\omega}^{D}-a_{\omega'}^{D}) + \epsilon a_{\omega}^{D^T} G^T G a_{\omega}^{D} \end{align*} \end{proof} For the following proofs, we will denote by $T: \mathbb{R}^{d} \times \mathbb{R}^{h} \rightarrow \mathbb{R}^d$, the transformation operator taking as input a datum and a group parameter, and giving as output the transformed datum. As we used a Lie group, we can define this operator analytically as $T(x,\theta)= \exp(\theta G) x$. \subsection{Proof of Theorem~\ref{prop:tang}} For this proof, we will use the notation $\mathcal{T}_{\mathcal{X}}(\omega)$ as the tangent space of the manifold described by the data $\mathcal{X}$ for the data in the region $\omega$, and by $\mathcal{T}_{AE}(\omega)$ the tangent space of the AE for the region $\omega$. We show that if these two tangent space coincides for a given region, i.e., if the tangent space of the AE coincides with the tangent space of the manifold for a specific position, then they coincide everywhere. \label{proof:tang} \begin{proof} By assumption, we know that $\left \{ a^{D}_1(\omega'),\dots, a^{D}_h[\omega'] \right \}$ form a basis of $\mathcal{T}_{\mathcal{X}}[\omega']$. If the regularization is satisfied, we also know that the tangent induced by the AE at position $\omega$, denoted by $\mathcal{T}_{AE}(\omega)$, is equal to $T(\mathcal{T}_{\mathcal{X}}(\omega'),\theta)$. In fact, for the order $k=2$ the regularization imposes that the tangent (induced by the AE) of the different regions are transformed version of each other by the transformation operator $T$. Now for the order one, we know that if $\frac{d \boldsymbol{f}(\theta)}{d \theta} = G \boldsymbol{f}(\theta)$, then $\frac{d^2 \boldsymbol{f}(\theta)}{d \theta^2} = G \frac{d \boldsymbol{f}(\theta)}{d \theta}$. Which means that if the outputs of the interpolant $\boldsymbol{f}$ are connected by the transformation group $T$, then the tangents of such interpolant are also connected by the same group of transformation. Note that the operator $T$ forms a Lie group action operator, it is a diffeomorphism from the orbit of the group to the orbit of the group. Therefore, $\forall \omega$, it exists $\theta$ such that $T(\mathcal{T}_{\mathcal{X}}(\omega'),\theta)= \mathcal{T}_{\mathcal{X}}(\omega)$. Per assumption, the tangent of the region $\omega'$,i.e. $\mathcal{T}_{AE}(\omega')$ is actually tangent to $\mathcal{X}$ as its basis coincides with $\mathcal{T}_{\mathcal{X}}(\omega')$. Denote by $x \in \mathcal{X}$ the point at which $\mathcal{T}_{\mathcal{X}}(\omega')$ and $\mathcal{X}$ intersects. Let's first first prove that for $\epsilon'= \argmax_{\epsilon} x + \epsilon h \in \omega$, where $h \in \mathcal{T}_{\mathcal{X}}(\omega')$, that is, $x+ \epsilon' h$ lies at the boundary of the region $\omega'$. We further assume that $\left \|h \right \|=1$ such that $\epsilon'= \text{Rad}(\omega')$. Let's define a smooth curve on the manifold $\gamma: \mathbb{R} \rightarrow \mathcal{X}$ such that $\gamma(0)=x$ and $\gamma'(0) = h$. Now, \begin{align*} d(x+\epsilon' h,\mathcal{X}) & \leq d(x+\epsilon' h, \gamma(\epsilon')) \\ & = \left \| \gamma(\epsilon') - \gamma(0) - \epsilon' \gamma'(0) \right \|. \end{align*} Since, $\lim_{\epsilon' \rightarrow 0} \frac{\gamma(\epsilon') - \gamma(0)}{\epsilon'} =\gamma'(0)$, we have that $\frac{d(x+\epsilon'h,\gamma(\epsilon'))}{\epsilon'} = o(\text{Rad}(\omega'))$. Then, since the $\omega_i \forall i \in \left \{1,\dots, |\Omega| \right \}$ form a partition of $\Omega$ and that by Proposition~\ref{prop:tang} we know that since one tangent of the AE coincides with the tangent of the manifold at the point $x$ then any tangent of the AE coincides with a tangent of the manifold. Thus, we have that $d \left ( \cup_{\omega \in \Omega} \mathcal{T}_{AE}(\omega), \mathcal{X} \right ) = \sum_{i=1}^{|\Omega|} d \left ( \mathcal{T}_{AE}(\omega_i), \mathcal{X} \right ) \leq \sum_{i=1}^{|\Omega|} \text{Rad}(\omega_i)$. \end{proof} \iffalse \subsection{Updates for $G$} \textbf{Case $h=1$:} For sake of clarity we will denote $J_{\omega}^{D}= J_{\omega}$ and $H_{\omega,\omega'} = A_{\omega}-A_{\omega'}$. \begin{align*} \argmin_{G} & \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \left\| A^{D}_{\omega} - (I+\theta_{\omega,\omega'} G A^{D}_{\omega'})\right \|^2_{F} \\ & = \argmin_G \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \left\| H^{D}_{\omega,\omega'} -\theta_{\omega,\omega'} G A^{D}_{\omega'}\right \|^2_{F} \\ & = \argmin_{G} \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \Tr \left [ ( H^{D}_{\omega,\omega'} - \theta_{\omega,\omega'} G J_{\omega'}^{D} ) ( H^{D}_{\omega,\omega'} - \theta_{\omega,\omega'} G J_{\omega'}^{D} )^T \right ] \\ & = \argmin_{G} \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \Tr \left [ -\theta_{\omega,\omega'} H_{\omega,\omega'} J_{\omega'}^{T} G^T - \theta G J_{\omega'} H_{\omega,\omega'}^{T} + \theta_{\omega,\omega'}^2 G J_{\omega'} J_{\omega'}^T G^T \right ] \\ & = \argmin_{G} \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \Tr \left [ - 2 \theta_{\omega,\omega'} G J_{\omega'} H_{\omega,\omega'}^{T} \right ] + \Tr \left [ \theta_{\omega,\omega'}^2 G J_{\omega'} J_{\omega'}^T G^T \right ] \end{align*} Now, \begin{align*} \frac{\delta \left [ \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \left\| A_{\omega} - (I+\theta_{\omega,\omega'} G) A_{\omega'}) \right \|^2_{F} \right ] }{\delta G} = \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \left [ -2 \theta_{\omega,\omega'} H_{\omega,\omega'} J_{\omega'}^{T} + 2 \theta_{\omega,\omega'}^2 G J_{\omega'} J_{\omega'}^T \right ]. \end{align*} Therefore, \begin{align*} G^{\star} = \left ( \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \theta_{\omega,\omega'} (A_{\omega} - A_{\omega'}) A_{\omega'}^T \right ) \left ( \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \theta_{\omega,\omega'}^2 A_{\omega'} A_{\omega'}^T \right )^{-1}. \end{align*} \fi \iffalse \textbf{Multi-dimensional case:} \begin{align*} \argmin_{G} & \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \left\| H_{\omega, \omega'} + \sum_{k=1}^{h} \theta_k G_k A_{\omega'} \right \|^2_{F} \\ & = \argmin_G \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \Tr \left [ \left (H_{\omega,\omega'} - \sum_{k} \theta_k G_k J_{\omega'} \right ) \left (H_{\omega,\omega'} - \sum_{k} \theta_k G_k J_{\omega'} \right )^T \right ] \\ &= \argmin_{G} \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \Tr \left [ - 2 \sum_k \theta_k G_k J_{\omega'} H_{\omega,\omega'}^{T} + \sum_{k,i} \theta_i \theta_k G_k J_{\omega'} J_{\omega'}^T G_i^T \right ]. \end{align*} Now, \begin{align*} \frac{\delta \left [ \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} -2 \sum_k \theta_k \Tr \left ( G_k J_{\omega'} H_{\omega,\omega'}^T \right ) \right ] }{\delta G_j} = -2 \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \theta_j H_{\omega,\omega'} J_{\omega'}^T , \end{align*} and, \begin{align*} \sum_{\omega \in \Omega^D} & \sum_{\omega' \in \mathcal{N}(\omega)} \sum_{k,i} \theta_i \theta_k \Tr \left [ G_k J_{\omega'} J_{\omega'}^T G_i^T \right ] \\ & = \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \sum_{i} \theta_i^2 \Tr \left [ G_i J_{\omega'} J_{\omega'}^T G_i^T \right ] + \sum_i \sum_{k \neq i } \theta_i \theta_k \Tr \left [ G_i J_{\omega'} J_{\omega'}^T G_k^T \right ] \end{align*} which derivative with respect to $G_j$ equals \begin{align*} \frac{\delta }{\delta G_j} = \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} 2 \theta_j^2 G_j J_{\omega'} J_{\omega'}^T + 2 \sum_{k \neq j} \theta_j \theta_k G_k J_{\omega'} J_{\omega'}^T. \end{align*} Therefore, \begin{align*} \frac{\delta \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} \left\| H_{\omega, \omega'} + \sum_{k=1}^{h} \theta_k G_k A_{\omega'} \right \|^2_{F}}{\delta G_j} & = \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} (-2 \theta_j H_{\omega,\omega'} J_{\omega'}^T \\ & \; \; + 2 \theta_j^2 G_j J_{\omega'} J_{\omega'}^T + 2 \sum_{k \neq j} \theta_j \theta_k G_k J_{\omega'} J_{\omega'}^T). \end{align*} Thus, \begin{align*} G_{j}^{\star} = \left ( \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} H_{\omega,\omega'} J_{\omega'}^T \right ) \left ( \sum_{\omega \in \Omega^D} \sum_{\omega' \in \mathcal{N}(\omega)} J_{\omega'} J_{\omega'}^T \right )^{-1} - \sum_{k \neq j} \frac{\theta_k}{\theta_j} G_k \end{align*} \fi \subsection{Per Region Tangent - Details} \label{ap:jaco} Let $[\textbf{D} \circ \textbf{E}(.)]_i: \mathbb{R}^d \rightarrow \mathbb{R}$ be the $i^{th}$ coordinate output of the AE, defined as $[\textbf{D} \circ \textbf{E}(x)]_{i} = [A^D_{\omega}]_{i,.}A^{E}_{\omega}x + [A^{D}_{\omega}]_{i,.} B^{E}_{\omega} + [B^{D}_{\omega}]_{i}$. \begin{align} \textit{d}[\textbf{D} \circ \textbf{E}(.)]_i &=[\textbf{D} \circ \textbf{E}(x+\epsilon)]_i-[(\textbf{D} \circ \textbf{E})(x)]_i =\left \langle A_{\omega}^{{E}^T} [A^D_{\omega}]_{i,.}^T, \epsilon \right \rangle, \forall \epsilon \in \mathbb{R}^{d}. \end{align} As such, we directly obtain that \begin{align} \nabla_{x} [\textbf{D} \circ \textbf{E}(.)]_i = A_{\omega}^{{E}^T} [A^D_{\omega}]_{i,.}^T, \end{align} which leads to the Jacobian of the AE as defined in Eq.~\ref{eq:jaco}. \subsection{Higher-order Contractive Autoencoder: Details} \label{sec:hoc} Let consider the case of a 1 hidden-layer encoder, follows by any depth encoder. In the second order regularization, one penalizes $\left \|A^{E}_{\omega} - A^{E}_{\omega'} \right \|_{F}$, where $\omega$ and $\omega'$ are neighboring regions. We know that $A^{E}_{\omega}= Q^{1}_{\omega} W^1$, now let consider the case of a $3$ ReLU-units encoder, that is, $Q_{\omega}^{1}$ is a $3 \times 3$ diagonal matrix, and $W^1 \in \mathbb{R}^{3 \times n}$, where $n$ is the input space dimension. A particular case we consider for our analysis is, $Q^{1}_{\omega} = \text{Diag}(1,0,1)$, and $Q^{1}_{\omega'} = \text{Diag}(1,1,1)$, i.e., the first region $\omega$ is encoded by $2$ activated ReLUs and $\omega'$ by $3$. The associated HOC penalization is $\left \| \begin{pmatrix} W^{1}_{1,:}\\ 0\\ W^{1}_{3,:} \end{pmatrix} - \begin{pmatrix} W^{1}_{1,:}\\ W^{1}_{2,:}\\ W^{1}_{3,:} \end{pmatrix} \right \|_{F} = \left \| W^{1}_{2,:} \right \|_2$, where $W^{1} = \begin{pmatrix} W^{1}_{1,:}\\ W^{1}_{2,:}\\ W^{1}_{3,:} \end{pmatrix}$. Therefore we see even if $W^{1}_{1,:}$ or $W^{1}_{3,:}$ are large, they will not induce a penalization of the curvature between the region $\omega$ and $\omega'$. Besides, if $W^{1}_{2,:}$ is small, even thought it is associated with the changing unit between the two regions, the curvature will not be penalized either. \section{Optimal Parameters} \label{app:params} The following proposition provides the optimal transformation parameters $\epsilon^{\star} = \left [\epsilon_1,\dots,\epsilon_h \right ]^T$ that are used during the learning of the regularized AE. \begin{prop} \label{prop:theta_1} The $\epsilon$ of the first-order regularization defined in Eq.~\ref{eq:regAE_first} is obtained as \setlength\itemsep{.004em} \[ \epsilon^* = \begin{pmatrix} \left \| G_1 \boldsymbol{D}(\theta') \right \|_2^2 & \dots & \left \langle G_h \boldsymbol{D}(\theta') , G_1 \boldsymbol{D}(\theta') \right \rangle \\ \vdots & \ddots & \vdots \\ \left \langle G_1 \boldsymbol{D}(\theta'), G_h \boldsymbol{D}(\theta') \right \rangle & \dots & \left \| G_h \boldsymbol{D}(\theta') \right \|_2^2 \end{pmatrix}^{-1} \begin{pmatrix} \left \langle \boldsymbol{D}(\theta) - \boldsymbol{D}(\theta'), G_1 \boldsymbol{D}(\theta') \right \rangle \\ \vdots \\ \left \langle \boldsymbol{D}(\theta) - \boldsymbol{D}(\theta'), G_h \boldsymbol{D}(\theta') \right \rangle \end{pmatrix}\] where the matrix is always invertible ($\textbf{D}(\theta') \neq 0$). (Proof in Appendix~\ref{proof:cortheta_1}.) \end{prop} \begin{prop} \label{prop:theta_2} The $\epsilon$ of the second-order regularization defined in Eq.~\ref{eq:regAE_second} is obtained by \[ \epsilon^* = \tiny{\begin{pmatrix} \sum_{i}\|G_1 [A_{\omega}^D]_{.,i}\|_2^2 & \dots & \sum_i \langle G_1 [A_{\omega}^D]_{.,i},G_h [A_{\omega}^D]_{.,i}\rangle \\ \vdots & \ddots & \vdots\\ \sum_i \langle G_h [A_{\omega}^D]_{.,i},G_1 [A_{\omega}^D]_{.,i}\rangle & \dots & \sum_{i}\|G_h [A_{\omega}^D]_{.,i}\|_2^2 \end{pmatrix}^{-1} \begin{pmatrix} \sum_i \langle G_1 [A_{\omega}^D]_{.,i},[A_{\omega'}^D]_{.,i} - [A_{\omega}^D]_{.,i}) \\ \vdots \\ \sum_i \langle G_h [A_{\omega}^D]_{.,i},[A_{\omega'}^D]_{.,i} - [A_{\omega}^D]_{.,i})\end{pmatrix}},\] where the matrix is invertible ($A_{\omega}^{D} \neq 0$). (Proof in Appendix~\ref{proof:cortheta_2}.) \end{prop} \section{Orbit of a Lie Group} \label{Lieexample} One example of the orbit of a data with respect to a Lie group is the result of the rotation on an initial point $x(0) \in \mathbb{R}^2$, we have $x(\theta) = \exp(\theta G)x(0), \theta \in \mathbb{R}, G = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}$. In fact, where we recall that $\exp(\theta \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}) = \begin{pmatrix} \cos(\theta) & -\sin(\theta)\\ \sin(\theta) & \cos(\theta) \end{pmatrix}.$ The infinitesimal operator $G$ is thus encapsulating the group information. For more details regarding Lie group and the exponential map refer to \cite{hall2015lie}. \iffalse \section{Sampling} \label{ap:sampling} \fi \section{Datasets} \label{ap:dataset} Most of the datasets used for the experiments are extracted from the univariate time-series repository in \citet{bagnall16bakeoff}. Some of them are recording from sensors or simulated data. They range from motion time-series to biological one. The dimension of the data we used is between $200-1000$. MNIST \citep{deng2012mnist}, is a handwritten digit dataset containing $60.000$ training and $10.000$ test images of dimension $28 \times 28$ representing $10$ classes. This is an example of a dataset where the intra-class viariability is induced by group transformations such as rotation, translation, and small diffeomorphism CIFAR$10$ \citep{krizhevsky2009learning}, consists of $50.000$ training colour images and $10.000$ test color images of dimension $32\times32$ representing $10$ classes. In this dataset, the transformation required to go from one data to another requires more than simple rigid transformations. \iffalse \section{Best Hyperparameters} \label{ap:besthyper} \begin{table}[h] \caption{Best Hyperparameters for each AE (columns) and Dataset (rows).} \begin{adjustbox}{width=\columnwidth,center} \begin{tabular}{|l|c|c|c|c|} \hline \textit{Dataset \: \textbackslash \; Model} & \textbf{Denoising AE} $(\epsilon)$ & \textbf{High-Order Contractive AE} $(\epsilon, \lambda)$ & \textbf{Lie Group AE ($1^{th})$} $(\lambda)$ &\textbf{Lie Group AE} $(\lambda)$\\\hline \hline \textbf{Single Class ($2$) MNIST} & $0.01$ & $0.1 , 100$ & & $0.01 $\\ \hline \textbf{Single Class ($5$) MNIST} & $0.1$ & $0.1 , 0.001$ & & $0.01 $\\ \hline \textbf{Single Class ($7$) MNIST} & $0.1$ & $0.1, 100$ & & $100 $\\ \hline \textbf{CBF} & $0.1$ & $ 1.0, 0.1 $ & & $100 $\\ \hline \textbf{Yoga} & $0.1$ & $1.0, 0.1$ & & $10 $\\ \hline \textbf{Trace} & $1.0$ & $1.0, 0.01$ & & $10 $\\ \hline \textbf{Wine} & $0.01$ & $1.0, 0.01$ & & $0.1 $\\ \hline \textbf{ShapesAll} & $0.1$ & $1.0, 100$ & & $0.1 $\\ \hline \textbf{FiftyWords} & $0.1$ & $ 1.0, 0.1$ & & $10.0 $\\ \hline \textbf{WordSynonyms} & $0.1$ & $ 1.0, 0.1 $& & $10 $\\ \hline \textbf{InsectWingbeatSound} & $0.1$ & $ 1.0, 0.1$ & & $1.0$\\ \hline \textbf{MNIST} & $0.1 $ & $0.1 , 100$ & & $100 $\\ \hline \textbf{ECG500} & $0.01$& $1.0, 0.001 $& $0.1$ &$0.1$\\ \hline \textbf{Earthquakes} & $1.0$ & $1.0, 100$ & & $100 $\\ \hline \textbf{Haptics} & $0.01$ & $1.0, 100$ & & $0.01 $\\ \hline \textbf{FaceFour} & $0.1$ & $1.0, 0.01$ & & $1.0 $\\ \hline \textbf{SyntheticControl} & $0.1$ & $1.0, 0.01$ & & $10 $\\ \hline \end{tabular} \end{adjustbox} \label{table:app_accu} \end{table} \clearpage \section{Supplementary Results} \label{app_accu} \begin{table}[h] \caption{Comparison of the Best Testing Reconstruction Error ($\times 10^{-2})$ for each AE (columns) and Dataset (rows).} \begin{adjustbox}{width=\columnwidth,center} \begin{tabular}{|l|c|c|c|c|} \hline \textit{Dataset \: \textbackslash \; Model} & \textbf{AE} & \textbf{Denoising AE} & \textbf{High-Order Contractive AE} & \textbf{Lie Group AE} \\\hline \hline \textbf{Single Class ($2$) MNIST} & $13.46 \pm 0.9 \times 10^{-3}$ & $12.48 \pm 0.7 \times 10^{-3}$ & $ 12.53 \pm 1.3 \times 10^{-3} $ & $\textbf{12.34} \pm 0.4 \times 10^{-3} $\\ \hline \textbf{Single Class ($5$) MNIST} & $12.53 \pm 0.7 \times 10^{-3}$ & $11.76 \pm 1.1 \times 10^{-3}$ & $ 12.59 \pm 1.7 \times 10^{-3} $ & $\textbf{11.47} \pm 0.9 \times 10^{-3} $\\ \hline \textbf{Single Class ($7$) MNIST} & $13.71 \pm 5.1 \times 10^{-4}$ & $11.17 \pm 1.3 \times 10^{-4}$ & $ 11.38 \pm 3.1 \times 10^{-5} $ & $\textbf{11.05} \pm 3.1 \times 10^{-5} $\\ \hline \textbf{CBF} & $62.38 \pm 7.4 \times 10^{-3}$ & $52.66 \pm 7.66 \times 10^{-3}$ & $ 51.09 \pm 5.4 \times 10^{-3} $ & $\textbf{49.73} \pm 3.1 \times 10^{-3} $\\ \hline \textbf{Yoga} & $33.76 \pm 8.1 \times 10^{-3}$ & $33.29 \pm 7.2 \times 10^{-3}$ & $ 32.08 \pm 4.2 \times 10^{-3} $ & $\textbf{30.78} \pm 1.2 \times 10^{-2} $\\ \hline \textbf{Trace} & $13.95 \pm 4.5 \times 10^{-3}$ & $11.28 \pm 5.7 \times 10^{-3}$ & $ 12.57 \pm 2.1 \times 10^{-3} $ & $\textbf{10.91} \pm 4.5 \times 10^{-3} $\\ \hline \textbf{Wine} & $63.06 \pm 2.1 \times 10^{-4}$ & $59.34 \pm 2.1 \times 10^{-4}$ & $ \textbf{49.94} \pm 2.1 \times 10^{-4} $ & $\textbf{49.94} \pm 1.9 \times 10^{-4} $\\ \hline \textbf{ShapesAll} & $67.98 \pm 3.0 \times 10^{-2}$ & $58.67 \pm 1.4 \times 10^{-2}$ & $ 61.42 \pm 5.5 \times 10^{-2} $ & $\textbf{57.80} \pm 1.2 \times 10^{-2} $\\ \hline \textbf{FiftyWords} & $64.91 \pm 1.7 \times 10^{-2}$ & $60.91 \pm 1.0 \times 10^{-2}$ & $ 60.92 \pm 0.7 \times 10^{-2} $ & $\textbf{57.89} \pm 1.0 \times 10^{-2} $\\ \hline \textbf{WordSynonyms} & $70.95 \pm 1.5 \times 10^{-2}$ & $66.02 \pm 0.8 \times 10^{-2}$ & $ 66.52 \pm 0.5 \times 10^{-2} $ & $\textbf{62.22} \pm 1.1 \times 10^{-2} $\\ \hline \textbf{InsectWingbeatSound} & $51.86 \pm 0.6 \times 10^{-2}$ & $40.24 \pm 0.8 \times 10^{-2}$ & $ 41.93 \pm 0.6 \times 10^{-2} $ & $\textbf{38.22} \pm 0.3 \times 10^{-2} $\\ \hline \textbf{MNIST} &$12.01 \pm 3.7 \times 10^{-5}$ & $12.01 \pm 4.7\times 10^{-5} $ & $12.01 \pm 4.7\times 10^{-5} $ & $\textbf{10.13} \pm 1.8\times 10^{-3} $\\ \hline \textbf{ECG500} & $21.92 \pm 7.5 \times 10^{-3}$ & $20.31 \pm 3.9 \times 10^{-3}$& $20.31 \pm 3.6 \times 10^{-3} $& $\textbf{20.29} \pm 3.6 \times 10^{-3} $\\ \hline \textbf{Earthquakes} & $56.23 \pm 4.1 \times 10^{-2}$ & $54.62 \pm 4.1 \times 10^{-2}$ & $51.79 \pm 1.0 \times 10^{-2}$ & $\textbf{50.20} \pm 0.5 \times 10^{-2} $\\ \hline \textbf{Haptics} & $37.25 \pm 0.2 \times 10^{-2}$ & $36.02 \pm 1.8 \times 10^{-2}$ & $27.21 \pm 0.5 \times 10^{-2}$ & $\textbf{26.06} \pm 0.9 \times 10^{-2} $\\ \hline \textbf{FaceFour} & $49.82 \pm 1.0 \times 10^{-2}$ & $48.51 \pm 0.8 \times 10^{-2}$ & $48.52 \pm 0.7 \times 10^{-2}$ & $\textbf{46.00} \pm 0.6 \times 10^{-2} $\\ \hline \textbf{SyntheticControl} & $95.61 \pm 1.3 \times 10^{-2}$ & $89.37 \pm 1.0 \times 10^{-2}$ & $88.47 \pm 0.9 \times 10^{-2}$ & $\textbf{86.83} \pm 0.6 \times 10^{-2} $\\ \hline \end{tabular} \end{adjustbox} \label{table:app_accu} \end{table} \fi \clearpage \section{Additional Experimental Figures} \label{app:Figures} \begin{figure}[th!] \begin{center} \hspace{1cm} \begin{minipage}{0.17\linewidth} \begin{center} AE \end{center} \end{minipage} \begin{minipage}{0.17\linewidth} \begin{center} Contractive \\ AE \end{center} \end{minipage} \begin{minipage}{0.17\linewidth} \begin{center} Denoising \\ AE \end{center} \end{minipage} \hspace{.05cm} \begin{minipage}{0.17\linewidth} \begin{center} Lie Group \\ AE ($1^{th}$) \end{center} \end{minipage} \hspace{.05cm} \begin{minipage}{0.17\linewidth} \begin{center} Lie Group \\ AE $(2^{nd})$ \end{center} \end{minipage} \end{center} \begin{center} \centering \begin{minipage}{0.04\linewidth} \rotatebox{90}{Test Set Reconst. Error} \end{minipage} \begin{minipage}{0.95\linewidth} \includegraphics[width=1\linewidth]{haptics_errors.png} \end{minipage} \end{center} \begin{center} \centering \begin{minipage}{0.04\linewidth} \rotatebox{90}{Test Set Reconst. Error} \end{minipage} \begin{minipage}{0.95\linewidth} \includegraphics[width=1\linewidth]{facefour_errors.png} \end{minipage} \end{center} \begin{center} \hspace{.5cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \hspace{.05cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \hspace{.1cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \hspace{.2cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \hspace{.2cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \end{center} \caption{ Test set reconstruction error on the (\textit{top}) Haptics and (\textit{bottom}) Facefour datasets evaluated on the best set of parameters for different AEs (from left to right): AE, Higher Order Contractive AE, Denoising AE, Lie Group AE (first-order), and Lie Group AE (second-order). For each model, the mean over $10$ runs is reported in black, and the gray area corresponds to its standard deviation.} \label{fig:error} \end{figure} \iffalse \paragraph{Extracting Normal Vectors:} In the AE settings, the tangent planes are of dimension $h$, the bottleneck dimension, embedded in dimension $n$, the data dimension. In the case where $h<n-1$, the normal of these tangents are defined up to a continuoum of directions. For instance, in the case $h=1$ and $n=3$ the tangents are lines and for each tangent the normal is defined up to a rotation. As the transformation between the tangents of each region is defined in term their normal, we propose a way to set their direction to obtain a unique normal for each tangent. To do so, we start from the observation that the canonical angle between two sub-spaces is obtained by computing the 2-norm between their orthogonal projection operator \cite{absil2006largest}, \[ \left \| P_{\omega} - P_{\omega'} \right \|_2. \] where $\left \|.\right \|_2$ defines the 2-norm, $P_{\omega}$ corresponds to the projector onto the space spanned by the tangent of region $w \in \Omega$, that is, $P_{\omega}= A^{D}_{\omega} (A^{D^T}_{\omega}A^{D}_{\omega})^{-1} A^{D^T}_{\omega}$, where we recall that the columns of $A^{D}_{\omega}$ form a basis for the tangent space of region $\omega$. Now, it is clear that for two regions, the angle between their tangent is equal to the angle of their normal vector, if defined according to a same principled direction. The following lemma provide a way to complete the span of two adjacent region by an orthogonal subspace. We will then show that completing the subspaces induced by the neighboring tangents does not change their angle. \begin{lemma} \label{lemma:dim} Let's define $S_{\omega} = span\left \{a^D_{1}(\omega),\dots,a^D_{h}(\omega) \right \}$, that is, the subspace spanned by the columns of the tangent induced by $A^{D}_{\omega}$, then we have \[ dim( S_{\omega} \cup S_{\omega'}) = h+1 \] \end{lemma} \begin{proof} \[ dim( S_{\omega} \cup S_{\omega'}) = dim( S_{\omega} ) + dim( S_{\omega'}) - dim( S_{\omega} \cap S_{\omega'}) \] with $ dim( S_{\omega} )= dim( S_{\omega'} ) = h$. Because of the tangents are continuously connected as in Proposition~\ref{prop:continuous}, the dimension of the intersection of the span of two neighboring region is $dim( S_{\omega} \cap S_{\omega'}) = h-1$. \end{proof} From Lemma~\ref{lemma:dim}, we know that it exists an orthogonal basis of dimension $d-h-1$ that is orthogonal to both subspaces spanned by two adjacent regions, we will denote this basis by $O_{\omega,\omega'}$. The following proposition s \begin{prop} \label{prop:angle} We denote by $\hat{P}_{\omega}$ the projector on $S_{\omega} \cup O_{\omega,\omega'}$, that is, the span of the subspace induced by region $\omega$ (of dimension $d-1)$ completed by the orthogonal basis with respect to $\omega$ and its neighbor $\omega'$. We have that \[ \left \|\hat{P}_{\omega} -\hat{P}_{\omega'} \right \|_2 = \left \| P_{\omega} - P_{\omega'} \right \|_2 \]. \end{prop} \begin{proof} \begin{align*} \left \| \hat{P}_{\omega} -\hat{P}_{\omega'} \right \|_2 = \left \| P_{\omega} + P^{\bot}_{\omega,\omega'} - P^{\bot}_{\omega,\omega'} -P_{\omega'} \right \|_2, \end{align*} where $P^{\bot}_{\omega,\omega'}$ denotes the projector on the subspace $O_{\omega,\omega'}$. This equality is deduced by the fact that $S_{\omega} \obot O_{\omega,\omega'}$ and $S_{\omega'} \obot O_{\omega,\omega'}$, therefore $\hat{P}_{\omega} = P_{\omega} + P^{\bot}_{\omega,\omega'}$ and $\hat{P}_{\omega'} = P_{\omega'} + P^{\bot}_{\omega,\omega'}$, where $\obot$ defines the orthogonal direct sum operation. \end{proof} Therefore, the canonical angle between the subspaces induced by neighboring regions of dimension $h$ embedded in dimension $d$ is the same as the canonical angle of their completed version of dimension $d-1$. This construction allows us to compute the normal of both spaces that will be unique as the problem is now related to finding the remaining orthogonal dimension completing the subspace of $d-1$-dimension embedded in $d$-dimension. As such, the computation aims at finding the normal of the affine hypersurphace of dimension $d-1$. Assuming linearly independance of the vectors in $S_{\omega} \cup O_{\omega,\omega'}, \forall \omega' \in \mathcal{N}(\omega)$, we have that \begin{equation} n_{\omega} = a^{D}_{1}(\omega) \times \dots \times a^{D}_{h}(\omega) \times o_{1}(\omega,\omega') \dots \times o_{d-h-1}(\omega,\omega'), \end{equation} where $\times$ denote the cross product operator and $o_{j}(\omega,\omega')$ the $j^{th}$ basis vector of $O_{\omega,\omega'}$. \fi \section{Introduction} Autoencoders (AEs) provide a rich and versatile framework that discovers the data's salient features in an unsupervised manner. They are commonly leveraged to efficiently perform compression \citep{cheng2018deep}, denoising \citep{eraslan2019single}, data completion \citep{tran2017missing}, as well as pre-training supervised DNs \citep{erhan2010does}. Solving these tasks is equivalent to discovering the data's underlying manifold, a task becoming challenging in the high dimensional and the finite samples regime \citep{tenenbaum2000global,wang2014generalized,wang2016auto,facco2017estimating}. To overcome these challenges and improve the efficiency of AEs, various explicit or implicit regularizations have been proposed \citep{vincent2008extracting,rifai2011contractive,makhzani2013k,falorsi2018explorations}. Despite these improvements, the underlying mechanisms and generalization capability of AEs are still poorly understood \citep{li2018on,pmlr-v89-nguyen19a,lei2020geometric}. \\ \\ \indent A compelling approach to understanding the inner mechanisms of DNs considers their capability at modeling the ubiquitous symmetries in the data \citep{paul2014does,mallat2016understanding}. Theoretically grounded models such as the Deep Scattering Network and its derivatives have been derived in accordance with this principle \citep{bruna2013invariant,anden2014deep,chen2014unsupervised,joint}. In \citet{cohen2016group,DBLP:journals/corr/abs-1801-10130,kondor2018generalization} they propose to explain the success of deep convolutional architectures through the development of a theory of equivariant DNs; in particular, they provide $(i)$ an understanding and formalism behind the equivariance properties of DNs as well as their generalization, and $(ii)$ reduce the sample complexity of DNs by exploiting well-known symmetry group inherent to the image manifold. \\ \\ \indent \iffalse Parallelly to these developments, the work in \citet{rao1999learning,pmlr-v119-cosentino20a,sohl2010unsupervised,hashimoto2017unsupervised,bahroun2019similarity} consider the learnability of the group of transformation governing the data. In particular, they propose methods capable of discovering the symmetry within the data alleviating the need for explicitly defining appropriate equivalence classes for the data. In fact, in a simple computer vision dataset such as MNIST or in a music retrivial dataset such as GTZAN, there is more than translation and rotation to characterize efficiently the data \citep{ick2020learning}. While the approaches consider only symmetries in the data that explicitly modeled, another line of work consists in learning them from the data. In \citet{rao1999learning,sohl2010unsupervised,hashimoto2017unsupervised,bahroun2019similarity,pmlr-v119-cosentino20a}, they propose methods capable of discovering the symmetry within the data alleviating the need for explicitly defining appropriate equivalence classes for the data. In fact, in a simple computer vision dataset such as MNIST or in a music retrivial dataset such as GTZAN, there is more than translation and rotation to characterize efficiently the data \citep{ick2020learning}. \fi Besides explicitly imposing specific group of transformations, the studies of DNs through that lens mainly consider the properties of internal layers of DNs, e.g., {\em convolution, pooling, per-layer representation}. In this paper, we propose a global analysis by considering the DN from a geometrical standpoint. By global analysis, we consider the understanding of the output of a DN given its input in an end-to-end manner. Such analysis is presently performed by leveraging the analytical continuous piecewise affine (CPA) map formulation of DNs, as described in \citet{balestriero2018mad}. Such an approach has two significant advantages; it is agnostic of the architecture, e.g., type of layer, nonlinearities, number of layers, and it provides an analytical formula for the entire network mapping. These criteria are crucial since the understanding of AEs performed in this work has the goal of developing practical tools that are not tied to any specific AE architecture. \\ \\ \indent In the present work, the CPA formulation is leveraged to take a step into answering the following questions: $(i)$ How an AE can effectively approximate the data manifold? $(ii)$ How can one improve and guarantee the generalization of AEs exploiting the symmetry in the data? \\ \\ \indent We will execute this by considering the following two-fold approach: First, we provide an analytical and interpretable formulation of the CPA representation of the manifold spanned by AEs. We make explicit some critical properties of AEs such as what type of function do they belong to, how standard regularization techniques affect the AE mapping, and how the encoder and decoder per region affine mappings are related. Second, we exploit these insights to provide novel regularizations for AEs to capture the symmetry in the data. In particular, our regularizations constrain the global continuous piecewise affine surface spanned by AEs such that they adapt to the geometry of the data manifold modeled from as the orbit of a Lie group. We show that these regularizations constrain the entire surface even at locations in the manifold where data are missing, which is critical for the generalization of AEs. Besides, we show that these regularizations lead to generalization guarantees in the finite data regime. Our contributions can be summarized as follows: \begin{itemize}[leftmargin=*] \setlength\itemsep{.004em} \item We highlight the fact that AEs provide a CPA approximation of the data manifold. From this analytical characterization, we interpret the role of the encoder, decoder, layer parameters, and latent dimension (Sec.~\ref{sec:AE_CPA}) as well as propose reconstruction guarantees (Sec.~\ref{sec:AE_RECONS}). \item Following these findings, we obtain interpretable formulas for the Jacobian and approximated Hessian of AEs (Sec.\ref{sec:tang-hess}); and leverage them to provide insights into standard regularization techniques employed in AEs (Sec.~\ref{sec:interp_usual}). \item We demonstrate that when considering the symmetry of the data, we can impose constraints on an interpolation function, e.g., an AE, such that it approximates the data manifold driven by a Lie group (Sec.~\ref{sec:secondorderreg}). We turn these constraints into regularizations adapted to AEs and demonstrate their generalization guarantees under a finite data regime (Sec.~\ref{sec:secondorderAE}). \item We finally provide experimental validations of the developed regularizations which compete with state-of-the-art methods on various datasets (Sec.~\ref{sec:ex}). \end{itemize} \iffalse To leverage such theoretical formulation as to provide a novel regularization that constrains the piecewise linear map to approximate the data manifold. We propose to they yield a simple and provide insights regarding their partitioning of the data. provide tools enabling the understanding of AEs which can be leveraged to develop novel regularizations with theoretical guarantees. In this work, we will focus on the theoretical analysis of DNs developed in \cite{pmlr-v80-balestriero18b,balestriero2019geometry}. They propose to recast DNs as Max Affine Spline Operators which enable to express most DN architectures as piecewise linear maps. This piecewise linear structure eases the analysis of DNs and provide insights regarding their partitioning of the data. underlying the data while having access embedded non-linear manifold within the higher-dimensional space. targeting these tasks are various and depend on the assumption on the data. Howevever, a common paradigm is governing the different approaches: how to extract the low dimension A wide number of unsipervised algorithms have been developped to this aim, Deep Neural Networks (DNs) are now the common solution to obtain efficient representation of the data as to perform efficient inference, compression, as well as denoising. In particular, Autoencoders (AEs) are creating low dimensional representation of the data in an unsupervised. The extensive use of AEs lead to the development of methods improving their generalization capability\cite{rifai2011contractive,makhzani2013k,vincent2008extracting}. While various flavors of penalizations have been created and improved the effiency of AEs, their underlying mecanism is still poorly understood. In AE MANIFOLD they.... The In this work, we propose to exploit these findings by reformulating AEs as a Max Affine Spline Operator enabling us to provide an interpretation of its different components as well as understand the different AEs commonly used. In particular, the analysis of the piecewise maps of AE rises the following questions, \textit{how to guarantee an improvement the extrapolation capability of AE in a finite data regime ?} We answer this question by showing how one can structure the partitioning induced by the AE such that it actually approximate the entire data manifold. To do so, we will assume that the data lie on the orbit of a Lie group. That is, each sample from the dataset can be represented by a transformation of another one. Common well-known transformations belonging to Lie group are rotations, dilations, translations. The orbit describes a manifold where the intrinsic dimension corresponds to the dimension of the underlying group. The global consensus among the AEs work is that there is the need for an improvement of the generalization capability of AE and the creation of a framework that enable to derive guarantees. While some of these work have been able to show that their methods enhance the AE performance only from an empirical standpoint, we propose analytical guarantee that under some specific assumption on the data set, any undercomplete AE of any size and any depth, will achieve perfect generalization. Learning and extracting the salient features of data has been a central topic in machine learning and signal processing for decades. Such features are then used to perform inference, compression, vizualisation non-linear manifold underlying the dta has been a central problem in machine learning for decades. We can classify these algorithms into two families: the local and non-local approaches. Local methods are approximating the manifold by considering patch or local information regarding the data. These are generally non-parametric method and more specifically kernel-based. In fact, kernels are used to approximate the distribution of the data around each datum. These methods have well known inherent drawbacks limitating their efficiency when dealing with real and complex data. For instance, in the case of high-dimensional space, the manifold with high curvature and noise will require a large number of data to appropriately approximate the manifold. In this work, we will consider a non-local method, Deep Autoencoder. In this work, we will consider two major pioneer work in this field. (RAO) models the manifold as the result of the action of a group on the data. The learnability of the group allows the approximation of the manifold. In this work, the mapping from the data to the manifold is assumed to be linear and thus manifold to be one-dimensional. In order to learn the group, they assume that the data are either consecutives (as in a video), or close to each other. Later, (RAO) generalized to multi-dimensional manifold. On the other hand, (BENGIO) aimed at the approximation of the tangent of the manifold by a Neural Network (NN). For each datum, the NN tries to approximate the tangent that is implemented as a difference between the datum and its neighbors. As the tangent is approximated by a NN, the relation between each data and their local tangent plane is not assumed to be linear. Also, they replace the supervised framework of Rao et al. requiring pairs of data by computing for each datum their k-Nearest Neighbors (k-NN). More recently, (Hashimoto) proposed a convex relaxation of the loss function proposed by Rao, and also proposed to use k-NN to require supervision on the data. They also assume that the relation between the data and the tangent is linear. In addition, for scalability, they propose a linear approximation of the whole manifold, hence reducing the number of parameters. For each datum, the basis of the tangent manifold is linearly combined as to best approximate the local tangent. However, estimating distance between data point in a non-uniformly sample high dimensional manifold is prone to error. As this estimation is considered as the target when approximating the group generator, the overall learnability of the group transformation is tedious. The global consensus among the AE work is that there is the need for an improvement of the generalization capability of AE and the creation of a framework that enable to derive guarantees. While some of these work have been able to show that their methods enhance the AE performance only from an empirical standpoint, we propose analytical guarantee that under some specific assumption on the data set, any undercomplete AE of any size and any depth, will achieve perfect generalization. In this work, we propose to first, alleviate two aspects: the requirement of supervision regarding data pairs as well as the use of k-NN as its accuracy is highly dependant on the sampling of the data distribution as well as the dimension of the data (CITE KNN). These will be achieved by exploiting the piece-wise linear property of Deep Autoencoders (AE). As opposed to Hashimoto et al., we will be able to obtain a scalable framework while not considering a linear manifold approximation. Our contribution is two folds, on the first hand we propose to provide an efficient and accurate way of learning the group underlying the data, and on the second hand, we propose to leverage this finding to provide a novel interpretation of the AE mecanisms. In section, we propose to formulate the problem with respect to the learnability of group of transformation as well as introduced group related notations and concepts. Then, in section ,we present the notations that will be used for our derivations as well as some novel properties of AE regarding their mecanism and reconstruction guarantees. Then in section, we establish how one can recover the group underlying the data from a AE. constraints on how its piecewise linear approximation of the data is structured as per Sec.~\ref{sec:secondorderreg}. We proposed a novel approach to tackle the learnability of transformation group in the case where the data are governed by Lie group transformations. We showed that using the second-order regularization defined in Eq.~\ref{eq:reg}, we can constrain the variation of the derivative of an approximant to behave such that it approximates a group orbit, while being a data-free regularization method. Besides, this infinitesimal operator can be approximated near the identity of the group, i.e., considering tangents are close to each other. We extended this concept by instead considering the transformation between tangent planes, that is, neighboring tangent plane should be the result of a linear transformation that is governed by the generator of the group. This linear transformation should be invariant with respect to the location of the tangents planes. As in the learnable transformation group approach, the exponential map will then allows to transform one tangent plane into any other tangent plane. The analysis of the piecewise maps of AE rises the following questions, \textit{how to improve the extrapolation capability of AE ?} The next section is devoted to answering this question under the assumption that the dataset lies on the orbit of a Lie group. \fi \section{Background and Notations} This section provides the required notions regarding the three frameworks this work intertwines. \label{maso_back} \subsection{Autoencoder} An Autoencoder (AE) aims at learning an identity mapping, also known as auto-association \cite{ackley1985learning}, on a given dataset with a bottleneck latent dimension. It has been implemented first for image compression \cite{Cottrell}, speech recognition \cite{elman1988learning}, and dimensionality reduction \cite{baldi1989neural}. It is composed of two nonlinear maps: an encoder, denoted by $\boldsymbol{E}$ and a decoder, denoted by $\boldsymbol{D}$. The encoder maps an input $x \in \mathbb{R}^d$ to a hidden layer of dimension $h<d$, $\boldsymbol{E}(\boldsymbol{x})$, which encodes the salient features in the data \cite{Goodfellow-et-al-2016} and defines its \textit{code} or \text{embedding}. The decoder reconstructs the input from its \textit{code}, thus the entire AE map is defined as $\left (\boldsymbol{D} \circ \boldsymbol{E} \right) (\boldsymbol{x})$ with $\circ$ denoting the composition operator. The weights of the AE are learned based on some flavors of reconstruction losses, e.g., the mean-square error for real data and the binary cross-entropy for binary data, between the output, $\left (\boldsymbol{D} \circ \boldsymbol{E} \right )(\boldsymbol{x})$, and the input, $\boldsymbol{x}$. To improve generalization, some regularizations can complement the reconstruction loss \cite{srivastava2014dropout} such as favoring sparsity of the \textit{code} \cite{makhzani2013k} or sparsity of the weights \cite{jarrett2009best}. Other types of regularization include injecting noise in the input leading to Denoising AE known to increase the robustness to small input perturbations \cite{vincent2008extracting}. Closer to our work, \cite{rifai2011higher} and \cite{rifai2011contractive} proposed to improve the robustness of the \textit{code} to small input perturbations by penalizing the curvature of the encoder mapping by regularizing the Jacobian as well as the Hessian of $\boldsymbol{E}$. \subsection{Max Affine Spline Network} \label{sec:maso} A DN is an operator $\boldsymbol{f}_\Theta$ with parameters $\Theta$ composing $L$ intermediate {\em layer} mappings $\boldsymbol{f}_{\ell}$, $\ell=1,\dots,L$, that combine affine and simple nonlinear operators such as the {\em fully connected operator}, {\em convolution operator}, {\em activation operator} (applying a scalar nonlinearity such as the ubiquitous ReLU), or {\em pooling operator}. A DN employing nonlinearities such as (leaky-)ReLU, absolute value, and max-pooling is a continuous piecewise linear operator and thus lives on a partition $\Omega$ of the input space. As such, the DN's CPA mapping of an input $\boldsymbol{x}$ can be written as \begin{equation} \label{eq:cpa} \boldsymbol{f}_{\Theta}(\boldsymbol{x}) = \sum_{\omega \in \Omega} 1_{\{\boldsymbol{x} \in \omega\}}\left(A_{\omega}\boldsymbol{x}+B_{\omega} \right) \end{equation} where $1$ defines the indicator function, $A_{\omega}$ and $B_{\omega}$ the per region affine parameters involving the DN per layer affine parameters , $W^{\ell}, \boldsymbol{b}^{\ell} \in \Theta, \forall \ell$, and the nonlinearities state of the region $\omega \in \Omega$ \citep{pmlr-v80-balestriero18b}. The unit and layer input space partitioning can be rewritten as Power Diagrams, a generalization of Voronoi Diagrams \citep{balestriero2019geometry}; composing layers produce a Power Diagram subdivision. \subsection{Lie Group Transformation} \label{sec:learning_group} The approaches mentioned in the introduction aiming at enhancing the capability of DNs to take into account the symmetries in the data consider only those that are explicitly modeled, s.a., translation, another line of work consists in learning them from the data. In \citet{rao1999learning,sohl2010unsupervised,hashimoto2017unsupervised,bahroun2019similarity,pmlr-v119-cosentino20a}, they propose methods capable of discovering the symmetry within the data alleviating the need for explicitly defining appropriate equivalence classes for the data. In fact, in a simple computer vision dataset such as MNIST or in a music retrieval dataset such as GTZAN, there is more than translation and rotation to characterize efficiently the data \citep{ick2020learning}. This paragraph is dedicated to the understanding of such approximation methods, which will be an important part of our regularizations. The approximation of Lie groups has been introduced by \cite{rao1999learning} and later extended in \cite{sohl2010unsupervised,wang2011lie}, and aims at learning the transformation operator underlying the data with the assumption that the dataset is the result of the action of a group on a sample. This framework has an essential place in neuroscience as there is evidence of an underlying network of neurons enabling the detection of a class of equivalence via transformation learning \citep{kriegeskorte2008matching,sengupta2018manifold,bahroun2019similarity}. In the case of a Lie group, the dataset can be modeled according to the first-order Lie equation \begin{equation} \label{lie_equation} \frac{d \boldsymbol{x}(\theta)}{d \theta} = G \boldsymbol{x}(\theta), \end{equation} where $\boldsymbol{x}(\theta)\in \mathbb{R}^{d}$, $\theta$ is the coefficient governing the amount of transformation, and $G \in \mathbb{R}^{d \times d}$. This first-order differential equation indicates that the variation of the data is linear with respect to the data and depends on the infinitesimal operator $G \in \mathcal{T}_{I}\mathcal{G}$ where $\mathcal{T}_{I}\mathcal{G}$ denotes the Lie algebra of the group $\mathcal{G}$, i.e., the tangent of the group at the identity element. An introduction to group transformations can be found in \cite{hall2015lie}. The solution of Eq.~\ref{lie_equation} is given by $\boldsymbol{x}(\theta) = \exp (\theta G) \boldsymbol{x}(0)$, a simple example with the group of rotation is given in Appendix~\ref{Lieexample}. While the learnability of the exponential map is tedious, one can exploit its Taylor series expansion to learn the infinitesimal operator. In fact, for a small $\epsilon$ we have \begin{align} \label{eq:approx_lie_first} \boldsymbol{x}(\theta +\epsilon) \approx (I+\epsilon G) \boldsymbol{x}(\theta) \end{align} The operator $G$ can thus be learned using data that are close to each other as they result from small transformations and thus follow this approximation. Without this form of supervision, the search for neighbor data is achieved by the nearest neighbor algorithm, as in \cite{hashimoto2017unsupervised}. Note that in our case, we will consider multiple transformations, each parametrized by a $1$-dimensional Lie group, i.e. $\textbf{x}(\theta) = \prod_{k=1}^h \exp(\theta_k G_k) \textbf{x}(0)$, where $\theta \in \mathbb{R}^h$. In that case the first order approximation around the identity element of each group, as Eq.~\ref{eq:approx_lie_first}, becomes $ \boldsymbol{x}(\theta +\epsilon) \approx (I+\sum_{k=1}^{h}\epsilon_k G_k) \boldsymbol{x}(\theta) $, where $\epsilon \in \mathbb{R}^h$ and with $\epsilon_k$ being the transformation parameter associated to infinitesimal operator $G_k$. \section{Max Affine Spline Autoencoders} We now leverage the CPA operator defined in Eq.~\ref{eq:cpa} to reformulate AEs and propose to interpret the role of the encoder and decoder (Sec.~\ref{sec:AE_CPA}), derive a necessary condition for the reconstruction of piecewise linear data surface (Sec.~\ref{sec:AE_RECONS}), characterize its per region surface via the Jacobian and approximated Hessian of the CPA operator (Sec.~\ref{sec:tang-hess}), and finally use these findings to analyze commonly used variations of AEs (Sec.~\ref{sec:interp_usual}). \label{sec:interp} \begin{figure}[t] \centering \begin{minipage}{.45\textwidth} \centering \includegraphics[width=1\linewidth]{partition2d_biais.png.png} \end{minipage} \hspace{1cm} \begin{minipage}{.45\textwidth} \centering \includegraphics[width=1\linewidth]{partition2d_biaisless.png.png} \end{minipage} \caption{2-dimensional visualizations of the input space partitioning $\Omega^{E,D}$ induced by two randomly initialized AEs with bias (\textit{left}) and zero bias (\textit{right}). Each region, depicted by a particular color, bounded by the black lines has a set of CPA parameters $A^{E}_{\omega}, A^{D}_{\omega}, B^{E}_{\omega}, B^{D}_{\omega}$ described in Eq.~\ref{masoparams} which depend on the per-layer affine parameters as well as the state of the nonlinearities of the region $\omega$. To reconstruct its input, an AE achieves an affine map for each region; its output for a sample of a given region $\omega$ is provided by Eq.~\ref{eq:masoAE}.} \label{fig:inputspacepartitioning} \end{figure} The output of a CPA DN is formed as per Eq.~\ref{eq:cpa}. An AE composing two CPA functions, the {\em encoder} and the {\em decoder}, the entire mapping remains a CPA with an input space partition and per region affine mappings. Because we can consider an AE as a network or as the composition of two networks, we will consider two different space partitioning. The partition of the input, i.e., data space, induced by the entire AE, and denoted by $\Omega^{E,D}$, as well as the partition of the decoder induced in the latent space, i.e., bottleneck layer, and denoted by $\Omega^D$. Examples of the entire AE partitioning, i.e., $\Omega^{E,D}$, can be visualized in Fig.~\ref{fig:inputspacepartitioning}. \subsection{Autoencoders as a Continuous Piecewise Affine Mapping} \label{sec:AE_CPA} Now, let $\omega \in \Omega^{E,D}$ defines a region induced by the AE partitioning in the input space as described in Sec.~\ref{sec:maso}. Given a d-dimensional sample $\boldsymbol{x} \in \omega$, the max affine spline formulation of the AE mapping is defined as \begin{equation} \label{eq:masoAE} \boldsymbol{D} \circ \boldsymbol{E}(\boldsymbol{x}) = A^{D}_{\omega}A^{E}_{\omega}\boldsymbol{x} + A^{D}_{\omega}B^{E}_{\omega} + B^{D}_{\omega}, \end{equation} where $\circ$ is the composition operator, $A^{D}_{\omega} \in \mathbb{R}^{d \times h}, A^{E}_{\omega} \in \mathbb{R}^{h \times d}, B^{E}_{\omega} \in \mathbb{R}^{h}$ and $B^{D}_{\omega} \in \mathbb{R}^d$ with $d$ being the dimension of the input space and $h$ the bottleneck dimension. The mapping from these global parameters to the per-layer ones is performed as follows. First, we denote by $W^{\ell} \in \mathbb{R}^{d_{\ell} \times d_{\ell-1}},\boldsymbol{b}^{\ell} \in \mathbb{R}^{d_{\ell}}$ the affine parameters of each layer, where $\ell \in \left \{1,\dots,L\right \}$ defines the encoder indexes and $\ell \in \left \{L+1,\dots,L+P \right \}$ the decoder ones (with structure depending on the layer type), where $L$ denotes the number of encoder layers, $P$ the number of decoder layers, $d_{\ell-1}$ the input dimension of the layer $\ell$ and $d_{\ell}$ its output dimension. We have that $d_{L}=h$ the bottleneck dimension, $d_{0}=d_{L+P}=d$ the input and output dimension. Then, we also denote by $Q^{\ell}$ the diagonal matrices encoding the region induced states of the nonlinearities, $(0,1)$ for ReLU, $(-1,1)$ for absolute value. Finally, the parameters of the max affine spline AE formulation described in Eq.~\ref{eq:masoAE} are defined as \begin{align} \label{masoparams} A^{E}_{\omega} =& W^{L}Q_{\omega}^{L-1}W^{L-1}\dots Q_{\omega}^{1}W^{1}\;\;\text{ and }\;\; B^E_{\omega} = \boldsymbol{b}^{L}+\sum_{i=1}^{L-1}W^{L}Q_{\omega}^{L-1}W^{L-1}\dots Q_{\omega}^{i}\boldsymbol{b}^{i}. \end{align} $A^{D}_{\omega}$ and $A^{D}_{\omega}$ are defined similarly with $\ell \in \left \{L+1,\dots,L+P \right \}$. Therefore, there is a direct mapping from the intuitive piecewise affine parameterization of the network to the per-layer parametrization as it is commonly used in the literature. Given these analytical maps, we now provide insights into the AE approximation. Let's rewrite Eq.~\ref{eq:masoAE} as \begin{align} \label{eq:proj} \boldsymbol{D} \circ \boldsymbol{E}(\boldsymbol{x}) & = \sum_{k=1}^{h} \left \langle \textbf{a}^{E^{T}}_{k}[\omega],\boldsymbol{x} \right \rangle \textbf{a}^{D}_{k}[\omega] + B^{E,D}_{\omega} = A^{D}_{\omega} \boldsymbol{\mu}_{\boldsymbol{x}} + B^{E,D}_{\omega}, \end{align} where $B^{E,D}_{\omega} = A^{D}_{\omega}B^{E}_{\omega}+B^{D}_{\omega}$, $\textbf{a}^{E^T}_{k}[\omega]$ are the rows of $A^{E}_{\omega}$, $\textbf{a}^{D}_{k}[\omega]$ are the columns of $A^{D}_{\omega}$. This is the shifted mapping of $\boldsymbol{x}$ onto the subspace spanned by $A^{D}_{\omega}$ and with coordinates driven by $A^{E}_{\omega}$. From Eq.~\ref{eq:proj}, we deduce the per region role of the encoder and decoder. The samples of each region $\omega \in \Omega^{E,D}$, are expressed in the basis defined by the decoder region-dependent parameter $A^{D}_{\omega}$, i.e., the per region parametric representation of the approximated manifold, and the coordinates of this sample in such a basis are induced by the region-dependent parameter $A^{E}_{\omega}$, the whole mapping is then shifted according to both the encoder and decoder CPA parameters. \subsection{Reconstruction Guarantees} \label{sec:AE_RECONS} We now derive a necessary condition on the CPA parameters, $A^{D}_{\omega}, A^{E}_{\omega}$, such that the AE achieves perfect reconstruction on a given continuous piecewise linear surface in the case of zero bias as often used in practice \cite{mohan2020robust}. \begin{prop} \label{prop_2} A necessary condition for the zero-bias AE to reconstruct a continuous piecewise linear data surface is to be bi-orthogonal as per $ \forall \boldsymbol{x} \in \omega, \;\; \boldsymbol{D} \circ \boldsymbol{E}(\boldsymbol{x}) = \boldsymbol{x} \implies \left \langle \boldsymbol{a}^{D}_k[\omega], \boldsymbol{a}^{E}_{k'}[\omega] \right \rangle = 1_{ \left \{k=k' \right \}}. $ (Proof in Appendix~\ref{proof:prop2}.) \end{prop} That is, if a continuous piecewise linear surface is correctly approximated, we know that the parameters of the MAS operator describing the encoder and decoder will be bi-orthogonal, i.e., the column vectors of $A^{D}_{\omega}$ and the row vectors of $A^{E}_{\omega}$ form a bi-orthogonal basis. We now propose to give intuitions regarding this condition by utilizing the mapping between CPA parameters and layer weights as per Eq.~\ref{masoparams}. In fact, the following corollary provides the conditions for the bi-orthogonality to be fulfilled depending on the weights of the autoencoder, i.e., $W^{\ell}$. For the sake of clarity, we consider the case of a $2$-layer ReLU AE. \begin{cor} \label{cor:corrolary_reconst} Let $\boldsymbol{E}$ and $\boldsymbol{D}$ be a $2$-layer ReLU network with respective weights $W^{1} \in \mathbb{R}^{h \times n} $ and $W^{2}\in \mathbb{R}^{n \times h}$, as per Eq.~\ref{masoparams}. We denote by $W^1_{i,j}$ the $i^{th}$ row and $j^{th}$ column of the weight matrix $W^{1}$. Now, $\forall x \in \mathcal{X}$, a necessary condition for bi-orthogonality is that, for each $k,k' \in \left \{1,\dots,h \right \}$, one of the following is fulfilled: \begin{enumerate}[label=(\roman*)] \setlength{\itemsep}{0pt} \item $W^{1^T}_{k',.} x \leq 0. $ \item $\forall i \in \left \{1,\dots,d \right \}, \;\;\; W^{2^T}_{i,.} \boldsymbol{E}(x) \leq 0. $ \item $\forall i \in \left \{1,\dots,d \right \}, \;\;\; W^{2^T}_{i,.} \boldsymbol{E}(x) >0$ and $\left \langle W^{2}_{.,k}, W^{1}_{k',.} \right \rangle = 0.$ \item $\sum_{i=1}^{d} W^{2}_{i,k} W^{1}_{k',i} 1_{ \left \{ W^{2^T}_{i,.} \boldsymbol{E}(x) >0 \right \}}=0.$ \end{enumerate} (Proof in Appendix~\ref{proof:corrolary1}.) \end{cor} This results shows that the bi-orthogonality condition can be obtained via a combination of orthogonality conditions between the weights and/or nonlinearity activations. For instance, the proposition $(i)$ corresponds to the case where the input of the $k'$ unit in the bottleneck layer is negative, condition $(ii)$ is the case where the input of all output units is negative, condition $(iii)$ corresponds to a linear decoder and orthogonality of the weights, and $(iv)$ corresponds to an orthogonality condition between the $k^{th}$ column of the decoder weight with the $k'^{th}$ row of the encoder weight modulo the activations of the decoder layer. Note that if $(ii)$ and $(iii)$ hold for multiple regions $\omega \in \Omega^{E,D}$ it implies that the decoder is linear with respect to the coordinate space and forms a linear manifold. Thus, these are not realistic conditions to have efficient AEs. \begin{figure} \centering \hspace{1.2cm} \begin{minipage}{0.45\linewidth} \includegraphics[width=.8\linewidth]{surface2.png} \end{minipage} \begin{minipage}{0.45\linewidth} \includegraphics[width=.8\linewidth]{surface.png} \end{minipage} \caption{Piecewise linear surfaces induced by two randomly initialized AE decoders and visualized in the ambient space of dimension $d=3$ (latent dimension being $h=2$). The gray denotes the regions, and the red lines their borders. As they correspond to the MAS surface induced by the decoder, each gray region has a slope characterized by the Jacobien of the decoder as in Eq.~\ref{eq:jaco_D}. Our work aims at developing a constraint on these surfaces via their per region tangent, such that they approximate the manifold defined by the orbit of a signal with respect to the action of a group.} \label{fig:surface} \end{figure} \subsection{Tangents and Hessian} \label{sec:tang-hess} From the CPA formulation, we observed that for each region $\omega \in \Omega^{E,D}$, $\boldsymbol{D} \circ \boldsymbol{E}$ defines a composition of two continuous piecewise affine functions, each defined respectively by the parameters $A^{E}_{\omega}$, $ B^E_{\omega}$, and $A^{D}_{\omega}$, $ B^D_{\omega}$. We can thus derive simple analytical formulas for the per region Jacobian and approximated Hessian of the AE. The Jacobian of the AE for a given region $\omega \in \Omega^{E,D}$ is given by \begin{align} \label{eq:jaco} J_{\omega}[\boldsymbol{D} \circ \boldsymbol{E}] = A^{D}_{\omega} A^{E}_{\omega}. \end{align} More details regarding the Jacobian are given in Appendix~\ref{ap:jaco}. It is also clear that the rank of the Jacobian is upper bounded by the latent dimension as $\text{rank}(J_{\omega}[\boldsymbol{D} \circ \boldsymbol{E}]) \leq h$, where $h$ is the number of units of the bottleneck layer of the AE, and in general by the $\min_{\ell} d_{\ell}$. This dimension is directly related to the manifold's dimension that one aims to approximate, assuming that all other layer widths are larger than $h$. One can similarly obtain the per region tangent of the decoder, as it defines the per region parametric representation of the manifold, see Fig.~\ref{fig:surface}. We recall that we denote by $\Omega^{D}$ the partition of the latent space induced by the decoder \begin{align} \label{eq:jaco_D} \forall \omega \in \Omega^D, J_{\omega}[\boldsymbol{D}] = A^{D}_{\omega}, \end{align} where the columns of $A^{D}_{\omega}$ form the basis of the tangent space induced by $\boldsymbol{D}$. The characterization of the curvature of the approximation of the data manifold can be done using the per region Hessian defined by $H_{\omega}, \forall \omega \in \Omega^{D}$, which in our case will be defined as the sum of the difference of neighboring tangent planes. \begin{equation} \label{eq:Hessian} \forall \omega \in \Omega^D, \left \| H_{\omega} \right \|_{F} = \sum_{\omega' \in \mathcal{N}(\omega)} \left \| J_{\omega}[\boldsymbol{D}] - J_{\omega'}[\boldsymbol{D}] \right \|_F, \end{equation} where $\mathcal{N}(\omega)$ denotes the set of neighbors of region $\omega$ and $\left \| . \right \|_{F}$ is the Frobenius norm. This approach is based on the derivation described in \citet{rifai2011higher}. In practice, we use a stochastic approximation of the sum by generating a small mini-batch of a few corrupted samples which induce neighboring regions. \subsection{Interpretability of Regularization Techniques} \label{sec:interp_usual} We are now interested in leveraging these findings to analyze and interpret common AE regularizations. \begin{enumerate}[label=(\roman*),leftmargin=*] \item \textbf{Higher-Order Contractive AE} \citep{rifai2011higher}: This regularization penalizes the energy of the first and approximated second derivative the encoder map for any region containing a training sample, i.e., $\left \|A^{E}_{\omega} \right \|_{F}$ and $ \sum_{\omega' \in \mathcal{N}(\omega)} \left \|A^{E}_{\omega}- A^{E}_{\omega'} \right \|_{F}$. In the case of a ReLU AE, we know from Eq.~\ref{eq:masoAE} and the submultiplicativity of the Frobenius norm that the norm of the Jacobian is upper-bounded by $\left \|W^{L} \right \|_{F} \times \dots \times \left \| W^{1} \right \|_{F}$. Therefore adding a weight-decay penalty on the encoder weights induces the first-order contractive AE. The second-order induces the curvature of the piecewise linear map $A^{E}$ to be small. Note that it is the per-region affine map induced by the encoder that is regularized, and that it depends on the region's activation codes, i.e., $ Q^{i} $ and $W^{i} \; \; \forall i \in \left \{1,\dots,L \right \}$. Thus, if two neighboring regions have only have few changes in their code, and that the associated weights are small, then, such a constraint does not affect the overall curvature. On the other hand, if between two regions, the code of a unit having a weight with large amplitude does not change, then the regularization does not affect the curvature either, see details with a toy example in Appendix~\ref{sec:hoc}. \item \textbf{Denoising AE} \citep{vincent2008extracting}: Denoising AE is known to have a similar effect than the weight-decay penalty on the DN architecture \cite{wager2013dropout}. A penalty on the energy of $W^{\ell}$ induces a penalty on the energy of the $A^{E}_{\omega}$ and $A^{D}_{\omega}$ $,\forall \omega \in \Omega^{E,D}$. Therefore, it constrains each piece's slope to be as flat a possible, implying that the piecewise linear map focuses on approximating the low-frequency content in the data, which reinforces the learning bias of deep networks towards low-frequency information \citep{rahaman2018spectral}. Thus, we see how denoising and Higher-Order Contractive are tied together. \iffalse \item \textbf{Weight-Sharing AE} \citep{teng2019invertible}: In the case of weight-sharing between the decoder and encoder, we have that the $W^{\ell}$ of the decoder are the transpose of the $W^{\ell}$ of the decoder, which implies that the parameters, $A^{E}_{\omega}$ and $A^{D}_{\omega}$ only differ via their matrices encoding the nonlinearity state, $Q^{\ell}$. Furthermore, as the weights are symmetrical, the input space partition of the encoder and the decoder are fully tied together; one can not adapt one without altering the other (without considering degenerate weights). \fi \end{enumerate} \iffalse This piecewise linear approximation of the data has the property that it is continuous as per the following proposition. \begin{prop} \label{prop:continuous} The tangents of the AE are continuously connected. \end{prop} \begin{proof} AE is a composition of continuous function. \end{proof} \fi \begin{figure}[t!] \centering \begin{minipage}{0.03\linewidth} \rotatebox{90}{\# samples in ball} \end{minipage} \begin{minipage}{0.398\linewidth} \includegraphics[width=1\linewidth]{sample_evol.png} \end{minipage} \begin{minipage}{0.03\linewidth} \rotatebox{90}{\# regions in ball} \end{minipage} \begin{minipage}{0.503\linewidth} \includegraphics[width=1\linewidth]{region_evol.png} \end{minipage} \\ \hspace{1.6cm} \begin{minipage}{0.17\linewidth} \centering radius \end{minipage} \begin{minipage}{0.17\linewidth} \centering radius \end{minipage} \begin{minipage}{0.17\linewidth} \centering radius \end{minipage} \begin{minipage}{0.17\linewidth} \centering radius \end{minipage} \begin{minipage}{0.17\linewidth} \centering radius \end{minipage} \caption{The first and second figures (from left to right) represent the number of data points inside a ball of growing radius (\textit{first} to \textit{second}: CIFAR10, MNIST). From the third to the last figure (from left to right), we show the number of regions in the latent space of the AE inside the same ball of growing radius for different AE architectures (\textit{third} to \textit{fifth}: Small MLP, Large MLP, Convolutional). We observe that the number of regions induced by the AE partitioning of any DN architecture in any randomly sampled ball is much larger than the number of data for any radius.} \label{fig:number_regions} \end{figure} \indent Now that we understand autoencoders' different components and their underlying functionality, we propose to constrain the surface's geometry spanned by the CPA map. In fact, we can see in Fig.~\ref{fig:number_regions} that for a given ball positioned in the input data space, the number of regions induced by the AE is much larger than the number of data. It is then clear that only a few of the regions contain data points. Thus, besides the implicit constraints of Deep Network, such as weight sharing on convolutional nets, and the continuity constraints of the mapping, there are no other structural constraints on the behavior of regions where no training data are available \citep{gamba2020hyperplane,ergen2020convex}. {\em There is, therefore, a need to constrain all the regions of the CPA to guarantee the generalization capability of AEs.} The next sections aim at deriving a regularization that imposes a global structure on this mapping, which is effective even where no data points are available. \section{Generalization Via Lie Group Regularizations} For the remaining of the paper, we model the dataset as the orbit of a Lie group, that is, as per Eq.~\ref{lie_equation}, $\boldsymbol{x}(\theta) = \exp(\theta G)\boldsymbol{x}(0), \theta \in \mathbb{R}, G \in \mathcal{T}_{I}\mathcal{G}$, where $\mathcal{T}_{I}\mathcal{G}$ denotes the Lie algebra of the group $\mathcal{G}$. We also assume that $\forall \theta \in \mathbb{R}$, $x(\theta) \in \mathbb{R}^d \setminus \left \{0 \right \}$ to avoid degenerated cases. Our aim is to provide a regularization that leads to generalization guarantees, i.e., the AE is equal to $\textbf{x}$ at any location of the manifold. In Sec.~\ref{sec:secondorderreg}, we first provide such a regularization from a general point of view, that is, we consider the approximation of $\textbf{x}$ by a smooth interpolation function ($C^2(\mathbb{R},\mathbb{R}^d)$). We then translate this condition for CPA operators (Sec.~\ref{sec:secondorderAE}) to apply it to any AE. We then demonstrate the generalization guarantees it yields (Sec.~\ref{sec:guar}). \subsection{Approximation of Lie Group's Orbit} \label{sec:secondorderreg} First, we want to understand under which condition a interpolation function $\boldsymbol{f} \in C^{2}(\mathbb{R}, \mathbb{R}^d)$ coincides with the orbit of $\boldsymbol{x}(0) \in \mathbb{R}^d \setminus \left \{0 \right \}$ under the action of the group $\mathcal{G}$. In particular, we propose to exploit a regularization that induces an orbit of a Lie group, such as \begin{equation} \label{eq:reg} \mathcal{R}_{k}(\boldsymbol{f}) \triangleq \int \left \| \frac{d^{k}\boldsymbol{f}(\theta)}{d \theta^{k}} -G\frac{d^{k-1}\boldsymbol{f}(\theta)}{d \theta^{k-1}} \right \| d\theta, \end{equation} where $\frac{d^k\boldsymbol{f}(\theta)}{d \theta^k}$ denotes the $k^{th}$ order derivative of $\boldsymbol{f}$. This regularization constrains $\boldsymbol{f}$ such that its $k^{th}$ order derivative is a linear map of the $k-1$ order. In the following theorem, we show that, for $k \in \left \{1,2 \right \}$, such regularization coupled with an interpolation loss function leads to a perfect approximation of the data manifold $x$. That is, $\boldsymbol{f}$ coincides with $\boldsymbol{x}(\theta)= \exp(\theta G)\boldsymbol{x}(0), \forall \theta \in \mathbb{R}$ if and only if $\frac{d^{k} \boldsymbol{f}(\theta)}{d \theta^{k}} = G \frac{d^{k-1} \boldsymbol{f}(\theta)}{d \theta^{k-1}}$ and it exists a certain number of $\theta_i$, depending on the order $k$, such that $\boldsymbol{f}(\theta_i)=\boldsymbol{x}(\theta_i)$. Note that the restriction to the first two orders is natural as we will apply these results on continuous piecewise affine maps, in which the second-order can only be approximated using stochastic approximation as per Sec.~\ref{sec:tang-hess}. \begin{thm} \label{prop:oneisenough} For all $k \in \left \{1,2 \right \}$, assuming $G$ is invertible, and that a function $\boldsymbol{f}$ minimizes the regularization $\mathcal{R}_{k}(\boldsymbol{f})$ and it exists $\theta_i, i \in \left \{1,\dots,k\right \}$ such that $\boldsymbol{f}(\theta_i) = \boldsymbol{x}(\theta_i)$ then $\boldsymbol{f}$ has perfect generalization as in \begin{equation} \mathcal{R}_{k}(\boldsymbol{f}) = 0 \; \text{ and } \; \exists \theta_i \in \left \{1,\dots,k\right\} \; \text{ s.t. } \; \boldsymbol{f}(\theta_i)=\boldsymbol{x}(\theta_i) \iff \forall \theta, \boldsymbol{x}(\theta)= \boldsymbol{f}(\theta). \end{equation} (Proof in Appendix~\ref{proof:cor1}.) \end{thm} Thus an interpolant $\boldsymbol{f}$, can approximate the orbit of a Lie group, utilizing two components, the aforementioned regularization with $k \in \left \{1,2\right \}$, and a reconstruction error that force the interpolation function to coincide with $k$ training samples. \iffalse {\bf Relation to Transformation Learning:} Instead of considering the first-order problem as defined in Eq.~\ref{lie_equation} which considers transformations between the data, we showed that we can also leverage a second-order problem, that encapsulates the relation between tangent planes. As such, the second-order regularization provides a way to learn the orbit of the data while not relying on the data, thus alleviating the drawbacks of the first-order equation. In the same vein as the first-order case, the differential of order one is locally given by \begin{align} \label{eq:approx_lie} \frac{dx(\theta)}{d\theta}|_{\theta=(\theta' +\epsilon)} \approx \frac{dx(\theta)}{d\theta}|_{\theta=\theta'} + \epsilon G \frac{dx(\theta)}{d\theta}|_{\theta=\theta'} \end{align} \fi \iffalse This lead to local tangent approximation that are then used in a least square fashion to learn the group generators such as \begin{equation} \min_{G} \sum_{x(\theta) \in \mathcal{X}_{\text{train}}} \sum_{x(\theta + \epsilon_i) \in \mathcal{N}(x(\theta))} \left \| (x(\theta + \epsilon) - x_i) - \theta G x_i \right \|, \end{equation} where $\mathcal{X}_{\text{train}}$ denote the training set, subset of $\mathcal{X}$, and $\mathcal{N}(x_i)$ is a neighbourhood of the point $x_i$. \fi \iffalse \subsection{A second-order regularization scheme} \label{sec:secondorderAE} We now leverage the second-order modelization previously defined. We introduce the approximant of $x$ as $f$, a smooth function in $ \mathbb{C}^{\infty}(\mathbb{R})$, and we propose the following regularization \begin{equation} \label{eq:reg} \min_{G} \mathcal{R}(f) = \min_{G} \left \| \frac{d^2f(\theta)}{d \theta^2} -G\frac{df(\theta)}{d \theta} \right \|, \forall \theta \in \mathbb{R} \end{equation} We know from Proposition~\ref{prop:2ndorder}, that given an infinitesimal operator $G \in \mathcal{T}_{I}\mathcal{G}$, a function $f$ governed by $\frac{d^{2} f(\theta)}{d \theta^2} = G \frac{df(\theta)}{d\theta}$ will in fact describe the orbit of an initial datum $f(0)$ with respect to the group $\mathcal{G}$. Therefore, this regularization imposes that the approximant $f$ describes the orbit of a group induced by $G$. Recall that the solution of Proposition~\ref{prop:2ndorder} is given when the initial condition $\frac{dx(\theta)}{\theta}|_{\theta=0}= Gx(0)$ is fulfilled. It is clear that the regularization does not induced any initial condition on the first-order derivative. It only contrains $f$ such that its second-order derivative is linearly mapped from the first-order. The following corollary of Proposition~\ref{prop:2ndorder} shows that $f(\theta)=x(\theta), \forall \theta \in \mathbb{R}$ if they coincide at one point. \begin{cor} \label{prop:oneisenough} Assuming $G$ is inversible and that \[ \frac{d^2f(\theta)}{d \theta^2} = G\frac{df(\theta)}{d \theta}, \] we have that $f(\theta) = x(\theta), \forall \theta \in \mathbb{R}$ if $f$ and $x$ coincides for a given $\theta'$. \end{cor} \begin{proof} Following the proof of Proposition~\ref{prop:2ndorder} with initial condition given by $\frac{df(\theta)}{d \theta}|_{\theta=0}$, we have that $f(\theta) = G^{-1} \exp( \theta G) \frac{df(\theta)}{d \theta}|_{\theta=0}= \exp(\theta G) G^{-1}\frac{df(\theta)}{d \theta}|_{\theta=0}$. Now if $\exists \theta'$ such that $f(\theta')= x(\theta')$, then, \[ \exp( \theta' G) G^{-1} \frac{df(\theta')}{d \theta'}|_{\theta'=0} = \exp(\theta' G) x(0) \] therefore $ \frac{df(\theta')}{d \theta'}|_{\theta'=0}= G x(0)$, thus \[ \exp( \theta' G) G^{-1} \frac{df(\theta')}{d \theta'}|_{\theta'=0} = \exp(\theta 'G) x(0) = x(\theta') \] \end{proof} In the next section, we leverage these results to show that combining the regularization of Eq.~\ref{eq:reg} with the reconstruction error of AE leads to provable generalization guarantee. In fact, while the loss function aims at overfit the manifold of the given training set the regularization enhance its generalization capability on unseen regions of the manifold as per proposition \ref{prop:oneisenough}. \fi \iffalse For each data $x_i$, we define a curve $\gamma_{x_i}: \theta \rightarrow \exp(\theta G)x_i$ on the manifold. In fact, it is clear that $\gamma'_{x_i}(0)=Gx_i \in \mathcal{T}_{I}\mathcal{G}$ which defines the tangent of the orbit of the group $\mathcal{G}$ at the point $x_i$. As such, for any point along the orbit, the tangent is a linear transformation of the data point that depends only on $G$. In fact, $G$ defined the Lie algebra which is the tangent of the group around the identity element. \roro{ On vbeut ajouter regularization TQ on fit Manifold Lie group. Usual way = ordre 1, sauf que data dependant = nul. Donc on check ordre 2, et on montre que si on verifie ordre 2 on a aussi Lie group, cf LEMME A FAIRE. } \subsection{Lie Group Approximation} \rara{ Lemma 1 : tous les lie group ont le true d2=Gd1 on sait que notre DN doit apprixomer un lie group donc condition necessaire est que d2f = Gd1f } \roro{ Quand double integrale de LEDO, il devrait apparaitre conditions derive + condition initial. Ensuite si on a pas access aux conditions aux bord sur la derive, on utilise lemma 1+ theorem 1} In this work, we are interested in the following 2nd order regularization \begin{equation} \label{eq:reg} \mathcal{R}_{\gamma}(f) = \left \| \frac{d^2}{d \theta^2} f(\theta_i) -\frac{d^2}{d \theta^2} \gamma_{x_i}(0) \right \|, \forall (\theta_i, x_i) \end{equation} where $f$ defines the approximant of the curve $\gamma$. However, if $\gamma$ denotes the orbit, we have \[ \frac{d^2}{d \theta^2} \gamma_{x_i}(0) = G \frac{d}{d \theta} \gamma_{x_i}(0).\] Thus, the regularization aim at \[ \frac{d^2}{d \theta^2} f(\theta_i)= G \frac{d}{d \theta} \gamma_{x_i}(0) \] The following proposition indicates that if $f$ and $\gamma$ coincides on their second-order derivative, then they are equal modulo an affine term. \begin{lemma} \label{lemma:modulo} If $\mathcal{R}_{\gamma}(f)=0$ we have that \[ \exists ! a \in \mathbb{R}^n, b \in \mathbb{R}^n \text{ s.t. } \{f(\theta)+ \theta a + b,\theta \in \mathbb{R}\}= \mathcal{X} \] \end{lemma} \begin{proof} Applying a first time the fundamental theorem of calculus induces the equality of the two derivative up to a constant constant vector $a$. Applying again the fundamental theorem of calculus provides the affine tranformation $a\theta+b$. \end{proof} \begin{thm} Assume $\mathcal{R}_{\gamma}(f)=0$, then $f$ approximates the curve $\gamma$, if either one of these statements is verified \begin{enumerate} \item $f(\theta_i) = \gamma_{x_i}(0)=x_i$ for $i \in \left \{1,\dots, 2n \right \}$ such the $x_i$ are not collinear, \item $\frac{d}{d \theta} f(\theta_i) = \frac{d}{d \theta} \gamma_{x_i}(0)$ for $i \in \left \{1,\dots, n \right \}$ such the $\frac{d}{d \theta} \gamma_{x_i}(0)$ are not collinear \end{enumerate} \end{thm} \begin{proof} Based on Lemma~\ref{lemma:modulo}, we know that if $\mathcal{R}=0$, $f$ coincides with $\gamma$ up to an affine term that has $2n$ parameters. if 1., then $f$ coincides with $\gamma$ for $2n$ points that are not collinears. Therefore one can solve exactly the system of equation providing the $2n$ parameters of the affine term. if 2., then the tangents of $f$ and $\gamma$ coincide, in this case the affine term reduces to a translation, i.e. $b$, which contains $n$ parameters. \end{proof} \roro{add corrolary Lie group} Notice that in the case of the approximation of a Lie group, the usage of the first-order derivative is a natural and common approach as developped in Sec.~\ref{lie_back}. In fact, two neighboring points $x$ and $x'$ are linearly related as in Eq.~\ref{eq:approx_lie}. To learn the matrix $G$, this approach requires the search for neighboring data points. Either the dataset is sequential, such as frames in a video, or a neirest neighbors approach is used. It is clear that several drawbacks occur, the first is the curse of dimensionality, how to guarantee that the data are in fact in a small neighborhood when $n$ is large. The second is with respect to the sampling of the data, how one can guarantee that the dataset contains data that are in fact close enough so that they can be considered as infinitesimal transformation of each other. On the other hand, the second-order derivative provides a linear behaviour with respect to neighboring tangent as \[ \frac{d^2}{d \theta^2} \gamma_{x_i}(0) = G \frac{d}{d \theta} \gamma_{x_i}(0).\] Again, this linear relation between the derivative of order $l$ and order $l-1$ is due to the linearity of the exponential map around the identity of the group. While the first-order requires data to learn the matrix $G$, the second-order requires tangents. As opposed to the constraints on the data, one can obtain an infinite amount of tangent of the approximant function $f$ as its analytical formula is given by the approximation scheme used. Therefore, the regularization $\mathcal{R}$ described in Eq.~\ref{eq:reg} can be optimized efficiently as it only requires to sample neighboring tangents and impose that they are the result of a linear transformation parametrized by $G$, that is agnostic of their position. Besides, we have shown that if in addition to this constrain, $f$ coincides with the curve at $2n$ positions, then the manifold is entirely approximated by the function $f$. \roro{1) $\epsilon$ pour sampling les $z$, variance w.r.t depth, 2) lie group => constant curvature => constant angle between close regions 3) complete basis with random vector error doesnt change the angle of the subspace, 4) general Regularization => reduce the error of Lienet regularization term, check the link via general regularization => angle regularization } \roro{ A CLEAN: RORO} We will from now assume that the manifold of the data is built upon the action of a group, leading to $\mathcal{X} = \left \{ T(x,\theta) |x \in \mathcal{X}, \forall \theta \in \mathbb{R}^h \right \}$, where $T$ is a smooth differentiable map as defined in Sec.~\ref{lie_back}, that is, the dataset is the orbit of a datum $x$ under the action of a $h$-dimensional group. \fi \subsection{Lie Group Regularizations for Autoencoders} \label{sec:secondorderAE} The derived regularizations were based on a smooth interpolant $\boldsymbol{f}$ and need to be adapted to the case of a CPA map. To do so, there are several crucial considerations: \begin{enumerate}[label=(\roman*),leftmargin=*] \item For the sake of clarity, the previous section illustrated the case of a one-dimensional group. Here we propose to generalize such an approach to multiple groups of transformations. We, therefore, consider the case of $h$ infinitesimal operators $G_1,\dots,G_h$ each corresponding to a $1$-dimensional group, as explained in Sec.~\ref{sec:learning_group}. \item The second-order regularization requires constrains the Hessian of the CPA, which by definition, can only be approximated stochastically as explained in Sec.~\ref{sec:tang-hess}. \item The assumption on the data is that they are generated by $h$ transformation groups. Thus, the intrinsic dimensionality of the data is at most $h$. Therefore, the size of the bottleneck layer, which corresponds to the maximum dimension of the manifold the autoencoder can generate (as per Sec.~\ref{sec:AE_CPA}), is also $h$. \end{enumerate} \paragraph{The case $k=1$:} \noindent The first-order regularization corresponds to the assumption that data that are generated by the decoder and that are close to each other result from small transformations of one to another. As per Eq.~\ref{eq:approx_lie_first}, we obtain \setlength\itemsep{.004em} \begin{align} \label{eq:regAE_first} \mathcal{R}_{1}(\boldsymbol{D}) & \triangleq \min_{G_1,\dots,G_h}\int_{\mathbb{R}^h} \int_{\mathcal{N}(\theta)} \min_{\epsilon_1, \dots,\epsilon_h} \left\| \boldsymbol{D}(\theta) - (I+\sum_{k=1}^h \epsilon_k G_k) \boldsymbol{D}(\theta') \right \|_{2} d\theta' d\theta, \end{align} where $\mathcal{N}(\theta)$ denotes the neighborhood of $\theta \in \mathbb{R}^h$, the parameters $\epsilon_1,\dots,\epsilon_h$ are the scalars corresponding to the scale of the transformations, and the $G_1,\dots,G_h$ the infinitesimal operators. The optimal parameters $\epsilon^{\star} = \left [\epsilon_1,\dots,\epsilon_h \right ]^T$ used during the training of the regularized AE are provided in Proposition~\ref{prop:theta_1} in Appendix~\ref{app:params}. Note that the infinitesimal operators are learned using stochastic gradient descent and that the approximation of the integrals in Eq.~\ref{eq:regAE_first} is developed in Sec.~\ref{sec:exp}. \paragraph{The case $k=2$:} \noindent We know from Sec.~\ref{sec:tang-hess} that for each region $\omega \in \Omega^D$, the decoder is characterized by its tangent plane, $A^{D}_{\omega}$. The second-order regularization imposes that each tangent plane of the AE is related to their neighboring tangents plane by small transformations. Again, considering the linearized exponential maps and exploiting the definition of the Hessian in Eq.~\ref{eq:Hessian} we obtain the following second-order regularization on the CPA \begin{align} \label{eq:regAE_second} \mathcal{R}_{2}(\boldsymbol{D}) & \triangleq \min_{G_1,\dots,G_h}\int_{\mathbb{R}^h} \int_{\mathcal{N}(\omega)} \min_{\epsilon_1, \dots,\epsilon_h} \left\| J_{\omega}[\boldsymbol{D}] - (I+\sum_{k=1}^h \epsilon_k G_k) J_{\omega'}[\boldsymbol{D}] \right \|_{F} d \omega' d\omega, \end{align} where $\mathcal{N}(\omega)$ denotes the set of neighbors of region $\omega$ and $\left \| . \right \|_{F}$ is the Frobenius norm and we recall that $ J_{\omega'}[\boldsymbol{D}]= A^{D}_{\omega'} $ and $ J_{\omega}[\boldsymbol{D}] = A^{D}_{\omega} $. The implementation regarding the sampling of neighboring regions is detailed Sec.~\ref{sec:exp}. In this case also, the optimal parameters $\epsilon^{\star} = \left [\epsilon_1,\dots,\epsilon_h \right ]^T$ used during the training of the regularized AE are provided in Proposition~\ref{prop:theta_2} in Appendix~\ref{app:params}. Let us now provide interpretations regarding the Lie group regularizations we developed. While the first-order regularization constrains the AE mapping, the second-order constrains the AE's tangent plane of each region. In the first-order case the distance between $(I+\sum_{k=1}^h \epsilon_k G_k) \boldsymbol{D}(\theta')$, which corresponds to small transformations of the sample generated by the decoder, and $D(\theta)$ is minimized. Thus, such a regularization constrains the AE mapping to approximate the orbit induced by the infinitesimal generators. Then, the second-order regularization aims at minimizing the distance between $(I+\sum_{k=1}^h \epsilon_k G_k) J_{\omega'}[\boldsymbol{D}]$, which is the small transformation of the tangent plane of region $\omega'$, and $J_{\omega}[\boldsymbol{D}]$. This means that the second-order regularization constrains the Hessian of the decoder, which defines the angle between neighboring piecewise linear maps, to approximating the angle of the data manifold. Therefore, this penalization enforces the curvature of the piecewise linear map to fit the curvature of the orbit. Besides, as opposed to the Higher-Order Contractive AE \citep{rifai2011higher}, these regularizations constrain all the piecewise affine regions whether they contain training data or not as they do not rely on samples from the dataset. This is crucial to provide generalization guarantees in a finite data regime. \paragraph{Remark:} Note that, because of the first order approximation around the identity of the group, the higher order term containing the information regarding the commutativity of the group are not taken into account in our approach. The non-abelian effects are in fact of the order $O(\epsilon^2)$. Therefore, in this work, no assumptions are made on the commutativity of the group. \subsection{Approximation Error} \label{sec:guar} In Sec.~\ref{sec:secondorderreg}, we showed that if the regularization defined in Eq.~\ref{eq:reg} is equal to zero for any given $k \in \left \{1,2 \right \}$, and if the interpolation function $\boldsymbol{f}$ coincides with the data manifold defined by $\boldsymbol{x}$ on $k$ points, then $\boldsymbol{f}$ coincides with $\boldsymbol{x}$. We now derive the generalization guarantees in the particular case where $\boldsymbol{f}$ is a CPA approximant. Based on the assumption that $(i)$ a region of the real manifold is correctly approximated, $(ii)$ one of the regularizations defined in Eq.~\ref{eq:regAE_first},\ref{eq:regAE_second} is minimized, and that $(iii)$ the infinitesimal operator $G$ obtained from the regularization coincides with the infinitesimal operator of the group governing the data, we obtain the following bound on the approximation of the data manifold. \begin{thm} \label{prop:tang} If on a region $\omega' \in \Omega^{D}$ the matrix $A^{D}_{\omega'}$ forms a basis of the manifold tangent space on this region, and it exists $k \in \left \{1,2 \right \}$ such that $\mathcal{R}_{k}(\boldsymbol{D})=0$ then for all regions $\omega \in \Omega^{D}$ the basis vectors of $A^{D}_{\omega}$ are the basis vector of the tangent of the data manifold and the distance between the continuous piecewise affine map and the data manifold is upper bounded by the radius of the regions as per \[ d \left ( \cup_{\omega \in \Omega^{D}} \mathcal{T}_{AE}(\omega), \mathcal{X} \right ) \leq \sum_{\omega_i \in \Omega^D} \text{Rad}(\omega_i), \] where $\mathcal{T}_{AE}(\omega)$ the tangent space of the AE for the region $\omega$, $\mathcal{X}$ denotes the data manifold, $d$ defines the 2-norm distance,and $\text{Rad}(\omega_i)$ the radius of the region $\omega_i$. (Proof in Appendix~\ref{proof:tang}.) \end{thm} The previous statement shows that if the number of pieces of the piecewise affine map, which depends on the number of neurons in the DN architecture (see Fig.~\ref{fig:number_regions} and refer to \citet{montufar2014number} for more details) and the type of nonlinearity, goes to infinity, then the decoder would coincide with the data manifold. In a practical setting, it tells us that the higher the number of regions is, the higher is the degrees of freedom of the CPA, and that under this regularization, these degrees of freedom are controlled while not requiring more training points. \section{Experimental Settings and Validations} \label{sec:ex} In this section, we discuss some practical aspects of the proposed regularizations as well as provide the experimental validations. In particular, how the parameters of the regularizations are learned (Sec.~\ref{sec:params}) as well as how the sampling required in both regularizations is performed along with their induced computational complexity (Sec.~\ref{sec:sampling}), and finally the experimental validations (Sec.~\ref{sec:exp}). \subsection{Parameters Learning} \label{sec:params} \iffalse \begin{figure}[t] \begin{center} \hspace{1cm} \begin{minipage}{0.17\linewidth} \begin{center} AE \end{center} \end{minipage} \begin{minipage}{0.17\linewidth} \begin{center} Contractive \\ AE \end{center} \end{minipage} \begin{minipage}{0.17\linewidth} \begin{center} Denoising \\ AE \end{center} \end{minipage} \hspace{.05cm} \begin{minipage}{0.17\linewidth} \begin{center} Lie Group \\ AE ($1^{th}$) \end{center} \end{minipage} \hspace{.05cm} \begin{minipage}{0.17\linewidth} \begin{center} Lie Group \\ AE $(2^{nd})$ \end{center} \end{minipage} \end{center} \begin{center} \centering \begin{minipage}{0.04\linewidth} \rotatebox{90}{Test Set Reconst. Error} \end{minipage} \begin{minipage}{0.95\linewidth} \includegraphics[width=1\linewidth]{syntheticcontrol_errors.png} \end{minipage} \end{center} \begin{center} \begin{minipage}{.06\linewidth} \begin{center} \end{center} \end{minipage} \begin{minipage}{0.16\linewidth} \begin{center} \; \;\;\; \;Epochs \end{center} \end{minipage} \hspace{.15cm} \begin{minipage}{0.16\linewidth} \begin{center} \;\;\;\;\;\; Epochs \end{center} \end{minipage} \hspace{.3cm} \begin{minipage}{0.16\linewidth} \begin{center} \; \; \;Epochs \end{center} \end{minipage} \hspace{.3cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \hspace{.3cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \end{center} \vspace{-.5cm} \caption{Test set reconstruction error on the SyntheticControl dataset evaluated on the best set of parameters for different AEs (from left to right): AE, Higher-Order Contractive AE, Denoising AE, Lie Group AE (first-order), and Lie Group AE (second-order). For each model, the mean over $10$ runs is reported in black, and the gray area corresponds to its standard deviation. } \label{fig:explourd} \end{figure} \fi \iffalse \begin{figure}[t] \centering \begin{minipage}{0.04\linewidth} \rotatebox{90}{Test Set Reconstruction Error} \end{minipage} \begin{minipage}{0.95\linewidth} \includegraphics[width=1\linewidth]{earthquake_best_run.png}\\ \begin{tabular}{@{\hspace{5.5em}}c@{\hspace{2.5em}}@{\hspace{3em}}c@{\hspace{2.75em}}@{\hspace{2.45em}}c@{\hspace{2.75em}}@{\hspace{2.7em}}c@{\hspace{2em}}} Epochs & Epochs & Epochs & Epochs \end{tabular} \end{minipage}\\ \caption{Test set reconstruction error on the Earthquakes dataset evaluated on the best set of parameters for different AEs (from left to right): AE, Higher-Order Contractive AE, Denoising AE, Group AE. For each model, the mean over $10$ runs is reported in black, and the gray area corresponds to its standard deviation. } \label{fig:explourd} \end{figure} \fi \begin{table}[t] \caption{ Comparison of the testing reconstruction errors ($\times 10^{-2} \pm \text{ std } \times 10^{-2})$ for each AE (columns) and dataset (rows). The methods denoted by $\textbf{Lie G. ($1^{th}$)}$ and $\textbf{Lie G. ($2^{nd}$)}$ correspond respectively to the first-order and second-order Lie group regularizations we developed. \textbf{H.O.C. AE} denotes the Higher-Order contractive AE, and \textbf{Den. AE} denoising AE.} \setlength\tabcolsep{3.7pt} \begin{tabular}{|l|c|c|c|c|c|} \hline \textit{Dataset \: \textbackslash \; Model} & \textbf{AE} & \textbf{Den. AE} & \textbf{H.O.C. AE} & \textbf{Lie G. ($1^{th}$)}& \textbf{Lie G. ($2^{nd}$)} \\\hline \hline \textbf{CIFAR10} & $5.6 \pm 0.05 $& $5.0 \pm 0.05$ & - & $\textbf{4.9} \pm 0.07$ & - \\ \hline \textbf{MNIST} &$12.01 \pm 0.003$ & $12.01 \pm 0.004 $ & $12.01 \pm 0.004 $ & $\textbf{6.3} \pm 0.1$ & $10.13 \pm 0.1 $\\ \hline \textbf{CBF} & $62.38 \pm 0.74 $ & $52.66 \pm 0.76 $ & $ 51.09 \pm 0.54 $ & $\textbf{43.99} \pm 1.2$& $ 49.73 \pm 0.31 $\\ \hline \textbf{Yoga} & $33.76 \pm 0.81 $ & $33.29 \pm 0.72$ & $ 32.08 \pm 0.42 $ & $\textbf{20.28} \pm 1.1$ & $30.78 \pm 1.2 $\\ \hline \textbf{Trace} & $13.95 \pm 0.45 $ & $11.28 \pm 0.57$ & $ 12.57 \pm 0.21 $ & $13.23 \pm 0.4$ &$\textbf{10.91} \pm 0.45 $\\ \hline \textbf{Wine} & $63.06 \pm 0.02 $ & $59.34 \pm 0.02 $ & $ 49.94 \pm 0.02 $ & $\textbf{19.01} \pm 0.02$ & $49.94 \pm 0.01 $\\ \hline \textbf{ShapesAll} & $67.98 \pm 3.0 $ & $58.67 \pm 1.4 $ & $ 61.42 \pm 5.5 $ & $\textbf{52.97} \pm 1.9$ & $57.80 \pm 1.2 $\\ \hline \textbf{FiftyWords} & $64.91 \pm 1.7$ & $60.91 \pm 1.0 $ & $ 60.92 \pm 0.7 $ & $71.84 \pm 3.4$ &$\textbf{57.89} \pm 1.0$\\ \hline \textbf{WordSynonyms} & $70.95 \pm 1.5$ & $66.02 \pm 0.8 $ & $ 66.52 \pm 0.5$ & $68.21 \pm 2.7$ &$\textbf{62.22} \pm 1.1$\\ \hline \textbf{InsectSounds} & $51.86 \pm 0.6 $ & $40.24 \pm 0.8$ & $ 41.93 \pm 0.6 $ & $\textbf{38.11} \pm 0.9$ & $38.22 \pm 0.3 $\\ \hline \textbf{ECG5000} & $21.92 \pm 0.75 $ & $20.31 \pm 0.39$& $20.31 \pm 0.36$& $\textbf{18.06} \pm 0.9$ &$ 20.29 \pm 0.4 $\\ \hline \textbf{Earthquakes} & $56.23 \pm 4.1 $ & $54.62 \pm 4.1 $ & $51.79 \pm 1.0 $ & $99.41 \pm 0.2$ &$\textbf{50.20} \pm 0.5$\\ \hline \textbf{Haptics} & $37.25 \pm 0.2 $ & $36.02 \pm 1.8$ & $27.21 \pm 0.5 $ &$ \textbf{16.94} \pm 3.4$ & $26.06 \pm 0.9$\\ \hline \textbf{FaceFour} & $49.82 \pm 1.0 $ & $48.51 \pm 0.8 $ & $48.52 \pm 0.7 $ & $48.60 \pm 1.9 $ &$\textbf{46.00} \pm 0.6$\\ \hline \textbf{Synthetic} & $95.61 \pm 1.3 $ & $89.37 \pm 1.0 $ & $88.47 \pm 0.9 $ & $\textbf{55.87} \pm 0.8 $ & $86.83 \pm 0.6 $\\ \hline \end{tabular} \label{table:accu} \end{table} The degrees of freedom of our regularized AE comprise the usual AE parameters (per layer affine transformations) and the parameters of each regularization. The $\epsilon$ values are found from the analytical form given by Propositions~\ref{prop:theta_1} and \ref{prop:theta_2} in Appendix~\ref{app:params}. We learn the matrices $G_{k}, \forall k \in \left \{1,\dots,h \right \}$ with gradient descent based optimizer \citep{kingma2014adam} and thus our method introduces $h d^2$ additional parameters, where $d$ is the dimension of the input data. Note that a priori knowledge on the structure of the $G_k$ such as low-rank or skew-symmetric, i.e., Lie algebra of the special orthogonal group, can be imposed to reduce the number of parameters; we do not explore this in our study while it could be considered to speed up the computations and improve the regularization tractability. The regularizations themselves depend on the AE to find the optimal $\epsilon$ and adapt the matrices $G_k$. The dimension of each $G_k$ is quadratic in the dimension of the data. As such, for a high-dimensional datasets, the number of learnable parameters is large. Hence the optimization of the $G_k$ matrices remains the current bottleneck of the method. We propose to apply the regularization term during training starting from the random initialization. More advanced strategies such as scheduled alternating minimization or employing a warm-up phase could be leveraged and result in further improvement in performance. We now describe how we approximate the regularization terms by removing the need to evaluate the entire input space partition of the decoder for the second-order term and removing the need to sample the entire domain for the first-order term. \subsection{Region's Sampling and Computational Complexity} \label{sec:sampling} Recall that in the proposed second-order regularization, one should have the knowledge of the decoder latent space partition. In practice, and for large networks, the discovery of the partition would not be feasible. We thus propose to approximate the regularization by only sampling some of the regions and some of their respective neighbors. This sampling is done by first randomly sampling some vectors in the AE latent space. As for each sample, the associated per region map is automatically formed during the foward pass of the decoder, the per region parameters can be obtained by computing the affine mapping induced by the samples. To compute the neighbors of those sample regions, we use a simple dichotomic search. That is, for each of the sampled regions, we sample another (nearby) vector and keep pushing this new sample toward the first sample until one obtains the closest sample that remains in a different region. With the above, one now has the knowledge of some regions and one neighboring region for each of those regions. We leverage this approach and perform the search of a single neighbor; for a better approximation of the regularization, one can repeat this sampling process and accumulate the obtained regions and neighbors. For the first-order term, we propose a similar approximation where we approximate the integral by sampling a latent space vector $\theta$ (at each mini-batch). \begin{figure}[t] \begin{center} \hspace{1cm} \begin{minipage}{0.17\linewidth} \begin{center} AE \end{center} \end{minipage} \begin{minipage}{0.17\linewidth} \begin{center} Contractive \\ AE \end{center} \end{minipage} \begin{minipage}{0.17\linewidth} \begin{center} Denoising \\ AE \end{center} \end{minipage} \hspace{.05cm} \begin{minipage}{0.17\linewidth} \begin{center} Lie Group \\ AE ($1^{th}$) \end{center} \end{minipage} \hspace{.05cm} \begin{minipage}{0.17\linewidth} \begin{center} Lie Group \\ AE $(2^{nd})$ \end{center} \end{minipage} \end{center} \begin{center} \centering \begin{minipage}{0.04\linewidth} \rotatebox{90}{Test Set Reconst. Error} \end{minipage} \hspace{-.5cm} \begin{minipage}{0.95\linewidth} \vspace{-.5cm} \includegraphics[width=1\linewidth]{syntheticcontrol_errors.png} \vspace{-1.cm} \end{minipage} \end{center} \begin{center} \begin{minipage}{.06\linewidth} \begin{center} \end{center} \end{minipage} \begin{minipage}{0.16\linewidth} \begin{center} \; \;\;\; \;Epochs \end{center} \end{minipage} \hspace{.15cm} \begin{minipage}{0.16\linewidth} \begin{center} \;\;\;\;\;\; Epochs \end{center} \end{minipage} \hspace{.3cm} \begin{minipage}{0.16\linewidth} \begin{center} \; \; \;Epochs \end{center} \end{minipage} \hspace{.3cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \hspace{.3cm} \begin{minipage}{0.16\linewidth} \begin{center} Epochs \end{center} \end{minipage} \end{center} \vspace{-.5cm} \caption{Test set reconstruction error on the SyntheticControl dataset evaluated on the best set of parameters for different AEs (from left to right): AE, Higher Order Contractive AE, Denoising AE, Lie Group AE (first-order), and Lie Group AE (second-order). For each model, the mean over $10$ runs is reported in black, and the gray area corresponds to its standard deviation. We observe that the first order regularization performs much better than the second order one, which is close to the higher-order contactive AE error. In fact, this dataset contains six classes of time-series trends (upward, downward, normal,...), which can be easily related by a linear transformations, that is, the first order regularization can be easily optimized. The second order is harder to train and is more sensitive to the sampling of the regions, therefore is less reliable and harder to interpret. } \label{fig:explourd} \end{figure} \begin{figure}[t] \begin{center} \begin{minipage}{.49\linewidth} \includegraphics[width=1\linewidth]{epsilon_syntheticcontrol.png} \end{minipage} \begin{minipage}{.49\linewidth} \includegraphics[width=1\linewidth]{epsilon_haptics.png} \end{minipage} \begin{minipage}{.49\linewidth} \includegraphics[width=1\linewidth]{epsilon_facefour.png} \end{minipage} \begin{minipage}{.49\linewidth} \caption{ Visualisation of the value (after learning) of the group strength parameter ,$\epsilon$, for the (\textit{Top left}) SyntheticControl, (\textit{Top right}) Haptics, and (\textit{Bottom left}) FaceFour datasets, in the case of the first order regularization. For each row, we observe the value of the the parameter $\epsilon_i$ for a given sample, $D(\theta)$ and its neigbhor $D(\theta')$ as per Eq.~\ref{eq:regAE_first}, that is, what is the amplitude of the transformation associated to the generator $G_i$ needed to map one onto the other. Note that we display the epsilons for $16$ sampled neighboring pairs. } \label{fig:epsilon} \end{minipage} \end{center} \end{figure} Let us now consider the computational complexity induced by the regularizations omitting the computational cost of a pass through the AE as it is shared across all techniques. The optimal coordinates $\epsilon^*$ are obtained by solving a linear system of $h$ equations in both cases for each sampled datum (first-order) or each sampled region (second-order). This equation has to be solved for each sample region or latent space vector; we denote this by $N$ as in our case, we sample in each mini-batch as many vectors/regions as the size of the mini-batch. We obtain the time complexity $\mathcal{O}(h^2N+d^2hN)$ for the first-order, and $\mathcal{O}(h^2N+d^2h^2N)$ for the second-order, and a space complexity of $\mathcal{O}(d^2h)$ in both cases being driven by the need to retain the matrices $G_1,\dots,G_h$. The current bottleneck is the storage of those matrices, which limits the size of the AE bottleneck and output dimension. \subsection{Experiments} \label{sec:exp} We evaluate our framework on diverse datasets, including images and time-series data including speech, medical as well a seismic recordings, the description of the datasets is given in Appendix~\ref{ap:dataset}. For each model and each hyperparameter, we perform $10$ runs for $125$ epochs with batch size $16$. The results are reported in Table~\ref{table:accu}. In this table, the statistics reported correspond to the average over the $10$ runs, each run using the test set performances based on the best validation set measure. Note that for CIFAR$10$, the computational burden of both the second-order Lie group regularization and the higher-order contractive one is too high. Thus only the AE, denoising AE and the first-order Lie group regularization are evaluated. We propose, in particular, to visualize the test set reconstruction for the different AE models during training in Fig.~\ref{fig:explourd} (see Fig.~\ref{fig:error} in Appendix~\ref{app:Figures} for supplementary figures), where we can see that both Lie Group AEs are robust to the DN initialization and do not overfit. Besides, we can observe that while the first order on this dataset outperforms all the other regularizations, its variance at the begining of the learning phase is more volatile than other approaches. The hyperparameter responsible for the variance of the noise added to the data in the Denoising AE case also corresponding to the noise added to the data to sample Jacobian of nearby regions in Higher-Order Contractive AE parameter is evaluated for the values $\left \{0.001, 0.01,0.1,1 \right \}$. Another hyperparameter is the regularization trade-off parameter for both the Higher-Order Contractive AE and Lie Group AEs, the following values are tested for both models $\left \{0.001, 0.01, 0.1, 1, 10, 100,1000 \right \}$. All the models were trained using the same AE with $3$ fully connected encoder layers with ReLU with bottleneck dimension $h=10$, and $3$ fully connected decoder layer with ReLU and $1$ linear fully connected output layer. \iffalse \begin{table}[t] \caption{Comparison of the best testing reconstruction error ($\times 10^{-2})$ for each AE model (columns) and dataset (rows).} \begin{adjustbox}{width=\columnwidth,center} \begin{tabular}{|l|c|c|c|c|} \hline \textit{Dataset \: \textbackslash \; Model} & \textbf{AE} & \textbf{Denoising AE} & \textbf{Higher-Order Contractive AE} & \textbf{Group AE} \\\hline \hline \textbf{CIFAR10} & $5.6 \pm 0.05 $& $5.0 \pm 0.05$ & - & $\textbf{4.9} \pm 0.07$ & - & \textbf{MNIST} &$12.01 \pm 3.7 \times 10^{-5}$ & $12.01 \pm 4.7\times 10^{-5} $ & $12.01 \pm 4.7\times 10^{-5} $ & $\textbf{10.13} \pm 1.8\times 10^{-3} $\\ \hline \textbf{ECG5000} & $21.92 \pm 7.5 \times 10^{-3}$ & $20.31 \pm 3.9 \times 10^{-3}$& $20.31 \pm 3.6 \times 10^{-3} $& $\textbf{20.29} \pm 3.6 \times 10^{-3} $\\ \hline \textbf{Earthquakes} & $56.23 \pm 4.1 \times 10^{-2}$ & $54.62 \pm 4.1 \times 10^{-2}$ & $51.79 \pm 1.0 \times 10^{-2}$ & $\textbf{50.20} \pm 0.5 \times 10^{-2} $\\ \hline \textbf{Haptics} & $37.25 \pm 0.2 \times 10^{-2}$ & $36.02 \pm 1.8 \times 10^{-2}$ & $27.21 \pm 0.5 \times 10^{-2}$ & $\textbf{26.06} \pm 0.9 \times 10^{-2} $\\ \hline \textbf{FaceFour} & $49.82 \pm 1.0 \times 10^{-2}$ & $48.51 \pm 0.8 \times 10^{-2}$ & $48.52 \pm 0.7 \times 10^{-2}$ & $\textbf{46.00} \pm 0.6 \times 10^{-2} $\\ \hline \textbf{SyntheticControl} & $95.61 \pm 1.3 \times 10^{-2}$ & $89.37 \pm 1.0 \times 10^{-2}$ & $88.47 \pm 0.9 \times 10^{-2}$ & $\textbf{86.83} \pm 0.6 \times 10^{-2} $\\ \hline \end{tabular} \end{adjustbox} \label{table:accu} \end{table} \fi We can observe in Table~\ref{table:accu} that the Lie group regularizations are usually outperforming the other methods the different datasets we evaluated. While the second-order regularization is more computationally demanding, it appears to be more stable and robust to the change of parameters. Besides, we can see that the first-order regularization might be more sensitive to how close to a Lie group the dataset under evaluation is. In fact, both the first and second-order depends on the learned infinitesimal operator, however, while the second-order use such matrix to constrain the overall curvature of the CPA the first-order use it to constrains its mapping. In Fig.~\ref{fig:epsilon}, we show, for three datasets, the value of the parameters $\epsilon_i, \forall i \in \left \{1,\dots,h\right\}$ obtained by minimizing Eq.~\ref{eq:regAE_first}. This observation is important as the framework we propose assumes that the dimension of the orbit, hence the number of group transformations, is the same as the dimension of the bottleneck layer of the autoencoder. In particular, we propose to highlight the sparsity of the parameters, i.e., if for various sampled pairs, the value a particular strength parameter, $\epsilon_i$, is close to $0$. If it is, then the associated group of transformation is not being used to map any $\textbf{D}(\theta)$ to a close sample $\textbf{D}(\theta')$. Therefore, the number of group of transformations selected is too large, e.g., in the top right subplot, corresponding to the Haptics dataset, we observe that, the $10$ transformations are not required. \section{Conclusion} We analyzed AEs from a geometrical standpoint and provided insights into how AEs are approximating the data manifold. In particular, we provided analytical formulas of the per region map that AEs are performing using its continuous piecewise affine formulation. This approach's strength lies in its interpretability power, as for a given region in the input space, the DN mapping is a simple affine map. Leveraging these key features, we proposed to enhance and guarantee the generalization capability of AEs by proposing two regularizations that capture the symmetry in the data. These regularizations constrain the piecewise continuous surface spanned by the decoder to approximate the orbit of a Lie group. Besides, inspired by the theory of learning Lie group transformations, we alleviated the need to explicitly define a group of symmetry underlying the data and propose to learn the group's generator. In fact, the generator of a Lie group lives in a vector space, thus enabling common matrix manipulations required to perform its update. Finally, we determined a computationally efficient procedure to learn these regularizations by performing a stochastic sampling approach to determine the per region parameters. Note that, in practice, this sampling is the bottleneck of our method since the regions do not form a regular tiling of the space. We showed that even using such an approximation, the method outperforms other existing regularizations and compete with state-of-the-art results on various datasets. We believe our methodology opens the door to novel ways for DN practitioners to regularize the DN's parameter space depending on data assumptions. In particular, this approach should be relevant in the case of the application of DNs in science, where the underlying physical phenomenons can be partially theoretically prescribed, and following our approach, problem-specific regularization can be derived to provide the AE with generalization guarantees and improved approximation capabilities. \textbf{Acknowledgments:}{\small A special thanks to Anirvan Segupta and Yanis Barhoun for their insights and discussions. RC and BA are supported by NSF grant SCH-1838873 and NIH grant R01HL144683-CFDA. Both RB are supported by NSF grants CCF-1911094, IIS-1838177, and IIS-1730574; ONR grants N00014-18-12571, N00014-20-1-2787, and N00014-20-1-2534; AFOSR grant FA9550-18-1-0478; and a Vannevar Bush Faculty Fellowship, ONR grant N00014-18-1-2047.} \small
{'timestamp': '2021-11-25T02:24:43', 'yymm': '2009', 'arxiv_id': '2009.09525', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09525'}
arxiv
\section{Introduction} \label{sec:intro} During the past decade, deep learning has been the engine powering many successes of artificial intelligence (AI). However, the deep neural network (DNN), as the basic model of deep learning, still suffers from some fundamental issues, such as model uncertainty, model interpretability, and prediction bias, which pose a high risk on the safety of AI. In particular, the standard optimization algorithms such as stochastic gradient descent (SGD) produce only a point estimate for the DNN, where model uncertainty is completely ignored. The machine prediction/decision is blindly taken as accurate and precise, with which the automated system might become life-threatening to humans if used in real-life settings. The universal approximation ability of the DNN enables it to learn powerful representations that map high-dimensional features to an array of outputs. However, the representation is less interpretable, from which important features that govern the function of the system are hard to be identified, causing serious issues in human-machine trust. In addition, the DNN often contains an excessively large number of parameters. As a result, the training data tend to be over-fitted and the prediction tends to be biased. As advocated by many researchers, see e.g. \cite{KendallGal2017} and \cite{ChaoChen2018}, Bayesian deep learning offers a principled way to address above issues. Under the Bayesian framework, a sparse DNN can be learned by sampling from the posterior distribution formulated with an appropriate prior distribution, see e.g. \cite{Liang2018BNN} and \cite{polson2018posterior}. For the sparse DNN, interpretability of the structure and consistency of the prediction can be established under mild conditions, and model uncertainty can be quantified based on the posterior samples, see e.g. \cite{Liang2018BNN}. However, due to the lack of efficient Monte Carlo algorithms for sampling from the posterior of DNNs, Bayesian deep learning has not yet powered our AI systems. Toward the goal of efficient Bayesian deep learning, a variety of stochastic gradient Markov chain Monte Carlo (SGMCMC) algorithms have been proposed in the literature, including stochastic gradient Langevin dynamics (SGLD) \citep{Welling2011BayesianLV}, stochastic gradient Hamiltonian Monte Carlo (SGHMC) \citep{Chen2014StochasticGH}, and their variants. One merit of the SGMCMC algorithms is that they are scalable, requiring at each iteration only the gradient on a mini-batch of data as in the SGD algorithm. Unfortunately, as pointed out in \cite{Dauphin2014}, DNNs often exhibit pathological curvature and saddle points, rendering the first-order gradient based algorithms, such as SGLD, inefficient. To accelerate convergence, the second-order gradient algorithms, such as stochastic gradient Riemannian Langevin dynamics (SGRLD)\citep{AhnKW2012, GirolamiG2011, PattersonTeh2013} and stochastic gradient Riemannian Hamiltonian Monte Carlo (SGRHMC) \citep{Ma2015ACR}, have been developed. With the use of the Fisher information matrix of the target distribution, these algorithms rescale the stochastic gradient noise to be isotropic near stationary points, which helps escape saddle points faster. However, calculation of the Fisher information matrix can be time consuming, which makes these algorithms lack scalability necessary for learning large DNNs. Instead of using the exact Fisher information matrix, preconditioned SGLD (pSGLD) \citep{Li2016PreconditionedSG} approximates it by a diagonal matrix adaptively updated with the current gradient information. \cite{Ma2015ACR} provides a general framework for the existing SGMCMC algorithms (see Section \ref{recipe}), where the stochastic gradient of the energy function (i.e., the negative log-target distribution) is restricted to be unbiased. However, this restriction is unnecessary. As shown in the recent work, see e.g., \cite{DalalyanK2017}, \cite{SongLiang2020}, and \cite{bhatia2019bayesian}, the stochastic gradient of the energy function can be biased as long as its mean squared error can be upper bounded by an appropriate function of $\theta_t$, the current sample of the stochastic gradient Markov chain. On the other hand, a variety of adaptive SGD algorithms, such as momentum \citep{Qian1999}, Adagrad \citep{Duchietal2011}, RMSprop \citep{TielemanH2012}, and Adam \citep{KingmaB2015}, have been proposed in the recent literature for dealing with the saddle point issue encountered in deep learning. These algorithms adjust the moving direction at each iteration according to the current gradient as well as the past ones. It was shown in \cite{StaibRK2019} that, compared to SGD, these algorithms escape saddle points faster and can converge faster overall to the second-order stationary points. Motivated by the two observations above, we propose a class of adaptive SGLD algorithms, where a bias term is included in the drift function to enhance escape from saddle points and accelerate the convergence in the presence of pathological curvatures. The bias term can be adaptively adjusted based on the path of the sampler. In particular, we propose to adjust the bias term based on the past gradients in the flavor of adaptive SGD algorithms \citep{Ruder2016}. We establish the convergence of the proposed adaptive SGLD algorithms under mild conditions, and demonstrate via numerical examples that the adaptive SGLD algorithms can significantly outperform the existing SGMCMC algorithms, such as SGLD, SGHMC and pSGLD. \section{A Brief Review of Existing SGMCMC Algorithms} \label{recipe} Let ${ X}_N=(X_1,X_2,\ldots,X_N)$ denote a set of $N$ independent and identically distributed samples drawn from the distribution $f(x|\theta)$, where $N$ is the sample size and $\theta$ is the vector of parameters. Let $p({ X}_N|\theta)=\prod_{i=1}^N f(X_i|\theta)$ denote the likelihood function, let $\pi(\theta)$ denote the prior distribution of $\theta$, and let $U(\theta)=-\log p({ X}_N|\theta)-\log \pi(\theta)$ denote the energy function of the posterior distribution. If $\theta$ has a fixed dimension and $U(\theta)$ is differentiable with respect to $\theta$, then the SGLD algorithm can be used to simulate from the posterior, which iterates by \[ \theta_{t+1}=\theta_t - \epsilon_{t+1} \nabla_{\theta} \tilde{U}(\theta_t) + \sqrt{2\epsilon_{t+1} \tau} \eta_{t+1}, \ \ \eta_{t+1} \sim N(0,I_d), \] where $d$ is the dimension of $\theta$, $I_d$ is an $d\times d$-identity matrix, $\epsilon_{t+1}$ is the learning rate, $\tau$ is the temperature, and $\nabla_{\theta} \tilde{U}(\theta)$ denotes an estimate of $\nabla_{\theta} U(\theta)$ based on a mini-batch of data. The learning rate can be kept as a constant or decreasing with iterations. For the former, the convergence of the algorithm was studied in \cite{Sato2014ApproximationAO} and \cite{DalalyanK2017}. For the latter, the convergence of the algorithm was studied in \cite{teh2016consistency}. The SGLD algorithm has been extended in different ways. As mentioned previously, each of its existing variants can be formulated as a special case of a general SGMCMC algorithm given in \cite{Ma2015ACR}. Let $\xi$ denote an augmented state, which may include some auxiliary components. For example, SGHMC augments the state to $\xi=(\theta,v)$ by including an auxiliary velocity component denoted by $v$. Then the general SGMCMC algorithm is given by \[ \theta_{t+1}=\theta_t - \epsilon_{t+1} [D(\xi)+Q(\xi)] \nabla_{\xi} \tilde{H}(\xi) + \Gamma(\xi) +\sqrt{2\epsilon_{t+1}\tau} Z_{t+1}, \] where $Z_{t+1} \sim N(0, D(\xi_t))$, $H(\xi)$ is the energy function of the augmented system, $\nabla_{\xi} \tilde{H}(\xi)$ denotes an unbiased estimate of $\nabla_{\xi} H(\xi)$, $D(\xi)$ is a positive semi-definite diffusion matrix, $Q(\xi)$ is a skew-symmetric curl matrix, and $\Gamma_i(\xi)=\sum_{j=1}^d \frac{\partial}{\partial \xi_j}(D_{ij}(\xi)+Q_{ij}(\xi))$. The diffusion $D(\xi)$ and curl $Q(\xi)$ matrices can take various forms and the choice of the matrices will affect the rate of convergence of the sampler. For example, for the SGHMC algorithm, we have $H(\xi)=U(\theta)+\frac{1}{2} v^T v$, $D(\xi)=\begin{pmatrix} 0 & 0 \\ 0 & C \end{pmatrix}$ for some positive semi-definite matrix $C$, and $Q(\xi)=\begin{pmatrix} 0 & -I \\ I & 0 \end{pmatrix}$. For the SGRLD algorithm, we have $\xi=\theta$, $H(\xi)=U(\theta)$, $D(\xi)=G(\theta)^{-1}$, $Q(\xi)=0$, where $G(\theta)$ is the Fisher information matrix of the posterior distribution. By rescaling the parameter updates according to geometry information of the manifold, SGRLD generally converges faster than SGLD. However, calculating the Fisher information matrix and its inverse can be time consuming when the dimension of $\theta$ is high and the total sample size $N$ is large. To address this issue, pSGLD approximates $G(\theta)$ using a diagonal matrix and sequentially updates the approximator using the current gradient information. To be more precise, it is given by \[ \begin{split} G(\theta_{t+1})&={\rm diag}(1 \oslash (\lambda \bf{1}+ \sqrt{V(\theta_{t+1})})), \\ V(\theta_{t+1})&=\beta V(\theta_{t})+(1-\beta) \nabla_{\theta} \tilde{U}(\theta_t) \odot \nabla_{\theta} \tilde{U}(\theta_t), \end{split} \] where $\lambda$ denotes a small constant, $\odot$ and $\oslash$ represent element-wise vector product and division, respectively. \section{Stochastic Gradient Langevin Dynamics with Adaptive Drifts} \label{ASGLDsect} Motivated by the observations that the stochastic gradient $\nabla_{\theta} \tilde{U}(\theta)$ used in SGLD is not necessarily unbiased and that the past gradients can be used to enhance escape from saddle points for SGD, we propose a class of adaptive SGLD algorithms, where the past gradients are used to accelerate the convergence of the sampler by forming a bias to the drift at each iteration. A general form of the adaptive SGLD algorithm is given by \begin{equation} \label{Adapteq} \theta_{t+1}=\theta_t - \epsilon_{t+1} (\nabla_{\theta} \tilde{U}(\theta_t) + a A_t) + \sqrt{2\epsilon_{t+1} \tau} \eta_{t+1}, \end{equation} where $A_t$ is the adaptive bias term, $a$ is called the bias factor, and $\eta_{t+1} \sim N(0,I_d)$. Two adaptive SGLD algorithms are given in what follows. In the first algorithm, the bias term is constructed based on the momentum algorithm \citep{Qian1999}; and in the second algorithm, the bias term is constructed based on the Adam algorithm \citep{KingmaB2015}. \subsection{Momentum SGLD} It is known that SGD has trouble in navigating ravines, i.e., the regions where the energy surface curves much more steep in one dimension than in another, which are common around local energy minima \citep{Ruder2016,Sutton1986}. In this scenario, SGD oscillates across the slopes of the ravine while making hesitant progress towards the local energy minima. To accelerate SGD in the relevant direction and dampen oscillations, the momentum algorithm \citep{Qian1999} updates the moving direction at each iteration by adding a fraction of the moving direction of the past iteration, the so-called momentum term, to the current gradient. By accumulation, the momentum term increases updates for the dimensions whose gradients pointing in the same directions and reduces updates for the dimensions whose gradients change directions. As a result, the oscillation is reduced and the convergence is accelerated. \begin{algorithm}[htbp] \caption{MSGLD} \label{alg:example} \begin{algorithmic} \STATE {\bfseries Input:} Data $\{x_i\}_{i=1}^N$, subsample size $n$, smoothing factor $0<\beta_1<1$, bias factor $a$, temperature $\tau$, and learning rate $\epsilon$; \STATE {\bfseries Initialization:} $\theta_0$ from an appropriate distribution, and $m_0=0$. \FOR{$i=1,2,\dots,$} \STATE Draw a mini-batch of data $\{x_j^*\}_{j=1}^n$, and calculate \STATE $\theta_{t+1}=\theta_{t}-\epsilon (\nabla\tilde{U}(\theta_{t})+a m_{t})+e_{t+1}$, \STATE $m_{t}=\beta_1 m_{t-1}+(1-\beta_1)\nabla\tilde{U}(\theta_{t-1})$, \\ where $e_{t+1} \sim N(0, 2 \tau \epsilon I_d)$, and $d$ is the dimension of $\theta$. \ENDFOR \end{algorithmic} \end{algorithm} As an analogy of the momentum algorithm in stochastic optimization, we propose the so-called momentum SGLD (MSGLD) algorithm, where the momentum is calculated as an exponentially decaying average of past stochastic gradients and added as a bias term to the drift of SGLD. The resulting algorithm is depicted in Algorithm \ref{alg:example}, where a constant learning rate $\epsilon$ is considered for simplicity. However, as mentioned in the Appendix, the algorithm also works for the case that the learning rate decays with iterations. The convergence of the algorithm is established in Theorem \ref{them:1}, whose proof is given in the Appendix. \begin{theorem}[Ergodicity of MSGLD] \label{them:1} Suppose the conditions (A.1)-(A.5) hold (given in Appendix), $\beta_1 \in (0,1]$ is a constant, and the learning rate $\epsilon$ is sufficiently small. Then for any smooth function $\phi(\theta)$, \[ \frac{1}{L} \sum_{k=1}^L \phi(\theta_k)- \int_{\Theta} \phi(\theta) \pi_*(\theta) d \theta \stackrel{p}{\to} 0, \quad \mbox{as $L\to \infty$}, \] where $\pi_*$ denotes the posterior distribution of $\theta$, and $\stackrel{p}{\to}$ denotes convergence in probability. \end{theorem} Algorithm \ref{alg:example} contains a few parameters, including the subsample size $n$, smoothing factor $\beta_1$, bias factor $a$, temperature $\tau$, and learning rate $\epsilon$. Among these parameters, $n$, $\tau$ and $\epsilon$ are shared with SGLD and can be set as in SGLD. Refer to \cite{Nagapetyan2017} and \cite{NemethF2019} for more discussions on their settings. The smoothing factor $\beta_1$ is a constant, which is typically set to 0.9. The bias factor $a$ is also a constant, which is typically set to 1 or a slightly large value. \subsection{Adam SGLD} The Adam algorithm \citep{KingmaB2015} has been widely used in deep learning, which typically converges much faster than SGD. Recently, \cite{StaibRK2019} showed that Adam can be viewed as a preconditioned SGD algorithm, where the preconditioner is estimated in an on-line manner and it helps escape saddle points by rescaling the stochastic gradient noise to be isotropic near stationary points. \begin{algorithm}[htbp] \caption{ASGLD} \label{alg:example2} \begin{algorithmic} \STATE {\bfseries Input:} Data $\{x_i\}_{i=1}^N$, subsample size $n$, smoothing factors $\beta_1$ and $\beta_2$, bias factor $a$, temperature $\tau$, and learning rate $\epsilon$; \STATE {\bfseries Initialization:} $\theta_0$ from appropriate distribution, $m_0=0$ and $V_0=0$; \FOR{$i=1,2,\dots,$} \STATE Draw a mini-batch of data $\{x_j^*\}_{j=1}^n$, and calculate \STATE $\theta_{t+1}=\theta_{t}-\epsilon(\nabla\tilde{U}(\theta_{t})+am_{t}\oslash \sqrt{V_{t}+\lambda {\bf 1}})+e_{t+1},$ \STATE $m_{t}=\beta_1 m_{t-1}+(1-\beta_1)\nabla\tilde{U}(\theta_{t-1})$, \STATE $V_{t}=\beta_2 V_{t-1}+(1-\beta_2)\nabla\tilde{U}(\theta_{t-1})\odot\nabla\tilde{U}(\theta_{t-1})$, \\ where $\lambda$ is a small constant added to avoid zero-divisors, $e_{t+1} \sim N(0, 2 \tau \epsilon I_d)$, and $d$ is the dimension of $\theta$. \ENDFOR \end{algorithmic} \end{algorithm} Motivated by this result, we propose the so-called Adam SGLD (ASGLD) algorithm. Ideally, we would construct the adaptive bias term as follows: \begin{equation} \label{Adameq1} \begin{split} m_t &=\beta_1 m_{t-1} +(1-\beta_1) \nabla \tilde{U}(\theta_{t-1}), \\ \tilde{V}_t &=\beta_2 \tilde{V}_{t-1}+(1-\beta_2) \tilde{U}(\theta_{t-1}) \tilde{U}(\theta_{t-1})^T, \\ \tilde{A}_t &=\tilde{V}_t^{-1/2} m_t, \end{split} \end{equation} where $\beta_1$ and $\beta_2$ are smoothing factors for the first and second moments of stochastic gradients, respectively. Since $\tilde{V}_t$ can be viewed as an approximator of the true second moment matrix $E(\nabla_{\theta} \tilde{U}(\theta_{t-1}) \nabla_{\theta} \tilde{U}(\theta_{t-1})^T)$ at iteration $t-1$, $\tilde{A}_t$ can viewed as the rescaled momentum which is isotropic near stationary points. If the bias factor $a$ is chosen appropriately, ASGLD is expected to converge very fast. In particular, the bias term may guide the sampler to converge to a global optimal region quickly, similar to Adam in optimization. However, when the dimension of $\theta$ is high, calculation of $\tilde{V}_t$ and $\tilde{V}_t^{-1/2}$ can be time consuming. To accelerate computation, we propose to approximate $\tilde{V}_t$ using a diagonal matrix as in pSGLD. This leads to Algorithm \ref{alg:example2}. The convergence of the algorithm is established in Theorem \ref{them:2}, whose proof is given in the Appendix. \begin{theorem} [Ergodicity of ASGLD] \label{them:2} Suppose the conditions (A.1)-(A.5) hold (given in Appendix), $\beta_1^2< \beta_2$ are two constants between 0 and 1, and the learning rate $\epsilon$ is sufficiently small. Then for any smooth function $\phi(\theta)$, \[ \frac{1}{L} \sum_{k=1}^L \phi(\theta_k)- \int_{\Theta} \phi(\theta) \pi_*(\theta) d \theta \stackrel{p}{\to} 0, \quad \mbox{as $L\to \infty$}, \] where $\pi_*$ denotes the posterior distribution of $\theta$, and $\stackrel{p}{\to}$ denotes convergence in probability. \end{theorem} Compared to Algorithm \ref{alg:example}, ASGLD contains one more parameter, $\beta_2$, which works as the smoothing factor for the second moment term and is suggested to take a value of 0.999 in this paper. \subsection{Other Adaptive SGLD Algorithms} In addition to the Momentum and Adam algorithms, other optimization algorithms, such as AdaMax \citep{KingmaB2015} and Adadelta \citep{AdaDelta2012}, can also be incorporated into SGLD to accelerate its convergence. Other than the bias term, the past gradients can also be used to construct an adaptive preconditioner matrix in a similar way to pSGLD. Moreover, the adaptive bias and adaptive preconditioner matrix can be used together to accelerate the convergence of SGLD. \section{Illustrative Examples} \label{ASGLDnum} Before applying the adaptive SGLD algorithms to DNN models, we first illustrate their performance on three low-dimensional examples. The first example is a multivariate Gaussian distribution with high correlation values. The second example is a multi-modal distribution, which mimics the scenario with multiple local energy minima. The third example is more complicated, which mimics the scenario with long narrow ravines. \subsection{A Gaussian distribution with high correlation values} Suppose that we are interested in drawing samples from $\pi(\theta)$, a Gaussian distribution with the mean zero and the covariance matrix $\Sigma=\begin{pmatrix} 1 &0.9 \\ 0.9 &1 \end{pmatrix}$. For this example, we have $\nabla_{\theta} U(\theta)=\Sigma^{-1}\theta$, and set $\nabla\tilde{U}(\theta)=\nabla U(\theta)+e$ in simulations, where $\theta=(\theta_1,\theta_2)^T \in \mathbb{R}^2$ and $e\sim N(0,I_2)$. For ASGLD, we set $\tau=1$, $a=0.1$, $\epsilon=0.1$, $\beta_1=0.9$ and $\beta_2=0.999$. For MSGLD, we set $\tau=1$, $a=0.01$, $\beta_1=0.9$ and $\epsilon=0.1$. For comparison, SGLD was also run for this example with the same learning rate $\epsilon=0.1$. Figure \ref{correlated} shows that both ASGLD and MSGLD work well for this example, where the left panel shows that they can produce the same accurate estimate as SGLD for the covariance matrix as the number of iterations becomes large. \begin{figure}[htbp] \begin{center} \centerline{\includegraphics[height=7cm, width=\columnwidth]{figures/covariance.png}} \caption{Performance of adaptive SGLD algorithms: (left) average absolute errors of the sample covariance matrix produced by SGLD, ASGLD and MSGLD along with iterations, and (right) scatter plots of the samples generated by ASGLD and MSGLD during their first 1000 iterations. } \label{correlated} \end{center} \vskip -0.4in \end{figure} \subsection{A multi-modal distribution} The target distribution is a 2-dimensional 5-component mixture Gaussian distribution, whose density function is given by $\pi(\theta)=\sum_{i=1}^5\frac{1}{10\pi}\exp(-\|\theta-\mu_i\|^2)$, where $\mu_1=(-3,-3)^T, \mu_2=(-3,0)^T, \mu_3=(0,0)^T, \mu_4=(3,0)^T, \mu_5=(3,3)^T$. For this example, we considered the natural gradient variational inference (NGVI) algorithm \citep{Kahn2019}, which is known to converge very fast in the variational inference field, as the baseline algorithm for comparison. For adaptive SGLD method, both ASGLD and MSGLD were applied to this example. We set $\nabla_{\theta} \tilde{U}(\theta)=\nabla U(\theta)+ e$, where $e\sim N(0,I_2)$ and $U(\theta)=-\log \pi(\theta)$. For a fair comparison, each algorithm was run in 6.0 CPU minutes. The numerical results were summarized in Figure \ref{multimodal1}, which shows the contour of the energy function and its estimates by NGVI, MSGLD and ASGLD. The plots indicate that MSGLD and ASGLD are better at exploring the multi-modal distributions than NGVI. \begin{figure}[htbp] \vskip 0.2in \begin{center} \centerline{\includegraphics[ width=\textwidth]{figures/multimodal.png}} \caption{ Contour plots of the true energy function (left) and its estimates by NGVI (middle left), MSGLD (middle right), and ASGLD (right). } \label{multimodal1} \end{center} \vskip -0.2in \end{figure} \subsection{A distribution with long narrow energy ravines} Consider a nonlinear regression \[ y=f_{\theta}(x)+\epsilon, \quad \epsilon\sim N(0,1), \] where $x \sim Unif[-2,4]$, $\theta=(\theta_1,\theta_2)^T \in \mathbb{R}^2$, and $f_{\theta}(x)=(x-1)^2+2\sin(\theta_1 x)+\frac{1}{30}\theta_1 +\cos(\theta_2 x-1)-\frac{1}{20}\theta_2$. As $\theta$ increases, the function $f_{\theta}(x)$ fluctuates more severely. Figure \ref{ravine1} depicts the regression, where we set $\theta_1=20$ and $\theta_2=10$. Since the random error $\epsilon$ is relatively large compared to the local fluctuation of $f_{\theta}(x)$, i.e., $2\sin(\theta_1 x)+\frac{1}{30}\theta_1 +\cos(\theta_2 x-1)-\frac{1}{20}\theta_2$, identification of the exact values of $(\theta_1, \theta_2)$ can be very hard, especially when the subsample size $n$ is small. \begin{figure}[htbp] \begin{subfigure}[t]{0.48\textwidth}\caption{} \includegraphics[height=6cm, width=\textwidth]{figures/wriggle.png}\label{ravine1} \end{subfigure} \begin{subfigure}[t]{0.48\textwidth}\caption{} \includegraphics[width=\textwidth]{figures/explor.png}\label{ravine2} \end{subfigure} \caption{(a) The dashed line is for the global pattern $(x-1)^2$ and the solid line is for the regression function $f_{\theta}(x)$, where $\theta_1=20$ and $\theta_2=10$. The points represent 100 random samples from the regression. (b) Contour plot of the energy function for one dataset and the sample paths produced by SGLD, SGHMC, pSGLD, ASGLD and MSGLD in a run, where the sample paths have been thinned by a factor of 50 for readability of the plot.}\label{Ravine} \end{figure} From this regression, we simulated 5 datasets with $(\theta_1,\theta_2)=(20,10)$ independently. Each dataset consists of 10,000 samples. To conduct Bayesian analysis for the problem, we set the prior distribution: $\theta_1 \sim N(0,1)$ and $\theta_2 \sim N(0,1)$, which are {\it a priori} independent. This choice of the prior distribution makes the problem even harder, which discourages the convergence of the posterior simulation to the true value of $\theta$. Instead, it encourages to estimate $f_{\theta}(x)$ by the global pattern $(x-1)^2$. Both ASGLD and MSGLD were run for each of the 5 datasets. Each run consisted of 30,000 iterations, where the first 10,000 iterations were discarded for the burn-in process and the samples generated from the remaining 20,000 iterations were averaged as the Bayesian estimate of $\theta$. In the simulations, we set the subsample size $n=100$. The settings of other parameters are given in the Appendix. Table \ref{distorted} shows the Bayesian estimates of $\theta$ produced by the two algorithms in each of the five runs. The MSGLD estimate converged to the true value in all five runs, while the ASGLD estimates converged to the true value in four of five runs. For comparison, SGLD, SGHMC and pSGLD were also applied to this example with the settings given in the Appendix. As implied by Table \ref{distorted}, all the three algorithms essentially failed for this example: none of their estimates converged to the true value! \begin{table}[htbp] \caption{Bayesian estimates of $\theta$ produced by different algorithms for the long narrow energy ravines example in five independent runs, where the true value of $\theta$ is (20,10). } \label{distorted} \begin{center} \begin{sc} \vspace{-0.1in} \begin{tabular}{lcccccc} \toprule Method & $\theta$ & 1 &2 &3 & 4 &5 \\ \midrule & $\theta_1$ &-5.79 &-6.59 & 17.43 & 0.99 & -3.01 \\ \raisebox{1.5ex}{SGLD} & $\theta_2$ &-2.42 & -1.76 &9.02 & -1.36 &-4.74 \\ \hdashline & $\theta_1$ & 9.22 & 14.73 &23.19 & 11.39& -4.22\\ \raisebox{1.5ex}{SGHMC} & $\theta_2$ & 1.27 & 6.23 & 11.03 & 2.65 & -2.25 \\ \hdashline & $\theta_1$ & 1.27 & -19.77 & 16.52 &5.14& -9.08\\ \raisebox{1.5ex}{pSGLD} & $\theta_2$ & -2.22& -15.44 & 8.17 & 0.65 & 3.75 \\ \midrule & $\theta_1$ & 19.75 & 15.34 & 19.99 & 19.01 &19.98 \\ \raisebox{1.5ex}{ASGLD} & $\theta_2$& 9.99 &9.29 & 9.92& 9.66 &9.99\\ \hdashline & $\theta_1$ &20.01 &20.07 & 19.99 & 20.00 &19.99 \\ \raisebox{1.5ex}{MSGLD} & $\theta_2$&9.99 &10.00 &9.99 & 9.99 & 9.99\\ \bottomrule \end{tabular} \end{sc} \end{center} \vspace{-0.1in} \end{table} For a further exploration, Figure \ref{ravine2} shows the contour plot of the energy function for one dataset as well as the sample paths produced by SGLD, SGHMC, pSGLD, ASGLD and MSGLD for the dataset. As shown by the contour plot, the energy landscape contains multiple long narrow ravines, which make the existing SGMCMC algorithms essentially fail. However, due to the use of momentum information, ASGLD and MSGLD work extremely well for this example. As indicated by their sample paths, they can move along narrow ravines, and converge to the true value of $\theta$ very quickly. It is interesting to point out that pSGLD does not work well for this example, although it has used the past gradients in constructing the preconditioned matrix. A possible reason for this failure is that it only approximates the preconditioned matrix by a diagonal matrix and missed the correlation between different components of $\theta$. \section{DNN Applications} \subsection{Landsat Data} The dataset is available at the UCI Machine Learning Repository, which consists of 4435 training instances and 2000 testing instances. Each instance consists of 36 attributes which represent features of the earth surface images taken from a satellite. The training instances consist of 6 classes, and the goal of this study is to learn a classifier for the earth surface images. We modeled this dataset by a fully connected DNN with structure 36-30-30-6 and \emph{Relu} as the activation function. Let $\theta$ denote the vector of all parameters (i.e., connection weights) of the DNN. We let $\theta$ be subject to a Gaussian prior distribution: $\theta \sim N(0,I_d)$, where $d$ is the dimension of $\theta$. The SGLD, SGHMC, pSGLD, ASGLD and MSGLD algorithms were all applied to simulate from the posterior of the DNN. Each algorithm was run for 3,000 epochs with the subsample size $n=50$ and a decaying learning rate \begin{equation} \label{decayrate} \epsilon_{k}=\epsilon_0 \gamma^{\lfloor k/L\rfloor}, \end{equation} where $k$ indexes epochs, the initial learning rate $\epsilon_0=0.1$, $\gamma=0.5$, the step size $L=300$, and $\lfloor z \rfloor$ denotes the maximum integer less than $z$. For the purpose of optimization, the temperature was set to $\tau=0.01$. The settings for the specific parameters of each algorithm were given in the Appendix. Each algorithm was run for five times for the example. In each run, the training and test classification accuracy were calculated by averaging over the last $200$ samples, which were collected from the last 100,000 iterations with a thinning factor of $500$. For each algorithm, Table \ref{UCI-result} reports the mean classification accuracy, for both training and test, averaged over five runs and its standard deviation. The results indicate that MSGLD has significantly outperforms other algorithms in both training and test for this example. While ASGLD performs similarly to pSGLD for this example. \begin{table}[htbp] \caption{Training and test classification accuracy produced by different SGMCMC algorithms for the Landsat data, where the accuracy and its standard error were calculated based on $5$ independent runs.} \label{UCI-result} \begin{center} \begin{sc} \vspace{-0.1in} \begin{tabular}{lcc} \toprule Method & Training Accuracy & Test Accuracy \\ \midrule SGLD & 93.163$\pm$0.085 & 90.225$\pm$0.153 \\ pSGLD & 93.857$\pm$ 0.125 & 90.712$\pm$0.090\\ SGHMC & 94.015$\pm$0.117 & 90.848$\pm$0.089\\ \midrule ASGLD & 93.827$\pm$0.087 & 90.794$\pm$0.087\\ MSGLD & {\bf 94.910} $\pm$0.105 & {\bf 91.247} $\pm$0.141 \\ \bottomrule \end{tabular} \end{sc} \end{center} \end{table} \begin{figure}[!t] \begin{subfigure}[t]{0.48\textwidth} \caption{}\label{uci2}\includegraphics[ width=\textwidth]{figures/UCI2.png} \end{subfigure} \begin{subfigure}[t]{0.48\textwidth} \caption{}\label{uci1}\includegraphics[width=\textwidth]{figures/UCI.png} \end{subfigure} \caption{(a) Training classification errors produced by different SGMCMC algorithms for the Landsat data example. (b) Test classification errors produced by different SGMCMC algorithms for the Landsat data example.}\label{uci} \end{figure} Finally, we note that for this example, the SGMCMC algorithms have been run excessively long. Figure \ref{uci2} and Figure \ref{uci1} show, respectively, the training and test classification errors produced by SGLD, pSGLD, SGHMC, ASGLD and MSGLD along with iterations. It indicates again that MSGLD significantly outperforms other algorithms in both training and test. \subsection{MNIST data} The MNIST is a benchmark dataset of computer vision, which consists of 60,000 training instances and 10,000 test instances. Each instance is an image consisting of $28\times 28$ attributes and representing a hand-written number of 0 to 9. For this data set, we tested whether ASGLD or MSGLD can be used to train sparse DNNs. For this purpose, we considered a mixture Gaussian prior for each of the connection weights: \begin{equation}\label{sparseprior} \pi(\theta_k)\sim \lambda_k N(0,\sigma_{1,k}^2)+(1-\lambda_k)N(0,\sigma_{0,k}^2), \end{equation} where $k$ is the index of hidden layers, and $\sigma_{0,k}$ is a relatively very small value compared to $\sigma_{1,k}$. In this paper, we set $\lambda_k=10^{-7},\ \sigma_{1,k}^2=0.02, \ \sigma_{0,k}^2=1\times 10^{-5}$ for all $k$. We trained a DNN with structure 784-800-800-10 using ASGLD and MSGLD for 250 epochs with subsample size $100$. For the first $100$ epochs, the DNN was trained as usual, i.e., with a Gaussian prior $N(0,I_d)$ imposed on each connection weight. Then the DNN was trained for 150 epochs with the prior (\ref{sparseprior}). The settings for the other parameters of the algorithms were given in the Appendix. Each algorithm was run for 3 times. In each run, the training and prediction accuracy were calculated by averaging, respectively, the fitting and prediction results over the iterations of the last 5 epochs. The numerical results were summarized in Table \ref{sparsetab}, where ``Sparse ratio'' is calculated as the percentage of the learned connection weights satisfying the inequality $|\theta_k|\geq \sqrt{\log(\frac{1-\lambda_k}{\lambda_k}\frac{\sigma_{1k}}{\sigma_{0k}})\frac{2\sigma_{0k}^2\sigma_{1k}^2}{\sigma_{1k}^2-\sigma_{0k}^2} }$. The threshold is determined by solving the probability inequality $P\{\theta_k \sim N(0,\sigma_{0,k}^2)|\theta_k\} \leq P\{\theta_k \sim N(0,\sigma_{1,k}^2)|\theta_k\}$. \begin{table}[htbp] \caption{Comparison of different algorithms for training sparse DNNs for the MNIST data, where the reported results for each algorithm were averaged based on three independent runs. } \label{sparsetab} \begin{center} \begin{sc} \begin{tabular}{lccc} \toprule Method & Training Accuracy & Test Accuracy & Sparsity Ratio \\ \midrule ASGLD &{\bf 99.542}$\pm$ 0.026 &{\bf 98.417}$\pm$0.044 & 3.176$\pm$0.155\\ MSGLD &99.494$\pm$ 0.002 &98.319 $\pm$0.019 &3.369$\pm$0.063\\ ADAM &99.383$\pm$0.072& 98.332$\pm$0.003& 2.169$\pm$0.013\\ \bottomrule \end{tabular} \end{sc} \end{center} \vskip -0.1in \end{table} Adam is a well known DNN optimization method for MNIST data. For comparison, it was also applied to train the sparse DNN. Interestingly, ASGLD outperforms Adam in both training and prediction accuracy, although its resulting network is a little more dense than that by Adam. \subsection{CIFAR 10 and CIFAR 100} The CIFAR-10 and CIFAR-100 are also benchmark datasets of computer vision. CIFAR-10 consists of 50,000 training images and 10,000 test images, and the images were classified into 10 classes. The CIFAR-100 dataset consists of 50,000 training images and 10,000 test images, but the images were classified into 100 classes. We modeled both datasets using a ResNet-18\cite{resnet}, and trained the model for 250 epochs using various optimization and SGMCMC algorithms, including SGD, Adam, SGLD, SGHMC, pSGLD, ASGLD and MSGLD with data augmentation techniques. The temperature $\tau$ was set to $1.0e-5$ for all SGMCMC methods. The subsample sample size was set to 100. For CIFAR-10, the learning rate was set as in (\ref{decayrate}) with $L=40$ and $\gamma=0.5$; and the weight prior was set to $N(0,\frac{1}{25}I_d)$ for all SGMCMC algorithms. For CIFAR-100, the learning rate was set as in (\ref{decayrate}) with $L=90$ and $\gamma=0.1$; and the weight prior was set to $N(0,\frac{1}{25}I_d)$ for SGLD, pSGLD, and SGHMC, and \textcolor{black}{$N(0,\frac{1}{75}I_d)$ for ASGLD and MSGLD.} For SGD and Adam, we set the objective function as \begin{equation} \label{objeq3} -\frac{1}{n} \sum_{i=1}^n \log f(x_i|\theta)+ \frac{1}{2} \lambda \|\theta\|^2, \end{equation} where $f(x_i|\theta)$ denotes the likelihood function of observation $i$, and $\lambda$ is the regularization parameter. For SGD we set $\lambda=5.0e-4$; and for Adam we set $\lambda=0$. For Adam, we have also tried the case $\lambda\ne 0$, but the results were inferior to those reported below. For each dataset, each algorithm was run for 5 times. In each run, the training and test classification errors were calculated by averaging over the iterations of the last 5 epochs. Table \ref{cifar-result} reported the mean training and test classification accuracy (averaged over 5 runs) of the Bayesian ResNet-18 for CIFAR-10 and CIFAR-100. The comparison indicates that MSGLD outperforms all other algorithms in test accuracy for the two datasets. In terms of training accuracy, ASGLD and MSGLD work more like the existing momentum-based algorithms such as ADAM and SGHMC, but tend to generalize better than them. This result has been very remarkable, as all algorithms were run with a small number of epochs; that is, the Monte Carlo algorithms are not necessarily slower than the stochastic optimization algorithms in deep learning. \begin{table}[htbp] \caption{Mean training and test classification accuracy (averaged over 5 runs) of the Bayesian ResNet-18 for CIFAR-10 and CIFAR-100 data} \label{cifar-result} \begin{center} \begin{sc} \begin{tabular}{lccccc} \toprule & \multicolumn{2}{c}{CIFAR-10} & & \multicolumn{2}{c}{CIFAR-100} \\ \cline{2-3} \cline{5-6} Method & Training & Test & & Training & Test \\ \midrule SGD & 99.721$\pm$0.058 &92.896$\pm$0.141 & & 98.211$\pm$0.208 & 72.274$\pm$0.145\\ ADAM & 99.515$\pm$0.087 & 92.144$\pm$0.154& & 96.744$\pm$0.390 & 67.564$\pm$0.501\\ \midrule SGLD & 99.713$\pm$0.034 & 92.908$\pm$0.114 & & 97.650$\pm$0.131 & 71.908$\pm$0.149\\ pSGLD & 97.209$\pm$0.465 & 89.398$\pm$0.379& & 99.034$\pm$0.101 & 69.234$\pm$0.162\\ SGHMC & 99.152$\pm$0.060 & 93.470$\pm$0.073 & & 96.92$\pm$0.091 & 73.112$\pm$0.139 \\ \midrule ASGLD & 99.738$\pm$0.052 & 93.018$\pm$0.187 & & 96.938$\pm$0.268 & 73.252$\pm$0.681\\ MSGLD & 99.702$\pm$0.066 & {\bf 93.512}$\pm$0.081 & & 96.801$\pm$0.150 & {\bf 73.670}$\pm$0.144\\ \bottomrule \end{tabular} \end{sc} \end{center} \end{table} \section{Conclusion} \label{ASGLDconc} This paper has proposed a class of adaptive SGMCMC algorithms by including a bias term to the drift of SGLD, where the bias term is allowed to be adaptively adjusted with past samples, past gradients, etc. The proposed algorithms have extended the framework of the existing SGMCMC algorithms to an adaptive one in a flavor of extending the Metropolis algorithm \cite{Metropolis1953} to the adaptive Metropolis algorithm \citep{Haario2001} in the history of MCMC. The numerical results indicate that the proposed algorithms have inherited many attractive properties, such as quick convergence in the scenarios with long narrow ravines or saddle points, from their counterpart optimization algorithms, while ensuring more extensive exploration of the sample space than the optimization algorithms due to their simulation nature. As a result, the proposed algorithms can significantly perform the existing optimization and SGMCMC algorithms in both simulation and optimization. For the adaptive SGMCMC algorithms, different bias terms represent different strengths in escaping from local traps, saddle points, or long narrow ravines. In the future, we will consider to develop an adaptive SGMCMC algorithm with a complex bias term which has incorporated all the strengths in escaping from local traps, saddle points, long narrow ravines, etc. We will also consider to incorporate other advanced SGMCMC techniques into adaptive SGMCMC algorithms to further improve their performance. For example, cyclical SGMCMC \citep{csgmcmc} proposed a cyclical step size schedule, where larger steps discover new modes, and smaller steps characterize each mode. This technique can be easily incorporated into adaptive SGLD algorithms to improve their convergence to the stationary distribution.
{'timestamp': '2020-09-22T02:20:27', 'yymm': '2009', 'arxiv_id': '2009.09535', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09535'}
arxiv
\section{Introduction} Categorizing visual scenes quickly and robustly is critical for navigating an environment, localizing targets, and deciding how to act in a given context, both for humans \cite{Malcolm2016MakingScenes} and robots \cite{Rangel2016SceneLabeling,Liao2016UnderstandNetworks}. Consequently, understanding scene perception is an important research topic in both biological and machine vision. The majority of computational approaches emphasize the importance of global summary statistics \cite{Oliva2001ModelingEnvelope}, or high-level features \cite{Simonyan2015VeryRecognition} in scene categorization. Human observers, however, experience a scene as being composed of multiple objects, and the deeper meaning of a scene is determined by the physical and semantic relationships between these objects as well as their relationship to the scene gist \cite{Malcolm2016MakingScenes}. In general, visual scenes such as a room, a beach, or a parking lot are well-defined spatial locations that typically contain a large number of items arranged according to semantic (and syntactic) regularities. Importantly, scenes not only contain objects, which are defined as spatially distinct entities that can be moved or manipulated (e.g., a bar of soap, a stone, or a statue); they also incorporate “stuff”, a term that refers to amorphous areas that do not have these properties (e.g., walls, floor, a river, or the sky) \cite{Zhou2017SceneDataset,Zhou2018Places:Recognition}. In all of our analyses, objects and stuff are treated identically, and are assumed to be constituent parts of scenes. For brevity, we will therefore use the label \textit{objects} as an umbrella term to refer to both proper objects and stuff. The purpose of this paper is to introduce vector representations of objects and scene categories and show how they might be useful for scene analysis and understanding. Importantly, our approach is not dependent on a text corpus, and we do not use image captions or complex annotations. Instead, we only rely on scene labels, object labels and the spatial organization of objects within a scene to develop two approaches for learning object and scene embeddings from images. In the first approach, the embeddings are based on co-occurrences of objects within scenes. In the second approach, we zoom into images and define as local spatial context the co-occurrence of objects in a small spatial window. In order to be useful, we aim for these representations to exhibit a number of properties critical for scene analysis and understanding: first, the embeddings should capture object-object relationships. For instance, we would like the embeddings to reflect the fact that a bar of soap and a towel are semantically closely related because they tend to co-occur in bathrooms and are used in the same functional contexts. Second, we hope to derive object-scene relationships such as a bar of soap being more closely related to a bathroom than to a living room. Third, we would like the embeddings to encode scene-scene relationships such that bathroom and bedroom are more closely related to each other than either of them to a football field. Finally, we aim for representations that are reliable at different hierarchical levels and can decompose scenes into sub-regions of semantically related objects. In order to generate these image-based object and scene embeddings, we build on word embeddings, a technique that has been successfully employed to represent semantic relationships in natural language \cite{Lai2016HowEmbedding}. The motivation for word embeddings rests on the distributional hypothesis: words that occur in the same context, for instance, within the same sentence, tend to carry a similar meaning. Based on this assumption, the statistics of co-occurrences of words can be used as a proxy for semantic relatedness. In analogy to this idea, one can formulate the \textit{distributional hypothesis for objects and scenes}: scenes that contain the same objects (object context) are semantically related. Similarly, objects that appear in the same spatial context (other objects within the scene or within subregions of it) are semantically related. Note that, in analogy to the relationships between words in word embeddings, the relationships between objects and scenes are not functionally defined (e.g., toilet paper and toothbrush have very different functions) but purely governed by spatial proximity. Yet, empirical evidence supports the hypothesis that spatial relations mirror semantic relations. For instance, when Convolutional Neural Networks (CNNs) are trained to classify scenes, object detectors emerge as an intermediate representation of the network, suggesting that objects are informative with respect to scene category \cite{Zhou2014ObjectCNNs,Zhou2018Places:Recognition}. \subsection{Related work} Embeddings have been useful in domains other than text data. For instance, they are used to represent genes in gene-expression data \cite{Du2019Gene2vec:Co-expression}, computer network log data \cite{Zhuo2017NetworkEmbeddings}, and graph-based data such as molecules \cite{Liu2019N-GramMolecules}. In computer vision, several studies attempt to use image information in order to enhance word embeddings learnt from text corpora. For instance, \cite{Mao2016TrainingImages} add a feature vector derived from a VGG-16 CNN to a neural network that learns word embeddings from the respective image captions. Instead of using fixed image vectors, \cite{Ailem2020AImages} use a model based on a Variational Autoencoder that learns a latent visual representation along with the word embedding. \cite{Harwath2016DeepImages} learn multi-modal embeddings by combining images with spoken rather than textual image captions. \cite{Kottur2016VisualScenes} use embeddings initialized with Word2vec to predict annotations of abstract scenes, yielding modified embeddings that might better encode visual semantic relationships. Using a GloVe-based embedding model, \cite{Gupta2019ViCo:Co-occurrences} train scene embeddings from co-occurrences of objects within images. A number of papers use features derived from objects in a scene to enhance scene classification. \cite{Li2012ObjectsClassification} propose an object filter bank to derive a set of image descriptors that serves as input for simple off-the-shelf classifiers such as SVM. \cite{Liao2016UnderstandNetworks} use semantic information from an image segmentation model as a regularizer for the first layers of an AlexNet CNN. A study by \cite{Chen2019SceneEmbeddings} is closest to ours. The authors propose to train object and scene embeddings from co-ocurrences within images. They then refine the prediction of a scene classifier using the predicted scene embedding. Our approach, too, relies on co-occurrences of objects. However, it differs from \cite{Chen2019SceneEmbeddings} in several important ways and offers the following additional contributions: (i) whereas previous papers focused on downstream applications such as scene classification only, we also investigate whether embeddings are semantically meaningful. Second, (ii) we adapt and compare a variety of models (LSA, Skipgram, CBOW). And third, (iii) we extend a state-of-the-art scene classification architecture with LSA embeddings. Unlike previous approaches, we directly fuse image features with object-based embeddings in the last CNN layer. Finally, (iv) we go beyond a 'bag-of-objects' approach and model local spatial context by considering the spatial proximity of objects within images. \subsection{Dataset} We use the ADE20K dataset \cite{Zhou2017SceneDataset} to train the object and scene embeddings (version ADE20K\_2016\_07\_26). Unlike many other visual datasets, ADE20K contains a dense image annotation with every pixel being labeled. Additionally, each image is assigned to a scene category (e.g., abbey, bathroom). In total, the dataset contains 3,148 objects labels, 872 scene labels, and 22,210 individual images. We remove unlabeled objects and scenes, and only consider object and scene categories that occur in at least five images. An image has to contain at least two different objects to be selected. After applying these selection criteria, 1,140 object categories and 19,290 images remain in the dataset. The least common scene 'stone circle' appears in five images whereas the most common scene 'street' appears 2,241 times. The least common object 'carriage' appears in five images whereas the most common object 'wall' appears in 11,559 images. Sampling strategies, similar to those used for text data, are used to deal with this imbalance. \section*{Scene embeddings from object co-occurrences}\label{sec:scene_embeddings} \begin{figure*} \centering \includegraphics[width=0.9\textwidth]{LSA_word2vec} \caption{Object and scene embeddings using LSA and Word2vec. (a) LSA operates on an object-scene occurrence matrix. (b) Single forward pass through a Skipgram model. A scene embedding (kitchen) is randomly selected. It is used to predict positive (blender, fridge) and negative (car) examples. (c) Forward pass through a CBOW model. Embeddings from a set of objects from a scene category are summed and used to predict the scene category.} \label{fig:embedding_models} \end{figure*} We harness two word embedding algorithms, Latent semantic analysis (LSA) \cite{Deerwester1990IndexingAnalysis} and Word2vec \cite{Mikolov2013EfficientSpace}, to learn two sets of embeddings, one for objects and one for scenes. For LSA, embeddings are obtained via matrix factorization of a scene-object co-occurrence matrix. For Word2vec, we either use a scene category to predict the objects it contains (Skipgram model) or use a set of objects to predict the category of the scene they appear in (CBOW). The resultant embeddings are used to test the distributional hypothesis for objects and scenes, and as feature vectors for a scene classification model. \subsection{Latent semantic analysis (LSA)} LSA models the relationship between words and a collection of documents they appear in \cite{Deerwester1990IndexingAnalysis}. Its applications include document retrieval for search queries and topic modelling. It is based on the singular value decomposition (SVD) of a term-document matrix, wherein rows represent terms or words, columns represent documents, and each entry corresponds to the frequency of occurrence. In order to derive image-based embeddings using LSA, we replace the document-word matrix by a scene-object matrix $\mathbf{X}\in\mathbb{R}^{n,m}$, where each row represents an object, each column represents a scene category, and the $(i,j)$-th entry is nonzero only if object $i$ appears in scene $j$. This is illustrated in Fig. \ref{fig:embedding_models}a. Using SVD, we can perform a low rank approximation of $\mathbf{X}$ as \begin{equation} \mathbf{X}\approx\O\L\S^\top. \end{equation} Here, the rows of $\O\in\mathbb{R}^{n\times d}$ act as object embeddings, $\S\in\mathbb{R}^{m\times d}$ as scene embeddings, $\L\in\mathbb{R}^{d\times d}$ is a diagonal matrix of singular values, and $d$ is the embedding dimension which is selected by the user. To use this approach with ADE20k data, we first binarize the $1,140$-dimensional vector of object counts for each image. Subsequently, object vectors from images representing the same category are added together, yielding a $1,140\times 682$ matrix. Three different normalization approaches for the object counts are explored: \textit{LSA-norm} (divide each column by its total count), \textit{LSA-log} (log-transform the counts), and \textit{LSA-tfidf} (TF-IDF transform). TF-IDF is a popular normalization scheme \cite{Beel2013ResearchSurvey} and is given by the product \[ \text{tfidf}(o, s) = \text{tf}(o,s)\cdot \text{idf}(o) \] where $\text{tf}(o,s)$ is the term frequency, i.e., the number of times an object $o$ occurs in a scene category $s$, and $\text{idf}(o) = m/|\sum_{i=1}^m \mathbf{X}(o,i)>0|$ is the inverse document frequency that down-weighs objects that occur in many scene categories. An advantage of LSA over methods such as Word2vec is that in addition to embeddings for items in the training vocabulary, it also provides a linear transform that can be applied to unseen images. For a vector of object counts $\mathbf{x}\in\mathbb{R}^n$ representing a test image, the respective embedding is given by \begin{equation} \text{embed}(\mathbf{x}) = \O^\top\mathbf{x}. \end{equation} We will exploit this property in section \ref{sce:scene_classification} when we perform scene classification on test images. \subsection{Word2vec}\label{sec:word2vec} Word2vec constructs word embeddings by relating target words to words with a context window, e.g., other words from the same sentence \cite{Mikolov2013EfficientSpace}. It comes in two flavors: In the Skipgram model, the conditional probability of a context word given the target word is maximized, whereas the CBOW model maximizes the probability of the target word given the sum of the embeddings of its context words. In typical text applications, input and output words come from the same domain, and two sets of embeddings (for inputs and outputs) are obtained. After training, the two sets are either averaged or one of them is selected to represent the embeddings. Here, we consider an asymmetrical approach in which inputs and outputs stem from different domains, one representing objects and the other scenes. Therefore, one matrix contains the object embeddings, the other matrix contains the scene embeddings. For the Skipgram model (depicted in Fig. \ref{fig:embedding_models}b), the objective it to maximize the average log probability for an object $o$ given the scene $s$ it appears in, \begin{equation}\label{eq:skipgram} \sum_{s\in S}\sum_{o\in\text{context}(s)}\log p(o | s) \end{equation} where $S$ is the set of scene images and context(s) is defined as the set of objects present in the respective image. Although our dataset is comparably small, we consider the subsampling and negative sampling strategies from \cite{Mikolov_NIPS13} for the Skipgram model. To subsample scenes categories (inputs), the relative number of images from a given category is defined as its frequency $f(s)$. An image is rejected from the training data with a probability of $p(s) = 1-\sqrt{t/f(s)}$. Since the image corpus is relatively small, we set $t=0.005$ and the subsampling is repeated in every epoch. For an input image, five objects from the scene are chosen as positive outputs (objects are repeated for images with less than five objects). For negative sampling of objects, denote the frequency of an object as $f(o)$. We thus sample 20 negative objects with a probability of $p(o) = f(o)^{3/4}/\sum_{o'\in O}f(o)^{3/4}$, where $O$ is the set of all objects. For the CBOW model, uniform sampling is used throughout. First, an object is randomly sampled. Then an image containing this object is randomly selected, and the remaining objects are sampled from this image. A context size of five objects is used, and the scene category corresponding to the image serves as target. Both models are implemented in Pytorch, using 100 epochs with an Adam optimizer and a learning rate of 0.01. \subsection{Testing the distributional hypothesis for scenes} \begin{figure} \centering \includegraphics[width=0.3\textwidth]{Word2vec_embeddings} \caption{t-SNE visualization of scene embeddings for the Skipgram model (d=100), using a cosine metric. (a) Supercategories. (b) Subcategories of 'indoor'.} \label{fig:tsne} \end{figure} If the distributional hypothesis for scenes is correct and relevant semantic information is preserved in the embeddings, the embedding vectors should cluster according to semantic properties such as membership in supercategories. For instance, in the Places dataset \cite{Zhou2018Places:Recognition} scene categories can be indoor (e.g. bathroom), natural outdoor (e.g. beach), or urban outdoor (e.g. football field). In line with this, we find that scenes within these supercategories appear more similar to each other than to scenes from other supercategories, using a cosine distance metric. This is exemplarily depicted for the Skipgram model in Fig. \ref{fig:tsne}a. Indoor, urban and natural scenes form well-defined clusters. Urban and natural scenes are partially overlapping, which could be explained by the fact that they are both outdoor scenes and hence share a number of objects such as sky, sun, or mountain. As a more quantitative evaluation, the results for a Wilcoxon rank-sum test are reported in Table \ref{tab:wilcoxon} for all models and d=100. The comparison of the within-category vs between-categories cosine distances is highly significant and illustrates that scenes within a category are much more similar to each other than to scenes from other categories. This relationship holds for subcategories, too (Fig. \ref{fig:tsne}b). Results and visualizations for other embedding dimensions and all subcategories are provided in the supplementary material. \begin{table} \footnotesize \begin{tabular}{ |p{1.5cm}|p{1.5cm}|p{1.5cm}|} \hline Method & Wilcoxon z & p-value\\ \hline {LSA-norm} & -16.33 & $<0.0001$\\ \hline {LSA-tfidf} & -14.72 & $<0.0001$\\ \hline {LSA-log} & -15.62 & $<0.0001$\\ \hline {Skipgram} & -261.18 & $<0.0001$\\ \hline {CBOW} & -98.69 & $<0.0001$\\ \hline \end{tabular} \caption{Within vs between category Wilcoxon rank-sum test results (z-statistic and p-value) for an embedding dimension of d=100.}\label{tab:wilcoxon} \end{table} \subsection{Scene classification}\label{sce:scene_classification} To evaluate the efficacy and relevance of the LSA embeddings, we compare scene classification performance of Residual Networks \cite{He2016DeepRecognition} (ResNets) and VGG networks \cite{Simonyan2015VeryRecognition} \emph{without LSA} features to the performance when the corresponding LSA features are appended to the second last fully connected layer. In a second type of evaluation, we add an \emph{object presence} vector rather than the LSA features. It is a 1200-dimensional binary array from the ADE20K Matlab API with an entry of 1 if an object is present in a particular scene and 0 otherwise. \subsubsection{ResNet18 and VGG11 training:} ResNet18 and VGG11 are trained in two classification analyses: first, (i) the training/validation split proposed by the ADE20K filenames, and second, (ii) a 5-fold cross-validation based on the combined training/validation data. For both analyses we use batches of 100 composed of randomly cropped 224$\times$224 px images. Each random crop is normalized using a uint8 normalization transform in Pytorch \cite{Paszke2019PyTorch:Library}. On the training/validation split we select the 506 scene categories contained in both sets. For the 5-fold cross-validation the number of classes depends on each fold (499-509). For ResNet18 we use an initial global learning rate of 0.1 with a linear weight decay of 0.0001 after each epoch. For VGG11, to prevent a divergence of the weight amplitudes we use an initial learning rate of 0.01 with a weight decay of $10^{-5}$ after each epoch. The models' weights and biases are initialized using the Glorot's initializer \cite{torres2017enhanced} and optimized using Adam. Models are trained for 100 epochs in all analyses. \subsubsection{Adding LSA features:} We add the LSA embeddings to two extra fully-connected (FC) ReLU layers added to the end of each model architecture as an additional classification subnetwork \cite{Zhang2016SPDA-CNN:Recognition}. The first FC layer has 4096 neurons. It receives inputs from both the 512 units of the last layer of ResNet18/VGG11 and the 300-dimensional vector of LSA embedding features. This feeds into a second FC ReLU layer with 4096 units which is followed by a final softmax layer. We use a fan-out/fan-in ratio greater than one on our proposed FC layers connection in order to optimize the layer-to-layer activation \cite{Glorot2010UnderstandingNetworks}. LSA transforms are generated using the training exemplars in each analysis. The transform is then applied to the object annotations of the respective test images. The weights and biases of the extra FC layers are updated using the same training parameters as in the baseline model. Therefore, we do not use ResNet18 and VGG11 with pre-trained weights but rather train the full model including the additional FC layers from scratch. For consistency with the image batch generation we use Pytorch's \emph{SubsetRandomSampler} synchronized with the corresponding image batches to generate corresponding LSA training batches. The LSA embeddings are not randomly cropped. Rather, batch indices are permuted on each training iteration. This approach guarantees consistent and reliable Class-Activation maps as reported in the supplementary material \cite{Zhou2016LearningLocalization}. \subsubsection{Results:} Table \ref{tab:trainvalres} shows the scene classification results of ResNet18 and VGG11 pipelines on the training/validation split. ResNet18 shows an average improvement of 3.72\% on Top1 and 4.56\% on Top5 accuracies when the LSA embeddings are included in the FC layer in comparison with the baseline \emph{without LSA} features. ResNet18 shows an average improvement of 3.72\% on Top1 and 4.56\% on Top5 accuracies when LSA embeddings are included as compared to the baseline without additional features. Compared to the baseline with the object presence vector, ResNet18 with LSA features shows an improvement of 2.99\% on Top1 and 3.77\% on Top5. VGG11 does not show a significant improvement on any of the baselines. We hypothesize that the information from LSA embeddings is not properly absorbed by the VGG11 network due to the large amount of FC-layers connected at the end of the layer and a poor segmentation associated with a relatively large size average-pool layer compared to ResNet18 \cite{Shen2017DeepAnalysis}. \begin{table*}[!ht] \small \begin{tabular}{|p{1.4cm}|c|p{1cm}|c|c|c|c|c|c|c|c|c|c|} \hline \textbf{Training /validation} & \multicolumn{2}{l|}{\textbf{Without LSA}} & \multicolumn{2}{l|}{\textbf{Object presence}} & \multicolumn{2}{l|}{\textbf{LSA}} & \multicolumn{2}{l|}{\textbf{LSA categories}} & \multicolumn{2}{l|}{\textbf{LSA tf-idf}} & \multicolumn{2}{l|}{\textbf{LSA log}} \\ \cline{ 2 - 13} \multicolumn{ 1}{|l|}{} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} \\ \cline{ 1 - 13} \textbf{VGG11} & 44.56 & 65.34 & 42.88 & 65.88 & 44.65 & 64.41 & 45.34 & 65.11 & 45.07 & 66.12 & 44.79 & 64.33 \\ \cline{ 1- 13} \textbf{ResNet18} & 49.01 & 71.06 & 50.77 & 71.65 & \textbf{53.47} & \textbf{75.45} & 51.06 & \textbf{73.77} & \textbf{52.37} & \textbf{75.88} & 50.35 & \textbf{73.94} \\ \hline \end{tabular} \caption{Training/validation results showing the Top1 and Top5 accuracies for the two baselines: (1) evaluating scene classification with the image data only or \emph{Without LSA}, and (2) using the object presence obtained from a binary \emph{Object Vector} included on the ADE20K API. The evaluations related to the LSA features are (1) using the \emph{LSA} normalized embeddings, (2) using the LSA embeddings obtained from \emph{combining the scene categories}, (3) using the LSA embeddings from the \emph{tf-idf} transform, and (4) the LSA embeddings after the \emph{log} transform. Values in bold are $p<0.001$ comparing the scores with the \emph{without LSA} baseline.} \label{tab:trainvalres} \end{table*} \begin{table*}[!htb] \small \begin{tabular}{|p{1.4cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|p{0.9cm}|} \hline \textbf{5-fold cross-val} & \multicolumn{2}{l|}{\textbf{Without LSA}} & \multicolumn{2}{l|}{\textbf{Object presence}} & \multicolumn{2}{l|}{\textbf{LSA}} & \multicolumn{2}{l|}{\textbf{LSA categories}} & \multicolumn{2}{l|}{\textbf{LSA tf-idf}} & \multicolumn{2}{l|}{\textbf{LSA log}} \\ \cline{ 2 - 13} \multicolumn{ 1}{|l|}{} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} & \textbf{Top1} & \textbf{Top5} \\ \cline{ 1 - 13} \textbf{VGG11} & 40.225$\pm$ 10.553 & 61.346$\pm$ 8.914 & 41.445$\pm$ 9.573 & 61.047$\pm$ 9.657 & 41.112$\pm$ 9.141 & 61.914$\pm$ 9.775 & 41.134$\pm$ 9.256 & 61.331$\pm$ 9.671 & 41.916$\pm$ 9.661 & 62.061$\pm$ 9.814 & 41.618$\pm$ 9.467 & 61.390$\pm$ 9.551 \\ \cline{ 1- 13} \textbf{ResNet18} & 42.556$\pm$ 11.237 & 62.277$\pm$ 10.333 & 42.959$\pm$ 10.111 & 62.691$\pm$ 9.989 & 44.112$\pm$ 9.991 & 63.491$\pm$ 10.143 & 43.562$\pm$ 9.877 & 62.952$\pm$ 10.225 & 44.067$\pm$ 10.023 & 63.001$\pm$ 10.120 & 43.067$\pm$ 9.741 & 62.114$\pm$ 10.342 \\ \hline \end{tabular} \caption{5-fold cross-validation results showing the Top1 and Top5 accuracies. Standard deviations are calculated across the 5 folds.} \label{tab:5fold} \end{table*} Table \ref{tab:5fold} shows the results for the 5-fold cross-validation modality in percentages. No significant improvements are found comparing any performance including LSA information with any performance baseline such as \emph{without LSA} and \emph{Object presence} information. The lack of significant improvement observed on the 5-fold cross-validation might be attributable to a smaller size of the training set in comparison to the training/validation split. We hypothesize that the size of the training set is important for obtaining a significant performance improvement on deep feed-forward networks. However, the information of the LSA embeddings can be properly transferred using the extra FC layers as we report on the Class Activation Map (CAM) analysis. CAM and additional analyses are presented in the supplementary material. \section{Object embeddings from spatial context}\label{sec:spatial_context} \begin{figure*} \centering \includegraphics[width=0.9\textwidth]{spatial_context} \caption{(a) Spatial context is defined as the objects in close proximity to a target object (vase). (b) Automated analysis of spatial context for a dining room image containing 29 objects. The insets show 4 different target objects (red outline) together with their spatial neighbors (green outline). (c) Graph analysis of the object embeddings from the Skipgram model (d=300). Spatially closely related objects such as body parts appear as subclusters within the graph.} \label{fig:spatial_context} \end{figure*} In the Skipgram model in Section \ref{sec:word2vec} the context of scene is defined as all objects occurring within it. While this 'bag-of-objects' approach is successful in creating meaningful scene embeddings, it is unclear whether this is an adequate approach for object embeddings. After all, the arrangement of objects within a scene is not random but follows semantic and syntactic rules, giving rise to hierarchies of objects within images \cite{Vo2019ReadingEnvironments}. Often, these relationships are indexed by spatial proximity. Proximity can be due to functional relatedness (a towel hanging from a towel ring or towel radiator) or object/part relationships (a body consists of different body parts). Our previous quantification of spatial relationships using co-occurrence within images probably lacks the granularity to model such tight-knit relationships. To alleviate this issue, we zoom in on sub-regions within images, and focus on objects and their local neighborhood. In particular, we define as \textit{spatial context} the objects in an image in close proximity to a target object (Fig. \ref{fig:spatial_context}a). Importantly, this allows us to transfer the notion of window size used by context-based methods such as Word2vec to image data. There are different ways to operationalize spatial context (e.g., radius around center, distance from object border). Furthermore, frames of reference can be proximal (image pixel coordinates) or distal (inferred 3D scene coordinates). Here, we perform an image-based (proximal) analysis of spatial context. Since center coordinates are not always meaningful for stuff (e.g. wall) and objects with holes, we consider \textit{distance to object boundary} as a more meaningful distance metric. We parse a total of 604,355 object instances across the ADE20K dataset. For each of the images, a sparse object x object distance matrix is created with up to 345 instances per image. A nonzero entry at position $i, j$ means that objects $i$ and $j$ are in the spatial context of each other. The calculation of the spatial context is based on the segmentation maps, where we use Matlab's \emph{imdilate} function with a 7x7 square-shaped structured element to expand a target object's boundary by 3 px. The dilated target now touches its immediate neighbors (spatial context) whose indices are obtained by intersecting all objects with the target. The distance between target and neighbor is given by the inverse proportion of pixels the dilated target has in common with the neighbor, which implies that distances are not symmetric. For objects that share object-part relationships (e.g. hand and arm) we set the distance to a small nonzero value of $10^{-10}$. Fig. \ref{fig:spatial_context}b shows the effect of such parsing on four objects in a dining room image. To train word embeddings we use these distance matrices with the Word2vec Skipgram model. In contrast to Section \ref{sec:word2vec}, the input to the model is now the target object and the outputs are uniformly sampled objects in the spatial context (positive examples) or outside the context (negative examples). Consequently, we maximize the probabilities \begin{equation}\label{eq:skipgram2} \sum_{o\in O}\sum_{o'\in\text{context}(o)}\log p(o' | o) \end{equation} where context(o) now refers to the local spatial context. In each iteration, 5 positive and 20 negative examples are randomly selected. For objects with less than 5 neighbors, positive examples are repeated. Hyperparameters are the same as before. The two resultant sets of embeddings are averaged. Fig. \ref{fig:spatial_context}c shows a graph analysis of the distance matrix between the embeddings thresholded at a cosine distance of 0.6. There is emergent subclusters with collections of objects that represent close spatial or object/part relationships. Another qualitative analysis is presented in Table \ref{tab:closest_neighbor}. The Skipgram model developed in this section (second column) is contrasted with the Skipgram model in Section \ref{sec:word2vec} based on object co-occurrences in scenes (third column). For the Skipgram model using spatial context, the closest objects for a given target are now indeed objects that are expected in close vicinity to the target. \begin{table} \footnotesize \begin{tabular}{p{1.3cm}|p{2.6cm}|p{2.6cm}} \hline \multirow{2}{1cm}{Target object} & \multicolumn{2}{c}{Closest neighboring objects}\\ & Skipgram with Spatial Context & Skipgram\\ \hline \multirow{3}{1cm}{towel} & towel rack 0.182& countertop 0.238\\ &towel ring 0.211 & screen door 0.259\\ &towel radiator 0.226 &shower 0.268\\ \hline \multirow{3}{1cm}{bicycle} & bicycle rack 0.351 & entrance 0.495\\ &parking meter 0.418 & street sign 0.501\\ & sidewalk 0.418 & stall 0.506\\ \hline \multirow{3}{1cm}{pen} & notepad 0.324 & paintbrush 0.417\\ & stapler 0.427 & sandpit 0.431\\ & paper 0.430 & scotch tape 0.435\\ \hline \end{tabular} \caption{Closest neighbors and cosine distances for different probe objects using Skipgram models (d=100) with spatial context. }\label{tab:closest_neighbor} \end{table} \section{Discussion} Object and scene embeddings derived from object co-occurrences in images yield semantically relevant representations. The embeddings cluster significantly along scene supercategories (indoor, urban, and natural) and subcategories (e.g., workplace, transportation, shopping and dining). This nicely dovetails with the distributional hypothesis which states that scenes are to some extent determined by the collection of objects they contain. The results are robust for a variety of models (LSA, Skipgram, CBOW) and embedding dimensions (d=50, 100, 300). Moreover, when using ADE20K's training/validation split, incorporation of LSA embeddings into a CNN for scene classification yields an improvement of 4.62\% Top5 classification accuracy over a model without object information and 3.77\% over a model that includes a vector of objects present in the scene. This suggests that the low-dimensional representation of object vectors provided by LSA is relevant for scene classification. In Section \ref{sec:spatial_context}, we abandon the 'bag-of-objects' approach in order to generate object embeddings that take spatial context into account. We define spatial context as the set of objects whose boundaries touch the boundary of a target object. Embeddings based on this spatially more sophisticated approach encode meaningful and hierarchical relationships of objects that cannot be achieved with the more coarse-grained analyses. More broadly speaking, there are two principal applications for object/scene embeddings generated with the proposed approaches. First, scene segmentation and analysis is a central problem in robotics \cite{Rangel2016SceneLabeling} which includes finding compact representations of images. In our experiment, embeddings appended to the last layer can improve the performance of a scene classification CNN. In line with our findings, \cite{Chen2019SceneEmbeddings} show that embeddings can refine predictions of a scene classifier. These findings are corroborated by the fact that object detectors emerge in CNNs for scene classification \cite{Zhou2014ObjectCNNs}. Second, in cognitive psychology, vision science, and sensory neuroscience scene perception, analysis, and interpretation is a model case for understanding how the brain represents complex visual information. Similar to embeddings, the human brain builds representation and expectations using image statistics and co-occurrences (both temporal and spatial) \cite{Teufel2020FormsSystem}. Since embeddings quantify object-object, scene-scene, and object-scene distances, they might provide an invaluable resource for studying the brain processes related to high-level image analysis and memory processes. For instance, object-scene pairs have been used as stimulus material in cued memory recall experiments (e.g. \cite{Treder2020TheMemory}), and embeddings might both explain some variability observed for different object-scene combinations and guide the selection of stimulus material. Another area, where image-based embeddings could provide an important tool, are the brain mechanisms underlying information sampling via eye-movements. For instance, it is well-established that semantic object-scene relationships have an important influence on oculomotor control in humans. Distances derived from image-based embeddings might provide a means to characterize these effects in detail, a possibility that current state-of-the-art models of oculomotor control fail to provide \cite{Pedziwiatr2019MeaningFixations}. There are several limitations that warrant consideration. A possible critique of our first approach is that the information relating scenes to objects is already contained in the object-scene co-occurrence matrix. This is, of course, trivially true, since the embeddings are directly built from the co-occurrences. However, we show that embeddings are able to represent this information in a lower dimensional space which is not only spatially more efficient but can also have a regularizing or denoising function \cite{Deerwester1990IndexingAnalysis}. A related limitation is the fact that our scene classifier relies on object annotations which are not available in many datasets. However, \cite{Chen2019SceneEmbeddings} show that such annotations can be generated on the fly using CNNs for object detection and segmentation. Consequently, a viable approach could be to train the embeddings on annotated data and then deploy them on a system that self-generates annotations. Lastly, our analysis of spatial context is a proof-of-concept case, rather than a rigorous quantitative investigation. Yet, the initial findings point towards several avenues for future research. First, a relevant question is whether spatial context is better defined based on proximal (image-based) or distal (3D-scene based) coordinates. The latter requires inferred 3D coordinates which can be derived from image reconstruction techniques that infer depth metrics \cite{Wu2016LearningModeling}. Second, it is conceivable that some scene categories differ not so much by the collection of objects they contain but rather by the spatial relationships between the objects. In such a case, incorporating local spatial context might be critical for good performance. Merging our approaches in sections \ref{sec:scene_embeddings} and \ref{sec:spatial_context} might be a way to address this. In conclusion, we show that object and scene embeddings can be created from object co-occurrences and modeling of local spatial context. These embeddings are both semantically meaningful and computationally useful for downstream applications such as scene classification.
{'timestamp': '2020-09-22T02:15:07', 'yymm': '2009', 'arxiv_id': '2009.09384', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09384'}
arxiv
\section{Introduction} \label{sec:intro} \par In recent years there has been a growing demand for casual photography and video conferencing using hand-held devices, especially in smartphones. To address such demands various imaging systems were introduced such as pop-up cameras, punch-hole cameras etc. Under-display camera (UDC) is such a digital data acquisition technique or an imaging system that is a by-product of the growing demand and greater hunger for new technologies. UDC is an imaging system in which a display screen is mounted atop the lens of a conventional digital camera. The major attraction of a UDC device is that the highest possible display-to-body ratio can be realized with a bezel-free design. UDC devices can provide a seamless digital experience through perfect gaze tracking in teleconferences. Leading smartphone makers like OPPO and XIAOMI have already developed and integrated under-display camera technology into some of their flagship products. \par The quality of a UDC image is poor due to severe degradation resulting from diffraction and low light transmission. Under-display camera image restoration is relatively a new task for the computer vision community since the technology is new. However, it has a high correlation with many image restoration tasks such as image denoising, deblurring, dehazing and low light image enhancement. The degradations in UDC images can be considered as a combination of degradations addressed in such restoration problems. \par Two different techniques are predominantly used for display purpose in a UDC device. They are transparent organic light emitting diode (T-OLED) and the pentile organic light emitting diode (P-OLED). The type of degradation is different in either of these technologies. The major degradations in T-OLED are blur and noise while in P-OLED they are color shift, low light and noise \cite{udc_paper}. Fig.\ref{fig:degradations} shows degraded images taken using P-OLED and T-OLED UDC cameras. The clean image taken without mounting a display screen is also depicted for reference. \begin{figure} \centering \includegraphics[scale=0.35]{images/intro/intro_pic_new.png} \caption{ (a) Original image without display screen (b) degraded image with P-OLED screen mounted on the camera (c) degraded image when using T-OLED screen.} \label{fig:degradations} \end{figure} \par This work addresses the restoration of under-display camera images taken with P-OLED and T-OLED configurations. Recently, deep convolutional neural network based techniques have proven to be effective for most image restoration tasks. Two methods are proposed in this work to address the restoration of under-display camera images. The first method employs a pyramidal dilated convolution block within a wavelet decomposed convolutional neural network for the restoration of P-OLED degraded images. The second method integrates a discrete cosine transform (DCT) based dual domain sub-net within a fully convolutional encoder-decoder architecture and performs well on T-OLED degraded images. The first method is a state-of-the-art that won the first position in the European Conference on Computer Vision (ECCV) 2020 challenge on image restoration for Under-display Camera - Track 2 - P-OLED \cite{udc_methods} organized in conjunction with RLQ-TOD workshop. The second method achieved $4^{th}$ position in Track -1 - T-OLED in the same challenge and has comparable performance with the winning methodology in that challenge track. The main contributions of the proposed work are : \renewcommand{\labelitemi}{\textbullet} \begin{itemize} \item A pyramidal dilated convolutional block has been integrated into a wavelet decomposed encoder-decoder network for state-of-the-art restoration results on P-OLED under-display camera images. \item An encoder-decoder network with DCT based dual domain sub-net has been developed to address T-OLED under-display camera image restoration. \end{itemize} Rest of the paper is organized as follows : in Section \ref{sec:related_wok} we review related works and in Section \ref{sec:proposed_method} we describe the two methodologies that we propose for UDC image restoration. Section \ref{sec:experiments} details our experiments and in Section \ref{sec:result_analysis} we present our result analysis. Finally, Section \ref{sec:conclusions} concludes the work. \section{Related Work} \label{sec:related_wok} \par Degradation caused by the under-display camera has a significant correlation with other image degradations like real noise, blur and underexposure in images. Recently, learning based methods have brought a significant improvement in low level vision tasks like super-resolution \cite{SRGAN,EDSR}, deblurring \cite{vstack}, denoising \cite{denoising_1} etc, and have produced promising results. A collection of state of the art deep learning techniques on super-resulution and deblurring can be found in \cite{ntire2020_sr} and \cite{ntire2020_deblur} respectively. \par Zhou \textit{et al. } \cite{udc_paper} described the degradation caused by UDC with P-OLED screens as a combination of low-light, color shift and noise. To the best of our knowledge their work was the first intensive study on under-display camera image restoration problem. In their work, they proposed a novel Monitor-Camera Imaging System (MCIS) for paired data acquisition for studying UDC problem. They demonstrated a data synthesizing pipeline for generating UDC images from natural images using only the camera measurements and display pattern. Additionally, they proposed a dual encoder variant of UNet\cite{unet} to restore the under-display camera images they generated using the proposed data pipeline. \par Extensive works have been done in tasks like low-light enhancement and denoising using deep learning techniques. Earlier such tasks were addressed using synthetic data generated using Additive White Gaussian Noise (AWGN) to develop training set for deep learning based networks. The DnCNN\cite{denoising_paper_zang} network proposed by Zang \textit{et al. } performs denoising on noisy images of unknown noise levels. This network follows a modified VGG19\cite{vgg19} architecture. Recently, there is a shift in the dataset used for training deep learning models. Datasets containing images pairs of original image and images with natural degradation are becoming more relevant. Abdelhamed \textit{et al. } \cite{denoising_data} proposed novel smartphone image denoising dataset (SIDD) containing images with real noise in smartphone images. Several denoising methods like WNNM \cite{WNNM} and DnCNN \cite{denoising_paper_zang} were benchmarked based on this dataset. Kim \textit{et al. } \cite{Kim_2020_CVPR} proposed a network that uses adaptive instance normalisation (AIN) to learn a denoiser for real noisy images from the models trained on synthetic training pair. Their network has better generalisation and has produced state-of-the-art results on Darmstadt Noise Dataset (DND) which contains real noisy images. \par \par Liu \textit{et al. } \cite{mwcnn} proposed a multi-level Wavelet-CNN (MWCNN) for general image restoration tasks. MWCNN follows an encoder-decoder architecture and uses wavelet decomposition for a computationally efficient network for subsampling. In their work, they demonstrated the effectiveness of their method for denoising and super-resolution. The winning team of CVPR NTIRE 2020 Challenge on single image demoireing \cite{ntire2020_demoire} used a wavelet decomposed network similar to MWCNN and achieved state-of-the-art results. \par Zhang \textit{et al. } \cite{dmcnn} proposed the use of dilated convolutions for removing compression artifacts from images. In their work, diverse dilation rates were used, with which they reached a receptive field of up to $145 \times 145$. Their theory of receptive field was adopted by Zheng \textit{et al. } \cite{idcn} wherein they used a pyramidal dilated convolution structure and implicit domain transform to remove compression artifacts. In their work, the dilation rate was gradually increased along with the dilated convolution stack and proved the effectiveness of dilated convolution in removing artifacts with a wide spatial range. In this work to restore P-OLED degraded images, we propose a fully convolutional network with wavelet decomposition namely Pyramidal Dilated Convolutional RestoreNet (PDCRN) inspired by MWCNN \cite{mwcnn}. Here, the feature extraction in the encoder and decoder levels has been improved by integrating the pyramidal dilated convolution blocks. A different approach was followed to address restoration of T-OLED degraded images wherein, a discrete cosine transform (DCT) based dual domain CNN was employed. \section{Proposed Methods} \label{sec:proposed_method} In this section, we describe the two different networks that we propose for the restoration of under-display camera images. Section \ref{sec:proposed_method_poled} details the solution for P-OLED while Section \ref{sec:proposed_method_toled} details the solution for T-OLED images. Although both networks follow a fully convolutional encoder-decoder architecture, the encoder and decoder sub-nets are different in either case. \subsection{Restoring P-OLED Degraded Images} \label{sec:proposed_method_poled} The proposed Pyramidal Dilated Convolutional RestoreNet (PDCRN) has a fully convolutional encoder-decoder architecture similar to a UNet \cite{unet} as shown in Fig. \ref{fig:poled_architecture}. There are three different operation levels in terms of the spatial resolution of the features being processed. The major degradations in a P-OLED under-display camera image are low light, color shift and noise as mentioned earlier. The task of the encoder is to extract the image features including contrast, semantic information and illumination from the degraded image. The decoder then uses this information to predict the clean image that mimics the one taken without a display screen mounted on the lens. \begin{figure}[h!] \centering \includegraphics[scale =0.12]{images/proposed_method/poled_new.jpg} \caption{Proposed PDCRN architecture. The network has an encoder and a decoder sub-net as shown in the figure. The network uses PDCB for efficient feature extraction.} \label{fig:poled_architecture} \end{figure} \begin{figure}[h!] \centering \includegraphics[scale =0.08]{images/proposed_method/dense_new.jpg} \caption{The PDCB sub-net used in PDCRN. The block has a series of densely connected convolutional layers with varying dilation rates for feature extraction.} \label{fig:pdcb} \end{figure} \subsubsection{PDCRN Encoder} \par In the encoder section, the input image is processed at $3$ different spatial scales obtained by progressively downsampling the inputs from the previous blocks. At the initial spatial scales of the encoder, the features such as colour distribution, brightness are captured. As encoder progress to smaller spatial scales, higher frequency details like texture, edges etc are learned from the image. The initial downsampling is done using discrete wavelet transform (DWT) based on Haar wavelet as it envelops a larger receptive field which in turn helps in acquiring maximum spatial information from the input image. The downsampling in the subsequent layers is done using strided convolutions as it is empirically found to be more effective than using DWT based downsampling along the whole of encoder. At each level in the encoder, a pyramidal dilated convolution block (PDCB) is used for efficient feature extraction. A detailed description of PDCB is discussed later. \subsubsection{PDCRN Decoder} \par The decoder section consists of a series of upsampling operations with PDCB blocks in between to learn the representation of the upscaled image. The decoder progressively upsamples the feature maps from the encoder with $3$ levels of upsampling until the required spatial resolution is reached. The first two upsampling processes are done using transposed convolutions and inverse discrete wavelet transform (IDWT) is used to upsample the image to the original resolution. To make the training process more efficient space-to-depth and depth-to-space\cite{depth_to_space} blocks are used at both ends of the network. \subsubsection{Pyramidal Dilated Convolutional Block (PDCB)} \label{subsec:pdcb} \par To capture the degradations that have wide spatial extension, convolutional filters of large receptive field is necessary. But this would potentially increase the network complexity and will require a huge dataset to avoid the risk of overfitting. Another solution is to have a sequence of convolutional layers with low filter size which effectively provide a larger receptive field with lower learnable parameters. However, this would also increase the number of trainable parameters and may lead to vanishing gradient problem for deep networks. Dilated convolutions with large dilation factors can overcome these limitations. However, large dilation rates may lead to information loss as the aggregated features in two adjacent pixels come from completely non-overlapping input feature set \cite{mwcnn}. Additionally, these may lead to gridding effect in the reconstructed images. To tackle this problem, a pyramidal dilated convolutional block (PDCB) is used for feature extraction in each encoder and decoder levels. \par PDCB is a residual densely \cite{densenet} connected convolutional network having varying dilatation rates in different convolution layers as shown in Fig.\ref{fig:pdcb}. The block is said to be pyramidal because the dilation rate used in the convolution layers is progressively reduced within the block in which the layers are stacked. Each convolutional layer in the block receives the activation outputs of every preceding convolutional layer as well as the input to the block. At the bottom of the pyramid, the information from far away pixels can be aggregated by using a high dilation rate. The information leakage that occurs with the highly dilated convolution is captured in the top of the pyramid. Thus the network achieves a large receptive field without information loss. The proposed PDCRN produced excellent results for P-OLED degraded images and the same network was also employed for the restoration of T-OLED degraded images and achieved considerable performance. To further improve the performance for T-OLED images, the network was modified using a dual domain approach with implicit Discrete Cosine Transform (DCT) and obtained superior results for T-OLED compared to PDCRN. This network is explained in detail in the next section. \subsection{ Restoring T-OLED Degraded Images} \label{sec:proposed_method_toled} In a T-OLED display, the size of horizontal gratings or openings for light transmission have a size comparable to visible light wavelength \cite{udc_paper}. Due to this, the light is heavily spread in the horizontal axis and results in blurry images. Thus the restoration of T-OLED degraded images is majorly a deblurring problem for horizontal distortion apart from removing the added noise during the acquisition process. \begin{figure}[h!] \centering \includegraphics[scale =0.19]{images/proposed_method/toled_final.jpg} \caption{Modified PDCRN architecture with dual domain block (DDB) for T-OLED degraded image restoration. } \label{fig:toled_archi} \end{figure} The modified PDCRN with dual domain block also follows an encoder-decoder architecture that process the image features at $3$ different scales. The architecture of the modified PDCRN is depicted in Fig. \ref{fig:toled_archi}. Each encoder and decoder level in the network uses a dual domain block with implicit DCT inspired from Implicit Dual-domain Convolutional Network (IDCN) proposed by Zheng \textit{et al. } \cite{idcn}. IDCN was introduced for restoration of compressed images. This restoration involves correction of details in the high frequency band and removal of distortion artifacts. In a T-OLED degraded image, the restoration task is to remove the horizontally spread blur distortion. since the blur leads to smoothening of edges and other sharp details, the correction is to be done in the mid and high frequency bands. Due to this reason, the IDCN methodology was adopted and improved in this work. \begin{figure}[h!] \centering \includegraphics[scale =0.19]{images/proposed_method/DDB.jpg} \caption{Expansion of the dual domain block in modified PDCRN} \label{fig:DDB} \end{figure} \subsubsection{Dual Domain Block} Here we use a simplified version of the IDCN proposed in Zheng \textit{et al. } \cite{idcn}. In this block, the image features are processed in the pixel domain using convolution layers and in the frequency domain using implicit discrete cosine transform (DCT). The DCT domain branch in the dual domain block takes the feature inputs and convert them into the DCT domain using a quantization rectified unit (QRU) and an implicit translation unit (ITU). The QRU thresholds the feature values into a range of $-0.5$ to $+0.5$. This output is given as the input to the ITU where the quantized DCT coefficients of the feature maps are obtained. The DCT domain features are then fused with the pixel domain features obtained from the parallel pixel domain branch as shown in Fig.\ref{fig:DDB}. Thus the dual domain approach performs efficient feature corrections fusing the multiple domain features. The major task of this network is to make corrections in the mid and high frequency details of the image. When DCT is applied to the features from PDCB, the correction in the subsequent layers are happening in frequency domain. This correction will aid the network in learning the edges and other sharp details of the ground truth. \subsection{Loss Function} The network is trained based on mean squared error (MSE) and the MSE loss is the mean squared error between the ground-truth and the predicted images. It is incorporated to generate high fidelity images and is formulated as : \begin{equation} L_{MSE} = \frac{1}{W\times H\times C} \sum_{i=0}^{W-1}\sum_{j=0}^{H-1}\sum_{k=0}^{C-1} (Y_{i,j,k} - \hat{Y}_{i,j,k})^2 \label{eq:mse_loss} \end{equation} where, $W$, $H$ and $C$ are the width, height and number of channels of the output, $Y$ is the ground truth image and $\hat{Y}$ is the predicted image. \section{Experiments} \label{sec:experiments} \subsection{Dataset} The dataset used in the experiments is the challenge dataset provided by the organizers of RLQ-TOD workshop 2020 for the image restoration for Under-display Camera - Track 1 - T-OLED and Track 2- P-OLED. Both the datasets contains $240$ pairs of degraded under-display camera images and their corresponding ground truth images for training, $30$ pairs for validation and $30$ pairs for testing. Each image is of resolution $1024\times2048\times3$. \subsection{Training} The PDCRN network was trained with images of a patch size of $1024\times2048\times3$ and batch size of $12$. For T-OLED, the images were trained with patch size of $256\times256\times3$ and batch size of $16$. Adam optimizer with $\beta_1=0.9$ , $\beta_2=0.99$ and learning rate $2e^{-4}$ was used in both the networks. The learning rate is decayed after every $10000$ epoch with a decay rate of $0.5$ in both networks. The networks were trained for a total of $30000$ epochs using Tesla V100 GPU card with 32 Gib memory. The training loss and accuracy plots of PDCRN and dual domain PDCRN are depicted in Fig. \ref{fig:loss_plot} and Fig. \ref{fig:accuracy_plot} respectively. \begin{figure}[htbp!] \centering \newcommand\x{0.49} \newcommand\scale{0.35} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/Ablation_study/poled_loss.jpg} \fontsize{8}{12pt}\selectfont (a) \end{center} \end{minipage} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/Ablation_study/toled_loss.jpg} \fontsize{8}{12pt}\selectfont (b) \end{center} \end{minipage} \caption{Training loss plot of (a) PDCRN for P-OLED (b) PDCRN with dual domain block for T-OLED. The spikes in loss function resulted from discontinuous training.} \label{fig:loss_plot} \end{figure} \begin{figure}[htbp!] \centering \newcommand\x{0.49} \newcommand\scale{0.35} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/Ablation_study/poled_psnr.jpg} \fontsize{8}{12pt}\selectfont (a) \end{center} \end{minipage} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/Ablation_study/toled_psnr.jpg} \fontsize{8}{12pt}\selectfont (b) \end{center} \end{minipage} \caption{Accuracy plot of (a) PDCRN for P-OLED (b) PDCRN with dual domain block for T-OLED. The accuracy plot in (a) is not smooth due to discontinuous training. The accuracy plot in (b) is high in initial epochs because of a high learning rate.} \label{fig:accuracy_plot} \end{figure} \subsection{Evaluation Metrics} To evaluate the performance of the methodology, the evaluation metric used is the peak signal to noise ratio (PSNR) and structural similarity (SSIM). \subsection{Ablation Study for PDCRN} The Fig.\ref{fig:ablation study} shows the accuracy and loss curves generated that shows the effectiveness of various components of the proposed network. The accuracy plot is generated based on the PSNR metric in every epoch of training and loss plot is based on MSE loss of every mini-batch of training. For standardisation, all the networks were trained up to $3500$ epochs were the plots reaching a comparative saturation. From the accuracy plots, we can understand that network without pyramid dilation and DWT performed the worse, attaining a PSNR of $30.81$ dB. The introduction of dilated convolutions in the pixel domain improved the results to $31 $ dB. The network of the proposed method obtained best PSNR of $30.25$ dB out of all. So with the addition of both DWT and pyramid dilation, there was performance gain of $0.5$ dB when compared to network with a no dilation and DWT. Loss plot doesn't give much insights into the performance comparison. \begin{figure}[h!] \centering \newcommand\x{0.45} \newcommand\scale{0.4} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/Ablation_study/Ablation_accuracy.png} \vskip 2pt \fontsize{9}{12pt}\selectfont (a) Accuracy plots. \end{center} \end{minipage} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/Ablation_study/Ablation_loss.png} \vskip 2pt \fontsize{9}{12pt}\selectfont (b) Loss plots. \end{center} \end{minipage} \caption{Study of the effects of various components of the proposed PDCRN on accuracy in Fig.(a) and mean squared error(MSE) loss in Fig.(b)} \label{fig:ablation study} \end{figure} \section{Result Analysis} \label{sec:result_analysis} \par The Fig. \ref{fig:poled sample results} and \ref{fig:Toled sample results} shows six sets of examples for P-OLED and T-OLED degraded image restoration. The proposed PDCRN was able to attain superior results in PSNR scores and from the visual comparison shows the high fidelity of the restored images with the ground truth. Similarly, the modified version of PDCRN with dual domain network also achieves high perceptual quality and fidelity scores for restored images degraded by T-OLED display. Two different networks have been proposed in this work to address the restoration of two types of under-display camera images. The PDCRN proposed for P-OLED image restoration was the winning entry in European conference on computer vision (ECCV) 2020 challenge on image restoration for Under-display Camera - Track 2 - P-OLED organized in conjunction with RLQ-TOD workshop. \par Table \ref{tab:table_poled} shows the performance comparison based on PSNR and SSIM of the proposed PDCRN with other competing entries in the challenge. It is evident from the table that the proposed PDCRN outperforms other methods by a considerable margin which proves its effectiveness. Similarly, PDCRN with dual domain network was a competing entry in Track -1 - T-OLED of the challenge. The modified PDCRN was able to achieve $4^{th}$ position in the final ranking and obtained comparable results only with a margin of $0.4$ dB with the challenge winners in terms of PSNR and SSIM as depicted in Table \ref{tab:table_toled}. \begin{figure}[htbp!] \centering \newcommand\x{0.3} \newcommand\scale{0.050} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/results/POLED_JPG/in21.jpg} \fontsize{8}{12pt}\selectfont PSNR-$13.33dB$/SSIM-$0.63$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/in13.jpg} \fontsize{8}{12pt}\selectfont PSNR-$20.77dB$/SSIM-$0.75$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/in2.jpg} \fontsize{8}{12pt}\selectfont PSNR-$11.38dB$/SSIM-$0.58$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/in17.jpg} \fontsize{8}{12pt}\selectfont PSNR-$15.64dB$/SSIM-$0.66$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/in28.jpg} \fontsize{8}{12pt}\selectfont PSNR-$9.86dB$/SSIM-$0.58$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/in6.jpg} \fontsize{8}{12pt}\selectfont PSNR-$10.38dB$/SSIM-$0.54$ \vskip 2pt \fontsize{9}{12pt}\selectfont (a) Input \end{center} \end{minipage} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/results/POLED_JPG/out21.jpg} \fontsize{8}{12pt}\selectfont PSNR-$32.67 dB$/SSIM-$0.89$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/out13.jpg} \fontsize{8}{12pt}\selectfont PSNR-$35.65 dB$/SSIM-$0.95$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/out2.jpg} \fontsize{8}{12pt}\selectfont PSNR-$33.26 dB$/SSIM-$0.93$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/out17.jpg} \fontsize{8}{12pt}\selectfont PSNR-$37.85 dB$/SSIM-$0.98$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/out28.jpg} \fontsize{8}{12pt}\selectfont PSNR-$35.06 dB$/SSIM-$0.96$ \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/out6.jpg} \fontsize{8}{12pt}\selectfont PSNR-$31.03 dB$/SSIM-$0.91$ \vskip 2pt \fontsize{9}{12pt}\selectfont (b) Ours \end{center} \end{minipage} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/results/POLED_JPG/21.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/13.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/2.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/17.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/28.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/POLED_JPG/6.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \fontsize{9}{12pt}\selectfont (c) Ground truth \end{center} \end{minipage} \caption{Sample results of the proposed PDCRN for (a). P-OLED degraded images, (b). images restored using PDCRN shows high fidelity with (c). the ground-truth captured without mounting any display.} \label{fig:poled sample results} \end{figure} \begin{figure} \centering \newcommand\x{0.3} \newcommand\scale{0.050} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/results/TOLED_JPG/in19.jpg} \fontsize{8}{12pt}\selectfont PSNR-$27.55dB$/SSIM-$0.77$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/in27.jpg} \fontsize{8}{12pt}\selectfont PSNR-$29.43dB$/SSIM-$0.84$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/in29.jpg} \fontsize{8}{12pt}\selectfont PSNR-$28.05dB$/SSIM-$0.77$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/in9.jpg} \fontsize{8}{12pt}\selectfont PSNR-$21.87dB$/SSIM-$0.68$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/in25.jpg} \fontsize{8}{12pt}\selectfont PSNR-$29.69dB$/SSIM-$0.87$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/in15.jpg} \fontsize{8}{12pt}\selectfont PSNR-$31.27dB$/SSIM-$0.88$ \vskip 2pt \fontsize{9}{12pt}\selectfont (a) Input \end{center} \end{minipage} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/results/TOLED_JPG/out19.jpg} \fontsize{8}{12pt}\selectfont PSNR-$34.33 dB$/SSIM-$0.91$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/out27.jpg} \fontsize{8}{12pt}\selectfont PSNR-$38.17 dB$/SSIM-$0.96$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/out29.jpg} \fontsize{8}{12pt}\selectfont PSNR-$35.12 dB$/SSIM-$0.93$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/out9.jpg} \fontsize{8}{12pt}\selectfont PSNR-$32.32 dB$/SSIM-$0.93$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/out25.jpg} \fontsize{8}{12pt}\selectfont PSNR-$38.4 dB$/SSIM-$0.95$ \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/out15.jpg} \fontsize{8}{12pt}\selectfont PSNR-$38.68 dB$/SSIM-$0.96$ \vskip 2pt \fontsize{9}{12pt}\selectfont (b) Ours \end{center} \end{minipage} \begin{minipage}{\x\linewidth} \begin{center} \includegraphics[scale=\scale]{images/results/TOLED_JPG/19.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/27.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/29.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/9.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/25.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \includegraphics[scale=\scale]{images/results/TOLED_JPG/15.jpg} \fontsize{8}{12pt}\selectfont {\color{white} PSNR-$\infty dB$/SSIM-$1$} \vskip 2pt \fontsize{9}{12pt}\selectfont (c) Ground truth \end{center} \end{minipage} \caption{Sample results of the modified PDCRN with DDB for (a). T-OLED degraded images, (b). images restored using the network shows high fidelity with (c). the ground-truth captured without mounting any display.} \label{fig:Toled sample results} \end{figure} \begin{table}[] \centering \caption{Comparative study of the results from P-OLED track under UDC challenge in RLQ-TOD'20 workshop, ECCV-2020} \label{tab:table_poled} \resizebox{\textwidth}{!}{% \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|} \hline Teams & \textbf{Ours} & Team 1 & Team 2 & Team 3 & Team 4 & Team 5 & Team 6 & Team 7 & Team 8 \\ \hline \textbf{PSNR} & \textbf{32.99(1)} & 32.29(2) & 31.39(3) & 30.89(4) & 29.38(5) & 28.61(6) & 26.6(7) & 25.72(8) & 25.46(9) \\ \hline SSIM & \textbf{0.9578(1)} & 0.9509(2) & 0.9506(3) & 0.9469(5) & 0.9249(6) & 0.9489(4) & 0.9161(7) & 0.9027(8) & 0.9015(9) \\ \hline \end{tabular}% } \end{table} \begin{table}[] \centering \caption{Comparative study of the results from T-OLED track under UDC challenge in RLQ-TOD'20 workshop, ECCV-2020} \label{tab:table_toled} \resizebox{\textwidth}{!}{% \begin{tabular}{|c|c|c|c|c|c|c|c|c|} \hline Teams & \textbf{Ours} & Team 1 & Team 2 & Team 3 & Team 4 & Team 5 & Team 6 & Team 7 \\ \hline \textbf{PSNR} & \textbf{37.83 (4)} & 38.23 (1) & 38.18 (2) & 38.13 (3) & 36.91 (5) & 36.72 (6) & 34.35 (7) & 33.78 (8) \\ \hline SSIM & \textbf{0.9783(4)} & 0.9803 (1) & 0.9796 (2) & 0.9797 (3) & 0.9734(6) & 0.9776 (5) & 0.9645 (7) & 0.9324 (8) \\ \hline \end{tabular}% } \end{table} \pagebreak \section{Conclusions} \label{sec:conclusions} In this paper, we proposed two different fully convolutional networks for the restoration of images degraded due to under-display imaging. Pyramidal Dilated Convolutional RestoreNet proposed for pentile-organic LED images has obtained state-of-the-art restoration performance in terms of standard evaluation metrics PSNR and SSIM. The network proposed for transparent-organic LED based imaging used a dual domain approach with implicit DCT and obtained considerable performance when compared with state-of-the-art methodologies. An intensive study may be conducted to devise a methodology that can generalize both P-OLED and T-OLED degradations equally well. \section{Acknowledgements} \label{sec:Acknowledgements} We gratefully acknowledge the support of NVIDIA PSG Cluster and Trivandrum Engineering Science and Technology Research Park (TrEST) with the donation of the Tesla V100 GPUs used for this research. \clearpage \bibliographystyle{splncs04}
{'timestamp': '2020-09-22T02:15:31', 'yymm': '2009', 'arxiv_id': '2009.09393', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09393'}
arxiv
\section*{Appendix} \noindent\textbf{Comparison of different methods on CIFAR10} \begin{table}[!htbp] \small \centering \begin{tabular}{@{}lll@{}} \toprule \multicolumn{1}{c}{} & \multicolumn{1}{c}{ResNet18} & \multicolumn{1}{c}{VGG16} \\ \midrule Label Smoothing & 95.1 $\pm$ 0.3 & 94.2 $\pm$ 0.3 \\ Confidence Penalty & 95.2 $\pm$ 0.1 & 94.0 $\pm$ 0.2 \\\midrule Ours (Class) & 95.2 $\pm$ 0.1 \comment{z6evrs493t zec43tsuj9 8by6q24ga8} & 94.1 $\pm$ 0.1 \comment{adu6wntpt4 4y88ikyn9n bzgd33nnys} \\ Ours (Instance) & \textbf{95.3 $\pm$ 0.1} \comment{mvxfv33ij4 gqkac9zqa7 qb3q3qepxj} & \textbf{94.3 $\pm$ 0.1} \comment{hkdpb7fftk gzd442byam v84hf6e6df} \\ \bottomrule \end{tabular} \caption{On CIFAR10, our method of learning dynamic soft labels is comparable to common methods that use fixed labels} \label{tab:baseline_results} \end{table} \noindent\textbf{Hyperparameters for CNN architectures} \begin{table}[!htbp] \small \centering \begin{tabular}{@{}llll@{}} \toprule & ResNet18 & VGG16 & WRN28-10 \\ \midrule Learning rate & 0.4 & 0.6 & 0.5 \\ Weight decay & 1e-3 & 5e-3 & 1e-3 \\ Epochs & 165 & 300 & 120 \\ \bottomrule \end{tabular} \caption{Hyperparameter setting for CNN architectures. We do not use dropout.} \end{table} \noindent\textbf{Hyperparameters for dynamic soft labels } The hyperprameters are tuned on a single cross validation fold using 20\% training data as held-out data. For class labels, we use a learning rate search grid of [1e-2, 3e-2, 1e-1, 3e-1, 1, 3]. For instance labels, we use a learning rate search grid of [5, 10, 25, 50, 75, 100]. For initialization of soft labels, we use a search grid of [0.3, 0.5, 0.7, 0.9] for both, class and instance labels. This initialization value is used to initialize the target class probability. The non-target class is initialized with a uniform distribution using the remaining probability. \newpage \subsection{Implementation details} To show the general applicability of our method, we evaluate our method on the CIFAR100 and CIFAR10 datasets \cite{Krizhevsky09learningmultiple} using multiple architectures viz. WideResNet (WRN) \cite{BMVC2016_87}, VGG16 \cite{simonyan2014very}, ResNet18 \cite{he2016deep}, and AlexNet \cite{krizhevsky2012imagenet}. Both datasets contain 50,000 images in the training set, and 10,000 images in the test set. Each image in CIFAR100 belongs to one of 100 classes, and each image in CIFAR10 belongs to one of 10 classes. We use 20\% of the training set as common held-out data for both validation set (tune hyper parameters) and meta set. The class and instance labels are optimized using a \textit{5}-fold cross validation approach. The final performance is reported on the full training data by averaging the learned dynamic labels across each fold. The label parameters do not change the overhead at inference, as they are only present during training. Unless stated otherwise, the following hyper-parameters are used for our meta-learning approach. Batch size for training and meta set is fixed to 128 and 256. We use separate optimizers for learning soft labels and model parameters, and both are optimized using stochastic gradient decent (SGD). For class labels, we ensure a valid probability distribution by clamping the smoothing parameters between 0 and 1. For instance labels, we use the softmax function to ensure a probability distribution over all classes. We search in the range of \{0.3, 0.5, 0.7, 0.9\} for initializing the target classes for soft label parameters. The remaining probability mass is used to uniformly initialize the non target classes. We search in the range of \{25, 50, 75, 100, 150, 200\} for the learning rate of soft label parameters. These parameters do not use any learning rate schedule. For all experiments, we report the mean and standard deviation over 3 runs. \subsection{Image classification in supervised setting} In this section we demonstrate the efficacy of our method when applied to the task of image classification in the supervised setting. We evaluate our framework on CIFAR100 and CIFAR10 dataset using ResNet18 \cite{he2016deep} and VGG16 \cite{simonyan2014very} architectures, and compare it with baseline which uses fixed one-hot labels. As shown in Table \ref{tab:baseline_results}, learning class labels on CIFAR100 improves over baseline by 1.8\% and 0.4\% for ResNet18 and VGG16, respectively. Learning instance labels lead to a gain of 2.1\% and 0.8\% for ResNet18 and VGG16, respectively. This result supports our hypothesis: instance labels relax the uniform prior over non-target classes, giving it an advantage to account for instance specific features. The gains over baseline are higher in ResNet18 compared to VGG16. We attribute this to ResNet18 being more prone to overfitting, and thereby benefiting more from dynamic regularization of soft labels. On CIFAR10, similar to CIFAR100, we improve over baseline. However, there are fewer, but more distinct classes, and so the gains are diminished. \begin{table}[!htbp] \small \centering \begin{tabular}{@{}lll|ll@{}} \toprule & \multicolumn{2}{c|}{{CIFAR100}} & \multicolumn{2}{c}{CIFAR10} \\ \multicolumn{1}{c}{} & \multicolumn{1}{c}{ResNet18} & \multicolumn{1}{c|}{VGG16} & \multicolumn{1}{c}{ResNet18} & \multicolumn{1}{c}{VGG16} \\ \midrule Baseline & 77.1 $\pm$ 0.3 \comment{99q3tvy7m5 } & 74.5 $\pm$ 0.2 \comment{bsuahv3q2j} & 95.0 $\pm$ 0.1 \comment{y85pqbdatd} & 93.9 $\pm$ 0.0 \comment{h6vt8f84ka} \\ \midrule Ours (Class) & 78.8 $\pm$ 0.2 \comment{jpw74pwrtn hqirpz5w3e 56py2frtgz } & 74.9 $\pm$ 0.2 \comment{ymwcgavkr9 dvakzbp4y5 fjnfxsrd5s} & 95.2 $\pm$ 0.1 \comment{z6evrs493t zec43tsuj9 8by6q24ga8} & 94.1 $\pm$ 0.1 \comment{adu6wntpt4 4y88ikyn9n bzgd33nnys} \\ Ours (Instance) & \textbf{79.2 $\pm$ 0.2} \comment{S2 7zww5zc8bi S3 c9w2rags7c S1 ifxp44k6sq} & \textbf{75.3 $\pm$ 0.3} \comment{3acmxmvd8b S2 d5dgdh9fbb S1 igfz37r7xq} & \textbf{95.3 $\pm$ 0.1} \comment{mvxfv33ij4 gqkac9zqa7 qb3q3qepxj} & \textbf{94.3 $\pm$ 0.1} \comment{hkdpb7fftk gzd442byam v84hf6e6df} \\ \bottomrule \end{tabular} \caption{Our method of learning dynamic labels achieves consistent gains over baseline.} \label{tab:baseline_results} \end{table} \begin{wrapfigure}{r}{0.40\columnwidth} \centering \resizebox{0.40\columnwidth}{!}{ \begin{tabular}{@{}lll@{}} \toprule & ResNet18 & VGG16 \\ \midrule Baseline & 77.1 $\pm$ 0.3 \comment{99q3tvy7m5 } & 74.5 $\pm$ 0.2 \comment{bsuahv3q2j} \\ Confidence Penalty \cite{pereyra2017regularizing} & 77.6 $\pm$ 0.3 \comment{yjudze937b} & \comment{e4ypv7zkdu} 74.1 $\pm$ 0.1 \\ Label Smoothing \cite{szegedy2015rethinking} & 78.4 $\pm$ 0.2 \comment{33gp54sr68} & 74.6 $\pm$ 0.1 \comment{4bjiewv89m} \\ \midrule Ours (Instance) & \textbf{79.2 $\pm$ 0.2} \comment{S2 7zww5zc8bi S3 c9w2rags7c S1 ifxp44k6sq} & \textbf{75.3 $\pm$ 0.3} \comment{3acmxmvd8b S2 d5dgdh9fbb S1 igfz37r7xq} \\ \bottomrule \end{tabular} } \captionof{table}{On CIFAR100, our method of learning dynamic labels outperform common methods that use fixed labels.} \label{tab:other-baselines} \end{wrapfigure} \vspace{-0.25cm} \noindent\textbf{Comparison with other methods}: In Table \ref{tab:other-baselines}, we compare our approach to methods that use fixed labels, but incorporate other strategies for improving generalization. Confidence penalty \cite{pereyra2017regularizing} uses one-hot labels to optimize the model parameters, but regularize the model predictions by penalizing low entropy distributions. Label smoothing \cite{szegedy2015rethinking} regularizes over-confident predictions by optimizing soft labels, that remain fixed throughout optimization. These soft labels are obtained by modifying the one-hot labels to allocate a small amount of uniform weights to non target classes. In contrast, our method takes into account the shared concepts at different stages of training, and dynamically regularizes the model for softer decision boundaries. For similar reasons stated above, we obtain diminished gains on CIFAR10 (reported in Supplementary). \subsection{Analysis of dynamic labels} \label{sec:experiments-analysis} In the previous section, we establish that dynamic soft labels improve generalization. In this section, we study the different components of our method and highlight their importance. \begin{wrapfigure}{r}{0.40\columnwidth} \centering \resizebox{0.30\columnwidth}{!}{ \begin{tabular}{@{}ccc@{}} \toprule Dynamic & Class & Instance \\ \midrule \xmark & 77.2 $\pm$ 0.1 \comment{y4tkcz2fv4} & 78.4 $\pm$ 0.3 \comment{3zdhy4kdze} \\ \cmark & \textbf{78.8 $\pm$ 0.2} \comment{m5qgy9rzfp} & \textbf{79.2 $\pm$ 0.2} \comment{5grp7w33ii} \\ \bottomrule \end{tabular} } \captionof{table}{Comparison of ResNet18 on CIFAR100 with dynamic and static soft labels.} \label{tab:dynamic-vs-static} \vspace{-0.1in} \end{wrapfigure} \noindent\textbf{Importance of dynamic labels}: To study the importance of trajectories of labels for generalization, we train a model in two settings (1) dynamic label trajectories {updated} at each iteration, and (2) {fixed} labels {taken from setting (1)} at convergence. As shown in Figure \ref{tab:dynamic-vs-static}, the model trained with {fixed} labels at convergence performs worse. This result empirically establishes that we need different degrees of smoothing (hence, dynamic labels) throughout optimization to improve generalization. \noindent\textbf{Dynamic labels are repeatable}: To perform a qualitative evaluation of the trajectories, we visualize the class labels in Figure \ref{fig:dynamic_global_trajectory} (middle). For CIFAR100 using ResNet18, we pick three random classes, and plot the probability mass on target class over the course of training (mean and standard deviation over three runs). The trajectories are dynamic, and adapt differently for these classes. More importantly, low standard deviation implies the learned trajectories are highly repeatable, and intrinsic to the dataset and the model. \noindent\textbf{Dynamic labels provide regularization}: In Figure \ref{fig:dynamic_global_trajectory} (left), we plot the meta set accuracy of three classes during optimization, which aligns with our hypothesis that certain classes are harder to optimize, and hence, need to be regularized differently. In Figure \ref{fig:dynamic_global_trajectory} (middle), we see that the target class probability (i.e. the effective smoothing due to the class label) and its meta set accuracy are highly correlated. E.g. the class depicted in green has the lowest accuracy, and therefore the highest smoothing. As the model performance improves, the smoothing reduces. This dynamic behavior is important for generalization, but is not possible in common methods which optimize model parameters with fixed labels \cite{pereyra2017regularizing, szegedy2015rethinking} or a fixed degree of regularization \cite{srivastava2014dropout}. \noindent\textbf{Instance labels capture instance properties}: Instance labels relax the assumption that non-target classes are equally likely. Therefore, this method can learn {more detailed} softer decision boundaries, which helps to capture instance specific properties. As shown in Figure \ref{fig:dynamic_global_trajectory} (right), our method learned different instance labels for two samples of the same class \emph{Baby}. For example, in the image of a \textit{baby} sitting on a \textit{table}, the second-most probability mass is on class \textit{Table}. Similarly, the learned soft labels also account for similar concepts between classes. For example, in the images of an \textit{apple}, the most probable classes are similar to target class i.e. \textit{pear} and \textit{orange}. \begin{figure}[!htbp] \centering \begin{minipage}[b]{0.36\textwidth} \centering \includegraphics[scale=0.20]{Images/images_final/class_acc_trajectories.png} \end{minipage}% \hfill \begin{minipage}[b]{0.36\textwidth} \centering \includegraphics[scale=0.20]{Images/images_final/class_trajectories_variation.png} \end{minipage}% \hfill \begin{minipage}[b]{0.28\textwidth} \centering \includegraphics[scale=0.30]{Images/images_final/temp_instance.png} \end{minipage}% \caption{Learning dynamics of soft labels on ResNet18 for CIFAR100 across three classes \textbf{Left}: Meta dataset accuracy of three random classes during optimization \textbf{Middle}: Regularization trajectory of these classes, where harder classes are regularized more at the start of optimization. \textbf{Right}: Top three non-target classes in instance labels capture the semantic properties of the instance. For example \textit{Bowl} being a class for an instance where \textit{Apples} are placed in a bowl. \textit{Baby} had \textit{Girl, Boy} and \textit{Woman} as top classes because they are semantically similar to the target class.} \label{fig:dynamic_global_trajectory} \end{figure} \vspace{-0.25cm} \subsection{Improving knowledge distillation using instance labels} Distillation \cite{hinton2015distilling} is a method to transfer the generalization ability of a large (teacher) model into a compact (student) model, via the information present in the predictions of the teacher model. More precisely, the predictions from a pretrained teacher model are softened using a temperature parameter, and used as targets for training the student model. Intuitively, methods such as label smoothing which regularize the models against making over-confident predictions, should help to improve the teacher models, thereby improving the downstream task of distillation. However, recent work \cite{Rafael2019} has shown that training teacher models with label smoothing leads to inferior student models, as the instance specific information is lost. In contrast, in this section, we show that training teacher models with dynamic labels makes them more suitable for distillation. \begin{table}[!htbp] \centering \small\begin{tabular}{ccccc} \toprule Temperature scaling & Baseline & Label Smoothing & Ours (Model) & Ours (Labels) \\ \midrule \xmark & $42.1 \pm 0.6$ \comment{wsigi9fqn8} & $43.2 \pm 0.1$ \comment{wsigi9fqn8} & $\bf{45.2 \pm 0.3}$ \comment{9yiktqz32u} & $45.1 \pm 0.8$ \comment{tti5m76qc2} \\ \cmark & $45.2 \pm 0.7$ \comment{d6uf67spu3} & $44.2 \pm 0.4$ \comment{uyhgjiv6py} & $\bf{45.7 \pm 0.3}$ \comment{8iydptf3nq} & $\bf{45.7 \pm 0.2}$ \comment{my9ftnmnw5} \\ \bottomrule \end{tabular} \caption{Performance of distillation from ResNet18 to AlexNet on CIFAR100 using instance labels.} \label{tab:distillation} \end{table} \vspace{-0.25cm} For this study, we replicate the setting in \cite{Rafael2019}, and use ResNet18 as teacher model and AlexNet as student model. We compare with knowledge distillation using one-hot targets and label smoothing. We use instance labels in two settings (1) Similar to \cite{hinton2015distilling}, we use predictions (referred as \textit{Ours (Model)} in Table \ref{tab:distillation}) from a teacher model trained with instance labels, as targets for the student, and (2) we use the converged instance labels (referred as \textit{Ours (Labels)} in Table \ref{tab:distillation}) as targets for the student. In all experiments, the temperature is tuned by searching in the range of [0, 10] with increments of 0.25. First, we replicate the findings of \cite{Rafael2019} in Table \ref{tab:distillation}, and verify that training with label-smoothing leads to worse downstream performance for distillation. As shown in \cite{Rafael2019}, use of a uniform-prior in label smoothing pushes all classes equally far, destroying the semantic similarity between classes and instances. In contrast, our method treats classes heterogeneously, and learns label smoothing specific to an instance (see Figure \ref{fig:dynamic_global_trajectory} (right)). Accordingly, as shown in Table \ref{tab:distillation}, when we distill knowledge from a teacher model trained using our method, we outperform the teacher trained using label smoothing by a significant margin. Our teacher model trained with instance labels is also less sensitive to temperature tuning, and performs well even without temperature scaling. This is expected as unlike distillation with one-hot targets where the predictions are softened at convergence, we optimize using soft labels at each step of optimization. Now that we have established the benefit of training teacher models with instance labels, we evaluate the efficacy of instance labels obtained at convergence, for the purpose of distillation. As shown in Table \ref{tab:distillation}, we achieve comparable performance even when we use soft labels instead of model predictions as targets for distillation. This shows that the converged labels capture the \textit{dark knowledge} \cite{hinton2015distilling} and can be used for label distillation. We expect this performance to further improve by using dynamic label trajectories, instead of static labels at convergence. However, due to difference in factors like learning rate schedule, and number of iterations, this is not straight-forward. We leave this for future exploration. \begin{wrapfigure}{r}{0.40\columnwidth} \centering \small \resizebox{0.40\columnwidth}{!}{ \begin{tabular}{@{}ll|l|l@{}} \toprule Train/Transfer & VGG16 & ResNet18 & AlexNet \\ \midrule VGG16 & $76.5 \pm 0.2$ \comment{5cn38vs2ya} & $\bf{79.6 \pm 0.2}$ \comment{8ad2ijp9pd} & $45.1\pm 0.2$ \comment{v7qfzbfaj9} \\ ResNet18 & $\bf{76.9 \pm 0.3}$ \comment{bsphs83jae} & $79.1 \pm 0.3$ \comment{wcw3fie4qk} & $\bf{45.7 \pm 0.2}$ \comment{my9ftnmnw5}\\ \midrule Baseline & 74.5 $\pm$ 0.2 & 77.1 $\pm$ 0.3 & 42.0 $\pm$ 0.4 \comment{myrn7hv6j9} \\ \bottomrule \end{tabular} } \captionof{table}{Transferring converged instance labels for CIFAR100 across architectures.} \label{tab:transfer_soft_labels} \vspace{-0.25cm} \end{wrapfigure} \noindent\textbf{Instance labels are generalizable across architectures}: From the above results, we would expect that instance labels depend more on the underlying data than on the architecture they were trained on. In this section, we show that instance labels {from one architecture} can be used to train other architectures. More specifically, we use the labels from VGG16 and ResNet18 at convergence, perform temperature scaling on them, and use them to train other architectures. As observed in Table \ref{tab:transfer_soft_labels}, using labels from other architectures outperforms the baseline by a significant margin. Interestingly, labels trained with ResNet18 generally perform better compared to labels trained using VGG16. We attribute this to the capacity of the model, which {we suppose could} play a crucial role in learning better labels. \subsection{Image classification in a noisy label setting } \label{sec:noisy} As mentioned earlier, an ideal framework to learn from noisy data should not only ignore incorrectly labelled instances, but also be able to correct labels so as to learn from them. As shown in Figure \ref{fig:correction of labels}, instance labels shift the probability mass across classes during the course of optimization, thereby correcting noisy instances. In this section, we show how our method performs in a noisy label setting by correcting incorrect samples, and how this compares with the existing state-of-art. \begin{wrapfigure}{r}{0.40\columnwidth} \centering \small \resizebox{0.40\columnwidth}{!}{ \includegraphics[]{Images/images_final/sample_instance_correction.png} } \caption{Examples of noisy instances in CIFAR100 that were corrected using our framework.} \label{fig:correction of labels} \vspace{-0.1in} \end{wrapfigure} To create the noisy data setting, and to compare with the relevant state-of-art, we follow the common settings as mentioned in \cite{jiang2017mentornet, saxena2019data, shu2019metaweightnet}. Here, the target label of each instance is independently changed to a uniformly random class with probability $p$. This $p$ is {called} the \emph{noise fraction}, and we show results with $p$=[0.2, 0.4, 0.6 and 0.8]. The target labels in the validation and meta set are, however, not changed. We maintain the same setting in \cite{jiang2017mentornet, shu2019metaweightnet} and use WideResNet-28-10 architecture, and 2\% training set as clean meta data. We report the results on CIFAR100 and CIFAR10 in two settings - (1) Setting A as in \cite{shu2019metaweightnet}, and (2) Setting B as in \cite{saxena2016convolutional}. \begin{wrapfigure}{r}{0.40\columnwidth} \centering \small \resizebox{0.34\columnwidth}{!}{ \includegraphics[]{Images/images_final/top_k.png} } \caption{Instance labels correct noise in CIFAR100 by shifting the probability mass on the correct class during training. Top-5 accuracy changes from 65\% at start of training to 90\% at convergence.} \label{fig:topk} \vspace{-0.1in} \end{wrapfigure} Current state-of-art approaches assign a weight to each instance in the training set, where ideally the noisy instances should be down-weighted over the course of training (see Section \ref{sec:related-work}. However, instance labels have an additional advantage in that they are able to change the target labels, there-by correcting the noisy instances. For example, at convergence, our method corrected 7\% of the noisy samples of CIFAR100 in the 40\% noise setting (see Figure \ref{fig:topk}), reaching 33\% noise at top-1 at convergence. Further, we observe that this method reduces the entropy of the noisy samples which it cannot correct, by reducing the probability mass on the incorrect target classes. We leverage this property to learn an implicit curriculum over the instances, by weighing each instance by the entropy of its label. In setting A \cite{shu2019metaweightnet}, our method outperforms the current state-of-art in CIFAR10 by 1.1\% at 40\% noise, and by 1.6\% at 60\% noise. On CIFAR100, we outperform the state-of-art by 2\% at 40\% noise, and 0.9\% at 60\% noise (see Table \ref{tab:mwnet-noisy}). Finally, in setting B \cite{saxena2019data}, we outperform state-of-art in CIFAR100 by 1.2\% at 20\% noise, and 0.9\% at 40\% noise. In the extreme noise setting at 80\%, our method achieves comparable performance to the current state of art (see Table \ref{tab:mwnet-noisy_2}). \begin{minipage}{\textwidth} \begin{minipage}[b]{0.48\textwidth} \centering \resizebox{1.0\textwidth}{!}{% \begin{tabular}{lcc} \toprule & 40\% & 60\% \\ \midrule Baseline \cite{shu2019metaweightnet} & $68.1 \pm 0.2$ & $53.1 \pm 3.0$ \\ Focal Loss \cite{lin2017focal} & $76.0 \pm 1.3$ & $51.9 \pm 1.2$ \\ Co-teaching \cite{han2018co} & $74.8 \pm 0.3$ & $73.1 \pm 0.3$ \\ \midrule \multicolumn{3}{c}{Using Additional Clean Data}\\ \midrule MentorNet \cite{jiang2017mentornet} & $87.3 \pm 0.2$ & $82.8 \pm 1.4$ \\ L2RW \cite{ren2018learning} & $86.9 \pm 0.2$ & $82.2 \pm 0.4$ \\ MWNet \cite{shu2019metaweightnet} & $89.3 \pm 0.3$ & $84.1 \pm 0.3$ \\ Ours (Instance labels) & $\bf{90.4 \pm 0.1}$ & $\bf{85.7 \pm 0.2}$ \\ \bottomrule \end{tabular} } \end{minipage} \hfill \begin{minipage}[b]{0.48\textwidth} \centering \resizebox{1.0\textwidth}{!}{% \begin{tabular}{lcc} \toprule & 40\% & 60\% \\ \midrule Baseline \cite{shu2019metaweightnet} & $51.1 \pm 0.4$ & $30.9 \pm 0.3$ \\ Focal Loss \cite{lin2017focal} & $51.2 \pm 0.5$ & $27.7 \pm 3.7$ \\ Co-teaching \cite{han2018co} & $46.2 \pm 0.15$ & $35.7 \pm 1.2$ \\ \midrule \multicolumn{3}{c}{Using Additional Clean Data}\\ \midrule MentorNet \cite{jiang2017mentornet} & $61.4 \pm 4.0$ & $36.9 \pm 1.5$ \\ L2RW \cite{ren2018learning} & $60.8 \pm 0.9$ & $48.2 \pm 0.3$ \\ MWNet \cite{shu2019metaweightnet} & $67.7 \pm 0.3$ & $58.8 \pm 0.1$ \\ Ours (Instance labels) & $\bf{69.7 \pm 0.3}$ & $\bf{59.4 \pm 0.4}$ \\ \bottomrule \end{tabular} } \end{minipage} \captionof{table}{Learning soft labels with WRN28-10 under varying uniform noise, outperforms the state-of-the-art methods. Model is trained with setting A \cite{shu2019metaweightnet} \textbf{Left}: CIFAR10 \textbf{Right}: \cite{shu2019metaweightnet}: CIFAR100} \label{tab:mwnet-noisy} \end{minipage} \begin{table}[!htbp] \centering \small\begin{tabular}{lccc} \toprule & 20\% & 40\% & 80\% \\ \midrule Baseline \cite{ren2018learning} & $60.0$ & $50.66 \pm 0.24$ & $8.0$ \\ MentorNet PD \cite{jiang2017mentornet} & $72.0$ & $56.9$ & $14.0$ \\ Data Parameters \cite{saxena2019data} & $75.68 \pm 0.12$ & ${70.93 \pm 0.15}$ & $\bf{35.8 \pm 1.0}$ \\ \midrule \multicolumn{4}{c}{Using Additional Clean Data}\\ \midrule MentorNet DD \cite{jiang2017mentornet} & 73.0 & $67.5$ & $35.0$ \\ L2RW \cite{ren2018learning} & - & $61.34 \pm 2.06$ & - \\ Ours (Instance labels) & $\bf{76.9 \pm 0.3}$ & $\bf{71.8 \pm 0.2}$ & $\bf{35.6 \pm 0.6}$ \\ \bottomrule \end{tabular} \caption{Learning soft labels with WRN28-10 under varying uniform noise, outperforms the state-of-the-art methods. Model is trained with setting B \cite{saxena2019data}: CIFAR100} \label{tab:mwnet-noisy_2} \end{table} \section{Related Work} \label{sec:related-work} \noindent\textbf{Soft labels}: Various techniques have been proposed to regularize model parameters for improving generalization \cite{ioffe2015batch, pereyra2017regularizing, srivastava2014dropout}. A relevant work is label smoothing \cite{szegedy2015rethinking}, where instead of the model parameters, the one-hot labels are regularized to a weighted mixture of targets in the dataset. This technique has been widely adopted in different problems like image-classification \cite{real2019regularized, zoph2018learning}, reducing word-error rate \cite{chorowski2016towards}, improving machine translation \cite{vaswani2017attention} etc. A shortcoming of this approach is that soft-labels remain static throughout the course of optimization. Multiple works \cite{dogan2019label,li2020regularization, pham2020meta, xie2016disturblabel} have been proposed to mitigate the static nature of labels. DisturbLabel \cite{xie2016disturblabel} regularizes model training by performing label dropout. Label smoothing can be viewed as a marginalized form of label dropout. \cite{dogan2019label} embed labels using word embeddings in a Euclidean space, and computes similarities (soft-labels) based on dot-product in this space. Their method is limited to settings where labels are comprised of natural words. \cite{li2020regularization} argue against using a single smoothing across entire dataset, and instead cluster the data and propose a heuristic to set the smoothing parameter for data points in each cluster. Our work does not rely on clustering in a feature space, and learns optimal soft-labels for each instance via meta-learning. \cite{li2019learning} also use meta-learning to learn optimal soft labels, but reset the label estimates at every epoch. On the contrary, our work treats labels as learnable parameters, that are continuously optimized throughout training (which is key to label correction in corrupt data setting). \cite{pham2020meta} is the most relevant to our proposed approach, where an auxillary teacher model is trained to assign soft targets to a student, thereby yielding dynamic soft labels. Our work does not rely on a teacher model, instead it explicitly instantiates and learns soft labels for the dataset. As a result, our method can account for the class membership of data points, and learns to regularize each class and instance separately. Also, their method is Markovian in nature, while our method benefits from the past history of optimization of the soft-labels. \noindent\textbf{Noisy data setting}: In the noisy data setting, \cite{jiang2017mentornet, shu2019metaweightnet} trained an auxillary neural network using meta-learning to assign weights to samples in the mini-batch. \cite{ren2018learning} uses a held-out set to perform an online approximation of weights for samples in a minibatch. \cite{saxena2019data} introduced learnable temperature parameters per data-point, which scale the gradient contribution of each data-point. \cite{zhang2020distilling} use meta-learning to perform a linear combination of the original labels and pseudo labels generated by DNN on the fly. The learned weights are used to cluster the data as clean or mislabelled. While these works can reduce the contribution of noisy instances, they cannot correct the incorrect labels. In contrast, our framework is able to correct the labels of noisy instances, and outperforms these methods. \cite{tanaka2018joint, yi2019probabilistic} propose a framework for correcting noisy annotations in the dataset. They update model parameters and labels in an alternate manner using the training dataset. However, since the model parameters and labels are updated on the same data, they rely on hand-crafted heuristics to prevent degenerate solutions. While they obtain promising results in low noise setting, these heuristics fail to converge in presence of high annotation noise \cite{yi2019probabilistic}. Our method does not rely on any heuristic, instead we use the meta-learning constraint, and outperform state-of-the-art at all levels of noise. \section{Conclusion} In this work, we have proposed a meta-learning framework under which the labels are treated as learnable parameters, and are optimized along with model parameters. The learned labels take into account the model state, and provide dynamic regularization, thereby improving generalization. We learn two categories of soft labels, class labels specific to each class, and instance labels specific to each instance. In case of supervised learning, training with dynamically learned labels leads to improvements across different datasets and architectures. In presence of noisy annotations in the dataset, our framework corrects annotation errors, and improves over the state-of-the-art. Finally, we show that teacher models trained with dynamically learned labels improves the downstream task of distillation. \section{Introduction} \input{Introduction} \section{Learning Dynamic Soft Labels via Meta Learning} \input{method_supervised} \section{Experimental Evaluation} \label{sec:experiments} \input{final_experimetal_section} \newpage {\small \bibliographystyle{ieee_fullname} \subsection{Class labels} \label{sec:class-specific} At different steps of optimization, certain classes may be more prone to over-fitting than others. So, different degrees of regularization may be required for them. We begin by considering an adaptive smoothing parameter unique to each class, such that the class label is obtained by smoothing the one-hot labels proportional to this parameter. The parameters regularize each class differently, thereby preventing over-confident model predictions \cite{pereyra2017regularizing}. To formalize, given a training set with \textit{N} data points and \textit{c} classes, let $\mathbf{x}_i \in \mathbb{R}^d$ denote a single data point and $y_i \in \{1,...,c\}$ denote the corresponding target class. Let ${\alpha}^t \in \mathbb{R}^c$ represent smoothing parameters for all classes at step $t$ of optimization, where $\alpha_k^t$ is the smoothing parameter for class $k$. Let ${p}_{i,k}^t$ be the probability mass on class \textit{k} for instance \textit{i} at step $t$. The effective class label $\mathbf{p}_i^t \in \mathbb{R}^c$ is a probability distribution defined as follows: \vspace{-0.25cm} \[ {p}_{i,k}^t (\alpha_{y_i}^t)= \begin{cases} 1-\alpha_{y_i}^t,& \text{if } k = y_i\\ \alpha_{y_i}^t / (c-1), & \text{otherwise} \end{cases} \] Let, $f(\mathbf{x}, \theta^t)$ and $\theta^t$ denote the model and model's parameters at step $t$ respectively. Let $L_{train}(\mathbf{x}_i, \mathbf{p}_i^t; \theta^t)$ denote the cross-entropy loss between model prediction and class label $\mathbf{p}_i^t$ for data point $i$. For sake of explanation, we denote $L_{train}(\mathbf{x}_i, \mathbf{p}_i^t; \theta^t)$ as $\mathcal{L}_{i}^\textrm{train}({\alpha}^{t}_{y_i} ;\theta^t)$, as $\mathbf{p}_i^t$ is a function of ${\alpha}^t_{y_i}$. Our goal is to solve for optimal $\hat{\theta}$ by minimizing the loss on the training set. \begin{align} \mathcal{L}_{train}(\theta^t,\alpha^{t}) &= \frac{1}{N} \sum_{i=1}^N \mathcal{L}_{i}^\textrm{train}(\alpha^t_{y_i} ;\theta^t) \label{eq:sgd_update} \\ \hat{\theta}(\alpha^{t}) &= \arg \min_{\theta} \mathcal{L}_{train}(\theta, {\alpha}^{t}) \label{eq:loss_min} \end{align} \vspace{-0.25cm} Here, $\hat{\theta}$ is a function of $\alpha^t$. Note, if $\forall{t}$ $\alpha^t=0$, Eq. \ref{eq:sgd_update} is equivalent to standard classification loss with one-hot fixed targets. But, here, {the best choice of} $\alpha^{t}$ is not known \textit{apriori}. We cannot optimize $\alpha^t$ and $\theta^t$ {using the loss objective} on the same data points, because it can lead to degeneracy. For instance, Eq. \ref{eq:loss_min} allows for a local minima where the class labels and model predictions converge to each other and can be away from the ground truth. To avoid this issue, we turn to meta-learning, where we use a training set to optimize $\theta^t$, and a meta set to optimize $\alpha^t$. To save the computational cost of unrolling the feed-forward graph through multiple time steps, we use a one-step look ahead approach to estimate the gradient of $\alpha^t$ on meta set. \textbf{Meta learning for class labels}: We sample a mini-batch with $n$ instances from the training set, and simulate a one step look-ahead SGD update on model parameters (${\theta^{t+1}}^*$) as a function of $\alpha^{t}$ (see Eq. \ref{eq:one_step_sgd_roll_out_instance}). Here, $\lambda_{\theta}$ is the learning rate for model parameters. Next, the one step look-ahead update is used to compute the loss on meta set $\mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)$. In our experiments, we use the cross entropy loss between the model predictions and labels in the meta set. This loss is used to compute the meta-gradient on the smoothing parameters (see Eq. \ref{eq:meta_gradient_instance}): \vspace{-0.25cm} \begin{align} {\theta^{t+1}}^* (\alpha^{t}) &= \theta^{t} - \frac{\lambda_{\theta}}{n} \sum_{i=1}^n \frac{\partial \mathcal{L}_i^\textrm{train}(\theta^t, \alpha^{t}_{y_i})}{\partial \theta^{t}} \label{eq:one_step_sgd_roll_out_instance} \\ \frac{\partial \mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)}{\partial \alpha^{t}_{y_i}} &= \frac{\partial \mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)}{\partial {\theta^{t+1}}^*} \cdot \frac{\partial {\theta^{t+1}}^*}{\partial \alpha^{t}_{y_i}} \nonumber \\ \frac{\partial \mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)}{\partial \alpha^{t}_{y_i}} &= \frac{-\lambda_\theta}{n} \cdot \frac{\partial \mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)} {\partial {\theta^{t+1}}^*} \cdot \frac{\partial}{\partial \alpha^t_{y_i}}\big[ {\frac{\partial \mathcal{L}^\textrm{train}_i}{\partial \theta^{t}}} \big]^T \label{eq:meta_gradient_instance} \end{align} Using the meta-gradient (in Eq. \ref{eq:meta_gradient_instance}), we update the smoothing parameter for each class using the first order gradient update rule (see Eq. \ref{eq:t_plus_1_update_inst_params}). The updated value $\alpha^{t+1}$ is then used to update the model parameters (see Eq. \ref{eq:t_plus_1_update_model}). Here, $\lambda_{\alpha}$ is the learning rate for smoothing parameters of all classes. \begin{align} \alpha^{t+1}_{y_i} &= \alpha^{t}_{y_i} - \lambda_{\alpha} \frac{\partial \mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)}{\partial \alpha^{t}_{y_i}} \label{eq:t_plus_1_update_inst_params} \\ \theta^{t+1} &= \theta^{t} - \frac{\lambda_{\theta}}{n} \sum_{i=1}^n \frac{\partial \mathcal{L}_i^\textrm{train}(\theta^t, \alpha^{t+1}_{y_i})}{\partial \theta^{t}} \label{eq:t_plus_1_update_model} \end{align} Our method is summarized in Algorithm \ref{alg}. Note, if the smoothing parameters are fixed and common to all classes, our method is similar to label smoothing \cite{szegedy2015rethinking}. However, having fixed smoothing throughout training might be suboptimal. We later verify this finding in Section \ref{sec:experiments-analysis}, where we show that when we adapt these parameters dynamically, the model prefers a higher degree of smoothing at the start of optimization, but reduces the smoothing at convergence. \input{pseudocode_meta} \subsection{Instance labels} \label{sec:instance-specific} Class labels assume a homogeneous distribution of instances within a class. Further, they allocate uniform probability on non-target classes, meaning for a given class, all non-target classes are equally likely. However, instances within a class can have varying properties. For example, in Figure \ref{fig:n_c_overview} (right), consider an image of class \textit{Baby}, where the baby is sitting on a table. The ideal soft label should have more probability mass on class \textit{Table} than other non-target classes. Such instance labels {could} help learn softer decision boundaries via shared concepts. We use our meta-learning framework to learn such labels directly. Formally, for a given instance $\mathbf{x}_i$ at step $t$ of optimization, instance labels are learnt via smoothing parameters, where $\alpha_{i,k}^t$ is the smoothing parameter for hypothesis class $k \in \{1,...,c\}$. The instance label $\mathbf{p}_i^t \in \mathbb{R}^c$, is a probability distribution over all $c$ classes, such that $\sum_{k=1}^c \alpha_{i,k}^t=1$. Here, ${p}_{i,k}^t (\alpha_{i,k}^t) = \alpha_{i,k}^t$ as shown in Eq. \ref{eq:rewrite_meta_gradient_update}, the meta gradient on an instance is proportional to the dot product of the gradient of training loss at the $i^{th}$ sample at step $t$, and the gradient of the meta loss over all samples in the meta set at step $t+1$. Therefore, a hypothesis class whose gradient aligns with the gradients on the meta set will obtain a higher probability mass. This allows a more informed allocation of probability mass on non target classes. \vspace{-0.25cm} \begin{align} \frac{\partial \mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)}{\partial \alpha_{i,k}^{t}} &= \frac{-\lambda_\theta}{n} \cdot \frac{\partial \mathcal{L}^\textrm{meta}({\theta^{t+1}}^*)} {\partial {\theta^{t+1}}^*} \cdot \frac{\partial}{\partial \alpha_{i,k}^t}\big[ {\frac{\partial \mathcal{L}^\textrm{train}_i}{\partial \theta^{t}}} \big]^T \label{eq:rewrite_meta_gradient_update} \vspace{-0.25cm} \end{align} Another advantage of learning instance labels is in the noisy data setting, as our framework can perform label correction. More specifically, the incorrect hypothesis class will misalign with the meta-gradients in Eq. \ref{eq:rewrite_meta_gradient_update}. So, under our algorithm, the probability mass over incorrect class will reduce, and the probability mass on correct class will increase during optimization (see Section \ref{sec:noisy}).
{'timestamp': '2020-09-22T02:19:06', 'yymm': '2009', 'arxiv_id': '2009.09496', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09496'}
arxiv
\section{Introduction} \lettrine[lines=2]{H}{UMAN} activity recognition (HAR) is a critical technology in the Internet of Things (IoT), which aims to provide information on human physical activity and detect human actions \cite{lara2012survey, kim2009human}. With the fast advancement of the IoT, HAR has attracted much attention as it enables many applications \cite{zhang2013human, pei2013human, wen2018survey, pei2018optimal} such as healthcare, security monitoring, smart home \cite{bianchi2019iot} etc. Based on different types of sensing modes, the HAR has been approached in three different ways: 1)vision-based HAR;\cite{lara2012survey, avci2010activity} 2)radio-based HAR;\cite{wang2016csi, kianoush2016device} 3)wearable-device-based HAR\cite{chavarriaga2013opportunity, zhang2019novel, xiao2020deep}. The vision-based HAR is one of the well-known external methods that has been extensively studied by academia and industry, but the vision-based HAR has to face many challenges in terms of cost, coverage, and lighting conditions, especially privacy security \cite{lara2012survey, avci2010activity}. With the deployment of wireless communication devices, the radio-based HAR used by the variations of wireless signal intensity has also been extensively studied\cite{zou2019multiple}. Besides, the radio-based HAR is vulnerable to environmental interference; The related HAR is relatively simple and is often used for location services in practical applications\cite{wang2016csi}. On the other hand, intelligent wearables equipped with inexpensive micro sensors, i.e., inertial measurement units (IMUs) \cite{chavarriaga2013opportunity}, provide a new way for HAR in a non-intrusive manner. Moreover, IMUs can be flexibly attached to the body and provide time-stamped signals with the acceleration and orientation of the body movement \cite{avci2010activity}. Therefore, in this work, we will focus on wearable-device-based HAR. Recent years have witnessed an increasing interest in machine learning-based HAR with wearable devices. Traditional HAR algorithms, such as random forest (RF)\cite{bhanujyothi2017comparative}, Bayesian network \cite{zerrouki2018vision}, and support vector machine (SVM) \cite{pei2012using}, have been proposed for HAR based on the manual mode for choosing characteristic points. For example, \cite{ravi2005activity, kwapisz2011activity} manually extracted different features, such as mean, energy, frequency-domain entropy and correlation, which were then fed into the classifiers, e.g., decision tree \cite{todorovski2003combining}, K-nearest neighbor (KNN) \cite{pirttikangas2006feature}. With manually selected features, the machine learning methods have achieved good recognition accuracy. Later, the advanced feature selection methods \cite{abidine2018joint}, such as principal component analysis (PCA), linear discriminate analysis (LDA), have been proposed, which can jointly minimize classification errors and decrease the computational time. With the rapid development of neural networks, researchers started to apply deep neural networks with HAR. Considering deep learning based HAR with automatic feature extraction, improved accuracy and robustness have been reported in many related works \cite{zeng2014convolutional, jiang2015human, yang2015deep, hammerla2016deep, guan2017ensembles, he2018weakly, xiao2020deep}. At the early stage of deep learning based HAR, Vepakomma et al. \cite{vepakomma2015wristocracy} used traditional methods to extract manual features, which were then fed into a fully-connected deep neural network for classifying activities in HAR. As the CNN is insensitive to scale changes and can capture local dependence of nearby signal-related information, the works of \cite{zeng2014convolutional, yang2015deep, jiang2015human, hammerla2016deep} used 1D/2D CNN frameworks to perform feature extraction and classification for HAR. It has been shown in these works that the CNN is an effective model for obtaining useful information in the spatial dimension from IMU signals. In addition to using the CNN architecture to process sensor data, some researchers started to pay attention to the temporal characteristics of sensor data. For example, Guan et al. \cite{guan2017ensembles} proposed a method for HAR, which is based on the recurrent neural network (RNN) with long short-term memory (LSTM) and obtained satisfactory results at the expense of increased computational time. What's more, the hyperbolic networks model \cite{ordonez2016deep}, consisting of convolutions and LSTM recurrent units, has been proposed to realize multi-modal wearable activity recognition. This hybrid network (denoted by Deep ConvLSTM) jointly takes into account the advantages of two kinds of network models, obtains multi-level { latent knowledge \cite{yan2019using}} for considered signals, and thus achieves better results for HAR compared with the network with single model. In summary, the deep learning methods provide an effective way for automatic feature extraction in HAR. Besides, the hyperbolic networks with different kinds of network modules (i.e., 1D CNN, 2D CNN, RNN) encourage a flexible way for obtaining multi-level latent representation for the investigated signals. However, the performance of deep learning methods is mostly based on the quality and quantity of the collected data. There is little works on robust and efficient HAR from noisy and label-deficient IMU data. In this study, motivated by recently published works \cite{laine2016temporal, miyato2018virtual, sun2019meta}, we propose a novel multiple-domain deep learning framework to realize robust and real-time HAR. Our contributions are listed as follows. \begin{enumerate} \item We first propose to build an extensive database based on virtual IMUs. A novel multi-domain deep learning framework, employing hybrid convolutional neural networks (CNNs) in the semi-supervised form, is then proposed to learn the single-frame human activity from noisy and imbalanced data, which are very important yet rarely exploited tasks in HAR. \item In the proposed method, the latent representations obtained from five single-domain feature extractors are fused together according to the principle of uncertainty-aware consistency, which reduces the uncertainty by weighting the importance of the features. This is a simple yet effective effort for improving the performance of the proposed method. \item { The mechanism of transfer learning is adopted in the proposed method based on the recently released AMASS dataset, containing great synthetic human poses and virtual IMU data. The employment of AMASS can enhance the variety and diversity of the training dataset and has demonstrated beneficial effects on training process and feature transfer in the proposed method.} \item Based on the real deep inertial poser (DIP) dataset, numerous experiments have been conducted to evaluate the performance of the problem method. The experimental results show that the proposed methods can surprisingly converge within a few iterations and outperform all competing methods, demonstrating the novelty of employing the virtual IMU and the effectiveness of the proposed methods. \end{enumerate} We will release our code for reproducible research. The remainder of this paper is structured as follows. Section \ref{sec:2} introduces the basic knowledge of data set preparation and the proposed method. Section \ref{sec:3} presents the multi-domain neural network which consists of the feature extraction module, feature fusion module and cross domain knowledge transfer module. In Section \ref{sec:4}, we evaluate the performance of the proposed method against several competing ones over various experiments. Finally, Section \ref{sec:5} concludes the work and discusses the future work. \section{Preliminaries} \label{sec:2} This section introduces the data sets and related signal processing methods used for HAR tasks and presents the relevant basic knowledge. In order to ensure the diversity and richness of the HAR dataset in real scene, we innovatively reproduce a synthetic HAR dataset and generate the corresponding virtual IMU data from a recently published motion capture dataset AMASS \cite{mahmood2019amass}, which relieves the pain of scarcity of the limit training data. \subsection{Synthesizing IMU Data} \label{SID} The proposed method is based on deep learning framework, in which a sufficiently large data set is required for training. Here, we obtain synthetic IMU dataset based on the motion capture dataset AMASS \cite{mahmood2019amass} and DIP-dataset \cite{huang2018deep}, which contain abundant human activities. Therefore, according to the characteristics of selected datasets, we introduced the basic principles of the SMPL model, and briefly explained the motion capture data generation process of virtual IMU data and related data processing for labeling. \subsubsection{Basic knowledge of SMPL model} \label{smpl} The SMPL model is a parametric human body model proposed by Matthew Loper \cite{loper2015smpl}, which contains 23 joint point posture descriptions of the standard bone model and a basic human body orientation description (root orientation), a total of 72 parameters describing posture (23*3+1*3), including 10 shape parameter descriptions describing the 3D human body shape. Combining the linear blend-skinning (LBS) function $ W(\cdot) $ and the human body average template shape $ \overline{T}$ composed of $ N $ cascaded vertex vectors at the zero pose time, the basic expression of the SMPL model $M(\overrightarrow{\beta} , \overrightarrow{\theta})$ , which maps shape and pose parameters to vertices, can be obtained \cite{loper2015smpl}: \begin{equation} \label{smpl1} M(\overrightarrow{\beta} , \overrightarrow{\theta}) = W(T_p(\overrightarrow{\beta} , \overrightarrow{\theta}),J(\overrightarrow{\beta}),\overrightarrow{\theta},\mathcal{W}), \end{equation} where \begin{equation} \label{smpl2} T_p(\overrightarrow{\beta} , \overrightarrow{\theta}) = \overline{T} + B_s(\overrightarrow{\beta}) + B_p(\overrightarrow{\theta}), \end{equation} $ B_s(\overrightarrow{\beta})$ and $ B_s(\overrightarrow{\theta})$ are the blend shape function and the pose-dependent blend shape function, which take the body shape parameters $\overrightarrow{\beta}$ and the pose parameters $\overrightarrow{\theta}$ as input of functions respectively; $ J(\overrightarrow{\beta}) $ is the position of the joint points, which is related to the body shape parameters; $\mathcal{W}$ is a set of blend weights. To take full advantage of the SMPL model, one need to collect real human body meshes in different poses, which are then trained for obtaining the corresponding relationship among shape parameters, pose parameters and the mesh. \subsubsection{Motion capture dataset preparation} The dataset containing abundant data is one of the cornerstones of deep learning research. However, general HAR datasets \cite{chavarriaga2013opportunity} only have a small amount of data and limited motion types. For the HAR task in real scene, we use a motion capture dataset commonly used for 3D reconstruction and pose reconstruction. To get the large dataset, Mahmhood and others proposed to use the Mosh++ algorithm to uniformly convert the motion capture data in different data sets into SMPL body model \cite{mahmood2019amass}, which constitutes a motion capture data set containing more than 40 hours of exercise data, more than 300 experimenters and 11,000 exercise types. The motion capture data set contained in the original AMASS data set used in this article is shown in Tab. \ref{AMASS_struct}. \begin{table}[] \caption{\sc Part of The AMASS Dataset Structure} \label{AMASS_struct} \centering \setlength{\tabcolsep}{7mm}{ \begin{tabular}{lllll} \hline \hline \multicolumn{1}{l}{\textbf{Dataset}} & \multicolumn{1}{l}{\textbf{Motions}} & \multicolumn{1}{l}{\textbf{Minutes}} \\ \hline ACCAD & 252 & 26.74 \\ CMU & 2083 & 551.56 \\ Eyes Japan & 750 & 363.64 \\ Human Eva & 28 & 8.48 \\ MPI HDM05 & 215 & 144.54 \\ SSM & 30 & 1.87 \\ Transitions & 110 & 15.1 \\ JointLimit & 40 & 24.14 \\ BioMotion & 3130 & 541.82 \\ \hline \hline \end{tabular} } \end{table} The original AMASS dataset only provides SMPL model data representing attitude parameters, and does not contain corresponding IMU data. In order to adapt to wearable gesture recognition tasks, it is necessary to simulate the IMU data of the corresponding position from the SMPL model in the AMASS dataset. Huang et al. \cite{huang2018deep} place virtual sensors on the skin surface of the SMPL model, and use forward kinematics to calculate the direction data of the virtual IMU for each frame, which is expressed in the form of a rotation matrix. For virtual simulated acceleration data, it can be obtained by two differential operations. For time $t$, the virtual acceleration can be defined as: \begin{equation} a_t = \frac{P_{t-1}+P_{t+1}-2P_{t}}{dt^{2}}, \end{equation} where $P_t$ represents the location of the virtual IMU at time $t$ and $a_{t} $ represents the virtual acceleration at time $t$. As a result, we adopt the similar strategy in \cite{huang2018deep} to generate the rotation matrix and virtual acceleration data, which are further used for training the our network model. \subsubsection{IMU data processing} IMU is a precision measurement device that includes an accelerometer, a gyroscope, and a magnetometer. With the development of Microelectromechanical Systems (MEMS) technology and the proliferation of IMUs in smart devices, researches on wearable IMU can better serve IoT applications. As introduced in the previous section, we use the IMU observations placed near the joints of the human body to recognize complex human activities. We use the observation values (rotation matrix and acceleration) obtained by the IMU placed near the joints of the human body to recognize the complex human activities. Since IMU sensors are susceptible to environmental noise, electromagnetic waves and temperature changes, the low-pass filter was used to reduce the impact of certain high-frequency noises in raw IMU data. Besides, in order to obtain data suitable for neural network input, we have performed necessary processing on the IMU raw data, such as coordinate conversion and normalization. Fig. \ref{IMU output and human skin model} shows a schematic diagram of the IMU output and the SMPL body model. \begin{figure}[!ht] \centering \includegraphics[width=8cm]{new_data1.png} \caption{IMU output and SMPL body model} \label{IMU output and human skin model} \end{figure} \subsubsection{Posture recognition data annotation} The dataset used in our work is based on the AMASS and DIP datasets as mentioned above. For the virtual IMU dataset AMASS, considering that the AMASS dataset contains a plentiful of activities, we need to screen out suitable data for HAR tasks and label them. Therefore, This paper uses the methods of text description division, common motion category screening and visual auxiliary annotation to label the HAR data of the motion capture dataset (AMASS dataset). The flowchart is shown in Fig. \ref{Data labeling flowchart}. \par \begin{figure}[!ht] \centering \includegraphics[width=8cm]{2.jpg} \caption{Data labeling flowchart.} \label{Data labeling flowchart} \end{figure} The following part introduces in detail the labeling process of the AMASS dataset: \textbf{1) \ Posture division based on text description:} The original AMASS dataset is a collection of many motion capture datasets. When collecting these data sets, the experimenter will often follow the pre-specified rules to perform the corresponding movement, so corresponding to each motion capture file, the dataset itself will provide the motion posture description corresponding to the file. This article directly uses the posture description provided by the file name as the basis to preliminarily divide the motion capture files of each sub-data set contained in AMASS. \textbf{2) \ Common motion category screening:} After dividing the preliminary postures according to the text description, we further label them in combination with common behaviors and postures in daily life. In this process, two types of posture files, the martial arts type and specific high-frequency conversion combined postures, which are rarely related to daily human activities, were eliminated. Therefore, following the preliminary results of posture division in step 1,the AMASS dataset was finally divided into 12 HAR categories. \textbf{3) \ Auxiliary annotation of posture visualization: }After the first two steps, specific behavior classification has been completed for most data files. However, due to the lack of particular posture description information, there are still some data files that cannot be directly labeled. Therefore, we mainly use Unity and Matlab to visualize motion capture files. Therefore, after visual analysis, the data can be segmented, annotated, or eliminated, so that all the files contained in the data set are classified and annotated. \begin{figure}[h] \centering \includegraphics[width=8cm]{new_dataset2.png} \caption{SMPL models with Unity visual action.} \label{SMPL model Unity visual action} \end{figure} For the DIP dataset which were collected in reality with a small amount of data, and a preliminary classification was made at the time of collection. We verified the classification of the DIP data set and eliminated some difficult-to-discern actions, and finally got 5 types of complex action categories, Upper Body, Lower Body, Locomotion, Jumping and Computer Works. Each behavior category and the specific motion posture included in each behavior category are shown in Tab. \ref{DIP_struct}. \par \newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}} \begin{table}[!ht] \caption{\sc DIP Datasets Structure} \label{DIP_struct} \centering \setlength{\tabcolsep}{5mm}{ \begin{tabular}{lllll} \hline \hline \multicolumn{1}{l}{\textbf{Categories}} & \multicolumn{1}{l}{\textbf{Motions}} \\ \hline Upper Body &\tabincell{c}{Arm raises, stretches and swings, Arm \\crossings on torso, and behind head.} \\ Lower Body & \tabincell{c}{Leg raises. Squats. Lunges} \\ Locomotion & \tabincell{c}{Walking (Walking straight and in circle),\\ Sidesteps (crossing legs, touching feet).} \\ Jumping & \tabincell{c}{Jumping jacks } \\ Computer Works & \tabincell{c}{Finishing computer works, interacting \\with everyday objects. } \\ \hline \hline \end{tabular} } \end{table} In what follows, we will introduce some preliminary knowledge about denoising autoencoders and the Kullback-Leibler Divergence, which are the basis of proposed scheme. \subsection{Denoising Autoencoders} With noisy observation of considered datasets (AMASS or DIP), the framework of denoising autoencoders \cite{vincent2010stacked} will be adopted to extract features and perform data reconstructions (cleaning) jointly. Given an input ${\bf{x}}$, the autoencoder-based deep neural network first encodes it to a latent space through several encoding techniques, i.e., 1D/2D convolution, pooling, and batch normalization. With similar techniques\footnote{In the decoding part, the 1D/2D convolution operations will be replaced by the deconvolution operations. In this work, following the prior work \cite{sze2017efficient} and considering the characteristics of IMU data samples, the large stride size is employed, instead of the pooling strategies, to persevere the spatial structure of the considered data.}, the features $\kappa $ embedded in the latent space are then decoded to obtain the estimation of the cleaned input ${{\bf{\hat x}}}$. The whole process can be summarized as: \[\begin{array}{c} {\rm{Encoding}}:\kappa = \varphi \left( {f\left( {{{\bf{W}}_1},{\bf{x}}} \right) + {{\bf{b}}_1}} \right)\\ {\rm{Decoding}}:{\bf{\hat x}} = \varphi \left( {g\left( {{{\bf{W}}_2},\kappa } \right) + {{\bf{b}}_2}} \right) \end{array},\] Where $f$ and $g$ denote the techniques used in the encoding and decoding processes, respectively. In this work, $f$ and $g$ are multiple layer convolution operations and deconvolution operation, respectively. The goal of the autoencoder is to learn the network parameters $\left\{ {{{\bf{W}}_1},{{\bf{W}}_2},{{\bf{b}}_1},{{\bf{b}}_2}} \right\}$ by minimizing the loss function as follows, \begin{equation} \label{1111} {\mathop {\min }\limits_{\left\{ {{{\bf{W}}_1},{{\bf{W}}_2},{{\bf{b}}_1},{{\bf{b}}_2}} \right\}} }{\sum\nolimits_{k = 1}^K {\left\| {{{{\bf{\hat x}}}_k} - {{\bf{x}}_k}} \right\|_2^2} }, \end{equation} where $K$ denotes the number of data samples in a mini batch. \subsubsection{Kullback-Leibler Divergence} The Kullback-Leibler (KL) divergence, also known as the relative entropy, is commonly used in statistics to measure similarity between two density distributions. Given two probability measures $P$ and $Q$, the KL divergence of $P$ from $Q$ can be denoted by \begin{equation} \label{22222} {D_{KL}}\left( {P,Q} \right) = \sum {P\ln \frac{P}{Q}}, \end{equation} In this work, we use the symmetrized version of the to measure the difference between the learned features in the different latent spaces, \begin{equation} \label{33333} S{D_{KL}}\left( {P,Q} \right) = {D_{KL}}\left( {P,Q} \right) + {D_{KL}}\left( {Q,P} \right), \end{equation} which will explained in the following section. \section{Methods} \label{sec:3} In this section, as shown in Fig. \ref{Proposed Overview}, we present the proposed multi-domain neural network which consist of three technical modules: 1) Feature extraction module based on the hybrid deep convolutional neural network; 2) Feature fusion module with the principle of uncertainty-aware consistency; 3) Cross domain knowledge transfer module according to the mechanism of the transfer learning. \begin{figure*}[h] \centering \includegraphics[width=17cm]{zongti.png} \caption{Proposed overview.} \label{Proposed Overview} \end{figure*} \subsection{Feature Extraction using Hybrid Deep Convolutional Neural Network} \label{femdnn} We use the IMU data collected from three inertial sensors, which are respectively equipped on the head, left wrist and right leg of the investigated subjects. Let ${\bf{x}} \in {R^{N \times T}}$ be the collected IMU data. The symbol $N$ denotes the sum of all parameters (acceleration and the rotation matrix) and $T$ the size of the sliding window. In the following, we will elaborate on the proposed multi-domain network model for automatically extracting multi-level feature from noisy IMU signals, which are used for classifying individual human activities. We design a hybrid CNN to perform spatio-temporal feature learning of the IMU datasets. As shown in Fig. \ref{Proposed Overview}, the proposed hybrid CNN model is specifically designed to identify dynamic patterns in IMU signals by incorporating feature extraction, signal denoising and classification tasks. Given the input data (DIP dataset or AMASS), ${\left\{ {{{\bf{x}}_k},{{\bf{y}}_k}} \right\}_{k = 1, \cdots ,K}}$, at the feature extraction stage, the extracted features obtained by hybrid CNNs (2D-CNNs and 1D-CNNs) can be respectively represented by \begin{equation} \label{femdnn1} \kappa _k^{2D} = {f^{2D}}\left( {{{\bf{W}}^{2D}},{{\bf{x}}_k}} \right), \end{equation} and \begin{equation} \label{femdnn2} \kappa _k^{1D} = {f^{1D}}\left( {{{\bf{W}}^{1D}},{{\bf{x}}^{T}_k}} \right), \end{equation} where ${f^{2D}}$ and ${f^{1D}}$ are the forward models of a multiple-layer 2D-CNN and 1D-CNN, respectively. We will present in detail about ${f^{2D}}$ and ${f^{1D}}$ in Section \ref{sec:3}. ${{\bf{W}}^{2D}}$ and ${{\bf{W}}^{1D}}$ are the corresponding parameters (weight matrices and bias vectors) in the 2D/1D networks. The feature extraction shown in \eqref{femdnn1} and \eqref{femdnn2} jointly take advantages of 2D-CNN and 1D-CNN, which can learn the connectivity pattern among the multi-modal signals and identify characteristics in individual channel \cite{goodfellow2016deep, han2019state, karunanayake2019transfer, tang2020rethinking}, respectively. We will introduce the fusion strategies in Section \ref{EFF} for the extracted features obtained from the hybrid CNN, which take into account importance of each extracted feature. \subsection{Extracted Features Fusion} \label{EFF} In this part, as shown in Fig. \ref{fig1}, we describe the fusion strategies, such as feature-level fusion, decision-level fusion and decision-level fusion with fairness consideration, for the extracted features. \begin{figure}[htbp] \centerline{\includegraphics[width=9cm]{Fusion_strategy.png}} \caption{Illustration of the proposed feature fusion strategies.} \label{fig1} \end{figure} \subsubsection{Feature-level Fusion} As shown in \cite{yang2003feature, mangai2010survey}, it is a common way to fuse the features with the feature-level fusion scheme (or so called parallel strategy) \cite{yang2003feature}, in which the obtained features are first flattened and then concatenated into a single feature vector, \begin{equation} \label{EFF1} \kappa _k^{Fussed} = {\left[ {\begin{array}{*{20}{c}} {\kappa _k^{2D}}&{\kappa _k^{1D}} \end{array}} \right]^T}, \end{equation} which is then fed into a common classification component consisting of dense layers and the $softmax$ output layer. The feature-level fusion scheme is a popular way for fusing the hierarchical latent representations learned by the hybrid CNN, however, ignoring the importance of the individual latent representation. In the following, we propose a decision-level fusion scheme and its improved version to address this problem. \subsubsection{Decision-level Fusion} In this subsection, we introduce the design of the decision-level fusion scheme. We assume that the input (extracted feature to be fused) of the proposed fusion module is denoted as \begin{equation} \label{EFF2} {\kappa _k} = {\left[ {\begin{array}{*{20}{c}} {\kappa _k^{2D}}&{\kappa _k^{1D}} \end{array}} \right]^T} \in {R^{M \times K}}, \end{equation} where $M$ is the dimension to be merged and $K$ is the output dimension of each merging feature. The general expression of the decision-level fusion scheme can be formulated as \[\begin{array}{*{20}{c}} {{\xi _k} \odot {\kappa _k}}&{{\rm{s}}{\rm{.t}}{\rm{. }}\sum {{\xi _k} = 1},} \end{array}, \ 0 \le {\xi _k} \le 1,\] where ${{\xi _k}}$ is the attention weights that control the contributions of each merging feature in ${\kappa _k}$. As a result, the key problem now is to find the way to determine the attention weights. Here, we propose to use the $sigmoid$ function ($\sigma \left( \cdot \right)$) to satisfy the condition in \eqref{EFF2}. As a result, we can have \begin{equation} \label{EFF3} \kappa _i^{Fussed} = \sqrt {\sigma \left( {\kappa _i^{2D}} \right)} \odot \kappa _i^{2D} + \sqrt {1 - \sigma \left( {\kappa _i^{1D}} \right)} \odot \kappa _i^{1D}, \end{equation} where $\odot$ denotes the Hadamard product. In order to further improve the stability of the proposed decision-level fusion scheme, we enable the design to perform the fusion with empirical risk minimization under fairness constraints (ERMFC) \cite{sugiyama2007covariate, donini2018empirical}. \subsubsection{Decision-level Fusion with ERMFC} The fusion strategy \eqref{EFF3} does not fully consider the fairness of the extracted feature i.e., the size and the distribution of each feature. Following the theoretical works shown in \cite{sugiyama2007covariate, donini2018empirical}, the fairness of the extracted feature will be enhanced when they are sampled from the same distribution. Such a condition is extremely hard to achieve for a network functional. As a result, we try to tackle the problem by minimizing the distance between their distribution as \begin{equation} \label{fusion3} {DKL\left( {\kappa _i^{2D},\kappa _i^{1D}} \right) = {D_{KL}}\left( {\kappa _i^{1D},\kappa _i^{2D}} \right) + {D_{KL}}\left( {\kappa _i^{2D},\kappa _i^{1D}} \right)}, \end{equation} where \[\kappa _i^{1D} = \frac{{{\kappa ^{1D}}}}{{\sum {{\kappa ^{1D}}} }},{\kappa ^{1D}} = \frac{1}{{{N_1}}}\sum\limits_{i = 1}^{{N_1}} {\kappa _i^{1D}} ,\] \[\kappa _i^{2D} = \frac{{{\kappa ^{2D}}}}{{\sum {{\kappa ^{2D}}} }},{\kappa ^{2D}} = \frac{1}{{{N_1}}}\sum\limits_{i = 1}^{{N_1}} {\kappa _i^{2D}}. \] Once the network was trained and the optimal condition of network optimization was achieved, the fairness among different features will be achieved at optimum \cite{sugiyama2007covariate, donini2018empirical}. With fine-grained features as shown above, we will use standard Softmax regression, \begin{equation} \label{fusion4} {J_s} = \mathop {\min }\limits \left( { - \frac{1}{M}\sum\limits_{i = 1}^M {\sum\limits_{j = 1}^K {{1_{\left\{ {{y_i} = j} \right\}}}\log \frac{{{e^{{{\left( {\kappa _j^{Fussed}} \right)}^T}{{\bf{x}}_i}}}}}{{\sum\limits_{j = 1}^K {{e^{{{\left( {\kappa _j^{Fussed}} \right)}^T}{{\bf{x}}_i}}}} }}} } } \right), \end{equation} to train the network at the training stage and finally obtain the estimates for the HAR activities. In \eqref{fusion4}, $1(.)$ denotes the indicator function whose value will be 1 if the condition ${{y_i} = j}$ is satisfied, otherwise 0. \subsection{Signal Denoising in Two Pathways} \label{sdtp} To reduce the effect of noise that inevitably contained in the IMU signals, we are trying to reconstruct the IMU signals in two pathways by solving the following minimization function: \begin{equation} \label{sdtp1} {J_r} = \begin{array}{*{20}{c}} {\mathop {\min }\limits_{\bf{W}} }&{\frac{1}{2}\sum\nolimits_{k = 1}^K {\left\| {{\bf{\hat x}}_k^{1D} - {\bf{x}}_k^{T}} \right\|_2^2} } + \sum\nolimits_{k = 1}^K {\left\| {{\bf{\hat x}}_k^{2D} - {\bf{x}}_k} \right\|_2^2} \end{array}, \end{equation} where \[{\bf{\hat x}}_k^{1D} = {g^{1D}} {\left( {{{\left( {{{\bf{W}}^{1D}}} \right)}^{'}},\kappa _i^{1D}} \right)}\] and \[{\bf{\hat x}}_k^{2D} = {g^{2D}}\left( {{{\left( {{{\bf{W}}^{2D}}} \right)}^{'}},\kappa _i^{2D}} \right)\] are outputs (reconstructed signals) of the proposed 2D-CNNs and 1D-CNNs, respectively. The functions ${g^{2D}}$ and ${g^{1D}}$ denote the models of a multiple-layer 2D-DCNN and 1D-DCNN, respectively. We will present in detail about ${g^{2D}}$ and ${g^{1D}}$ in Section \ref{sec:3}. ${\bf{W}} = \left\{ {{{\left( {{{\bf{W}}^{2D}}} \right)}^{'}},{{\left( {{{\bf{W}}^{1D}}} \right)}^{'}}} \right\}$, are the corresponding parameters (weight matrices and bias vectors) in the 2D/1D networks. The design in \eqref{sdtp1} enables us to denoise the IMU signals in two distinct pathways, improving the robustness of the proposed algorithm. \subsection{Overall Network Parameters Optimization} With above technical analysis, we obtain the final objective function which acts as the general rule for the network parameters learning as \begin{equation} \label{onpo_1} \begin{array}{*{20}{c}} {\mathop {\min }\limits_{\bf{W}} }&{{J_s} + {\beta _1}{J_r} + {\beta _2}\Psi \left( {\bf{W}} \right)} \end{array} + {\beta _3}DKL\left( {\kappa _i^{2D},\kappa _i^{1D}} \right), \end{equation} where ${\bf{W}}$ are network parameters in all considered networks and ${\left\{ {{\beta _k}} \right\}_{k = 1,2,3}}$ are auxiliary variables that are used for balancing each penalty in \eqref{onpo_1}. ${\Psi \left( {\bf{W}} \right)}$ is an regularization on the model parameters (${{{\bf{W}}_i}}$ are the ensembles of $i$-th network weights and bias), which is defined as follows, \begin{equation} \label{23434} \Psi \left( {\bf{W}} \right) = \sum {{{\left\| {{{\bf{W}}_i}} \right\|}^2}}, \end{equation} The network parameters will be updated using the stochastic gradient descent strategy \cite{lecun2015deep} with a dynamic learning rate scheme, which will be elaborated in the following section. \subsection{Knowledge Transfer from Synthetic to Real IMU Data} \begin{algorithm}[!t] \DontPrintSemicolon \KwIn{AMASS: $\left\{ {{\bf{x}}_{train}^{A},{\bf{y}}_{train}^{A}} \right\}$, $\left\{ {{\bf{x}}_{eval}^{A},{\bf{y}}_{eval}^{A}} \right\}$; \\ DIP: $\left\{ {{\bf{x}}_{train}^{D},{\bf{y}}_{train}^{D}} \right\}$, $\left\{ {{\bf{x}}_{eval}^{D}} \right\}$} \KwOut{Activity estimates for DIP: ${{\bf{\hat y}}_{eval}^A}$} Initialize the weights and bias (${\bf W}$) using Xavier initialization; \\ $i \gets 0, lr \gets 0.001, factor = 0.99 $\; \While{$i \leq max_{iter}$ or {Convergent}}{ Get mini batch data in AMASS;\\ $i \gets i + 1$\; Update ${\bf W}$ according to \eqref{onpo_1}; \\ \If{mod(i, 100) = 0}{$lr = lr*factor$} Calculate ${{\bf{\hat y}}_{eval}^A}$ according to \eqref{fusion4} and examine convergence; } \Return{${{\bf{\hat W}}}$}\; Initialize the weights and bias in fusion layer using Xavier initialization; \\ Initialize the weights and bias in other layers with ${{\bf{\hat W}}}$; \\ \While{$i \leq max_{iter}$ or {Convergent}}{ Get mini batch data in DIP;\\ $i \gets i + 1$\; Update ${\bf W}$ according to \eqref{onpo_1}; } Calculate ${{\bf{\hat y}}_{eval}^D}$ according to \eqref{fusion4}; \Return{${{\bf{\hat y}}_{eval}^D}$}\; \caption{{\sc Knowledge Transfer Algorithm}} \label{alg1} \end{algorithm} As shown in Section \ref{SID}, we have created a very large synthetic IMU data (AMASS) based on the recently released AMASS dataset, containing abundant human poses. The knowledge transfer from synthetic IMU data to the real one is enabled by the mechanism of the transfer learning \cite{torrey2010transfer}, which is summarized in Algorithm. \ref{alg1}. So far, we have introduced the design of the proposed network model. We will evaluate its performance with numerous experiments in the following. \section{Implementations and Discussions} \label{ID} Combining the related theories of feature extraction, fusion and signal reconstruction introduced earlier, we now briefly explain the network parameters and structure. \subsection{Network parameters specification} The network architecture consists of five single-domain modules: a 1D-CNN encoder, a 1D-CNN decoder, a 2D-CNN encoder, a 2D-CNN decoder and a feature fusion classifier. In the first module, the input IMU data in the mini-batch has a dimension of $36\times60$, which means the data in the time-domain were assigned in the sub-channels, leading to effective extraction of latent feature in the spatial-domain. Besides, the 1D-CNN encoder has four 1-strided 1D-convolutional layers, which reduce the input size from 60 to 48, and change the channel from 36 to 128. Next, the convolutional feature of dimension $128\times48$ were flattened into $6144\times1$ to obtain 1D latent features. The 1D-CNN decoder contains four 1-strided transposed 1D-convolutional layers, which restore the IMU data from 48 to 60, and change the channel from 128 to 36. Before passing the 4 transpose layers, the feature data needs to be reshaped to $64\times128$. The 1D-CNN module and its transposed version comprise first pathway for IMU data construction. The second signal reconstruction way includes two network single-domain modules: a four-layer 2D-CNN encoder and a four-layer 2D-CNN decoder. The input has a dimension of $1\times60\times36$, which means the input IMU data were allocated in one sub-channel to obtain the connectivity pattern of all sensors in one time window. The 2D-CNN encoder has two 2-strided 2D-convolutional layers and two 1-strided 2D-convolutional layers, which reduce the input size from $60\times36$ to $7\times1$, and change the channel number form 1 to 96. Next, the convolutional feature data of size $96\times7\times1$ were reshaped into $672\times1$ to obtain flattened 2D features. The 2D-CNN decoder contains two 1-strided transposed 2D-convolutional layers and two 2-strided transposed 2D-convolutional layers, which restore the IMU data from $7\times1$ to $60\times36$, and change the channel number from 96 to 1. These two signal reconstruction ways were connected by a feature fusion network module, which has three kinds of forms (See detailed introductions in Section \ref{EFF}). This module takes hybrid (1D/2D) latent feature as input, and is then fed into fully connected layers to obtain the HAR activity estimates. \subsection{Convergence Performance} \label{CP} This part discusses complexities of the proposed network model in terms of its training performance. To compare the convergence speed of different methods, we define convergence as the accuracy of training during the training process reaches 99\% and remains stable for 10 epochs. In Fig. \ref{shoulian}, we compare the convergence performance of the three methods proposed in this article and a representative competing algorithm (Deep ConvLSTM). The proposed methods with three different kinds of fusion strategies are denoted by MARS-v1, MARS-v2, and MARS-v3, respectively. \begin{figure}[h] \centering \includegraphics[width=8cm]{shoulian_final-eps-converted-to.pdf} \caption{Convergence performance comparison.} \label{shoulian} \end{figure} In the experiment, we set up to 500 epochs. Among them, the training accuracy of the method MARS-v1 and the comparison algorithm Deep ConvLSTM cannot reach the set conditions in the upper limit of 500 iterations. The MARS-v2 and MARS-v3 can converge at a surprising speed whether they are directly trained on the DIP dataset or fine-tuned by the AMASS dataset pre-training model. And using the model pre-trained on the AMASS data set, through fine-tuning training on the DIP data set, it can converge only after 4 iterations. This result also shows that the proposed method has fast convergence characteristics, and the use of the pre-trained model on the AMASS data set for fine-tuning can converge in just a few iterations, which is of great significance in practical applications. \begin{table}[] \caption{\sc Train Convergence Performance Comparison} \label{shoulian_compare} \setlength{\tabcolsep}{1.2mm}{ \begin{tabular}{lclclclclcl} \hline \hline & \multirow{2}{*}{$Settings$} & \multicolumn{2}{c}{\textbf{$DIP$}} & \multicolumn{2}{c}{\textbf{$Finetune$}} \\ \cline{3-4} \cline{5-6} & & $10 Epoch $ & $200 Epoch$ & $10 Epoch$ & $200 Epoch$ \\ \hline & \textbf{Deep ConvLSTM} & 35.90\% & 94.97\% & 93.11\% & 92.69\% \\ \hline & \textbf{MARS-v1} & 97.56\% & 97.81\% & 97.96\% & 97.98\% \\ \hline & \textbf{MARS-v2} & 97.99\% & 99.96\% & 99.96\% & 100.00\% \\ \hline & \textbf{MARS-v3} & 97.51\% & 100.00\% & 99.95\% & 100.00\% \\ \hline \hline \end{tabular} } \end{table} Tab. \ref{shoulian_compare} further shows the convergence characteristics of the four methods. We compared the training accuracy of 10 epochs and 200 epochs. For Deep ConvLSTM and MARS-v1 whose training accuracy does not reach 99\% after 500 Epochs, Fig. \ref{shoulian_compare} shows that the training accuracy of all proposed methods are higher than Deep ConvLSTM under the same number of training epoch. Moreover, it is shown in Fig. \ref{shoulian_compare} that the training accuracy of all methods with knowledge transfer ( Algorithm. \ref{alg1}) can obtain satisfactory accuracy within several training epochs, which demonstrates that the efficiency of the proposed methods. \subsection{Discussions} { The general objective of HAR based on handy instruments, i.e., IMUs, is to obtain knowledge about human physical activity and then achieve intelligent control, such as smart healthcare and smart home. It is noted that the multi-modality in the non-stationary signals collected by IMUs makes it a hard way to realize robust data analysis. Besides, the scarcity of informative information aggravates pain in achieving accurate HAR. On the other hand, the deep learning-based methods pave the way for better understanding the signals. We have proposed a novel multi-domain deep learning framework through the above analysis, enabling automatic and efficient feature extraction from both the synthetic and real data. From the perspective of practical implementation, the computational complexity is a significant concern for many platforms with limited computing resources. In this work, we first trained the network with a large-size AMASS dataset, which can be completed in a control center with rich computing resources. The network model has a medium-size (about 20M) and was saved. As shown in Section \ref{CP}, with the pre-trained network parameters, experimental results on the real DIP dataset demonstrated that the proposed method could surprisingly obtain a target accuracy within few iterations, indicating the novelty of employing the virtual IMU and the effectiveness of the proposed methods. We believe this work will be beneficial for both researchers and practitioners. } \section{Experiment Results} \label{sec:4} In this section, we will introduce the experimental setup and evaluation results of the proposed method. First, we briefly describe the data set and experimental settings used in the experiment; second, we evaluate the effect of the algorithm in public datasets, and then present the experimental results of the proposed methods and several competing HAR ones. All algorithms are performed on the Pytorch platform in a workstation equipped with an Intel i7-8750 processor, 32GB memory, and eight NVIDIA GTX 1080 Ti GPUs. \subsection{Experimental Setup} In order to evaluate the effectiveness of the proposed model, we conducted extensive experiments on the datasets:AMASS and DIP, which have been introduced in Section \ref{sec:2}. It is worth noting that the IMU data in AMASS is virtual IMU data, which is obviously different from real IMU data. Therefore, in order to improve the versatility of the data set in the real scene, all our methods are pre-trained on AMASS, and then using transfer learning to fine-tune the network on the DIP data set, and finally test on the DIP datasets. \subsection{Performance Metrics} In this paper, three performance metrics \cite{torrey2010transfer, lecun2015deep}: accuracy, precision, f1-score, are employed to evaluate the final classification performance of our proposed method in HAR. $\textbf{Accuracy}$: Accuracy is the overall accuracy for all classes calculated as \begin{equation} \begin{split} Accuracy = \frac{\sum_{i=1}^{N}TP_{i}+\sum_{i=1}^{N}TN_{i}}{\splitfrac{\sum_{i=1}^{N}TP_{i}+\sum_{i=1}^{N}TN_{i}+}{\sum_{i=1}^{N}FP_{i}+\sum_{i=1}^{N}FN_{i}}}, \end{split} \end{equation} where $N$ denotes the class number. Variables $TP_{i}$, $FP_{i}$, $TN_{i}$, $FN_{i}$ are the true positives, false positives, true negatives and false negatives of the class $i$, respectively. $\textbf{Precision}$: Precision is the precision of correctly classified positive instances to the total number of instances classified as positive, which can be denoted by \begin{equation} Precision =\frac{1}{N} \sum_{i=1}^{N} \frac{TP_{i}}{TP_{i}+FP_{i}}. \end{equation} $\textbf{F1-score}$: F1-score is a key evaluation measure of classification performance, which considers both the precision and the recall of the test: \begin{equation}F1_{score}=\frac{2 \sum_{i=1}^{N} TP_{i}}{2 \sum_{i=1}^{N} TP_{i}+\sum_{i=1}^{N} FP_{i}+\sum_{i=1}^{N} FN_{i}}. \end{equation} \subsection{ Compared Algorithms} We compare the three proposed methods with the following algorithms: \par $\textbf{Random forest (RF)}$ \cite{liaw2002classification}: it refers to a classifier that constructs a multitude of decision trees to train and predict samples. \par $\textbf{LSTM}$ \cite{zebin2018human}: A multi-layer RNN network with long short-term memory has been proposed for HAR based on inertial sensor time-series. \par $\textbf{Deep ConvLSTM}$ \cite{ordonez2016deep}: This model uses a deep convolutional neural network to extract feature and a recurrent neural network to learn time dependencies. \par $\textbf{Xiao2019}:$ In \cite{xiao2020deep}, a deep convolutional autoencoder based network have been proposed for HAR based on the DIP dataset. \subsection{Overall Performance Comparison} \label{opc} In this experiment, we select the data of three inertial sensors at the head, left wrist and right leg for training and testing. The specific data organization is shown in Tab. \ref{3IMUform}. Where Acc represents acceleration, Ori represents the rotation matrix measured by IMU. \begin{table}[] \caption{\sc IMU Data Organization Form} \label{3IMUform} \begin{tabular}{llllll} \hline \hline Acc\_head & Ori\_head & Acc\_wrist & Ori\_wrist & Acc\_knee & Ori\_knee \\ \hline \multicolumn{1}{c}{1$\sim$3} & \multicolumn{1}{c}{4$\sim$12} & \multicolumn{1}{c}{13$\sim$15} & \multicolumn{1}{c}{16$\sim$24} & \multicolumn{1}{c}{25$\sim$27} & \multicolumn{1}{c}{28$\sim$36} \\ \hline \hline \end{tabular} \end{table} For the AMASS dataset and DIP dataset, we organize them according to the format as shown in Tab. \ref{3IMUform}. Besides, we use the AMASS dataset for training to obtain pre-training models of all employed networks. Then, we use the pre-trained model on the AMASS data set to initialize the new network weights, and then perform the knowledge transfer according to Algorithm. \ref{alg1} for the DIP dataset and get the test results. \begin{figure*}[!ht] \subfigure[The result of MARS-v2 without fine-tuning]{ \includegraphics[width=8cm]{Pro2_3IMU_mat-eps-converted-to.pdf}} \subfigure[The result of MARS-v2 with fine-tuning]{ \includegraphics[width=8cm]{Pro2_3IMUFinetune_mat-eps-converted-to.pdf}} \\ \subfigure[The result of MARS-v3 without fine-tuning]{ \includegraphics[width=8cm]{Pro3_3IMU_mat-eps-converted-to.pdf}} \subfigure[The result of MARS-v3 with fine-tuning]{ \includegraphics[width=8cm]{Pro3_3IMUFinetune_mat-eps-converted-to.pdf}} \caption{Confusion matrices illustration in the first case (3 IMUs).} \label{level} \end{figure*} \begin{figure*}[] \subfigure[MARS-v1]{ \includegraphics[width=6cm]{Pro1_6IMU_mat-eps-converted-to.pdf}} \label{221} \subfigure[MARS-v2]{ \includegraphics[width=6cm]{Pro2_6IMU_mat-eps-converted-to.pdf}} \label{222} \subfigure[MARS-v3]{ \includegraphics[width=6cm]{Pro3_6IMU_mat-eps-converted-to.pdf}} \label{223} \caption{Confusion matrices illustration in the second case (6 IMUs). } \label{22} \end{figure*} \begin{table}[!ht] \caption{\sc Overall Performance Comparison Result} \label{demo0} \centering \begin{tabular}{c|c|c|c|c} \hline \hline \textbf{Classifier} & \textbf{Dataset} & \textbf{Accuracy} & \textbf{F1-score} & \textbf{Precision} \\ \hline \textbf{Random Forest} & DIP & \textbf{83.20\%} & \textbf{82.86\%} & \textbf{83.50\%} \\ \hline \textbf{\multirow{2}{*}{LSTM}} & DIP & \textbf{80.34\%} & \textbf{82.57\%} & \textbf{80.86\%} \\ \cline{2-5} & DIP/AMASS & 73.63\% & 77.28\% & 74.77\% \\ \hline \textbf{\multirow{2}{*}{Deep ConvLSTM}} & DIP & 78.33\% & 79.31\% & -\% \\ \cline{2-5} & DIP/AMASS & \textbf{84.80\%} & \textbf{85.12\%} & \textbf{-\%} \\ \hline \textbf{\multirow{2}{*}{Xiao2019}} & DIP & 89.08\% & 89.16\% & -\% \\ \cline{2-5} & DIP/AMASS & \textbf{91.15\%} & \textbf{91.21\%} & \textbf{-\%} \\ \hline \textbf{\multirow{2}{*}{MARS-v1}} & DIP & 91.19\% & 90.35\% & 89.87\% \\ \cline{2-5} & DIP/AMASS & \textbf{93.81\%} & \textbf{92.88\%} & \textbf{92.00\%} \\ \hline \textbf{\multirow{2}{*}{MARS-v2}} & DIP & 91.75\% & 91.77\% & 92.53\% \\ \cline{2-5} & DIP/AMASS & \textbf{94.50\%} & \textbf{94.46\%} & \textbf{94.47\%} \\ \hline \textbf{\multirow{2}{*}{MARS-v3}} & DIP & 93.94\% & 93.93\% & 94.09\% \\ \cline{2-5} & DIP/AMASS & \textbf{95.81\%} & \textbf{95.84\%} & \textbf{95.93\%} \\ \hline \hline \end{tabular} \end{table} Tab. \ref{demo0} summarizes the comparison of all algorithms in terms of three performance metrics. It has been shown in Tab. \ref{demo0} that the proposed methods perform favorably over all competing ones when only DIP dataset is available. All three proposed methods can achieve an accuracy of more than 90\% while the comparison algorithm can only achieve a recognition accuracy of 83\%. This result can be explained by the effectiveness of the denoising design and fusion strategies embedded in the proposed methods. Specially, the spatio-temporal feature of the considered dataset can be effectively extracted by the proposed method. On the other hand, the LSTM based algorithm is good at capturing the dependency in real time series data but ignore the spatial information, resulting in decreased HAR results. What's more, with AMASS dataset, one can perform the knowledge transfer according to Algorithm. \ref{alg1} for all considered deep learning based methods. The results in Tab. \ref{demo0} shows that the knowledge learned from AMASS dataset is beneficial for boosting the performance of deep learning based HAR algorithms except LSTM, demonstrating the adaption of knowledge transfer can bridge the gap between virtual and real IMU datasets. In order to fully display the test results of various methods, we show the confusion matrix of MARS-v2 and MARS-v3 on the DIP dataset in Fig. \ref{level}. The result shows that the action of Jumping is recognized with the lowest accuracy of 55\%/71\% in MARS-v2 / MARS-v3 without fine-tuning. Jumping is mainly incorrectly labeled as Upper body (39\%/23\%). This error is caused by the complex structure (composite activities) of the Jumping category. For example, the Jumping action in the DIP data set is actually defined as opening and closing jump, which causes the recognition misjudgment between Jumping and Upper body category. Moreover, from the confusion matrix in Fig. \ref{level}, there is an ambiguity between Locomotion and Lower body category. On the other hand, after fine-tuning, the recognition accuracy of Jumping and Locomotion categories has been respectively increased by 10\%/6\% and 14\%/4\%, reaching 65\%/77\% (Jumping) and 96\%/93\% (Locomotion). These result prove that the rich features obtained from the AMASS dataset can boost the performance of the HAR task in real scene. \subsection{Effect of Sensor Numbers} For the results shown in Section \ref{opc}, we conducted experiments based on 3 sensors (head, left wrist and right leg). In order to further demonstrate the advantages of using the AMASS dataset, we select more sensors in different locations, which are explained in Tab. \ref{s3456s}. It is noted that when five IMUs are selected, the location of the fifth IMU can be placed on the right wrist or left leg. The specific wearing position and the organization of the collected data are shown in Tab. \ref{s3456s}. \begin{table}[] \caption{\sc Multi-sensor Data Organization Form} \setlength{\tabcolsep}{1mm}{ \label{s3456s} \centering \begin{tabular}{lllllll} \hline \hline & \textbf{Head} & \textbf{R\_Knee} & \textbf{L\_Wrist} & \textbf{Spine} & \textbf{L\_Knee} & \textbf{R\_Wrist} \\ \hline \textbf{3IMU} & 1$\sim$12 & 13$\sim$24 & 25$\sim$36 & & & \\ \textbf{4IMU} & 1$\sim$12 & 13$\sim$24 & 25$\sim$36 & 37$\sim$48 & & \\ \textbf{5IMU\_knee} & 1$\sim$12 & 13$\sim$24 & 25$\sim$36 & 37$\sim$48 & 49$\sim$60 & \\ \textbf{5IMU\_wrist} & 1$\sim$12 & 13$\sim$24 & 25$\sim$36 & 37$\sim$48 & & 49$\sim$60 \\ \textbf{6IMU} & 1$\sim$12 & 13$\sim$24 & 25$\sim$36 & 37$\sim$48 & 49$\sim$60 & 61$\sim$72 \\ \hline \hline \end{tabular} } \end{table} In this experiment, the classification performance metrics, including accuracy, F1 scores, and precision, were adopted in the evaluation, and the experimental results were given in Tab. \ref{demo1}. \begin{table}[!htbp] \caption{\sc Performance Comparison of Proposed Methods with different numbers of IMUs} \setlength{\tabcolsep}{1mm}{ \label{demo1} \centering \begin{tabular}{c|c|c|c|c|c} \hline \hline \textbf{Classifier} & \textbf{IMU Number} & \textbf{Dataset} & \textbf{Accuaary} & \textbf{F1-score} & \textbf{Precision} \\ \hline \textbf{\multirow{6}{*}{MARS-v1}} &\multirow{2}{*}{3} & DIP & 91.19\% & 90.35\% & 89.87\% \\ \cline{3-6} & & \textbf{DIP/AMASS} & \textbf{93.81\%} & \textbf{92.88\%} & \textbf{92.00\%} \\ \cline{2-6} &4 & DIP & 91.94\% & 91.02\% & 90.40\% \\ \cline{2-6} &5-knee & DIP & 92.19\% & 91.46\% & 91.13\% \\ \cline{2-6} &5-wrist & DIP & 93.44\% & 92.68\% & 92.47\% \\ \cline{2-6} &\textbf{6} & \textbf{DIP} & \textbf{95.00\%} & \textbf{95.01\%} & \textbf{95.15\%} \\ \hline \textbf{\multirow{6}{*}{MARS-v2}} &\multirow{2}{*}{3} & DIP & 91.75\% & 91.77\% & 92.53\% \\ \cline{3-6} & & \textbf{DIP/AMASS} & \textbf{94.50\%} & \textbf{94.46\%} & \textbf{94.47\%} \\ \cline{2-6} &4 & DIP & 92.69\% & 92.73\% & 92.59\% \\ \cline{2-6} &5-knee & DIP & 94.44\% & 94.47\% & 94.95\% \\ \cline{2-6} &5-wrist & DIP & 94.13\% & 94.19\% & 94.68\% \\ \cline{2-6} &\textbf{6} & \textbf{DIP} & \textbf{95.81\%} & \textbf{95.82\%} & \textbf{95.94\%} \\ \hline \textbf{\multirow{6}{*}{MARS-v3}} &\multirow{2}{*}{3} & DIP & 93.94\% & 93.93\% & 94.09\% \\ \cline{3-6} & & \textbf{DIP/AMASS} & \textbf{95.81\%} & \textbf{95.84\%} & \textbf{95.93\%} \\ \cline{2-6} &4 & DIP & 94.00\%& 93.99\%& 94.22\% \\ \cline{2-6} &5-knee & DIP & 95.31\% & 95.26\% & 95.45\% \\ \cline{2-6} &5-wrist & DIP & 95.19\% & 95.21\% & 95.34\% \\ \cline{2-6} & \textbf{6} & \textbf{DIP} & \textbf{96.06\%} & \textbf{96.04\%} & \textbf{96.05\%} \\ \hline \hline \end{tabular} } \end{table} In Tab. \ref{demo1}, the notations ``DIP" and ``DIP/AMASS" are referred to the cases that the network training is based solely on the DIP dataset and jointly on the DIP \& AMASS datasets, respectively. Besides, for the case of ``DIP/AMASS", we train the network based on the AMASS and then fine-tune the network parameters with DIP. From Tab. \ref{demo1}, it is clear that the accuracies of HAR improve with an increase in the number of sensors. The MARS-v3 can obtain the best performance for any number of IMUs in both cases, demonstrating the effectiveness of the proposed fusion scheme for the obtained latent features in various domains. Besides, from Fig. \ref{Zhexian} and Tab. \ref{demo1}, we can see that the proposed methods' accuracy using six IMUs is higher than 95\%, especially MARS-v3, which can reach 96.06\%. Besides, we can find that the use of 6 IMUs will improve the HAR results in each category compared to that of 3 IMUs. Moreover, as the number of sensors increases, the ambiguity between the Locomotion category and the Lower body category is reduced. However, the ambiguity between the Jumping category and the Upper body category still exists. \begin{figure}[!htbp] \centering \includegraphics[width=8cm]{3456-eps-converted-to.pdf} \caption{HAR accuracy comparison using different numbers of IMUs.} \label{Zhexian} \end{figure} Next, we compare the multi-sensor results with fine-tuned results with three IMUs according to Algorithm \ref{alg1}. Tab. \ref{demo1} and Fig. \ref{histogram} show the comparison between fine-tuned results and the multi-sensor results without the fine-tuning. HAR accuracies of all three proposed methods with three IMUs achieve that with using 6 IMUs. This can be explained by noticing the fact that AMASS contains abundant action features, which encourages effective feature extraction. Besides, combing with the proposed feature fusion and transfer strategies, it would not be surprising that HAR results with only 3 IMUs (with fine-tuning) can suppress that using 6 IMUs (without fine-tuning). We will end this section by providing some discussions. It can be seen from the analysis above that since each type of action in the DIP dataset contains many complex composite activities, which results in poor classification performance for some activity, such as Jumping. Increasing the number of wearable sensors seems an effective way to improve the performance of HAR. For example, when using three sensors, the result of training directly on the DIP is 93.94\%. However, a classifier trained with four sensors has little improvement (0.06\%) in recognition performance. This is because we placed the fourth sensor on the human spine, which contributed relatively little to the HAR in the DIP dataset. After that, when placing the sensor at the knee or wrist, HAR's accuracy will increase to a more considerable extent. The recognition accuracy using five IMUs can reach more than 95\%, which is slightly lower than the result after fine-tuning (95.81\%). As shown in Fig. 8, the recognition accuracy of the proposed methods after fine-tuning reached the result of training using five or six sensors. Therefore, our methods can achieve considerable accuracy while avoiding the intrusion caused by too many sensors, which are favorable to practical applications. \begin{figure}[!htbp] \centering \includegraphics[width=8cm]{36-eps-converted-to.pdf} \caption{Human activity recognition accuracy comparison histogram.} \label{histogram} \end{figure} \section{Conclusion and Future Work} \label{sec:5} This paper innovatively created a big dataset using virtual IMUs based on the recently released AMASS dataset. To achieve complex HAR in the real scene, we have proposed multiple-domain deep learning methods, consisting of a hybrid feature extractor, comprehensive feature fusion, and transfer module. Extensive experimental results based on the real DIP dataset proved that our proposed methods compare favorably over other competing ones. Significantly, the synthetic AMASS dataset is beneficial for all considered methods to achieve efficient and effective HAR. The proposed methods have dramatically faster training speed and higher recognition accuracy than other comparison methods, reaching 93.81\% and 94.50\% and 95.81\% accuracy. Moreover, combing with the scheme of fine-tuning, the proposed methods with three IMUs can obtain a comparable HAR accuracy obtained from the ones with six IMUs and without fine-tuning, demonstrating again the effectiveness of proposed methods and the novelty of adopting virtual IMU data to realize real HAR. We will build a more extensive dataset using more virtual IMUs and release it for shared research in our future work. We will also report the HAR results with more datasets and use more methods, such as light-weight neural networks. \section*{Acknowledgement} This work was supported by the National Nature ScienceFoundation of China (NSFC) under Grants: No. 61873163 and No. 61871265.
{'timestamp': '2020-10-12T02:20:13', 'yymm': '2009', 'arxiv_id': '2009.09404', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09404'}
arxiv
\section{Introduction} Digital design tools like Illustrator or Photoshop are widely used nowadays. Though having considerable user demand, they require prior knowledge and multiple steps to use successfully. These applications would significantly improve the accessibility if they can automatically perform corresponding editing actions based on the language instructions given by users for each step. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{imgs/fig_task.pdf} \vspace{-3ex} \caption{An example of the iterative language-based image editing (ILBIE) task. During each turn, the model edits the image from the previous turn based on the current instruction. Eventually, a desired image is accomplished after iterative editing. Note that the generation is at the pixel level.} \label{fig:task} \vspace{-3ex} \end{figure} Iterative language-based image editing (ILBIE) task follows iterative instructions to edit images step by step, as illustrated in Fig.~\ref{fig:task}. To accomplish ILBIE, models are required not only to modify images but also to understand the visual differences between the previous and resulting image, based on the given instructions. One of the primary limitations of ILBIE is data scarcity. Since collecting large-scale previous-resulting images with instructions is difficult, it makes learning the association between vision and language challenging. A GAN-based \cite{goodfellow2015gan} model, GeNeVA~\cite{nouby2019geneva}, is proposed to perform ILBIE, where a conditional generator serves as the image editor, and a discriminator provides the training loss by discriminating a resulting image. Though it yields promising results, GeNeVA neglects the data scarcity issue of ILBIE. As a binary classifier, the discriminator easily suffers from data scarcity given the shortage of ground-truth instruction-and-resulting-image pairs and thus limits the model's generalization ability to new instructions. Despite lacking prior experiences with images or instructions, humans can still accomplish editing under unfamiliar image-instruction pairs. For example, for a given instruction ``add a purple cube in front of the blue cylinder", humans can think about the resulting image if the instruction changed to ``adding a blue square" or ``on the right of". This process is known as counterfactual thinking \cite{roese1997ctf}, which allows humans to operate in data-scarce scenarios by considering alternative instructions from the seen examples. In this paper, we introduce self-supervised counterfactual reasoning (SSCR) that incorporates counterfactual thinking to deal with the data scarcity issue. SSCR allows the model to think about expected, resulting images under unseen instructions. Since there are no ground-truth resulting images, we propose cross-task consistency (CTC), which adopts an iterative explainer to reconstruct the instruction of each step. With CTC, we can supply detailed token-level training loss (e.g., wrong objects or wrong positions), which is better than only using the discriminator, and consider these counterfactual instructions in a self-supervised scenario. The experimental results on i-CLEVR~\cite{nouby2019geneva} and CoDraw~\cite{kim2019codraw} show that our SSCR can improve the correctness of the ILBIE task in both aspects of object identity and position. In summary, our contributions are three-fold: \begin{itemize}[noitemsep, topsep=2pt] \item We introduce SSCR that incorporates counterfactual thinking into the ILBIE task to deal with the data scarcity issue. \item The proposed cross-task consistency (CTC) and counterfactual reasoning methods help train the generator better, improve the generalizability, and achieve the SOTA results on i-CLEVR and CoDraw. \item Extensive ablation studies show that SSCR is effective even with only partial training data. \end{itemize} \section{Related Work} \noindent\textbf{Text-to-Image} (T2I) generates an image that matches the given instruction. T2I is challenging yet important that has a vast potential in practical applications like art generation or automatic design \cite{nguyen2017langevin,reed2017pixcelcnn, tan2019t2s}. With the success of a generative adversarial network \cite{goodfellow2015gan} on the image generation task, several works \cite{reed2016t2i-gan,zhang2017stack-gan, xu2018att-gan} introduce different GAN-based models to synthesize an image from a text description. Unlike T2I, we focus on image editing, where a model needs to understand the visual differences between two images rather than generating an image from scratch. \noindent\textbf{Language-based Image Editing} (LBIE) tasks a model to edit an image based on the guided text description. PixelTone \cite{laput2013pixel-tone} and Image Spirit \cite{cheng2013image-spirit} are both rule-based, which accept only pre-defined instructions and semantic labels that can significantly decrease the practicality of LBIE. Some studies \cite{chen2018lbie-ram,shinagawa2017edit-mnist} adopt the conditional GAN model to attend on the instruction and perform LBIE as image colorization. However, image colorization is not truly an editing task since it only supports fixed object templates, and the objects and the scene of the image remain the same after editing. In contrast, the editing processes of Photoshop or Illustrator are not accomplished in a single pass. GeNeVA \cite{nouby2019geneva} proposes an iterative GAN-based generator to accomplish iterative language-based image editing (ILBIE) but neglects the data scarcity issue. \noindent\textbf{Counterfactual Thinking} ~\cite{roese1997ctf} is a concept that refers to the human propensity to consider possible alternatives to events that have happened already. People can consider different outcomes from a wide range of conditions and engage in causal reasoning by asking questions like ``What if ...?" or ``If I had only...." Previous works \cite{kusner2017ctf-fair,garg2019ctf-tc} have shown how counterfactual fairness improves the robustness of the model and makes it more explainable. Furthermore, counterfactual thinking has also been applied to augment training targets \cite{zmigrod2019ctf-da,fu2020aps}. In this paper, we incorporate counterfactual thinking into that ILBIE task that considers counterfactual instructions to deal with the data scarcity issue and improve the generalizability. \begin{figure*}[t] \centering \includegraphics[width=\linewidth]{imgs/fig_overview.pdf} \vspace{-3ex} \caption{An overview of our self-supervised counterfactual reasoning (SSCR). The iterative editor modifies an image based on current instruction and editing history. Counterfactual reasoning allows the model to think about various counterfactual instructions that can improve the generalizability and deal with data scarcity. Since there are no ground-truth images, we propose cross-task consistency (CTC) to not only provide explicit training signal but also train these counterfactual instructions self-supervisedly.} \label{fig:overview} \vspace{-3ex} \end{figure*} \section{Self-Supervised Counterfactual Reasoning (SSCR)} \vspace{-1ex} \subsection{Task Definition} During each turn $t$, an editor edits the image from the previous turn $V_{t-1}$ into the current turn $V_t$ based on instruction $I_t$. After a final turn $T$, we get the predicted final image $V_T$ and evaluate the outcome with the ground truth resulting image $O_T$. Note that the editing process is at a pixel level where the model has to generate each pixel of the image: \begin{equation} \begin{split} V_t &= \text{Editor}(V_{t-1}, I_t), \\ \text{eval} &= \text{Compare}(V_T, O_T). \end{split} \end{equation} \subsection{Overview} To overcome data scarcity, we introduce self-supervised counterfactual reasoning (SSCR). The overall framework is illustrated in Fig,~\ref{fig:overview}. The iterative editor is a conditional generator that modifies an image based on current instruction and editing history. Counterfactual reasoning allows the model to think about the expected, resulting images under various counterfactual instructions. In this way, the editor can consider more diverse instructions than the original data to improve the generalizability, even if under data scarcity. Since there are no ground-truth resulting images for these counterfactual instructions, we propose cross-task consistency (CTC). CTC adopts an iterative explainer to reconstruct the given instruction of each editing step. With the help of this cross-task matching, we can not only provide a detailed token-level training signal to train the editor better but also supply training loss for counterfactual reasoning in a self-supervised scenario. \subsection{Iterative Editor} Similar to GeNeVA \cite{nouby2019geneva}, the iterative editor is a GAN-based architecture that contains a conditional generator $G$ and a discriminator $D$. We first apply a bidirectional GRU \cite{chung2014gru} to encode the instruction $I_t$ as $d_t$ for each turn $t$. And another GRU is used to encode the history of instructions $h_t$ as following: \begin{equation} h_t = \text{GRU}(d_t, h_{t-1}). \end{equation} Then, to perform the editing for turn $t$, we adopt a convolutional neural network (CNN) \cite{miyato2018res-block} to extract image features $f_{t-1}$ from the previous image $V_{t-1}$, concatenate with the instruction history $h_t$, and feed into $G$ to predict the resulting image $V_{t}$: \begin{equation} V_t = G([f_{t-1}, h_t]). \end{equation} After all iterations, there is the final image $V_{T}$ after the final turn $T$. For each turn, $D$ provides a binary training signal by discriminating a resulting image that is generated from either $G$ or the ground-truth data according to the instruction history $h_t$: \begin{equation} \label{eq:lg} L_G = \sum_{t=1}^{T} \mathbb{E}_{V_t \sim \mathcal{P}_{G_t}}[\log(D([V_t, h_t]))], \end{equation} where $L_G$ is the binary loss from $D$. For training $D$, similar to T2I \cite{reed2016t2i-gan}, we add additional [real image, wrong instruction] pairs as false examples: \begin{equation} \label{eq:ld} L_D = \sum_{t=1}^{T} L_{D_{\text{real}_t}}+\frac{1}{2}(L_{D_{\text{false}_t}}+L_{D_{\text{wrong}_t}}), \end{equation} where \begin{equation} \begin{split} L_{D_{\text{real}_t}} &= \mathbb{E}_{O_t \sim \mathcal{P}_\text{data}}[\log(D([O_t, h_t]))], \\ L_{D_{\text{false}_t}} &= \mathbb{E}_{V_t \sim \mathcal{P}_{G_t}}[\log(1-D([V_t, h_t]))], \\ L_{D_{\text{wrong}_t}} &= \mathbb{E}_{O_t \sim \mathcal{P}_\text{data}}[\log(1-D([O_t, h'_t]))], \end{split} \end{equation} with ground-truth data distribution $\mathcal{P}_\text{data}$ and $h'_t$ being the wrong instruction history by randomly selecting another instruction. Then $G$ and $D$ are optimized through an alternating minmax game: \begin{equation} \begin{split} \max_{G} & \min_{D} L_G+L_D. \end{split} \end{equation} \subsection{Cross-Task Consistency (CTC)} Though we can train the iterative editor for ILBIE, $D$ only supports a binary training loss, which is not explicit enough to express the complex association between the visual difference and the text description. To supply a more explicit training loss, we propose cross-task consistency (CTC). Despite being image generation, we consider instruction generation, which explains the visual difference between previous-resulting image pairs, to do reasoning for the editing process in a cross-task scenario. During CTC, an iterative explainer provides a token-level training signal that encourages the matching between the predicted image and the original instruction. \paragraph{Iterative Explainer} Our iterative exaplainer $E$ is an instruction decoder which considers previous-resulting image pair and the instruction history as input, as shown in Fig.~\ref{fig:explainer}: \begin{equation} \hat{I_t} = E(V_t, V_{t-1}, h_{t-1}). \end{equation} Similar to the iterative editor, we apply CNN to extract visual feature $f$ for both previous and predicted resulting image: \begin{equation} f_{t-1} = \text{CNN}(V_{t-1}), f_t = \text{CNN}(V_t). \end{equation} \begin{figure}[t] \centering \includegraphics[width=\linewidth]{imgs/fig_explainer.pdf} \vspace{-3ex} \caption{The architecture of our iterative explainer. We consider the previous-resulting image pair and the encoded instruction history as input to reconstruct the editing instruction by an attention-based GRU decoder.} \label{fig:explainer} \vspace{-3ex} \end{figure} Then, a GRU serves as an attention-based language decoder \cite{xu2015att} which reconstructs the instruction $\hat{I_t}$ according to the feature difference and instruction history $h_{t-1}$ of previous turn: \vspace{-2ex} \begin{equation} \begin{split} g_0 = [f_d, h_{t-1}],\\ \hat{w_i}, g_i = \text{GRU}(w_{i-1}, g_{i-1}), \\ \hat{I_t} = \{\hat{w_1}, \hat{w_2}, ..., \hat{w_L}\}, \end{split} \end{equation} where $f_d = f_t-f_{t-1}$ represents the visual difference by subtracting previous and result feature, $g_i$ is the decoding history, and $\hat{w_i}$ is the predicted word token of the instruction. All $w_i$ are combined as the reconstruction where $L$ is the length of the instruction. The iterative explainer considers not only the visual difference but also instruction history so that we can reconstruct the instruction, which explains the editing of the resulting image following by the editing history. Finally, we provide an explicit token-level training signal $L_E$ by computing the teacher-forcing loss \cite{williams1989tf} between the original instruction $I_t$ and the reconstructed one $\hat{I_t}$: \begin{equation} \label{eq:le} L_E = \sum_{i=1}^{L}\text{CELoss}(\hat{w_i}, w_i), \end{equation} where $w_i$ is the $i$th token of $I_t$ and CELoss means the cross-entropy loss. By minimizing $L_E$, $G$ learns to match the original instruction with this cross-task consistency. Different from $L_G$, which only supplies binary but vague loss, $L_E$ provides token-level loss about the information of the wrong object or wrong position (by comparing $\hat{w_i}$ with $w_i$) that can train $G$ better for each editing turn. In the experiments, $E$ is pre-trained by the ground-truth image pairs and is fixed during the following training. \begin{table}[t] \small \centering \begin{tabular}{ccc} \toprule Dataset & Token Type & Example \\ \midrule \multirow{3}{*}{i-CLEVR} & color & blue, purple \\ & object & cylinder, cube \\ & relation & at the center, in front of \\ \midrule \multirow{3}{*}{CoDraw} & size & small, meidum \\ & object & sun, boy \\ & relation & in the middle, on the left \\ \bottomrule \end{tabular} \vspace{-1ex} \caption{Types of token on i-CLEVR and CoDraw.} \label{table:token} \vspace{-3ex} \end{table} \subsection{Counterfactual Reasoning} We assume that $\mathcal{U}$ is the available training data. Because of the practical challenge of collecting large-scale previous-resulting images with instructions, $\mathcal{U}$ suffers from data scarcity. To deal with this issue, we propose counterfactual reasoning to allow the model to consider various instructions out of the distribution of $\mathcal{U}$. For instance, an instruction $I' \sim \mathcal{U}'$ from the intervention data $\mathcal{U}'$ replaces the original instruction, and we edit the image based on the counterfactual instruction $I'$. \paragraph{Instruction Intervention} To get the intervention data $U'$ that provides diverse instructions, we do interventions on the original instructions $I$: \begin{equation} \begin{split} I, O &= \mathcal{U}, \\ I' &= \text{intervention}(I), \\ \mathcal{U}' &= \{I', O\}, \end{split} \end{equation} where $O$ is the image in the original $\mathcal{U}$. First, we apply NLTK \cite{pbird2004nltk} to parse out \textit{tokens} in the original $I$. The types of \textit{token} on i-CLEVR and CoDraw are shown in Table~\ref{table:token}. We then replace these \textit{tokens} with randomly sampled \textit{tokens} of the same type to get the counterfactual $I'$. Finally, $I'$ combines with the original image $G$ as the intervention data $\mathcal{U}'$. Our experiments show that this simple yet effective intervention makes the training data more diverse and deals with data scarcity during our counterfactual reasoning. For each turn $t$, with $I'_t$ from $U'$, we predict the counterfactual resulting image $V'_t$: \begin{equation} V'_t = G([f_{t-1}, h'_t]), \end{equation} where $h'_t$ is the counterfactual instruction history encoded from $I'$. Since there is no ground-truth image for the counterfactual instruction $I'_t$, we adopt the iterative explainer $E$ to provide counterfactual training loss $L'_E$ in a self-supervised scenario: \begin{equation} \begin{split} \label{eq:cf} \hat{I'_t} &= E(V'_t, V_{t-1}, h_{t-1}), \\ L'_E &= \sum_{i=1}^{L}\text{CELoss}(\hat{w'_i}, w'_i), \end{split} \end{equation} where $\hat{w'_i}$ and $w'_i$ are the $i$th word token. \begin{algorithm}[t] \begin{algorithmic}[1] \small \State $G$: the generator model \State $D$: the discriminator model \State $H$: the instruction history encoder \State $E$: our iterative explainer in CTC \State $\mathcal{U}$: the original training set \\ \State Pre-train RE with $\mathcal{U}$ \State Initialize G, D \\ \While{TRAIN\_EDITOR} \For{$t \gets 1$ to $T$} \State $I_t$, $O_t$ $\gets$ $\mathcal{U}$ \State $h_t$ $\gets$ $H(h_{t-1}, I_t)$ \State $V_t$ $\gets$ $G(h_t, O_{t-1})$ \Comment{teacher-forcing training} \State $\hat{I_t}$ $\gets$ $E(V_t, O_{t-1}, h_{t-1})$ \\ \State $L_G$ $\gets$ binary loss from $D$ \Comment{Eq.~\ref{eq:lg}} \State $L_E$ $\gets$ explicit loss from $E$ \Comment{Eq.~\ref{eq:le}} \State Update $G$ by maximizing $L_G-L_E$ \\ \State $L_D$ $\gets$ loss for $D$ \Comment{Eq.~\ref{eq:ld}} \State Update $D$ by minimizing $L_D$ \EndFor \EndWhile \end{algorithmic} \caption{Iterative Editor with CTC} \label{algo:ctc} \end{algorithm} \begin{algorithm}[t] \begin{algorithmic}[1] \small \While{COUNTERFACTUAL\_REASONING} \For{$t \gets 1$ to $T$} \State $\mathcal{U}'$ $\gets$ intervention($\mathcal{U}$) \State \_, $O_t$ $\gets$ $\mathcal{U}$ \State $I'_t$, \_ $\gets$ $\mathcal{U}'$ \Comment{counterfactual instruction} \\ \State $h_t$ $\gets$ $H(h_{t-1}, I_t)$ \Comment{real history} \State $h'_t$ $\gets$ $H(h_{t-1}, I'_t)$ \Comment{counterfactual history} \State $V'_t$ $\gets$ $G({h'}_t, O_{t-1})$ \Comment{counterfactual editing} \State $\hat{I'_t}$ $\gets$ $E({V'}_t, O_{t-1}, h_{t-1})$ \\ \State $L'_E$ = counterfactual loss from $E$ \Comment{Eq.~\ref{eq:cf}} \State Update $G$ by minimizing ${L'}_E$ \EndFor \EndWhile \end{algorithmic} \caption{Counterfactual Reasoning} \label{algo:sscr} \end{algorithm} By minimizing $L'_E$, the model has an opportunity to access $U'$, which is different from the original training data. With the help of our iterative explainer, SSCR improves the generalizability by reasoning diverse counterfactual instructions $I'$ even if under data scarcity. \begin{table*} \centering \small \begin{tabular}{lccccccccc} \toprule ~ & \multicolumn{4}{c}{\textbf{i-CLEVR}} & ~ & \multicolumn{4}{c}{\textbf{CoDraw}} \\ \cmidrule{2-5} \cmidrule{7-10} Method & Precision & Recall & F1 & RelSim & ~ & Precision & Recall & F1 & RelSim \\ \midrule GeNeVA & 71.01 & 42.61 & 53.26 & 30.66 & ~ & 54.38 & 54.42 & 54.40 & \underline{38.93} \\ w/ CTC only & \underline{72.24} & \underline{45.51} & \underline{55.84} & \underline{33.67} & ~ & \underline{57.69} & \underline{55.60} & \underline{56.62} & 38.68 \\ w/ SSCR & \textbf{73.75} & \textbf{46.39} & \textbf{56.96} & \textbf{34.54} & ~ & \textbf{58.17} & \textbf{56.61} & \textbf{57.38} & \textbf{39.11} \\ \bottomrule \end{tabular} \vspace{-1ex} \caption{The testing results of the baseline (GeNeVA\footnotemark[1]), with only cross-task consistency (CTC only), and with whole self-supervised counterfactual reasoning (SSCR) for both i-CLEVR and CoDraw.} \label{table:result} \vspace{-3ex} \end{table*} \subsection{Learning of SSCR} Alg.~\ref{algo:ctc} presents the learning process of training the iterative editor with CTC. Since ILBIE is also a sequential generation process, we apply the widely used teacher-forcing where we feed in the ground-truth resulting image ($O_{t-1}$) from the previous turn instead of our predicted one ($V_{t-1}$) to make the training more robust. When training the iterative editor, for each turn $t$, we adopt $G$ to perform image editing. We maximize the binary loss from $D$ ($L_G$) with minimizing the explicit token-level loss from $E$ ($L_E$) to train $G$. We also update $D$ by minimize $L_D$: \begin{equation} \begin{split} \max_{G} & \min_{D} L_G+L_D-L_E. \end{split} \end{equation} During counterfactual reasoning, as shown in Alg.~\ref{algo:sscr}, we first perform an intervention on $\mathcal{U}$ to get the counterfactual instructions ($I'$). Then, we edit the image based on $I'$. Since there is no ground-truth resulting image for the counterfactual editing, we adopt CTC to compute the cycle-consistency loss ($L'_E$) self-supervisedly. Similar to the iterative editor, we also apply teacher-forcing training (feeding in $O_{t-1}$ and $h_{t-1}$) to further update $G$. In this way, $G$ can improve the generalizability by considering the counterfactual $U'$, which is more diverse than $U$. \section{Experiments} \vspace{-1ex} \subsection{Experimental Setup} \paragraph{Datasets} We evaluate our counterfactual framework on two ILBIE datasets, i-CLEVR \cite{nouby2019geneva} and CoDraw \cite{kim2019codraw}. Each example in i-CLEVR consists of a sequence of 5 (image, instruction) pairs. The instruction describes where the object should be placed relative to existing objects. In i-CLEVR, there are 6,000, 2,000, and 2,000 examples for training, validation, and testing, respectively. CoDraw is a more difficult art-like dataset of children playing in a park. There are 58 objects and children with different poses. We use the same split as in CoDraw where 7,988, 1,002, and 1,002 are for training, validation, and testing. \paragraph{Evaluation Metrics} Standard metrics like Inception Score \cite{salimans2016is} or Frechet Inception Distance (FID) \cite{heusel2017fid} cannot detect whether the editing is correct based on the instruction \cite{nouby2019geneva}. Following GeNeVA \cite{nouby2019geneva}, we adopt F1 and RelSim to evaluate the editing result. The F1 score is based on a pre-trained object detector \cite{szegedy2016v3} (\textasciitilde 99\% accuracy on both i-CLEVR and CoDraw), which detects the objects in the predicted images that meet the ground-truth resulting images. To evaluate not only object type but also object position, we build the scene graph according to the object detector. The edges are given by the left-right and front-back relations between the vertices (objects). Then, RelSim determines how many of the ground-truth relations are in the predicted images: \begin{equation} \text{RelSim}(E_\text{gt}, E_\text{pd}) = \text{recall} \times \frac{|E_\text{pd} \cap E_\text{gt}|}{|E_\text{gt}|}, \end{equation} where $E_\text{gt}$ and $E_\text{pd}$ are relational edges for ground-truth resulting images and predicted image. Note that we only evaluate the final predicted image of each example for both F1 and RelSim. \paragraph{Baseline} We use the SOTA model GeNeVA\footnote{We reproduce the result for GeNeVA by their official GitHub repo ({https://github.com/Maluuba/GeNeVA}). We apply the default hyperparameters as them, and issue \#2 can support that the results are comparable.} as our baseline: it shares the same model architecture as our iterative editor and is trained with the GAN objective but without the cross-task consistency (CTC) and our counterfactual reasoning. \paragraph{Implementation Detail} We apply the ResBlocks \cite{miyato2018res-block} into $G$ and $D$ where the visual feature size is 1024. For our $E$, we add self-attention \cite{zhang2019sa-gan} for the concatenation of the visual difference and the encoded instruction history. We adopt Adam \cite{kingma2015adam} to optimize the iterative editor with learning rate 1e-4 for $L_G$ and $L_E$, 4e-4 for $L_D$. The learning rate of $L'_E$ during the counterfactual reasoning is 5e-5. \begin{figure*}[t] \centering \begin{minipage}{.59\linewidth} \centering \includegraphics[width=\linewidth]{imgs/fig_ratio.pdf} \vspace{-3ex} \captionof{figure}{Result comparison among baseline, with only cross-task consistency (CTC only), and with whole self-supervised counterfactual reasoning (SSCR) under different ratios of training data. Note that the iterative explainer is also pre-trained using the same available data for each result.} \label{fig:ratio} \vspace{-3ex} \end{minipage}~~~ \begin{minipage}{.39\linewidth} \centering \includegraphics[width=.8\linewidth]{imgs/fig_loss-vs.pdf} \vspace{-1ex} \captionof{figure}{The learning curve of training loss provided from the discriminator ($L_G$) and our iterative explainer ($L_E$) on i-CLEVR.} \label{fig:loss-vs} \vspace{2ex} \small \begin{tabular}{ccc} \toprule X\% Training Used & PPL & BLEU \\ \midrule 100\% & 0.1073 & 50.236 \\ ~~80\% & 0.1295 & 48.873 \\ ~~50\% & 0.1163 & 48.763 \\ \bottomrule \end{tabular} \vspace{-1ex} \captionof{table}{The PPL and BLEU of our iterative explainer with different ratios of training data on i-CLEVR.} \label{table:explainer} \vspace{-3ex} \end{minipage} \end{figure*} \subsection{Quantitative Results} Table~\ref{table:result} presents the testing F1 and RelSim results. First, with our cross-task consistency (CTC only), which provides a more explicit training signal, we can improve the baseline on the i-CLEVR dataset in terms of all metrics. In particular, CTC improves 1.2\% on precision, 2.9\% on recall, and 2.6\% on F1. Additionally, for whole self-supervised counterfactual reasoning (SSCR), which allows the model to consider out-of-distribution instructions, it brings more improvements and achieves new SOTA results, \textit{e}.\textit{g}., 56.9\% on F1 and 34.5\% on RelSim. Similar trends can be found on CoDraw. Since the instructions under CoDraw are more complex, the improvement of relation correctness (RelSim) is not as high as i-CLEVR. But for object correctness, CTC still improves baseline with 2.2\% F1, and SSCR further achieves the new SOTA on all metrics, \textit{e}.\textit{g}., 57.4\% F1 and 39.1\% RelSim. \subsection{Ablation Study} \paragraph{Under Data Scarcity} To examine the framework's effectiveness under the data scarcity scenario, we compare models trained using 100\%, 80\%, and 50\% data. Note that our $E$ is also pre-trained using the same 100\%, 80\%, and 50\% data. The results are shown in Fig.~\ref{fig:ratio}. We can observe that on both i-CLEVR and CoDraw datasets, the baseline performance drops drastically as the training data decreases, and our SSCR consistently outperforms the baseline. More importantly, the baseline severely suffers from the data scarcity issue, while SSCR is relatively resilient to data decrease and only drops 4.34 F1 score and 2.51 RelSim score (\textit{vs.} 8.73 and 6.78 reduced by the baseline) on iCLEVR when there is only 50\% data. Similar results can be observed on CoDraw. Furthermore, comparing SSCR with 50\% data and the baseline with 100\%, we can notice that our method can achieve comparable results to the baseline with only half the data used for training. Therefore, incorporating counterfactual thinking to explore out-of-distribution instructions indeed makes the model better capable of generalization and avoiding performances drops from data scarcity. Table~\ref{table:explainer} presents the performance of our iterative explainer $E$ with different ratios of training examples. Perplexity (PPL) and BLEU \cite{papineni2002bleu} are calculated between the reconstructed instructions and the original ones. We can see that the PPL and BLEU under 50\% are similar to 100\%. It shows that $E$ still supplies meaningful training loss for SSCR even if only using 50\% data. \begin{table} \centering \small \begin{tabular}{lccccc} \toprule ~ & \multicolumn{2}{c}{100\%} & ~ & \multicolumn{2}{c}{50\%} \\ \cmidrule{2-3} \cmidrule{5-6} Method & F1 & RelSim & ~ & F1 & RelSim \\ \midrule GeNeVA & 53.26 & 30.66 & ~ & 44.53 & 23.88 \\ w/ SSCR (D) & 54.05 & 30.87 & ~ & 43.31 & 22.99 \\ w/ SSCR (E) & \textbf{56.95} & \textbf{34.54} & ~ & \textbf{52.62} & \textbf{32.03} \\ \bottomrule \end{tabular} \vspace{-1ex} \caption{Results of discriminator ($D$) or iterative explainer ($E$) used for the counterfactual reasoning (SSCR) on i-CLEVR.} \label{table:sscr-vs} \vspace{-1ex} \end{table} \begin{table} \centering \small \begin{tabular}{lcc} \toprule Method & F1 & RelSim \\ \midrule GeNeVA & 42.23 & 23.70 \\ w/ CTC Only & \underline{43.91} & \underline{25.26} \\ w/ SSCR & \textbf{48.30} & \textbf{29.09} \\ \bottomrule \end{tabular} \vspace{-1ex} \caption{Results of zero-shot generalization.} \label{table:zero-shot} \vspace{-3ex} \end{table} \begin{figure*}[t] \centering \includegraphics[width=0.8\linewidth]{imgs/fig_case.pdf} \vspace{-1ex} \caption{Visulaization example of baseline (GeNeVA) and our SSCR on CoDraw.} \label{fig:case} \vspace{-1ex} \end{figure*} \paragraph{Zero-shot Generalization} To further demonstrate the effectiveness of SSCR under severe data scarcity, we conduct a zero-shot experiment for the i-CLEVR dataset. The zero-shot setting is as following. There are 3 shapes (\textit{cube}, \textit{sphere}, \textit{cylinder}) and 8 colors (\textit{gray}, \textit{red}, \textit{blue}, \textit{green}, \textit{brown}, \textit{purple}, \textit{cyan}, \textit{yellow}), which lead to 24 different objects on the i-CLEVR dataset. We remove examples containing “\textit{gray cube}, \textit{red cube}, \textit{green sphere}, or \textit{purple cylinder}” in the training set but still evaluate the full testing set with all kinds of objects. The result is shown in Table ~\ref{table:zero-shot}. Since there is no example like “\textit{gray cube}” in the training set, CTC can only consider those seen objects and improves marginally. However, the iterative explainer ($E$) can disentangle color and shape information from “\textit{gray sphere}” and “\textit{green cube},” and generalize to the unseen object “\textit{gray cude}”. During SSCR, when we intervene the counterfactual instructions to contain “\textit{gray cube},” the iterative explainer can still provide self-supervised loss to make the model consider unseen objects. Hence, SSCR can bring out obvious improvements on both F1 and RelSim, even if under the zero-shot setting. \paragraph{Iterative Explainer \textit{vs}. Discriminator} Fig.~\ref{fig:loss-vs} shows the learning curve of the training losses of the discriminator $D$ ($L_G$) and our iterative explainer $E$ ($L_E$). We can see that the relative decrease of $L_G$ over time is very little, which means that $D$ can barely provide extra training signal after 100 epochs. In contrast, since $E$ can supply explicit token-level loss instead of vague binary loss, $L_E$ keeps decreasing much and training the model. \begin{figure}[t] \centering \includegraphics[width=.95\linewidth]{imgs/fig_ssr-iter.pdf} \vspace{-1ex} \caption{The validation F1 and RelSim on i-CLEVR with 50\% training data under different instructions of counterfactual reasoning.} \label{fig:sscr-iter} \vspace{-3ex} \end{figure} Table~\ref{table:sscr-vs} shows the comparison when using $D$ and our $E$ to provide the training loss during the counterfactual reasoning. If using $D$, since there are not ground-truth resulting images of those counterfactual instructions, we cannot feed them into $D$ as true examples. It can only provide training loss by discriminating predicted images as false. Therefore, using $D$ during SSCR cannot improve the model much, and may even hurt the generalizability under data scarcity, \textit{e}.\textit{g}., 23.9 drops to 23.0 on RelSim for 50\%. In comparison, since our $E$ does not suffer from data scarcity, it supports SSCR by providing meaningful training loss to perform counterfactual reasoning, and thus improves the generalizability, \textit{e}.\textit{g}., 23.9 increases to 32.0 on RelSim for 50\%. \paragraph{Counterfactual Reasoning: The More The Better?} Despite allowing the model to explore various instructions and become more generalized, excessive counterfactual reasoning may result in overfitting to existing images and degrade the performance. Fig.~\ref{fig:sscr-iter} presents the validation performance under different iterations. It shows a trade-off between the model's generalizability and the iterations of the counterfactual reasoning. The performance keeps improving until the best 700 iteration and then drops down, possibly due to overfitting to existing images and the imperfect cost function for instruction prediction. \begin{figure}[t] \centering \includegraphics[width=.7\linewidth]{imgs/fig_case-ssr.pdf} \vspace{-1ex} \caption{Example of counterfactual reasoning.} \label{fig:case-ssr} \vspace{-3ex} \end{figure} \paragraph{Qualitative Results} Fig.~\ref{fig:case-ssr} present an example of counterfactual instructions and the predicted resulting image. We replace \textit{color token} ``red" with ``cyan"", \textit{color token} ``behind" with ``in front of", and ``right" with "left." By considering counterfactual instructions, SSCR allows the model to explore diverse instruction-image pairs, that deals with the data scarcity issue. Fig.~\ref{fig:case} demonstrates an example of the iterative editing on CoDraw. For baseline GeNeVA, since there is only a discriminator to provide vague loss that the pixels of those generated objects are almost broken, it makes the predicted images low quality. In contrast, for our SSCR, CTC can help train the generator better, which leads to defined objects. Furthermore, counterfactual reasoning also makes the predicted images more aligned to the instructions. \section{Conclusion and Future Work} \vspace{-1ex} We present a self-supervised counterfactual reasoning (SSCR) framework that introduces counterfactual thinking to cope with the data scarcity limitation for iterative language-based image editing. SSCR allows the model to consider new instruction-image pairs. Despite without ground-truth resulting images, we propose cross-task consistency (CTC) to provide a more explicit training signal and train these counterfactual instructions in a self-supervised scenario. Experimental results show that our counterfactual framework not only trains the image editor better but also improves the generalizability, even under data scarcity. For the real world, both visual and linguistic will be more complicated. To accomplish real-world image editing, large-scale pre-trained language encoders and image generators should be applied to understand the diverse instructions and model the interaction for editing. From a theoretical perspective, our SSCR is a model-agnostic framework that can incorporate with any image generator, for GAN or non-GAN architecture, to perform real-world image editing. Currently, the interactive explainer and counterfactual intervention in SSCR both improve the editing quality in the token-level. To make it more suitable for real-world images, semantic-level intervention for the diverse natural instructions can support better counterfactual reasoning. Also, a stronger explainer that explains not only token-level error but also global editing operation between two images can provide robust self-supervised loss. \\ \\ \noindent\textbf{Acknowledgments.~}Research was sponsored by the U.S. Army Research Office and was accomplished under Contract Number W911NF-19-D-0001 for the Institute for Collaborative Biotechnologies. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation herein.
{'timestamp': '2020-09-30T02:07:16', 'yymm': '2009', 'arxiv_id': '2009.09566', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09566'}
arxiv
\section{Introduction} Each year, approximately 4.2 million youth in the United States experience some form of homelessness \cite{morton2018prevalence}. One of the key health challenges for this population is high HIV prevalence, with reported prevalence in the range of 2-11\% \cite{young2011online}, up to 10 times the rate for youth with access to stable housing \cite{nhch2012}. One proposed mechanism for fostering behavior change in high-risk populations is the \textit{peer change agent} model. The main idea is to recruit peer leaders from the population of youth experiencing homelessness (YEH) to serve as advocates for HIV awareness and prevention. Use of peer leaders has been suggested in the public health and social science literature due to the central role that peers play in risk behaviors for YEH, including related to HIV spread \cite{green2013shared,rice2010internet,doi:10.2105/AJPH.2011.300295}. Indeed, peer change agent models have succeeded in past HIV prevention interventions in other contexts \cite{medley2009effectiveness}. However, there have also been notable failures \cite{nimh2010results}, and it has been argued such failures may be attributable to how peer leaders are selected \cite{schneider2015new}. The long-standing and most widely adopted method in the public health literature for selecting peer leaders is to identify the most popular individuals in the social network of the youth \cite{kelly1997randomised} (formally, the highest degree nodes). This poses the question: are high-degree youth the best peer leaders to disseminate messages about HIV prevention? This question has relevance far beyond HIV prevention; analogous social network interventions are used widely across development, medicine, education, etc.\ \cite{kim2015social,paluck2016changing,banerjee2013diffusion,valente2007identifying}. Information dissemination on social networks is the focus of a long line of research in computer science. In particular, the \textit{influence maximization} problem, formalized by \cite{kempe2003maximizing}, asks how a limited number of seed nodes can be selected from a social network to maximize information diffusion. Influence maximization has been the subject of extensive work by the theoretical computer science and artificial intelligence communities \cite{chen2009efficient,chen2010scalable,goyal2011celf++,borgs2014maximizing,tang2014influence}. However, to our knowledge, no work prior to this project had connected the computational literature on influence maximization to the use of network-driven interventions in public health and related fields. Computational work has mainly focused on developing highly efficient algorithms for use on large-scale social media networks (often motivated by advertising), while interventionists in health domains have not used explicitly algorithmic approaches to optimize the selection of peer leaders. Previous computational work assumed access to data (e.g., the full network structure and a model of information spread) which are simply not available in a public health context. This paper reports the results of a project which bridges the gap between computation and health interventions. As a research team composed of computer scientists and social workers, we developed, implemented, and evaluated an intervention for HIV prevention in YEH where the peer leaders are algorithmically selected. This intervention was developed over the course of several years, alternating between algorithm design and smaller-scale pilot tests to evaluate feasibility. The final system, which we refer to as CHANGE (CompreHensive Adaptive Network samplinG for social influencE), was evaluated in a large-scale clinical trial enrolling 713 youth across two years and three sites. The trial compared interventions planned with CHANGE to those using the standard public health methodology of selecting the youth with highest degree centrality (DC), as well as an observation-only control group (OBS). \textit{Results from this clinical trial demonstrate that CHANGE was substantially more effective than the standard DC method at increasing adoption of behaviors protective against HIV spread.} To our knowledge, this is the first empirically validated success of using AI methods to improve social network interventions for health. It is critically important for ``AI for Social Good" work to result in deployed and rigorously evaluated interventions, and this paper provides one such example. The remainder of the paper is organized as follows. First, we survey related work from both a computational and application perspective. Second, we introduce a formalization of the problem of selecting peer leaders from a computational perspective. Third, we briefly review the design of the CHANGE system to address this problem (deferring most details to earlier technical publications \cite{wilder2018end,wilder2018equilibrium,wilder2018maximizing}). Fourth, we present the design of the clinical trial. Fifth, we present and analyze results from the trial. Sixth, we discuss lessons learned over the course of the project which may help inform future attempts to design and implement AI-augmented public health interventions. \section{Related work} A great deal of research in computer science has been devoted to the influence maximization problem. The majority of this has focused on computationally efficient algorithms for large networks \cite{chen2009efficient,chen2010scalable,goyal2011celf++,borgs2014maximizing,tang2014influence} and assumes that the underlying social network and model of information diffusion are perfectly known. There is also more recent literature on algorithms to learn or explore these properties. Predominantly though, such work requires many repeated interactions with the system. For example, algorithms to estimate the parameters of an unknown model of information diffusion \cite{du2014influence,pouget2015inferring,narasimhan2015learnability,he2016learning,kalimeris2018learning} typically require the observation of hundreds of cascades on the same network. Collecting this amount of data is intractable for public health interventions, where a single round of the intervention takes months. Other work concerns the bandit setting, where the algorithm can repeatedly select sets of nodes and observe the resulting cascade \cite{wen2017online,chen2013combinatorial,wang2017improving}. Similarly, these algorithms accept poor performance in early rounds as the price for improvement over the long run, but waiting tens or hundreds of rounds for improved performance is not an option in our domain. Such techniques are a much better fit for problems concerning online social networks (for example, in advertising domains) where repeated experiments and large datasets are possible. The most closely related related computational work to ours concerns a robust version of the influence maximization problem \cite{he2018stability,chen2016robust,lowalekar2016robust}, building on the earlier work of \cite{krause2008robust} on general robust submodular maximization problems. Our algorithm for robust submodular optimization, for which an overview is provided below, differs from these approaches mainly in that it solves a fractional relaxation of the problem instead of repeatedly calling a greedy algorithm for discrete submodular optimization, which helps improve computational performance. There is a large literature on social network interventions in public health \cite{valente2007identifying,kim2015social}, clinical medicine \cite{young2003role}, international development \cite{cai2015social,banerjee2013diffusion}, education \cite{paluck2016changing}, etc. Common strategies involve selecting high degree nodes (as compared to in our trial), selecting nodes at random, or asking members of the population to nominate others as influencers. The empirical evidence for the relative effectiveness of different strategies is mixed; \cite{kim2015social} reports no or marginal improvement for nominations vs random selections (depending on the outcome measure), while \cite{banerjee2019using} report statistically significant improvements for a nomination-based selection mechanism. \cite{chin2018evaluating} introduce improved statistical methods to compare the effectiveness of seeding strategies and conclude that nomination-based strategies do not measurably improve performance. Indeed, \cite{akbarpour2018diffusion} show that in some theoretical network models it may be preferable to recruit a slightly larger number of influencers at random rather than carefully map the network. We contribute to this literature by developing and empirically evaluating an algorithmic framework which combines both features reminiscent of the nomination-based strategies proposed by others (for gathering information about network structure) as well as robust optimization techniques for jointly optimizing the entire set of influencers who are selected (not part of previous empirically evaluated strategies). Our clinical trial demonstrates statistically significant improvements from this strategy compared to the baseline of selecting high-degree nodes, providing (to our knowledge) the first real-world evidence that systematic optimization leads to improved results. \section{Problem description} The population of youth are the nodes of a graph $G = (V, E)$. We seek to recruit a set of youth $S$ to be peer leaders, where $|S| \leq k$. In domain terms, this budget constraint reflects the fact that peer leaders are given a resource-intensive training and support process. The objective is to maximize the total expected number of youth who receive information about HIV prevention, given by the function $f(S)$. Here, $f$ encapsulates the dynamics of a probabilistic model of information diffusion across the network (discussed below). The optimization problem $\max_{|S| \leq k} f(S)$ is the subject of the well-known influence maximization problem. When the objective function $f$ is instantiated using common models for information diffusion, the resulting optimization problem is submodular (i.e., there are diminishing returns to selecting additional peer leaders). While finding an optimal solution is NP-hard, a simple greedy algorithm obtains a $\left(1 - 1/e\right)$-approximation \cite{kempe2003maximizing}. The most common choice for the model of information diffusion is the independent cascade model. In this model, each node who receives information transmits it to each of their neighbors with probability $p$. All such events are independent. The process proceeds in discrete time steps where each newly informed node attempts to inform each of their neighbors, and concludes when there are no new activations. $f(S)$ calculates the number of nodes who receive information when the nodes $S$ are informed at the start of the process, in expectation over the random propagation. The standard influence maximization problem concludes here. However, while developing an algorithmic framework applicable to public health contexts, we came across challenges which must be solved before, during, and after the setting imagined in standard influence maximization. These challenges opened up new algorithmic questions, addressed in a series of publications in the AI literature \cite{wilder2018end,wilder2018equilibrium,wilder2018maximizing}. Here, we detail three steps for deploying an influence maximization intervention in the field. First, information about the network structure $G$ must be gathered. Previous work on influence maximization assumed that the network structure is known in advance. While this assumption may be reasonable for online social networks, we aim to disseminate information through the network consisting of real-world interactions between youth at a given center. Moreover, pilot studies revealed that information from an online social network (Facebook) was a poor proxy for actual connections at the center -- not all youth used Facebook, and of those who did, many were not friends with their actual contacts at the drop-in center. Instead, network information must be gathered through in-person interviews where social workers ask youth to list those who they regularly interact with. Collecting data in this manner is time-consuming and expensive, often requiring a week or more of effort on the part of the social work team. Accordingly, the first stage of our algorithmic problem is to decide which nodes to query for network information. The algorithm is allowed to make $M$ queries, where each query reveals the edges associated with the selected node. The queries can be adaptive, i.e., the choice of the $i$th node to be queried can depend on the answers given by nodes $1...i-1$. Second, this network information is used to select an initial set of peer leaders. This stage more closely resembles the standard influence maximization problem. However, there is an additional complication that the propagation probability $p$ is not known. Indeed, there is no data source from which it could be inferred (as opposed to online platforms with abundant data; see related work). Instead, we formulate an uncertainty set $\mathcal{U}$ containing a set of possible values for $p$ which are consistent with prior knowledge (in CHANGE, we took $\mathcal{U}$ to be a discretization of the interval [0,1], reflecting limited prior knowledge). The aim is to find a set $S$ which performs near-optimally for every scenario contained in $\mathcal{U}$. Formally, this corresponds to the robust optimization problem \begin{align*} \max_{|S| \leq k} \min_{p \in \mathcal{U}} \frac{f(S, p)}{OPT(p)} \end{align*} where $OPT(p)$ denotes $\max_{|S| \leq k} f(S, p)$, i.e., the best achievable objective value if the propagation probability $p$ were known. Normalizing by $OPT(p)$ encourages the algorithm to find a set $S$ which simultaneously well-approximates the optimal value for each $p \in \mathcal{U}$ and avoids the trivial solution where solution to the inner $\min$ problem is always the smallest possible value of $p$. Note that since $OPT(p)$ is constant with respect to $S$, $\frac{f(S, p)}{OPT(p)}$ remains submodular with respect to $S$. Robust optimization of submodular functions is substantially more difficult than optimization of a single submodular function; in fact, it is provably inapproximable in general \cite{krause2008robust} and the aim is instead to approximate a tractable relaxation of the problem. Third, after an initial set of peer leaders $S$ is identified, recruitment proceeds in an adaptive manner. Not all youth invited to become peer leaders will actually attend the training session. A number of potential barriers exist, e.g., a given youth could have been arrested or not have had enough money for a bus ticket. Formally, we model that each youth who is invited will actually attend with probability $q$ (based on experience in pilot studies, we took $q = 0.5$), where the attendance of each youth is independent of the others. For a given value of $p$, the resulting objective function is $f(S, p, q)$, which takes an expectation over both the randomness in which nodes are successfully influenced at the start of the process and in the subsequent diffusion. It is easy to show \cite{wilder2018end} that $f$ remains submodular with this additional randomness. Because of this variation in attendance, as well as capacity limits for the initial training, peer leaders are recruited over multiple rounds, where the peer leaders selected in round $t$ can depend on those who were successfully recruited in rounds $1...t-1$. In each round $t$, we select a set of peer leaders $S_t$ with $|S_t| \leq k_t$ and observe which nodes are successfully recruited as peer leaders. The process continues for $T$ rounds in total. \section{System design} Our final proposed system for intervention planning is called CHANGE. CHANGE was originally introduced in \cite{wilder2018end}. The final version of CHANGE summarized here is nearly the same as the original, with the exception of the algorithm used for robust optimization, which was separately developed and published in \cite{wilder2018equilibrium}. We now provide an overview of CHANGE, mirroring the steps of the earlier problem formulation. \subsubsection{Network sampling} CHANGE uses a simple but well-motivated heuristic to select a subset of nodes to be queried for network information (in the discussion section, we briefly review our earlier work on a more theoretically sophisticated solution, and the rationale for choosing a simpler method). The chosen method splits the query budget $M$ into two halves. Each query in the first half is made to a node selected uniformly at random from the network. Each query in the second half follows a query in the first half, and selects a uniformly random neighbor of the first node. This design is motivated by the friendship paradox, the observation that high-degree nodes are overrepresented when we sample random neighbors \cite{feld1991your}. Hence, the two stages of the query process balance between competing objectives: the first step encourages diversity, since random sampling ensures that we cover many different parts of the network, while the second step tends towards high-degree nodes who can reveal a great deal of network information. \subsubsection{Robust optimization} We now provide an overview of how CHANGE handles parameter uncertainty within a single stage of the planning process, before considering the multi-stage problem (with uncertain attendance) below. As mentioned above, max-min submodular optimization is NP-hard to approximate (within any nonzero factor) \cite{krause2008robust}. Accordingly, we need to somehow relax the problem to obtain meaningful guarantees. Let $\mathcal{I}$ denote the set of all feasible solutions (sets $S$ where $|S| \leq k$) and $\Delta(\mathcal{I})$ be the set of all distributions over $\mathcal{I}$ (i.e., the $|\mathcal{I}|$-dimensional simplex). We developed an algorithm for the problem \begin{align} \label{problem:fractional} \max_{D \in \Delta(\mathcal{I})} \min_{p \in \mathcal{U}} \E_{S \sim D}\left[\frac{f(S, p)}{OPT(p)}\right] \end{align} which allows the algorithm to select a distribution over feasible sets and evaluates the worst case only in expectation over this distribution. In game theoretic terms, this allows the algorithm to select a mixed strategy instead of a pure strategy. At run-time, we sample from $D$; the resulting set has guaranteed performance in expectation over the sampling, but strong guarantees cannot be obtained ex-post for the sampled set (as a result of the computational hardness of the original max-min problem). However, in practice we find that sampling several random sets and selecting the best one gives excellent empirical performance (i.e., closely matching or exceeding the expected value of the distribution). Our algorithm for this problem, detailed in \cite{wilder2018equilibrium}, uses a compact representation of the space of distributions (keeping track of only the marginal probability that each node is selected instead of each of the exponentially many potential subsets). It solves a fractional relaxation of the discrete max-min problem using this compact representation via a stochastic first-order method which is adapted to the particular properties of the objective. Then, we can use known rounding algorithms for submodular maximization to sample random sets from the distribution encoded by the solution to the fractional relaxation. This procedure guarantees a $(1 - 1/e)^2$-approximation for Problem \ref{problem:fractional}, which can be improved to $(1 - 1/e)$ with some additional steps (which we did not find empirically necessary). \subsubsection{Multi-stage intervention with attendance uncertainty} We handle the multi-stage nature of the intervention by running the robust optimization problem at each stage, calculating the objective function in expectation over which peer leaders will attend and conditioning on the selection of those who have attended previous interventions. Formally, this means that at stage $t > 1$, we solve \fontsize{9}{10}\selectfont \begin{align*} \max_{D \in \Delta(\mathcal{I})} \min_{p \in \mathcal{U}} \E_{S_t \sim D}\left[\frac{f(S_t \cup S_1 \cup ... \cup S_{t-1}, p, q)}{\max_{|S^*| \leq k} f(S^* \cup S_1 \cup ... \cup S_{t-1}, p, q)}\right] \end{align*}\normalsize where $S_1...S_{t-1}$ denote the sets of peer leaders who were succsesfully recruited in each previous stage. It is easy to show that the inner objective $f$ remains submodular in $S_t$ (see \cite{wilder2018end}), and so we retain the earlier guarantees on the quality of the solution obtained at each individual step. Moreoever, in \cite{wilder2018end} we show that the multi-stage problem as a whole enjoys the property of \textit{adaptive submodularity}, meaning that for any fixed parameter value $p$, solving \begin{align*} \max_{D \in \Delta(\mathcal{I})} \E_{S_t \sim D}\left[\frac{f(S_t \cup S_1 \cup ... \cup S_{t-1}, p, q)}{\max_{|S^*| \leq k} f(S^* \cup S_1 \cup ... \cup S_{t-1}, p, q)}\right] \end{align*} at each step $t$ and selecting the resulting set $S_t$ enjoys an approximation guarantee relative to the optimal adaptive policy for selecting a sequence of sets $S_1...S_t$ (again, with respect to a fixed $p$). More detailed discussion of the theoretical properties can be found in \cite{wilder2018end}. \section{Study design} \begin{figure} \centering \includegraphics[width=3.2in]{participants.png} \caption{Number of participants recruited and retained in each arm of the study.} \label{fig:participants} \end{figure} We now move to the empirical portion of the project and provide an overview of the design of the clinical trial. All study procedures were approved by our institution's Institutional Review Board. The study was designed to compare the efficacy of two different means of selecting peer leaders: the CHANGE system described above and the standard DC approach in public health (selecting the highest-degree youth). We additionally included an observation-only control group (OBS), for three arms in total. The study was conducted at three drop-in centers for YEH in a large US city. Drop-in centers provide basic services to YEH (e.g., food, clothing, case management, mobile HIV testing). Due to high transience in the YEH population, most clients at a given center leave within approximately six months. Accordingly, we tested each of the three methods at each of the the three drop-in centers (giving nine deployments in total, each with a unique set of youth)\footnote{Randomizing treatments at an individual level is clearly impossible for an social network intervention, so this is an example of a quasi-experimental design where entire populations of youth were assigned to one treatment or another.}, ensuring that successive deployments at a given drop-in center were separated by six months. Youth were only allowed to enroll in the study once, so even the small number of youth who were present at the center across multiple deployments were included only on the first time they attempted to enroll. Testing each method at each drop-in center helps account for differences in the demographic and other characteristics of youth who tend to access services at each center. Each of the nine deployments used the following procedure. Figure \ref{fig:participants} shows the number of youth recruited and retained for each phase of the study in each arm. First, youth were recruited at the drop-in center over the course of a week to participate in the study. All participants gave informed consent. Each participant completed a baseline survey which assessed demographic characteristics, sexual behaviors, and HIV knowledge. Demographic characteristics included age, birth sex, gender identity, race/ethnicity, and sexual orientation. Youth were also surveyed about their living situation and relationship status. Second, peer leaders were selected and trained (for the CHANGE and DC arms of the study). Each individual training consisted of approximately 4 youth and there were 3-4 trainings per deployment (depending on exact attendance). In total, approximately 15\% of survey participants in each deployment were trained as peer leaders. In the CHANGE arm of the study, network information was queried from approximately 20\% of the participants (sampled according to the mechanism described above). In the DC arm, we used a full survey of the network to find high-degree nodes, in order to give the strongest possible implementation to compare to. Third, peer leaders had three months to disseminate HIV prevention messages. Peer leaders were supported via 7 weeks of 30-minute check-in sessions with study researchers, which focused on positive reinforcement of their successes as well as problem-solving strategies and goals for the future. All peer leaders attended at least one check-in session, with modal attendance at five sessions. Peer leaders received \$60 in compensation for attending the initial training and \$20 for each check-in session. Fourth, follow-up surveys were administered to the original study participants from the first step. Follow-up surveys assessed the same characteristics as the baseline survey. Differences in reported sexual behavior between baseline and follow-up were used as the primary metrics to evaluate the interventions. All such metrics were self-reported; we followed best practices in social science research to minimize bias in self-reported data (surveys were self-administered on a tablet and participants were guaranteed anonymity, each of which aim to reduce social desirability bias in reporting sensitive information). Additionally, any bias would be expected to influence each arm of the study equally, including the observation-only control group. The training component of the peer change agent intervention was delivered by two or three facilitators from the social work research team. The training lasted approximately 4 hours (one half-day). Training was interactive and broken into six 45-minute modules on the mission of peer leaders (sexual health, HIV prevention, communication skills, leadership skills, and self-care). Peer leaders were asked to promote regular HIV testing and condom use through communication with their social ties at the drop-in center. \section{Study results} We now present the results of the clinical trial, starting with an overview of the outcome variables and methodology for statistical analysis, and then giving the main results. \subsection{Outcome variables} We compare two outcome variables across arms of the study. First, condomless anal sex (CAS), assessed via a survey question asking whether youth had anal sex without a condom at least once in the previous month. Second, condomless vaginal sex (CVS), assessed via a survey question asking whether youth had vaginal sex without a condom at least once in the previous month. CAS and CVS are both important behavioral risk factors for HIV transmission and so provide a direct assessment of the success of the intervention at producing a material health impact. \subsection{Statistical methodology} We provide both the average value of each outcome variable at each time point for the three arms of the study as well as an analysis of statistical significance. The statistical analysis used a generalized estimating equations (GEE) model. GEE is an extension of generalized linear models which incorporates repeated measurements of data across a population. It is a standard choice for analysis of clinical data in this form \cite{gee}. We specified a linear model for each outcome variable which included terms for both the improvement caused by participating in a given arm of the study (our estimand of interest) as well as terms for a range of control variables which account for differences in demographics and the baseline rate of risk behaviors in each arm of the study. The demographic control variables were age, birth sex, transgender identity, LGBQ identity, the combination of male sex and LGBQ identity, race, committed relationship, housing status, and drop-in center. We also included a ``time" variable to account for changes in the entire population over time regardless of participation in a particular arm of the study. This combination of control variables helps separate the impact of the intervention from pre-existing differences between arms of the study and intervention-independent trends. The linear model combined contributions from each of these variables through a logistic link function. Since each outcome is binary, we present results in the form of the odds ratio (OR), which measures the ratio in the odds of the outcome in youth who are exposed to a given intervention vs youth in the observation-only group (after controlling for demographics and baseline rate of risk behaviors). For all quantities, we also present 95\% confidence intervals and indicate where significant $p$-values are obtained. Results are known only for youth who completed the follow-up surveys, leading to missing data due to participant attrition (as is expected for a study enrolling YEH). Of the 713 participants who completed the baseline survey, 245 (34\%) missed the 1-month follow-up, 300 (42\%) missed the 3-month follow-up, and 180 (25\%) missed both follow-ups. However, missingness had no statistically significant association with CAS or CVS, indicating that youth were not significantly over or under represented in the follow-up data based on their baseline level of risk behavior. \newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}} \begin{table}\centering \ra{1.3} \fontsize{8.5}{8.5}\selectfont \begin{tabular}{@{}rccrrcccccccccc@{}}\toprule & \multicolumn{2}{c}{CAS} & & \multicolumn{2}{c}{CVS} \\ \cmidrule{2-3} \cmidrule{5-6} & OR & CI && OR & CI\\ \midrule \multicolumn{1}{l}{Baseline}\\ \multicolumn{1}{r}{CHANGE}& 1.43 & 0.91, 2.28 && 0.77 & 0.52, 1.13\\ \multicolumn{1}{r}{DC}& 1.49 & 0.89, 2.48 && 1.07 & 0.67, 1.68\\ \multicolumn{1}{l}{Post-intervention}\\ \multicolumn{1}{r}{CHANGE}& 0.69* & 0.49, 0.98 && 0.78$^\dagger$ & 0.57, 1.04\\ \multicolumn{1}{r}{DC}& 0.80 & 0.55, 1.17 && 0.88 & 0.62, 1.23 \\ \multicolumn{1}{l}{Time}& 1.05 & 0.82, 1.33 && 0.87 & 0.71, 1.06\\ \bottomrule \end{tabular} \caption{Results of statistical analysis. Each column gives the effect size and confidence interval for one of the outcome variables. Each row gives the corresponding estimates for one of the variables included in the GEE model. The ``baseline" category measures pre-existing differences between the groups (relative to the observation-only group) on enrollment in the study. The ``post-intervention" category measures the estimated impact of participating in each arm of the intervention (relative to the observation-only group, and after controlling for both demographics and baseline behaviors). ``Time" gives the estimated contribution of a trend over time independent of which arm of the study a participant was enrolled in. $^\dagger p < 0.1$; $^*p < 0.05$.} \label{table:results} \end{table} \subsection{Results} We start by presenting the main results of the statistical analysis; the full results can be found in Table \ref{table:results}. \subsubsection{CAS} We find that CAS reduced in the CHANGE group over time by a statistically significant amount (OR = 0.69, $p < 0.05$). The estimated OR of 0.69 indicates that, in the GEE estimates, a youth who is enrolled in the CHANGE arm of the study has 31\% lower odds to engage in CAS than if they were enrolled in the observation-only group. That is, a youth who is enrolled in CHANGE has 31\% lower odds to engage in CAS post-intervention than a youth with identical starting characteristics (including baseline rate of CAS) who did not receive the intervention. For the DC group, there was not a statistically significant change in CAS over time relative to the observation-only group. \subsubsection{CVS} The GEE model estimated that CVS decreased by a marginally statistically significant amount in the CHANGE group (OR = 0.78, $p < 0.1$). For the DC group, there was no statistically significant change in CVS over time relative to the observation-only group. \begin{figure} \centering \includegraphics[width=1.5in]{CAS.pdf} \includegraphics[width=1.5in]{CVS} \caption{Average value of each outcome variable at each point in time for the three arms. These plots show the results without any statistical processing, while the analysis above attempts to control for pre-existing differences between participants in each arm.} \label{fig:results} \end{figure} We conclude from the analysis that only CHANGE provided a statistically significant improvement in HIV risk behaviors compared to the observation-only baseline. Direct examination of the average values of the outcome variables for each arm at each point in time (Figure \ref{fig:results}) shows another interesting trend. Improvements in the CHANGE group happen faster than the DC group: most of the improvement for CHANGE occurs by the one-month survey, while improvements in the DC group are not fully realized until month three. Fast results are important for two reasons. First, rapid adoption of protective behaviors helps to immediately curtail transmission in a high-risk population. Second, high transience among YEH means that a non-negligible portion of youth will have left the center by the time a three-month intervention is completed. We conclude that the AI-augmented intervention implemented with CHANGE has substantial advantages over an intervention where peer leaders are selected with the standard DC method. \section{Discussion} This project provides evidence that AI methods can be used to improve the effectiveness of social network interventions in public health: significant reductions in HIV risk behaviors were observed in groups where our CHANGE method was used to plan the intervention, with no significant changes in behavior when the status quo method (selecting high degree nodes) was employed. More broadly, we hope that our experiences over the course of the project can provide generalizable lessons about how AI research can be successfully employed for social good. There have been recent attempts by others to synthesize principles for AI for Social Good research \cite{floridi2020design,tomavsev2020ai}. We offer a complementary perspective shaped by the process of deploying a specific community-level intervention. In particular, existing discussions of best practice often focus in large part on ethics, data privacy, and building trust with stakeholders. While such considerations are indispensable, it is also important for the research community to investigate the on-the-ground components of developing and deploying an impactful intervention. We highlight five points. First, the starting point was to listen to domain experts and understand where in the problem domain AI could be most impactful. We did not approach this project with a preexisting intention to apply influence maximization to the choice of peer leaders. Rather, this emerged organically from discussions between the AI and social work sides of the research team as a topic where an AI-augmented intervention was both technically feasible and likely to improve outcomes. \textit{Success is less likely when AI researchers start with a favored technique and search for an application. } Second, data was overwhelmingly the bottleneck to the AI component of the intervention. Computational work on influence maximization to date had largely assumed a great deal of information would be known -- the structure of the graph, the model for information diffusion, etc. None of this information was in fact available for YEH (or would likely be available in other public health settings). Moreoever, gathering this data is itself time-consuming and costly, requiring unsustainable effort on the part of an agency wishing to deploy the intervention on their own. Much of the technical focus of the research consisted of finding ways to reduce the amount of data which needed to be gathered for the intervention to succeed. \textit{Finding ways to reduce or eliminate data needs through improved algorithm design is an important part of producing deployable AI interventions in a community health context.} Third, simplicity is valuable. As an example, prior to developing CHANGE, we designed a much more theoretically sophisticated algorithm for collecting network data which enjoyed provable guarantees for certain families of graphs \cite{wilder2018maximizing}. However, it quickly became apparent that this algorithm would be difficult to deploy in practice because it required a large number of sequential queries (the node which is queried on step 1 determines the node who is to be queried on step 2, and so on). This was impractical in the context of a program working with YEH where any given youth may be difficult to find, interrupting the entire process. More generally, if the algorithm requires tight coupling with the outside world (many steps where information is input, the algorithm recommends a very specific action, more information is input, and so on) then there are more things that can go wrong which are not captured in the computational formalization of the problem. This poses a contrast to the way that simplicity is often operationalized in AI for social good work as either \textit{explainability} \cite{floridi2020design} or as \textit{methodological} simplicity \cite{tomavsev2020ai} (e.g., using well-developed techniques instead of a new algorithm). Both explainability and methodological simplicity are of course valuable in many settings but in our experience neither was first-order requirement: the algorithm can solve a complex optimization problem internally so long as the way that it interacts with the outside world is simple and robust.\textit{ We believe that this \textit{operational} simplicity is an under-emphasized design criterion for AI for Social Good. } Fourth, smaller pilot tests were a valuable part of the project prior to embarking on a larger clinical trial. We conducted several such tests, each of which consisted of a deployment at a single drop-in center, in order to test earlier versions of our system \cite{wilder2018end,yadav2016using,yadav2017influence}. This helped reveal key issues which needed to be addressed. For example, we quickly discovered that a plan to collect network information via Facebook was not viable with this population and that manual collection of network data entailed a great deal of effort. We also quickly observed that peer leaders often did not attend the training, requiring on-the-fly adjustments over the course of the program. Addressing such issues was necessary to the success of the overall project (and turned out to provide much of the technical challenge involved). \textit{It would have been very difficult to identify these challenges without piloting algorithms in the actual environment where they will be used. }It was also helpful for computer scientists on the research team to be regularly present onsite during the pilot deployments to learn more about the environment and help coordinate the initial attempts at using the algorithm. Fifth, community engagement and trust was essential to the success of the project. Beyond the research team, a number of stakeholders needed to be involved in the process. For example, we needed buy-in from each of the drop-in centers to conduct the study at the center, enroll their clients, and use their facilities. We regularly convened a community advisory board with representatives from each of the drop-in centers along with members of the research team to provide information about the study progress, explain the methods being used, and share information which could be helpful to other center activities. Just as critical as the center leadership though, were the youth themselves. We asked youth to disclose sensitive information, including their HIV risk behaviors and social contacts. Especially for the YEH population, which is less inclined than most to engage with authority figures, building trust is essential. We found two factors to be especially important in establishing this trust. First, the social work portion of the research team had deep roots in the community, having regularly offered services at these drop-in centers for the past ten years. Second, transparency about why information was being collected was critical. We observed substantially increased willingness to disclose information related to social contacts when researchers explained how this information would be used in the study (i.e., that a computer program would be used to select some people as peer leaders based on their contacts) than when such an explanation was not proactively given. \textit{A critical part of the peer change agent model is empowering youth to make a difference in their community, and this philosophy extends to the way that AI should be used in a community setting.} Our hope is that this project provides one example towards a broader research agenda aiming at AI techniques which can be successfully used to improve health and equity within our communities. A great deal of work remains. Just within the context of social network intervention, future work should explore other intervention designs (e.g., interventions which attempt to modify network structure by fostering supportive relationships), methods for further reducing data requirements (e.g., by using administrative data to infer social connections), and more deeply investigate the relationship between information diffusion and behavioral change. However, the results from this clinical trial provide evidence that AI can substantially improve the quality of services offered to the most vulnerable among us. \bibliographystyle{aaai}
{'timestamp': '2020-11-09T02:18:43', 'yymm': '2009', 'arxiv_id': '2009.09559', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09559'}
arxiv
\section{Introduction} The expanded use of machine learning (ML) has empowered a wide variety of Internet-of-Things (IoT) applications, including fine-grained road-traffic and pedestrian prediction, fine-grained environment prediction, anomaly detection in network systems, and fraud detection in financial transactions \cite{mahdavinejad2018machine, cui2018survey}. Generally, ML requires tremendous computational power to quickly produce the analytical results. The steady growth of cloud computing platforms (e.g., AWS, Microsoft Azure, and Alibaba) has supported `resource-heavy' ML computing. Data used by ML for IoT applications are generated by the IoT devices themselves, which are located at the network edge and include sensor devices, smartphones, and smart vehicles. People engaged in this activity have found this scenario to be problematic for the following two reasons. First, individuals and private organizations are concerned about the privacy of their data when sharing them with an entity that operates an IoT application. After the EU adopted its general data protection regulation (GDPR) \cite{voigt2017eu}, privacy became a top-prioritized issue with regard to IoT applications. The second reason concerns bandwidth costs, which individuals or private organizations must bear to support their IoT needs. As the volume of data increases, such bandwidth costs will become more problematic \cite{shinkuma2019data, inagaki2019prioritization}. Federated learning (FL) was invented to tackle both of the above two issues \cite{McMahan16}. With traditional ML, the training dataset is usually stored at a central entity. Data must be first collected from the data sources to facilitate the learning process. FL focuses on data integration methods that comply with privacy and security laws. Under FL, data owners employ privacy protection techniques (e.g., homomorphic encryption, secret sharing, and differential privacy) to contribute model parameters trained on their own datasets to a federation. The federation then combines these local model parameters to train a more effective collective ML model. This allows the learning process to leverage the computational power of the data sources to train the model, similar to crowdsourcing. Although FL has shown great advantages in enabling collaborative learning while protecting data privacy, it still faces an open challenge of incentivizing owners of IoT devices to join the FL effort by contributing their computation power and data \cite{zhan2020learning}. An intuitive idea is to reward participants according to their contributions. However, it is difficult to accurately evaluate their contributions. It has been reported that the relationship between model accuracy and the amount of training data is nonlinear. The model accuracy depends on model complexity and data quality. This accuracy can hardly be predicted in advance. Generally, in FL, data are unbalanced and non-i.i.d. between clients: as the training data present on the individual clients is collected by the clients themselves based on their local environment and usage pattern, both the size and the distribution of the local data sets will typically vary heavily between different clients \cite{sattler2019robust}. Therefore, accurate estimation of individual contribution levels with small computation and communication overhead is a key to the success of incentivizing participants in FL. This paper proposes a method that estimates the individual contribution level of FL participants with no overhead traffic and little computation overhead. Conventionally, a direct and accurate way of estimating their individual contribution levels is to first measure the degradation of model accuracy by removing the local model provided by each participant. This method is more computation-and communication-resource consuming, because it must repeat entire FL processes as many times as the number of participants. The proposed method achieves estimation during a single FL process with small computation overhead and no overhead traffic. This is helpful for the incentive mechanism of FL when quickly determining rewards for each participant on the basis of their contribution levels. Of course, accuracy of the estimation must be also ensured. In this paper, performance evaluation using a real dataset is conducted to validate the proposed method in terms of estimation accuracy. \section{Prior works} Several studies on FL incentive mechanisms were published in 2019 and 2020, suggesting that this research topic is building momentum. Several basic analyses have been presented \cite{pandey2020crowdsourcing, lee2020market, kang2019design, chen2020mechanism}. Pandey et al. designed a framework in which FL-participating clients iteratively solved the local learning subproblems to meet an accuracy level that was subject to an offered incentive \cite{pandey2020crowdsourcing}. A communication-efficient cost model for the participating clients was established to formulate the incentive mechanism and to induce the necessary interaction between the mobile-edge computing (MEC) server and the participating FL clients. Introducing a two-stage Stackelberg game, they analyzed the game's equilibria and the response behaviors of the participating clients. Lee et al. designed a distributed learning resource management mechanism over multiple MECs owned by different operators \cite{lee2020market}. They also presented a game theoretic approach that focused on analyzing the market behaviors and the economic benefits of FL by formulating and analytically solving a Stackelberg game model. Kang et al. adopted contract theory to design an efficient incentive mechanism that mapped contributed resources into appropriate rewards to entice mobile-device owners possessing high-quality data to join FL and overcome information asymmetry issues \cite{kang2019design}. They presented the problem formulation and the optimal contract design of their mechanism and showed its superiority using the Stackelberg game model. Chen et al. modeled and formulated the mechanism-design problem with type-imposed externalities \cite{chen2020mechanism}. For quasi-monotone externality-setting, they provided a revenue-optimal and truthful mechanism. For the general valuation functions, they provided both necessary and sufficient conditions for all truthful and individually rational mechanisms. The method of determining rewards for clients is a key issue for FL incentive mechanisms \cite{kang2019mechanism, liu2020fedcoin, toyoda2019mechanism}. Kang et al. applied reputation as the necessary metric needed to assess the reliability of an FL-worker candidate, thus ensuring reliable worker selection. High-reputation workers bring high-quality data (i.e., high accuracy and reliability) to model training, generating reliable local model updates for FL tasks. Liu et al. suggested that, to properly incentivize data owners to contribute their efforts, the Shapley value (SV) was often adopted to fairly assess their contribution \cite{liu2020fedcoin}. To help FL systems compute SVs to support sustainable incentive schemes, they proposed a blockchain-based peer-to-peer payment system: FedCoin. The SV of each FL client reflected its contribution to the global FL model in a fair way. It was calculated using the Proof-of-Shapley consensus protocol, which replaced the traditional hash-based protocol in existing blockchain proof-of-works method. Toyoda and Zhang introduced a competitive model-update method so that any rational worker who followed the protocol could maximize their profits. Each worker chosen in a certain round selects the top model updates submitted by workers in the previous round and updates their own model. Here, workers' reward is decided by the vote of the next round of workers. The motivation of choosing the models that achieve the best k models is that their model updates will have a greater chance to be voted for in the next round, meaning that more rewards will be obtained. This design will naturally compel rational workers to behave honestly without any heavy cryptography or special hardware. Sustainability and fairness are also key issues of FL incentive mechanisms \cite{yu2020fairness, yu2020sustainable, zhan2020learning}. Yu et al. considered a method to quantify the payoff for each data owner in order to achieve long-term systemic wellbeing \cite{yu2020fairness, yu2020sustainable}. Participants must incur some cost for contributing to the FL model with their local datasets. The training and commercialization of the models take time. Thus, there are delays before the federation has a sufficient budget to pay the participants. They further addressed this temporary mismatch between contributions and rewards. To address the issues of unshared decisions and ambiguous contribution evaluations, Zhan et al. designed an algorithm based on deep-reinforcement learning (DRL), which can learn system states from historical training records \cite{zhan2020learning}. DRLs can adjust the strategies of the parameter server and edge nodes according to environmental changes that may impose different requirements on training data. Incentive mechanisms for FL in heterogeneous resource environments have also been studied \cite{lim2020hierarchical, jiao2020toward, zeng2020fmore}. To the best of our knowledge, no prior work has addressed the reduction of computation and communication overhead for estimating the individual contribution levels of FL participants. \section{Proposed method} \subsection{System model} Figure \ref{fig:system} shows our system model. The system comprises a server and multiple FL clients. At each client, the sensor generates data to be used for ML. The receiver receives an ML model from the server and stores it. The learner performs the training process to update the ML model using the data obtained from the sensor. The transmitter uploads the updated ML model to the server. The server ultimately receives the updated ML models from all the clients and stores them. The aggregator performs the model aggregation to update the ML model using the ML models obtained from the clients. The evaluator estimates the individual contribution level of each client by comparing the ML models before and after being updated using the clients' models. The evaluator sends back the rewards to each client based on its contribution. Note that decision making by clients is out of the scope of this paper and will be included in future work. The decision maker at each client makes a decision to participate in FL if the reward is sufficient to compensate the cost of contribution of a client to the FL. Otherwise, a client leaves the FL. \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{system_model1.pdf} \caption{System model} \label{fig:system} \end{figure} \subsection{Design metrics to evaluate client contributions}\label{sec:metric} Evaluating the contributions of each client accurately is not easy, because it is difficult to explicitly describe the actual improvement of model performance based on the quality of the clients' data and model (e.g., data amount, data variety, noisy label, the number of epochs, and noisy gradients, etc). Therefore, we next discuss model-performance based metrics that can be used to estimate the contributions of each client based on trained model performance. Let $\mathcal{C} = {1,...,c}$ be a set of indices that describes $c$ clients. The amount of data samples possessed by client $i$ and the data distribution are denoted as $d_i$ and $v_i$, respectively. $M^{(r)}_i$ denotes the model updated by client $i$ at round $r$, and $M^{(r)}_\mathcal{S}$ denotes the model aggregated by those updated by a subset of clients, $\mathcal{S} \subseteq \mathcal{C}$. $M^{0}$ is defined as an initial model the parameters that are randomly determined. $P(\mathcal{M})$ is the performance score of model $M$, and the validation accuracy or loss can be used for the score. In each round, each client updates $M^{(r-1)}_\mathcal{C}$ with its own data and uploads an updated model $M^{(r)}_i$. The server then aggregates the models into $M^{(r)}_\mathcal{C}$. The round is repeated until the $P(M^{(r)}_\mathcal{C})$ or $r$ achieves a certain threshold. \vspace{3mm} \noindent \textbf{Naive contribution metric } \\ Let $M_\mathcal{S}$ be a global model at the end of the FL where only clients in $\mathcal{S}$ participate in. We define a naive metric for evaluating contributions of client $i$ as the gain in performance when the client joins the FL. The gain can modeled as the relative performance of a model that includes all clients to that which excludes only client $i$. Specifically, the normalized relative gain is given as: \begin{equation} G^{\mathrm{Naive}}_i = \frac{P(M_\mathcal{C}) - P(M_{\mathcal{C} \setminus \{ i \}})}{\sum_{i \in \mathcal{C}}P(M_\mathcal{C}) - P(M_{\mathcal{C} \setminus \{ i \}})}, \end{equation} where $P(M_{\mathcal{C} \setminus \{i\}})$ indicates a performance score in which all the clients excluding client $i$ train the model. The naive metric is intuitive, reasonable, and calculable. However, calculating the metric requires additional FL training to obtain $M_{\mathcal{C} \setminus \{ i \}}$, which causes a large computational overhead and traffic overhead. Specifically, the computation and traffic overhead of calculating the naive metric can be given as: \begin{eqnarray} \mathrm{Comp.:}&\; & \sum_{i\in\mathcal{C}} r_\mathrm{end} (C_\mathrm{server} + \sum_{j \in \mathcal{C}\setminus \{i\}}C^{(j)}_\mathrm{ud}), \label{eq:comp_naive}\\ \mathrm{Traffic:}&\; & \sum_{i\in\mathcal{C}} r_\mathrm{end} \sum_{j \in \mathcal{C}\setminus \{i\}}2\Theta^{(j)}_\mathrm{model},\label{eq:traffic_naive} \end{eqnarray} where $r_\mathrm{end}$ is the number of rounds at the end of the FL task. $C^{(j)}_\mathrm{ud}$ and $C_\mathrm{server}$ denote the amount of computations for model update, namely stochastic gradient decent (SGD) operations, at client $j$ and the computation at the server, which is model aggregation and model validation. $\Theta^{(j)}_\mathrm{model}$ denotes traffic for transmitting a model from/to client $j$. The usual FL process causes computations of model aggregation and model updates at each client, the sum of which is $C_\mathrm{server} + \sum_{j \in \mathcal{C}}C^{(j)}_\mathrm{ud}$, at each round. Traffic is also generated for distributing and gathering models to/from FL clients at each round. The round is repeated $r_\mathrm{end}$ times. For calculating the naive metric for client $i$, the FL process with $\mathcal{C}\setminus \{i\}$ must be conducted individually, and thus the additional computation and traffic are as shown in \eqref{eq:comp_naive} and \eqref{eq:traffic_naive}. The computation cost and traffic can be huge since the number of clients are expected to be large in mobile networks and the data size of the model could be huge, especially when using deep neural networks. Therefore, we require an intuitive and reasonable, but more computation-and communication-efficient metric to evaluate clients' contributions. \vspace{3mm} \noindent \textbf{Step-wise contribution} \\ We propose a light-weight but intuitive contribution estimation method based on step-wise contribution calculation. The metric used in the proposed method is defined as the sum of gains that include the client model in each round, calculated as: \begin{equation} G^{\mathrm{SWC}}_i = \frac{\sum_{r = 1}^{r_\mathrm{end}}P(M^{(r)}_\mathcal{C}) - P(M^{(r)}_{\mathcal{C} \setminus \{ i \}})}{\sum_{i \in \mathcal{C}} \sum_{r = 1}^{r_\mathrm{end}}P(M^{(r)}_\mathcal{C}) - P(M^{(r)}_{\mathcal{C} \setminus \{ i \}})}, \end{equation} where the denominator is used for normalization. The metric evaluates how much the client's model improves the global model at each round and regards the sum of the step-wise contributions as the contribution of the FL client. This is based on the intuition that a client that improves model performance at each round will also contribute to the improvement of the final overall model performance. Note that $G^{\mathrm{SWC}}_i$ cannot be the same as $G^{\mathrm{Naive}}_i$ since $M^{(r)}_j$ used to obtain $M^{(r)}_{\mathcal{C} \setminus \{ i \}}$ is calculated from $M^{(r-1)}_\mathcal{C}$ that involves the effect of $M^{(r-1)}_i$ while $(M_{\mathcal{C} \setminus \{ i \}})$ never involves the effect of client $i$. However, the proposed metric can be calculated in $r_\mathrm{end}$ FL training rounds, \textit{i.e.} the FL operator does not need the additional FL training rounds while the Naive metric requires $(c+1)\cdot r_\mathrm{end}$ FL training rounds. The proposed method requires an increase in model aggregations, model validations and gain calculations by a factor $c \cdot r_\mathrm{end}$ compared to the original FL training process. The computation and traffic overhead caused by the proposed method is described as \begin{eqnarray} \mathrm{Comp.:}&\; & r_\mathrm{end} \cdot c \cdot C_\mathrm{server}, \label{eq:comp_step}\\ \mathrm{Traffic:}&\; & 0.\label{eq:traffic_step} \end{eqnarray} The additional computation, that is $(c-1)$-times model aggregation, is caused at the server at each round. The calculation is completed by the server, and no traffic overhead is caused. Comparing with the naive metric, the computation overhead is reduced by \begin{equation} \frac{c \cdot C_\mathrm{server}}{c\cdot C_\mathrm{server} + \sum_{i\in\mathcal{C}} \sum_{j \in \mathcal{C}\setminus \{i\}}C^{(j)}_\mathrm{ud}}. \end{equation} Generally, because the computation power of the server is much higher than those of clients, the additional computation of the proposed method is not a critical issue. Besides incentive/reward selection, the proposed metric can also be used for other mechanisms such as \textit{e.g.,} a client selection problem where the FL operator selects a subset of clients to participate in a FL round for reducing latency for model distribution and uploading with maintaining the improvement of model performance by the FL \cite{nishio2019client}. \vspace{3mm} \noindent \textbf{Other heuristic metrics} \\ Based on the intuition that the clients having copious and diverse data improves the global model, two heuristic metrics can be defined: \begin{eqnarray} \mathrm{Heuristic 1:} \quad G_i^\mathrm{H1} = D_i/\sum_{i \in \mathcal{C}}{D_i}, \\ \mathrm{Heuristic 2:} \quad G_i^\mathrm{H2} = D_i\cdot v_i/\sum_{i \in \mathcal{C}}{D_i\cdot v_i}, \end{eqnarray} where $D_i$ denotes the number of data sample stored by client $i$. $v_i$ denotes the varieties of the data owned by client $i$, which refers specifically to the number of classes of the data samples stored by client $i$ in classification tasks and the range of the target values in the regression tasks. These metrics are intuitive and easy to calculate. Furthermore, it can be obtained prior to FL training process. However, the metrics do not work in some cases. Supposing that there are three clients having the same number of data with four classes at each client, the client's data class differs from those of the others. The other clients' data classes overlap somewhat. In this case, the heuristic metrics become the same value for each client. However, their actual contributions may differ. \section{Experimental evaluation} \subsection{Setup} A total of $c=3$ clients participated in the FL and joined all the FL rounds. The clients trained their local models using their own data, uploading them to a server that aggregated the models into a global model. We adopted an image classification task leveraging MNIST dataset \cite{MNIST}, which is a dataset of handwritten digits and is commonly used as a benchmark. The MNIST dataset consists of 60,000 training images and 10,000 testing images with digits of 0--9 stored as 28x28 pixels. The small portions of the training dataset were distributed to $c=3$ clients. The total number of data samples stored by Client 3 was fixed to $D_3=350$, and those of Client 1 and 2 were $D_1, D_2 \in [50, 200, 350]$. We considered a non-i.i.d setting, wherein each client possessed data samples from specific classes of the 50,000 training samples. Specifically, Client 1 stored $D_1$ samples by randomly sampling from $v_1 = 7$ classes of digits (i.e., 0--6). Client 2 stored $D_2$ samples by randomly sampling from $v_2 = 7 \text{ or } 5$ classes of digits (i.e., 0 or 2 to 6). Client 3 stored $350$ samples by randomly sampling from $v_3 = 3$ classes of digits that did not overlap the classes Client 1 (i.e., 7--9). In these settings, Client 1 stored samples of the most various classes ($v_1 \geq v_2 > v_3$), and Client 2 stored digits that were stored by Client 1. The digits of 7--9 were stored by only Client 3. Therefore, the contributions of Client 2 were expected to trend smaller than those of the other clients. The 10,000 testing images were used for the model validation at each round. We implemented convolutional neural networks as global and local models with TensorFlow \cite{TF}. Specifically, the model consisted of two $3\times 3$ convolution layers of 16 and 32 channels, each of which was activated by a ReLU and batch normalized. Each convolution layer was followed by $2\times 2$ max pooling. The last max pool layer was followed by two fully-connected layers of 64 units with ReLU activation and another 10 units activated by soft-max. The batch size, the number of epochs for local training $E$, and the number of FL rounds were set to $B=50$, $E=30$, and 30, respectively. A SGD having a learning rate of 0.25 was used for the optimizer of each client. We evaluated the errors of the metrics defined in Sect.~\ref{sec:metric} from the Naive contribution metric. The error was defined as Euclidean distance between the metrics, which is written as follows: \begin{equation} E = \sqrt{(G^{\mathrm{Naive}}_1 - G_1^{*})^2+(G^{\mathrm{Naive}}_2 - G_2^{*})^2+(G^{\mathrm{Naive}}_3 - G_3^{*})^2}. \end{equation} \subsection{Results} Figure~\ref{fig:comp_time} depicts a total computation time required for the FL and evaluating contributions, which did not include latency for model transmissions. Thus, this result indicates the computation load of each method. Since the computation load to calculate heuristic metrics was negligible, which was hundreds microseconds in the experiments, the computation time of the heuristic methods were almost the same as the usual FL. On the other hand, the naive and proposed method increased in the computation time. However, the proposed method increases much shorter time than the naive method, which means that the proposed method requires much smaller computation overhead as discussed in Sect.\ref{sec:metric}. \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{./comp_time.pdf} \caption{Total computation time for the FL and evaluating contributions.} \label{fig:comp_time} \end{figure} Figure~\ref{fig:res_773} depicts the contribution scores of each client when Clients 1 and 2 had 350 training samples of 0--6 digits, and Client 3 has 350 samples of 7--9 digits. In the every methods, the contribution scores of Clients 1 and 2 were nearly the same. This is reasonable scoring, because Clients 1 and 2 had the same number and variety of training samples. On one hand, the score of Client 3 was higher than the others according to the naive and proposed methods. This is also reasonable, because the data stored by Client 3 was unique, whereas training data for integers 0--6 were stored at both clients. When Client 3 left the FL, the global model could not achieve an accuracy higher than 0.7. The model could, however, achieve greater than 0.7 if the Clients 1 or 2 left, because both had training data of 0--6 digits. The heuristic methods for Clients 1 and 2 did not consider the data uniqueness and gave the same or lower score to Client 3, which is unreasonable in this scenario. \begin{figure}[t] \centering \includegraphics[clip, width=1.0\linewidth]{./350all_7_7_3.pdf} \caption{Client contribution scores when Clients 1 and 2 had 350 training samples of 0--6 digits, and Client 3 had 350 samples of 7--9 digits.} \label{fig:res_773} \end{figure} Figure~\ref{fig:res_753} depicts the contribution scores of each client when Clients 1,2, and 3 had 350 training samples of 0--6 digits, 2--6 digits, and 7--9 digits, respectively. In this setting, the contributions of Client 2 must have been smaller than Client 1, because Client 2 had a smaller variety of training samples. The naive and proposed methods gave the lower score to Client 2 as expected, whereas the heuristic methods did not. \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{./350all_7_5_3.pdf} \caption{Client contribution scores when Clients 1,2 and 3 had 350 training samples of 0--6 digits, 2--6 digits, and 7--9 digits, respectively.} \label{fig:res_753} \end{figure} Figure~\ref{fig:res_1} depicts that errors of scores from the naive method when changing the data amount of Clients 1 and 2, $D_1, D_2$. Here, Clients 1 and 2 had training samples of 0--6 and 2--6 digits, respectively. The proposed metric achieved a smaller gap from the naive method when the training samples of Clients 1 and 2 became larger, whereas the gaps in the other methods became larger. Figure~\ref{fig:res_2} depicts that the errors that occurred when Clients 1 and 2 had the same classes of training samples. This result shows cases in which the proposed method achieved larger errors than other methods. When $D_1$ and $D_2$ were larger than 200, the proposed method achieved lower errors than other methods as with the results shown in Figs.~\ref{fig:res_773}--\ref{fig:res_1}. On the other hand, when $D_1$ or $D_2$ was 50, the error of the proposed method became larger than other methods. When $D_1$ or $D_2$ was 50, the proposed method estimated that the contribution of the client with 50 data samples was less than other clients but not zero, while the naive method estimated that its contribution was almost zero, which made the larger gap. This is because that the model improvement at each round by a client with small but diverse data samples is little but unstable, which could cause large but temporal model improvement and increase in the step-wise contribution metric employed in the proposed method. This drawback of the proposed method can be mitigated by restricting clients with so small amount of data, which are not expected to improve the global model, from participating the FL. \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{./result_753.pdf} \caption{Errors between Naive metric and each method when Client 2 had digits of 5 classes. Average error were Proposed: 1.80, Heuristic1: 2.50, Heuristic2: 2.36.} \label{fig:res_1} \end{figure} \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{./result_773.pdf} \caption{Errors between Naive metric and each method when Client 2 had digits of 7 classes. Average error were Proposed: 3.57, Heuristic1: 2.55, Heuristic2: 3.55} \label{fig:res_2} \end{figure} \section{Conclusion} This paper proposed an intuitive and computation-and communication-efficient method to estimate the individual contribution levels of participants in FL so as to determine appropriate incentive mechanisms for participation in FL. The proposed method enabled the evaluation during a single FL training process, there by reducing the need for traffic and computation overhead. The performance evaluations using the MNIST dataset showed that the proposed method estimated the contributions of the individual clients with much smaller computation and communication overhead than those of the naive method. \bibliographystyle{IEEEtran}
{'timestamp': '2020-09-22T02:14:34', 'yymm': '2009', 'arxiv_id': '2009.09371', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09371'}
arxiv
\section{Background} In this section, we describe two important ways deep learning workloads are tightly coupled with the underlying hardware in state-of-the-art systems (\S\ref{subsec:hyperparameters}, \S\ref{subsec:model-graph}), then discuss the target setting of this paper (\S\ref{subsec:setting}). \subsection{Hyperparameters Tied to Hardware} \label{subsec:hyperparameters} Hyperparameters, such as the batch size, learning rate, and dropout rate, have important effects on the convergence of a model. For this reason, significant effort is often put into tuning these hyperparameters to achieve desirable results. The \textit{batch size} refers to the number of input examples, e.g.,\xspace images or sentences, processed within a training or inference step. Each batch is divided evenly among the hardware accelerators, which are assumed to be homogeneous. Using larger batch sizes generally improves training and inference throughput. Within a single accelerator, the \textit{local} batch size is often set to the maximum size possible within the limits of the accelerator's memory capacity, so as to maximize utilization of the accelerator and reduce the number of kernels launched on it. Across multiple accelerators, the \textit{global} batch size is simply the local batch size multiplied by the number of accelerators in the system. Thus, the larger the global batch size, the greater the number of accelerators that can be used to process the batch in parallel. However, prior work has shown that large batch sizes tend to deteriorate model convergence~\cite{large-batch}. In order to preserve convergence behavior while scaling a workload, various efforts have proposed to adjust hyperparameters dependent on the batch size, such as the learning rate~\cite{facebook-imagenet}, or even to apply custom optimization algorithms~\cite{sensetime-imagenet, tencent-imagenet, lars, bert-76-minutes}. \textbf{Hurdles for reproducibility.} Thus, reproducing existing results on a different set of hardware requires significant effort and expertise. In some cases, it is even impossible. For example, the results from training the the BERT model using a batch size of $32,000$ examples on $1,024$~TPUs~\cite{bert-76-minutes} and $1,472$~GPUs~\cite{bert-nvidia} cannot be reproduced on a smaller test bed of $16$~GPUs, as the same batch size would not fit in the smaller cluster's GPU memory. On the other hand, reducing the batch size would inevitably lead to very different convergence trajectories that require retuning various hyperparameters. This poses a major hurdle for experimentation as well as scaling. \subsection{Inflexible Model Graph} \label{subsec:model-graph} Another source of coupling between the model and the hardware lies in the \textit{model graph}, which specifies the network of operations to perform on the input data. Modern deep learning frameworks compile and optimize this graph once at the beginning of training and reuse it for the rest of the job. In addition to tensor operations, information regarding the underlying cluster configuration is also embedded into the model graph. In both TensorFlow and PyTorch, for instance, the graph is defined under a \textit{distribution strategy} that specifies how model parameters should be synchronized in different settings, such as single GPU, single machine multi-GPU, and distributed multi-GPU. \textbf{Hurdles for resource elasticity.} Once the model graph is created under a particular distribution strategy, subsequent training will use synchronization operations that involve a fixed set of hardware accelerators. Adjusting a job's resource allocation would involve rebuilding the entire graph under a new distribution strategy and reloading previously trained model parameters from a checkpoint, an expensive process that can take minutes~\cite{andrew-resource-elasticity}. Further, as discussed in~\S\ref{subsec:hyperparameters}, changing the amount of resources in the middle of a job can lead to adverse effects on the model's convergence. \subsection{Data Parallel, Synchronous Training} \label{subsec:setting} The most common form of parallelism in distributed deep learning workloads is \textit{data parallelism}, where the model graph is replicated across the hardware accelerators, and each accelerator processes its share of the batch independently. This is in contrast to \textit{model parallelism}, which partitions the model graph across the accelerators instead, and is used primarily for extremely large models that do not fit in the memory of a single accelerator. In modern workloads, data parallelism is typically combined with \textit{synchronous training}, which enforces a synchronization barrier at the end of each step, and is shown to have better convergence properties than \textit{asynchronous training}~\cite{revisiting-sync}. Gradients can be synchronized using either the parameter server architecture~\cite{parameter-server} or the all-reduce architecture~\cite{allreduce, horovod}, though the latter is increasingly common. This paper targets data parallel, synchronous training, though many of the techniques proposed are also applicable to the model parallel setting. This is explored further in~\S\ref{sec:future}. \section{Conclusion} \label{sec:conclusion} VirtualFlow\xspace is an important step towards decoupling deep learning models from the underlying hardware. Leveraging the idea of virtual node processing, VirtualFlow\xspace allows users to reproduce training results consistently across different clusters, reap the benefits of resource elasticity without worrying about model convergence, and combine multiple accelerator types to improve training throughput, all without a single change to the model specification or the hyperparameters. The benefits of virtual nodes are not limited to the use cases explored in this paper. In the future, we expect to see more complexities associated with resource management pushed into the deep learning frameworks themselves, enabling the user to focus on application-level objectives instead. \section{Resource Elasticity} \label{sec:elasticity} Jobs that run on shared clusters can benefit significantly from resource elasticity. This enables jobs to adapt their resource usage to changing allocations from the cluster scheduler, which may perform such adjustments to enforce fairness~\cite{locality2, zaharia2010delay}, preemption~\cite{pdq}, and utility-based~\cite{slaq} scheduling policies. Elasticity has been a desireable feature in many other distributed systems, including ones from batch processing~\cite{spark-autoscaling}, stream processing~\cite{stream-autoscaling}, cluster management~\cite{kubernetes-autoscaling}, and cloud computing~\cite{aws-autoscaling, azure-autoscaling, gce-autoscaling}, with important benefits such as higher cluster utilization and lower job completion time. In this section, we describe how VirtualFlow\xspace can bring the same benefits to distributed deep learning workloads by expressing elasticity in terms of redistributing virtual nodes across accelerators. \subsection{Redistributing Virtual Nodes} \label{subsec:redistributing} VirtualFlow\xspace maintains a mapping between virtual nodes and hardware accelerators, but this mapping need not be fixed over time. To enable resource elasticity, virtual nodes can be redistributed dynamically across the accelerators assigned to a job in response to cluster demand. More specifically, downsizing a job can be expressed in terms of moving virtual nodes from released hardware accelerators to the remaining ones that are still allocated to the job. Similarly, upsizing a job can be expressed in terms of migrating a subset of the virtual nodes assigned to existing accelerators to the new accelerators that were added. In both cases, the total number of virtual nodes remains the same, and so adjustments to a job's resource allocation are seamless from the perspective of the application. When scaling out, certain virtual node state must be migrated to the new accelerators, including the model parameters and certain \textit{stateful kernels}. One example of the latter is the batch normalization moving mean and variance~\cite{batch-norm}, which are computed independently on each accelerator and never synchronized. Bootstrapping new workers without also migrating these stateful kernels would effectively reset their internal state, potentially hurting convergence. VirtualFlow\xspace migrates these stateful kernels as well as the model parameters through an all-gather operation performed on the new workers. This process typically takes less than a second (similar to all-reduce) and only takes place once per resource adjustment. Figure~\ref{fig:virtual-overview} illustrates an example of resizing a job from 16 GPUs to 4 GPUs. Each batch is split into 16 equally sized virtual nodes, which were all assigned to different GPUs initially. The virtual nodes are then redistributed among the 4 remaining GPUs, such that each GPU is assigned 4 virtual nodes (instead of 1) in the new configuration. \begin{figure*}[t] \centering \setlength{\abovecaptionskip}{0mm} \setlength{\belowcaptionskip}{-3mm} \subfigure{\includegraphics[width=0.77\textwidth,trim={0 8.5cm 0 0}]{figures/het-overview.pdf}} \hspace{3mm} \subfigure{\includegraphics[width=0.2\textwidth]{figures/het-step-times.pdf}} \captionsetup{width=0.95\textwidth} \caption{(Left) VirtualFlow\xspace heterogeneous training overview. (Right) Splitting a batch evenly across a set of uneven resources is inefficient. In this workload, we wish to train ResNet-50 on ImageNet on 2 V100 GPUs and 2 P100 GPUs with a global batch size of 8192. "3072:1024 BS" means 3072 examples are assigned to each V100 GPU, while 1024 are assigned to each P100 GPU per batch. In this example, the heterogeneous solver will output the more efficient uneven configuration.} \label{fig:het-overview} \end{figure*} \subsection{Elastic Weighted Fair Sharing (WFS)} \label{subsec:wfs-scheduler} To showcase the benefits of expressing elasticity in terms of virtual nodes, we built a simple event-driven cluster scheduler that dynamically resizes deep learning jobs based on their relative weighted fair shares (WFS)~\cite{wfq}. These fair shares are computed based on the priority of the jobs, which can be set to arbitrary attributes of the job to express a variety of scheduling objectives, such as Shortest Job First (SJF) and Shortest Remaining Time First (SRTF). The main scheduling logic is summarized in Algorithm~\ref{alg:wfs-scheduler}. \begin{algorithm}[t] \small \DontPrintSemicolon \SetKw{Break}{break} \underline{function schedule} $(running\_jobs, job\_queue)$:\; $new\_allocations$ = expand current allocations\; \While{$job\_queue$ \normalfont{not empty}}{ $fair\_allocations$ = compute fair shares(\ $running\_jobs$, $job\_queue.peek()$)\; \eIf{\normalfont{no higher priority job allocations are affected}}{ $new\_allocations$ = $fair\_allocations$\; $running\_jobs \hspace{1mm} \texttt{+=} \hspace{1mm} job\_queue.dequeue()$\; }{ \Break\; } } resize jobs($new\_allocations$)\; \caption{Elastic WFS Scheduler} \label{alg:wfs-scheduler} \end{algorithm} \setlength{\textfloatsep}{8pt} This scheduler has two important distinctions from existing GPU cluster schedulers~\cite{gandiva, optimus, gavel}. First, resource adjustments need not interrupt the jobs and restart them from checkpoints. Second, while existing schedulers dynamically adjust cluster-wide resource allocations, they are unable to resize individual jobs without potentially hurting model convergence. As an example, suppose job A demands 2 GPUs and job B demands 8 GPUs, and there are no other jobs in the queue. If there are 8 GPUs in total, jobs A and B will never be able to run at the same time, and 6 GPUs will have to go idle for the entire duration of job A. Regardless of the scheduling policy, being able to dynamically adjust the resource requirement of each job will generate many new scheduling opportunities, potentially leading to higher cluster utilization~(\S\ref{subsec:elasticity}). \section{Evaluation} \label{sec:eval} We implemented VirtualFlow\xspace with resource elasticity and heterogeneous training support on top of TensorFlow $2.4$ in $2700+$ lines of code. For elasticity, we used the same mechanisms as~\cite{andrew-resource-elasticity}, in which Horovod~\cite{horovod} was used as the narrow waist communication layer that connects a changing set of worker processes. In this section, we evaluate VirtualFlow\xspace's effectiveness in reproducing results across different hardware (\S\ref{subsec:reproducibility}), exploring previously inaccessible hyperparameters (\S\ref{subsec:exploration}), providing elasticity while preserving model semantics (\S\ref{subsec:elasticity}), and enabling heterogeneous training (\S\ref{subsec:het}). \subsection{Experimental Setup} \label{subsec:experimental-setup} End-to-end reproducibility and elasticity experiments are performed on 2 servers, each with 8 NVIDIA V100 GPUs (16GB), 64 Intel Xeon CPUs (2.2Ghz), and 250GB of DRAM, connected over a 16 Gbps connection. Heterogeneous training experiments additionally use 2 extra similar servers, each with 4 NVIDIA P100 GPUs (16GB). Exploration and microbenchmark experiments use 2 NVIDIA GeForce RTX 2080Ti GPUs on a server with 32 Intel(R) Xeon(R) E5-2620v4 CPUs (2.1GHz) and 64GB of DRAM. \begin{table}[t] \small \centering \setlength\dashlinedash{0.75pt} \setlength\dashlinegap{2pt} \setlength\arrayrulewidth{0.75pt} \setlength{\abovecaptionskip}{4mm} \setlength{\belowcaptionskip}{0mm} \begin{tabular}{c|ccc|cc} \noalign{\hrule height 1.5pt} & \multicolumn{3}{c|}{VirtualFlow\xspace} & \multicolumn{2}{c}{TF*} \\ GPUs & BS & VN$_{GPU}$ & Acc (\%) & BS & Acc (\%)\\ \noalign{\hrule height 1pt} 1 & 8192 & 32 & 75.92 & 256 & 69.25\\ 2 & 8192 & 16 & 75.96 & 512 & 67.30\\ 4 & 8192 & 8 & 75.99 & 1024 & 70.68\\ 8 & 8192 & 4 & 75.83 & 2048 &73.04\\ 16 & 8192 & 2 & 75.68 & -- & --\\ 2$^{\dagger}$ & 8192 & 32 & 76.01 & -- & --\\ \hdashline Target & 8192 & -- & 76.26~\cite{facebook-imagenet} & -- & --\\ \noalign{\hrule height 1.5pt} \end{tabular} \caption{\textbf{Reproducibility:} Final top-1 validation accuracies for the same ResNet-50 experiment shown in Figure~\ref{fig:resnet-imagenet-V100}. VirtualFlow\xspace preserves the target accuracy of 76\% ($\pm$ 0.5\%) regardless of the number of GPUs assigned, while the naive solution (TF*) diverges. VN$_{GPU}$ refers to number of virtual nodes per GPU, and $\dagger$ refers to training on RTX 2080Ti GPUs instead of on V100 GPUs.} \label{tab:resnet-imagenet-V100} \end{table} \begin{table}[t] \small \centering \setlength\dashlinedash{0.75pt} \setlength\dashlinegap{2pt} \setlength{\abovecaptionskip}{4mm} \setlength{\belowcaptionskip}{0mm} \begin{tabular}{cccccc} \noalign{\hrule height 1.5pt} \multicolumn{3}{c}{} & QNLI & SST-2 & CoLA \\ GPUs & BS & VN$_{GPU}$ & Acc (\%) & Acc (\%) & Acc (\%) \\\noalign{\hrule height 1pt} 1 & 64 & 8 & 90.86 & 92.07 & 83.01\\ 2 & 64 & 4 & 91.05 & 92.35 & 84.08\\ 4 & 64 & 2 & 90.86 & 92.20 & 83.50\\ 8 & 64 & 1 & 90.88 & 91.86 & 82.45\\ \hdashline Target & 64 & -- & 90.90 & 91.97 & 82.36\\ \noalign{\hrule height 1.5pt} \end{tabular} \caption{\textbf{Reproducibility}: Final top-1 validation accuracies achieved by VirtualFlow\xspace for fine-tuning BERT-BASE across 3 GLUE tasks. VirtualFlow\xspace was able to reproduce the same training results as the state-of-the-art on a variety of hardware configurations. Previously, a batch size of 64 would not fit in the memory of 1 V100 GPU.} \label{tab:bert-base-V100} \end{table} \subsection{Reproducibility} \label{subsec:reproducibility} We demonstrate VirtualFlow\xspace can reproduce training results across different cluster sizes for two well-known deep learning workloads: ResNet-50~\cite{resnet} on ImageNet~\cite{imagenet} and BERT~\cite{bert} fine-tuning on GLUE~\cite{glue}. We varied the number of GPUs from 1 to 16 (8 for BERT) while fixing the global batch sizes, and observed almost identical convergence trajectories across different allocations for both workloads. \textbf{Baseline.} We compare VirtualFlow\xspace with a version of vanilla TensorFlow that does not retune hyperparameters across batch sizes. For example, for ResNet, we do not apply the linear scaling rule~\cite{facebook-imagenet} to tune the learning rate when attempting to simulate large workloads on smaller sets of GPUs. This setup is motivated by the fact that these optimization techniques are often workload-specific and difficult to identify for arbitrary workloads~\cite{dp-survey}. \begin{figure}[t] \centering \setlength{\belowcaptionskip}{-3mm} \includegraphics[width=0.8\linewidth]{figures/resnet-imagenet-V100.pdf} \caption{\textbf{Reproducibility:} VirtualFlow\xspace preserves the convergence trajectory across different numbers of GPUs by fixing the batch size at 8192. Naively attempting to reproduce the same workload on fewer GPUs without retuning the hyperparameters (TF*) yields lower accuracies and different convergence behavior.} \vspace{3mm} \label{fig:resnet-imagenet-V100} \end{figure} \begin{figure*}[t] \centering \subfigure{\includegraphics[width=0.26\textwidth]{figures/bert-large-glue-RTE-2080Ti.pdf}} \hspace{1mm} \subfigure{\includegraphics[width=0.26\textwidth]{figures/bert-large-glue-SST-2-2080Ti.pdf}} \hspace{1mm} \subfigure{\includegraphics[width=0.26\textwidth]{figures/bert-large-glue-MRPC-2080Ti.pdf}} \vspace{-1mm} \captionsetup{width=0.92\textwidth} \caption{\textbf{Batch size exploration} with VirtualFlow\xspace on a single RTX 2080 Ti GPU. VirtualFlow\xspace expands the space of possible batch sizes on this GPU from 4 (TF) to [4, 8, 16, 32, 64, 128], and can support even larger batch sizes. In some cases, such as in RTE (left), being able to access larger batch sizes can lead to significantly higher final accuracies (+7.1\% with a batch size of 16).} \label{fig:bert-large-2080Ti} \end{figure*} \subsubsection{ResNet-50 on ImageNet} In this experiment, we train ResNet-50 on the ImageNet dataset for 90 epochs using a fixed batch size of 8192, a widely used benchmark that is known to converge to the vicinity of 76\%~\cite{facebook-imagenet, resnet, pytorch-imagenet}. To demonstrate VirtualFlow\xspace can preserve convergence across GPU types, we ran this workload on both V100 and RTX 2080Ti GPUs. Each V100 GPU can fit a batch of 256 examples at a given time, so we use 32 total virtual nodes for these runs. For the smaller RTX 2080Ti GPUs, we use 64 total virtual nodes instead. Table~\ref{tab:resnet-imagenet-V100} demonstrates VirtualFlow\xspace can reproduce the target accuracy for all runs ($\pm 0.5\%$) across different numbers and types of GPUs. Previously, this workload required 32 V100 GPUs. With VirtualFlow\xspace, however, the user can reproduce the results for the same workload on even a single GPU. In contrast, attempts to reproduce this workload on fewer GPUs without retuning the hyperparameters (TF*) led to diverged models, e.g.,\xspace doing so on 1 GPU led to a final accuracy of only 69.25\%, far short of the target 76\%. Additionally, VirtualFlow\xspace preserves not only the final accuracy but also the entire convergence trajectory (Figure~\ref{fig:resnet-imagenet-V100}). \subsubsection{BERT-BASE Finetuning on GLUE} To demonstrate VirtualFlow\xspace's reproducibility, we also fine-tuned BERT-BASE on the GLUE dataset using a fixed batch size of 64. The GLUE tasks considered in this experiment are QNLI, SST-2, and CoLA. For QNLI and SST-2, we use 1/10th of the original dataset in each epoch and train for 20 epochs. For CoLA, we train on the whole dataset for 50 epochs. As with the ResNet workload, VirtualFlow\xspace was able to reproduce the target accuracies (obtained by running without virtual nodes) across different numbers of GPUs for all GLUE tasks by preserving the batch size and the total number of virtual nodes (Table~\ref{tab:bert-base-V100}). Unlike in the ResNet case, however, the naive approach of not retuning hyperparameters across different hardware also happened to converge to the same accuracies in these workloads (not shown). This illustrates that these workloads are less sensitive to a changing batch size within this range (8 to 64). While VirtualFlow\xspace did not lead to higher accuracies in this case, it still guaranteed that results for the batch size of 64 can be consistently reproduced across different sets of resources. \begin{figure}[t] \setlength\columnsep{6pt} \vspace{-2.5mm} \begin{multicols}{2} \centering \subfigure[VF scheduler with elasticity]{\includegraphics[width=0.23\textwidth]{figures/elasticity-3jobs-WFS.pdf}}\vspace{-2mm} \subfigure[Priority scheduler, no elasticity]{\includegraphics[width=0.23\textwidth]{figures/elasticity-3jobs-Priority.pdf}} \vspace{-1mm} \subfigure[Final accuracy]{\includegraphics[width=0.23\textwidth]{figures/elasticity-3jobs-accuracy.pdf}} \subfigure[JCT]{\includegraphics[width=0.23\textwidth]{figures/elasticity-3jobs-jct.pdf}} \end{multicols} \vspace{-3mm} \caption{\textbf{Elasticity} with VirtualFlow\xspace reduces the makespan by 38\% and the job completion time (JCT) for the highest priority job by 45\%, while preserving model accuracies. In this workload, 3 jobs share 4 V100 GPUs on a single machine.} \label{fig:elasticity-3jobs} \end{figure} \subsection{Hyperparameter Exploration} \label{subsec:exploration} Another use case of virtual nodes is to explore hyperparameters previously inaccessible on the same set of resources. To achieve this, we vary the number of virtual nodes, and consequently the batch size, while holding the number of GPUs constant, i.e.,\xspace the opposite of the previous experiments. We fine-tune BERT-LARGE on three GLUE tasks, RTE, SST-2, and MRPC, for 10 epochs on a single RTX 2080Ti GPU. Figure~\ref{fig:bert-large-2080Ti} plots the model convergence for this experiment. Unlike before, since the batch size changes across runs, so do the convergence trajectory and the final accuracy. This allows the user to explore the convergence characteristics of various batch sizes, without deploying the resources that would have been necessary to run these batch sizes using vanilla TensorFlow (e.g.,\xspace 32 GPUs for a batch size of 128). In some cases, VirtualFlow\xspace can even achieve higher accuracies in the batch sizes explored. For RTE (a reading entailment task), using a larger batch size of 16 is now possible on 1 GPU, even though this batch size required 4 GPUs before. This configuration ended up improving the final accuracy by 7 percentage points on the same set of resources. \begin{table}[t] \small \centering \setlength{\abovecaptionskip}{4mm} \begin{tabular}{ccccc} \noalign{\hrule height 1.5pt} Model & Dataset & Batch sizes & VN$_{GPU}$ \\ \noalign{\hrule height 1pt} ResNet-56 & cifar10 & 64, 128 & 1 \\ [0.1cm]ResNet-50 & ImageNet & \pbox{20cm}{\relax\ifvmode\centering\fi 256, 512, 1024\\2048, 4096, 8192} & 1, 2, 4\\[0.25cm] BERT-BASE & CoLA & 8, 16, 32, 64, 128 & 1, 2\\ BERT-BASE & SST-2 & 8, 16, 32, 64, 128 & 1, 2\\ [0.1cm]Transformer & WMT & \pbox{20cm}{\relax\ifvmode\centering\fi 4096, 8192, 16384\\32768, 65536} & 1, 2\\[0.25cm] \noalign{\hrule height 1.5pt} \end{tabular} \caption{\textbf{Elasticity:} Mix of workloads used in 20 job experiment. Each job in the trace is selected uniformly at random from this set of workloads and assigned a random priority chosen from (1, 5, 10).} \label{tab:elasticity-20jobs-workload} \end{table} \subsection{Elasticity} \label{subsec:elasticity} Another important use case enabled by VirtualFlow\xspace is resource elasticity: a job can be resized dynamically during training by adjusting the number of virtual nodes per GPU. This section describes experimental results that highlight the cluster-level benefits of this approach. \subsubsection{Elastic Scheduling with Three Jobs} Using the scheduling framework described in \S\ref{subsec:wfs-scheduler}, we ran two traces with and without VirtualFlow\xspace. The first is a simple 3-job trace designed to illustrate a scenario in which elasticity can have significant effects on cluster-level objectives. Job~0 fine-tunes BERT-BASE on SST-2, Job~1 trains ResNet-56 on cifar10~\cite{cifar10}, and Job~2 fine-tunes BERT-BASE on QNLI. The BERT jobs both demand 4 GPUs, while the ResNet job demands only 2 GPUs. The jobs arrive in the order of increasing priority, with Job 2 being the highest. Figure~\ref{fig:elasticity-3jobs} compares running this trace with the VirtualFlow\xspace scheduler, which dynamically resizes jobs to satisfy cluster-level Weighted Fair Shares (WFS), to running it with a simple priority scheduler that orders jobs in descending priority but does not resize any job. With VirtualFlow\xspace, existing jobs downsize as soon as a new job with priority arrives. With the static priority scheduler, however, the high priority Job~2 is stuck behind Job~1 for a long time, leaving 2 GPUs idle for the entire duration of Job~1. Observe that although all 3 jobs resized over the course of their respective lifetimes in the VirtualFlow\xspace case, they all converged to the same accuracies as their counterparts in the simple priority scheduler case. Thus, the VirtualFlow\xspace scheduler is able to reduce the makespan by 38\% and the high priority job completion time (JCT) by 45\%, while preserving the application-level semantics of each job. \begin{figure}[t] \centering \vspace{-2mm} \setlength\belowcaptionskip{-5mm} \subfigure{\includegraphics[width=0.35\textwidth]{figures/elasticity-20jobs-WFS.pdf}}\\[-1mm] \vspace{-8mm} \subfigure{\includegraphics[width=0.35\textwidth]{figures/elasticity-20jobs-Priority.pdf}} \vspace{-3mm} \caption{\textbf{Elasticity} with VirtualFlow\xspace (top) increases average cluster utilization by 19.5\% and reduces makespan by 45.5\%, compared to a simple priority scheduler (bottom) that does not perform elasticity. Each colored box corresponds to a job. Boxes resize for the elastic scheduler (top) but not for the static scheduler (bottom).} \label{fig:elasticity-20jobs} \end{figure} \begin{figure}[t] \centering \subfigure{\includegraphics[width=0.2\textwidth]{figures/elasticity-20jobs-queuing.pdf}} \subfigure{\includegraphics[width=0.2\textwidth]{figures/elasticity-20jobs-jct.pdf}} \vspace{-3mm} \caption{\textbf{Elasticity:} In the same 20 job experiment shown in Figure~\ref{fig:elasticity-20jobs}, VirtualFlow\xspace reduces the median JCT by 47.6\% and the median queuing delay by 99.3\% by resizing jobs dynamically.} \label{fig:elasticity-20jobs-cdf} \end{figure} \begin{table}[t] \small \centering \setlength\dashlinedash{0.75pt} \setlength\dashlinegap{2pt} \setlength\arrayrulewidth{0.75pt} \setlength{\tabcolsep}{4pt} \setlength{\belowcaptionskip}{-3mm} \begin{tabular}{r|ccc|ccc} \noalign{\hrule height 1.5pt} & \multicolumn{3}{c|}{V100} & \multicolumn{3}{c}{P100}\\ Exp & Num & BS$_{GPU}$ & VN$_{GPU}$ & Num & BS$_{GPU}$ & VN$_{GPU}$\\ \noalign{\hrule height 1pt} H1a & 1+1 & 2048 & 8 & 1+1 & 2048 & 8 \\ b & 1+1 & 3072 & 16 & 1+1 & 1024 & 4 \\ c & 1+1 & 3072 & 32 & 1+1 & 1024 & 4 \\ \hline H2a & 1+1 & 3072 & 16 & 2+2 & 512 & 2 \\ b & 1+1 & 3072 & 16 & 2+2 & 512 & 4 \\ c & 1+1 & 3072 & 16 & 2+2 & 512 & 8 \\ d & 1+1 & 3072 & 16 & 2+2 & 512 & 16 \\ \hline H3 & 1+1 & 2048 & 8 & 4+4 & 512 & 2 \\ \noalign{\hrule height 1.5pt} \end{tabular} \vspace{2mm} \caption{\textbf{Heterogeneous training} configurations for ResNet-50 on ImageNet (batch size 8192). Columns BS$_{GPU}$ and VN$_{GPU}$ refer to the batch size and number of virtual nodes assigned to each GPU of the given type respectively, and 1+1 in the Num column refers to 2 servers with 1 GPU each.} \label{tab:het-configs} \end{table} \begin{figure}[t] \small \setlength{\abovecaptionskip}{6mm} \setlength{\belowcaptionskip}{2mm} \setlength{\tabcolsep}{2pt} \includegraphics[width=0.72\linewidth, trim=0 1.75cm 0 0]{figures/het-throughputs.pdf} \hspace{1mm} \begin{tabular}[b]{cc}\noalign{\hrule height 1.5pt} & Acc (\%) \\\noalign{\hrule height 1pt} H1b & 75.97 \\ H2a & 75.92 \\ H3 & 75.80 \\ \noalign{\hrule height 1.5pt} \end{tabular} \caption{\textbf{Heterogeneous training} can improve throughput by up to 42\% while converging to same target accuracy (76\%~\cite{facebook-imagenet}) as homogeneous training. Experiment H3 had the largest improvement because the V100 only performance is most similar to the P100 only performance. The specific configurations can be found in table~\ref{tab:het-configs}.} \label{fig:het-throughputs} \end{figure} \subsubsection{Elastic Scheduling with Twenty Jobs} Next, we evaluate VirtualFlow\xspace on a more realistic trace consisting of 20 jobs arriving according to a poisson distribution, with an average load of 12 jobs per hour (average interarrival time of 5 minutes). The mixture of workloads used in this trace is selected uniformly at random from Table~\ref{tab:elasticity-20jobs-workload}. To speed up the experiment, we train each job for only a subset of the steps or epochs needed for convergence. Figure~\ref{fig:elasticity-20jobs} depicts the GPU allocations for both schedulers over time. Compared to the simple priority scheduler, enabling elasticity with VirtualFlow\xspace improved average cluster utilization from 71.1\% to 90.6\%, reduced the makespan by 45.5\%, the median JCT by 47.6\%, and the median queuing delay by 99.3\%. The largest gain from using elasticity is the reduction in queuing delay (Figure~\ref{fig:elasticity-20jobs-cdf}): most jobs are assigned some GPUs as soon as they are submitted instead of being queued behind other potentially long jobs. This is especially true for high priority jobs, which can partially preempt lower priority jobs by downsizing them. \subsection{Heterogeneous Training} \label{subsec:het} In this section, we explore the conditions under which heterogeneous training in VirtualFlow\xspace is most beneficial and evaluate the effectiveness of the heterogeneous solver~(\S\ref{subsec:het-assignment}) in searching for an efficient configuration. \begin{figure}[t] \begin{subfigure}{} \centering \setlength{\abovecaptionskip}{0mm} \setlength{\belowcaptionskip}{-2mm} \includegraphics[width=0.8\linewidth]{figures/het-solver-throughputs.pdf} \caption{\textbf{Heterogeneous solver} produces throughputs within 5.6\% of actual throughputs on average (experiments from Table~\ref{tab:het-configs}).} \vspace{3mm} \label{fig:het-solver-throughputs} \end{subfigure}{} \begin{subfigure}{} \centering \setlength{\abovecaptionskip}{0mm} \setlength{\belowcaptionskip}{-2mm} \includegraphics[width=0.8\linewidth]{figures/het-scheduler.pdf} \caption{\textbf{Heterogeneous scheduler:} Extending Gavel~\cite{gavel} to additionally consider heterogeneous allocations can reduce the average job completion time by up to 29.2\%. The cluster consists of 4 V100 GPUs, 8 P100 GPUs, and 16 K80 GPUs. (Simulation)} \vspace{3mm} \label{fig:het-scheduler} \end{subfigure}{} \begin{subfigure}{} \centering \setlength{\abovecaptionskip}{0.5mm} \setlength{\belowcaptionskip}{1mm} \includegraphics[width=0.8\linewidth]{figures/het-scheduler-8jph-top.pdf} \includegraphics[width=0.8\linewidth]{figures/het-scheduler-8jph-bottom.pdf} \caption{\textbf{Heterogeneous scheduler:} An example trace where Gavel~\cite{gavel} with heterogeneous allocations (top) reduces the average job completion time by 26.4\% compared to Gavel without (bottom). Each colored box refers to an allocation, and each box with a hatched pattern refers to a heterogeneous allocation. In this trace, 8 jobs arrive per hour on average. (Simulation)} \label{fig:het-scheduler-8jph} \end{subfigure} \end{figure} \subsubsection{Throughput and Accuracy} \label{subsubsec:het-throughput} Figure~\ref{fig:het-throughputs} demonstrates the effectiveness of heterogeneous training across different sets of resources compared to homogeneous training. Detailed configurations regarding these experiments can be found in Table~\ref{tab:het-configs}. Heterogeneous configuration H3 significantly outperformed both the V100 only (by 42.3\%) and the P100 only (by 52.4\%) homogeneous configurations. Compared to H1 and H2, H3 is best able to balance the step times of the two individual GPU types. This is because, for this workload, V100 GPUs are roughly 4x as fast as P100 GPUs, and H3 uses 2 V100 GPUs + 8 P100 GPUs. Importantly, this configuration also converged to the target accuracy of 76\%~\cite{facebook-imagenet, resnet, pytorch-imagenet}, the same as homogeneous training. VirtualFlow\xspace's heterogeneous solver accurately predicted throughputs for this set of experiments (Figure~\ref{fig:het-solver-throughputs}). In the H1 group, the V100 only configuration is the most efficient because there are not enough P100 GPUs to compensate for the difference in performance. For this group, VirtualFlow\xspace's heterogeneous solver fell back on recommending the more efficient V100 only configuration. \subsubsection{Heterogeneous Scheduler} \label{subsubsec:het-scheduler} To illustrate the benefits of heterogeneous training in a multi-tenant cluster, we extended Gavel~\cite{gavel} to additionally consider heterogeneous allocations. Although Gavel was designed for heterogeneous clusters, it only considers \textit{homogeneous} allocations. We evaluate our implementation in a simulated environment consisting of 4 V100, 8 P100, and 16 K80 GPUs, drawing from a subset of the workloads in Table~\ref{tab:elasticity-20jobs-workload}. Following~\cite{gavel}, we use a round duration of 6 minutes and their formulation of the Least Attained Service (LAS) objective. In this experiment, using heterogeneous allocations allowed the scheduler to reduce the average job completion time by up to 29.2\% (Figure~\ref{fig:het-scheduler}). At higher job arrival rates, the benefits of using heterogeneous allocations diminishes, however, and the system gracefully falls back to prior behavior. This is because leftover resources can be allocated to new jobs instead. Figure~\ref{fig:het-scheduler-8jph} illustrates an example of how heterogeneous training can improve job completion time. Individual jobs can train faster on multiple types of GPUs if there are idle resources, e.g.,\xspace the rightmost job's throughput improved by 33.7\% with 5 extra P100 GPUs in addition to the 16 K80 GPUs already assigned to it. \subsection{Microbenchmarks} \label{subsec:microbenchmarks} \begin{figure}[t] \centering \vspace{-1mm} \setlength\belowcaptionskip{-5mm} \begin{subfigure}{} \includegraphics[width=0.4\textwidth]{figures/memory-microbenchmark.pdf} \end{subfigure} \vspace{-5mm} \begin{subfigure}{} \hspace*{-1mm}\includegraphics[width=0.4\textwidth]{figures/throughput-microbenchmark.pdf} \vspace{-1mm} \caption{Peak memory and throughput on a single RTX 2080Ti GPU, normalized by the values from TensorFlow. Memory overhead scales with the model size and is constant across virtual nodes (top), while throughput scales with the number of virtual nodes for large models, due to fewer model updates (bottom).} \label{fig:microbenchmark} \end{subfigure} \end{figure} \begin{figure}[t] \centering \setlength{\belowcaptionskip}{0mm} \hspace*{-4mm}\includegraphics[width=0.85\linewidth]{figures/overhead-microbenchmark.pdf} \vspace{-2mm} \caption{Overhead on a single RTX 2080Ti GPU for batch sizes that fit within the GPU's memory, normalized by throughputs from TensorFlow. The max batch sizes for ResNet-50, Transformer, and BERT-LARGE on this GPU are 192, 3072, and 4 respectively.} \label{fig:overhead} \end{figure} Virtual node processing adds a gradient buffer to aggregate gradients across virtual nodes. This gradient buffer is the same size of the model (Figure~\ref{fig:microbenchmark} top): larger models like BERT see up to 16.2\% memory overhead. Beyond 2 virtual nodes, however, this memory overhead stays constant. Figure~\ref{fig:microbenchmark} (bottom) plots the throughput across a range of virtual nodes for the same three workloads. The global batch size increases with the number of virtual nodes, and so the frequency of potentially expensive model updates decreases proportionally. For these workloads, using virtual nodes at worst lowers the throughput by 4.2\% but can increase it by 31.4\% in some cases, especially when the model is large (BERT), since updating large models is expensive. Figure~\ref{fig:overhead} plots the overhead for workloads that already fit within the accelerator memory. In all workloads considered, the overhead is minimal; the throughput of using virtual nodes is within 88.4\% of the throughput without using virtual nodes. Note that for these single accelerator workloads, the user can simply disable virtual nodes since the job likely will not benefit from elasticity or heterogeneous training. \section{Future Directions} \label{sec:future} The virtual node abstraction is not limited to the above use cases. For instance, VirtualFlow\xspace can be extended to support: \textbf{Fault tolerance.} We can reuse existing elasticity mechanisms to migrate virtual nodes from failed workers to remaining healthy ones, and then to the new replacement workers when they become available. This would ensure training is uninterrupted from the application's perspective. In contrast, state-of-the-art solutions must restart the job from potentially stale checkpoints if even a single worker fails~\cite{checkfreq}, since the model graph does not support changes in cluster membership. \begin{figure}[t] \centering \includegraphics[width=0.95\linewidth,trim={0.25cm 4cm 3cm 0}]{figures/model-parallelism.pdf} \caption{Model parallelism combined with data parallelism today (top), versus model parallelism with virtual nodes (bottom), which lowers the resource requirement for this workload by half. This can be further optimized by pipelining the virtual nodes, which would overlap boxes F1 and F2 for example, as in GPipe~\cite{gpipe}.} \label{fig:model-parallelism} \end{figure} \textbf{Model parallelism.} Training extremely large models~\cite{gpt3, turing-nlg, megatron-lm} relies on \textit{model parallelism}, which partitions, instead of replicates, the model across the accelerators in the system. The model can be partitioned by layer or groups of layers (as in pipeline parallelism~\cite{gpipe}) and/or by slices within each layer (spatial partitioning~\cite{mesh-tensorflow}). In both cases, model parallelism is often used in conjunction with data parallelism~\cite{gpipe, flexflow, mesh-tensorflow}, where each partition of the model is additionally replicated across multiple accelerators, and the input batch is divided evenly among these accelerators (Figure~\ref{fig:model-parallelism}, top). The techniques presented in this paper can still be applied to this setting to reduce resource requirements along the \textit{batch} dimension. More specifically, within each model partition, the input batch can be divided among virtual nodes rather than physical accelerators, and multiple virtual nodes can be mapped to each accelerator as before. The system would effectively unroll the data parallel pipelines into sequential forward and backward passes (Figure~\ref{fig:model-parallelism}, bottom), thus trading off compute time for lower resource requirement as in VirtualFlow\xspace. This would bring the benefits of reproducibility, elasticity and heterogeneous training to the model parallelism setting as well. Exploring how to pipeline these virtual nodes for higher efficiency (as in GPipe~\cite{gpipe} and PipeDream~\cite{pipedream}) would be an interesting future direction. \section{Heterogeneous Training} \label{sec:het} An important assumption made by state-of-the-art frameworks is resource allocations must be \textit{homogeneous}. However, this idealistic assumption is not well-suited for today's clusters with multiple generations of hardware accelerators, which are increasingly common~\cite{gavel, deep-learning-cluster-analysis}. Similarly, in a research lab setting, users may only have access to a scarce, assorted collection of various accelerator types. However, today's deep learning jobs are limited to individual accelerator types and must leave unused accelerators of different types idle. VirtualFlow\xspace relaxes this assumption by allowing users to combine multiple accelerator types in the same job, potentially leading to significant improvements in job throughput and cluster utilization. There are two main challenges involved, however. First, how to distribute virtual nodes across heterogeneous resources efficiently~(\S\ref{subsec:het-assignment})? Second, how to provide the same semantics as homogeneous training~(\S\ref{subsec:het-correctness})? \subsection{Virtual Node Assignment} \label{subsec:het-assignment} The key intuition is to assign more virtual nodes to the resource types with higher compute capabilities, so as to balance the step times across the different accelerator types. This allows users to scale their workloads by reducing the amount of computation required on the each set of homogeneous accelerators, thereby improving the overall throughput. For additional flexibility in deciding how to split the batch across the heterogeneous set of resources, we further relax the assumption in VirtualFlow\xspace that the size of each virtual node must be the same across all accelerators. Then, determining an efficient assignment of virtual nodes involves two steps, as outlined in Figure~\ref{fig:het-overview} (left). First, VirtualFlow\xspace performs an offline profile of the given workload on all target accelerator types. Then, using these offline profiles, VirtualFlow\xspace solves for a configuration that minimizes the overall step time. \subsubsection{Offline Profile} \label{subsubsec:het-profile} To generate an offline profile, VirtualFlow\xspace runs the given workload on a single hardware accelerator at a time across all batch sizes of interest that fit in the accelerator's memory. Due to memory alignment, we only consider batch sizes that are powers of 2 or power-of-2-like numbers (e.g.,\xspace 48, 192, 768), which are the mid-points between adjacent powers of 2. The process is then repeated on all accelerator types and the result is a set of throughput over batch size curves (Figure~\ref{fig:het-overview}, left), one for each accelerator type. For each batch size, we only need to run a few steps (e.g.,\xspace 20) to arrive at a representative average throughput, since the performance is typically consistent across steps. Therefore, the entire process typically takes no longer than 10 minutes, a small fraction of the job duration for many deep learning workloads, which can run for many hours or even days. \subsubsection{Heterogeneous Solver} \label{subsubsec:het-solver} To understand why a solver is necessary, consider the scenario in Figure~\ref{fig:het-overview} (right), in which we are given 2 V100 GPUs and 2 P100 GPUs, all with the same memory capacity of 16GB. A naive, even split of the batch would assign the same amount of data and the same number of virtual nodes to each GPU, regardless of the GPU type. However, this configuration is inefficient, because, for this workload, V100 GPUs are 4x as fast as P100 GPUs, so the system will be bottlenecked on the P100 GPUs, leaving the V100 GPUs idle for a large fraction of the training time. Instead, an uneven split that assigns more data in each batch to the V100 GPUs will result in a much shorter (44\%) overall step time. In order to arrive at an appropriate split across the different accelerator types, we formulate the problem as follows. For simplicity, we treat the resources as GPUs: \setlength{\abovedisplayskip}{-3pt} \setlength{\belowdisplayskip}{-3pt} \setlength{\abovedisplayshortskip}{-3pt} \setlength{\belowdisplayshortskip}{-3pt} \begin{align*} \text{Objective} \quad & \min{\max_i{(t_i(b_i) \cdot v_i + comm)}}\\ \text{Constraint} \quad & \sum_i{n_i \cdot b_i} = B\\ \text{Solve for} \quad & b_i, v_i, n_i \quad \forall i \end{align*} \begin{align*} B &= \text{Global batch size}\\ b_i &= \text{Per GPU batch size for GPU type $i$}\\ v_i &= \text{Num virtual nodes on each GPU of type $i$}\\ t_i(b_i) &= \text{Step time on GPU type $i$}\\ n_i &= \text{Number of GPUs of type $i$}\\ comm &= \text{Communication overhead}\\ \end{align*} \noindent This objective aims to equalize the step times across all GPU types so as to minimize the overall step time, which is bottlenecked by the slowest GPU. We multiply the step time by the number of virtual nodes $v_i$ to reflect the fact that virtual nodes on a given GPU are executed sequentially. The step times for each GPU type $t_i$ are constants supplied by offline profiles computed previously. The communication overhead $comm$ can be estimated as part of the offline profile by taking the difference between the distributed and single node step times, using synthetic data and a local batch size of 1 in both cases to isolate the time spent on gradient synchronization. The solver falls back to recommending homogeneous allocations when there are no heterogeneous combinations that can improve the throughput of the job. This can happen if the compute capabilities are vastly different across the GPU types, and there are not enough of the slower GPUs to compensate for the discrepancy in performance. \subsection{Correctness} \label{subsec:het-correctness} An important goal of VirtualFlow\xspace is to preserve training semantics regardless of the underlying hardware configuration. Maintaining this abstraction for heterogeneous training involves solving two main challenges: \textbf{Gradient synchronization.} Existing implementations of gradient synchronzation first take the average of the gradients computed on the local batch, then take the average of these local averages across all hardware accelerators. On heterogeneous resources, however, this method can produce incorrect gradients. For instance, suppose we assign 6 input examples to GPU0 and 2 input examples to GPU1 in each batch. Taking a simple average will result in: { \small \vspace{-3mm} \begin{align*} \frac{1}{2}\left(\frac{g_1 + ... + g_6}{6}\right) + \frac{1}{2}\left(\frac{g_7 + g_8}{2}\right) = \frac{g_1 + ... + g_6 + 3(g_7 + g_8)}{12} \end{align*} \vspace{-3mm} } \noindent where the gradients on GPU1 are weighed disproportionately compared to the rest. Instead, VirtualFlow\xspace performs a \textit{weighted average} during gradient synchronization: { \small \vspace{-3mm} \begin{align*} \frac{3}{4}\left(\frac{g_1 + ... + g_6}{6}\right) + \frac{1}{4}\left(\frac{g_7 + g_8}{2}\right) = \frac{g_1 + ... + g_8}{8} \end{align*} \vspace{-3mm} } \noindent This ensures all gradients are considered equally regardless of how the data is distributed across the accelerators. \textbf{Data sharding.} Similarly, existing sharding techniques assume the batch is split evenly across the accelerators. Naively reusing these techniques for heterogeneous training will result in certain input examples being observed more often than others. VirtualFlow\xspace maintains the exactly-once data semantics of homogeneous training by sharding the dataset unevenly to match the relative local batch sizes (e.g.,\xspace 4:1) across the different accelerator types. \section{Introduction} Modern deep learning frameworks, such as TensorFlow~\cite{tensorflow} and PyTorch~\cite{pytorch}, make a number of simplifying assumptions about the environment in which deep learning jobs are run today. First, a model's convergence behavior need not be preserved across different hardware configurations. Instead, the burden falls on the user to retune the hyperparameters and apply custom optimization techniques in order to achieve the same training results~\cite{facebook-imagenet, tencent-imagenet, bert-76-minutes}. Second, resource allocations are tied to the lifetime of a job; any adjustment to a job's allocation requires interrupting the job and restarting it from checkpoints. Third, the set of resources allocated to a job must be homogeneous. \begin{figure}[t] \centering \includegraphics[width=\linewidth,trim={3cm 0.65cm 3cm 0},clip=true]{figures/virtual-overview.pdf} \caption{\textbf{Virtual node processing.} A batch is split into $16$~equally sized virtual nodes (colored shapes), which are distributed among the GPUs. Virtual nodes assigned to the same GPUs are executed sequentially, allowing 4 GPUs to train the same model as 16 GPUs using the same set of hyperparameters, including the batch size. } \vspace{-4mm} \label{fig:virtual-overview} \end{figure} In light of recent trends, however, the above assumptions fall short in today's practical circumstances. First, the scale of deep learning workloads continues to rise dramatically: model sizes have grown to billions of parameters~\cite{megatron-lm, turing-nlg, gpt3}, dataset sizes to hundreds of GBs~\cite{imagenet, t5}, and batch sizes to $64$K and above to allow for increased parallelism~\cite{tencent-imagenet, sensetime-imagenet}. Hardware advances have been slow to catch up, however, leading to high computational requirements for these larger workloads. For instance, BERT has been pre-trained on $16$~TPUs~\cite{bert} and up to $1024$~TPUs~\cite{bert-76-minutes}, and Megatron-LM, with $8.3$~billion parameters, has been trained on $512$ V100~($32$GB) GPUs~\cite{megatron-lm}. But given the inability to translate convergence across hardware, these results are often unrepeatable for most researchers. Second, shared clusters with a heterogeneous mix of GPUs are increasingly common. For instance, Microsoft reports using a large, multi-tenant cluster consisting of thousands of GPUs of various types shared among hundreds of users~\cite{deep-learning-cluster-analysis}. Resource heterogeneity is also common in small research lab settings, which often accumulate multiple generations of GPUs over the years~\cite{gavel}. Yet systems today are unable to leverage this heterogeneity for individual training jobs. \subsection{New Challenges} \label{subsec:challenges} These recent trends raise new important challenges or exacerbate existing ones for today's deep learning workloads: \textbf{High resource requirement.} Many new workloads require large clusters of expensive hardware accelerators that are inaccessible to most users. \textbf{Lack of experimentation.} With the increase in scale, users may wish to experiment on a small testbed before deploying the model on a large cluster. However, this is not possible today: the original batch size will not fit in the memory limits of the testbed, and changing the batch size may compromise the convergence of the model. \textbf{Lack of reproducibility.} More generally, training results cannot be easily reproduced across different hardware. This is because training the same model on a different set of resources typically requires adjusting the batch size and retuning dependent hyperparameters, such as the learning rate, in order to achieve the same training results~\cite{facebook-imagenet, sensetime-imagenet, tencent-imagenet, bert-76-minutes}. This is cumbersome in practice, and techniques proposed for one workload often do not work for another~\cite{dp-survey}. \textbf{Adapting to dynamic resource availability.} Existing attempts to dynamically adjust a job's resource allocation must interrupt and restart the job~\cite{gandiva, optimus, gavel}, since resource allocations are static in today's deep learning systems. However, this is inefficient, because each adjustment can take minutes~\cite{andrew-resource-elasticity}. Further, the batch size may change across restarts, potentially affecting the convergence of the model. \textbf{Adapting to heterogeneous environments.} Today, deep learning jobs are restricted to single types of accelerators. Being able to additionally utilize leftover accelerators of different types can lead to faster jobs and higher cluster utilization. \subsection{Decoupling Model from Hardware} All of the above challenges largely stem from a central drawback in today's deep learning systems: \textit{a tight coupling between the model and the underlying hardware}. This coupling comes from two main sources: \textbf{Model graph.} Today's frameworks embed hardware configuration information into the model graph itself. Tensor operations are explicitly placed on specific accelerators, and communication operations involve a fixed set of accelerators. \textbf{Batch size.} The batch size, an important hyperparameter that has a large effect on the convergence trajectory of a model~\cite{large-batch}, is often tied to the memory capacity of individual hardware accelerators and the number of such accelerators in the cluster~\cite{facebook-imagenet, tencent-imagenet, sensetime-imagenet}. If the global batch size exceeds the cluster-wide memory limit, the workload will simply fail. In this paper, we argue that systems-level constraints should be decoupled from application-level semantics. A model should converge to the same accuracy regardless of the set of resources it is trained on. Performance should degrade gracefully with the amount of resources assigned to a job. The user should be able to tune the model's hyperparameters once and train the model everywhere, and the result should be the same across different hardware configurations. The same philosophy can be observed in many big-data analytics systems. In MapReduce-style batch processing~\cite{mapreduce, spark} and stream processing workloads~\cite{storm, flink, spark-streaming}, the system always computes the same answers regardless of the level of parallelism and the amount of resources assigned to the job. The input data is sliced into many small partitions to be processed in multiple sequential waves of tasks, and the job would not fail if the amount of data processed in a single wave did not fit in the aggregate memory of the system. \subsection{Virtual Node Processing} Towards this goal of separating the model from the hardware, this paper introduces \textit{virtual nodes} as a substrate for distributing computation across hardware accelerators (Figure~\ref{fig:virtual-overview}). In this paradigm, each batch of the input data is partitioned among virtual nodes instead of hardware accelerators. One or more virtual nodes are then mapped to each hardware accelerator and processed sequentially on the accelerator, thus producing one or more MapReduce-style waves of execution within each step of training or inference. VirtualFlow\xspace's approach leverages the insight that all virtual nodes share the same model parameters. This allows the model to be cached in each accelerator's memory at the beginning of the step and efficiently reused by all virtual nodes mapped to that accelerator. The gradients produced by these virtual nodes are then aggregated into a shared memory buffer on the accelerator, thus adding a small, constant overhead independent of the number of virtual nodes used~(\S\ref{subsec:execution}). Virtual node processing allows VirtualFlow\xspace to preserve model convergence behavior across different hardware by fixing the total number of virtual nodes, and thus the batch size and other hyperparameters. Instead, only the mapping between virtual nodes and hardware accelerators need to be adjusted. This enables new important use cases: \textbf{Lower resource requirement.} Workloads that previously required large clusters can now be packed into smaller ones by mapping many virtual nodes to each accelerator. \textbf{Reproducibility and experimentation} on smaller test beds is now possible, as results obtained by other users can now be reproduced on a different set of resources without modification of any hyperparameter or optimization strategy. \begin{figure} \centering \setlength{\abovecaptionskip}{1mm} \setlength{\belowcaptionskip}{-3mm} \includegraphics[width=0.85\linewidth]{figures/bert-large-glue-RTE-2080Ti-2lines.pdf} \caption{Training with virtual nodes (batch size 16) achieved a higher accuracy than was previously possible on the same set of resources. In this task, we fine-tune BERT-LARGE on the Recognizing Textual Entailment~(RTE) task on a single RTX 2080Ti GPU.} \label{fig:bert-large-rte-2lines} \end{figure} \textbf{Hyperparameter exploration.} Batch sizes previously exceeding the aggregate limits of the underlying cluster are now accessible. In certain workloads, being able to access these batch sizes can lead to higher model accuracies~(Figure~\ref{fig:bert-large-rte-2lines}). \textbf{Resource elasticity.} Dynamically resizing a job while maintaining convergence guarantees---previously an open challenge~\cite{andrew-resource-elasticity}---is now possible. VirtualFlow\xspace achieves this by redistributing the virtual nodes among the new set of accelerators. When scaling out, important virtual node state such as model parameters and certain stateful kernels (e.g.,\xspace batch normalization variables~\cite{batch-norm}) are migrated in an all-gather operation to bootstrap the new workers~(\S\ref{subsec:redistributing}). Unlike in state-of-the-art schedulers, the transition is seamless from the application's perspective and the job need not be restarted. \textbf{Heterogeneous training}---combining multiple types of accelerators in the same job---can be expressed as distributing virtual nodes unevenly across the accelerators, thereby assigning more data to the more powerful types. Given a workload and a set of heterogeneous resources, VirtualFlow\xspace solves for the most efficient configuration(s) using offline profiles (\S\ref{subsec:het-assignment}) and ensures training correctness by performing weighted gradient synchronizations (\S\ref{subsec:het-correctness}). We implemented {VirtualFlow\xspace} on top of TensorFlow and evaluated the system on a set of representative deep learning models (ResNet~\cite{resnet}, BERT~\cite{bert}, Transformer~\cite{transformer}). To showcase the benefits of heterogeneous training in a multi-tenant setting, we also extended Gavel~\cite{gavel} to consider heterogeneous allocations (\S\ref{subsubsec:het-scheduler}). In our evaluation, {VirtualFlow\xspace} demonstrates strong model convergence guarantees across different hardware, improves cluster utilization by 20\% and reduces job completion time by 48\% with elasticity, and improves job throughput by 42\% with heterogeneous training. \section{Related Work} \label{sec:related} \textbf{Gradient accumulation.} The execution of virtual nodes is similar to gradient accumulation in PyTorch~\cite{pytorch-grad-accum} and a variant of asynchronous training that synchronizes gradients every $k$ steps~\cite{ksync, adacomm, elastic-bsp}. VirtualFlow\xspace is a generalization of these approaches: virtual nodes not only allow users to simulate larger batch sizes, but also provide a general abstraction that enable elasticity and heterogeneous training. \textbf{Virtual nodes.} The use of virtual nodes to decouple from hardware is not new. Chord~\cite{chord} uses virtual nodes to map multiple ring segments to the same server, and Dynamo~\cite{dynamo} uses virtual nodes to dynamically balance load across servers in the system. VirtualFlow\xspace borrows from these ideas. \textbf{Elasticity mechanism.} Resource elasticity for deep learning has been explored in~\cite{andrew-resource-elasticity}, and our implementation builds on top of the resizing mechanisms they introduced. Elastic Horovod~\cite{elastic-horovod} and TorchElastic~\cite{torchelastic} also provide elasticity mechanisms for deep learning. Unlike VirtualFlow\xspace, however, these approaches do not provide model convergence guarantees as they allow the global batch size to change throughout training. \textbf{Cluster scheduling.} Multi-tenant GPU cluster schedulers such as Optimus~\cite{optimus}, Tiresias~\cite{tiresias}, Gandiva~\cite{gandiva}, Themis~\cite{themis}, and Gavel~\cite{gavel} dynamically migrate jobs across GPUs to achieve various cluster-level objectives. However, unlike VirtualFlow\xspace, these approaches constantly interrupt and restart jobs when adjusting their resource allocations (e.g.,\xspace every 6 minutes~\cite{gavel}), and assume fixed resource requirements for each job, thus limiting the scheduling options available. Antman~\cite{antman} can adjust resource allocations seamlessly by swapping to and from host memory, but only for co-located jobs that share the same accelerators. \textbf{Heterogeneous training.} Gavel~\cite{gavel} introduces policies for heterogeneous clusters, but only makes homogeneous allocations. Extending their scheduler to additionally consider VirtualFlow\xspace's heterogeneous training opens up new scheduling options, which can improve cluster utilization (\S\ref{subsubsec:het-scheduler}). \section{Virtual Node Processing} \label{sec:virtual} \begin{figure}[t] \centering \setlength{\abovecaptionskip}{0mm} \setlength{\belowcaptionskip}{-1mm} \vspace{-3mm} \includegraphics[width=0.9\linewidth, trim={-0.75cm 10cm 13.5cm 0}]{figures/mapping.pdf} \caption{Mapping between virtual nodes and hardware accelerators is flexible, but only virtual nodes affect model convergence. Thus, changes to resource allocations are hidden from the application.} \vspace{-3mm} \label{fig:mapping} \end{figure} The core concept in VirtualFlow\xspace is virtual node processing, a layer of indirection between the model and the hardware. From the model's perspective, \textit{virtual nodes}, rather than hardware accelerators, perform the computation. As long as the total number of virtual nodes is unchanged, the batch size and thus the convergence properties of the model also remain the same. Then, flexibility in resource allocation comes from adjusting the mapping between the virtual nodes and the underlying hardware accelerators, which have no effect on model training semantics (Figure~\ref{fig:mapping}). \subsection{Time and Resource Trade-off} \label{subsec:tradeoff} Today's deep learning systems are a special case of virtual node processing that uses one virtual node per hardware accelerator (Figure~\ref{fig:virtual-tradeoff}a). However, this is only one possible configuration in the trade-off space between time and resource requirements. VirtualFlow\xspace divides the compution in each batch in the time dimension as well as the spatial dimension (Figure~\ref{fig:virtual-tradeoff}b and c), processing the virtual nodes assigned to the same accelerators sequentially. This provides users with the freedom to gracefully fall back to running on fewer accelerators with longer training times. This flexibility is crucial to model reproducibility, experimentation, and hyperparameter exploration. By preserving convergence behavior across different hardware configurations (e.g.,\xspace Figure~\ref{fig:virtual-tradeoff}a, b, and c), VirtualFlow\xspace allows users to replicate training results produced by others regardless of the resources used. Experimentation on smaller testbeds is now possible by using many virtual nodes on each hardware accelerator to mimic the larger deployment. On the other hand, users can explore the effects of using previously inaccessible batch sizes on the same set of resources by increasing the number of virtual nodes used on each accelerator. \begin{figure}[t] \centering \setlength{\belowcaptionskip}{0mm} \vspace{-3mm} \includegraphics[width=0.85\linewidth,trim={0cm 6cm 11cm 0.25cm}]{figures/virtual-tradeoff.pdf} \vspace{-2mm} \caption{Virtual node trade-off between resource requirement and time requirement. VN in this figure refers to number of virtual nodes assigned to each hardware accelerator. The design space for today's deep learning workloads is limited to only (a).} \vspace{-3mm} \label{fig:virtual-tradeoff} \end{figure} \begin{figure*}[t] \centering \setlength{\belowcaptionskip}{-1mm} \includegraphics[width=0.95\linewidth,trim={0 4cm 0 3cm}]{figures/memory-cycle.pdf} \vspace{0mm} \captionsetup{width=0.95\textwidth} \caption{ Memory footprint of virtual node processing in a single training step. The model parameters and the gradient buffer are shared across all virtual nodes on each accelerator, while the memory used in each forward and backward pass is specific to individual virtual nodes. Memory overhead from the gradient buffer is a small constant independent of the number of virtual nodes $V$ per accelerator. } \label{fig:memory-cycle} \end{figure*} \subsection{Virtual Node Execution} \label{subsec:execution} Each batch of the input data is split among the virtual nodes in a manner analogous to how a job in MapReduce is divided into tasks. Virtual nodes assigned to the same hardware accelerator are processed sequentially, while virtual nodes assigned to different accelerators are still processed in parallel. This produces one or more \textit{waves} of execution, similar to MapReduce workloads where the number of tasks is often a small multiple of the number of CPU slots in the system. Figure~\ref{fig:memory-cycle} traces the steps involved in processing a single batch of data with virtual node processing. In each training step, VirtualFlow\xspace computes $V$ forward and backward passes, where $V$ is the number of virtual nodes on each accelerator. During the forward pass, VirtualFlow\xspace computes the activations while prefetching inputs for the next virtual node in the background~(Step~1). At the end of the backward pass~(Step~2), local gradients are aggregated into a gradient buffer shared across all virtual nodes on the accelerator~(Step~3). When there are no more virtual nodes to process, the locally aggregated gradients are synchronized across the cluster~(Step~4) and each accelerator independently applies the averaged gradients to its copy of the model as before~(Step~5). An important insight of VirtualFlow\xspace's approach is that the model can be cached in memory to be efficiently reused in all $V$ forward passes. If there is only a single virtual node per accelerator ($V = 1$), the system falls back to prior behavior. \subsection{Memory Overhead} \label{subsec:memory-overhead} \begin{figure} \centering \setlength{\belowcaptionskip}{-4.5mm} \includegraphics[width=0.85\linewidth, trim={0 0 0 0.75cm}]{figures/resnet-memory-breakdown.pdf} \caption{Memory usage in the first 3 steps of training ResNet-50 on ImageNet~\cite{imagenet} on a single 2080 Ti GPU, broken down by category. Activations constitute the vast majority of memory usage at the peak. The first step is slower due to initial graph optimizations.} \label{fig:resnet-memory-breakdown} \end{figure} The gradient buffer in VirtualFlow\xspace is a source of memory overhead (Figure~\ref{fig:memory-cycle}). However, because this buffer is shared among all virtual nodes assigned to the same accelerator, the memory overhead is a \emph{constant} independent of the number of virtual nodes on the accelerator. The size of this buffer is the same as the model, which is a small fraction of the peak memory usage for most workloads. Instead, memory usage is typically dominated by activations computed during the forward pass, which scale with the batch size while the model does not. For example, when training ResNet-50 on ImageNet, the activations typically require over $8$GB, while the model is only around $104$MB (see Fig.~\ref{fig:resnet-memory-breakdown}).
{'timestamp': '2021-05-13T02:03:47', 'yymm': '2009', 'arxiv_id': '2009.09523', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09523'}
arxiv
\subsection{Synthetic data} \begin{figure*}[t] \begin{centering} \begin{tabular}{cc} \subfloat[Noise-free $10\times10$ input matrix. \label{fig:synthetic_small_wo_noise}]{\centering{}\includegraphics[width=0.95\columnwidth]{figures/synthetic/auc_vs_hidden_binary_ver2_4models_dataSize5000_length20_input100_1layers_epoch100_seed0+1+2__mlpDrop0. 1_condDec_norm}} & \subfloat[Noisy $10\times10$ matrix inputs. \label{fig:synthetic_small_with_noise}]{\centering{}\includegraphics[width=0.95\columnwidth]{figures/synthetic/auc_vs_hidden_binary_ver2_4models_dataSize5000_length20_input100_1layers_epoch100_seed0_noise0. 2__mlpDrop0. 1_condDec_norm}}\tabularnewline \end{tabular} \par\end{centering} \caption{Behaviors of LSTM vs. matLSTM in synthetic data experiments on clean and noisy data. Performance measure is AUC against the number of parameters.} \end{figure*} In this section, we conduct three different ablation studies on a synthetic dataset: (1) noise-free, (2) noisy, and (3) long movement pattern. In each study, the data are sequences of binary matrices generated as follows: \begin{align*} X_{1} & =\left[X_{1}^{ij}\sim\text{Bern}\left(0.5\right)\right]_{i=1:n_{r},j=1:n_{c}}\\ X_{t} & =\text{circshift}\left(X_{t-1},\text{Uniform}\{1,5\}\right),\qquad t=2:T \end{align*} where circshift is the circular shift of the matrix to the right by $c\sim\text{Uniform}\left\{ 1,5\right\} $ columns, $n_{r}=10$ and $n_{c}=10$ are the number of rows and columns respectively, and $T=20$ is the sequence length. The abnormal data sequences are created similarly but instead of the right-shifting pattern, we use a random permutation of columns. Each of the train and test set consists of 5,000 sequences with 5\% outlier. We randomly take 20\% of the train set for validation. For simplicity, we only examine the single-layer models in this setting. \subsubsection*{Noise-free data} Fig.~\ref{fig:synthetic_small_wo_noise} compares the performance of matLSTM to LSTM on the test set. As shown, performance improves with more model capacity, but the matLSTMs improve much faster, suggesting matLSTMs can capture the multi-way structure better than LSTMs. In this setting, both compression (Sec.~\ref{subsec:Lossy-sequence-compression}) and prediction strategies (Sec.~\ref{subsec:Predicting-the-unrolling}) work well for matLSTM models while for vector models, the prediction strategy is more robust than the compression strategy. \subsubsection*{Noisy data} In this setting, we randomly set 20\% of the pixels to zero at each timestep but keep the moving pattern the same as the noise-free cases. The results are shown in Fig.~\ref{fig:synthetic_small_with_noise}. With noisy inputs, the performance of vector models drop, while matrix models retain their near-perfect performance. \subsubsection*{Longer movement pattern data} In this setting, we investigate the changes in performances of matLSTM vs. LSTM when the moving pattern is longer. We make the data matrices horizontally longer by increasing $n_{c}=100$. Table~\ref{tab:synthetic-longer-pattern} shows that both vector LSTM methods require more number of free parameters than matLSTM to recognise the moving patterns. \begin{table}[h] \begin{centering} \begin{tabular}{|c|c|c|} \hline Models & \#params & AUC\tabularnewline \hline \hline 1-layer LSTM-AutoEncoder & 472k & 94.7 $\pm$ 0.2\tabularnewline \hline 2-layer LSTM-AutoEncoder & 505k & 93.9 $\pm$ 0.7\tabularnewline \hline 1-layer LSTM-Encoder-Predictor & 472k & 95.3 $\pm$ 0.4\tabularnewline \hline 2-layer LSTM-Encoder-Predictor & 505k & 87.1 $\pm$ 0.5\tabularnewline \hline 1-layer matLSTM-AutoEncoder & 104k & 100.0 $\pm$ 0.0\tabularnewline \hline 2-layer matLSTM-AutoEncoder & 177k & 100.0 $\pm$ 0.0\tabularnewline \hline 1-layer matLSTM-Encoder-Predictor & 104k & 100.0 $\pm$ 0.0\tabularnewline \hline 2-layer matLSTM-Encoder-Predictor & 177k & 100.0 $\pm$ 0.0\tabularnewline \hline \end{tabular} \par\end{centering} \caption{LSTM vs. matLSTM in longer horizontal movement pattern, matrix size $10\times100$, on synthetic data. \label{tab:synthetic-longer-pattern}} \end{table} \subsection{Moving permuted digits} \begin{figure*}[t] \begin{centering} \begin{tabular}{cc} \subfloat[Noise-free input. \label{fig:mnist_wo_noise}]{\centering{}\includegraphics[width=0.95\columnwidth]{figures/moving_mnist/train-on-60000-images/eval_loss_bce_with_logits_auc_vs_hidden_dataVer5_shuffle1_4models_outlierRatio0. 0_train60000_epoch100_seed0+1+2_mlpDrop0. 1_condDec_norm}} & \subfloat[Salt and pepper noise added. \label{fig:mnist_with_noise}]{\centering{}\includegraphics[width=0.95\columnwidth]{figures/moving_mnist/train-on-60000-images/eval_loss_bce_with_logits_auc_vs_hidden_dataVer5_shuffle1_4models_outlierRatio0. 0_train60000_epoch100_seed0+1+2_noise0. 1_mlpDrop0. 1_condDec_norm}}\tabularnewline \end{tabular} \par\end{centering} \caption{Results on moving MNIST. } \end{figure*} \begin{figure*}[t] \begin{centering} \begin{tabular}{cc} \textbf{Normal data} & \textbf{Abnormal data}\tabularnewline \subfloat[LSTM-AutoEncoder vs. matLSTM-AutoEncoder. \label{fig:mnist_recon_normal}]{\centering{}\includegraphics[clip,width=0.8\columnwidth]{figures/moving_mnist/no_noise/recon_normal_19}} & \subfloat[LSTM-AutoEncoder vs. matLSTM-AutoEncoder. \label{fig:mnist_recon_abnormal}]{\centering{}\includegraphics[width=0.8\columnwidth]{figures/moving_mnist/no_noise/recon_outlier_43}}\tabularnewline \subfloat[LSTM-Encoder-Predictor vs. matLSTM-Encoder-Predictor. \label{fig:mnist_predict_normal}]{\centering{}\includegraphics[width=0.8\columnwidth]{figures/moving_mnist/no_noise/predict_normal_17}} & \subfloat[LSTM-Encoder-Predictor vs. matLSTM-Encoder-Predictor. \label{fig:mnist_predict_abnormal}]{\centering{}\includegraphics[width=0.8\columnwidth]{figures/moving_mnist/no_noise/predict_outlier_21}}\tabularnewline \end{tabular} \par\end{centering} \caption{LSTM vs. matLSTM methods on \emph{clean} normal and abnormal data. In each figure, the top row is the original sequence, the middle row result is by LSTM, and the bottom row result is by matLSTM. \emph{The rows and columns of each image are permuted in the actual models}. Original images are shown for ease of interpretation only.} \end{figure*} \begin{figure*}[h] \begin{centering} \begin{tabular}{cc} \textbf{Normal data} & \textbf{Abnormal data}\tabularnewline \subfloat[LSTM-AutoEncoder vs. matLSTM-AutoEncoder. \label{fig:mnist_recon_normal_sp_noise}]{\centering{}\includegraphics[width=0.8\columnwidth]{figures/moving_mnist/salt_pepper_noise/recon_normal_19}} & \subfloat[LSTM-AutoEncoder vs. matLSTM-AutoEncoder. \label{fig:mnist_recon_abnormal_sp_noise}]{\centering{}\includegraphics[width=0.8\columnwidth]{figures/moving_mnist/salt_pepper_noise/recon_outlier_43}}\tabularnewline \subfloat[LSTM-Encoder-Predictor vs. matLSTM-Encoder-Predictor. \label{fig:mnist_predict_normal_sp_noise}]{\centering{}\includegraphics[width=0.8\columnwidth]{figures/moving_mnist/salt_pepper_noise/predict_normal_17}} & \subfloat[LSTM-Encoder-Predictor vs. matLSTM-Encoder-Predictor. \label{fig:mnist_predict_abnormal_sp_noise}]{\centering{}\includegraphics[width=0.8\columnwidth]{figures/moving_mnist/salt_pepper_noise/predict_outlier_21}}\tabularnewline \end{tabular} \par\end{centering} \caption{LSTM vs. matLSTM methods on \emph{noisy} normal and abnormal data. In each figure, the top row is the original sequence, the middle row result is by LSTM, and the bottom row result is by matLSTM. \emph{The rows and columns of each image are permuted in the actual models}. Original images are shown for ease of interpretation only. } \end{figure*} For ease of visualisation, we generate moving digits from the MNIST dataset. MNIST dataset contains 60,000 images in the train set and 10,000 images in the test set. For normal sequences, we first select a random slope between $\left[0,2\pi\right]$ and move the digit along a straight line; for abnormal sequences, we also select a random slope between $\left[0,2\pi\right]$ but the digit moves along a curved line. A curved line has a slightly different moving pattern compared to a straight line, therefore we want to investigate if all models can discriminate between two moving patterns. We use all of the 60,000 digits in the MNIST train set to form the train set of moving digit data, and use all the digits in MNIST test set to generate test set of moving digit data. The train set contains only normal sequences and the test set has 5\% outlier. \emph{We treat the images as matrices of pixels, whose rows or columns are permutable}, ignoring the strict grid structure which typically warrants CNN models. Our goal is not to compete against CNN-based techniques, but to expose regularities found in 2D motions. To simulate the permutation-invariant scenario, in each sequence, we permute the rows and columns for each image following the same permutation matrix. The cross-entropy loss is used as the pixel intensities fall within the range $[0,1]$. For each model, the hidden size of LSTM unit is chosen so that the number of parameters increases from a small number up to approximately 500K parameters. \subsubsection{Noise-free data} Fig.~\ref{fig:mnist_wo_noise} compares the AUC against the number of parameters for the single-layer models. Again we observe that matrix neural network can capture movement pattern and predict future frames well, yielding high performance using much fewer parameters than vector counterparts. We visualise reconstructed frames of the autoencoder models for a normal and abnormal sequence in Fig.~\ref{fig:mnist_recon_normal} and \ref{fig:mnist_recon_abnormal} respectively. We choose the LSTM-AutoEncoder models which have the highest number of parameters from Fig.~\ref{fig:mnist_wo_noise}. In Fig.~\ref{fig:mnist_recon_abnormal}, LSTM-AutoEncoder fails to reconstruct the moving pattern of the sequence (the digit lies lower in the first few frames), as they try to reconstruct the moving pattern in a straight line. In contrast, matLSTM-AutoEncoder reconstructs the sequence well, thus making it unable to discriminate between two patterns and yields random performance in Fig.~\ref{fig:mnist_wo_noise}. Similarly, we show that matLSTM model is able to encode and predict digit movement well, also produce sharper images compared to the vector counterpart, in Fig.~\ref{fig:mnist_predict_normal} and Fig.~\ref{fig:mnist_predict_abnormal}. Since matLSTM is able to encode the past movement well, its prediction will deviate from ground truth if the movement pattern is anomalous, hence giving high prediction error. In Fig.~\ref{fig:mnist_predict_abnormal}, the digit is predicted to keep moving downward, while ground truth frames show that the digit moves further to the right. \subsubsection*{Adding outlier to training data} We add 5\% of outlier into the training data, in the same way as the testing data, to reflect a real situation where our training data is not lean but contaminated with unknown outliers by a small proportion. Table~\ref{tab:mnist-results-unsup-permute} shows the results for all models, including 3D-CNN and two-layer LSTM models. With the presence of outlier, the performances of both vector models drop. \begin{table}[h] \begin{centering} \begin{tabular}{|c|c|c|} \hline Models & \#Params & AUC\tabularnewline \hline \hline 3D-ConvAE & 140k & 59.6 $\pm$ 0.1\tabularnewline 3D-Conv-Predictor & 66k & 81.9 $\pm$ 0.4\tabularnewline \hline 1-layer LSTM-AutoEncoder & 331k & 61.6 $\pm$ 0.7\tabularnewline 2-layer LSTM-AutoEncoder & 357k & 65.9 $\pm$ 0.4\tabularnewline \hline 1-layer LSTM-Encoder-Predictor & 331k & 76.8 $\pm$ 0.1\tabularnewline 2-layer LSTM-Encoder-Predictor & 357k & 75.3 $\pm$ 0.5\tabularnewline \hline 1-layer matLSTM-AutoEncoder & 52k & 64.9 $\pm$ 2.7\tabularnewline 2-layer matLSTM-AutoEncoder & 101k & 66.7 $\pm$ 0.6\tabularnewline \hline 1-layer matLSTM-Encoder-Predictor & 52k & \textbf{83.4 $\pm$ 1.7}\tabularnewline 2-layer matLSTM-Encoder-Predictor & 101k & 78.8 $\pm$ 2.2\tabularnewline \hline \end{tabular} \par\end{centering} \caption{Moving permuted digits: Models performance (AUC) with outliers in training data. \label{tab:mnist-results-unsup-permute}} \selectlanguage{american}% \selectlanguage{american}% \end{table} \subsubsection*{Dynamics only} In this experiment, we run single-layer models that take the temporal difference $\Delta X_{t}$ as input, as described in Section~\ref{subsec:Dynamics-of-changes}. The results are shown in Fig.~\ref{fig:mnist_wo_noise_input_diff}. While the matLSTM-Encoder-Predictor model stills perform well, LSTM-Encoder-Predictor model suffers a loss in performance. This suggests that while using temporal difference as inputs may suffice given a suitable model (e.g., the predictive matLSTM in this case), appearance-based data can be used to detect irregularities in trajectory dynamics. \begin{figure}[h] \begin{centering} \includegraphics[width=0.95\columnwidth]{figures/moving_mnist/train-on-60000-images/eval_loss_mse_auc_vs_hidden_dataVer5_shuffle1_4models_outlierRatio0. 0_train60000_epoch100_seed0+1+2_mlpDrop0. 1_condDec_norm_inputDiff} \par\end{centering} \caption{AUC vs. number of parameters for \emph{difference of moving permuted digits}. \label{fig:mnist_wo_noise_input_diff} } \end{figure} \subsubsection{Noisy pixels} From the noise-free data, we add salt and pepper noise to each frame in the sequence with a probability of $0.1$ for each type of noise. Performance vs model size for single-layer models is shown in Fig.~\ref{fig:mnist_with_noise}. All models require more parameters to reach high performance compared to the noise-free counterparts. In fact, except for the prediction strategy in matLSTM, other models struggle to learn regularities at all. The matLSTM-AutoEncoder does not improve with more parameters. This suggests that it may encode noise into its memory and thus cannot discriminate between normal and abnormal sequence. To examine the model behaviours in more detail, we visualise reconstructed frames of the autoencoder models for normal and abnormal sequences in Fig.~\ref{fig:mnist_recon_normal_sp_noise} and Fig.~\ref{fig:mnist_recon_abnormal_sp_noise}, respectively. The models with highest number of parameters from Fig.~\ref{fig:mnist_with_noise} are chosen for evaluation. The figures further confirm that the matLSTM-AutoEncoder actually memorises the noise as well as the signals, and thus cancels out its discriminative capability. However, this is not the case for the prediction strategy, as shown in Fig.~\ref{fig:mnist_predict_normal_sp_noise} and Fig.~\ref{fig:mnist_predict_abnormal_sp_noise}. This is expected because the noise is random, and there is no structure to be learnt, and thus future prediction is still smooth. \subsubsection{Noisy trajectories} A new dataset is created by randomly shifting the digits from the original trajectories within the 3-pixel margin. In both of the train and test set, 5\% of the sequences are abnormal. Each sequence is then permuted using the same procedure as in the previous sections. The performance of all models are reported in Table~\ref{tab:AUC-for-permuted-moving-digit-noisy-traj}. We tune the number of free parameters independently for each model using the validation set. Again the matLSTM-AutoEncoder suffers greatly from the noise, suggesting that it does not suit for this task. The predictive counterpart, however, performs very well, and matLSTM-Encoder-Predictor achieves similar performance compared to LSTM-Encoder-Predictor, using much fewer number of free parameters. The two-layer predictive models experience overfitting, thus their performances are worse than single-layer models. \begin{table}[h] \begin{centering} \begin{tabular}{|c|c|c|} \hline Models & \#Params & AUC\tabularnewline \hline \hline 3D-Conv-AE & 140k & 55.3 $\pm$ 0.0\tabularnewline \hline 3D-Conv-Predictor & 66k & 74.9 $\pm$ 0.3\tabularnewline \hline 1-layer LSTM-AutoEncoder & 331k & 60.3 $\pm$ 0.7\tabularnewline \hline 2-layer LSTM-AutoEncoder & 357k & 67.5 $\pm$ 0.1\tabularnewline \hline 1-layer LSTM-Encoder-Predictor & 331k & 82.9 $\pm$ 0.7\tabularnewline \hline 2-layer LSTM-Encoder-Predictor & 357k & 82.6 $\pm$ 0.2\tabularnewline \hline 1-layer matLSTM-AutoEncoder & 52k & 53.1 $\pm$ 0.9\tabularnewline \hline 2-layer matLSTM-AutoEncoder & 101k & 52.2 $\pm$ 0.2\tabularnewline \hline 1-layer matLSTM-Encoder-Predictor & 52k & \textbf{85.1 $\pm$ 1.2}\tabularnewline \hline 2-layer matLSTM-Encoder-Predictor & 101k & 82.1 $\pm$ 0.2\tabularnewline \hline \end{tabular} \par\end{centering} \caption{AUC for moving permuted digit data with noisy trajectories. \label{tab:AUC-for-permuted-moving-digit-noisy-traj}} \selectlanguage{american}% \selectlanguage{american}% \end{table} \subsection{ECG anomalies} We use MIT-BIH Arrhythmia dataset\footnote{https://physionet.org/content/mitdb/1.0.0/} which contains 48 half-hour recordings of two-channel ECG signals, obtained from 47 subjects. The recordings are digitised at 360 samples per second. According to \cite{liu2019arrhythmias}, each heartbeat is classified into one of five classes and detail statistics is shown in Table~\ref{tab:ECG-heartbeats-statistics}. \begin{table}[h] \begin{centering} \begin{tabular}{|l|r|} \hline Classes & \# heartbeats\tabularnewline \hline \hline Normal (N) & 90,631\tabularnewline \hline Premature ventricular contraction (V) & 2,779\tabularnewline \hline Supraventricular premature beat (S) & 7,236\tabularnewline \hline Fusion (F) & 803\tabularnewline \hline Unknown (Q) & 8,043\tabularnewline \hline \end{tabular} \par\end{centering} \caption{Heartbeats statistics, classes are divided according to \cite{liu2019arrhythmias}. \label{tab:ECG-heartbeats-statistics}} \end{table} We perform data preprocessing steps similar to those in \cite{liu2019arrhythmias,lynn2019deep}. First, we manually pick 38 subjects whose recordings have both MLII and V1 channels and contain no paced beats. For each univariate signal, the raw ECG signal is detrended by first fitting a 6-order polynomial and then subtracting it from the signal. Following this, a 6-order Butterworth bandpass filter with 5Hz and 15Hz range is applied. Finally, filtered signals are normalised individually by using Z-score normalisation. Each heartbeat is then represented by a window of length 360 samples, with the R-peak values given in expert annotation. Each heartbeat therefore corresponds to one second in data recordings. In this experiment, we remove the unknown class and consider heartbeat in one of three classes V, S, F as anomalous instances. We randomly select 20\% of subjects for testing and the remaining subjects are used for training. We perform 4-fold cross validation to optimise the hyperparameters. The final AUC and F1 measures are calculated from 3 different runs. \subsubsection*{Matrix construction} The common practice is that each heartbeat is classified into one of the predefined classes. We consider a different setting in which we consider multiple consecutive heartbeats as one unit. The units are extracted from original data using a sliding-window strategy. Each unit is labelled abnormal if one of the heartbeats is abnormal. Thus the data will become more balanced, as seen in Table~\ref{tab:ECG-statistics-prediction-lengths}. The detection may be more sensitive as a result, allowing a way of screening before the doctor has a detailed investigation into the suspicious units. Another motivation is that for heartbeat prediction models, predicting multiple beats at once may be easier than predicting a sequence of beats due to their local dependencies. The matrices are then constructed by using one heartbeat per row. In essence, we are modelling the dependencies between wave signals within a beat, and across multiple beats. This construction allows using longer contexts. For example, when $N=10$ beats are grouped, a sequential model of 20 steps will account for 200 beats, which is much more difficult to handle by conventional beat-based models. \begin{table}[h] \centering{}% \begin{tabular*}{0.95\columnwidth}{@{\extracolsep{\fill}}|>{\centering}m{0.2\columnwidth}|c|>{\centering}m{0.12\columnwidth}|>{\centering}m{0.15\columnwidth}|>{\centering}m{0.13\columnwidth}|} \hline \# prediction steps & Normal & Abnormal & \# test samples & \% test outlier \tabularnewline \hline \hline 5 heartbeats & 12,437 & 5,396 & 4,128 & 22\tabularnewline \hline 10 heartbeats & 5,334 & 3,398 & 2,026 & 29\tabularnewline \hline 20 heartbeats & 2,157 & 2,027 & 974 & 39\tabularnewline \hline \end{tabular*}\caption{ECG statistics for different prediction lengths.\label{tab:ECG-statistics-prediction-lengths}} \end{table} \subsubsection*{Evaluation result} Table~\ref{tab:ECG:-Performance-5-beats} compares the performances of LSTM and matLSTM in predicting 5 heartbeats ahead. For LSTM models, we adopt two different types of inputs, the first type uses one heartbeat as the observation at each timestep and the second type uses flattened vector of 5 heartbeats as the observation at each timestep. For matLSTM model, a group of 5 heartbeats can be represented by a matrix, as denoted above. From table~\ref{tab:ECG:-Performance-5-beats}, we observe that matLSTM yields the best performance, compared to LSTM models. For LSTM models using one heartbeat as input at each step, the results suggest that using longer context helps improve the performance. \begin{table}[h] \begin{centering} \begin{tabular*}{0.95\columnwidth}{@{\extracolsep{\fill}}|c|c|c|c|c|} \hline Models & $T_{e}$ & \#Params & AUC (\%) & F1 (\%)\tabularnewline \hline \hline \multicolumn{5}{|l|}{\emph{Input: 1 heartbeat at each timestep}}\tabularnewline \hline LSTM & 10 & 386k & 90.7 $\pm$ 0.3 & 71.2 $\pm$ 0.6\tabularnewline \hline LSTM & 45 & 822k & 91.2 $\pm$ 0.3 & 71.9 $\pm$ 0.9\tabularnewline \hline \multicolumn{5}{|l|}{\emph{Input: 5 heartbeats at each timestep}}\tabularnewline \hline LSTM-flat & 9 & 727k & 87.8 $\pm$ 0.2 & 69.9 $\pm$ 0.2\tabularnewline \hline matLSTM & 9 & 257k & \textbf{92.5 $\pm$ 0.1} & \textbf{72.8 $\pm$ 0.2}\tabularnewline \hline \end{tabular*} \par\end{centering} \caption{ECG: Performance of different models for predicting 5 heartbeats. $T_{e}$: past context length. All models use the encoder-predictor version. LSTM-flat denotes LSTM model using flattened vectors as inputs. \label{tab:ECG:-Performance-5-beats}} \end{table} Table~\ref{tab:ECG:-Changes-in-length} reports the performances of models under various context length and group size. We use one heartbeat as input at each timestep for LSTM model since it gives better performance than using a flattened vector of multiple heartbeats. For fair comparisons, LSTM and matLSTM are compared using the same context length. In every case, matrix models show better performance than vector LSTM models and 3D-CNN models. \begin{table}[h] \begin{centering} \begin{tabular*}{0.95\columnwidth}{@{\extracolsep{\fill}}|c|c|c|c|c|} \hline Models & $T_{e}$ & \#Params & AUC (\%) & F1 (\%)\tabularnewline \hline \hline \multicolumn{5}{|l|}{\emph{Predict 5 heartbeats ahead}}\tabularnewline \hline 3D-Conv-Predictor & 9 & 81k & 91.7 $\pm$ 0.1 & 71.4 $\pm$ 0.7\tabularnewline \hline 1-layer LSTM & 45 & 822k & 91.2 $\pm$ 0.3 & 71.9 $\pm$ 0.9\tabularnewline \hline 2-layer LSTM & 45 & 984k & 90.9 $\pm$ 0.2 & 71.9 $\pm$ 0.4\tabularnewline \hline 1-layer matLSTM & 9 & 257k & \textbf{92.5 $\pm$ 0.1} & \textbf{72.8 $\pm$ 0.2}\tabularnewline \hline 2-layer matLSTM & 9 & 343k & \textbf{92.5 $\pm$ 0.1} & \textbf{72.9 $\pm$ 0.4}\tabularnewline \hline \multicolumn{5}{|l|}{\emph{Predict 10 heartbeats ahead}}\tabularnewline \hline 3D-Conv-Predictor & 9 & 106k & 90.9 $\pm$ 0.1 & 72.9 $\pm$ 0.2\tabularnewline \hline 1-layer LSTM & 90 & 1,010k & 89.2 $\pm$ 0.1 & 75.1 $\pm$ 0.2\tabularnewline \hline 2-layer LSTM & 90 & 1,243k & 89.1 $\pm$ 0.2 & \textbf{75.2 $\pm$ 0.4}\tabularnewline \hline 1-layer matLSTM & 9 & 263k & \textbf{91.4 $\pm$ 0.1} & 75.0 $\pm$ 0.2\tabularnewline \hline 2-layer matLSTM & 9 & 350k & \textbf{91.3 $\pm$ 0.1} & 74.7 $\pm$ 0.2\tabularnewline \hline \multicolumn{5}{|l|}{\emph{Predict 20 heartbeats ahead}}\tabularnewline \hline 3D-Conv-Predictor & 9 & 143k & 90.4 $\pm$ 0.1 & 78.7 $\pm$ 0.2\tabularnewline \hline 1-layer LSTM & 180 & 1,308k & 87.3 $\pm$ 0.4 & 77.0 $\pm$ 0.2\tabularnewline \hline 2-layer LSTM & 180 & 1,670k & 87.0 $\pm$ 0.4 & 77.5 $\pm$ 0.7\tabularnewline \hline 1-layer matLSTM & 9 & 276k & \textbf{90.8 $\pm$ 0.1} & \textbf{79.7 $\pm$ 0.2}\tabularnewline \hline 2-layer matLSTM & 9 & 362k & \textbf{90.9 $\pm$ 0.1} & \textbf{79.9 $\pm$ 0.1}\tabularnewline \hline \end{tabular*} \par\end{centering} \caption{ECG: Changes in performance with different prediction length. $T_{e}$: past context length. LSTM denotes LSTM-Encoder-Predictor, matLSTM denotes matLSTM-Encoder-Predictor. \label{tab:ECG:-Changes-in-length}} \end{table} \selectlanguage{american}% \section{Introduction} \input{intro.tex} \section{Related Work \label{sec:Related}} \input{related2.tex} \section{Methods \label{sec:Method}} \input{method.tex} \section{Experiments and Results} \input{exp.tex} \section{Conclusion} \input{discuss.tex} \bibliographystyle{plain} \subsection{Matrix LSTM} Matrix LSTM (matLSTM) \cite{do2017learning} is an extension of the LSTM designed to effectively deal with sequences of matrices. Like LSTM, the matLSTM maintains a short-term memory that summarises the historical data. However, unlike LSTM, the matLSTM uses matrices to natively represent input $X_{t}$, neural activations in hidden state $H_{t}\in\Real^{k_{r}\times k_{c}}$ and \emph{working memory} $C_{t}\in\Real^{k_{r}\times k_{c}}$. matLSTM compresses the data tensor $\Xb_{1:t}$ into $C_{t}$. It is also highly compact as the number of parameters typically scales linearly with $n_{r}^{2}$. Let us define the following operation: \begin{align*} \text{mat}\left(X,H;\theta\right) & =U_{xh}^{\top}XV_{xh}+U_{hh}^{\top}HV_{hh}+B \end{align*} where $U_{xh}\in\mathbb{R}^{k_{r}\times n_{r}}$, $V_{xh}\in\mathbb{R}^{n_{c}\times k_{c}}$, $U_{hh}\in\mathbb{R}^{k_{r}\times k_{r}}$, $V_{hh}\in\mathbb{R}^{k_{c}\times k_{c}}$, and $B\in\mathbb{R}^{k_{r}\times k_{c}}$ are free parameters. Upon seeing a new input, the memory is refreshed using \[ C_{t}=F_{t}\odot C_{t-1}+I_{t}\odot\hat{C}_{t} \] where $\hat{C}_{t}=\text{tanh}\left(\text{mat}\left(X_{t},H_{t-1};\theta_{c}\right)\right)$, and $I_{t},F_{t}\in(\boldsymbol{0},\boldsymbol{1})$ are input and forget gates. The state is estimated using $H_{t}=O_{t}\odot C_{t}$, where $O_{t}\in(\boldsymbol{0},\boldsymbol{1})$ is output gate. The gates are computed as $I_{t}=\sigma\left(\text{mat}\left(X_{t},H_{t};\theta_{i}\right)\right)$, $F_{t}=\sigma\left(\text{mat}\left(X_{t},H_{t};\theta_{f}\right)\right)$ and $O_{t}=\sigma\left(\text{mat}\left(X_{t},H_{t};\theta_{o}\right)\right)$, respectively, for $\sigma\left(\cdot\right)$ is element-wise logistic function. Prediction at time $t$ takes $H_{t}$ as input and computes a matrix feedforward net: \[ \hat{Y}_{t}=\text{matnet}\left(H_{t}\right) \] whose basic fully connected layers assume the form: $Z^{l+1}=f\left(U^{l}Z^{l}V^{l}+B^{l}\right)$ for element-wise nonlinear transformation $f$. Training proceeds by minimising a loss function. For example, for continuous outputs, we may use the quadratic loss: $L_{mse}=\frac{1}{T}\sum_{t=1}^{T}\left\Vert Y_{t}-\hat{Y}_{t}\right\Vert _{F}^{2}$, where $\left\Vert \cdot\right\Vert _{F}$ is Frobenius norm. For binary outputs, a cross-entropy loss is applied: $L_{cross}=$ \begin{multline*} -\frac{1}{T}\sum_{t=1}^{T}\left\Vert Y_{t}\odot\log\sigma\left(\hat{Y}_{t}\right)+\left(1-Y_{t}\right)\odot\log\left(1-\sigma\left(\hat{Y}_{t}\right)\right)\right\Vert _{1} \end{multline*} \subsection{Lossy sequence compression \label{subsec:Lossy-sequence-compression}} As the memory matrix $C_{T}$ at time step $T$ of the matLSTM is a lossy compression of the data $\Xb_{1:T}$, we can use the reconstruction loss as a measure how regular the sequence is, similar to the case of vector sequence \cite{malhotra2016lstm}. That is because an abnormal sequence does not exhibit the regularities, it is hardly compressible, and thus its reconstruction error is expected to be higher than the error in the normal cases. \begin{figure}[H] \centering{}\includegraphics[height=3.5cm]{figures/models/matrix_lstm_ae_wrap}\caption{(Matrix) LSTM AutoEncoder model \label{fig:autoencoder}} \end{figure} The model thus has two components: an \emph{encoder} matLSTM which compresses $\Xb_{1:T}$ into $C_{T}^{enc}$ (and $H_{T}^{enc})$ by reading one matrix at a time; and a \emph{decoder} matLSTM decompresses the memory into $\hat{\Xb}_{T+1:2T}$ by predicting one matrix at a time. The decoding takes the initial state $H_{T}^{enc}$ and proceeds backward, starting from the last element, until the first. At each step $t=T+1,T+2,...,2T$, it predicts an output matrix $\hat{X}_{t}$. See Fig.~\ref{fig:autoencoder} for a graphical illustration. We denote the two models employing this strategy as LSTM-AutoEncoder and matLSTM-AutoEncoder. The anomaly score $e_{\boldsymbol{X}}$ is computed as the mean reconstruction error $\frac{1}{T}\sum_{t=1}^{T}\left\Vert X_{t}-\hat{X}_{2T-t+1}\right\Vert _{F}^{2}$ for continuous data, and mean cross-entropy for binary data. \subsection{Predicting the unrolling of sequence \label{subsec:Predicting-the-unrolling}} An alternative to the autoencoder method relies on the premise that if a sequence is regular (i.e., normal), the history may contain sufficient information to predict several steps ahead, as the temporal regularities unrolled over time. This is arguably based on a stronger assumption than the compress-decompress strategy in the autoencoder, because we cannot rely on the working memory $C_{T}$ of the current past only but also the statistical regularities embedded in model parameters. \begin{figure}[H] \begin{centering} \includegraphics[height=3.5cm]{figures/models/matrix_lstm_predict_wrap} \par\end{centering} \caption{(Matrix) LSTM Encoder-Predictor predictive model \label{fig:enc_dec_predict}} \end{figure} More formally, given a past sub-sequence $\Xb_{1:T_{e}}$ we want to predict the future sub-sequence $\Xb_{T_{e}+1:T}$ using $P\left(\Xb_{T_{e}+1:T}\mid\Xb_{1:T_{e}}\right)$. At time $t\le T_{e}$, the encoder reads the past matrices into memory. At time $t>T_{e}$, the decoder predicts future matrices, one at a time. Fig.~\ref{fig:enc_dec_predict} illustrates the encoder-predictor architecture. We denote the two models employing this strategy as LSTM-Encoder-Predictor and matLSTM-Encoder-Predictor. The anomaly score $e_{\boldsymbol{X}}$ is computed as the mean prediction error $\frac{1}{T-T_{e}}\sum_{t=T_{e}+1}^{T}\left\Vert X_{t}-\hat{X}_{t}\right\Vert _{F}^{2}$ for continuous data, and mean cross-entropy for binary data. \subsection{Stacking LSTM layers \label{subsec:Stacking-LSTM-layers}} Raw data may be too noisy to provide informative outliers signals. This necessitates data denoising or abstraction. We propose to abstract data by using the lower LSTM states as input for the higher LSTM. That is, the stack of LSTMs is trained on a layerwise manner, starting from the bottom to the top. At each layer, we compute an outlier score, using methods in Sec.~\ref{subsec:Lossy-sequence-compression} and Sec.~\ref{subsec:Predicting-the-unrolling}. How to combine the scores across layers remains open. For simplicity, we use the score at the top layer. \subsection{Dynamics of changes \label{subsec:Dynamics-of-changes}} If $X_{t}$ is an image, one may argue that since the loss and anomaly score are based on pixel intensities, the models focus too much on the appearance of the digits, and less on its dynamics. Thus the detection of dynamic abnormality may be less effective as a result. To test whether it is the case, we also study the dynamics of changes, that is, instead of studying the original sequence $\left\{ X_{t}|1\le t\le T\right\} $, we study the differences between time step, that is, $\left\{ \Delta X_{t}=X_{t+1}-X_{t}|1\le t<T\right\} $.\selectlanguage{american}%
{'timestamp': '2020-09-22T02:17:19', 'yymm': '2009', 'arxiv_id': '2009.09443', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09443'}
arxiv
\section{Introduction} Raven's Progressive Matrices (RPM) is a widely-used intelligence test~\cite{raven2003raven,carpenter1990one}, which does not require prior knowledge in language, reading, or arithmetics. While IQ measurements are often criticized~\cite{te2001practice,flynn1987massive}, RPM is highly correlated with other intelligence-based properties~\cite{snow1984topography} and has a high statistical reliability~\cite{neisser1996intelligence,mackintosh2011iq}. Its wide acceptance by the psychological community led to an interest in the AI community. Unfortunately, as pointed out by~\cite{szegedy2013intriguing,zhang2016understanding,jo2017measuring}, applying machine learning models to it can sometimes result in shallow heuristics that have little to do with actual intelligence. Therefore, it is necessary to study the pitfalls of RPMs and the protocols to eliminate these exploits. In Sec.~\ref{sec:datasets}, we present an analysis of the most popular machine learning RPM benchmarks, PGM~\cite{santoro2018measuring} and RAVEN~\cite{zhang2019raven}, from the perspective of biases and exploits. It is shown that RAVEN is built in a way that enables the selection of the correct answer with a high success rate without observing the question itself. To mitigate this bias, we construct, in Sec.~\ref{sec:ravenfair}, a fair variant of the RAVEN benchmark. To further mitigate the identified issues, we propose a new evaluation protocol, in which every choice out of the multiple-choice answers is evaluated independently. This new evaluation protocol leads to a marked deterioration in the performance of the existing methods and calls for the development of more accurate ones that also allows for a better understating of abstract pattern recognition. In Sec.~\ref{sec:method}, we propose a novel neural architecture, which, as shown in Sec.~\ref{sec:exp}, outperforms the existing methods by a sizable margin. The performance gap is also high when applying the network to rules that were unseen during training. Furthermore, the structure of the new method allows us to separate the rules into families that are based on the scale in which reasoning occurs. The success of the new method stems mostly from two components: (i) a multi-scale representation, which is shown to lead to a specialization in different aspects of the RPM challenge across the levels, and (ii) a new form of information pooling along the rows and columns of the challenge's $3\times 3$ matrix. To summarize, the contributions of this work are as follows: (i) An abstract multi-scale design for relational reasoning. (ii) A novel reasoning network that is applied on each scale to detect relational patterns between the rows and between the columns of the query grid. (iii) An improved loss function that balances between the single positive example and the numerous negative examples. (iv) A multi-head attentive loss function that prioritizes the different resolutions to specialize in solving different rules. (v) A new balanced version of the existing RAVEN dataset, which we call RAVEN-FAIR. \section{Related Work and Dataset Analysis}\label{sec:related} The first attempt in an RPM-like challenge with neural networks involved simplified challenges~\cite{hoshen2017iq}. The Wild Relation Network (WReN)~\cite{santoro2018measuring}, which relies on the Relation Module~\cite{santoro2017simple}, was the first to address the full task and introduced the PGM benchmark. WReN considers the possible choices one-by-one and selects the most likely option. Two concurrently proposed methods, CoPINet~\cite{zhang2019learning} and LEN~\cite{zheng2019abstract} have proposed to apply row-wise and column-wise relation operations. Also, both methods benefit from processing all eight possible choices at once, which can improve the reasoning capability of the model, but as we show in this work, has the potential to exploit biases in the data that can arise during the creation of the negative choices. CoPINet applies a contrast module, which subtracts a common factor from all choices, thereby highlighting the difference between the options. LEN uses an additional ``global encoder'', which encodes both the context and choice images into a single global vector that is concatenated to the row-wise and column-wise representations. The latest methods, MXGNet~\cite{wang2020abstract} and Rel-AIR~\cite{spratleycloser}, have proposed different complex architectures to solve this task and also consider all choices at once. Zhang et al.~\cite{zheng2019abstract} also introduced a teacher-student training method. It selects samples in a specialized category- and difficulty-based training trajectory and improves performance. In a different line of work, variational autoencoders~\cite{kingma2013auto} were shown to disentangle the representations and improve generalization on held-out rules~\cite{steenbrugge2018improving}. Our method shows excellent performance and better generalization to held-out rules without relying on either techniques. When merging different outputs of intermediate paths, such as in residual~\cite{he2016deep} or shortcut~\cite{bishop1995neural,ripley2007pattern,venables2013modern} connections, most methods concatenate or sum the vectors into one. This type of pooling is used by the existing neural network RPM methods when pooling information across the grid of the challenge. In Siamese Networks~\cite{bromley1994signature}, one compares the outputs of two replicas of the same network, by applying a distance measure to their outputs. Since the pooling of the rows and the columns is more akin to the task in siamese networks, our method generalizes this to perform a triple pair-wise pooling of the three rows and the three columns. \begin{figure}[t] \centering \begin{tabular}{c@{~}c} \includegraphics[width=0.22\textwidth, trim={3 4 4 2}, clip]{images/PGM_shape2.png} & \includegraphics[width=0.22\textwidth, trim={3 4 4 2}, clip]{images/RAVEN2.png} \\ (a)&(b) \\ \end{tabular} \caption{Dataset examples. (a) PGM. (b) RAVEN. The rules are annotated and the correct answer is highlighted.} \label{fig:dataset} \end{figure} \subsection{Datasets}\label{sec:datasets} The increased interest in the abstract reasoning challenges was enabled by the introduction of the PGM~\cite{santoro2018measuring} and RAVEN~\cite{zhang2019raven} datasets. These datasets share the same overall structure. The participant is presented with the first eight images of a 3x3 grid of images, called the context images, and another eight images, called the choice images. The objective is to choose the missing ninth image of the grid out of the eight presented choices, by identifying one or more recurring patterns along the rows and/or columns of the grid. The correct answer is the one that fits the most patterns. See Fig.~\ref{fig:dataset} for illustration. PGM is a large-scale dataset consisting of 1.2M train, 20K validation, and 200K test questions. All images in the dataset are conceptually similar, each showing various amounts of lines and shapes of different types, colors, and sizes. Each question has between 1-4 rules along the rows or columns. Each applies to either the lines or the shapes in the image. Fig.~\ref{fig:dataset}(a) shows an example of the dataset. RAVEN is a smaller dataset, consisting of 42K train, 14K validation, and 14K test questions divided into 7 distinct categories. Each question has between 4-8 rules along the rows only. Fig.~\ref{fig:dataset}(b) shows an example of the dataset. \paragraph{Evaluation protocols} Both datasets are constructed as a closed-ended test. It can be performed as either a multiple-choice test (MC) with eight choices, where the model can compare the choices, or as a single choice test (SC), where the model scores each choice independently and the choice with the highest score is taken. While this distinction was not made before, the previous works are divided in their approach. WReN follows the SC protocol and CoPINet, LEN, MXGNet, and Rel-AIR, all followed the MC protocol. In the SC scenario, instead of presenting the agent with all the choices at once, it is presented with a single choice and has to predict if it is the right answer or not. The constraint of solving each image separately increases the difficulty since the model cannot make a decision by comparing the choices. While this eliminates the inter-choice biases, the agent may label multiple or zero images as the correct answer and opens the door to multiple success metrics. In order to directly compare models trained in the MC and SC protocols, we evaluate both types of models in a uniform manner: the score for all models is the accuracy for the multiple-choice test, where for the SC-trained model, we consider the answer with the highest confidence, regardless of the number of positive answers. \paragraph{Dataset Analysis} When constructing the dataset for either the MC or the SC challenge, one needs to be very careful in how the negative examples are selected. If the negative examples are too obvious, the model can eliminate them and increase the probability of selecting the correct answer, without having to fully identify the underlying pattern. Negative examples are therefore constructed based on the question. However, when the negative examples are all conditioned on the correct answer, in the MC scenario, the agent might be able to retrieve the correct answer by looking at the choices without considering the context at all. For example, one can select the answer that has the most common properties with the other answers. See the supplementary for an illustration of such biases in a simple language-based multiple-choice test. A context-blind test, which is conducted by training a model that does not observe the context images, can check whether the negative answers reveal the correct answer. Ideally, the blind test should return a uniform random accuracy, e.g. 12.5\% for eight options. However, since the negative choices should not be completely random so that they will still form a challenge when the context is added, slightly higher accuracy is acceptable. When introduced, the PGM dataset achieved a blind test score of 22.4\%. In the RAVEN benchmark, the negative examples are generated by changing a single attribute from the correct image for each example, making it susceptible to a majority-based decision. RAVEN was released without such a context-blind test, which we show in the supplementary that it fails at. Concurrently to our work, Hu et al.~\cite{hu2021stratified} have also discovered the context-blind flaw of RAVEN. They propose an adjustment to the dataset generation scheme that eliminates this problem, which they call `Impartial-RAVEN'. Instead of generating the negative choices by changing a random attribute from the correct answer, they propose to sample in advance three independent attribute changes and generate seven images from all the possible combinations of them. \section{RAVEN-FAIR} \label{sec:ravenfair} In the supplementary, we analyze both PGM and RAVEN under the blind, SC, and MC settings. As we show, due to the biased selection of the negative examples, the RAVEN dataset fails the context-blind test, as it is solved with 80.17\% accuracy by only looking at the choices, making it unsuitable for the MC protocol. We, therefore, propose a modified dataset we term RAVEN-FAIR, generated by Algorithm.~\ref{algorithm1}. This algorithm starts with a set of choices that contains the correct answer and iteratively enlarges this set, by generating one negative example at a time. At each round, one existing choice (either the correct one or an already generated negative one) is selected and a new choice is created by changing one of its attributes. The result is a connected graph of choices, where the edges represent an attribute change. \begin{algorithm}[t] \SetAlgoLined \SetKwInOut{Input}{input} \SetKwInOut{Output}{output} \Input{$C$ - 8 context components \\ $a$ - the correct answer for $C$} \Output{$A$ - 8 choice components ($a \in A$)} $A \xleftarrow{} \{ a \}$\; \While{length(A) $<$ 8}{ $a' \xleftarrow{} Choice(A)$\; $\hat{a} \xleftarrow{} Modify(a')$\; \If{Solve($C,\hat{a}$) = False}{ $A \xleftarrow{} A \cup \{\hat{a}\}$\; } } \caption{RAVEN-FAIR}\label{algorithm1} \end{algorithm} \begin{figure}[t] \centering \begin{tabular}{cc} \includegraphics[width=0.45\columnwidth]{images/algorithm_old.png} & \includegraphics[width=0.45\columnwidth]{images/algorithm.png} \\ (a) & (b) \\ \end{tabular} \caption{Illustration of negative examples' generation processes. (a) RAVEN. (b) RAVEN-FAIR.} \label{fig:algorithm_old} \end{figure} As an example, we show the process of generating the negative examples for RAVEN in Fig.~\ref{fig:algorithm_old}(a). For comparison, we also show the process of how our proposed algorithm generates the negative examples for RAVEN-FAIR in Fig.~\ref{fig:algorithm_old}(b). Note that the two figures show the produced choices for different context questions. In each figure, eight choices for an initial question are shown. The center image, which is also highlighted, is the correct answer. Each arrow represents a newly generated negative example based on an already existing choice, by changing one arbitrary attribute. The dotted lines connect between choices that also differ by one attribute but were not generated with condition to each other. As can be seen, the RAVEN dataset generates the questions in a way that the correct answer is always the one with the most shared attributes with the rest of the examples. The negative option with the most neighbors in this example is the top-left one, which only has three neighbors, while the correct answer always has eight. Even without highlighting the correct answer, it would be easy to point out which one it is, by selecting the one with the most neighbors, without looking at the question. In contrast, our fair algorithm generates the negative examples in a more balanced way. Since each newly generated negative choice can now be conditioned on both the correct image or an already existing negative one, the correct choice cannot be tracked back by looking at the graph alone. In this example, the correct answer only has two neighbors, and both the right and top-right negative images have three neighbors. Because the algorithm is random, the number of neighbors that the correct image has is arbitrary across the dataset, and is between one and eight. In the context-blind test (supplementary), RAVEN-FAIR returned a 17.24\% accuracy, therefore passing the test and making it suitable for both SC and MC. The PGM dataset passed our context-blind test as well, with 18.64\% accuracy. \section{Method}\label{sec:method} \begin{figure*}[t] \centering \includegraphics[width=0.9\textwidth, trim={5 10 5 10}, clip]{images/architecture_final.png} \caption{MRNet. (a) Depiction of the input query. (b) High-level diagram of the architecture. (c) The relation module ($RM_t$). (d) The pattern module ($PM_t$).} \label{fig:architecture} \end{figure*} Our Multi-scale Relation Network (MRNet), depicted in Fig.~\ref{fig:architecture}(b), consists of five sub-modules: (i) a three-stage encoder $E_t$, where $t\in\{h,m,l\}$, which codes the input context and a single choice image into representations in three different resolutions: $20\times 20$ (high), $5\times 5$ (med) and $1\times 1$ (low), (ii) three relation modules $RM_t$, one for each resolution, which perform row-wise and column-wise operations on the encodings to detect relational patterns, (iii) three pattern modules $PM_t$, one for each resolution, which detects if similar patterns occur in all rows or columns, (iv) three bottleneck networks $B_t$, which merge the final features of each resolution, and (v) a predictor module $MLP$, which estimates the correctness of a given choice image to the context in question, based on the bottlenecks' outputs. The model is presented with a question in the form of $16$ images: a set of context images $I_C = \{I^n | n \in [1,8]\}$ and a set of choice images $I_A = \{I_a^n | n \in [1,8]\}$. Since the model operates in the SC protocol, it evaluates the choices separately. Therefore, the notations act as if there is only a single choice image $I^a$ to answer. To solve all eight choices, the model is repeated eight times with a different choice image $I_a\in I_A$. \paragraph{Multi-scale encoder} The encoder is a three-stage Convolutional Neural Network that encodes all images (context or choice) into multi-resolution representations (high, middle, low). Every image $I^n \in [-1,1]^{1,80,80}$, for $n \in \{1,2,...,8,a\}$, is passed sequentially through the three stages of the encoder, i.e., the middle resolution encoding is obtained by applying further processing to the output of the high resolution encoder and similarly the low resolution encoding is obtained by further processing the middle resolution one. Specifically, the encoding process results in three tensors. $e_h^n \in \mathbb{R}^{64,20,20}$, $e_m^n \in \mathbb{R}^{128,5,5}$ and $e_l^n \in \mathbb{R}^{256,1,1}$. \begin{equation}\label{eq:encoder} e^n_h = E_h(I^n), \quad e_m^n = E_m(e_h^n), \quad e_l^n = E_l(e_m^n)\,. \end{equation} \paragraph{Relation Module} Based on the encoding of the images, we apply a relational module (RM) to detect patterns on each row and column of the query. There are three such modules ($RM_h, RM_m, RM_l$). For each resolution $t \in \{h,m,l\}$, the 9 encodings $e^n_t$ for $n=1,2,..,8,a$ are positioned on a 3x3 grid, according to the underlying image $I^n$, see Fig.~\ref{fig:architecture}(c). The rows and columns are combined by concatenating three encodings on the channel dimension. The rows consist of the three triplets $(e^1_t,e^2_t,e^3_t)$, $(e^4_t,e^5_t,e^6_t)$, $(e^7_t,e^8_t,e^a_t)$. Similarly, the columns consist of the three triplets $(e^1_t,e^4_t,e^7_t)$, $(e^2_t,e^5_t,e^8_t)$, $(e^3_t,e^6_t,e^a_t)$. Each row and column is passed through the relation network (RN). \begin{equation}\label{eq:rm} \begin{split} r^1_t = RN_t(e^1_t,e^2_t,e^3_t), \quad c^1_t = RN_t(e^1_t,e^4_t,e^7_t) \\ r^2_t = RN_t(e^4_t,e^5_t,e^6_t), \quad c^2_t = RN_t(e^2_t,e^5_t,e^8_t) \\ r^3_t = RN_t(e^7_t,e^8_t,e^a_t), \quad c^3_t = RN_t(e^3_t,e^6_t,e^a_t) \end{split} \end{equation} Each RN consists of two residual blocks with two convolution layers inside each one. For the high and middle resolutions, the convolution has a kernel of size 3 with 'same' padding, while for the low resolution the kernel size is 1 without padding. The output of each relation block is of the same shape as its corresponding encoding $e_t$, i.e. $RN_h: \mathbb{R}^{3*64,20,20} \rightarrow \mathbb{R}^{64,20,20}$, $RN_m: \mathbb{R}^{3*128,5,5} \rightarrow \mathbb{R}^{128,5,5}$, and $RN_l: \mathbb{R}^{3*256,1,1} \rightarrow \mathbb{R}^{256,1,1}$. Note that we apply the same relation networks to all rows and columns. This approach allows comparison between the rows and between the columns to detect recurring patterns. In addition, it maintains the permutation and transpose invariance property we assume on the rows and columns. \paragraph{Pattern Module} At this point, at each level $t \in \{h,m,l\}$ the representation of the panel is structured as three row features and three column features, which we want to merge into a single representation. The module dedicated to this is the pattern module (PM), which applies some operator $F(\cdot)$ on the rows and columns. It is depicted in Fig.~\ref{fig:architecture}(d). To promote order-invariance between the three rows or columns, a permutation-invariant operator $F(\cdot)$ is recommended. One can perform sum pooling (SUM3). This kind of approach was employed by~\cite{santoro2018measuring,zhang2019learning,zheng2019abstract}. Due to the linearity of the sum pooling, a ReLU is employed. \begin{equation}\label{eq:defsum} \text{SUM3}(x_1,x_2,x_3) := \text{ReLU}(x_1 + x_2 + x_3) \end{equation} The reduction is then applied on the rows and columns. \begin{equation}\label{eq:sum} r_t = \text{SUM3}(r^1_t, r^2_t, r^3_t), \quad c_t = \text{SUM3}(c^1_t, c^2_t, c^3_t) \end{equation} The SUM3 operator has a drawback in that it does not detect similarity between the rows and between the columns. Instead, we propose a novel method that is inspired by Siamese Networks, which compares multiple rows and columns. This vector operator DIST3 is defined per vector index $i$ and is applied to the rows and columns: \begin{equation}\label{eq:defdist} \begin{split} \text{DIST3}_i(x_1,x_2,x_3) :=& (x_{1,i} - x_{2,i})^2 \\ +& (x_{2,i} - x_{3,i})^2 \\ +& (x_{3,i} - x_{1,i})^2 \end{split} \end{equation} \begin{equation}\label{eq:dist} \begin{gathered} r_t = \text{DIST3}(r^1_t, r^2_t, r^3_t),\quad c_t = \text{DIST3}(c^1_t, c^2_t, c^3_t) \\ \end{gathered} \end{equation} DIST3 does not contain an activation function, since the method is already non-linear. Its advantage is also visible in its backward path. The gradient of each operator with respect to element $i$ of $x_1$ is: \begin{equation}\label{eq:defgrad} \begin{split} \frac{\partial\text{SUM3}_i(x_1,x_2,x_3)}{\partial x_{1,i}} &= 1 \\ \frac{\partial\text{DIST3}_i(x_1,x_2,x_3)}{\partial x_{1,i}} &= 2\cdot(2\cdot x_{1,i} - x_{2,i} -x_{3,i}) \end{split} \end{equation} The gradient of SUM3 does not depend on the values of $x_2$ and $x_3$, while the gradient of DIST3 does. Therefore, DIST3 has the potential to encourage increased coordination between the paths. Finally, the row- and column-features are summed into a merged representation of the entire panel: \begin{equation} p_t = r_t + c_t \end{equation} \paragraph{Bottleneck module} The three relation modules and their pattern detectors return a latent representation of the panel in three resolutions ($p_h, p_m, p_l$). This module collects the three representations into a single representation. For this purpose, each representation is downsampled by a bottleneck network ($B_t$) that encodes the panel representation $p_t$ into feature vectors with 128 features. \begin{equation} \label{eq:bottleneck} v_t = B_t(p_t) \end{equation} The three final features are then concatenated into a single vector with 384 features {(3x128)}. \begin{equation} v = \text{Concat}(v_h, v_m, v_l) \end{equation} \paragraph{The predictor} The resulting merged feature vector from the bottleneck module is used to predict the correctness of a choice $I^a \in I_A$ to the context $I_C$. A Multi-Layer Perceptron (MLP) predicts the score of the choice images. A sigmoid translates this score to the probability of the choice $I^a$ to be a correct answer: \begin{equation}\label{eq:mlp} p(y=1|I^a,I_C) = \text{Sigmoid}(MLP(v)) \end{equation} For each choice image, the loss is the Binary Cross Entropy loss. Because each grid has seven negative choices and only one correct answer, we weight the loss of each choice respectively, meaning that the correct answer has a weight of 7 and each negative answer has a weight of 1. \paragraph{Multi-head attentive predictor} Optimizing the three heads with the main loss works relatively well, but we have found that adding an objective that optimizes each head separately improves the final results and reduces the overall training time. To do so, three additional predictors were created, one for each bottleneck output $v_h,v_m,v_l$. The architecture of the heads is the same as that of the main head and the loss function is identical. To encourage each resolution to specialize in the rules that the other resolutions are having difficulty with, we propose an attentive weight distribution on the loss functions of the three heads. Consider the prediction of each head $p_t(y=y^*|I^a,I_C)$ for $t \in \{h,m,l\}$, where $y^* \in \{0,1\}$ represent whether the choice $I^a$ is correct or not. The weight applied to each head is: \begin{equation} w_t = \frac{\exp\{p_t(y=y^*|I^a,I_C)\}}{\sum_{\tau}\exp\{p_\tau(y=y^*|I^a,I_C)\}} \end{equation} Let $\mathcal{L}_t$ be the Binary Cross Entropy loss for head $t \in \{h,m,l\}$. The final multi-head loss is: \begin{equation} \mathcal{L}_3 = \sum_t w_t \mathcal{L}_t \end{equation} \noindent{\bf Training method\quad} We trained with a batch size of 32 queries with an early stopping scheme of 20 epochs, measuring the accuracy on the validation set. The reported accuracy was measured on the test set, for the checkpoint with the best validation accuracy. See supplementary for a detailed description of the architecture. We did not tune any hyper-parameter of the model. Adam~\cite{kingma2014adam} was used with lr=1e-3, $\beta$=(0.9,0.999), and weight decay of 1e-6. \begin{table}[t] \centering \begin{tabular}{@{}l@{~}l@{~}l@{}c@{~}c@{~}c@{~}c@{~}c@{}} \toprule & \multicolumn{7}{c}{Test Accuracy (\%)} \\ \midrule & \multicolumn{3}{c}{Model} & \multicolumn{2}{c}{PGM} & \multicolumn{2}{c}{RAVEN} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8} & Name & Version & SC & base & meta & FAIR & orig \\ \midrule \multirow{5}{*}{\rotatebox[origin=c]{90}{SC Baselines}} & \emph{ResNet-SC} & & \cmark & $^\dagger$48.9 & - & $^\dagger$58.3 & $^\dagger$40.4 \\ & \emph{WReN'18 & normal & \cmark & 62.6 & 76.9 & $^\dagger$30.3 & $^\dagger$16.8 \\ & \emph{V-WReN'18 & Normal & \cmark & 64.8 & - & - & - \\ & \emph{CoPINet'19 & no-contrast & \cmark & $^\dagger$42.7 & $^\dagger$45.2 & $^\dagger$36.5 & $^\dagger$18.4 \\ & \emph{LEN'19 & global-8 & \cmark & $^\dagger$65.6 & $^\dagger$79.6 & $^\dagger$50.9 & $^\dagger$29.9 \\ \midrule & \emph{MRNet} & & \cmark & {\bf93.4} & {\bf92.6} & {\bf86.8} & {\bf84.0} \\ \cmidrule(lr){1-8} \multirow{5}{*}{\rotatebox[origin=c]{90}{Ablation}} & \multicolumn{2}{l}{no $\mathcal{L}_{3}$} & \cmark & 84.4 & 88.4 & 84.0 & 80.1 \\ & \multicolumn{2}{l}{no $\mathcal{L}_{3}$, no wb} & \cmark & 75.2 & 84.9 & 80.6 & 78.6 \\ & \multicolumn{2}{l}{no $\mathcal{L}_{3}$, no wb, with SUM3} & \cmark & 74.3 & 79.0 & 77.0 & 69.6 \\ & \multicolumn{2}{l}{no wb} & \cmark & 87.6 & 88.9 & 83.4 & 80.2 \\ & \multicolumn{2}{l}{with SUM3} & \cmark & 83.2 & 85.3 & 79.5 & 78.2 \\ \midrule \midrule \multirow{8}{*}{\rotatebox[origin=c]{90}{MC Baselines}} & \emph{ResNet-MC} & & \xmark & $^\dagger$41.1 & - & $^\dagger$24.5 & $^\dagger$72.5 \\ & \emph{CoPINet'19 & normal & \xmark & 56.4 & $^\dagger$51.1 & $^\dagger$50.6 & 91.4 \\ & \emph{LEN'19 & normal & \xmark & 68.1 & 82.3 & $^\dagger$51.0 & 72.9 \\ & \emph{LEN'19 & teacher-model & \xmark & 79.8 & 85.8 & - & 78.3 \\ & \emph{T-LEN'19 & normal & \xmark & 70.3 & 84.1 & \xmark & \xmark \\ & \emph{T-LEN'19 & teacher-model & \xmark & 79.8 & 88.9 & \xmark & \xmark \\ & \emph{MXGNet'20 & & \xmark & 66.7 & 89.6 & - & 83.9 \\ & \emph{Rel-AIR'20 & & \xmark & 85.5 & - & - & 94.1 \\ \midrule & \emph{MRNet} & with-contrast & \xmark & {\bf94.5} & {\bf92.8} & {\bf 88.4} & {\bf96.6} \\ \cmidrule(lr){1-8} \multirow{3}{*}{\rotatebox[origin=c]{90}{Ablation}} & \multicolumn{2}{l}{no $\mathcal{L}_{3}$} & \xmark & 85.7 & 89.0 & 85.2 & 95.5 \\ & \multicolumn{2}{l}{no $\mathcal{L}_{3}$, no wb} & \xmark & 76.4 & 85.4 & 81.3 & 94.3 \\ & \multicolumn{2}{l}{no wb} & \xmark & 87.4 & 89.8 & 86.1 & 95.0 \\ \bottomrule \end{tabular} \caption{Evaluation on all datasets. $^\dagger$Baseline was run by us, due to missing results.}\label{tab:evaluation} \end{table} \begin{table}[t] \centering \centering \begin{tabular}{l@{~}c@{~~}c@{~~}cc@{~~}c} \toprule & \multicolumn{5}{c}{Accuracy (\%)} \\ \cmidrule(lr){2-6} & \multicolumn{3}{c}{Baselines} & \multicolumn{2}{c}{\emph{MRNet}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-6} Regime & \emph{WReN} & \emph{V-WReN} & \emph{MXGNet} & (a) & (b) \\ \midrule Neutral & 62.6 & 64.2 & 66.7 & {\bf75.2} & {\bf93.4} \\ Interpolation & 64.4 & - & 65.4 & {\bf67.1} & {\bf68.1} \\ Extrapolation & 17.2 & - & 18.9 & {\bf19.0} & {\bf19.2} \\ HO Pairs & 27.2 & 36.8 & 33.6 & {\bf37.8} & {\bf38.4} \\ HO Triple Pairs & 41.9 & 43.6 & 43.3 & {\bf53.4} & {\bf55.3} \\ HO Triples & 19.0 & 24.6 & 19.9 & {\bf25.3} & {\bf25.9} \\ HO line-type & 14.4 & - & 16.7 & {\bf27.0} & {\bf30.1} \\ HO shape-color & 12.5 & - & 16.6 & {\bf16.9} & {\bf16.9} \\ \bottomrule \end{tabular} \caption{Generalization evaluation on the held-out regimes of PGM. (a) Without weight balancing and $\mathcal{L}_3$. (b) With them.} \label{tab:generalization} \end{table} \begin{table}[t] \centering \begin{tabular}{c@{~~}c@{~}cc@{~}c@{~}c@{~}c@{~}c@{~}c@{~}c@{~}c} \toprule \multicolumn{3}{c}{{Scales}} & \multicolumn{8}{c}{Configurations. Accuracy(\%)} \\ \cmidrule(lr){1-3} \cmidrule(lr){4-11} h & m & l & {All} & {Center} & {2$\times$2} & {3$\times$3} & {L-R} & {U-D} & {O-IC} & {O-IG} \\ \midrule \cmark & \xmark & \xmark & 72.0 & 84.1 & 47.2 & 48.3 & {\bf90.0} & {\bf91.5} & {\bf87.6} & 55.5 \\ \xmark & \cmark & \xmark & {\bf73.3} & 90.5 & 56.1 & 53.4 & 83.5 & 83.0 & 82.5 & {\bf64.1} \\ \xmark & \xmark & \cmark & 58.9 & {\bf97.7} & {\bf62.2} & {\bf62.8} & 42.3 & 42.5 & 56.8 & 48.1 \\ \midrule \cmark & \cmark & \xmark & 77.7 & 82.8 & 61.7 & 59.5 & {\bf91.7}& {\bf92.2}& {\bf89.9}& {\bf66.3} \\ \cmark & \xmark & \cmark & {\bf78.3}& 91.0 & 63.2 & 64.7 & 88.8 & 92.2 & 87.7 & 60.3 \\ \xmark & \cmark & \cmark & 76.6 & {\bf98.3}& {\bf67.5}& {\bf65.4}& 81.6 & 83.4 & 81.5 & 58.3\\ \midrule \cmark & \cmark & \cmark & 80.6 & 87.7 & 64.7 & 64.3 & 94.2 & 94.3 & 90.9 & 68.0 \\ \multicolumn{3}{c}{{with $\mathcal{L}_3$}} & {\bf86.8} & {\bf97.0} & {\bf72.7} & {\bf69.5} & {\bf98.7} & {\bf98.9} & {\bf97.6} & {\bf73.3} \\ \bottomrule \end{tabular} \caption{Ablation on the role of each scale in RAVEN-FAIR} \label{tab:multires} \end{table} \begin{figure*}[t] \centering \begin{tabular}{@{}c@{}c@{}c@{}c@{}} \includegraphics[width=0.091\linewidth, trim={8 5 8 8}, clip]{images/piechart_bar.png} & \includegraphics[width=0.293\linewidth, trim={8 5 8 8}, clip]{images/piechart_a.png} & \includegraphics[width=0.293\linewidth, trim={8 5 8 8}, clip]{images/piechart_b.png} & \includegraphics[width=0.293\linewidth, trim={8 5 8 8}, clip]{images/piechart_c.png} \\ &(a)&(b)&(c) \\ \end{tabular} \caption{Ablation on the role of each scale in PGM, using a fully trained MRNet on the SC protocol. (a) Without auxiliary loss (PGM), no $\mathcal{L}_3$. (b) With auxiliary loss (PGM\_meta), no $\mathcal{L}_3$. (c) Wihout auxiliary loss (PGM), with $\mathcal{L}_3$. We measured the accuracy for each type, using only one of the scales and the other ones are masked. The inner radius shows the accuracy of the full model. The three rings show the accuracy of each resolution. The inner ring is the low resolution, then the middle, and the high resolution is the outer one.}\label{fig:multires} \end{figure*} \section{Experiments}\label{sec:exp} We experiment on PGM, RAVEN, and RAVEN-FAIR. Each dataset has a preset train, validation, and test splits of the data. We used the train set for training and the test set for the evaluation. The validation set was used to pick the best checkpoint during training for evaluation. PGM has additional metadata of the rules logic, which can be used as additional supervision during training. The use of the metadata has been shown to improve performance on all previous works. We refer to this more informative setting as PGM\_meta. Following previous works, the utilization of the metadata was done by extending the predictor module with an additional head that predicts the 12 bits of the metadata, and training the model with an additional (auxiliary) Cross Entropy loss. Similar to the previous works, the weight for the auxiliary loss is $\beta=10$. \smallskip \noindent{\bf Baselines\quad} We compare our method to the state of the art methods: WReN~\cite{santoro2018measuring}, LEN~\cite{zheng2019abstract}, CoPINet~\cite{zhang2019learning}, MXGNet~\cite{wang2020abstract}, and Rel-AIR~\cite{spratleycloser}. We also employed the ResNet~\cite{he2016deep} models described in the supplementary: ResNet-SC and ResNet-MC. The former evaluates each choice separately and the latter all choices at once. As noted in Sec.~\ref{sec:related}, LEN and CoPINet follow the MC protocol. To evaluate these baselines without the possibility of exploiting the weaknesses of RAVEN, we have created additional versions of them for the SC protocol. In LEN, the `global-CNN' originally accepted all 16 images, including the choices. We have changed it to accept only the context images (`global-8'). In CoPINet, we removed the contrasting module (`no-contrast'), which allows information to pass between the choices. We also compared to LEN with their proposed teacher-model training schedule, and to T-LEN, which has dedicated prediction paths for line rules and shape rules and is only applicable to PGM. The results can be seen in Tab.~\ref{tab:evaluation} separately for each protocol. \smallskip \noindent{\bf Results\quad} Before evaluating our model, two important things can be noticed by observing at the baselines. First, the performance of LEN and CoPINet declines in SC, where unlike MC, the models cannot compare the choices within the model. This is especially noticeable in RAVEN, where CoPINet practically solved it in MC and failed it in SC. On both RAVEN and RAVEN-FAIR, all SC baselines performed worse than the simple ResNet-SC, which does not have any dedicated modules for relational reasoning. Second, by comparing each models' performance between RAVEN and RAVEN-FAIR, we can see that MC models perform significantly lower on RAVEN-FAIR than on RAVEN. This confirms that RAVEN-FAIR indeed fixes the biases in the data and is much more suitable as a benchmark than RAVEN, especially for the MC protocol. These observations align with the dataset analysis presented in the supplementary, which conclusions were discussed in Sec.~\ref{sec:datasets}. One can observe that our model outperforms the baselines in both protocols and across all datasets. In SC, our method outperforms previous baselines by 27.8\% in PGM, 13.0\% in PGM\_meta, 35.9\% in RAVEN-FAIR, and 54.1\% in RAVEN. In MC, we outperform the baselines by 9.0\%, 3.2\%, 37.4\% and 4.9\% respectively. Except for RAVEN, our SC protocol model even performed better than both SC and MC protocols of the baselines, despite the SC protocol having less information. We noticed that our model's performance has reached a point where the auxiliary task of the metadata hurts performance since the added task creates a burden on the optimization of the main task (Vapnik et al. (1998)~\cite{Vapnik1998}) and does no longer benefit the model. Therefore the accuracy on PGM\_meta is lower than that of PGM, which is the first time a model shows such behavior. For {\bf ablation}, we trained our model with the SUM3 operator instead of DIST3, without the weight balancing of the positive choices versus the negative ones (no wb), and without the multi-head attentive loss ($\mathcal{L}_3$). The results are shown in Tab.~\ref{tab:evaluation} below those of the full model. For SC, we show an aggregated ablation on these modifications, i.e., each following instance applies an additional modification. Each added modification results in a performance decline compared to the previous version. The experiments which remove one component at a time also support that both multi-head attentive loss and the weight balancing both greatly improve the training of the main head. It is also evident that DIST3 is a superior pooling operator over SUM3. For MC, we performed an ablation with either or both the weight balancing and the $\mathcal{L}_3$ removed. The simplified models without these contributions are not competitive. Aside from test accuracy, model capacity and training resource consumption is also an important factor. While our method outperforms the other baselines, it is not bigger or slower to train. Our method trains in about 40 minutes per epoch on PGM on a single 1080TI GPU, which is about the same speed as WReN and CoPINet, and about 3x faster than LEN. We did not measure the runtime of MXGNet, Rel-AIR, or LEN with the teacher-model framework, but we expect them to require substantial resources and time. \smallskip \noindent{\bf Generalization\quad} An important property of a model that is good at abstract reasoning is to be able to generalize over rules that were not seen during training. PGM has specially built versions of the dataset for this purpose. Aside from the `Neutral' regime, there are seven more regimes, where different rule types were omitted from the train and validation sets, and the test set consists solely of the held-out rules. For more details, please refer to Santoro et al.~\cite{santoro2018measuring}. Tab.~\ref{tab:generalization} shows that our method generalizes better in all regimes. Most notably are the 'HO line-type' and 'HO Triple Pair' regimes, where our method has a gap of 10\% from the baselines. We do note, however, that other regimes, such as 'HO shape-color' and 'Extrapolation', only made a negligible improvement on the baselines and are still only slightly better than random. This reassures that there is still much to be done for future work in this regard. {\color{black}In the generalization experiments, training with $\mathcal{L}_3$ only showed minor improvement. We, therefore, conclude that the performance gain for out-of-domain rules has more to do with the architecture, i.e. the multi-scale design and the relation and pattern modules.} \smallskip \noindent{\bf Understanding the Role of Each Scale\quad} The premise of the importance of multi-scale design is incomplete without gaining additional knowledge on the contribution of each resolution. We, therefore, trained the model multiple times on RAVEN-FAIR with different combinations of scales ($h, m, l$) removed. We did not use weight balancing or the multi-head attentive loss for this evaluation. In Tab.~\ref{tab:multires}, we show the average accuracy per rule type. The results clearly show that each resolution has an advantage in different rules. The lower resolution solves the 'Center', '2$\times$2', and '3$\times$3' configurations better, and the upper resolution is more adept for 'L-R', 'U-D' and 'O-IC'. The 'O-IG' configuration is best solved by the middle resolution, which suggests it requires a combination of high-resolution and low-resolution features. When using two scales, the combination of the lower and upper resolutions was better than the ones with the middle resolution, even though the middle resolution is better when only one scale is permitted. This shows that the combination of upper and lower resolutions is more informative. Finally, the full model performs best on average, and the added $\mathcal{L}_3$ improves on all configurations by optimizing each scale separately. A similar analysis was done on PGM. Since PGM is a very large dataset that takes longer to train, instead of retraining, we measured the accuracy of prediction using the output of a single bottleneck by masking the outputs of two different bottlenecks each time. Questions with multiple rules were ignored in this analysis since it wouldn't be clear which rules assisted in answering the question correctly and would contaminate the analysis. Fig.~\ref{fig:multires} visualizes the accuracy per resolution for each type of rule. As with RAVEN-FAIR, there is a clear role for each resolution. The lower resolution is responsible for the 'line' rules, which are more semantic, while the upper resolution is for the 'shape' rules, which have a strong spatial dependency. The middle resolution is specialized in shape-number, likely because the 3$\times$3 grid alignment of the shapes in each individual image $I_C^n$ of PGM (not to be confused with the 3$\times$3 question alignment) is close to the 5$\times$5 shaped matrix of the encodings $e_m$. The analysis of the model trained on PGM\_meta shows specifically where the added auxiliary loss contributes. All resolutions improved their area of expertise from the setting without the metadata and learned to solve additional tasks. Some rules were already solved without the auxiliary loss, such as 'shape-number' and 'line-type, but others, such as 'shape-color' and 'shape-type', received a substantial increase in accuracy. {$\mathcal{L}_3$ showed a large improvement on all rules and better utilization of the middle resolution, without having to use the metadata.} The exact results on each rule can be found in the supplementary. Both analyses come to the same conclusion: Each scale is naturally advantageous for a different set of tasks. Rules that require full embedding of the image, to recognize the shape of a large object (RAVEN 'Center') or detecting a pattern in arbitrary located lines (PGM 'line-color'), require low-resolution encoding. Rules on small objects and specific positions (RAVEN 'L-R', PGM 'shape-position') are better solved in high resolution, before the spatial coherency is lost. We noticed during training that the model converges in steps, i.e. that several times the improvement on the validation set stagnates and then starts to rise again. We hypothesized that these steps occur when learning new rules and have conducted a per-rule analysis during training. The results, presented in the supplementary, indicate that this is indeed the case. A different set of rules is learned in each step and the learned rules usually have a common property. \section{Conclusions} The novel method we introduce outperforms the state of the art methods across tasks, protocols, benchmarks, and splits. It also generalizes better on unseen rules. Since the MC protocol can be readily exploited, we advocate for the SC protocol, which more directly tests the ability to infer the pattern from the question. For MC, evaluating on the RAVEN-FAIR variant mitigates the weaknesses of the original RAVEN benchmark. We expect both multi-scale encoders and pairwise distance-based pooling to be beneficial also for other multi-faceted tasks that involve reasoning such as causality analysis based on temporal sequences, visual question answering, and physics-based reasoning. \subsection*{Acknowledgements} The contribution of the first author is part of a Ph.D. thesis research conducted at Tel Aviv University. This project has received funding from the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant ERC CoG 725974). \section{An example of biases in the construction of the negative choices}\label{sec:example} In the main paper, Sec.~2.1, we discuss the importance of the selected approach for the creation of the negative choices and that it should be done carefully. In this section, we elaborate on this topic by showing examples for bad edge cases. Consider the following four sets of answers to the question ``when and where was 'The Declaration of the Rights of Man' published?'' \begin{enumerate} \item \makebox[35mm]{(a) Aug. 1789, France\hfill} ~ \makebox[35mm]{(b) Albert Einstein\hfill} \\ \makebox[35mm]{(c) 55\%\hfill} ~ \makebox[35mm]{(d) Alpha Centauri A\hfill} \item \makebox[35mm]{(a) Aug. 1789, France\hfill} ~ \makebox[35mm]{(b) Nov. 1784, Italy\hfill} \\ \makebox[35mm]{(c) Dec. 1780, Brazil\hfill} ~ \makebox[35mm]{(d) Feb. 1782, Japan\hfill} \item \makebox[35mm]{(a) Aug. 1789, France\hfill} ~ \makebox[35mm]{(b) Nov. 1789, France\hfill} \\ \makebox[35mm]{(c) Aug. 1784, France\hfill} ~ \makebox[35mm]{(d) Aug. 1789, Italy\hfill} \item \makebox[35mm]{(a) Aug. 1789, France\hfill} ~ \makebox[35mm]{(b) Nov. 1789, France\hfill} \\ \makebox[35mm]{(c) Nov. 1784, France\hfill} ~ \makebox[35mm]{(d) Nov. 1784, Italy\hfill} \end{enumerate} In all options, the correct answer is the same (a). However, there is a big difference in the negative examples that make the question either easier of harder to answer. The first option is too simple. The negative choices do not fit the domain of the question and it can be solved without any prior knowledge (by prior knowledge, we mean having some information about the questions). The only answer that fits the domain is also the correct answer. In the second option, all negative choices are from the same domain as the correct answer. The negative choices are similar enough so that the correct answer cannot be chosen, beyond luck, without having at least some prior knowledge. However, the options are at the same time random enough so that knowing only one attribute (month, year, location) is sufficient to know the answer. For example, one only needs to know that the declaration was published in France to correctly answer the question, without knowing when it was published. In the third options, each negative choice is produced by changing a single attribute from the correct answer. Unlike the previous option, knowing only one attribute is not enough to eliminate all negative choices, which makes the question more difficult. However, one could notice that 'Aug', '1789' and 'France' are majority attributes in all the answers. If this pattern is recurring across all questions in the test, the participant can learn how to locate the correct answers without even looking at the question. Paradoxically, this issue becomes more severe when more choices are given, in contrast to the purpose of adding more choices. Finally, the fourth option overcomes all the limitations of the previous examples. The negative choices are sufficiently related so that elimination requires prior knowledge and the attributes are diverse enough so that a majority guess does not promise a correct answer. However, this option is more complicated to produce and a sophisticated method for generating the negative choices needs to be designed. \subsection{Implications for RAVEN} As explained in the related work (Sec.~2), the negative examples in RAVEN are generated by changing a single arbitrary attribute from the correct answer every time. This approach is equivalent to option (3) in the example given above. The problem with this approach is that the model can learn to extract the properties of each attribute from the choice images and compare which values occur in most options. The model can then make an educated guess on which choice is the correct answer. In the next section, we show that this topic is not just a hypothetical concern, but an actual flaw of the RAVEN dataset that is easily exploited by MC protocol models. \begin{table}[t] \caption{Dataset benchmarks using ResNet. Accuracy(\%)} \label{tab:resnet} \centering \begin{tabular}{@{}l@{~}c@{~~}c@{~}c@{~}c@{~}c@{~}c@{~}c@{}} \toprule & \multicolumn{3}{c}{PGM} & \multicolumn{4}{c}{RAVEN}\\ \cmidrule(lr){2-4} \cmidrule(lr){5-8} Model & all & lines & shapes & ORIG & FAIR & R-IN & R-ALL \\ \midrule \emph{ResNet-Blind} & 18.6 & 33.8 & 14.7 & 80.2 & 17.2 & 13.1 & 13.5 \\ \emph{ResNet-MC} & 41.1 & 60.7 & 28.7 & 72.5 & 24.5 & 52.8 & 81.6 \\ \emph{ResNet-SC} & 48.9 & 67.1 & 40.1 & 40.4 & 58.4 & 82.9 & 94.4 \\ \bottomrule \end{tabular} \end{table} \section{Dataset analysis}\label{sec:data_analysis} In Sec.~2.1 of the paper, we discuss the datasets and their potential pitfalls. We then define two different protocols (SC and MC) that can be followed when challenging this task. In Sec.~3, we provide a new dataset (RAVEN-FAIR) that is better suited than the original dataset for the MC protocol. We have discussed the results of experiments done on the blind, SC and MC settings. In this section, we provide the details of these experiments and their results. Before using the PGM and RAVEN datasets in our experiments. We analyzed each of them in how they perform on three tests: (i) context-blind test, (ii) multiple choice test (iii) single choice test. The results can be seen in Tab.~\ref{tab:resnet}. The model for each test is based on the ResNet16, with an adjusted input and output layer to comply with each test. For the context-blind test, the model (ResNet-Blind) accepts the eight choices, without the context images, as an 8-channel image and produces a probability for each of the input channels to be the correct answer. For the multiple choice test, the model (ResNet-MC) accepts all 16 images as a 16-channel image (context:1-8, choices:9-16) and produces the probability for channels 9-16, which are the choices. For the single choice test, the model (ResNet-SC) accepts a 9-channel image with the context being the first eight channels and a choice added as the ninth channel. The model is fed eight iterations for each question to evaluate each choice separately, and the image with the highest score is chosen as the correct one. For PGM, we evaluated not only the full dataset, but also two subsets of it, where rules were only applied on the lines or on the shapes. Each subset accounts for roughly a third of the dataset and the remaining third is where both line and shape rules are applied simultaneously. In Tab.~\ref{tab:resnet}, the full dataset came out to be relatively balanced, it had a low score on the context-blind test (18.6\%) and balanced score between the MC and SC protocols (41\% for MC and 48.9\% for SC). We have found the lines subset to be significantly easier overall than the shapes subset across all tests, which suggests that the dataset could be improved in that regard. For RAVEN, we compared four different versions of the dataset. The difference between the versions is the method in which the negative choices were selected. ORIG is the original version of RAVEN. FAIR is our proposed improved dataset. R-IN and R-ALL are two versions where the negative choices were chosen randomly. In R-IN, the negative examples were sampled from the same domain as the correct answer. In R-ALL, we sampled from all domains. The four versions of the dataset represent the four options presented in the question earlier in Sec.~\ref{sec:example}. R-ALL represents option 1, since the negative choices are out of the domain of the correct answer. R-IN represents option 2, since the negative choices are randomly selected from within the domain of the correct answer. ORIG represents option 3, since the negative choices are one attribute away from the correct one. FAIR represents option 4, since it aims not to be too conditioned on the correct answer while not being too random. The evaluation in Tab.~\ref{tab:resnet}, shows that RAVEN indeed fails the context-blind test (80.2\%). On the other hand, R-IN (13.1\%) and R-ALL (13.3\%) were unsolvable in this setting, as expected. RAVEN-FAIR passed the context-blind as well (17.2\%), with an equal performance with PGM. When the context was added, both R-IN and R-ALL became notably easy to solve (82.9\%, 94.4\% respectively on ResNet-SC), which highlights that sampling negative choices randomly is a bad design. ORIG turned out to be more difficult than FAIR in the SC test. This is reasonable since all negative examples are very close to the correct answer in ORIG, which makes them more challenging than those of FAIR. On the other hand, ORIG turned out to be really easy in the MC test (72.5\%), while FAIR was significantly harder (40.4\%). This is due to the fact that ORIG fails the context-blind test and is easy to solve when all the choices are presented simultaneously. This evaluation shows that one needs to be very careful in evaluating models with RAVEN, since it cannot be used in the MC setting. Interestingly, except for the original RAVEN, ResNet-SC performed consistently better than ResNet-MC. This is in contrast to the common sense that MC is a simpler setting than SC due to capability to compare the choices. We conclude that this is an architectural drawback of ResNet-MC that it has less practical capability, since it processes all choices at once without added capacity. It is also not permutation invariant to the choices, which means that changing the order of the choices could lead to a different result. \begin{table*}[t] \caption{Understanding the role of each scale in PGM. Accuracy(\%)} \label{tab:multires-pgm} \centering \begin{tabular}{@{}lllc@{~}c@{~}c@{~}cc@{~}c@{~}c@{~}cc@{~}c@{~}c@{~}c} \toprule & & & \multicolumn{12}{c}{Operation} \\ \cmidrule(lr){4-15} & & & \multicolumn{4}{c}{Progression} & \multicolumn{4}{c}{XOR+OR+AND} & \multicolumn{4}{c}{Consistent Union} \\ \cmidrule(lr){4-7} \cmidrule(lr){8-11} \cmidrule(lr){12-15} & Subset & Attribute & ALL & H & M & L & ALL & H & M & L & ALL & H & M & L \\ \midrule \parbox[t]{3mm}{\multirow{7}{*}{\rotatebox[origin=c]{90}{PGM}}} & \multirow{5}{*}{\rotatebox[origin=c]{0}{Shape}} & Color & 14.8 & 14.8 & 12.2 & 14.1 & 15.4 & 14.7 & 14.9 & 12.1 & 17.3 & 16.2 & 14.6 & 11.9 \\ & & Type & 23.8 & 20.8 & 12.6 & 11.5 & 12.9 & 13.5 & 12.1 & 10.3 & 15.7 & 11.0 & 12.1 & 13.2 \\ & & Size & 96.5 & 95.7 & 13.5 & 11.5 & 51.0 & 43.9 & 13.7 & 14.9 & 79.1 & 73.6 & 12.0 & 15.1 \\ & & Position & \multicolumn{4}{c}{\xmark} & 99.9 & 99.9 & 12.6 & 14.7 & \multicolumn{4}{c}{\xmark} \\ & & Number & 100 & 12.7 & 100 & 12.4 & \multicolumn{4}{c}{\xmark} & 100 & 13.7 & 100 & 13.7 \\ \cmidrule(lr){2-15} & \multirow{2}{*}{\rotatebox[origin=c]{0}{Line}} & Color & 100 & 13.3 & 10.7 & 100 & 96.9 & 12.4 & 12.6 & 92.9 & 99.6 & 12.5 & 11.4 & 99.9 \\ & & Type & \multicolumn{4}{c}{\xmark} & 100 & 39.1 & 13.1 & 30.4 & 100 & 100 & 15.9 & 12.8 \\ \midrule \parbox[t]{3mm}{\multirow{7}{*}{\rotatebox[origin=c]{90}{PGM\_meta}}} & \multirow{5}{*}{\rotatebox[origin=c]{0}{Shape}} & Color & 71.5 & 58.9 & 11.8 & 15.6 & 31.4 & 29.0 & 12.3 & 12.0 & 40.8 & 28.5 & 12.7 & 15.4 \\ & & Type & 92.6 & 88.8 & 13.0 & 17.5 & 52.0 & 47.8 & 15.2 & 13.5 & 65.8 & 47.7 & 12.8 & 12.8 \\ & & Size & 92.3 & 91.2 & 12.7 & 15.0 & 56.3 & 45.6 & 11.7 & 12.1 & 72.5 & 65.9 & 15.1 & 14.3 \\ & & Position & \multicolumn{4}{c}{\xmark} & 99.9 & 94.6 & 68.8 & 12.5 & \multicolumn{4}{c}{\xmark} \\ & & Number & 100 & 14.8 & 100 & 12.1 & \multicolumn{4}{c}{\xmark} & 99.6 & 13.7 & 99.4 & 14.6 \\ \cmidrule(lr){2-15} & \multirow{2}{*}{\rotatebox[origin=c]{0}{Line}} & Color & 100 & 12.3 & 13.8 & 100 & 96.0 & 11.3 & 12.4 & 87.3 & 100 & 12.1 & 10.6 & 99.9 \\ & & Type & \multicolumn{4}{c}{\xmark} & 100 & 50.8 & 12.9 & 49.2 & 100 & 99.9 & 15.7 & 23.4 \\ \midrule \parbox[t]{3mm}{\multirow{7}{*}{\rotatebox[origin=c]{90}{PGM $\mathcal{L}_3$}}} & \multirow{5}{*}{\rotatebox[origin=c]{0}{Shape}} & Color & 91.5 & 89.5 & 12.7 & 13.7 & 54.5 & 48.7 & 12.0 & 12.7 & 88.0 & 83.3 & 12.2 & 13.1 \\ & & Type & 98.2 & 97.2 & 14.1 & 12.1 & 80.0 & 76.9 & 12.6 & 12.5 & 91.3 & 88.5 & 13.0 & 11.5 \\ & & Size & 98.0 & 92.5 & 11.7 & 12.6 & 79.8 & 76.4 & 12.8 & 12.4 & 93.9 & 88.2 & 12.6 & 13.9 \\ & & Position & \multicolumn{4}{c}{\xmark} & 99.9 & 98.5 & 99.9 & 12.5 & \multicolumn{4}{c}{\xmark} \\ & & Number & 100 & 27.2 & 100 & 12.1 & \multicolumn{4}{c}{\xmark} & 100 & 25.3 & 99.9 & 12.5 \\ \cmidrule(lr){2-15} & \multirow{2}{*}{\rotatebox[origin=c]{0}{Line}} & Color & 100 & 12.6 & 99.2 & 100 & 97.7 & 14.6 & 87.7 & 97.2 & 100 & 12.5 & 97.9 & 98.3 \\ & & Type & \multicolumn{4}{c}{\xmark} & 99.9 & 99.5 & 99.8 & 39.3 & 100 & 99.6 & 99.8 & 34.4 \\ \bottomrule \end{tabular} \end{table*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth, trim={70 10 70 20}, clip]{supplementary/tsne2.png} \caption{t-SNE analysis of each resolution. (a) High resolution $v_h$. (b) Middle resolution $v_m$. (c) Low resolution $v_l$.} \label{fig:tsne} \end{figure*} \begin{figure*}[t] \centering \begin{tabular}{cc} \includegraphics[width=0.45\textwidth, trim={0 0 0 0}, clip]{supplementary/performance_no_multihead.png} & \includegraphics[width=0.45\textwidth, trim={0 0 0 0}, clip]{supplementary/performance_multihead.png} \\ (a) & (b) \\ \end{tabular} \caption{Accuracy for each rule over time. (a) Without $\mathcal{L}_3$. (b) With $\mathcal{L}_3$. It can be seen that during each 'step', the model is focused at learning a different subset of tasks. It is also noticeable that the added multihead loss immediately improves the rules that the model was not able to solve.} \label{fig:accuracy_over_time} \end{figure*} \section{Analyzing PGM per rule and stage} In Sec.~5, we analyze the performance on PGM per rule and per stage in our networks. This allows us to determine which stage is responsible for solving each task. We have shown visually how each stage performs on each task. In addition to that, Tab.~\ref{tab:multires-pgm} shows the accuracy for in total and for each stage with respect to each rule. The table also shows the accuracy per type of operation ('progression', 'logical', 'consistent-union'), where this separation was not done in the main paper. We noticed that the operations have sometimes different performances. For example, in PGM\_meta, the rules 'shape-color', shape-type' and 'shape-size' work much better in 'progression' than in the other operations. We also noticed that, for each rule, the same resolution solves all operations. To better understand how each resolution solves each type of rule, we performed a t-SNE analysis of the embedding layer $v_t$ of each resolution, for the embedding of the correct answer $I^{a^*}$. The analysis was done on the fully trained model with $\mathcal{L}_3$. It can be seen in Fig.~\ref{fig:tsne}. It should be noted that separation of the rules in the latent space is not a requirement for accuracy in solving the task, but we have observed high correlation between the two in each resolution and it is a valuable analysis nevertheless. (a) The upper resolution is good at separating most rule types. It even separates 'line-type' into distinct sub-groups, which we have found to be correlated to the relational operation 'progression', 'union', 'xor', etc'. (b) The middle resolution is very good at separating some tasks, such as 'line-type', 'line-color', 'shape-number', and 'shape-position'. These rules are also separated into sub-groups and are also where this resolution has a high accuracy on. The other rules are not separated at all and the resolution also had trouble in solving them. (c) The lower resolution had the lowest overall performance in accuracy and also in separating the rules. However, we did notice that it was exceptional in separating the 'line-color' rules into multiple sub-groups. The lower resolution also has the highest accuracy on this type of rules. Aside from the final results per rule, we noticed an interesting behaviour in the training convergence. Fig.~\ref{fig:accuracy_over_time} shows the accuracy of each rule and operation over time. We noticed that the model does not learn all the rules at the same time. Instead, the training appears to go in stages, where the model learns a particular kind of rule at each stage. In Fig.~\ref{fig:accuracy_over_time}(a), we show the learning progress without $\mathcal{L}_3$, and in Fig.~\ref{fig:accuracy_over_time}(b), we show the contribution of $\mathcal{L}_3$ when it is added. It was especially surprising to see that the model only started to learn 'line-color' very late (around 500K iterations) but did it very fast (within ~50K iterations for 'progression' and 'union'). The model is able to learn numerous rules without the multihead loss $\mathcal{L}_3$. However, many rules, especially in the 'shape' category are not solved well. The addition of the multihead loss immediately and significantly increases the performance on all rules. Since training took a long time and we measured only after each epoch, the plot doesn't show the progress in the early stages of the training, which would show when the 'easier' tasks have been learned. Future work can focus on this 'over-time' analysis and try to explain: (i) 'why are some rules learned and others not?', (ii) 'why are some rules learned faster than others?', (iii) 'how can the training time be shortened?', (iv) 'would the rules that were learned late also be learned if the easier rules were not present?'. \section{Architecture of each sub-module} We detail each sub-module used in our method in Tab.~\ref{table:arch_E}-\ref{table:arch_MLP}. Since some modules re-use the same blocks, Tab.~\ref{table:arch_general} details a set of general modules. \begin{table*}[t] \caption{General modules, with variable number of channels $c$.}\label{table:arch_general} \centering \begin{tabular}{llccc} \toprule Module & layers & parameters & input & output\\ \midrule \multirow{7}{*}{ResBlock3($c$)} & Conv2D & C$c$K3S1P1 & $x$ \\ & BatchNorm \\ & ReLU \\ & Conv2D & C$c$K3S1P1 \\ & BatchNorm & & & $x'$ \\ & Residual & & $(x,x')$ & $x''=x+x'$ \\ & ReLU \\ \midrule \multirow{10}{*}{DResBlock3($c$)} & Conv2D & C$c$K3S1P1 & $x$ \\ & BatchNorm \\ & ReLU \\ & Conv2D & C$c$K3S1P1 \\ & BatchNorm & & & $x'$ \\ \cmidrule(lr){2-5} & Conv2D & C$c$K1S2P0 & $x$ \\ & BatchNorm & & & $x_d$ \\ \cmidrule(lr){2-5} & Residual & & $(x_d,x')$ & $x''=x_d+x'$ \\ & ReLU \\ \midrule \multirow{7}{*}{ResBlock1($c$)} & Conv2D & C$c$K1S1P0 & $x$ \\ & BatchNorm \\ & ReLU \\ & Conv2D & C$c$K1S1P0 \\ & BatchNorm & & & $x'$ \\ & Residual & & $(x,x')$ & $x''=x+x'$ \\ & ReLU \\ \bottomrule \end{tabular} \end{table*} \begin{table*}[ht] \caption{Encoders $E_h,E_m,E_l$}\label{table:arch_E} \centering \begin{tabular}{lllcc} \toprule Module & layers & parameters & input & output\\ \midrule \multirow{6}{*}{$E_{h}$} & Conv2D & C32K7S2P3 & $I^1$ & \\ & BatchNorm \\ & ReLU \\ & Conv2D & C64K3S2P1 \\ & BatchNorm \\ & ReLU & & & $e^1_h$ \\ \midrule \multirow{6}{*}{$E_{m}$} & Conv2D & C64K3S2P1 & $e^1_h$ & \\ & BatchNorm \\ & ReLU \\ & Conv2D & C128K3S2P1 \\ & BatchNorm \\ & ReLU & & & $e^1_m$ \\ \midrule \multirow{6}{*}{$E_{l}$} & Conv2D & C128K3S2P1 & $e^1_m$ & \\ & BatchNorm \\ & ReLU \\ & Conv2D & C256K3S2P1 \\ & BatchNorm \\ & ReLU & & & $e^1_l$ \\ \bottomrule \end{tabular} \end{table*} \begin{table*}[ht] \caption{Relation networks $RN_h,RN_m,RN_l$}\label{table:arch_RM} \centering \begin{tabular}{lllcc} \toprule Module & layers & parameters & input & output \\ \midrule \multirow{5}{*}{$RN_{h}$} & Conv2D & C64K3S1P1 & $(e^1_h,e^2_h,e^3_h)$ & \\ & ResBlock3 & C64 \\ & ResBlock3 & C64 \\ & Conv2D & C64K3S1P1 \\ & BatchNorm & & & $r^1_h$ \\ \midrule \multirow{5}{*}{$RN_{m}$} & Conv2D & C128K3S1P1 & $(e^1_m,e^2_m,e^3_m)$ & \\ & ResBlock3 & C128 \\ & ResBlock3 & C128 \\ & Conv2D & C128K3S1P1 \\ & BatchNorm & & & $r^1_m$ \\ \midrule \multirow{5}{*}{$RN_{l}$} & Conv2D & C256K1S1P0 & $(e^1_l,e^2_l,e^3_l)$ & \\ & ResBlock1 & C256 \\ & ResBlock1 & C256 \\ & Conv2D & C256K1S1P0 \\ & BatchNorm & & & $r^1_l$ \\ \bottomrule \end{tabular} \end{table*} \begin{table*}[ht] \caption{Bottlenecks $B_h,B_m,B_l$}\label{table:arch_B} \centering \begin{tabular}{lllcc} \toprule Module & layers & parameters & input & output \\ \midrule \multirow{2}{*}{$B_{h}$} & DResBlock3 & C128 & $b_h$ \\ & DResBlock3 & C128 & & \\ & AvgPool2D & & & $v_h$ \\ \midrule \multirow{2}{*}{$B_{m}$} & DResBlock3 & 256 & $b_m$ \\ & DResBlock3 & C128 & & \\ & AvgPool2D & & & $v_m$ \\ \midrule \multirow{4}{*}{$B_{l}$} & Conv2D & C256K1S1P0 & $b_l$ & \\ & BatchNorm \\ & ReLU \\ & ResBlock1 & C128 & & $v_l$ \\ \bottomrule \end{tabular} \end{table*} \begin{table*}[ht] \caption{MLP}\label{table:arch_MLP} \centering \begin{tabular}{lllcc} \toprule Module & layers & parameters & input & output \\ \midrule \multirow{8}{*}{$MLP$} & Linear & C256 & $(v_h,v_m,v_l)$ \\ & BatchNorm \\ & ReLU \\ & Linear & C128 & \\ & BatchNorm \\ & ReLU \\ & Linear & C1 & \\ & Sigmoid & & & $p(y=1 | I^a, I_C)$ \\ \bottomrule \end{tabular} \end{table*}
{'timestamp': '2021-07-28T02:03:48', 'yymm': '2009', 'arxiv_id': '2009.09405', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09405'}
arxiv
\subsection{Construction of rigid matrices: An algebraic geometry perspective} In \cite{KLPS14}, the authors attempt to construct rigid matrices by using a approach based on {\em algebraic geometry} that we discuss in this subsection. The rigid matrices demonstrated in \cite{KLPS14} have the same shortcomings as that of \cite{Lok00,Lok06} in the sense that these matrices are not as explicit as we want them to be although their rigidity matches the upper bound in Lemma \ref{lem:rigid-upperbound}. However, the construction of rigid matrices based on ideas from elimination theory is quite insightful. \begin{theorem} \label{thm:rigid-alggeo} Let $p_{11},\ldots,p_{nn}$ be $n^2$ distinct primes greater than $n^{4n^2}$ and $\zeta_{ij}$ be the primitive root of unity of order $p_{ij}$ (i.e., $\zeta_{ij}= e^{2\pi i/p_{ij}}$). Let $A \in \mathbb{K}^{n\times n}$ be the matrix given by $A[i,j]=\zeta_{ij}$ where $\mathbb{K}=\mathbb{Q}(\zeta_{ij},\ldots,\zeta_{ij})$. Then $R_A^{\mathbb{K}}(r)= (n-r)^2$. \end{theorem} \noindent {\em Proof Sketch of Theorem \ref{thm:rigid-alggeo}.} The proof involves the following observations as basic building blocks: \begin{enumerate} \item[(1)] The set of $n\times n$ matrices of rigidity at most $s$ for rank $r$ have dimension $n^2 - (n-r)^2 +s$ when viewed as an algebraic variety. \item[(2)] By using (1), prove the existence of a non-zero polynomial $g$ of not-so-large degree in the {\em elimination ideals} associated with matrices with rigidity at most $s$. \item[(3)] As the matrix $A$ has as entries primitive roots of unity of high order, $A$ cannot satisfy any polynomial $g$ with such a degree upper bound(i.e., $g(A)\neq 0$). \end{enumerate} Before we briefly describe each of the steps outlined above we will need the following notation: \begin{notation} \begin{itemize} \item For any $n\times n$ matrix $A\in \mathbb{F}^{n\times n}$, ${\sf Supp}(A)$ denotes the positions $(i,j)$ in $A$ where there are non-zero entries. \item Let {\em pattern} $\pi$ denote a subset of positions $\{(i,j) \mid i,j\in [n]\}$ in the matrix $A$. For any pattern $\pi$ let $S(\pi)$ be set of $n\times n$ matrices $A$ over $\mathbb{F}$ that are supported only on positions in $\pi$ (i.e., ${\sf Supp}(A)\subseteq \pi$). \item For a fixed pattern $\pi$ denote by ${\sf RIG}(n,r,\pi,\mathbb{F})$ the set of matrices in $\mathbb{F}^{n\times n}$ such that their rank can be reduced to $r$ by changing only the locations indexed by $\pi$. We will drop $\mathbb{F}$ when the field is clear from the context for ease of notation. \end{itemize} \end{notation} \paragraph*{Step (1):}Let $\pi$ be a fixed pattern of size $s$. By definition of matrix rigidity, for every matrix $A\in {\sf RIG}(n,r,\pi)$ there exists a matrix $C_\pi\in \mathbb{F}^{n\times n}$ with ${\sf Supp}(C_\pi)\subseteq \pi$ and ${rank}(A+C_\pi) =r$. The first observation to make is that both these conditions - ${\sf Supp}(C_\pi)\subseteq \pi$ and ${rank}(A+C_\pi) =r$ can be expressed via polynomial equations(support can be expressed via simple linear equations and rank being $r$ can be expressed by $(r+1)\times(r+1)$ minors of $A+C_\pi$ being 0). That is, ${\sf RIG}(n,r,\pi)$ is solution of a system of finitely many polynomial equations in variables $x_1,\ldots,x_{n^2},t_1,\ldots,t_s$. Hence, ${\sf RIG}(n,r,\pi)$ is an affine algebraic variety and so is ${\sf RIG}(n,r,\leq s) = \bigcup_{\pi : |\pi|=s}$ the set of $n\times n$ matrices of rigidity at most $s$ for rank $r$. Thus, it makes sense to talk about the dimension of ${\sf RIG}(n,r,\leq s)$ as an affine algebraic variety. Now, we analyse upper and lower bounds on the dimension of ${\sf RIG}(n,r,\leq s)$. \paragraph*{Upper bound on $\dim({\sf RIG}(n,r,\leq s))$:} Clearly, $\dim({\sf RIG}(n,r,\leq s))\leq n^2$. By the definition of rigidity, there is a natural map $\Phi$ from the product of rank $r$ $n\times n$ matrices and $S(\pi)$ to ${\sf RIG}(n,r,\pi))$(i.e., $\Phi((A,C_\pi)) = A+C_\pi$). As mentioned earlier the set of rank $r$ $n\times n$ matrices as well as $S(\pi)$ form an affine algebraic variety. Note that $\dim(S(\pi))=s$ for any pattern $\pi$ of size $s$. Also, by an argument similar to Lemma \ref{lem:rigid-upperbound} dimension of the variety corresponding to rank $r$ $n\times n$ matrices is $n^2-(n-r)^2$. Putting this all together, $\dim({\sf RIG}(n,r,\pi)) \leq n^2-(n-r)^2 +s$ since $\Phi$ is surjective. \paragraph*{Lower bound on $\dim({\sf RIG}(n,r,\leq s))$:} First, let us try to understand {\em elimination ideals} associated with matrices of low rigidity. For any pattern $\pi$ with $|\pi|=s$, let $T_{\pi}$ denote the $n\times n$ matrix with variables $y_1,\ldots,y_s$ as entries in the $s$ positions indexed by $\pi$. It is clear hat for any $n\times n$ matrix $X$ with entries $x_{1},\ldots,x_{n^2}$, the fact that ${rank}(X+T_{\pi})=r$ is the same as saying that all $(r+1)\times (r+1)$ minors of the matrix $X+T_{\pi}$ vanish. Then denoting by $I(n,r,\pi)$ the ideal generated by the $(r+1)\times (r+1)$ minors of the matrix $X+T_{\pi}$, we get that $I(n,r,\pi)\subseteq \mathbb{F}[x_1,\ldots,x_{n^2},y_1,\ldots,y_s]$. It is not difficult to observe that ${\sf RIG}(n,r,\pi) = \psi(\mathbb{V}(I(n,r,\pi))$ where $\psi$ is a projection map representing the projection of $s$ variables $y_1,\ldots,y_s$. Let us define the {\em elimination ideal} $EI(n,r,\pi)$ as the ideal $EI(n,r,\pi) \triangleq I(n,r,\pi) \cap \mathbb{F}[x_1,\ldots,x_{n^2}]$. By Closure Theorem of elimination theory[], $\psi(\mathbb{V}(I(n,r,\pi)) = \mathbb{V}(EI(n,r,\pi))$. Hence, $\dim({\sf RIG}(n,r,\pi)) =\dim(\mathbb{V}(EI(n,r,\pi)))$ and $\dim({\sf RIG}(n,r,\leq s)) = \max_{k\leq s,\pi}\dim(\mathbb{V}(EI(n,r,\pi)))$. The authors in \cite{KLPS14} demonstrate a pattern $\pi$ of size $k\leq s$ such that $\dim(\mathbb{V}(EI(n,r,\pi))) \leq n^2-(n-r)^2 +s$ thhus obtaining a lower bound on $\dim({\sf RIG}(n,r,\leq s))$. \paragraph*{Step (2):}From Step 1, proving that a matrix $A$ has rigidity $(n-r)^2$ for rank $r$ is the same as showing that $A\not \in {\sf RIG}(n,r,\leq (n-r)^2-1)$. This is in essence the same as proving that $A\not\in {\sf RIG}(n,r,\pi)$ for any pattern $\pi$ with $|\pi|= (n-r)^2-1$. Given that ${\sf RIG}(n,r,\pi) = \mathbb{V}(EI(n,r,\pi))$, we want to show $A \not\in \mathbb{V}(EI(n,r,\pi))$ for any pattern $\pi$ with $|\pi|= (n-r)^2-1$. In other words, our goal is to the existence of a non-zero fairly-low degree polynomial $g\in EI(n,r,\pi)$ such that $g(A)\neq 0$. But what if $EI(n,r,\pi) =\langle 0\rangle$? To rule this out, observe that $\dim(\mathbb{V}(EI(n,r,\pi))) < n^2$ for any pattern $\pi$ with $|\pi|= (n-r)^2-1$. Hence $EI(n,r,\pi) \neq (0)$ by Hilbert's Nullstellensatz. In particular, the authors in \cite{KLPS14} use the effective Nullstellensatz theorem of \cite{DFGS91} which is as follows: \begin{theorem} Let $Z = \{ z_1,\ldots,z_m\}$ and $I = \langle F_1,\ldots,f_p \rangle \subseteq\mathbb{F}[Z]$ such that the maximum degree of any of the $f_i$'s is $d$. Let $Z'$ be a subset of $\ell$ $Z$ variables. If $I\cap \mathbb{F}[Z'] \neq \langle 0 \rangle$ then there exists a non-zero polynomial $g\in I\cap \mathbb{F}[Z']$ such that $g=\sum_{i\in [p]} f_i g_i$ where $g_i \in \mathbb{F}[Z']$ and $\deg(g_i f_i) \leq d^p(d^p+1)$. \end{theorem} In our setting, $Z =\{x_1,\ldots,x_{n^2},y_1,\ldots,y_s \} , Z' =\{x_1,\ldots,x_{n^2}\}, I = I(n,r,\pi)$ and $d\leq r+1$ for sufficiently large $n,r$. Then there exists a polynomial $g$ in $I(n,r,\pi)\cap \mathbb{F}[x_1,\ldots,x_{n^2}]$ of degree less than $n^{4n^2}$ where $\pi$ is a pattern of size $(n-r)^2-1$. This shows that there is a polynomial $g\in EI(n,r,\pi)$ of degree $<n^{4n^2}$. \paragraph*{Step (3):} Let $A \in \mathbb{K}^{n\times n}$ be the matrix in the statement of the theorem, $A[i,j]=\zeta_{ij}$ where $\mathbb{K}=\mathbb{Q}(\zeta_{ij},\ldots,\zeta_{ij})$. It is not very difficult to $g(A)\neq 0$ as the entries of the matrix $A$ are algebraic. This completes the proof of Theorem \ref{thm:rigid-alggeo}. \begin{remark} Along the lines of analysing the degree of the polynomial $g$ in the above result, Kumar and Volk in \cite{KV19} reduce the upper bound on the degree of such a polynomial to $\poly(n)$. That is, there is a polynomial $P$ on $n^2$ variables of degree at most $\poly(n)$ such that any matrix $M\in\mathbb{F}^{n\times n}$ with $R_{M}(n/100)\leq n^2/100$ satisfies $P(M) = 0$. \end{remark} \subsection{Non-Rigidity of Function Matrices} Let $\mathbb{F}_q$ be any finite field. For any function $f:\mathbb{F}_q^n\rightarrow \mathbb{F}_q$ let $M_f$ be the $q^n\times q^n$ matrix given by $M_f[I,J]=f(I+J)$ for any $I,J$ in $\mathbb{F}_q^n$. In the following subsection we discuss a result from \cite{DE17} proving an upper bound on the rigidity of the {\em function matrix} $M_f$\footnote{The term {\em function matrix} used here is non-standard terminology and is used here to denote that there is a specific function associated with these matrices.}. \begin{theorem} \label{thm:function-matrix} Let $f:\mathbb{F}_q^n\rightarrow \mathbb{F}_q$ be any function. For any $\epsilon>0$ and $n$ sufficiently large, there exists an $\epsilon ' >0$ such that ${\cal R}_{M_f}(q^{n(1-\epsilon')})\leq q^{n(1+\epsilon)}$. \end{theorem} The above theorem says that for any function $f:\mathbb{F}_q^n\rightarrow \mathbb{F}_q$ and any $\epsilon >0$, the matrix $M_f$ has rigidity at most $q^{n(1+\epsilon)}$ for rank $q^{n(1-\epsilon')}$ where the rank is over $\mathbb{F}_q$. \noindent\textit{Proof Sketch of Theorem \ref{thm:function-matrix}.} The proof is extremely elegant and involves the following two steps: \begin{enumerate} \item {\em Approximate} $f:\mathbb{F}_q^n\rightarrow \mathbb{F}_q$ by a polynomial $p:\mathbb{F}_q^n\rightarrow \mathbb{F}_q$ of {\em low} degree ($d=(1-\delta)n(q-1)$) for some $\delta>0$. By approximating function $f$ by polynomial $p$, we mean $|\{ x\in \mathbb{F}_q^n \mid p(x)\neq f(x) \}| \leq q^{n\epsilon}$. \item Show that for any polynomial $p:\mathbb{F}_q^n\rightarrow \mathbb{F}_q$ of sufficiently {\em low} degree($d$ being $(1-\delta)n(q-1)$), ${rank}(M_p)\leq q^{n(1-\epsilon')}$ for some $\epsilon'>0$ depending on $\delta$ and $\epsilon$. \end{enumerate} From Steps $1$ and $2$, we can infer that $M_f= S+L$ where $S=M_f-M_p$ and $L=M_p$. From Step 1 function $f$ and polynomial $p$ differ on at most $q^{n\epsilon}$ many inputs implying that $S$ has at most $q^{n\epsilon}$ non-zero entries in every row and column. Hence, ${sparsity}(S)\leq q^{n(1+\epsilon)}$. From Step 2, ${rank}(L)\leq q^{n(1-\epsilon')}$ for some $\epsilon'>0$. Thus , ${\cal R}_{M_f}(q^{n(1-\epsilon')})\leq q^{n(1+\epsilon)}$. $\hfill\square$ \paragraph{} We now delve into the details of Steps $1$ and $2$. The set of all functions $\{f \mid f:\mathbb{F}_q^n\rightarrow \mathbb{F}_q\}$ denoted by $F(q,n)$ is a vector space of dimension $q^n$ with basis $\{ x_1^{a_1}x_2^{a_2}\cdots x_n^{a_n}\mid 0\leq a_i\leq q-1 \}$. Let $F_d(q,n)$ be the set of polynomials of degree $d$ in $\mathbb{F}_q[x_1,\ldots,x_n]$. $F_d(q,n)$ is a subspace of $F(q,n)$ with basis $\{ x_1^{a_1}x_2^{a_2}\cdots x_n^{a_n} \mid 0\leq a_i\leq q-1, \sum_{i} a_i=d \}$. Any function $f:\mathbb{F}_q^n\rightarrow \mathbb{F}_q$ can be viewed as a vector $v$ in $F(q,n)$. To begin with, we show that for any $d\leq n$ by changing the vector $v$ in $F(q,n)$ (corresponding to the function $f$) on $\dim(F(q,n))-\dim(F_d(q,n))$ many coordinates, we can obtain a vector $u$ in $F_d(q,n)$ (corresponding to a polynomial $p$ of degree $d$). To complete the proof of Step $1$, we obtain a lower bound of $q^n-q^{n\epsilon}$ on $\dim(F_d(q,n))$ when $d=(1-\delta)n(q-1)$. Let $m\triangleq\dim(F(q,n))$ (i.e., $m=q^n$) and $r\triangleq\dim(F_d(q,n))$. As $F_d(q,n)$ is a subspace of $F(q,n)$, there is an $m\times r$ matrix $M$ of rank $r$ such that $F_d(q,n)$ is the image of the linear transformation defined by $M$. The aim here is to construct for any vector $v\in F(q,n)$, a vector $u$ in $F_d(q,n)$ that differs from $v$ on $m-r$ coordinates. In other words, for any vector $v$ in $F(q,n)$, we want to construct a vector $u$ agreeing with $v$ on $r$ coordinates such that $u$ is in the image of the transformation defined by $M$ (i.e., $u=My$ for some $y\in \mathbb{F}_q^r$). As ${rank}(M)=r$, there exists row-vectors $R_{i_1},\ldots,R_{i_r}$ that span the row-space of $M$. A natural attempt would be do construct a partial vector $\bar{u}$ by setting $u_{i_j}\triangleq v_{i_j}$ for every $j\in [r]$. To set the remaining coordinates of vector $u$, observe that the matrix $A$ with rows $R_{i_1},\ldots,R_{i_r}$ has full rank implying that there is a unique $x$ satisfying $Ax=\bar{u}$. As rows of $A$ span rows of $M$, the remaining coordinates of $u$ can be fixed using matrix $A$ and vector $x$. This implies that vector $u$ is in $F_d(q,n)$. Now, for $d=(1-\delta)n(q-1)$, we want a lower bound of $q^n-q^{n\epsilon}$ on $\dim(F_d(q,n))$. For this, we want to bound the size of the set $\{ x_1^{a_1}x_2^{a_2}\cdots x_n^{a_n} \mid 0\leq a_i\leq q-1, \sum a_i=d \}$. Let $m=x_1^{a_1}\cdots x_n^{a_n}$ be a monomial of degree $d$. Consider the map $\varphi: x_1^{a_1}\cdots x_n^{a_n} \mapsto x_1^{(q-1)-a_1}\cdots x_n^{(q-1)-a_n}$. Clearly, $\varphi$ is a bijection and $\deg(\varphi(m))\leq n(q-1)-d \leq \delta n(q-1)$ when $\deg(m)\geq (1-\delta)n(q-1)$. Hence, estimating $\dim(F_d(q,n))$ is the same as estimating $|\{ x_1^{a_1}x_2^{a_2}\cdots x_n^{a_n} \mid 0\leq a_i\leq q-1, \sum a_i \leq \delta n (q-1) \}|$. Now, by multilinearizing the monomial $x_1^{a_1}x_2^{a_2}\cdots x_n^{a_n}$ by $x_{11}x_{12}\cdots x_{1a_1}x_{21}\cdots x_{2a_2}\cdots x_{n1}x_{n}\cdots x_{na_n}$, it suffices to count the number of multilinear monomials of degree $\delta n (q-1)$ in $n(q-1)$ variables. Therefore, $\dim(F_d(q,n)) = \binom{n(q-1)}{\delta n (q-1)} = 2^{n(q-1)H(\delta)}$ where $H$ is the binary entropy function. By choosing $\delta$ to be a small enough, we get $\dim(F_d(q,n)) \leq q^{n\epsilon}$ where $\delta$ is a function of $q$ and $\epsilon$. Now, we move on to Step $2$. We use the {\em Croot-Lev-Pach Lemma} to obtain an upper bound on the rank of the matrix $M_p$ where the degree of $p$ if small enough. \begin{remark}[The Cap Set Problem] Consider the space $\mathbb{Z}_3^n$. The {\em cap set problem} is to understand the maximum size of a {\em cap set}, a subset $A$ of $\mathbb{Z}_3^n$ that does not contain pairwise distinct elements $a,b$ and $c$ that lie in a line (i.e., $a+b=2c$). That is, we want to find the size of the largest set $A$ in $\mathbb{Z}_3^n$ that does not contain an arithmetic progression of the form $\{x,x+r,x+2r\}$ for some $r>0$. A trivial upper bound on $|A|$ is that of $3^n$. By using the {\em polynomial method} Croot, Lev and Pach in \cite{CLP17} showed that over $\mathbb{Z}_4^n$, any cap set $A$ has size at most $4^{cn}$ where $c\approx 0.926$. For more on this problem, see blog posts \cite{Tao17,Gowers17} and references therein. \end{remark} We now state and prove the {\em Croot-Lev-Pach Lemma} completing the proof of Step 2. \begin{lemma} \label{lem:clp} Let $p$ be a polynomial in $F_d(q,n)$ and $M_p$ be the $q^n\times q^n$ matrix given by $M_p[I,J] =p(I+J)$ for all $I,J\in \mathbb{F}_q^n$. Then, ${rank}(M_p)\leq 2\cdot\dim(F_{d/2}(q,n))$. \end{lemma} \begin{proof} Let $p$ be a polynomial in $F_d(q,n)$, so $\deg(p)\leq d$. We show that for any $x,y\in \mathbb{F}_q^n$, $p(x+y)=\sum_{i=1}^{R}f_i(x)\cdot g_i(y)$, where $R\leq 2\cdot \dim(F_{d/2}(q,n))$ and the polynomial $f_i$ (respectively $g_i(y)$) is independent of what $x\in \mathbb{F}_q^n$ (respectively $y\in \mathbb{F}_q^n$) is. This immediately implies that $M_p = \sum_{i=1}^{R} M_i$ where each $M_i$ is the outer-product of two vectors in $\mathbb{F}_q^t $ ($t=q^n$) and ${rank}(M_i)=1$. Therefore, ${rank}(M_p)\leq R \leq 2\cdot\dim(F_{d/2}(q,n))$. As the polynomial $p$ is in $F_d(q,n)$, there exists coefficients $\alpha_{I,J}\in \mathbb{F}_q$ (depending on $p$) such that for any $x,y\in \mathbb{F}_q^n$, \begin{align*} p(x+y)&= \sum_{\substack{I,J\subseteq [n]\\ |I|+|J|\leq d}}\alpha_{I,J} x^I y^J \end{align*} where for any $I,J\subseteq [n]$, $x^I = \prod_{i\in I}x_i$ and $y^J = \prod_{j\in J}y_j$. For every $I,J\subseteq [n], |I|+|J|\leq d$, we have either $|I|\leq d/2$ or $|J|\leq d/2$. Then, \begin{equation} p(x+y) = \sum_{\substack{I\subseteq [n]\\ |I|\leq d/2}}x^I \left(\sum_{\substack{J\subseteq [n]\\ |J|\leq d-|I|}} \alpha_{I,J} y^J\right) + \sum_{\substack{J\subseteq [n]\\ |J|\leq d/2}}y^J \left(\sum_{\substack{I\subseteq [n]\\ d/2 < |I|\leq d-|J|}} \alpha_{I,J} x^I \right) \end{equation} Let $m$ be the number of subsets of $\{1,\ldots,n\}$ of size at most $d/2$. Note that $m= \sum_{i=0}^{d/2} \binom{n}{i} = \dim(F_{d/2}(q,n))$. Let $\{S_1,\ldots, S_m \}$ be subsets of $\{1,\ldots,n\}$ of size at most $d/2$. We now define vectors $\bar{f}$ and $\bar{g}$ in $\mathbb{F}^{2m}$ as follows: \begin{itemize} \item for $i\in [m]$, $f_i(x)=x^{S_i}$; and $g_i(y) = \sum\limits_{\substack{J\subseteq [n]\\ |J|\leq d-|S_i|}} \alpha_{S_i,J} y^J$. \item for $i\in [m]$, $f_{i+m}(x) = \sum\limits_{\substack{I\subseteq [n]\\ d/2 < |I|\leq d-|S_i|}} \alpha_{I,S_i} x^I$; and $g_{i+m}(y) = y^{S_i}$ \end{itemize} Clearly, $p(x+y)=<\bar{f},\bar{g}>$. Hence, $p(x+y)=\sum_{i=1}^{R}f_i(x)\cdot g_i(y)$, where $R\leq 2\cdot \dim(F_{d/2}(q,n))$ and ${rank}(M_p)\leq 2\cdot\dim(F_{d/2}(q,n))$. \end{proof} Now, we need to estimate $\dim(F_{d/2}(q,n))$. For this, we need upper bound on number of monomials in $F(q,n)$ of degree at most $d/2$ which is $q^n\cdot \Pr\limits_m[\deg(m)\leq d/2] \leq q^n\exp^{-\delta^2n/4}$ by Chernoff bound for $d=(1-\delta)n(q-1)$ when $m$ is a random monomial. Therefore, $\dim(F_{d/2}(q,n))\leq q^n\cdot q^{-\frac{n\delta^2}{4\log q}} \leq q^{n(1-\epsilon')}$ for some $\epsilon'>0$ thus completing the proof. \subsection{Non-rigidity of Generalized Hadamard Matrices} For the whole of this subsection we will deal with a {\em weaker} notion of rigidity. A matrix $A\in\mathbb{F}^{n\times n}$ has {\em weak rigidity} at most $s$ for rank $r$ if the rank of matrix $A$ can be reduced to $r$ by changing at most $s$ entries in every row and every column of $A$. The weak rigidity of a matrix $A$ for rank $r$ is denoted by $WR_A(r)$\footnote{In \cite{DL19} the authors use the term regular rigidity. However for ease, we use the term weak-rigidity}. Observe that this is a weaker notion of matrix rigidity that we have seen so far as $R_A(r)\leq n\cdot s$ whenever $WR_A(r)\leq s$. The {\em generalized Hadamard matrix} $H_{d,n}$ is a $d^n\times d^n$ matrix given by $H_{d,n}[I,J] = \omega^{I\cdot J}$ for $I,J\in \mathbb{Z}_d^n$ where $w=e^{\frac{2\pi i}{d}}$ is the $d^{th}$ root of unity. One of the results of \cite{DL19} is that generalized Hadamard matrices are not weakly rigid over $\mathbb{C}$. Note that these results are stronger than just saying that generalized Hadamard matrices are not rigid over $\mathbb{C}$. \begin{theorem} \label{thm:gen-hadamard} Let $d,n$ be positive integers. For any $\epsilon \in (0, 0.1)$ and $n \geq \frac{d^2 (\log d)^2}{\epsilon^4}$, there exists an $\epsilon ' = \frac{\epsilon^4}{d^2\log d}$ such that ${ WR}_{H_{d,n}}\left(d^{n\left(1-\epsilon '\right)}\right)\leq d^{n\epsilon}$. \end{theorem} In order to proceed with the proof of Theorem \ref{thm:gen-hadamard} we need to introduce a few notations and make some preliminary observations. For any $I\in \mathbb{Z}_d^n$ such that $I=(i_1,i_2,\ldots,i_n)$ we denote by $x^I$ the monomial $x_1^{i_1}x_2^{i_2}\cdots x_n^{i_n}$. Let $f:\mathbb{Z}_d^n \rightarrow \mathbb{C}$ be any function. We can associate with function $f$: \begin{enumerate} \item[(i)] a polynomial $P_f\in \mathbb{C}[x_1,\ldots ,x_n]$ given by $P_f\triangleq \sum_{I\in\mathbb{Z}_d^n} f(I)x^{I}$; and \item[(ii)] a $d^n\times d^n$ matrix $M_f$ given by $M_f [I,J] \triangleq f(I+J)$ for $I,J\in \mathbb{Z}_d^n$. \end{enumerate} It is reasonable to expect interesting connections between the matrix $M_f$ and polynomial $P_f$ which we pen down in the following observation: \begin{obs} \label{obs:rank-roots} Let $f:\mathbb{Z}_d^n \rightarrow \mathbb{C}$ be any function. If the polynomial $P_f$ has $r$ roots in the set $\{(\omega^{i_1},\ldots,\omega^{i_n})\mid (i_1,\ldots,i_n)\in \mathbb{Z}_d^n \}$ then ${rank}(M_f) = d^n-r$. \end{obs} Proof of the above observation is based on a simple fact that the matrix $H_{d,n}\cdot M_f\cdot H_{d,n}$ is a $d^n\times d^n$ diagonal matrix whose $[I,I]^{th}$ diagonal entry is given by $d^n\cdot P_f (\omega^{I})$ where $\omega^{I}$ denotes the tuple $(\omega^{i_1},\omega^{i_2},\ldots,\omega^{i_n})$ for any $I =(i_1,i_2,\ldots,i_n) \in \mathbb{Z}_d^n$.\footnote{The notation $\omega^{[I]}$ is more appropriate as $(\omega^{i_1},\omega^{i_2},\ldots,\omega^{i_n})$ is tuple in $\mathbb{Z}_d^n$. However we will use $\omega^{I}$ for ease of notation.} Now, with Observation \ref{obs:rank-roots} in hand, we sketch the proof of Theorem \ref{thm:gen-hadamard}. \\ \noindent\textit{Proof Sketch of Theorem \ref{thm:gen-hadamard}.} The proof proceeds in two steps: \begin{enumerate} \item Rescale the rows and columns of $H_{d,n}$ to obtain a matrix $H_{d,n}'$ such that there exists a symmetric function $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$ with $M_f=H_{d,n}'$. The rows and columns of $H_{d,n}$ are uniformly rescaled in such a way that $ {WR}_{H_{d,n}}(r)= {WR}_{M_f}(r)$ for any $r$. \item For any $\epsilon\in (0,0.1)$ and any symmetric function $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$, by changing $f$ on at most $d^{n\epsilon}$ many values, obtain a symmetric function $f':\mathbb{Z}_d^n\rightarrow \mathbb{C}$ such that the matrix $M_{f'}$ has ${rank}(M_{f'}) \leq d^{n(1-\epsilon')}$ where $\epsilon' = \frac{\epsilon4}{d^2\log d}$. The upper bound on ${rank}(M_{f'})$ follows from Observation \ref{obs:rank-roots} as the polynomial $P_{f'}$ has {\em many} roots in $\{(\omega^{i_1},\ldots,\omega^{i_n})\mid (i_1,\ldots,i_n)\in \mathbb{Z}_n^d \}$. \end{enumerate} \noindent {\em Proof of Step 1:} Let $H_{d,n}$ be the $d^n\times d^n$ generalized Hadamard matrix. Let $\mu\in \mathbb{C}$ be such that $\mu^2 = \omega$. For every $I,J \in \mathbb{Z}_d^n$, the $d^n\times d^n$ matrix $H_{d,n}'$ is obtained by multiplying every element of the $I^{th}$ row by $\mu^{I\cdot I}$ and every element of the $J^{th}$ column by $\mu^{J\cdot J}$. Now, we define $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$ as: $f(I)=\mu^{i_1^2+i_2^2 +\cdots + i_n^2}$ for any $I=(i_1,i_2,\ldots,i_n)\in \mathbb{Z}_d^n$. Observe that $f$ is a symmetric function and for any $I,J \in \mathbb{Z}_d^n$ the matrix $M_f [I,J] = f(I+J) = \mu^{(i_1+j_1)^2+(i_2+j_2)^2 +\cdots + (i_n+j_n)^2} = H_{d,n}'[I,J]$. Note that the function $f$ is well-defined and ${ WR}_{H_{d,n}}(r)= { WR}_{M_f}(r)$ for any $r$. \\ Now, in the following step we will have to modify the function $f$ so that the polynomial $P_f$ satisfies the hypothesis of Observation \ref{obs:rank-roots}. \noindent {\em Proof of Step 2:} Given any symmetric function $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$ by changing $f$ on a {\em ``small"} set $T$ of values in $\mathbb{Z}_d^n$, we want to construct a symmetric function $f':\mathbb{Z}_d^n\rightarrow \mathbb{C}$ such that the polynomial $P_{f'}$ vanishes on a {\em ``large"} set $S$ in $\{(\omega^{i_1},\ldots,\omega^{i_n})\mid (i_1,\ldots,i_n)\in \mathbb{Z}_d^n \}$. The sets $S$ and $T$ are defined as follows: \begin{enumerate} \item Let $m = \frac{n(1-\epsilon^2)}{d}$ and $S$ be the set of tuples $ (i_1, i_2,\ldots, i_n) \in \mathbb{Z}_d^n$ such that $i_1= i_2 =\cdots = i_m =0$; $i_{m+1} = i_{m+2} = \cdots = i_{2m} = 1$ and so on till $i_{(d-1)m+1}= i_{(d-1)m+2} = \cdots = i_{dm} = m$. \item Let $T\subseteq \mathbb{Z}_d^n$ be the set of tuples with at least $n(1-\epsilon^2)$ many zeros. \end{enumerate} Having defined sets $S$ and $T$, the following lemma(which we will prove later) ensures that we can use Observation \ref{obs:rank-roots} to complete the proof of Theorem \ref{thm:gen-hadamard}. \begin{lemma} \label{lem:symmetric} Let $f:\mathbb{Z}_n^d\rightarrow \mathbb{C}$ be any symmetric function. By changing $f$ on values in $T$, we can construct a symmetric function $f':\mathbb{Z}_n^d\rightarrow \mathbb{C}$ such that $P_{f'}(\omega^I) = 0$ for every $I\in S$. \end{lemma} Now, assuming Lemma \ref{lem:symmetric}, let us complete the proof of Theorem \ref{thm:gen-hadamard}. Note that $M_f = (M_f- M_{f'}) + M_{f'}$ and we bound ${rank}(M_{f'})$ and ${sparsity}(M_f- M_{f'})$. By Lemma \ref{lem:symmetric} $P_{f'}$ vanishes on the set $\{ \omega^I \mid I\in S\}$. Hence $P_{f'}$ has $|S| = d^{n-dm} = d^{n\epsilon^2}$ many roots in $\{(\omega^{i_1},\ldots,\omega^{i_n})\mid (i_1,\ldots,i_n)\in \mathbb{Z}_d^n \}$ as $m=n(1-\epsilon^2)/d$. However, as $f'$ is a symmetric function, the polynomial $P_{f'}$ not only vanishes on $\{\omega^I \mid I\in S\}$ but also on $\omega^J$ for all tuples $J$ in $\mathbb{Z}_d^n$ that are obtained by permuting the entries of $I = (i_1,\ldots,i_n)$. That is, $P_{f'}(\omega^J)=0$ for all $J$ in ${perm}(S)=\{ {perm}(I) \mid I\in S\}$ where ${perm}(I)$ denotes the set of distinct permutations are obtained by permuting the entries of $I = (i_1,\ldots,i_n)$. Thus, by Observation \ref{obs:rank-roots}, ${rank}(M_{f'})$ is exactly the number of tuples in $\mathbb{Z}_d^n$ that are not in ${perm}(S)$ and estimating ${rank}(M_{f'})$ amounts to estimating the size of $\mathbb{Z}_d^n \setminus {perm}(S)$. A tuple $I\in \mathbb{Z}_d^n$ is in ${perm}(S)$ iff every $a\in \{0,1,\ldots,d-1\}$ appears at least $m$ times. Then, ${rank}(M_{f'})$ is given by the number of tuples in $\mathbb{Z}_d^n$ such that there exists an $a\in \{0,1,\ldots,d-1\}$, $a$ appears less than $m$ times. Let $\tau\in_{r} \mathbb{Z}_d^n, i\in \{0,\ldots,d-1\}$ and $X_i$ be a random variable that denotes the number of times $i$ appears in the tuple $\tau$. Then, $\Pr\left[X_i < \frac{(1-\epsilon^2)n}{d}\right] \leq e^{-\frac{2\epsilon^4 n}{d^2}}$ and $\Pr[\tau \not \in {perm}(S)] \leq d\cdot e^{-\frac{2\epsilon^4 n}{d^2}}$. The expected size of $\mathbb{Z}_d^n \setminus {perm}(S)$ is at most $d^n\cdot d\cdot e^{-\frac{2\epsilon^4 n}{d^2}}$. Thus, when $n> \frac{d^2(\log d)^2}{\epsilon^4}$, the size of $\mathbb{Z}_d^n \setminus {perm}(S)$ is $d^{n(1-\epsilon')}$ for $\epsilon' = \frac{\epsilon^4}{d^2\log d}$. This immediately implies that ${rank}(M_{f'})\leq d^{n(1-\epsilon')}$ for $\epsilon' = \frac{\epsilon^4}{d^2\log d}$. To upper bound ${sparsity}(M_f- M_{f'})$, it is enough to estimate $|T|$ which is the number of tuples in $\mathbb{Z}_d^n$ with at least $n(1-\epsilon^2)$ many zeros. Let $\tau\in_{r} \mathbb{Z}_d^n$ and $X$ be a random variable that denotes the number of zeros in $\tau$. Then, $\Pr[ \tau \in T ] = \Pr [X \geq n(1-\epsilon^2)] \leq e^{-D((1-\epsilon^2)||1/d)} \leq d^{-n(1-\epsilon)}$ when $\epsilon\in (0,0.1)$. The expected size of set $T$ is at most $d^n\cdot d^{-n(1-\epsilon)}$. This implies that ${sparsity}(M_f- M_{f'}) \leq d^{n\epsilon}$. Thus, by changing $M_f$ on $|T|\leq d^{n\epsilon}$ values in every row, the rank of $M_f$ becomes $d^{n(1-\epsilon')}$ implying that ${ WR}_{H_{d,n}}\left(d^{n\left(1-\epsilon '\right)}\right)\leq d^{n\epsilon}$. $\hfill\square$ \paragraph{} We now turn to the proof of Lemma $\ref{lem:symmetric}$. Let $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$ be any symmetric function and $T\subseteq \mathbb{Z}_d^n$ be the set of tuples with at least $n(1-\epsilon^2)$ many zeros. As we want to change $f$ only on tuples in $T$, for all $J\not\in T$, $f'(J)=f(J)$. Also, as we want $f':\mathbb{Z}_d^n\rightarrow \mathbb{C}$ to be symmetric, we require that for every $j\in [k]$, for any $J,J'\in {perm}(J_j)$, $f'(J)=f'(J')$. Since we do not know what values to change $f$ to on tuples in set $T$, the most natural approach would be to come up with a system of equations with these as the unknown variables and $P_{f'}(\omega^{I}) = 0$ for every $I\in S$ as the constraints and show that this system has a solution. \begin{align*} P_{f'}(\omega^{I}) &= 0 \text{~~for all $I\in S$} \\ \sum\limits_{J\in T} f'(J)\omega^{I\cdot J} + \sum\limits_{J'\not \in T} f(J')\omega^{I\cdot J'} &= 0 \text{~~for all $I\in S$} \end{align*} Note that we require the new function $f'$ to be symmetric. Also, let us consider the equivalence classes obtained by permuting the tuples $S$ and $T$ and denote by ${rep}(S)=\{I_1,\ldots,I_{\ell}\}$ and ${rep}(T)=\{ J_1,\ldots,J_k\}$ the set obtained by picking one representation from each equivalence class of $S$ and $T$ respectively. Now, we define a system of linear equations with $\{f'(J_j) \mid j\in [k] \}$ as the unknowns labelled as $a_1,\ldots,a_k$: \begin{align*} \sum\limits_{j=1}^{k} a_j \sum\limits_{J\in {perm}(J_j)} \omega^{I\cdot J} + \sum\limits_{J'\not \in T} f(J')\omega^{I\cdot J'} &= 0 \text{~~for all $I\in S$} \end{align*} Since $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$ is a symmetric function, it suffices to consider the following set of linear equations: \begin{align*} \sum\limits_{j=1}^{k} a_j \sum\limits_{J\in {perm}(J_j)} \omega^{I_i\cdot J} + \sum\limits_{J'\not \in T} f(J')\omega^{I_i\cdot J'} &= 0 \text{~~for all $I_i\in {rep}(S)$} \end{align*} That is, \begin{align*} \sum\limits_{j=1}^{k} a_j \sum\limits_{J\in {perm}(J_j)} \omega^{I_i\cdot J} &=- \sum\limits_{J'\not \in T} f(J')\omega^{I_i\cdot J'} \text{~~for all $I_i\in {rep}(S)$} \end{align*} Let $M$ be the $\ell\times k$ coefficient matrix given by $M_{ij}=\sum\limits_{J\in {perm}(J_j)} \omega^{I_i\cdot J}$. In order to show that the above non-homogeneous system of linear equations has a solution, it is enough to show that the column space of $M$ has full rank. That is, for each $i=1,\ldots,\ell$, we require constants $a_1,\ldots ,a_k$ such that: \begin{align} \sum\limits_{j=1}^{k} a_j M_{ij} &\neq 0 \label{eq:eq5} \\ \sum\limits_{j=1}^{k} a_j M_{i'j} &= 0 \text{~~for $i'\neq i$} \label{eq:eq6} \end{align} Fix $i'=i_0$ in Equations (\ref{eq:eq5}) and (\ref{eq:eq6}). We need $a_1,\ldots ,a_k$ such that \begin{align} \sum\limits_{j=1}^{k} a_j \sum\limits_{J\in {perm}(J_j)} \omega^{I_{i_0}\cdot J} &\neq 0 \label{eq:eq3} \\ \sum\limits_{j=1}^{k} a_j \sum\limits_{J\in {perm}(J_j)} \omega^{I_i\cdot J} &= 0 \text{~~for $i\neq i_0$} \label{eq:eq4} \end{align} Clearly, from equations (\ref{eq:eq3}) and (\ref{eq:eq4}) this is equivalent to constructing an $n$-variate polynomial $P(x_1,\ldots,x_n) = \sum\limits_{j=1}^{k} a_j \sum\limits_{J\in {perm}(J_j)} x^J$ that vanishes on $\omega^{I_i}$ for any $i\in [\ell], i\neq i_0$ but does not vanish on $\omega^{I_{i_0}}$. However, for any tuple $I= (i_1,\ldots,i_n)$ in $S$, the first $dm$ entries are fixed and let $I'$ be the sub-tuple $(i_{dm+1},\ldots,i_n)$ of $I$ and $I'(j)$ denote the $j^{th}$ entry of tuple $I'$. Thus, we want an $(n-dm)$-variate polynomial $Q(x_{dm+1} \ldots,x_n) = P(1, \ldots 1, \ldots, \omega^{d-1},\ldots,\omega^{d-1}, x_{dm+1} \ldots,x_n)$ that vanishes on $\omega^{I_i'}$ if and only if $i\neq i_0$ \footnote{Note that for every $i_0$, we get a polynomial $Q_{i_0}$ that is dependent on the tuple $I_{i_0}$. For ease of notation, we refer to the polynomial as $Q$ dropping the subscript $i_0$}. Let $Q(x_{dm+1} \ldots,x_n) = \sum\limits_{I'\in {perm}(I_{i_0}')}\left( \frac{x_{dm+1}^d-1}{x_{dm+1}-\omega^{I'(0)}} \right)\cdots \left(\frac{x_{n}^d-1}{x_n-\omega^{I'(n-dm)}} \right)$. The proof of Theorem \ref{thm:gen-hadamard} is complete with the following claim: \begin{claim} \label{claim:hadamard-claim1} Let $Q(x_{dm+1} \ldots,x_n)$ be the polynomial defined above. Then, \begin{itemize} \item[(i)] $Q(x_{dm+1} \ldots,x_n)$ vanishes on $\omega^{I_i'}$ if and only if $i\neq i_0$. \item[(ii)] $Q(x_{dm+1} \ldots,x_n) = P(1, \ldots 1, \ldots, \omega^{d-1},\ldots,\omega^{d-1}, x_{dm+1} \ldots,x_n)$. \end{itemize} \end{claim} We do not include a proof of Claim \ref{claim:hadamard-claim1} here but it is not hard to prove the above properties of the polynomial $Q$. The above discussion proves that for any symmetric function $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$, for every $\epsilon\in (0,0.1)$ and sufficiently large $n$, ${WR}_{M_f}(d^{n(1-\epsilon')})\leq d^{n\epsilon}$ for some $\epsilon'>0$ ($\epsilon'$ is a function of $d$ and $\epsilon$). We now extend this rigidity upper bound to matrices $M_f$ corresponding to functions that are not symmetric: \begin{theorem} \label{thm:non-symmetric} Let $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$ be any function. For any $\epsilon\in (0,0.1)$ and $n \geq \frac{d^2 (\log d)^2}{\epsilon^4}$, there exists an $\epsilon'= \frac{\epsilon^4}{d^2\log d}$ such that ${WR}_{M_f}(2d^{n(1-\epsilon')})\leq d^{2n\epsilon}$. \end{theorem} The proof of Theorem \ref{thm:non-symmetric} is immediate from Theorem \ref{thm:gen-hadamard}, the following property of Hadamard matrices (mentioned in Lemma \ref{lem:hadamard-prop} proof of which is straightforward from the definition of matrices $H_{d,n}, M_f$ and polynomial $P_f$) and a simple tool that reduces the task of proving non-rigidity of a matrix $B$ to proving non-rigidity of the matrix $A$ that diagonalizes it (mentioned in Lemma \ref{lem:diag}). \begin{lemma} \label{lem:hadamard-prop} Let $f:\mathbb{Z}_d^n\rightarrow \mathbb{C}$ be any function. Then $D=H_{d,n}\cdot M_f\cdot H_{d,n}$ is a $d^n\times d^n$ diagonal matrix with $D[I,I]=d^n\cdot P_f(\omega^{I})$ where $\omega$ is the $d^{th}$ root of unity. \end{lemma} \begin{lemma} \label{lem:diag} Let $B=A^{*}DA$ (respectively $B=ADA$) where $A^{*}$ is the conjugate transpose of $A$ and $D$ is a diagonal matrix. If ${WR}_A(r)\leq s$ then ${WR}_B(2r)\leq s^2$. \end{lemma} \begin{proof} If ${WR}_{A}(r)\leq s$ then $A=S+L$ where ${rank}(L)\leq r$ and $S$ has at most $s$ non-zero entries in every row and column. Then, \begin{align*} B-S^{*}DS &= B-S^{*}DS+A^{*}DS -A^{*}DS \\ &= A^{*}DA -S^{*}DS+A^{*}DS -A^{*}DS & [\because B=A^{*}DA] \\ &= A^{*}D(A-S) + (A^{*}-S^{*})DS \\ B &= S^{*}DS + A^{*}D(A-S) + (A^{*}-S^{*})DS \end{align*} where the matrix $S^{*}DS$ has at most $s^2$ non-zero entries in each row and column as $S$ has at most $s$ non-zero entries in every row and column. Further, ${rank} ( A^{*}D(A-S) + (A^{*}-S^{*})DS)\leq 2r$ as ${rank}(A-S)\leq r$. Therefore, ${WR}_B(2r)\leq s^2$. \end{proof} The proof of Theorem \ref{thm:non-symmetric} is immediate though we sketch it here for the sake of completeness. \noindent{\em Proof of Theorem \ref{thm:non-symmetric}.} By Lemma \ref{lem:hadamard-prop}, $M_f=H_{d,n}^{-1}\cdot D\cdot H_{d,n}^{-1}$. From Theorem \ref{thm:gen-hadamard}, we have $WR_{H_{d,n}}(d^{n(1-\epsilon')}) \leq d^{n\epsilon}$ for any $\epsilon\in (0,0.1)$ and some $\epsilon'$. This immediately implies that $WR_{M_f}(2d^{n(1-\epsilon')}) \leq d^{2n\epsilon}$ from Lemma \ref{lem:diag}. \paragraph*{A brief note on non-rigidity of Fourier and Circulant matrices.}Although understanding the rigidity of generalized Hadamard matrices is of independent interest,Theorem \ref{thm:gen-hadamard} also acts as a building block in showing that {\em Fourier matrices} are also not rigid which is the main theorem of \cite{DL19}. As {\em Fourier matrix} $F_d$ is the $d\times d$ matrix $H_{d,1}$, the generalized Hadamard matrix $H_{d,n}= \underbrace{F_d \otimes F_d \cdots \otimes F_d}_{\text{$n$ times}}$. Even though we don not include the proof of non-rigidity of Fourier matrices which is quite involved, among other basic blocks it uses Theorem \ref{thm:gen-hadamard} as well as the following interesting lemma which analyses the weak rigidity of tensor product of two matrices: \begin{lemma} \label{lem:tensor-product} Let $A\in\mathbb{F}^{m\times m}$ and $B\in \mathbb{F}^{n\times n}$. Then for any $r_1\leq m$ and $r_2\leq n$, $WR_{M}(r_1 n+r_2 m)\leq WR_{A}(r_1)\cdot WR_{B}(r_2)$ where $M=A\otimes B$. \end{lemma} \begin{proof} Suppose $WR_{A}(r_1)\leq s_1$ and $WR_{A}(r_2)\leq s_2$ then there exists $S_1,S_2$ of appropriate dimensions such that ${rank}(A+S_1)\leq s_1$ and ${rank}(B+S_2)\leq s_2$. Now, we want to argue about the rank of $M + (S_1\otimes S_2)$: \begin{align*} M+ (S_1\otimes S_2) &= (A\otimes B) + (S_1\otimes S_2) \\ & = (A\otimes B) + (S_1\otimes B) - (S_1\otimes B ) + (S_1\otimes S_2)\\ &= (A+ S_1)\otimes B - S_1\otimes(B+S_2) \end{align*} Thus, ${rank}(M+(S_1\otimes S_2))=r_1n+r_2m$ and sparsity of $S_1\otimes S_2$ is $s_1s_2$. \end{proof} In \cite{DL19}, the authors also prove that {\em circulant matrices} are not rigid. Let $c_0,\ldots,c_{n-1}\in \mathbb{F}$. A matrix $C_n\in \mathbb{F}^{n\times n}$ is said to be {\em circulant} if \begin{center} $C_n= \begin{bmatrix} c_0 & c_{n-1} & \cdots & c_2 & c_1 \\ c_1 & c_0 & c_{n-1} & \cdots & c_2 \\ \vdots & \vdots & \vdots & \vdots & \vdots \\ c_{n-1} & c_{n-2} & \cdots & c_1 & c_0 \\ \end{bmatrix}$ \end{center} Observe that circulant matrix is a special case of Toeplitz matrix. Dvir and Liu\cite{DL19} prove that for sufficiently large $n$, $C_n$ is not rigid. Hence, although rigidity lower bound of Toeplitz matrix in Theorem \ref{thm:toeplitz} is reasonable for much smaller $n$(as noted in Remark \ref{rem:toeplitz}) it is impossible to match the lower bound in Question \ref{que:rigidity-Valiant}. \begin{remark} In \cite{DL19} the matrix $M_f$ is given by $M_f [I,J] = f(I+J)$ for $I,J\in \mathbb{Z}_n^d$. However the argument also works for $M_f [I,J] = f(I-J)$ for $I,J\in \mathbb{Z}_n^d$ as the two definitions differ only upto permutation of rows/columns giving the same rigidity bounds. Further, Theorem $\ref{thm:non-symmetric}$ extends the results of \cite{DE17} to the field of complex numbers and the result of \cite{AW17} to arbitrary $d$ while the result in \cite{AW17} is for $d=2$. \end{remark} \subsection{Rigidity of generator matrices of asymptotically good codes} Asymptotically good codes are family of codes whose rate and relative distance are both constant in the asymptotic sense. \begin{definition} \label{def:alg-codes} A family of codes ${\cal C} = \{C_i\}_{i\geq 1}, C_i = [n_i,k_i,d_i]_{q}$ is said to be {\em asymptotically good} if there exists constants $R_0,\delta_0>0$ such that $\lim\limits_{n\rightarrow \infty} \frac{k_i}{n_i}\geq R_0$ and $\lim\limits_{n\rightarrow \infty} \frac{d_i}{n_i}\geq \delta_0$. \end{definition} Using algebraic geometric codes\cite{TLP98}, we can prove the existence of asymptotically good error correcting codes. We state the lemma about the existence of asymptotically good error correcting codes without giving a proof. For a proof see Theorem 2.81 in \cite{TLP98}. \begin{lemma} \label{lem:asym-good-code} Let $\mathbb{F}_q$ be a finite field. For infinitely many $n$, there exists $[2n,n,d]_{q}$ code with rate $1/2$ and relative distance at least $1-\frac{2}{\sqrt{q}-1}$. \end{lemma} For the above code let $G$ denote the generator matrix and the generator matrix can be brought to the standard form $G_C=[ I_n \mid A]$ where $I_n$ is the $n\times n$ identity matrix and $A$ is a $n\times n$ matrix. In the following theorem, we prove that the matrix $A$ has high rigidity over $\mathbb{F}_q$: \begin{theorem} Let $A\in\mathbb{F}_q^{n\times n}$ be a the matrix obtained from the standard form of the generator matrix of the $[2n,n,(1-\epsilon)n]$ code for $\epsilon = \frac{2}{\sqrt{q}-1}$ as in Lemma \ref{lem:asym-good-code}. Then $R_A(r) = \Omega(\frac{n^2}{r}\log\frac{n}{r})$ for $\epsilon n \leq r \leq n/2$. \end{theorem} \begin{proof} Let $\epsilon n \leq r \leq n/2$ and $A'$ be a $2(r+1)\times 2(r+1)$ submatrix of $A$. We claim that ${rank}(A') \geq r+1$. Suppose not, ${rank}(A') < r+1$. Then, there exists a codeword of weight $n-(r+1) < n-\epsilon n$. Hence, minimum distance of the code is at most $n(1-\epsilon)$, a contradiction. This implies that every $2(r+1)\times 2(r+1)$ sub-matrix of $A$ has rank at least $r+1$. Now, by following an argument similar to the untouched minor argument, we get the required lower bound. \end{proof} \begin{remark} \label{rem:dvir} Although matrices of high rigidity can be obtained from generator matrices of asymptotically good linear codes, \cite{Dvir16} obtained a distribution ${\cal D}$ of matrices such that for $G \sim D$, $G$ generates a good linear code but with high probability $R_G(r) \leq O(n^2/r)$ for any $r \leq O(r \log(\frac{n}{r}))$. \end{remark} Next, we review a result of Dvir\cite{Dvir16} which states that if the generating matrix $G_C$ of any locally decodable code $C$ is not row rigid then there exists a locally self-correctable code $C'$ with rate of $C'$ is $\approx$ 1. \subsection{Locally self-correctable codes and rigid matrices} The focus of this subsection is to review the connections between {\em locally decodable codes} or {\em locally self-correctable codes} and matrix rigidity which is the main result of \cite{Dvir11}. Informally a {\em locally decodable code}(LDC) is an error-correcting code that enables probabilistically decoding a particular symbol of the message by querying a {\em small} number of locations of the corresponding codeword even when the codeword is corrupted in a {\em few} locations while a {\em locally self correctable code}(LCC) is an error-correcting code that enables probabilistically decoding bits of the codeword rather than the message which can be viewed as self-correcting the corrupted codeword. For any vector $v$, we denote by $w(v)$ the Hamming weight of the vector $v$. We give the formal definitions below: \begin{definition} [Locally decodable code.] A $(q,\delta,\epsilon)$-LDC $C$ is a linear map $C:\mathbb{F}_p^n\rightarrow \mathbb{F}_p^m$ such that there is a randomized decoding algorithm $D:\mathbb{F}_p^m\times [n]\rightarrow \mathbb{F}_p$ that on input $(c+u,i)$ queries at most $q$ locations in $c+u$ and recovers with probability at least $1-\epsilon$, the $i^{th}$ bit of message $x$ from $c+u$ where $c =C(x)$ and $w(u)\leq \delta\cdot n$ (i.e., codeword $c$ is corrupted in at most $\delta\cdot n$ locations). \end{definition} \begin{definition}[Locally self-correctable code.] A $(q,\delta,\epsilon)$-LCC is a linear map $C':\mathbb{F}_p^n\rightarrow \mathbb{F}_p^m$ such that there is a randomized (self-correcting) algorithm $D':\mathbb{F}_p^m\times [n]\rightarrow \mathbb{F}_p$ that on input $(c+u,i)$ queries at most $q$ locations in $c+u$ and recovers with probability at least $1-\epsilon$, the $i^{th}$ bit of codeword $c$ from $c+u$ where $u\in \mathbb{F}_p^n$ with $w(u)\leq \delta\cdot n$ (i.e., codeword $c$ is corrupted in at most $\delta\cdot n$ locations). \end{definition} We say an error-correcting code $C$ is {\em explicit} if every entry of the generator matrix can be obtained in deterministic polynomial time. It is interesting to note the following explicit constructions of locally decodable code from \cite{Dvir11} which will be useful for our purpose. We do not prove this construction here(for proof, see Corollary 3.3 in \cite{Dvir11}) \begin{theorem} \label{thm:ldc-existance} For any $\epsilon,a>0$, there exists an explicit family of codes $C_n:\mathbb{F}_p^n\rightarrow \mathbb{F}_p^m$ such that $C_n$ is a $(n^a,\delta,\epsilon)$-LDC with $m=O(n)$ and $\delta=\delta(\epsilon)>0$. \end{theorem} We now state the main theorem of \cite{Dvir11} showing that if the generating matrix $G_C$ of any locally decodable code $C$ is not row rigid then there exists a locally self-correctable code $C'$ with dimension close to $n$. We first give a sketch of the proof and then move on to the details. \begin{theorem} \label{thm:rigidity-selfcorrectable-codes} Let $C:\mathbb{F}_p^n\rightarrow \mathbb{F}_p^m$ be a $(q,\delta,\epsilon)$ locally decodable code whose generator matrix $G_C$ has $RR_{G_C}(r)\leq s$. Then for any $\rho >0$, there exists a $(q',\delta',\epsilon)$-LCC $C'$ (a subspace of $\mathbb{F}_p^n$) with $q'=qs, \delta' = (\rho\delta)/s$ and dimension of $C'$ being $n(1-\rho)-r$. \end{theorem} \noindent\textit{Proof Sketch.} Suppose $G_C$ has row rigidity at most $s$ for rank $r$ then $G_C=S+L$ where ${rank}(L)$ is {\em low} and every row of $S$ has at most $s$ non-zero entries. Since ${rank}(L)$ is {\em low} to construct an LCC $C'$ of sufficiently large dimension a natural candidate for $C'$ is the ${\sf nullspace}(L)$. When $C'={\sf nullspace}(L)$, dimension of $C$ is $n-{rank}(L)$ which is {\em large}(as ${rank}(L)$ is low). We need to ensure that $C'$ is $(q',\delta',\epsilon)$ locally self-correctable. That is, to decode the $i^{th}$ symbol of the codeword $c$ which is corrupted in at most $\delta'$ locations we need a decoding algorithm $D'$ that on input $D(c+v)$ ($w(v)\leq \delta'\cdot n$) outputs $c_i$ with probability $1-\epsilon$. Observe that for every $c\in C'$, $$C(c)=G_C\cdot c = S\cdot c + L\cdot c = S\cdot c$$ as $L\cdot c =0$ for $C'={\sf nullspace}(L)$. Now, it is sufficient to invoke the local decoding algorithm for the LDC $C$ with $(C(c)+v',i)$ as input where $v'\triangleq S\cdot v$. Here, weight of $v'$ is {\em small} as matrix $S$ is $s$-row-sparse. the algorithm $D$ that locally decodes the LDC $C$ returns $c_i$ with probability $1-\epsilon$ by querying a small number of locations as $C(c)+v' = S(c+v)$.(For technical reasons we cannot quite work with the matrix $S$ but we will construct a slightly modified matrix $S'$ from $S$ obtained in Observation \ref{obs:col-sparse}.) $\hfill\square$ We now explain all the details mentioned in the above proof idea. We will need the following simple observation that for any row sparse matrix, the columns can also be made fairly sparse without increasing the rank by much. The proof appeals to the intuition that if too many columns of an $s$ row-sparse matrix are {\em dense} then we can find a row that is not $s$-sparse. \begin{obs} \label{obs:col-sparse} Let $\rho>0$ and $A\in\mathbb{F}^{m\times n}$ be any matrix with $RR_A(r)\leq s$ (i.e., $A=S+L$ where ${rank}(L)\leq r$ and $S$ is $s$-row-sparse). Then, $A=S'+L'$ where ${rank}(L')\leq r+\rho\cdot n$ and every column of $S'$ has at most $(s\cdot m)/ (\rho\cdot n)$ non-zero entries. \end{obs} \noindent\textit{Proof of Observation \ref{obs:col-sparse}.} The number of non-zero entries in $A$ is at most $s\cdot n$. For any $\rho>0$, the number of columns with at least $(s\cdot m)/(\rho\cdot n)$ non-zero entries is at most $\rho\cdot n$. Let $C_{i_1},C_{i_2},\ldots,C_{i_j}, j\in [\rho\cdot n]$ be the columns in $S$ with at least $(s\cdot m)/(\rho\cdot n)$ non-zero entries. Let $S'$ be the matrix obtained by replacing columns $C_{i_1},C_{i_2},\ldots,C_{i_j}$ in $S$ with all zeros vectors. Let $L'$ be the matrix obtained by adding to the $i_j^{th}$ column of $L$ the column vector $C_{i_j}$ for all $j\in [\rho\cdot n]$. Then $A=L'+S'$ where ${rank}(L')\leq r+\rho\cdot n$ and every row of $S'$ has at most $s$ non-zero entries and every column of $S'$ has at most $(s\cdot m)/(\rho\cdot n)$ non-zero entries. $\hfill\square$ Now, we complete proof of theorem \ref{thm:rigidity-selfcorrectable-codes}. \begin{proof} Let $C:\mathbb{F}_p^n\rightarrow \mathbb{F}_p^m$ be a $(q,\delta,\epsilon)$-LDC and $G_C\in \mathbb{F}^{m\times n}$ be its generator matrix. Suppose $G_C$ has row rigidity at most $s$ for rank $r$ then by Observation \ref{obs:col-sparse}, $G_C=S'+L'$ where $ {rank}(L')\leq r+\rho\cdot n$ and every row of $S'$ has at most $s$ non-zero entries and every column of $S'$ has at most $(s\cdot m)/(\rho\cdot n)$ non-zero entries. Let $C'\triangleq {\sf nullspace(L')}$. Then dimension of $C'$ as a subspace of $\mathbb{F}_p^n$ is $n-{rank}(L') \geq n-(r+\rho\cdot n) = n(1-\rho)-r$. It remains to show that $C'$ is a $(q',\delta',\epsilon)$-LCC where $q'=qs$ and $\delta'=\rho\delta/s$. In particular, we need a randomized algorithm $D':\mathbb{F}_p^n \times [n]\rightarrow \mathbb{F}_p$ that decodes (with probability at least $1-\epsilon$) a particular symbol of a codeword $c\in \mathbb{F}_p^n$ that is corrupted in at most $\delta'\cdot n$ locations by querying at most $q'$ locations of the corrupted codeword. Since $C$ is a $(q,\delta,\epsilon)$-LDC, we have at our disposal a randomized algorithm $D:\mathbb{F}_p^m \times [n]\rightarrow \mathbb{F}_p$ that decodes (with probability at least $1-\epsilon$) a particular symbol of a message $x\in\mathbb{F}_p^n$ by querying at most $q$ locations in the corresponding codeword $C(x)$ which is corrupted in at most $\delta\cdot m$ locations. The main idea is to make $D'$ run $D$ on appropriate inputs. Note that $D$ can correct message symbols only when the codeword is corrupted in at most $\delta m$ locations. The input to $D'$ is $(c+v,i)$ where $i\in [n], c\in \mathbb{F}_p^n$ and $v\in \mathbb{F}_p^n$ with $w(v)\leq \delta'\cdot n$. \\ The idea is to encode $c\in \mathbb{F}_p^n$ using the LDC $C$ and then use decoding algorithm $D$ on $C(c)$ to correct the $i^{th}$ bit of codeword $c_i$. Let $v'=S'\cdot v$ be a vector in $\mathbb{F}_p^m$. Observe the following: \begin{itemize} \item The weight of vector $v'$ is at most $\delta\cdot m$ as $w(v)\leq \delta'\cdot n$ and every column of $S'$ has at most $(s\cdot m)/ (\rho\cdot n)$ non-zero entries. \item $D(C(c)+v',i)$ outputs $c_i$ (the $i^{th}$ bit of $c\in \mathbb{F}_p^n$) with probability $1-\epsilon$ by making at most $q$ queries to $C(c)+v'$. \item For every $c\in C'$, $C(c)+v'= S'\cdot m + v' = S'\cdot (c+v)$. As $S'$ has at most $s $non-zero entries in every row, $D'$ makes at most $qs$ queries overall before returning $c_i$. \end{itemize} Thus, $C'$ is a $(q',\delta',\epsilon)$-LCC where $q'=qs$ and $\delta'=\rho\delta/s$. \end{proof} \section{Introduction} \input{intro} \section{Past Progress on Matrix Rigidity} \label{sec:past-progress} \input{prelims} \section{Explicit constructions of Rigid Matrices} \label{sec:lower-bounds} In this section, we review semi-explicit constructions of rigid matrices starting with constructions in class $\E^\NP$ proceeding towards constructions in $\P^{\NP}$. We use the term {\em semi-explicit} to broadly refer to matrices that require worse than polynomial time to construct them. \subsection{Rigidity of Random Toeplitz matrices} \input{goldreich-tal} \subsection{Construction of rigid matrices in sub-exponential time} \input{kumar-volk} \subsection{Construction of rigid matrices based on probabilistically checkable proofs} \input{rigid-pcp} \input{elimination-rigid} \section{Upper Bounds on Matrix Rigidity} \label{sec:upper-bounds} In this section, we survey some of the recent developments on mathematical techniques involved in proving the non-rigidity of some of the matrix families that were previously conjectured to be rigid. \input{walsh-hadamard} \input{function-matrix} \input{generalized-hadamard} \section{Matrix rigidity via static data structure lower bounds} \label{sec:data-structures} \input{data-structure-lb} \section{Matrix rigidity and error-correcting codes} \label{sec:codes} \input{rigidity-codes} \section{Discussion and Open problems} \label{sec:discussion} \input{discussion} \paragraph*{Acknowledgements} I am grateful to Ramprasad Saptharishi for introducing to me the concept of matrix rigidity. I thank Ramprasad Saptharishi, Anamay Tengse and Prerona Chatterjee for numerous technical discussions on the various papers presented in this article. I thank Prahladh Harsha for providing several clarifications on the results in subsection \ref{subsec:pcp-constructions}. \bibliographystyle{plainurl} \subsection{Non-rigidity of Walsh-Hadamard matrices} The {\em Walsh-Hadamard matrix} $H_n$ is a $2^n\times 2^n$ matrix whose rows and columns are indexed by vectors in $\{0,1\}^n$ (in lexicographic order). The entries of $H_n$ are given by $H_n[x,y] = (-1)^{\inner{x}{y}}$ for any $x,y\in \{0,1\}^n$ where $\inner{x}{y}$ denotes the inner product of vectors $x$ and $y$. Alman and Williams in \cite{AW17} prove the following upper bounds on the rigidity of {\em Walsh-Hadamard matrix}: \begin{theorem} \label{thm:walsh-hadamard} Let $\mathbb{F}$ be any field. For every $\epsilon\in (0,1/2)$, ${\cal R}_{H_n}(2^{n(1-f(\epsilon))}) \leq 2^{n(1+\epsilon)}$ where $f(\epsilon)=\Theta(\epsilon\log(1/\epsilon))$. \end{theorem} \noindent{\em Proof Sketch of Theorem \ref{thm:walsh-hadamard}.} The idea behind the proof is to approximate $H_n$ by a sparse polynomial(say $M'$) so that we can obtain a trivial upper bound on the rank of $M'$ and $H_n$ is close to $M'$ implying that rigidity of $H_n$ is low. In order to provide more clarity, we delineate the approach to prove Theorem \ref{thm:walsh-hadamard} which has two broad steps: \begin{enumerate} \item Approximate $H_n$ by the truth table matrix of a {\em sparse} polynomial. That is, construct a sparse polynomial $p:\{0,1\}^{2n}\rightarrow \mathbb{R}$ such that the $2^n\times 2^n$ matrix $M_p$ given by $M_p[x,y]\triangleq p(x+y)$ (for all $x,y\in \{0,1\}^n$) agrees with $H_n$ on {\em most} entries. If $p$ has sparsity $2^{n-\Omega(\epsilon^2 n)}$ then ${rank}(M_p) \leq 2^{n-\Omega(\epsilon^2 n)}$. Although this way $M_p$ has low rank, $H_n$ does not agree with $M_p$ on all entries. The construction of $p$ is only such that $H_n$ agrees with $M_p$ on those where $\inner{x}{y}\in [2\epsilon n, (1/2+\epsilon)n]$ for some $\epsilon\in (0,1/2)$. Thus, ${sparsity}(H_n-M_p)$ could be large (which we tackle in Step 2). \item Construct a matrix $M'$ from $M_p$ that agrees with $H_n$ on far more entries than that of $M_p$ but has rank comparable to that of $M_p$. Obtain $M'$ from $M_p$ such that $M'[x,y]=H_n[x,y]$ whenever: \begin{enumerate} \item[(i)] $M'[x,y]=M_p[x,y]$ (i.e., $\inner{x}{y}\in [2\epsilon n, (1/2+\epsilon)n]$); or \item[(ii)] one of $x$ or $y$ has a large fraction of $1$'s (i.e., when $|x|\not\in [(1/2-\epsilon)n,(1/2+\epsilon)n]$ or $|y|\not \in [(1/2-\epsilon)n,(1/2+\epsilon)n]$). \end{enumerate} Now, $M'$ disagrees with $H_n$ only on entries indexed by elements in \begin{align*} D=\{ (x,y)\in \{0,1\}^n\times \{0,1\}^n &\mid |x|\in [(1/2-\epsilon)n,(1/2+\epsilon)n], \\ & |y|\in [(1/2-\epsilon)n,(1/2+\epsilon)n], \\ & \inner{x}{y}\not\in [2\epsilon n, (1/2+\epsilon)n].\} \end{align*} \end{enumerate} To complete the proof of Theorem \ref{thm:walsh-hadamard}, we estimate the size of $D$. Observe that for any $(x,y)$ in $\{0,1\}^n\times \{0,1\}^n$ such that $|x|\in [(1/2-\epsilon)n,(1/2+\epsilon)n],|y|\in [(1/2-\epsilon)n,(1/2+\epsilon)n]$, the inner product $\inner{x}{y}$ has value at most $n(1/2+\epsilon)$. In order to estimate $|D|$, it suffices to count for a given $x\in \{0,1\}^n$ with $|x|\in [(1/2-\epsilon)n,(1/2+\epsilon)n]$, the number of vectors $y\in \{0,1\}^n$ with $|y|\in [(1/2-\epsilon)n,(1/2+\epsilon)n]$ and $\inner{x}{y}< 2\epsilon n$ which is given by $\sum\limits_{i=(1/2-\epsilon)n}^{(1/2+\epsilon)n}\sum\limits_{j=0}^{2\epsilon n} \binom{|x|}{i}\binom{n-|x|}{i-j} $. Using the fact that $\epsilon\in (0,1/2)$ and $(1/2-\epsilon)n \leq |x|,|y|\leq (1/2+\epsilon)n$, $|D|\leq 2^{O(n\epsilon\log(1/\epsilon))}$. $\hfill\square$ In the rest of this section we discuss in detail the steps outlined above. To discuss Step 1, consider the following lemma that uses multivariate polynomial interpolation over integers to construct a sparse polynomial agreeing with the matrix $H_n$ on many entries. \begin{lemma} \label{lem:poly-interpolate} Let $\mathbb{F}$ be a field and $\epsilon\in (0, 1/2)$. There exists a $2n$-variate multilinear polynomial $p(\bar{x},\bar{y})$ of sparsity at most $2^{n-\Omega(\epsilon^2 n)}$ such that for any $x,y\in \{0,1\}^n$ with $\inner{x}{y}\in [2\epsilon n, (1/2+\epsilon)n]$, $$p(\bar{x},\bar{y}) = H_n[\bar{x},\bar{y}] = (-1)^{\inner{\bar{x}}{\bar{y}}}.$$ \end{lemma} \begin{proof} First, we construct an $n$-variate polynomial $q(z_1,\ldots,z_n)$ with integer coefficients such that for any $\bar{a} \in \{0,1\}^n$ with $|\bar{a} | \in [2\epsilon n, (1/2+\epsilon)n]$, $q(\bar{a} )= (-1)^{|\bar{a} |}$. \begin{claim} \label{claim:hadamard-polynomial} Given integers $c_1,c_2,\ldots,c_r$, there exists an $n$-variate polynomial $q(z_1,\ldots,z_n)$ of degree $r-1$ that agrees with $c_1,\ldots,c_r$ on boolean inputs of hamming weight $k+1,\ldots,k+r$ for any $k\leq n-r$. That is, $q(\bar{a} )=c_i$ for any $\bar{a} \in \{0,1\}^n$ such that $|\bar{a} |=k+i$. \end{claim} \noindent\textit{Proof of Claim $\ref{claim:hadamard-polynomial}$.} Let us consider the most natural construction of such an $n$-variate polynomial $q:\{0,1\}^n \rightarrow \mathbb{Z}$ of degree $r-1$. Then, \begin{equation} q(z_1,\ldots,z_n)=\sum\limits_{i=1}^{r-1}b_i\sum\limits_{\substack{\alpha\in \{0,1\}^n \\ |\alpha|=i}}\prod\limits_{j=1}^n x_j^{\alpha_j}, \end{equation} where $b_0,\ldots,b_{r-1}$ are in $\mathbb{Z}$. Observe that for any $\bar{a} \in \{0,1\}^n$, $q(\bar{a})= \sum\limits_{i=1}^{r-1}b_i \binom{|\bar{a}|}{i}$. Whenever $|\bar{a}| = k+i$, we want $q(\bar{a})=c_i$. That is, for every $i\in [r-1]$, we need \begin{equation*} b_0\binom{k+i}{0} + b_1\binom{k+i}{1} +\cdots + b_{r-1}\binom{k+i}{r-1} = c_i \end{equation*} This gives us the following matrix equation: \begin{equation*} \begin{bmatrix} \binom{k+1}{0} & \binom{k+1}{1} & \cdots & \binom{k+1}{r-1} \\ \binom{k+2}{0} & \binom{k+2}{1} & \cdots & \binom{k+2}{r-1} \\ \vdots & \vdots & \vdots &\vdots \\ \binom{k+r}{0} & \binom{k+r}{1} & \cdots & \binom{k+r}{r-1} \end{bmatrix}\cdot \begin{bmatrix} b_0 \\ b_1 \\ \vdots \\ b_{r-1} \end{bmatrix} = \begin{bmatrix} c_1 \\ c_2 \\ \vdots \\ c_{r} \end{bmatrix} \end{equation*} It is not difficult to note that the $r\times r$ matrix in the above equation with binomial coefficients as entries is invertible. Hence there exists a vector $b=(b_0 b_1 \cdots b_{r-1})$ satisfying the above matrix equation which in turn completes the proof of Claim \ref{claim:hadamard-polynomial}. $\hfill\square$ Now, we proceed with the proof of Lemma \ref{lem:poly-interpolate}. Observe that by setting $r=(1/2-\epsilon)n+1, k=2\epsilon n -1$ and $c_i=(-1)^{k+i}$( $k+r = (1/2+\epsilon)n$) in Claim \ref{claim:hadamard-polynomial}, we get the polynomial $q(z_1,\ldots,z_n)$ over $\mathbb{Z}$ of degree $(1/2-\epsilon)n$ satisfying the required properties. (By taking coefficients of $q$ modulo an appropriate $m$, we can get a polynomial $q$ over a field $\mathbb{F}$ satisfying the required properties.) In the remaining part of the proof, we show how to use the above lemma to obtain the $2n$-variate polynomial $p(x_1,\ldots,x_n,y_1,\ldots,y_n)$ as required. A semi-natural candidate for $p(x_1,\ldots,x_n,y_1,\ldots,y_n) \triangleq q(x_1y_1,\ldots,x_n y_n) $. For any $x,y \in \{0,1\}^n$ such that $\inner{x}{y}\in [2\epsilon n , (1/2+\epsilon)n]$ we immediately have $p(\bar{x},\bar{y}) = q(\bar{z})$ where $|\bar{z}|=\inner{\bar{x}}{\bar{y}}$. Hence, by construction of $q$ in Claim \ref{claim:hadamard-polynomial}, $p(\bar{x},\bar{y}) = (-1)^{\inner{x}{y}}$. Since we are only interested in $x,y$ in $\{0,1\}^n$, we can make $p$ multilinear by setting $x_i^2=x_i,y_i^2=y_i$ for all $i\in [n]$. In $p$ the variables $x_i$ and $y_i$ are tied together whenever they occur. Thus, we can view $p(x_1,\ldots,x_n,y_1,\ldots,y_n)$ as a multilinear polynomial of degree $(1/2-\epsilon)n$ on $n$ variables $w_1,\ldots,w_n$ where each $w_i=x_iy_i$ and ${sparsity}(p) = \binom{n}{(1/2-\epsilon)n+1} \leq 2^{n-\Omega(\epsilon^2 n)}$. \end{proof} Now, we move on to Step 2 of the proof of Theorem \ref{thm:walsh-hadamard} outlined above. To obtain $M'$ from $M_p$, correct those rows in $M_p$ indexed by $\{x\in \{0,1\}^n \mid |x|\not\in [(1/2-\epsilon)n,(1/2+\epsilon)n]$ and those columns in $M_p$ indexed by $\{y\in \{0,1\}^n \mid |y|\not\in [(1/2-\epsilon)n,(1/2+\epsilon)n]$. Since we want ${rank}(M')$ to be comparable to ${rank}(M_p)$ the idea is to construct a matrix $M'$ such that $M' \triangleq M_p - (M_1 +\cdots +M_t)$ where ${rank}(M_i)=1$ for all $i\in [t]$ and $t=2^{n-\Omega(\epsilon^2 n)}$. For every row $r$ indexed by $x\in \{0,1\}^n$ with $|x|\not \in [(1/2-\epsilon)n,(1/2+\epsilon)n]$ let matrix $M_r\in\mathbb{F}^{2^n\times 2^n}$ be given by $M_r[x,y]=H_n[x,y]$ for all $y\in \{0,1\}^n$ and every other row of $M_r$ be zero. Similarly, for every column $c$ indexed by $y\in \{0,1\}^n$ with $|y|\not \in [(1/2-\epsilon)n,(1/2+\epsilon)n]$, let matrix $M_c\in\mathbb{F}^{2^n\times 2^n}$ be given by $M_c[x,y]=H_n[x,y]$ for all $x\in \{0,1\}^n$ and every other column of $M_c$ be zero. Observe that each such matrix $M_r$(resp., $M_c$) has rank 1. Note that \begin{align*} t &= 2\cdot |\{ v\in \{0,1\}^n \mid |v|\not\in [(1/2-\epsilon)n,(1/2+\epsilon)n] \}| \\ &= 2 \cdot \Bigg[\sum\limits_{i=0}^{(1/2-\epsilon)n}\binom{n}{i} + \sum\limits_{i=(1/2+\epsilon)n}^{n}\binom{n}{i}\Bigg] =4\cdot \sum\limits_{i=0}^{(1/2-\epsilon)n}\binom{n}{i} \leq 4\cdot n \cdot 2^{n-\Omega(\epsilon^2 n)} \end{align*} Therefore, ${rank}(M')\leq {rank}(M_p) + 4\cdot n \cdot 2^{n-\Omega(\epsilon^2 n)} \leq 5\cdot n \cdot 2^{n-\Omega(\epsilon^2 n)} $ as ${rank}(M_p) \leq 2^{n-\Omega(\epsilon^2 n)}$ from Step 1. Further, on every row $M'$ differs from $H_n$ on at most $|D| \leq 2^{n\epsilon\log(1/\epsilon)}$ entries. Hence, ${\cal R}_{H_n}(2^{n(1-f(\epsilon))}) \leq 2^{n(1+\epsilon)}$. \\ $\hfill\square$
{'timestamp': '2020-09-22T02:18:09', 'yymm': '2009', 'arxiv_id': '2009.09460', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09460'}
arxiv
\section{Introduction} Coreference resolution identifies mentions in a document that co-refer to the same entity. It is an important task facilitating many applications such as reading comprehension~\cite{dasigi-etal-2019-quoref} and text summarization~\cite{azzam-etal-1999-using}. \citet{lee-etal-2017-end} proposed the first neural end-to-end architecture for coreference resolution. Most recent systems use it as a backbone and employ better scoring functions~\cite{zhang-etal-2018-neural-coreference}, pruning procedures~\cite{lee-etal-2018-higher}, or token representations~\cite{joshi-etal-2019-bert, joshi2020spanbert}.\footnote{Except \citet{wu-etal-2020-corefqa} which has not seen wide adoption.} Despite this usage, little in-depth analysis has been done to better understand the inner workings of such an influential system. \citet{xu-choi-2020-revealing} analyzed the effect of the high-order inference, while \citet{subramanian-roth-2019-improving} and \citet{zhao-etal-2018-gender} respectively examined its generalizability and gender bias. Few work has inspected the interaction between its components. \citet{lu-ng-2020-conundrums} conducted oracle experiments that are related to ours, but without fine-grained control over confounding factors affecting oracle mentions. Such an understanding is important: for example, \citet{kummerfeld-klein-2013-error}'s dissection of the then-best classical coreference systems inspired many important follow-up works \cite[\emph{inter alia}]{peng-etal-2015-solving, martschat-strube-2015-latent, wiseman-etal-2016-learning}. However, it is unknown if observations on such classical feature-based and often pipelined systems extend to current neural end-to-end models. We consider the best instantiation of this model family, SpanBERT~\cite{joshi2020spanbert} + c2f-coref~\cite{lee-etal-2018-higher}, and investigate the interaction between its two components: mention detector and mention linker. We study how their errors independently or jointly affect the final clustering. Using the CoNLL-2012~\cite{pradhan2012conll} and PreCo~\cite{chen-etal-2018-preco} datasets, we highlight the low-precision, high-recall nature of the detector. While traditionally only recall is emphasized for the detector as a design decision (\citealp{lee2011stanford}; \citealp{lee-etal-2017-end}), we show huge degradation from noisy mentions and, perhaps surprisingly, increasing the number of candidates considered by the baseline linker only deteriorates the performance. While some classical coreference pipelines focused on detector precision~\cite{Uryupina2009DetectingAA}, it is rarely emphasized for current end-to-end systems. We hence stress the importance of a precision-recall balance for the detector and demonstrate how pruning hyperparameters, in addition to reducing computational complexity, control this trade-off. However, we show the difficulty of obtaining a precise detector by demonstrating the importance of anaphoricity decisions and the inability of the detector to make them. Finally, we highlight the high potential of the linker and that the remaining errors mainly involve pronoun resolution. We hope this work sheds light on the internals of the mainstream coreference system and, with our proposed next steps, catalyze future research. We believe some of our findings may also transfer to other tasks with a similar joint span detection and span (pair) classification architecture, such as SRL~\cite{he-etal-2018-jointly}, IE~\cite{luan-etal-2019-general}, and entity linking~\cite{kolitsas-etal-2018-end}. See \citet{jiang-etal-2020-generalizing} which subsumes many other tasks under such a span-based framework. \section{Background} \paragraph{Model} We study the coarse-to-fine coreference system (c2f-coref; \citealt{lee-etal-2018-higher}). It assigns an antecedent for every span in a document of length $T$, including a dummy that indicates non-mentions or non-anaphoric mentions. The final clustering is the transitive closure of connected spans. The system consists of a mention detector and a mention linker. The detector scores all $O(T^2)$ spans up to length $L$ and outputs the $\lambda T$ highest-scoring spans as possibly anaphoric mentions. The linker links each mention candidate with the highest-scoring antecedent among $K$ ones. Hyperparameters $L$, $\lambda$, and $K$ control the number of considered spans and antecedents, reducing computational complexity. \paragraph{Data} CoNLL-2012 is the most common dataset to test coreference models. However, it lacks singleton mention annotation~\cite{pradhan2012conll}. Singleton, or non-anaphoric, mentions do not co-refer with other spans, e.g. ``The dog'' in ``[The dog] barks.'' However, they may become anaphoric in another context, e.g. ``[The dog] barks at [itself].'' Being a mention is a span's inherent property, while anaphoricity, whether or not a mention co-refers, is context-dependent. We use ``all mentions'' to refer to the union of singleton and anaphoric mentions. To understand the effect of singleton mentions, we heuristically generate all mentions for CoNLL-12 (\S\ref{sec:heuristics}) for relevant experiments. We also experiment with PreCo, a coreference dataset with annotated singleton mentions. We do all analyses on development sets and report dataset statistics in \S\ref{sec:dataset-statistics}. \section{Experiments} \paragraph{Settings} We embed tokens with SpanBERT-large, a pre-trained transformer~\cite{vaswani2017attention} with state-of-the-art performance in coreference resolution. We choose $L = 30,\lambda = 0.4,K = 50$. We only keep the first 110 sentences per document during training. To reduce confounding factors, we do not use speaker and genre metadata.% \paragraph{``Original'' System} refers to a standard SpanBERT + c2f-coref trained baseline. Its F$_1$ score\footnote{We use coreference F$_1$ to refer to the average F$_1$ of MUC, B$^3$, and CEAF$_{\phi_4}$, the most common coreference metric.} is reported in Table~\ref{tab:original}, similar to the results in \citet{joshi2020spanbert} considering we disregard metadata. \begin{table}[t] \centering \begin{tabular}{c|cc} \hline & CoNLL-12 & PreCo \\ \hline Coref F$_1$ & 79.17 & 85.04 \\ \hline A\textsc{na}.\xspace P & 28.37 & 39.23 \\ A\textsc{na}.\xspace R & 96.42 & 98.40 \\ A\textsc{ll}\xspace P & 82.04 & 76.55 \\ A\textsc{ll}\xspace R & 57.35 & 95.98 \\ \hline \end{tabular} \caption{\label{tab:original} Original system coreference F$_1$ and precision / recall for anaphoric mentions (A\textsc{na}.\xspace) and all mentions (A\textsc{ll}\xspace) on CoNLL-12 and PreCo development sets.} \vspace{-0.3cm} \end{table} \paragraph{Oracles} We build oracle detectors where, starting from the original system's mention candidates (its detector output), we either remove all non-gold mentions (prefect precision), add all missing gold mentions (perfect recall), or both (perfect precision \& recall). We give the altered, rather than the original, mention candidates to the linker. We consider both anaphoric mentions and all mentions as gold mentions and modify either in a post-hoc manner or re-train the system with the altered candidates. To control for a non-trainable detector, we train only a linker reusing the original system's mention candidates, dubbed \textbf{Fixed Detector}. We consider this baseline as the comparison target for the oracles. Besides oracle detectors, we also build an oracle linker that assigns the correct antecedent (including dummy) to each of the $\lambda T$ mention candidates. \section{Precision-Recall Trade-Off for the Mention Detector} \label{sec:pr-re-analysis} \begin{table*}[t] \centering \begin{tabular}{c|l|c|cccccc} \hline \multicolumn{2}{c|}{} & Span & Conflated & Extra & Extra & Divided & Missing & Missing \\ \multicolumn{2}{c|}{} & Error & Entities & Mention & Entity & Entity & Mention & Entity \\ \hline \multicolumn{2}{c|}{Original} & 1.6 & 3.1 & 1.3 & 3.1 & 2.6 & 2.1 & 4.5 \\ \hline \multicolumn{2}{c|}{Fixed Detector} & 1.7 & 3.1 & 1.7 & 3.3 & 2.8 & 2.1 & 4.7 \\ \hline A\textsc{na}.\xspace & Perfect P & 0.0 & 2.4 & 0.0 & 0.0 & 2.0 & 2.6 & 5.7 \\ Post-hoc & Perfect R & 1.6 & 3.1 & 1.4 & 3.1 & 2.6 & 2.0 & 4.4 \\ Oracle & Perfect P\&R & 0.0 & 2.3 & 0.0 & 0.0 & 1.9 & 2.5 & 5.5 \\ \hline A\textsc{na}.\xspace & Perfect P & 0.0 & 3.4 & 0.0 & 0.0 & 0.9 & 1.5 & 1.4 \\ Re-train & Perfect R & 0.7 & 3.1 & 2.0 & 3.4 & 2.6 & 1.5 & 4.4 \\ Oracle & Perfect P\&R & 0.0 & 3.0 & 0.0 & 0.0 & 1.0 & 0.4 & 0.3 \\ \hline \end{tabular} \caption{\label{tab:fix-errors} The F$_1$ score improvement after fixing different types of errors on the CoNLL-12 development set. The errors are independently fixed after span errors are fixed. The categorization is from \citet{kummerfeld-klein-2013-error}.} \vspace{-0.3cm} \end{table*} \begin{table}[t] \centering \begin{tabular}{c|l|cc} \hline \multicolumn{2}{c|}{} & CoNLL-12 & PreCo \\ \hline \multicolumn{2}{c|}{Fixed Detector} & 78.28 & 84.64 \\ \hline A\textsc{na}.\xspace & Perfect P & 86.02 & 90.31 \\ Post-hoc & Perfect R & 79.37 & 85.17 \\ Oracle & Perfect P\&R & 86.28 & 90.45 \\ \hline A\textsc{na}.\xspace & Perfect P & 89.98 & 95.09 \\ Re-train & Perfect R & 79.65 & 85.22 \\ Oracle & Perfect P\&R & 92.39 & 96.50 \\ \hline A\textsc{ll}\xspace & Perfect P & 79.48 & 88.37 \\ Re-train & Perfect R & 78.52 & 85.23 \\ Oracle & Perfect P\&R & 80.05 & 89.13 \\ \hline \multicolumn{2}{c|}{Oracle Linker} & 97.07 & 98.69 \\ \hline \end{tabular} \caption{\label{tab:oracles} Baseline and oracle coreference F$_1$ for anaphoric mentions (A\textsc{na}.\xspace) and all mentions (A\textsc{ll}\xspace) on CoNLL-12 and PreCo development sets. ``Fixed Detector'' is the baseline with a non-trainable detector. The middle three sections are oracle detectors with perfect candidate precision/recall. The last row is an oracle linker that always makes correct antecedent decisions.} \vspace{-0.3cm} \end{table} Traditionally, coreference systems heavily favor recall over precision for the detector ~\cite{lee2011stanford} as the linker cannot recover missed mentions. Similarly, our c2f-coref system gets \textgreater96\% anaphoric mention recall yet only \textless40\% precision (Table~\ref{tab:original}). We therefore explore if detector recall is always more important than its precision. If more spans are considered by increasing the max span width $L$ or the number of spans considered per word $\lambda$, will the system performance necessarily improve? In the extreme case, if we hypothetically had enough compute that allows the linker to consider all $O(T^4)$ span-antecedent pairs, should we simply remove the pruning in the detector? \paragraph{The Aggregated Importance of Precision} For all oracles in Table~\ref{tab:oracles}, fixing precision yields a larger improvement than recall, especially with anaphoric mentions. % This highlights the importance of detector precision and the extent to which the linker suffers from noisy mention candidates. In Table~\ref{tab:fix-errors}, we present the F$_1$ improvement after independently fixing categorized errors following~\citet{kummerfeld-klein-2013-error}.\footnote{Span (boundary) errors are fixed before independently fixing all others. The numbers do not add up to the performance gap due to error type interactions.} Noisy candidates result in extra mention and extra entity errors, fixing which accounts for more than half of the $\approx$8 F$_1$ gap between the post-hoc perfect precision oracle and the baseline for CoNLL-12 (Table~\ref{tab:oracles}). Furthermore, re-training the system to leverage the distributional shift of the absence of noise leads to another $\approx$4 and 5 F$_1$ increase (CoNLL-12/PreCo). To analyze how higher detector precision helps the linker, we examine the coreference score the linker assigns to every span-antecedent pair. The anaphoric mention re-trained perfect precision oracle has an average score of --13.0 on CoNLL-12, higher than --15.1 with perfect recall. Among only correct span-antecedent pairs, these scores are 11.7 and 7.1, with the same pattern. This indicates that the noise with perfect recall prevents the linker from reliably assigning high coreference scores, even for correct links. The effect of higher coreference scores also shows in that, compared with perfect recall, the perfect precision oracle produces on average larger (4.44 vs. 4.26 entities) and longer-distance (154 vs. 152 tokens spanned) clusters. We also see this effect by examining the amount of improvement with reduced noise in Table~\ref{tab:fix-errors}. In the anaphoric mention post-hoc oracles, as expected, fixing precision results in fewer extra mention/entity errors and more missing errors, while the perfect recall oracle behaves conversely. However, when re-trained, the perfect precision oracle has much fewer missing entities, even fewer than with perfect recall. This is surprising as the latter considers more candidates. The reason is likely that the linker learns to leverage the absence of noise and reliably assigns high coreference scores. Despite some incorrect links leading to more conflated entities, the many correct ones drastically reduce missing mention/entity errors. On the other hand, the noise in the perfect recall or the original system prevents consistent high scores, resulting in more missing mentions and entities. Hence, the improvement with perfect precision partly stems from the linker's increased confidence in assigning coreference scores when \emph{not} tasked with ignoring non-mentions (and singletons) in noisy candidates. \begin{table}[t] \centering \begin{tabular}{@{\hspace{4pt}}c|c|c|c|c@{\hspace{2pt}}} \hline \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{CoNLL-12} & \multicolumn{2}{c}{PreCo} \\ \cline{2-5} \multicolumn{1}{c|}{} & \# Op & Op effect & \# Op & Op effect \\ \hline A\textsc{na}.\xspace; P & 135.9 & 0.086 & 79.2 & 0.132 \\ A\textsc{na}.\xspace; R & 1.9 & \textbf{0.715} & 0.8 & \textbf{0.709} \\ \hline A\textsc{ll}\xspace; P & 34.1 & \textbf{0.035} & 30.6 & 0.122 \\ A\textsc{ll}\xspace; R & 115.3 & 0.002 & 4.1 & \textbf{0.143} \\ \hline \end{tabular} \vspace{-0.05cm} \caption{\label{tab:operation-effects} The number of addition/removal operations needed for the oracle candidates, and the oracle performance increase, in F$_1$, amortized over each operation. Boldface indicates the higher per-operation effect between perfect precision and recall in each category.} \vspace{-0.1cm} \end{table} \begin{table}[t] \centering \fontsize{9.5}{12} \selectfont \begin{tabular}{@{\hspace{4pt}}c|c|c|c|c|c|c@{\hspace{4pt}}} \hline $L$ & 30 & 32 & 34 & 36 & 38 & 40 \\ \hline F$_1$ & \textbf{79.17} & 78.76 & 78.86 & 79.03 & 78.88 & 78.85 \\ \hline \hline $\lambda$ & 0.4 & 0.45 & 0.5 & 0.55 & 0.6 & 0.65 \\ \hline F$_1$ & \textbf{79.17} & 78.99 & 79.15 & 78.35 & 79.05 & 78.85 \\ \hline \end{tabular} \vspace{-0.05cm} \caption{\label{tab:more-spans} CoNLL-12 development F$_1$ with increased max span width $L$ or the number of spans considered per word $\lambda$. The first column is the original setting. Boldface indicates the best performance.} \vspace{-0.3cm} \end{table} \paragraph{The Average Importance of Recall} The large improvement from fixing precision may be due to its larger original headroom than recall (Table~\ref{tab:original}). We compute the number of operations (span addition/removal) needed for each oracle and the average F$_1$ improvement per operation in Table~\ref{tab:operation-effects}. For anaphoric mentions, recall has 5-8$\times$ the average effect of precision.\footnote{CoNLL-12 with all mentions has a different pattern as we noisily generated singletons in a recall-oriented way.} If we control the number of operations by re-training an anaphoric mention (semi-)perfect precision oracle removing only as many top-scoring extra spans as the number of missing correct spans (rather than removing all extra spans), it gets 79.08 and 85.01 F$_1$ on CoNLL-12 and PreCo, lower than the perfect recall oracle with 79.65 and 85.22. It is therefore only due to the low-precision high-recall nature of the original detector that precision is more important in aggregate. \paragraph{Precision-Recall Trade-Off} We return to the original question: if we had more compute, is it always beneficial to consider more spans in the detector? From our results, while recall is important, an imprecise detector has substantial adverse effects by increasing the linker's learning burden. Indeed, Table~\ref{tab:more-spans} shows that increasing the max span width by up to 33\% or the spans considered per word by up to 38\% only degrades the performance. As the extra low-scoring spans are mostly noise, we slightly increase recall but more heavily decrease precision, causing more harm than benefit. Hence, besides saving computation, these hyperparameters also balance the precision-recall trade-off. Future work should hence put more emphasis on precision which is often overlooked in end-to-end systems. \section{Difficulties Facing Each Component} \label{sec:focus} \subsection{The Detector's Difficulty With Anaphoricity Decisions} \label{sec:detector-difficulty} Despite its large aggregated improvement, i.e. $\approx$11.7 and 10.5 F$_1$ for CoNLL-12 and PreCo, perfect anaphoric mention precision requires perfectly distinguishing anaphoric from singleton mentions. These anaphoricity decisions in fact account for most of the improvement, $\approx$10.5 and 6.7 F$_1$ (Table~\ref{tab:oracles}, anaphoric v.s. all mentions perfect precision).\footnote{\citet{chen-etal-2018-preco} observed a similar pattern on an LSTM architecture that less directly receives global information which is important for anaphoricity decisions. We confirm that this still holds on transformers with a larger receptive field.} However, the detector, as a span classifier, does not explicitly model inter-span anaphoric relationships. To test this architecture's ability to distinguish anaphoric from singleton mentions, we build two span classifiers with the same structure as the detector, supervised with sigmoid loss, that recognize all mentions and anaphoric mentions in PreCo. The former achieves 79.89 classification F$_1$ while the latter only 54.32, showing the inability of a span classifier to make anaphoricity decisions. To better understand this difficulty, we define a confusion index as singleton recall divided by anaphoric mention recall. It correlates with the classifier's inability to identify anaphoricity. Ideally, this value should be close to 0, recalling more anaphoric mentions and fewer singletons. A random classifier incapable of distinguishing between the two has an expected confusion index of 1. \begin{table}[t] \centering \fontsize{9.5}{11} \selectfont \begin{tabular}{@{\hspace{1pt}} c@{\hspace{1pt}}|@{\hspace{3pt}}p{6cm} @{\hspace{2pt}}} \hline Error Type & \multicolumn{1}{c}{\multirow{2}{*}{Example}} \\ (\#) \\ \hline \multirow{4}{*}{\shortstack{Pronoun\\(109)}} & ... a cross-sea bridge connecting \textbf{Hong Kong, Zhuhai, and Macao} . \\ \cline{2-2} & ... after \textbf{their} return, Macao, and Hong Kong, the two special administrative regions ... \\ \hline \multirow{4}{*}{\shortstack{Exact\\Match\\(6)}} & The most important thing about \textbf{Disney} is that it is a global brand . \\ \cline{2-2} & The subway to \textbf{Disney} has already been constructed . \\ \hline \multirow{4}{*}{\shortstack{Head\\Match\\(11)}} & \textbf{Ten landmark buildings located on Hong Kong Island} reveal themselves ... \\ \cline{2-2} & ... \textbf{those private , er , buildings} , that is , the business community , ah , is willing to ... \\ \hline Other & And \textbf{Dr. Andy Henry} notices something else \\ \cline{2-2} Match (7) & \textbf{Dr. Mann} says they 've narrowed it down ... \\ \hline \multirow{4}{*}{\shortstack{Semantic\\Proximity\\(12)}} & ... \textbf{Hong Kong cinema} has nurtured many internationally renowned directors ... \\ \cline{2-2} & ... memorializing \textbf{Hong Kong 's 100 - year film history} . \\ \hline \multirow{2}{*}{\shortstack{Others\\(5)}} & But [\textbf{Paul Kelly}] [\textbf{Steve Sodbury}] and Mel Anderson ... had no idea ... \\ \hline \end{tabular} \caption{\label{tab:conflated-examples} Examples of categorized conflated entity errors in the CoNLL-12 development set with a perfect detector. Following past studies \cite{kummerfeld-klein-2013-error,joshi-etal-2019-bert}, we consider all deictic terms as pronouns. Each example contains two incorrectly linked entities in bold. Square brackets are added to separate mentions.} \vspace{-0.3cm} \end{table} The anaphoric mention classifier above has a confusion index of 0.81, showing its inability to make anaphoricity decisions even when explicitly trained with the signal. If we only consider text appearing as both singleton and anaphoric mentions in the same document, demanding contextual reasoning by disregarding obvious anaphoric mentions such as pronouns, the confusion index degrades to 0.997. Hence, the classifier is poor at leveraging self-attentive contextual cues to make anaphoricity decisions without explicit inter-span relational modeling. In \S\ref{sec:confusion-index-vs-span-width} we also show the degradation of the confusion index with shorter spans. Given the importance of anaphoric mention precision (\S\ref{sec:pr-re-analysis}), more research in improving anaphoricity decisions in the detector would be fruitful, for example, by more explicitly attending to neighboring spans. Alternatively, as \citet{zhong-chen-2021-frustratingly} showed the benefit of disentangling the span representations for entity detection and relation extraction in information extraction based on the intuition that they are disparate tasks, one may split the task of anaphoricity decision from mention linking and introduce a separately parameterized anaphoricity module, similarly considering the discrepancy between the two tasks. \citet{recasens-etal-2013-life,moosavi-strube-2016-search}; \textit{inter alia} have pursued similar ideas in the pre-neural era, but it has still not yet been explored with deep models. \subsection{The Linker's Errors} While the detector struggles with anaphoricity decisions, the linker explicitly models anaphoricity by assigning the dummy to extra mentions. % It is hence also viable to determine anaphoricity in the linker. Indeed, the current detector would suffice with a stronger linker: in Table~\ref{tab:oracles}, the oracle linker gets near-perfect scores with the original mentions (not perfect since the candidates are not gold).\footnote{A modified oracle linker that only considers coarse-pruned antecedents~\cite{lee-etal-2018-higher} still gets 96.61 and 98.65 F$_1$ on CoNLL-12 and PreCo. The small difference compared to considering all antecedents also shows that, with a strong linker, coarse-to-fine pruning has only negligible performance impact while substantially reducing the decision space.} To analyze the remaining non-anaphoricity linker errors, we assume a perfect anaphoric mention detector. Here, conflated entities is the single major error source (last row of Table~\ref{tab:fix-errors}). Table~\ref{tab:conflated-examples} shows 150 manually categorized conflated entities in the CoNLL-12 development set.\footnote{\citet{joshi-etal-2019-bert} and \citet{lu-ng-2020-conundrums} conducted similar analyses but we study in a more controlled setting by excluding detector errors and focusing on entity conflation, the largest remaining error source.} Suboptimal pronoun resolution is the biggest issue, and the linker also tends to link spans with various degrees of text match or semantic proximity. Within pronoun errors, the most common case is a pronoun linked to an incorrect nominal (in Table~\ref{tab:conflated-examples}), occurring 43 times. Sometimes two pronouns, often identical, are incorrectly linked, a case that necessitates better higher-order inference. Third person pronouns with different referents are conflated 29 times. Errors with first or second person pronouns occur 37 times, usually due to speaker switching. Similar to \S\ref{sec:detector-difficulty}, separately parameterizing the linker's encoder may help reduce conflation: intuitively, the span representation for mention detection may promote homogeneity. Meanwhile, the lack of discerning span-internal content for certain error types including pronoun resolution and exact match, combined with current systems' trend to rely on such cues~\cite{lu-ng-2020-conundrums}, calls for more focus on improving their contextual reasoning. \section{Conclusion} We analyzed the complex interaction between the mention detector and linker in the mainstream coarse-to-fine coreference system. Using oracle experiments, we showed that, while detector recall is important, higher anaphoric mention precision would lead to dramatically better linker performance, though achieving this is difficult. We also demonstrated that the oracle linker performance is near perfect and that the vast majority of remaining linker errors besides anaphoricity decisions are about pronoun resolution. We hope these discoveries will help future coreference research.% \section{Introduction} Coreference resolution identifies mentions in a document that co-refer to the same entity. It is an important task facilitating many applications such as reading comprehension~\cite{dasigi-etal-2019-quoref} and text summarization~\cite{azzam-etal-1999-using}. \citet{lee-etal-2017-end} proposed the first neural end-to-end architecture for coreference resolution. Most recent systems use it as a backbone and employ better scoring functions~\cite{zhang-etal-2018-neural-coreference}, pruning procedures~\cite{lee-etal-2018-higher}, or token representations~\cite{joshi-etal-2019-bert, joshi2020spanbert}.\footnote{Except \citet{wu-etal-2020-corefqa} which has not seen wide adoption.} Despite this usage, little in-depth analysis has been done to better understand the inner workings of such an influential system. \citet{xu-choi-2020-revealing} analyzed the effect of the high-order inference, while \citet{subramanian-roth-2019-improving} and \citet{zhao-etal-2018-gender} respectively examined its generalizability and gender bias. Few work has inspected the interaction between its components. \citet{lu-ng-2020-conundrums} conducted oracle experiments that are related to ours, but without fine-grained control over confounding factors affecting oracle mentions. Such an understanding is important: for example, \citet{kummerfeld-klein-2013-error}'s dissection of the then-best classical coreference systems inspired many important follow-up works \cite[\emph{inter alia}]{peng-etal-2015-solving, martschat-strube-2015-latent, wiseman-etal-2016-learning}. However, it is unknown if observations on such classical feature-based and often pipelined systems extend to current neural end-to-end models. We consider the best instantiation of this model family, SpanBERT~\cite{joshi2020spanbert} + c2f-coref~\cite{lee-etal-2018-higher}, and investigate the interaction between its two components: mention detector and mention linker. We study how their errors independently or jointly affect the final clustering. Using the CoNLL-2012~\cite{pradhan2012conll} and PreCo~\cite{chen-etal-2018-preco} datasets, we highlight the low-precision, high-recall nature of the detector. While traditionally only recall is emphasized for the detector as a design decision (\citealp{lee2011stanford}; \citealp{lee-etal-2017-end}), we show huge degradation from noisy mentions and, perhaps surprisingly, increasing the number of candidates considered by the baseline linker only deteriorates the performance. While some classical coreference pipelines focused on detector precision~\cite{Uryupina2009DetectingAA}, it is rarely emphasized for current end-to-end systems. We hence stress the importance of a precision-recall balance for the detector and demonstrate how pruning hyperparameters, in addition to reducing computational complexity, control this trade-off. However, we show the difficulty of obtaining a precise detector by demonstrating the importance of anaphoricity decisions and the inability of the detector to make them. Finally, we highlight the high potential of the linker and that the remaining errors mainly involve pronoun resolution. We hope this work sheds light on the internals of the mainstream coreference system and, with our proposed next steps, catalyze future research. We believe some of our findings may also transfer to other tasks with a similar joint span detection and span (pair) classification architecture, such as SRL~\cite{he-etal-2018-jointly}, IE~\cite{luan-etal-2019-general}, and entity linking~\cite{kolitsas-etal-2018-end}. See \citet{jiang-etal-2020-generalizing} which subsumes many other tasks under such a span-based framework. \section{Background} \paragraph{Model} We study the coarse-to-fine coreference system (c2f-coref; \citealt{lee-etal-2018-higher}). It assigns an antecedent for every span in a document of length $T$, including a dummy that indicates non-mentions or non-anaphoric mentions. The final clustering is the transitive closure of connected spans. The system consists of a mention detector and a mention linker. The detector scores all $O(T^2)$ spans up to length $L$ and outputs the $\lambda T$ highest-scoring spans as possibly anaphoric mentions. The linker links each mention candidate with the highest-scoring antecedent among $K$ ones. Hyperparameters $L$, $\lambda$, and $K$ control the number of considered spans and antecedents, reducing computational complexity. \paragraph{Data} CoNLL-2012 is the most common dataset to test coreference models. However, it lacks singleton mention annotation~\cite{pradhan2012conll}. Singleton, or non-anaphoric, mentions do not co-refer with other spans, e.g. ``The dog'' in ``[The dog] barks.'' However, they may become anaphoric in another context, e.g. ``[The dog] barks at [itself].'' Being a mention is a span's inherent property, while anaphoricity, whether or not a mention co-refers, is context-dependent. We use ``all mentions'' to refer to the union of singleton and anaphoric mentions. To understand the effect of singleton mentions, we heuristically generate all mentions for CoNLL-12 (\S\ref{sec:heuristics}) for relevant experiments. We also experiment with PreCo, a coreference dataset with annotated singleton mentions. We do all analyses on development sets and report dataset statistics in \S\ref{sec:dataset-statistics}. \section{Experiments} \paragraph{Settings} We embed tokens with SpanBERT-large, a pre-trained transformer~\cite{vaswani2017attention} with state-of-the-art performance in coreference resolution. We choose $L = 30,\lambda = 0.4,K = 50$. We only keep the first 110 sentences per document during training. To reduce confounding factors, we do not use speaker and genre metadata.% \paragraph{``Original'' System} refers to a standard SpanBERT + c2f-coref trained baseline. Its F$_1$ score\footnote{We use coreference F$_1$ to refer to the average F$_1$ of MUC, B$^3$, and CEAF$_{\phi_4}$, the most common coreference metric.} is reported in Table~\ref{tab:original}, similar to the results in \citet{joshi2020spanbert} considering we disregard metadata. \begin{table}[t] \centering \begin{tabular}{c|cc} \hline & CoNLL-12 & PreCo \\ \hline Coref F$_1$ & 79.17 & 85.04 \\ \hline A\textsc{na}.\xspace P & 28.37 & 39.23 \\ A\textsc{na}.\xspace R & 96.42 & 98.40 \\ A\textsc{ll}\xspace P & 82.04 & 76.55 \\ A\textsc{ll}\xspace R & 57.35 & 95.98 \\ \hline \end{tabular} \caption{\label{tab:original} Original system coreference F$_1$ and precision / recall for anaphoric mentions (A\textsc{na}.\xspace) and all mentions (A\textsc{ll}\xspace) on CoNLL-12 and PreCo development sets.} \vspace{-0.3cm} \end{table} \paragraph{Oracles} We build oracle detectors where, starting from the original system's mention candidates (its detector output), we either remove all non-gold mentions (prefect precision), add all missing gold mentions (perfect recall), or both (perfect precision \& recall). We give the altered, rather than the original, mention candidates to the linker. We consider both anaphoric mentions and all mentions as gold mentions and modify either in a post-hoc manner or re-train the system with the altered candidates. To control for a non-trainable detector, we train only a linker reusing the original system's mention candidates, dubbed \textbf{Fixed Detector}. We consider this baseline as the comparison target for the oracles. Besides oracle detectors, we also build an oracle linker that assigns the correct antecedent (including dummy) to each of the $\lambda T$ mention candidates. \section{Precision-Recall Trade-Off for the Mention Detector} \label{sec:pr-re-analysis} \begin{table*}[t] \centering \begin{tabular}{c|l|c|cccccc} \hline \multicolumn{2}{c|}{} & Span & Conflated & Extra & Extra & Divided & Missing & Missing \\ \multicolumn{2}{c|}{} & Error & Entities & Mention & Entity & Entity & Mention & Entity \\ \hline \multicolumn{2}{c|}{Original} & 1.6 & 3.1 & 1.3 & 3.1 & 2.6 & 2.1 & 4.5 \\ \hline \multicolumn{2}{c|}{Fixed Detector} & 1.7 & 3.1 & 1.7 & 3.3 & 2.8 & 2.1 & 4.7 \\ \hline A\textsc{na}.\xspace & Perfect P & 0.0 & 2.4 & 0.0 & 0.0 & 2.0 & 2.6 & 5.7 \\ Post-hoc & Perfect R & 1.6 & 3.1 & 1.4 & 3.1 & 2.6 & 2.0 & 4.4 \\ Oracle & Perfect P\&R & 0.0 & 2.3 & 0.0 & 0.0 & 1.9 & 2.5 & 5.5 \\ \hline A\textsc{na}.\xspace & Perfect P & 0.0 & 3.4 & 0.0 & 0.0 & 0.9 & 1.5 & 1.4 \\ Re-train & Perfect R & 0.7 & 3.1 & 2.0 & 3.4 & 2.6 & 1.5 & 4.4 \\ Oracle & Perfect P\&R & 0.0 & 3.0 & 0.0 & 0.0 & 1.0 & 0.4 & 0.3 \\ \hline \end{tabular} \caption{\label{tab:fix-errors} The F$_1$ score improvement after fixing different types of errors on the CoNLL-12 development set. The errors are independently fixed after span errors are fixed. The categorization is from \citet{kummerfeld-klein-2013-error}.} \vspace{-0.3cm} \end{table*} \begin{table}[t] \centering \begin{tabular}{c|l|cc} \hline \multicolumn{2}{c|}{} & CoNLL-12 & PreCo \\ \hline \multicolumn{2}{c|}{Fixed Detector} & 78.28 & 84.64 \\ \hline A\textsc{na}.\xspace & Perfect P & 86.02 & 90.31 \\ Post-hoc & Perfect R & 79.37 & 85.17 \\ Oracle & Perfect P\&R & 86.28 & 90.45 \\ \hline A\textsc{na}.\xspace & Perfect P & 89.98 & 95.09 \\ Re-train & Perfect R & 79.65 & 85.22 \\ Oracle & Perfect P\&R & 92.39 & 96.50 \\ \hline A\textsc{ll}\xspace & Perfect P & 79.48 & 88.37 \\ Re-train & Perfect R & 78.52 & 85.23 \\ Oracle & Perfect P\&R & 80.05 & 89.13 \\ \hline \multicolumn{2}{c|}{Oracle Linker} & 97.07 & 98.69 \\ \hline \end{tabular} \caption{\label{tab:oracles} Baseline and oracle coreference F$_1$ for anaphoric mentions (A\textsc{na}.\xspace) and all mentions (A\textsc{ll}\xspace) on CoNLL-12 and PreCo development sets. ``Fixed Detector'' is the baseline with a non-trainable detector. The middle three sections are oracle detectors with perfect candidate precision/recall. The last row is an oracle linker that always makes correct antecedent decisions.} \vspace{-0.3cm} \end{table} Traditionally, coreference systems heavily favor recall over precision for the detector ~\cite{lee2011stanford} as the linker cannot recover missed mentions. Similarly, our c2f-coref system gets \textgreater96\% anaphoric mention recall yet only \textless40\% precision (Table~\ref{tab:original}). We therefore explore if detector recall is always more important than its precision. If more spans are considered by increasing the max span width $L$ or the number of spans considered per word $\lambda$, will the system performance necessarily improve? In the extreme case, if we hypothetically had enough compute that allows the linker to consider all $O(T^4)$ span-antecedent pairs, should we simply remove the pruning in the detector? \paragraph{The Aggregated Importance of Precision} For all oracles in Table~\ref{tab:oracles}, fixing precision yields a larger improvement than recall, especially with anaphoric mentions. % This highlights the importance of detector precision and the extent to which the linker suffers from noisy mention candidates. In Table~\ref{tab:fix-errors}, we present the F$_1$ improvement after independently fixing categorized errors following~\citet{kummerfeld-klein-2013-error}.\footnote{Span (boundary) errors are fixed before independently fixing all others. The numbers do not add up to the performance gap due to error type interactions.} Noisy candidates result in extra mention and extra entity errors, fixing which accounts for more than half of the $\approx$8 F$_1$ gap between the post-hoc perfect precision oracle and the baseline for CoNLL-12 (Table~\ref{tab:oracles}). Furthermore, re-training the system to leverage the distributional shift of the absence of noise leads to another $\approx$4 and 5 F$_1$ increase (CoNLL-12/PreCo). To analyze how higher detector precision helps the linker, we examine the coreference score the linker assigns to every span-antecedent pair. The anaphoric mention re-trained perfect precision oracle has an average score of --13.0 on CoNLL-12, higher than --15.1 with perfect recall. Among only correct span-antecedent pairs, these scores are 11.7 and 7.1, with the same pattern. This indicates that the noise with perfect recall prevents the linker from reliably assigning high coreference scores, even for correct links. The effect of higher coreference scores also shows in that, compared with perfect recall, the perfect precision oracle produces on average larger (4.44 vs. 4.26 entities) and longer-distance (154 vs. 152 tokens spanned) clusters. We also see this effect by examining the amount of improvement with reduced noise in Table~\ref{tab:fix-errors}. In the anaphoric mention post-hoc oracles, as expected, fixing precision results in fewer extra mention/entity errors and more missing errors, while the perfect recall oracle behaves conversely. However, when re-trained, the perfect precision oracle has much fewer missing entities, even fewer than with perfect recall. This is surprising as the latter considers more candidates. The reason is likely that the linker learns to leverage the absence of noise and reliably assigns high coreference scores. Despite some incorrect links leading to more conflated entities, the many correct ones drastically reduce missing mention/entity errors. On the other hand, the noise in the perfect recall or the original system prevents consistent high scores, resulting in more missing mentions and entities. Hence, the improvement with perfect precision partly stems from the linker's increased confidence in assigning coreference scores when \emph{not} tasked with ignoring non-mentions (and singletons) in noisy candidates. \begin{table}[t] \centering \begin{tabular}{@{\hspace{4pt}}c|c|c|c|c@{\hspace{2pt}}} \hline \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{CoNLL-12} & \multicolumn{2}{c}{PreCo} \\ \cline{2-5} \multicolumn{1}{c|}{} & \# Op & Op effect & \# Op & Op effect \\ \hline A\textsc{na}.\xspace; P & 135.9 & 0.086 & 79.2 & 0.132 \\ A\textsc{na}.\xspace; R & 1.9 & \textbf{0.715} & 0.8 & \textbf{0.709} \\ \hline A\textsc{ll}\xspace; P & 34.1 & \textbf{0.035} & 30.6 & 0.122 \\ A\textsc{ll}\xspace; R & 115.3 & 0.002 & 4.1 & \textbf{0.143} \\ \hline \end{tabular} \vspace{-0.05cm} \caption{\label{tab:operation-effects} The number of addition/removal operations needed for the oracle candidates, and the oracle performance increase, in F$_1$, amortized over each operation. Boldface indicates the higher per-operation effect between perfect precision and recall in each category.} \vspace{-0.1cm} \end{table} \begin{table}[t] \centering \fontsize{9.5}{12} \selectfont \begin{tabular}{@{\hspace{4pt}}c|c|c|c|c|c|c@{\hspace{4pt}}} \hline $L$ & 30 & 32 & 34 & 36 & 38 & 40 \\ \hline F$_1$ & \textbf{79.17} & 78.76 & 78.86 & 79.03 & 78.88 & 78.85 \\ \hline \hline $\lambda$ & 0.4 & 0.45 & 0.5 & 0.55 & 0.6 & 0.65 \\ \hline F$_1$ & \textbf{79.17} & 78.99 & 79.15 & 78.35 & 79.05 & 78.85 \\ \hline \end{tabular} \vspace{-0.05cm} \caption{\label{tab:more-spans} CoNLL-12 development F$_1$ with increased max span width $L$ or the number of spans considered per word $\lambda$. The first column is the original setting. Boldface indicates the best performance.} \vspace{-0.3cm} \end{table} \paragraph{The Average Importance of Recall} The large improvement from fixing precision may be due to its larger original headroom than recall (Table~\ref{tab:original}). We compute the number of operations (span addition/removal) needed for each oracle and the average F$_1$ improvement per operation in Table~\ref{tab:operation-effects}. For anaphoric mentions, recall has 5-8$\times$ the average effect of precision.\footnote{CoNLL-12 with all mentions has a different pattern as we noisily generated singletons in a recall-oriented way.} If we control the number of operations by re-training an anaphoric mention (semi-)perfect precision oracle removing only as many top-scoring extra spans as the number of missing correct spans (rather than removing all extra spans), it gets 79.08 and 85.01 F$_1$ on CoNLL-12 and PreCo, lower than the perfect recall oracle with 79.65 and 85.22. It is therefore only due to the low-precision high-recall nature of the original detector that precision is more important in aggregate. \paragraph{Precision-Recall Trade-Off} We return to the original question: if we had more compute, is it always beneficial to consider more spans in the detector? From our results, while recall is important, an imprecise detector has substantial adverse effects by increasing the linker's learning burden. Indeed, Table~\ref{tab:more-spans} shows that increasing the max span width by up to 33\% or the spans considered per word by up to 38\% only degrades the performance. As the extra low-scoring spans are mostly noise, we slightly increase recall but more heavily decrease precision, causing more harm than benefit. Hence, besides saving computation, these hyperparameters also balance the precision-recall trade-off. Future work should hence put more emphasis on precision which is often overlooked in end-to-end systems. \section{Difficulties Facing Each Component} \label{sec:focus} \subsection{The Detector's Difficulty With Anaphoricity Decisions} \label{sec:detector-difficulty} Despite its large aggregated improvement, i.e. $\approx$11.7 and 10.5 F$_1$ for CoNLL-12 and PreCo, perfect anaphoric mention precision requires perfectly distinguishing anaphoric from singleton mentions. These anaphoricity decisions in fact account for most of the improvement, $\approx$10.5 and 6.7 F$_1$ (Table~\ref{tab:oracles}, anaphoric v.s. all mentions perfect precision).\footnote{\citet{chen-etal-2018-preco} observed a similar pattern on an LSTM architecture that less directly receives global information which is important for anaphoricity decisions. We confirm that this still holds on transformers with a larger receptive field.} However, the detector, as a span classifier, does not explicitly model inter-span anaphoric relationships. To test this architecture's ability to distinguish anaphoric from singleton mentions, we build two span classifiers with the same structure as the detector, supervised with sigmoid loss, that recognize all mentions and anaphoric mentions in PreCo. The former achieves 79.89 classification F$_1$ while the latter only 54.32, showing the inability of a span classifier to make anaphoricity decisions. To better understand this difficulty, we define a confusion index as singleton recall divided by anaphoric mention recall. It correlates with the classifier's inability to identify anaphoricity. Ideally, this value should be close to 0, recalling more anaphoric mentions and fewer singletons. A random classifier incapable of distinguishing between the two has an expected confusion index of 1. \begin{table}[t] \centering \fontsize{9.5}{11} \selectfont \begin{tabular}{@{\hspace{1pt}} c@{\hspace{1pt}}|@{\hspace{3pt}}p{6cm} @{\hspace{2pt}}} \hline Error Type & \multicolumn{1}{c}{\multirow{2}{*}{Example}} \\ (\#) \\ \hline \multirow{4}{*}{\shortstack{Pronoun\\(109)}} & ... a cross-sea bridge connecting \textbf{Hong Kong, Zhuhai, and Macao} . \\ \cline{2-2} & ... after \textbf{their} return, Macao, and Hong Kong, the two special administrative regions ... \\ \hline \multirow{4}{*}{\shortstack{Exact\\Match\\(6)}} & The most important thing about \textbf{Disney} is that it is a global brand . \\ \cline{2-2} & The subway to \textbf{Disney} has already been constructed . \\ \hline \multirow{4}{*}{\shortstack{Head\\Match\\(11)}} & \textbf{Ten landmark buildings located on Hong Kong Island} reveal themselves ... \\ \cline{2-2} & ... \textbf{those private , er , buildings} , that is , the business community , ah , is willing to ... \\ \hline Other & And \textbf{Dr. Andy Henry} notices something else \\ \cline{2-2} Match (7) & \textbf{Dr. Mann} says they 've narrowed it down ... \\ \hline \multirow{4}{*}{\shortstack{Semantic\\Proximity\\(12)}} & ... \textbf{Hong Kong cinema} has nurtured many internationally renowned directors ... \\ \cline{2-2} & ... memorializing \textbf{Hong Kong 's 100 - year film history} . \\ \hline \multirow{2}{*}{\shortstack{Others\\(5)}} & But [\textbf{Paul Kelly}] [\textbf{Steve Sodbury}] and Mel Anderson ... had no idea ... \\ \hline \end{tabular} \caption{\label{tab:conflated-examples} Examples of categorized conflated entity errors in the CoNLL-12 development set with a perfect detector. Following past studies \cite{kummerfeld-klein-2013-error,joshi-etal-2019-bert}, we consider all deictic terms as pronouns. Each example contains two incorrectly linked entities in bold. Square brackets are added to separate mentions.} \vspace{-0.3cm} \end{table} The anaphoric mention classifier above has a confusion index of 0.81, showing its inability to make anaphoricity decisions even when explicitly trained with the signal. If we only consider text appearing as both singleton and anaphoric mentions in the same document, demanding contextual reasoning by disregarding obvious anaphoric mentions such as pronouns, the confusion index degrades to 0.997. Hence, the classifier is poor at leveraging self-attentive contextual cues to make anaphoricity decisions without explicit inter-span relational modeling. In \S\ref{sec:confusion-index-vs-span-width} we also show the degradation of the confusion index with shorter spans. Given the importance of anaphoric mention precision (\S\ref{sec:pr-re-analysis}), more research in improving anaphoricity decisions in the detector would be fruitful, for example, by more explicitly attending to neighboring spans. Alternatively, as \citet{zhong-chen-2021-frustratingly} showed the benefit of disentangling the span representations for entity detection and relation extraction in information extraction based on the intuition that they are disparate tasks, one may split the task of anaphoricity decision from mention linking and introduce a separately parameterized anaphoricity module, similarly considering the discrepancy between the two tasks. \citet{recasens-etal-2013-life,moosavi-strube-2016-search}; \textit{inter alia} have pursued similar ideas in the pre-neural era, but it has still not yet been explored with deep models. \subsection{The Linker's Errors} While the detector struggles with anaphoricity decisions, the linker explicitly models anaphoricity by assigning the dummy to extra mentions. % It is hence also viable to determine anaphoricity in the linker. Indeed, the current detector would suffice with a stronger linker: in Table~\ref{tab:oracles}, the oracle linker gets near-perfect scores with the original mentions (not perfect since the candidates are not gold).\footnote{A modified oracle linker that only considers coarse-pruned antecedents~\cite{lee-etal-2018-higher} still gets 96.61 and 98.65 F$_1$ on CoNLL-12 and PreCo. The small difference compared to considering all antecedents also shows that, with a strong linker, coarse-to-fine pruning has only negligible performance impact while substantially reducing the decision space.} To analyze the remaining non-anaphoricity linker errors, we assume a perfect anaphoric mention detector. Here, conflated entities is the single major error source (last row of Table~\ref{tab:fix-errors}). Table~\ref{tab:conflated-examples} shows 150 manually categorized conflated entities in the CoNLL-12 development set.\footnote{\citet{joshi-etal-2019-bert} and \citet{lu-ng-2020-conundrums} conducted similar analyses but we study in a more controlled setting by excluding detector errors and focusing on entity conflation, the largest remaining error source.} Suboptimal pronoun resolution is the biggest issue, and the linker also tends to link spans with various degrees of text match or semantic proximity. Within pronoun errors, the most common case is a pronoun linked to an incorrect nominal (in Table~\ref{tab:conflated-examples}), occurring 43 times. Sometimes two pronouns, often identical, are incorrectly linked, a case that necessitates better higher-order inference. Third person pronouns with different referents are conflated 29 times. Errors with first or second person pronouns occur 37 times, usually due to speaker switching. Similar to \S\ref{sec:detector-difficulty}, separately parameterizing the linker's encoder may help reduce conflation: intuitively, the span representation for mention detection may promote homogeneity. Meanwhile, the lack of discerning span-internal content for certain error types including pronoun resolution and exact match, combined with current systems' trend to rely on such cues~\cite{lu-ng-2020-conundrums}, calls for more focus on improving their contextual reasoning. \section{Conclusion} We analyzed the complex interaction between the mention detector and linker in the mainstream coarse-to-fine coreference system. Using oracle experiments, we showed that, while detector recall is important, higher anaphoric mention precision would lead to dramatically better linker performance, though achieving this is difficult. We also demonstrated that the oracle linker performance is near perfect and that the vast majority of remaining linker errors besides anaphoricity decisions are about pronoun resolution. We hope these discoveries will help future coreference research.%
{'timestamp': '2021-09-10T02:06:25', 'yymm': '2009', 'arxiv_id': '2009.09363', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09363'}
arxiv
\section{Introduction} Drones have gained great attention for civil applications from both academic and industrial domains \cite{LIU2019163}. The wide range of applications and services offered by drones show the extensive utilization of drones in various sectors including search and rescue, real-time monitoring, aerial surveillance, structural inspection, and delivery of goods \cite{DBLP:journals/corr/abs-1805-00881} \cite{2}. Several large corporations such as Amazon, DHL, and Google have shown a growing interest in using drones for package delivery \cite{doi:10.1111/drev.10313}. The attractive features of commercial drone delivery are \textit{higher efficiency, cost-effectiveness,} and \textit{higher flexibility} compared to terrestrial transportation \cite{5}. The \textit{service paradigm} \cite{Bgt2017} provides powerful mechanisms to abstract the \textit{functional} and \textit{non-functional} or \textit{Quality of Service} (QoS) properties of a drone as \textit{Drone-as-a-Service} (DaaS) \cite{8818436}. The functional property of a DaaS describes the delivery of a package from a given source to a destination following a skyway network. The non-functional properties of a DaaS are battery capacity, flight range, payload, and speed. Drone delivery services usually operate in a skyway network to avoid no-fly zones and restricted areas. A skyway network is composed of skyway segments between any two particular nodes following the drone flying regulations such as visual line-of-sight \cite{doi:10.1068/b34066}. The nodes are assumed to be the delivery targets or recharging stations. The practicality of drone delivery services is limited by a diverse range of \textit{intrinsic} and \textit{extrinsic} factors \cite{8}. The intrinsic factors are the inherited drone's limitations such as limited battery capacity, limited flight range, and constrained payload. The extrinsic factors are related to the drone service environment such as highly dynamic operating environment and constraints on recharging pads at the stations. The maximum flight range of a delivery drone with full payload weight varies from 3 to 33 km \cite{12}. The \textit{battery capacity, speed, payload weight,} and \textit{weather conditions} influence the flight range of a drone \cite{7513397}. To the best of our knowledge, existing research mainly focuses on the \textit{scheduling} and \textit{routing} of drones by formulating the problem as Travelling Salesman Problem (TSP) \cite{8488559} and Vehicle Routing Problem (VRP) \cite{7513397}. A single drone routing problem with fuel constraints is studied to minimize the total fuel consumption in \cite{6619438}. The proposed approach is limited to generating routes for only a single drone with a finite number of stations. Detailed analysis on maximizing the profitability and minimizing the drone delivery time is presented in \cite{8}. This approach mainly focuses on battery management of a drone delivery service. However, existing approaches do not consider \textit{recharging constraints} and the \textit{stochastic} nature of drone delivery services. A drone may need multiple times of recharging its battery at intermediate stations for persistent delivery services in long-distance areas. The arrival of the drone services at a recharging station is usually stochastic in nature \cite{venkatachalam2017two}. Each station has usually a finite number of recharging pads. Therefore, the availability of recharging pads may not be guaranteed. \textit{Our previous work \cite{10.1007/978-3-030-33702-5_28} is the first to focus on the recharging constraints of drone services using the service paradigm}. In our previous work, we proposed a \textit{novel DaaS composition framework considering the recharging constraints of drone services}. In this context, recharging at intermediate stations leads to the \textit{composition} of DaaS services. The composition provides a means to aggregate the skyway segment services from source to destination \cite{10.1007/978-3-662-45391-9_26}. We formulated the problem of \textit{constraint-aware DaaS composition as a multi-armed bandit tree exploration problem}. We assumed that both the intrinsic and extrinsic factors are \textit{deterministic}, i.e., we know a priori about the available drone services, their QoS properties, and the service environment. Multiple DaaS services instantiated by different drones, operating in the same skyway network at the same time, may cause congestion in the network. We defined \textit{congestion} as the total waiting time require a drone for the availability of recharging pad at a certain station \cite{12}. To avoid congestion within the network, we proposed a lookahead heuristic-based multi-armed bandit approach to compose drone services minimizing the delivery time and cost. However, \textit{our previous work does not consider the failures in drone services in dynamic weather conditions.} In real-world settings, the drone service environment is \textit{highly dynamic} in nature \cite{BARAKAT2018215}. The QoS properties of drone services may fluctuate due to the changes in the airflow pattern \cite{Mabrouk:2009:QSC:1813355.1813365}. For example, a drone service may arrive late due to strong headwind or may not find a recharging pad available on a certain recharging station due to recharging constraints and stochastic arrival of other drone services. As a result, the drone service may no longer provide the required QoS and fail. Therefore, the initial deterministic composition plan may become non-optimal and need to be \textit{replanned} to deal with changing weather conditions and recharging constraints. \textit{Failure} is a natural phenomenon in service composition. \textit{To the best of our knowledge, no prior work has addressed the failure of drone service composition during the delivery operation.} In this paper, we extend our previous DaaS composition framework \cite{8818436} \cite{10.1007/978-3-030-33702-5_28} by adapting the failures in DaaS composition. Our objective is to propose a \textit{resilient DaaS composition framework}. We compose the DaaS services and build an initial composition plan using our deterministic approach. The drone services are required to reach certain intermediate stations at a specific time during the delivery operation. The position and time of a drone service are of paramount importance for the smooth execution of the delivery operation. \textit{Failure in DaaS composition means to fail in executing the initial deterministic composition plan.} For example, a drone service $DaaS_1$ needs to reach a recharging station $S_1$ at 02:30 pm. The smooth execution of subsequent drone services depends on the current drone service and the movement of other drone services. The early or late arrival of $DaaS_1$ may affect the other drone services and require to change the initial plan. The early arrival of a drone service at an intermediate recharging station does not necessarily mean to support the initial composition plan. This early arrival may result in long waiting time for the availability of recharging pad. Failure to meet constraints of a composite plan may result in the failure of partial or complete composite drone service. We propose a \textit{resilient composition of drone services for delivery considering the recharging constraints and uncertain weather conditions}. In this context, resilient means that DaaS composition eventually delivers the package to the destination by adapting failures in the initial deterministic composition plan. The recharging time, weather conditions, and arrival (or departure) of one drone influence the execution plan of other drones at each station. We assume that the available drone services are initially deterministic, i.e., there is a knowledge about the availability of drone services and their QoS values a priori. The real-time delivery operation transforms the deterministic drone services to dynamic and stochastic drone services. The service environment is dynamic and the availability of recharging pads may not be guaranteed. We analyze the local impact of a failed drone service. We then locally recompose the initial composition plan using a novel adaptive lookahead heuristic-based approach. Our proposed approach finds the \textit{best composition plan} from the current position to the next intermediate station where no change to the initial plan has occurred. This process continues until the delivery of the package to the destination. The main contributions of this paper are as follows: \begin{itemize} \item A formal model to represent constraint-aware DaaS services. \item A Skyline approach for DaaS selection in delivery. \item A resilient drone service composition approach considering recharging constraints and uncertain weather conditions. \item A new heuristic-based local service recomposition algorithm using adaptive lookahead approach. \item A custom drone simulation model for simulating the experiments. \item An evaluation using a real-world dataset to show the efficiency and effectiveness of the proposed model. \end{itemize} \subsection*{Motivating Scenario} We use a typical drone delivery scenario as our motivating scenario. Drones deliver the packages within Sydney, Australia. Suppose a drone delivery service provider company is planning to deliver a package from \textit{Richmond} to \textit{Cronulla} (89 km). The maximum service distance of a typical delivery drone ranges from 3 to 33 km. The payload weight and wind speed also affect the flight range of a drone. The Bureau of Meteorology (BoM)\footnote{http://www.bom.gov.au/nsw/observations/sydney.shtml} provides the real-time information of wind speed and direction for the Sydney area which helps in determining the flight range of a drone. Multiple times of recharge may be required to serve the delivery request. Avoiding the strong wind areas and the congestion of drones at recharging stations is of paramount importance for time-optimal and cost-effective delivery services. We construct a skyway network following the Civil Aviation Safety Authority (CASA)\footnote{https://www.casa.gov.au/drones/rules} drone flying regulations such as avoiding no-fly zones and restricted areas. The nodes of the skyway network are the rooftops of high-rise buildings within the Sydney area. Each node can be a \textit{recharging station} or a \textit{delivery target}. Each rooftop has a finite number of recharging pads where a drone can land and recharge. To avoid compatibility issues and present a realistic scenario, we assume that there is no handover of packages at the intermediate stations, i.e., the same drone delivers the package from source to destination. The stochastic arrival of drone services may cause dynamic congestion at certain nodes, i.e., all recharging pads are occupied. Avoiding the congested nodes would result in faster delivery services. \begin{figure} \centering \includegraphics[width=\textwidth, height=6cm]{fig1.jpg} \caption{Skyway network for drone-based package delivery considering failures} \vspace{-10pt} \label{fig1} \end{figure} Suppose Yasir needs a package to be delivered within the \textbf{shortest period of time}. If we ignore the uncertainties, e.g., wind effect and the congestion at the stations (i.e., busy recharging pads) and assume that the services are deterministic, the problem would be reduced to finding the shortest path (the composition of skyway segments) from the source to the destination within the skyway network. However, this greedy approach has a higher probability to fail under uncertain conditions in the real-world environment. For example, the initial delivery plan may be highly affected by strong wind in an area or other arriving drone services at a certain station. Fig. \ref{fig1} presents the skyway network for drone delivery with recharging stations, uncertain wind conditions, and failures at intermediate stations. Our objective is to design a \textit{smart resilient approach} to deal with the effects of failures in the initial deterministic composition plan. This smart resilient approach adapts to the failures automatically, handles the effects of failures, and ensures the on-time package delivery. The brute-force approach considers all the possible compositions to find the best composition plan. However, this approach is highly time-consuming as finding all the possible compositions may produce exponential search space. As a result, we consider the \textbf{local recomposition} approach which updates the initial composition plan when a failure occurs in the initial plan at an intermediate recharging station. We use an \textit{adaptive lookahead heuristic-based approach} which performs the \textit{local optimizations} instead of the \textit{replanning from scratch or global optimization}, i.e., finding the impact of failure in next couple of nodes (relative to the direction of the destination). \section{Related Work} To the best of our knowledge, there exists no similar resilient drone service composition approach in the literature considering the dynamic weather conditions. The proposed framework combines concepts from two separate areas: (1) routing and scheduling of drones and (2) failure detection and recovery in composite services. In this section, we overview related work in these two areas. \subsection{Routing and Scheduling of Drones} Several studies address the routing and scheduling problems for drone delivery services. Most of the existing research work focuses on using drones in combination with ground vehicles for last-mile delivery. A hybrid framework for ground vehicle and drone was first studied in \cite{MURRAY201586}. They proposed two new approaches for drone-assisted parcel delivery problem to minimize the total delivery time. In the first approach, a drone is launched from the ground vehicle to serve a customer while a ground vehicle is serving another customer. After serving the customer, the drone meets with the ground vehicle in a rendezvous location. In the second approach, the ground vehicle and the drone are separately operated, i.e., the ground vehicle and drone perform dedicated deliveries. \textit{It is concluded that the speed of a drone is an important consideration in determining its flight range} \cite{MURRAY201586}. The proposed approach is tested for small-sized customer instances up to 20. \textit{The proposed hybrid approach requires road access for ground vehicles to make deliveries, i.e., not suitable for remote areas where there is no road infrastructure}. A single drone routing problem is examined considering multiple refuelling depots in \cite{6619438} where a drone can refuel at any depot. The objective of this study is to minimize the total fuel consumption for visiting all the customers. \textit{It is assumed that drone will never run out of fuel during the journey to a customer}. The problem is modelled using Mixed Integer Linear Programming (MILP) formulation. An approximation algorithm is proposed for solving the problem. The proposed approach is tested for 6 depots and 25 targets only. \textit{The proposed model does not consider the temporal logic constraints}. The proposed approach is restricted to generating delivery routes for only a single drone, i.e., not scalable to be used for multiple drones. Two multi-trip VRPs problem is proposed considering solely drones to perform deliveries \cite{7513397}. The objective is to minimize delivery time and operational cost. They proposed an energy consumption model based on the relationship between battery capacity and payload weight. Simulated annealing (SA) metaheuristic and MILP solver are used to find sub-optimal solutions for the drone delivery problem. The service area for drone deliveries is limited because all drones are restricted to dispatch from and return to a single depot. The actual flight time, drone speed, and uncertain weather conditions are not taken into account in the proposed model. \textit{The proposed approach does not consider the field recharging which limits the coverage and applicability.} An energy consumption model is presented for automated drone delivery services in \cite{choi2017optimization}. They assumed that drones can perform multi-package deliveries in a predefined service area. The drone fleet size is optimized by analyzing the impact of payload weight and flight range considering battery capacity. They explore the relationship between four variables (working period, drone speed, demand density of service area, and battery capacity) to minimize the total costs of the drone delivery system. The study indicated that the long hours of operation would benefit both service providers and customers. They found that drone deliveries are more cost-effective in areas with high demand densities. \textit{This study does not consider the dynamic congestion conditions at recharging stations and uncertain weather conditions}. A scheduling model is presented to support persistent drone delivery services in \cite{SONG2018418}. The relationship between the intrinsic factors such as payload and flight range is considered for the effective use of drone delivery services. Multiple service stations are assumed to replenish batteries of drones during the delivery operation. A MILP formulation is presented to model the problem and solved using a heuristic approach. An exact solution through MILP and a heuristic algorithm are provided. It is assumed that the recharging time at the service station is constant, which is not realistic in practical applications. The flight time is assumed as a function of payload weight. In real-world problems, the flight time depends upon the payload weight, drone speed, and environmental weather conditions such as wind speed and temperature. \textit{The proposed solutions do not take into account the extrinsic factors such as dynamic operating environment, recharging constraints at each station, the influence of one drone’s recharging on other drones, congestion conditions at each station, uncertain weather conditions, and failures in drone delivery services.} Hence, a heuristic-based approach is required which incorporates the aforementioned real-world aspects of drone delivery services. \subsection{Failure Detection and Recovery in Composite Services} Many research works discuss the problem of failure detection and recovery in composite services \cite{4580652,1530790,10.1007/978-3-642-17358-5_11,5175901,Saboohi:2012:FRW:2428736.2428787,1452105}. In \cite{4580652}, a service failure recovery approach is presented using subgraph replacement of services containing a failed service. They first represent the composite services as directed graphs. They pre-calculate the subgraphs and then rank them to speed up the recovery process at the time of failure. The subgraph calculation is time-expensive as it considers all possible compositions of all the component services. The subgraph of a failed service is replaced by the best-ranked alternative subgraph. The replacement patterns simply consider the functional and non-functional differences between the new subgraph and replaced subgraph containing the failed service. The proposed approach is highly time-consuming and limited to considering only the sequential digraphs. A region-based service reconfiguration approach is proposed to repair multiple failed services and satisfy the original end-to-end QoS constraints in \cite{5175901}. A reconfiguration region is composed of one or more failed services. When one or more services in a service composition fail at runtime, they try to replace only those failed services. The proposed approach uses Mixed Integer Programming (MIP) to recompose each region until all regions have a satisfactory composition. Generally, MIP methods are very effective when the size of the problem is small. However, these methods suffer from poor scalability due to the exponential time complexity of the applied search algorithms. Yu and Lin \cite{1452105} proposed two algorithms to solve service failures. The proposed algorithms compose offline backup service paths for each component service. When a component service incurs a failure, the predecessor of the failed service quickly switches to a backup path to skip the failed service. However, the proposed approach does not consider the QoS in the execution of the composite service. Also, the approach presented can only handle a single point of failure. Because of the dynamic nature of services, the availability of the backing up processes may not be guaranteed when failure happens. A two-phase approach is proposed for the recovery of failed composite services in \cite{Saboohi:2012:FRW:2428736.2428787}. The two proposed phases are the offline phase and the online phase. In the offline phase, the subgraphs of services are calculated and added to a composite service registry. The offline phase pre-calculations can quicken the replacement. The online phase refers to the execution of composite services. Found subgraphs are ranked according to the semantic description of their component services. The online phase comprises forward and backward approaches. Forward recovery approach attempts to reach the original goal of the composite service by retrying or replacing components and continuing the process. If the forward approach fails to accomplish, the backward approach is applied. The proposed recovery approach does not consider the QoS-awareness capabilities and the dynamism of the execution context environment to adapt the most appropriate recovery strategy. Recomposition is a naive solution to handle the problem of service execution time failures \cite{saboohi2013automatic}. However, it is extremely time-consuming which is undesired. A repair approach based on planning graphs is proposed as an alternative to recomposition in \cite{10.1007/978-3-642-17358-5_11}. Repair is a form of heuristic and guided partial recomposition. Repair is time-efficient compared to recomposition while generates solutions of similar quality. The proposed approach is restricted to the composition of deterministic services with simple composition requirements. The presented technique does not consider the QoS criteria, which simplifies the problem. In \cite{7543850}, the service composition problem is transformed into a non-deterministic planning problem for creating workflows with contingency plans. The beforehand planning for failures saves execution time. However, the generation of all possible alternative composition plans is a time-consuming process. A constraint-aware failure recovery approach is proposed to explore the reliability of service composition in \cite{LALEH2018387}. Existing approaches do not consider the constraint verification failures in composite services. They predict failures inside a composite service to reduce the number of service rollbacks upon failure recovery. The proposed solution includes a planning-based service composition approach and a constraint-processing method. The planning-based algorithm constructs constraint-aware composite service plans. The constraint-processing method proceeds with constraint verification in constructed composite service. The proposed approach is restricted to only a small number of possible solutions, i.e., inefficient for a very large number of plans. An adaptive composition approach is proposed to handle the service changes occurring at runtime, for both repair and optimisation purposes \cite{BARAKAT2018215}. The proposed approach adapts to changes as soon as possible in parallel to the execution process. In this way, the interruption time reduces, the chances of a successful recovery increase, and the most optimal solution is produced according to the current state of the environment. The results show that the proposed approach manages to recover from unexpected situations with minimal interruption, even with frequent changes or in the cases where interference with execution is non-preventable. The service paradigm is leveraged to abstract the line segment as a service (e.g., a bus service) for multi-modal travel purposes in \cite{9,7862268}. A service composition framework is proposed for composing spatio-temporal line segment services. A novel spatio-temporal A*-based algorithm is proposed to compose the services. It is assumed that the services are deterministic, i.e., time and availability are unknown in advance. A failure-proof composition approach for Sensor-Cloud services is presented in \cite{10.1007/978-3-662-45391-9_26} considering the dynamic features such as position and time. The proposed approach is based on D*Lite algorithm to deal with the changes in QoS of Sensor-Cloud services at runtime. A spatio-temporal service model is proposed for drone services in \cite{8818436}. A drone delivery function over a line segment in a skyway network is abstracted as a service. A spatio-temporal service model is also proposed for drone delivery services. A spatio-temporal service selection and composition algorithm is proposed to compose line segment services considering QoS properties. The battery capacities and recharging constraints are not considered in the proposed model. A constraint-aware deterministic drone service composition approach is proposed in \cite{10.1007/978-3-030-33702-5_28}. The proposed approach considers the recharging constraints at each station. A skyline approach is presented to select an optimal set of drone services. The drone service composition problem is formulated as a multi-armed bandit tree exploration problem. A lookahead heuristic-based algorithm is developed to compose the selected services. However, the dynamic service environment, the uncertain weather conditions, and the failure in drone services at runtime are not considered in the proposed approach. \textit{To the best of our knowledge, this paper is the first attempt to model the influence of recharging constraints in a drone service environment and resilient composition of drone delivery services}. \section{Constraint-Aware System Model for Drone Services} We propose a constraint-aware system model for drone delivery services. The proposed model includes four main parts: (1) Skyway Network, (2) Drone Services, (3) Effects of Wind Speed and Direction in DaaS, and (4) Constraint-Aware Model for Drone Delivery Services. \subsection{Skyway Network} In this section, we describe the structure of the skyway network in which drone delivery services operate. Let $D = \{d_1, d_2,\ldots, d_n\}$ be a set of $n$ drones and $T = \{t_1, t_2,\ldots, t_m\}$ be a set of $m$ delivery targets. The skyway network is represented as an undirected graph $G = (V, E)$, where $V$ is a set of vertices (or nodes) each of which represents a target and $E$ is a set of edges each of which represents a skyway segment service joining any two vertices. We assume that each vertex is also a recharging station. Each node is assumed to have a \textit{finite number of recharging pads}. $B$ is a set of battery capacities for all the drones. The travelling cost and battery consumed in travelling from node $i$ to $j$ are represented by $c_{ij}$ and $b_{ij}$ respectively. The battery consumption of the drone has a proportional relationship with payload weight, the distance travelled by the drone, and the wind speed and direction. \subsection{Drone Services} We formally defined a model for drone services in our previous work \cite{8818436}. The proposed model includes the formal definitions of DaaS, DaaS composite service, and DaaS composition problem as follows. \textbf{Definition 1: Drone-as-a-Service DaaS}. A DaaS is defined as a delivery function of a drone which takes a package from a pickup location to a delivery location (i.e., longitude and latitude) having a start time and an end time and meeting a set of QoS attributes (e.g., flight range). A DaaS is a 3-tuple $<DaaS\_id, DaaS_{f}, DaaS_q>$, where \begin{itemize} \item[$\bullet$] $DaaS\_id$ is a unique drone service ID, \item[$\bullet$] $DaaS_{f}$ represents the delivery function of a drone over a skyway segment. The location and time of a DaaS are 2-tuples $<loc_s, loc_e>$ and $<t_s, t_e>$, where \begin{itemize} \item $loc_s$ and $loc_e$ represent the pickup location and the delivery location, \item $t_s$ and $t_e$ represent the start time and the end time, \end{itemize} \item[$\bullet$] $DaaS_q$ is an n-tuple $<q_1, q_2,\ldots, q_n>$, where each $q_i$ represents a quality parameter of a DaaS, e.g., flight range. \end{itemize} \textbf{Definition 2: Composite DaaS Service CS}. A CS is required if a single DaaS service is not able to fulfil the delivery request. A CS is an aggregation of atomic drone services which are combined to satisfy a user's request. The QoS attributes for CS are derived from aggregating the corresponding QoS attributes of atomic DaaS services. For example, the delivery cost of a CS is the summation of delivery costs of all atomic DaaS services in a CS. A CS is a 3-tuple $<CSID, CSF, CSQ>$, where \begin{itemize} \item[$\bullet$] $CSID$ is a concatenation of each component DaaS $DaaS_i \in CS$, i.e., $CSID = concat(DaaS_i.id)$ \item[$\bullet$] $CSF$ is a set of functions $\{f_1(DaaS_1), f_2(DaaS_2), \ldots, f_n(DaaS_n)\}$, where each $f_i$ represents the function of corresponding component DaaS $DaaS_i \in CS$ \item[$\bullet$] $CSQ$ is an m-tuple $<Q_1, Q_2, \ldots, Q_m>$, where each $Q_j$ denotes an aggregated value of $j^{th}$ quality parameter of component DaaS $DaaS_i \in CS$. \end{itemize} \textbf{Definition 3: DaaS Composition Problem}. For a given set of DaaS $S_{DaaS} = \{DaaS_1, DaaS_2,..., DaaS_n\}$ services in a skyway network, the DaaS composition problem is to compose the services for delivering a package from a pickup location to a delivery location in minimum time. \subsection{Effects of Wind Speed and Direction in DaaS} The wind is a major environmental factor affecting the drone's performance and flight behaviour \cite{10.1007/978-3-319-99996-8_16}. The wind effect that causes the drone to drift in a certain direction is studied in \cite{selecky2013wind}. They designed a method based on a modified accelerated A* algorithm to take the wind effects into account and generate reachable states. It is assumed that the wind is constant which does not reflect the real-world scenarios. A deadline-constrained routing scheme is presented for delivery drones in \cite{BNCSS102}. The objective of this study is to minimize the energy consumption under wind conditions. We consider the effects of wind speed and direction in dynamic weather conditions. Highly random nature of wind speed and direction (i.e., headwind and tailwind) greatly influences the battery consumption rate and flight range of the drone \cite{doi:10.2514/6.2005-6951} \cite{VAZQUEZ2017304}. We present a model to determine the impact of wind speed and direction on the travel time of a drone. The travel time of a drone increases with headwind and reduces with the tailwind. We calculate the effects of wind speed and direction on travel time using a method in \cite{10.2307/43943662} for a drone travelling from node $i$ to $j$ as follows. \begin{align} \begin{split}\label{eq:1} \delta &= \theta_{ij} - \theta_{WS} \end{split}\\ \begin{split}\label{eq:2} A &= WS.\cos(180-\delta) \end{split}\\ \begin{split}\label{eq:3} C &= WS.\sin(180-\delta) \end{split}\\ \begin{split}\label{eq:4} B &= \sqrt{AS^2-C^2} \end{split}\\ \begin{split}\label{eq:5} GS &= A + B \\ &= WS.\cos(180-\delta) + \sqrt{AS^2-WS^2.\sin^2(180-\delta)} \end{split}\\ \begin{split}\label{eq:6} T_{ij} &= \frac{d_{ij}}{GS} \end{split} \end{align} where, \begin{multicols}{2} \begin{itemize} \item{\makebox[0.5cm]{$\theta_{ij}$\hfill} = bearing from node $i$ to $j$} \item{\makebox[0.5cm]{$\theta_{WS}$\hfill} = wind bearing} \item{\makebox[0.5cm]{$\delta$\hfill} = course correction angle} \item{\makebox[0.5cm]{$WS$\hfill} = wind speed} \item{\makebox[0.5cm]{$A$\hfill} = headwind/tailwind. When $|\delta| < 90$, $A$ is negative and denotes headwind. When $90 < |\delta| \leq 180$, $A$ is positive and denotes tailwind.} \item{\makebox[0.5cm]{$C$\hfill} = wind adjustment angle} \item{\makebox[0.5cm]{$B$\hfill} = wind adjustment angle} \item{\makebox[0.5cm]{$AS$\hfill} = air speed} \item{\makebox[0.5cm]{$GS$\hfill} = ground speed} \item{\makebox[0.5cm]{$d_{ij}$\hfill} = distance between node $i$ and $j$} \item{\makebox[0.5cm]{$T_{ij}$\hfill} = travel time from node $i$ to $j$} \end{itemize} \end{multicols} \subsection{Constraint-Aware Model for Drone Delivery Services} In this section, we first present our previous constraint-aware DaaS composition model for drone delivery services. The constraint-aware composition means to compose the drone services knowing the availability of recharging pads at intermediate stations and the arrival of other drone services. In our previous work \cite{10.1007/978-3-030-33702-5_28}, we assume all the drone services and service environment are deterministic, i.e., the QoS attributes of drone services, the availability of recharging pads, and the trajectory of other drone services are all known beforehand. Our objective was to compose the drone services avoiding the congested recharging stations and delivering the packages in the shortest time. However, such an assumption of the deterministic service environment is not realistic in practice. The QoS may fluctuate and fail due to the dynamic nature of drone services and changing wind patterns. We relax the assumption of the deterministic service environment. We consider that the service environment is stochastic and flight time may vary with the changing wind conditions and the arrival of other drone services. We compose the drone services to generate an initial service composition plan using our previous deterministic approach. Different types of drones have varying payloads, flight ranges, and battery capacities. There is a constraint that the same drone delivers the package from source to destination. A drone can either \textit{recharge, wait, or travel from one station to the next station}. The deterministic approach estimates the \textit{arrival time, waiting time,} and \textit{recharging time} of each drone at a specific recharging station. The initial composition plan adapts to the failures \textit{dynamically} occurred at runtime. Here, failure means the late or early arrival of drones than the scheduled arrival in the initial plan. This failure may have a \textit{cascading effect} to the execution of subsequent drone services, thus affecting the initial composition. Therefore, a resilient DaaS composition framework is required to ensure the on-time delivery of drone services. \section{Drone Service Selection using Skyline Approach} The first step to compose drone services is the selection of appropriate candidate services. For this purpose, we consider several drone services from multiple service providers. The QoS properties of drone services distinguish among functionally equivalent services. Some of the available drones may not carry the package because of its higher weight. Therefore, we use the difference between the payload capacity of the drone and package weight to filter out the candidate drone services. We use skyline approach \cite{914855}\cite{5552749} to further reduce the number of candidate drone services by selecting only the non-dominated services. Skyline computation \textit{speeds up} the service selection process and selects the services with \textit{best QoS attributes}. Skyline approach is also used to deal with the uncertainty of service in the process of selection \cite{Papadias:2003:OPA:872757.872814}. A multi-attribute optimization technique, called service skyline computation, guarantees to provide the best user-desired service providers \cite{Yu2012}. For a given set $DaaS = \{DaaS_1, DaaS_2, \ldots, DaaS_n\}$ of functionally similar drone services and a set $Q = \{q_1, q_2, \ldots, q_m\}$ of QoS attributes, we present formal definitions of drone service domination and service skyline as follows. \textbf{Definition 4: Drone Service Domination}. The domination relationship between a drone service $DaaS_i \in DaaS$ and another drone service $DaaS_j \in DaaS$ is defined as $DaaS_i \prec DaaS_j$, if $\forall q_k \in Q $, $q_k(DaaS_i) \preceq q_k(DaaS_j)$, and $\exists q_l \in Q $, $q_l(DaaS_i) \prec q_l(DaaS_j)$ where $\prec$ denotes better than and $\preceq$ denotes better than or equal to relationship. \textbf{Definition 5: Service Skyline}. The service skyline comprises a set of drone services, denoted by $SKY_{DS}$, that are not dominated by any other drone service, i.e., $SKY_{DS} = \{DaaS_i \in DaaS | \neg\exists DaaS_j \in DaaS : DaaS_j \prec DaaS_i\}$. We compute the skyline using the following three QoS properties: (1) \textit{flight time} (in minutes) represents the time duration a drone can fly with battery charged to its capacity, (2) \textit{flight range} (in kilometres) represents the distance a drone can travel with full capacity charge, and (3) \textit{recharging time} (in hours) for 0 to 100\% recharge. We use \textit{Block Nested Loop (BNL)} algorithm \cite{914855} for skyline computation. The non-dominated skyline services are obtained by repetitive scanning of the candidate drone services. The \textit{BNL} algorithm can be used for any dimensionality without requiring any indexing or storage. It performs well most of the time for dealing with our low dimension and small domain range data. Table \ref{tab:table1} presents an example of skyline computation for functionally similar drone services that are differed in QoS properties. For instance, a drone service $DaaS_7$ dominates another drone service $DaaS_9$ according to aforementioned domination relationship. The ``Is skyline?" column illustrates the outcome of skyline computation. \begin{table}[t] \centering \scriptsize \caption{A set of functionally similar Drone services} \label{tab:table1} \resizebox{\columnwidth}{!}{\begin{tabular}{|c|c|c|c|c|c} \hline \textbf{Drone service} & \textbf{Flight time (min)} & \textbf{Flight range (km)} & \textbf{Recharging time (hours)} & \textbf{Is skyline?} \\ \hline $DaaS_1$ & 20 & 0.8 & 1.5 & No \\ \hline $DaaS_2$ & 20 & 56 & 2 & Yes \\ \hline $DaaS_3$ & 25 & 8 & 1 & Yes \\ \hline $DaaS_4$ & 30 & 7 & 1.5 & No \\ \hline $DaaS_5$ & 20 & 1.6 & 1.5 & No \\ \hline $DaaS_6$ & 18 & 0.8 & 1.5 & Yes \\ \hline $DaaS_7$ & 120 & 100 & 2 & Yes \\ \hline $DaaS_8$ & 20 & 3 & 1 & Yes \\ \hline $DaaS_9$ & 27 & 7 & 1 & No \\ \hline $DaaS_{10}$ & 40 & 1.9 & 1.5 & No \\ \hline $DaaS_{11}$ & 22 & 5 & 1.5 & Yes \\ \hline $DaaS_{12}$ & 24 & 8 & 1.5 & Yes \\ \hline \end{tabular}} \end{table} \section{Resilient Drone Service Composition Framework} We divide the resilient drone service composition framework into two categories: (1) Constraint-Aware Drone Service Composition using Lookahead and (2) Resilient Drone Service Composition using Adaptive Lookahead. Fig \ref{fig6} presents an overview of the resilient drone service composition framework. The initial offline composition is provided by constraint-aware drone service composition in a deterministic fashion. While the resilient online composition is carried out to handle the dynamic failures in the initial offline composition at runtime. \begin{figure} \centering \includegraphics[width=\textwidth]{fig6.pdf} \caption{Resilient Drone Service Composition Framework} \label{fig6} \end{figure} \subsection{Constraint-Aware Drone Service Composition using Lookahead} We formulate the constraint-aware drone service composition as the multi-armed bandit tree \cite{Coquelin:2007:BAT:3020488.3020497} exploration problem. In multi-armed bandits, an arm denotes an action or a choice which is initially unknown to the player. If the arms are deterministic, i.e., known beforehand, the problem would be reduced to the selection of arms with the highest reward. We assume that the drone services and the services environment are initially deterministic. Our target is to maximize the reward by selecting optimal arms. A drone can take the following set of actions at each station: recharge, wait, or travel from one station to the next. These actions generate a large set of possible states. Fig. \ref{fig2} presents an example of a temporal state tree. We formally define a state as follows: \textbf{Definition 5: State}. A state is a tuple of $<NodeID, TimeStamp>$, where \begin{itemize} \item[$\bullet$] $NodeID$ is a unique node identifier, \item[$\bullet$] $TimeStamp$ represents the arrival time of drone at a certain node. \end{itemize} For the sake of simplicity, we consider that the states are known beforehand. In case of immediate state selection, the temporal optimal neighbour state may lead to a non-optimal state, e.g., long waiting time due to congestion at the next station. \begin{figure} [t] \centering \includegraphics[width=\textwidth]{fig2.pdf} \caption{An example of a state tree} \label{fig2} \end{figure} The selection and composition of optimal drone services from a large number of candidate services is a challenging task. The uncertainty is the main issue in a DaaS composition. In many cases, an immediate optimal service may lead to a non-optimal service. For example, we have a skyway network where node 1 is the source node and node 5 is the destination node. Here we find a temporal optimal neighbour leading to a non-optimal state. Temporal optimal means taking towards destination faster. As shown in Fig. \ref{fig2}, the service of state [2, $t_1$] is optimal but the overall delivery time is more compared to state [3, $t_2$]. This uncertainty can cause long delays for drones to deliver packages. Looking for all possible service compositions or deep tree exploration is not computationally feasible to find the best composition. The time complexity for such problems is exponential. Hence, we need a heuristic-based solution to find the optimal composition of drone services. \begin{figure} [t] \centering \includegraphics[width=\textwidth]{fig3.pdf} \caption{State selection without lookahead} \label{fig3} \end{figure} We propose a lookahead heuristic-based solution to the multi-armed bandit tree exploration problem. The selection of optimal actions in a DaaS composition is performed by looking ahead of neighbour services. We consider the current waiting time, expected waiting time, and flight time to the destination for selection of optimal drone services. The term lookahead means considering the next-to-adjacent states while making the state selection decision. Fig. \ref{fig3} and \ref{fig4} illustrate the difference between without lookahead and with one lookahead based service (state) selection. Without lookahead considers only the neighbour optimal states which leads to an overall non-optimal solution. Using lookahead heuristic provides more information to select the overall optimal states. We build our initial composition plan using the aforementioned lookahead strategy. But, this approach does not take into account the runtime failures in the execution of the initial composition plan such as uncertain weather conditions. We need a resilient composition approach for drone services to ensure the in-time package delivery. \begin{figure} [t] \centering \includegraphics[width=\textwidth]{fig4.pdf} \caption{State selection with one lookahead} \label{fig4} \end{figure} \subsection{Resilient Drone Service Composition using Adaptive Lookahead} The underlying initial DaaS composition approach is formulated as a multi-armed bandit problem \cite{10.1007/978-3-030-33702-5_28}. Multi-armed bandits are a special type of sequential decision problems which demonstrate exploration and exploitation trade-offs and produce maximum rewards under uncertainty \cite{villar2015multi}. The exploration refers to trying each possible action to find an optimal reward. In contrast, exploitation refers to trying the actions that are believed to provide higher payoffs in the future. We focus on the constraints at recharging stations and dynamic weather conditions. However, multi-arm bandits are generally proposed for tree-based search exploration in the context of combinatorial optimization \cite{7969356}. An exact approach such as MILP does not naturally fit to solve such exploratory optimization \cite{RADMANESH2016149}. MILP approaches are usually applied in solving deterministic linear optimization problems \cite{lin2012review}. While heuristic-based lookahead \cite{NIPS2017_6785}, genetic algorithm \cite{Berro2010}, and tabu search \cite{soykan2016hybrid} are usually used for exploratory optimization problems. We focus on the adaptive lookahead heuristic-based approach which is typically used to solve combinatorial multi-armed bandit problems \cite{10.1145/1273496.1273587}. The heuristics are widely used in multi-armed bandit literature and provide substantially more efficient solutions than traditional optimization approaches \cite{NIPS2019_9592}. Therefore, we focus on exploring a heuristic-based solution for the composition of drone services. The stochastic arrival of other drone services at intermediate stations and the changes in wind pattern influence the initial composition plan. As a result, the established composition plan may become non-optimal and fail. Such failures may impact on the initial composition in two ways: (1) local impact (2) global impact. The term local impact means the effect of failure propagates to a certain number of recharging stations. The rest of the plan is still recoverable. The term global impact refers to the propagation of failure effect till the destination. \begin{figure} [t] \centering \includegraphics[width=\textwidth, height=8cm]{fig13.pdf} \caption{State selection using adaptive lookahead} \label{fig13} \end{figure} \begin{figure} [t] \centering \includegraphics[width=\textwidth, height=8cm]{fig5.pdf} \caption{An example of initial composition plan failure and its impact} \label{fig5} \end{figure} We propose a resilient drone service composition using adaptive lookahead heuristic-based approach. The resilient means that the delivery operation is successfully carried out even the established composition plan adapts to the failures. We require a lookahead algorithm to handle time-varying constraints and weather conditions. The adaptive lookahead performs lookahead according to the type of failure occurred rather than a fixed number of lookaheads. There is only one difference between an adaptive lookahead and a standard lookahead algorithm: the distance in adaptive lookahead is no longer a fixed length but varies with the propagation effect of the failures. Once the adaptive lookahead finds the distance of failures, we locally recompose the drone services from the current station to the next failure-free station. The state selection using adaptive lookahead approach is shown in Fig. \ref{fig13}. The selective states of initial composition plan are represented by green colour. Failure occurs at node 3 which requires the recomposition of services. We recompose the services until the next state where no change is observed. Fig. \ref{fig5} presents an example of initial service composition, failed service, and its impact on other services. We first compute an initial offline composition plan from source to destination, denoted by a sequence of solid line arrows connecting green colour nodes. The initial composition plan avoids the congested recharging stations (yellow colour nodes) for faster delivery services. A failed service is represented by a red colour node and its impact on the next services in the initial plan is shown by orange colour nodes. The formal definitions of failure, service failure, and resilient service composition are given as follows. \textbf{Definition 6: Failure}. A failure is defined as the deviation from expected (specified) behaviour. In some cases, the failure may result in the termination of the ability to perform the required function. \textbf{Definition 7: Service Failure}. Service failure is defined as an event that occurs when the delivered service deviates from the correct service. For example, a drone service $DaaS_i$ is specified to reach a station $Station_j$ at $04:00$ pm. If $DaaS_i$ reaches at $Station_j$ before or after $04:00$ pm, we say that the service is failed. \textbf{Definition 8: Resilient Service Composition}. Resilience refers to the ability or capacity of a system to adapt to dynamic changes (failures) without deviating from the expected behaviour. Resilient service composition is a mechanism for handling the failures occurred at runtime. When one or more services fail at runtime, the resilient service composition approach locally or partially recomposes the failed services to deliver the expected behaviour. Fig \ref{fig6} illustrates the process of resilient drone service composition. We first execute the initial offline composition plan. The failure detection module periodically checks for any failures at each station. Each drone service has a certain deadline for each station defined in the initial offline plan. We compare the current arrival time of a drone service with an expected arrival time given by the established plan. In the case of the early or late arrival of a drone service, the failure is detected. The failure analysis module finds the number of services affected due to failure. The failure may affect the execution of a couple of next drone services. The adaptive lookahead tree exploration module guarantees the exploration of all possible alternatives to the failed service. Finally, we locally recompose the explored alternatives to mitigate the effect of failure. The recomposition of drone services at the intermediate station obtains an optimal composite service in minimal computational time. \begin{algorithm}[t] \caption{Resilient Drone Service Composition Algorithm}\label{alg:algorithm1} \begin{algorithmic}[1] \Procedure {Execute\_Init\_Plan} {$InitComp$} \State $DaaS_{cur} \gets InitComp [start]$ \State $DaaS_{dst} \gets InitComp [end]$ \While{$DaaS_{cur} \ne DaaS_{dst}$} \State Execute initial composition plan \State Monitor the execution to find the failed services \State $fd \gets$ failure\_detection ($DaaS_{cur}.t_e, curTime$) \If{$fd$} \State $DaaS_{affected} \gets$ failure\_analysis ($InitComp, DaaS_{cur}$) \State $LocalComp \gets$ recompose ($InitComp, DaaS_{cur}, DaaS_{affected}, curTime$) \State $InitComp \gets$ update\_plan ($InitComp, LocalComp, DaaS_{cur}$) \EndIf \State $DaaS_{cur} \gets InitComp [next\_DaaS]$ \EndWhile \EndProcedure \end{algorithmic} \end{algorithm} \begin{algorithm}[t] \caption{Failure Analysis}\label{alg:algorithm3} \begin{algorithmic}[1] \Procedure{failure\_analysis}{$InitComp, DaaS_{cur}$} \State $failedDaaS \gets 1$ \State Find first congested node $CongNode$ from $DaaS_{cur}$ to the destination \If{$CongNode$} \State $DaaS_{affected} \gets$ compute number of services from $DaaS_{cur}$ to $CongNode$ \EndIf \For {each $DaaS \in InitComp$ from $DaaS_{cur}$} \State $td \gets$ compute time difference between actual and expected $DaaS$ \If{$td \geq 0$} \State $failedDaaS \gets failedDaaS + 1$ \Else \State break \EndIf \EndFor \State \Return min($DaaS_{affected}, failedDaaS$) \EndProcedure \end{algorithmic} \end{algorithm} \begin{algorithm} \caption{Recomposition of Drone Services}\label{alg:algorithm4} \begin{algorithmic}[1] \Procedure{recompose}{($InitComp, DaaS_{cur}, Ld_{adapt}, curTime$)} \State $srcLocal = DaaS_{cur}$ \State $dstLocal = InitComp[DaaS_{cur}.index + Ld_{adapt}]$ \State $startTime = curTime$ \State $newComp = $ find\_optimal\_comp ($G, RP, D, srcLocal, dstLocal, w,$ $ Ld_{adapt}, WS, \theta_{WS},startTime $) \State \Return $newComp$ \EndProcedure \end{algorithmic} \end{algorithm} Algorithm \ref{alg:algorithm1} provides the details of the proposed approach as follows. The algorithm generates a resilient composition of drone services using an initial composition plan as input. The first and last component services in the initial plan are the source and destination locations (Lines 2-3). We execute the initial plan and monitor periodically for any failure at runtime (Lines 4-6). The initial plan is executed smoothly until a failure is detected (Line 7). The actual arrival time at each station is compared with the expected arrival in the initial plan. If a failure is detected, the failure analysis algorithm computes the affected (i.e., failed) drone services (Line 9). Algorithm \ref{alg:algorithm3} presents the details of the failure analysis algorithm. We find the first congested node in the initial plan from the failed service until the destination. If a congested node is found, we simply compute the number of services from the current failed service to the congested node. Moreover, we find the first unaffected service from the failed service until the destination. We calculate the difference between the first failed service and unaffected service in the initial plan. The minimum of distance (i.e., nodes) is selected from the congested node and unaffected service. We consider the congested node for failure analysis because the delay of service failure results in less waiting time at a congested node. For example, a service failure causes 15 minutes delay to the initial composition plan. Let's assume that there is a congestion node in the initial plan ahead of failed service. The waiting time on the congested node is 25 minutes for the availability of recharging pad. In such a case, the waiting time will be reduced to 10 minutes because of 15 minutes delay from failed service. The adaptive lookahead distance is equivalent to the number of affected drone services for exploration of all possible alternatives. We recompose the services from the failed position to next unaffected drone service using recompose algorithm (Line 10). The details of recompose algorithm are given in Algorithm \ref{alg:algorithm4}. The recompose algorithm composes the services locally by calling the $find\_optimal\_comp$ function which is same as our drone service selection and composition algorithm in \cite{10.1007/978-3-030-33702-5_28}. Finally, the new locally composed drone services update the inconsistent affected services in our initial composition plan. This process continues until the package is delivered to the destination. An alternative to the use of local recomposition is to replicate the delay in the initial service composition till the destination. This alternative approach may result in longer delays, and in some cases, the package may not be delivered. \section{Experiments and Results} We evaluate the effectiveness of the proposed resilient drone service composition approach in this section. A set of experiments are conducted to assess the performance of the proposed approach. We compare the proposed approach with a baseline (i.e., Brute-Force) approach and a without lookahead approach. The most important features of the drone delivery services are the shortening of the delivery time and cost reduction. The delivery cost is a function of drone travelling distance. Therefore, we mainly focus on three evaluation metrics: (1) \textit{delivery time}, (2) \textit{computation time}, and (3) \textit{distance travelled}. All the experiments are conducted on an Intel Core i9-9900X processor (3.50 GHz) with 32.0 GB memory under Windows 10. Python is used to implement the algorithms. \subsection{Experimental Setup} Simulation tools offer a faster, cost-effective, and safe approach to assess the performance of possible solutions before physical testing. There exists several simulators for drones, e.g., AirSim \cite{10.1007/978-3-319-67361-5_40}, Gazebo \cite{1389727}, and JMavSim \cite{babushkin2018jmavsim}. These simulators are not specifically designed for drone delivery services over skyway networks with recharging stations. For example, AirSim does not model drone energy consumption in dynamic environments \cite{DBLP:journals/corr/abs-1906-00421}. Energy is a scarce resource in drones that affects the entire delivery operation. The AirSim platform does not implement payload effects on the power consumption of the drone. The failures in delivery services are not considered in AirSim. The skyway network for drone delivery services is also not a part of the AirSim platform. As the centre of our paper is the drone-based delivery platform, we implement a custom drone-based delivery simulation model for the experiments. In future, we plan to deploy a skyway network and delivery management framework on AirSim for greater reachability to the research community. \begin{figure} [t] \centering \includegraphics[width=\textwidth, height=6cm]{fig16.pdf} \caption{Structure of drone simulation model} \label{fig16} \end{figure} We design a custom drone simulation model using tools from drone energy consumption model \cite{9091085}, weather model \cite{roubeyrie2018windrose}, operations research, i.e., delivery service management \cite{hadjimichael2020rhodium}, and 2D path planning \cite{SciPyProceedings_11}. The simulation model consists of the following modules (as shown in Fig. \ref{fig16}): (a) \textit{controller}, (b) \textit{energy module}, (c) \textit{flight path module}, (d) \textit{weather module}, (e) \textit{request dispatcher}, (f) \textit{failure detection module}, (g) \textit{failure recovery module}, and (h) \textit{skyway network}. The controller module ensures the long-term stability of drone delivery services. It keeps track of all types of manoeuvres in the dynamic environment. The controller realizes the desired composition objectives by handling more and more services at each step. The energy module simulates the energy consumption of a drone service travelling from one recharging station to the next station. The energy consumption is calculated using the method in \cite{9091085}. An initial flight path is generated using our existing deterministic offline composition approach. The flight path module contains the composed services and position information of the drone services operating in the skyway network. The flight path is updated to maintain the resilience of composite services under dynamic weather conditions. The changing weather conditions influence the initial composition plan. The weather module is in charge of generating weather data for the whole simulation. The request dispatcher module takes care of receiving drone service requests from users. The current implementation of drone simulation model deals with single package delivery service request. The failure detection module monitors the execution of the initial composition plan. If a failure occurs due to dynamic weather conditions or stochastic arrival of other drone services, it notifies the failure recovery module. The failure recovery module is responsible for the execution of two main actions: (1) estimation of the failure impact and (2) local recomposition of affected drone services. As there is no 3D graphics involved (to simulate 3d drones), we do not require high capacity GPU. The simulation environment and composition algorithms are written in Python. \begin{table}[t] \centering \caption{Dataset Description} \label{tab:table2} \begin{tabular}{|p{1.75cm}|p{6.75cm}|p{2.4cm}|} \hline \textbf{Attribute} & \textbf{Description} & \textbf{Example value}\\ \hline Drone name & Represents the manufacturer of the drone & DJI M200 V2 \tablefootnote{https://www.dji.com/au/matrice-200-series-v2/info\#specs} \\ \hline Payload & Represents the weight a drone can carry (in kilograms) & 1.45 kg \\ \hline Flight time & Represents the time a drone can fly with full payload capacity (in minutes) & 24 min \\ \hline Range & Represents the distance a drone can cover with full payload capacity (in kilometres) & 32.4 km \\ \hline Speed & Represents the flying speed of a drone with full payload capacity (in kilometres per hour) & 81 km/h \\ \hline Recharging time & Represents the time required by a drone for recharging from 0\% to 100\% (in hours) & 2.24 hours \\ \hline \end{tabular} \end{table} We use NetworkX \cite{SciPyProceedings_11} python library to construct the topology of the skyway network. We model the multiple delivery drones operating in the same skyway network. We evaluate the proposed approach using a real drone dataset \cite{14}. The dataset contains the trajectories of drones, which include data for coordinates, altitude, and timestamps. We augment a dataset for different types of drones considering the flight range, payload, battery capacity, speed, and recharging time. The details of the dataset are given in Table \ref{tab:table2}. The efficiency of the proposed framework depends on the values of the environmental variables. Table \ref{tab:table3} describes the environmental variables used in the experiments. The number of drones varies from 50-80 for varying sizes of the skyway network. We assume that each node is a recharging station. The number of nodes (i.e., recharging stations) varies from 10-60 for all approaches. Each recharging station has a finite number of recharging pads. The number of skyway segment DaaS services depends upon the size of the skyway network and the number of interconnected nodes. The proposed approach focuses on the single package delivery services from a given source to a destination. Each experiment starts with a random source and a destination point. The service failures occur randomly at runtime. The frequency of failures in each experiment varies from 10-50\% times the total number of nodes. The effect of each failure varies from a couple of subsequent nodes to the destination node. We conducted the experiments for 10\% times the total number of nodes and computed the average results. \begin{table}[t] \centering \caption{Experiment Variables} \label{tab:table3} \begin{tabular}{|l|l|} \hline \textbf{Variable} & \textbf{Value} \\ \hline Number of drones & [50, 80]\\ \hline Number of nodes (or recharging stations) & [10, 60] \\ \hline Number of recharging pads at each station & 5 \\ \hline Number of DaaS services & [500, 2500] \\ \hline Number of generated requests & 1500 \\ \hline Average battery consumption rate with 1 kg package & 25\%/10 km \\ \hline Number of sources & 1 (random) \\ \hline Number of destinations & 1 (random) \\ \hline Frequency of failures (\% times the total nodes) & [10, 50] \\ \hline Experiment run (\% times the total nodes) & 10 \\ \hline \end{tabular} \end{table} \subsection{Baseline Approach} To the best of our knowledge, this paper is the first attempt for a resilient drone service selection and composition in dynamic weather conditions. To evaluate our proposed approach, we compare the resilient drone service composition algorithm with Brute-Force algorithm. The Brute-Force approach is an all-paths search method. We apply the Brute-Force approach as a baseline to generate the ground truth of optimal compositions. We use Brute-Force in two phases of experiments to find optimal service compositions. In the first phase of experiments, Brute-Force approach finds all the possible compositions of drone services from a given source to a destination. We then select an optimal composition based on the QoS parameters of drone services. In the second phase of experiments, Brute-Force approach is used for the global recomposition of services to handle the service failures at runtime. Global recomposition refers to composing services from the failed point until the destination. Whenever a service failure occurs, Brute-Force approach finds all the possible compositions from current failed service until the destination. Finding all possible compositions of drone services is time exponential which is undesired. This significantly reduces the performance of Brute-Force approach to find optimal drone service composition and limits its use for large-scale problems. \subsection{Without Lookahead Approach} We use without lookahead approach in comparison to the proposed lookahead heuristic-based approach. The without lookahead approach behaves similar to a greedy shortest path algorithm. It always selects the least travel distance services leading towards the destination. The without lookahead approach has a higher probability to fail under dynamic weather conditions. For example, the initial composition plan and expected delivery time may be highly affected by adverse wind. Because of its greedy nature, the without lookahead is fast compared to baseline Brute-Force approach and the proposed lookahead approach. Sometimes, the selection of least travel distance services leads to the congested nodes which may result in longer delays for the availability of recharging pads. \subsection{Results and Discussion} The proposed approach performs composition of selective services based on certain parameters to reach the destination faster. We first generate an initial service composition plan and compare the Brute-Force, without lookahead, and lookahead approaches. We consider three evaluation parameters for comparison as follows: (1) average computation time, (2) average delivery time, and (3) average distance travelled. We then compare the Brute-Force and adaptive lookahead heuristic-based approaches dealing with the runtime service failures. \subsubsection{Results for Initial Offline Service Composition} \textbf{1) Average Computation Time:} The baseline Brute-Force approach is not time-efficient. The computational time for drone service composition using Brute-Force approach is very high in comparison to without lookahead and proposed lookahead heuristic-based approaches. The computation time increases due to the increasing number of possible compositions for drone services. Fig.~\ref{fig:fig7.pdf} compares the average computation time for Brute-Force, without lookahead, and proposed heuristic-based approaches. We observe that the proposed approach significantly outperforms the Brute-Force approach by drastically reducing the computational time. This is because the proposed approach avoids expensive computations by looking ahead once per neighbour state. The computation time varies for composing drone services depending upon the number of lookaheads. The higher the number of lookaheads we have, the more computational time is required to compose drone services. \begin{figure} \centering \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig7.pdf} \caption{Average computation time} \label{fig:fig7.pdf} \end{minipage}\hfill \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig9.pdf} \caption{Average delivery time} \label{fig:fig9.pdf} \end{minipage} \end{figure} \textbf{2) Average Delivery Time:} The delivery time of a drone service includes the flight time, recharging time, and waiting time. The selection of a \emph{right} drone service is of paramount importance as it ensures the availability of recharging pads ahead of time minimizing the overall delivery time. Fig.~\ref{fig:fig9.pdf} shows the efficiency of the proposed lookahead approach compared to Brute-Force and without lookahead approaches. The Brute-Force provides the exact solution as it finds all possible compositions. Our proposed approach obtains a near-optimal solution compared to Brute-Force approach. However, the time complexity of the proposed approach is much better than the baseline Brute-Force approach. Our proposed approach delivers the package 36\% faster than without lookahead approach. The without lookahead approach selects the services without anticipating the congestion conditions ahead which results in higher delivery time compared to our proposed approach. Our proposed approach uses a lookahead search strategy to reduce recharging and waiting times. \begin{figure} \centering \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig11.pdf} \caption{Average distance travelled} \label{fig:fig11.pdf} \end{minipage}\hfill \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig8.pdf} \caption{Average computation time} \label{fig:fig8.pdf} \end{minipage} \end{figure} \textbf{3) Average Distance Travelled:} Some studies investigate the costs associated with drone delivery \cite{doi:10.1111/drev.10313}. The drone delivery cost for a package of 2 kg within a 10 km range is estimated at 10 cents in \cite{5}. For simplicity, we use the distance travelled by a drone as a cost function. Due to dynamic recharging constraints and wind conditions, the immediate drone services with least travel distance cost may lead to congested nodes. Fig.~\ref{fig:fig11.pdf} shows the average travel distances chosen by Brute-Force, without lookahead, and proposed heuristic-based approaches. The without lookahead approach always selects the least travel distance services, therefore, ends in higher delivery time. The Brute-Force approach always considers the least delivery time services leading towards the destination. Our proposed lookahead approach makes a decision based on next-to-adjacent node congestion information which results in 6\% improvement in delivery cost than the baseline approach. \subsection{Results for Resilient Online Composition} When a service failure occurs at any point during the execution, we recompose the services to meet the delivery demands. We use the Brute-Force approach for the global recomposition of drone service. While we propose adaptive lookahead heuristic-based local recomposition of affected drone services. In this context, global recomposition refers to the recomposition of services from failure point until the destination. The local recomposition refers to the recomposition of only the affected services in the initial composition plan. \textbf{1) Average Computation Time:} The Brute-Force approach is highly time-consuming which is undesired. Whenever a failure occurs, it finds all possible compositions from failure point until the destination. The adaptive lookahead approach finds the best alternative composition from failure point until the next unaffected drone service in the initial composition or the next congested node. In the case of congested node selection, the failure effect on delivery time is compensated by subtracting it from waiting time at that node. Fig.~\ref{fig:fig8.pdf} plots the computation times of the baseline Brute-Force approach and the proposed heuristic-based approach. The computation time increases along with the number of services, which is an expected result. The computational complexity of our proposed approach is more consistent over time and less dependent on the network size. It is impractical to use the baseline approach in real-world scenarios as it is exhausted for large scale problems. \textbf{2) Average Delivery Time:} The delivery time for drone services is highly uncertain when a single drone service cannot fulfil the user's requirements. The inter-dependencies on recharging constraints by other drones affect the overall delivery time of a drone service. At each station, the number of recharging pads are limited which can be occupied by other drones for long time periods. Fig.~\ref{fig:fig10.pdf} shows the comparison of the Brute-Force approach and the proposed approach compared to the initial plan. It shows that the local recomposition provides a near-optimal solution in a significantly shorter period of time compared to the Brute-Force approach. In some cases, only a single composition is possible from a failed point until the destination. In such cases, we simply replicate the delay effect of failures to the subsequent services. We observe that sometimes the Brute-Force approach finds better alternate composition than the original initial plan. \textbf{3) Average Distance Travelled:} When a service failure occurs, the recomposition approach finds alternate routes to ensure the resilient delivery of drone services. In some cases, the travel distances may vary significantly compared to the original plan. Fig.~\ref{fig:fig12.pdf} plots the average travel distances chosen by Brute-Force and the proposed heuristic-based approaches on top of the initial composition plan. We observe that the performance of our proposed approach is almost linear up to 40 nodes in terms of travelling distance and maintains a notable trend even for a higher number of nodes. Our proposed approach saves a substantial amount of time to generate near-optimal solutions. \begin{figure} \centering \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig10.pdf} \caption{Average delivery time} \label{fig:fig10.pdf} \end{minipage}\hfill \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig12.pdf} \caption{Average distance travelled} \label{fig:fig12.pdf} \end{minipage} \end{figure} \textbf{4) Effects of Failure Rate:} We analyze the effects of the increasing number of failure rates on the resilience of delivery time and travel distance. Fig.~\ref{fig:fig14.pdf} and \ref{fig:fig15.pdf} plots the effects of different rates of failures on the average delivery time and distance travelled for the baseline Brute-Force approach and the proposed adaptive lookahead heuristic-based approach. We observe that the proposed approach finds optimal or near-optimal solutions for the increasing number of failure rates. The performance of our proposed approach is close to the Brute-Force approach even when the failure rate is high. Experiments based on the different failure rates demonstrate the effectiveness of our proposed approach in terms of delivery time and distance travelled (i.e., delivery cost). \begin{figure} \centering \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig14.pdf} \caption{Average delivery time} \label{fig:fig14.pdf} \end{minipage}\hfill \begin{minipage}{0.49\textwidth} \centering \includegraphics[width=\textwidth]{fig15.pdf} \caption{Average distance travelled} \label{fig:fig15.pdf} \end{minipage} \end{figure} \subsection{Lessons Learned} We observed several unique features from our experiments with resilient composition during drone delivery operations. First, drones are vulnerable to weather conditions such as wind. The dynamic changes in the service environment may significantly influence the initial composition plan. Second, we may have a high failure rate of drone services due to dynamic weather conditions. The proposed adaptive recomposition algorithm can provide computationally efficient and near-optimal solutions in the dynamic environment. Moreover, the adaptive recomposition algorithm provides significantly better solutions when the number of services is small. Third, the computational complexity of the adaptive recomposition algorithm remains consistent even when the network size becomes large. Fourth, the use of local recomposition techniques over global recomposition techniques provides better practical solutions especially in terms of computational complexity. Finally, the use of global recomposition is impractical in real-world scenarios as it exhausts for large scale delivery networks. \section{Conclusion} We propose a resilient service composition framework for drone-based delivery considering the recharging constraints and dynamic weather conditions. An optimal set of candidate drone services is selected using the skyline approach at the source node in a skyway network. We present a formal model to represent constraint-aware drone services. We propose a deterministic lookahead algorithm to build an initial offline composition plan. We develop a heuristic-based resilient service composition algorithm that adapts to changes in service behaviour at runtime. We run several experiments to illustrate the performance of the proposed approach in comparison to Brute-Force and without lookahead approaches. We found that the proposed approach is runtime efficient and produces significantly better results than the Brute-Force and without lookahead approaches. Moreover, the proposed approach guarantees the resilience of delivery services for the increasing number of failure rates. Hence, it is a more practical solution in real-world applications of drone delivery services. A key limitation of the proposed approach is that the proposed approach does not take into account the handover of packages among different drones at intermediate recharging stations. The handover of packages to spare drones at intermediate recharging stations may assist in minimizing the overall delivery time. We plan to apply new optimization techniques for the handover initiation, the selection of the optimal drone service, and the handover management among different drones. The behaviour of a drone depends on wind patterns such as tailwinds and headwinds in different geographical areas. Another limitation of the proposed approach is that it does not incorporate the changing wind patterns into the drone service model. The proposed approach only focuses on the effects of wind speed and direction on the drone service composition plan. There are several weather conditions that can affect a drone's performance such as precipitation (e.g., rain, snow, hail, and sleet), temperature, cloud cover, and visibility. We intend to consider the effects of different weather conditions on the performance of a drone and exploit deep learning techniques for predicting and forecasting weather patterns. A single drone can deliver multiple small packages from a warehouse to desired destinations in one trip. The proposed resilient composition approach is limited to generate solutions for single package delivery by a drone from a given source to a destination. As future work, we plan to explore different adaptive techniques to extend the proposed approach for multi-package deliveries in a dynamic environment. \subsubsection*{Acknowledgment} This research was partly made possible by DP160103595 and LE180100158 grants from the Australian Research Council. The statements made herein are solely the responsibility of the authors.
{'timestamp': '2020-09-22T02:21:06', 'yymm': '2009', 'arxiv_id': '2009.09549', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09549'}
arxiv
\subsection{Design of ES Attack} \begin{figure*}[!tb] \centering \begin{subfigure}{0.28\textwidth} \centering \includegraphics[width=\linewidth]{figs/steal_0.png} \caption{Initial Steal ($t=0$)} \end{subfigure} \begin{subfigure}{0.28\textwidth} \centering \includegraphics[width=\linewidth]{figs/steal_1.png} \caption{The $1$st Steal ($t=1$)} \end{subfigure} \begin{subfigure}{0.28\textwidth} \centering \includegraphics[width=\linewidth]{figs/steal_2.png} \caption{The $2$st Steal ($t=2$)} \end{subfigure} \begin{subfigure}{0.28\textwidth} \centering \includegraphics[width=\linewidth]{figs/steal_3.png} \caption{The $3$rd Steal ($t=3$)} \end{subfigure} \begin{subfigure}{0.28\textwidth} \centering \includegraphics[width=\linewidth]{figs/steal_4.png} \caption{The $4$th Steal ($t=4$)} \end{subfigure} \begin{subfigure}{0.28\textwidth} \centering \includegraphics[width=\linewidth]{figs/steal_legend.png} \end{subfigure} \vspace{-0.5em} \caption{\textbf{Progress of Data Synthesis During \textit{ES Attack}\xspace.} We compare the synthetic datasets $\mathcal{D}_{\text{syn}}^{(t)}$ (in red), generated by our proposed attack, with the victim's training dataset $\mathcal{D}_{\text{train}}$ (in blue) and the auxiliary dataset $\mathcal{D}_{\text{aux}}$ (in green). The auxiliary dataset $\mathcal{D}_{\text{aux}}$ may share similar input space with the victim's training dataset $\mathcal{D}_{\text{train}}$, but a large space of $\mathcal{D}_{\text{train}}$ cannot be covered by the auxiliary dataset. In our attack, we first initial a randomly generated synthetic dataset $\mathcal{D}_{\text{syn}}^{(0)}$. $\mathcal{D}_{\text{syn}}^{(0)}$ share some attributes with $\mathcal{D}_{\text{train}}$, which might be less than $\mathcal{D}_{\text{aux}}$. During our attacks, $\mathcal{D}_{\text{syn}}^{(t)} (t=1, 2, 3)$ get information from our substitute models and explore more space in $\mathcal{D}_{\text{train}}$ in each iteration. The goal of the attacks is to cover the input space of $\mathcal{D}_{\text{train}}$ as much as possible. Note that the adversary trains the substitute model on a synthetic dataset $\mathcal{D}_{\text{syn}}^{(i)}$, ($i=0, 1, \cdots, N$) in each stealing epoch. As a sum, the substitute model is trained on all the synthetic datasets. } \label{fig:steal} \vspace{-0.5em} \end{figure*} Model stealing attacks aim to build a model $f_s$ that is functionally equivalent to the victim model $f_v$. Theoretically, if the adversary can train the substitute model on all the samples in the input space of $f_v$, the substitute model can achieve the same performance as the victim model. However, it is infeasible to query all the samples in the input space. Therefore, a critical step for model stealing attacks is to explore the input sub-space that represents the task domain $\mathcal{T}$. Adversaries will mimic the behavior of victim models in the input sub-space. \cite{orekondy2019knockoff,correia2018copycat,pal2019framework} leverage public datasets as an auxiliary dataset to train the substitute model to approximate the output of the victim model. The auxiliary data share common attributes with $\mathcal{D}_{\text{train}}$, which can be used to train the substitute model. However, these approaches are not practical due to many reasons: i) Data with shared attributes is not always available. Confidential data such as medical images, financial records are not publicly available. The scarcity of data is still a critical problem in many domains. ii) The relationship between the available auxiliary data on the public domain and the task domain $\mathcal{T}$ is unclear, which brings a challenge to select a proper auxiliary dataset. The rationale for selecting a specific auxiliary dataset is missing in most of the existing approaches. In the experiments, we show that using a randomly generated dataset, a special case of an auxiliary dataset, fails to steal the victim model. iii) The quality of data used for training the substitute model cannot be improved during model stealing. The data samples are fixed in the auxiliary dataset. Therefore, we propose an \textit{ES Attack}\xspace to heuristically explore the potential input space related to task domain $\mathcal{T}$ by learning from the victim model. We outline \textit{ES Attack}\xspace in Algorithm~\ref{alg:attack}. First, \textit{ES Attack}\xspace initializes a randomly synthetic dataset $\mathcal{D}_{\text{syn}}^{(0)}$, which may share few attributes with $\mathcal{D}_{\text{train}}$, most likely fewer than $\mathcal{D}_{\text{aux}}$. Second, \textit{ES Attack}\xspace trains a substitute model $f_s$ based on the samples from the synthetic dataset and their predictions from the victim model. Then, \textit{ES Attack}\xspace can generate a better synthetic dataset using the improved substitute model; in the meanwhile, the better synthetic dataset can help improve the substitute model. In this way, \textit{ES Attack}\xspace iteratively synthesizes the datasets and trains the substitute model to improve the quality of the synthetic dataset and the performance of the substitute model. Eventually, the synthetic datasets will approximate the private training dataset, and the substitute model will approximate the victim model or steal the victim model. Figure~\ref{fig:steal} illustrates the progress of data synthesis during \textit{ES Attack}\xspace. In Figure~\ref{fig:steal}, we compare the synthetic datasets $\mathcal{D}_{\text{syn}}^{(t)}$ (in red) with the victim's training dataset $\mathcal{D}_{\text{train}}$ (in blue) and the auxiliary dataset $\mathcal{D}_{\text{aux}}$ (in green). $\mathcal{D}_{\text{aux}}$ may share similar input space with $\mathcal{D}_{\text{train}}$, but in most cases, adversaries may not know the distance between the distribution of $\mathcal{D}_{\text{aux}}$ and the distribution of $\mathcal{D}_{\text{train}}$. Hence, $\mathcal{D}_{\text{train}}$ may not be fully covered by $\mathcal{D}_{\text{aux}}$. However, after initializing the synthetic dataset $\mathcal{D}_{\text{syn}}^{(0)}$, \textit{ES Attack}\xspace will iteratively improve the synthetic datasets $\mathcal{D}_{\text{syn}}^{(t)} (t=1, 2, 3, 4, \ldots)$, and explore more space in the training dataset $\mathcal{D}_{\text{train}}$. Two key steps in \textit{ES Attack}\xspace, E-Step and S-Step, are described as follows. \par\noindent \textbf{E-Step: } Estimate parameters in the substitute model on the synthetic dataset using knowledge distillation. The knowledge distillation approach transfers the knowledge from $f_v$ to $f_s$ with minimal performance degradation: \begin{equation} \label{eq:estep} f_s^{(t)} \gets \argmin_{f_s} \mathrm{L}_{\text{KD}}(f_s, f_v;\mathcal{D}_{\text{syn}}^{(t-1)}), \end{equation} where $f_s^{(t)}$ denotes the substitute model at iteration $t$ and $\mathcal{D}_{\text{syn}}^{(t-1)}$ denotes the synthetic dataset at the previous iteration $t-1$. The objective function $\mathrm{L}_{\text{KD}}$ is defined as knowledge distillation loss to make $f_s^{(t)}$ approximate the victim model $f_v$: \begin{equation} \mathrm{L}_{\text{KD}}(f_s, f_v; \mathcal{D}_{\text{syn}}) = \frac{1}{|\mathcal{D}_{\text{syn}}|}\sum_{\bm{x} \in \mathcal{D}_{\text{syn}}}\mathrm{L}_{\text{CE}}(f_s(\bm{x}), f_v(\bm{x})), \end{equation} where $L_{\text{\text{CE}}}$ denotes the cross-entropy loss. We train the substitute model by minimizing the objective function (Equation~\ref{eq:estep}) for $M$ epochs using Adam~\cite{kingma2014adam}. \par\noindent \textbf{S-Step: } Synthesize the dataset $\mathcal{D}_{\text{syn}}^{(t)} = \{\bm{x}\}$ consisted of the synthetic input samples. \begin{algorithm}[!tb] \caption{\textit{ES Attack}\xspace} \label{alg:attack} \textbf{INPUT}: \\ \text{\quad The black-box victim model $f_v$}\\ \text{\quad Number of classes $K$}\\ \text{\quad Number of stealing epochs $N$}\\ \text{\quad Number of training epochs for each stealing epoch $M$}\\ \textbf{OUTPUT}: \\ \text{\quad The substitute model $f_s^{(N)}$} \begin{algorithmic}[1] \State Initialize a synthetic dataset $\mathcal{D}_{\text{syn}}^{(0)}$ by randomly sampling $\bm{x}$ from a Gaussian distribution. \State Construct an initial substitute model $f_s^{(0)}$ by initializing the parameters in the model. \For{$t \gets 1$ to $N$} \State \textbf{E-Step:} \xy{Estimate the parameters in the substitute model $f_s^{(t)}$ using knowledge distillation for $M$ epochs on the synthetic dataset $\mathcal{D}_{\text{syn}}^{(t-1)}$}. \State \textbf{S-Step:} Synthesize a new dataset $\mathcal{D}_{\text{syn}}^{(t)}$ based on the knowledge of the substitute model $f_s^{(t)}$. \EndFor \State \textbf{return} $f_s^{(N)}$. \end{algorithmic} \end{algorithm} \subsection{Two approaches for Data Synthesis (S-Step)} \label{sec:data_syn} \xy{ Data synthesis (S-step in \textit{ES Attack}\xspace) aims to explore the possible data that reveal the data distribution of the victim's training dataset and benefit the substitute model. The most challenging problem in data synthesis is the lack of gradient of the victim model. The adversary can only get the prediction rather than the gradient from the victim model. Accordingly, the data generated by the adversary cannot be tuned by the victim model directly. The existing approaches used in data-free knowledge distillation fail to be applied in the model stealing attacks, since they require to back-propagate the gradients from the victim model. More discussion about the difference between model stealing and data-free knowledge distillation can be found in Section~\ref{sec:related_knowledge}. To overcome this challenge, we propose two data synthesis approaches that make use of the gradients of the substitute model as a proxy for updating the synthetic input data. Specifically, we introduce two approaches to generate the synthetic data: namely, \textit{DNN-SYN} and \textit{OPT-SYN}. Both approaches start with generating a set of random labels and initial data samples. Further the approaches update the data samples based on the assigned labels and the gradients from the substitute model. Once the substitute model is close to the victim model, the synthetic data becomes close to the distribution of the victim's training dataset. } \subsubsection{DNN-SYN.} \begin{figure}[!t] \centering \includegraphics[width=0.35\linewidth]{figs/acgan.png} \vspace{-0.5em} \caption{\textbf{DNN generator $G$ in \textit{DNN-SYN}.}} \label{fig:acgan} \vspace{-1em} \end{figure} We design a DNN-based generator to synthesize images that can be classified by our substitute model with high confidence. The design of image generator $G$ follows the major architecture of Auxiliary Classifier GAN (ACGAN)~\cite{odena2017conditional}, a variant of Generative Adversarial Network (GAN), which can generate images with label conditioning. We refer to the data generation approach using DNN as \textit{DNN-SYN}. We describe the procedure of \textit{DNN-SYN} as follows: \begin{enumerate}[\textbf{Step} 1:] \item Randomly assign a set of labels $\bm{l}=\{\bm{l_1}, \bm{l_2}, \ldots, \bm{l_n}\}$, where $\bm{l_i}$ denotes a $K$-dimensional one-hot vector. \item Train a DNN generator $G$ with parameter $w_G$ to generate data from a random latent vector $\bm{z_i}$. $G$ is optimized that the generated data can be classified by $f_s$ as assigned labels $L$ with high confidence: \begin{equation} \label{eq:gan} \min_{w_G} \quad \mathrm{L_{\text{img}}}(G, \bm{l}) \buildrel \text{def}\over = \sum_{i}^n \mathrm{L}_{\text{CE}}(f_s(G(\bm{z_i}, \bm{l_i})), \bm{l_i}). \end{equation} \item Generate a synthetic dataset using the generator trained in Step 2: $\mathcal{D}_{\text{syn}} = \{G(\bm{z_i}, \bm{l_i})\}$. \end{enumerate} In addition, mode collapse is one of the critical problems for training GANs. To avoid mode collapse in \textit{DNN-SYN}, we use a mode seeking approach to increase the diversity of data samples~\cite{mao2019mode}. Mode seeking has been shown simple yet effective in mitigating mode collapse. We generate two images $G(\bm{z_i^1})$ and $G(\bm{z_i^2})$ using latent vectors $\bm{z_i^1}$ and $\bm{z_i^2}$ and maximize the ratio of the distance of images to the distance of latent vectors. In other words, we minimize the mode seeking loss $\mathrm{L}_{\text{ms}}$: \xy{ \begin{equation} \mathrm{L}_{\text{ms}}(G, \bm{l}) \buildrel \text{def}\over = \sum_{i}^n \frac{d(\bm{z_i^1}, \bm{z_i^2})}{d(G(\bm{z_i^1}, \bm{l_i}), G(\bm{z_i^2}, \bm{l_i}))}, \end{equation} } where $d(\cdot, \cdot)$ denotes a distance metric. In this paper, we use $\ell_2$ norm distance. We sum up the original objective function $\mathrm{L}_{\text{img}}$ and the regularization term $\mathrm{L}_{\text{ms}}$ and minimize the new objective function: \begin{equation} \mathrm{L_{\text{DNN}}} = \mathrm{L}_{\text{img}} + \lambda \mathrm{L}_{\text{ms}}, \end{equation} where $\lambda$ denotes the hyper-parameter to adjust the value of regularization. In the experiment, we set $\lambda$ as $1$. Figure~\ref{fig:acgan} illustrates the architecture of DNN-based generator in \textit{DNN-SYN}. We follow the major design of ACGAN~\cite{odena2017conditional}. We feed a random latent vector $\bm{z_i}$ and a generated one-hot label $l_i$ into generator $G$. We concatenate these two vectors and up-sample them using several transposed convolution layers. Transposed convolution layers are parameterized by learnable weights. Each transposed convolution layer is followed by a batch normalization layer and a ReLU activation function except the last transposed convolution layer. 4 transposed convolution layers are used in the model. In the final layer, we use a Tanh function to output a synthesis image within $(-1, 1)$. \subsubsection{OPT-SYN.} \begin{algorithm}[!tb] \caption{Data Synthesis of \textit{OPT-SYN}} \label{alg:opt} \textbf{INPUT}:\\ \text{\quad The substitute model $f_s^{t}$ at iteration $t$}\\ \text{\quad Number of synthetic data $S$}\\ \text{\quad Number of output classes $K$}\\ \text{\quad Number of optimization iterations $m$}\\ \textbf{OUTPUT}: \text{\quad A set of optimized data samples $\mathcal{X}$} \begin{algorithmic}[1] \State $\mathcal{X} \gets \emptyset$ \For{$i \gets 1, S$} \State // Generate a $K$-dimensional random parameter $\alpha$ from a Gaussian distribution \State $\bm{\alpha} \sim \mathcal{N}(0, 1)$ \State // Sample a prediction vector $\bm{y}$ from a Dirichlet distribution \State $\bm{y} \sim D(K, \bm{\alpha})$ \State // Initialize a data sample $\bm{x}$ from Gaussian distribution \State $\bm{x} \sim \mathcal{N}(0, 1)$ \State // Minimize Equation~\ref{eq:opt} for $m$ iterations \State $\bm{x}^* \gets \argmin_{\bm{x}} \quad \mathrm{L}_{\text{CE}}(f_s^{(t)}(\bm{x}), \bm{y})$ \State // Add $\bm{x}^*$ to set $X$ \State $\mathcal{X} \gets \mathcal{X} \cup \bm{x}^*$ \EndFor \State \textbf{return}: $\mathcal{X}$. \end{algorithmic} \end{algorithm} Instead of training a generator to synthesize the dataset, we propose an optimization-based data synthesis approach, \textit{OPT-SYN}, which operates on the input space directly and does not suffer the problem of mode collapse. In addition, \textit{OPT-SYN} explores a more diverse label space compared to the one-hot labels used in \textit{DNN-SYN}. \textit{OPT-SYN} first explores the possible prediction vectors $\{\bm{y}\}$ in the task domain $\mathcal{T}$ and then minimizes the cross-entropy loss between $\{\bm{y}\}$ and the substitute model's prediction on the synthetic data: \begin{equation} \label{eq:opt} \min_{\bm{x}} \mathrm{L}_{\text{CE}}(f_s^{(t)}(\bm{x}), \bm{y}), \end{equation} where $f_s^{(t)}$ denotes the substitute model at the $t$th stealing epoch. In the experiments, we find that \textit{OPT-SYN} performs better than \textit{DNN-SYN} does in most scenarios. The proposed \textit{OPT-SYN} approach is detailed in Algorithm~\ref{alg:opt}. First, to explore the possible prediction vectors, we sample each random vector $\bm{y} = \{y_1, y_2, \ldots, y_K\}$ from a $K$-dimensional Dirichlet distribution with parameter $\bm{\alpha}$. Dirichlet distribution is commonly used as conjugate prior distribution of categorical distribution. From the Dirichlet distribution, we can sample prior probabilities $\{y_1, y_2, \ldots, y_K\}$, where $y_i \in (0, 1)$ and $\sum_{i=1}^K y_i = 1$. $\bm{\alpha}$ is referred to as the concentration parameter, which controls the distribution. The probability density function of Dirichlet distribution $Dir(K, \bm{\alpha})$ can be calculated by: \begin{equation} f(y_1, y_2, \ldots, y_K, \bm{\alpha}) = \frac{1}{B(\bm{\alpha})}\prod_{i=1}^K y_i^{\alpha_i -1}, \end{equation} where $B(\bm{\alpha})$ denotes the gamma function and $\sum y_1, y_2, \ldots, y_K = 1$. In the experiment, we randomly sample the parameter $\bm{\alpha}$ from a Gaussian distribution: $\bm{\alpha} \sim \mathcal{N}(0, 1)$ to explore the possible Dirichlet distribution. Given the prediction vector $\bm{y}$, we synthesize data $\bm{x}$ by iteratively minimizing the objective function~\ref{eq:opt}. The goal is to generate a data sample $\bm{x}^*$ that $f_s^{(t)}$ predicts $\bm{x}^*$ close to $\bm{y}$. An adaptive gradient-based optimization algorithm, Adam~\cite{kingma2014adam}, is applied to optimize the objective function iteratively. \subsection{Experiment Setup} \subsubsection{Victim Models and Datasets} In our experiments, we evaluate model stealing attacks on four image classification datasets: MNIST, KMNIST, SVHN, CIFAR-10. The MNIST dataset~\cite{lecun1998gradient} contains 70,000 28-by-28 gray images of 10 digits. We use 60,000 images for training and 10,000 images for testing following the original train/test split in the MNIST dataset. Kuzushiji-MNIST (KMNIST)~\cite{clanuwat2018deep} is a similar dataset to MNIST, containing 70,000 28-by-28 grey images of 10 Hiragana characters. We use 60,000 images for training and 10,000 images for testing. The SVHN~\cite{netzer2011reading} dataset consists of 60,000 32-by-32 RGB images from house numbers (10 classes from 0 to 9) in the Google Street View dataset. The CIFAR10~\cite{krizhevsky2009learning} dataset contains 60,000 32-by-32 RGB images with 10 classes. We train three types of DNN models on four datasets and use them as the victim models in our experiments. We train LeNet5~\cite{lecun1998gradient} on the MNIST~\cite{lecun1998gradient} and KMNIST~\cite{clanuwat2018deep} datasets. We train ResNet18~\cite{he2016deep} and ResNet34~\cite{he2016deep} on the SVHN~\cite{netzer2011reading} and CIFAR10~\cite{krizhevsky2009learning} datasets. LeNet5 is trained for 30 epochs using an SGD optimizer with a learning rate of 0.1 on the MNIST and KMNIST datasets. We train ResNet18 and ResNet34 for 200 epochs with an initial learning rate of 0.1 on the SVHN and CIFAR10 datasets. We reduce the learning rate by 10 after 80 and 120 epochs. We select the models with the highest test accuracies as the victim models. \subsubsection{Settings of \textit{ES Attack}\xspace} For \textit{DNN-SYN}, we input a $100$-dimensional random latent vector and a one-hot label vector into DNN-based generator $G$. The substitute model $f_s$ and DNN-based generator $G$ is trained by an Adam optimizer with a learning rate of 0.001. $f_s$ and $G$ are trained alternatively for 2,000 epochs each on the MNIST, KMNIST, and SVHN dataset ($N=2000, M=1$), and 15,000 epochs each on the CIFAR10 dataset ($N=15000$, $M=1$). For \textit{OPT-SYN}, we synthesize data for $30$ iterations ($M=30$) in each stealing epoch using an Adam optimizer with a learning rate of 0.01. We train the adversary model for $10$ epochs on the synthetic dataset ($M=10$). We repeat the stealing for $200$ epochs on the MNIST, KMNIST, and SVHN dataset ($N=200$), and 1,500 epochs on the CIFAR10 dataset ($N=1500$). To speed up the stealing process, we augment the synthetic dataset by random horizontal flip, horizontal shift, and adding Gaussian noise. \subsubsection{Baseline Model Stealing Attacks} We compare \textit{ES Attack}\xspace with two baseline attacks - model stealing using randomly generated data and auxiliary data. First, if the adversary has no knowledge of the victim's training data, randomly generated data could be the only dataset the adversary can leverage. We form a random dataset with the random data sampled from a Gaussian Distribution $\mathcal{N}(0,1)$ and their prediction from the victim model. We train our substitute model using the random dataset iteratively. Second, we consider public data as an auxiliary dataset. We use data samples from other public datasets and query the victim model with them. We construct an auxiliary dataset and train the substitute model on it. To make a fair comparison, we make sure that all the model stealing attacks, including two baseline attacks and two \textit{ES Attacks} (\textit{DNN-SYN} and \textit{OPT-SYN}), train their substitute models for the same epochs. \begin{table}[!tb] \renewcommand{\arraystretch}{1.3} \centering \caption{Performance comparison of model stealing attacks. } \label{tab:function} \vspace{-0.5em} \begin{tabular}{@{}llclc@{}} \toprule Dataset & Model & \begin{tabular}[c]{@{}c@{}} Victim \\accuracy (\%)\end{tabular} & Attacks & \begin{tabular}[c]{@{}c@{}} Substitute \\accuracy (\%) \end{tabular} \\ \hline \multirow{4}{*}{SVHN} & \multirow{4}{*}{ResNet18} & \multirow{4}{*}{95.40} & Random & 50.71 \\ && & Auxiliary & 74.84\\ && & DNN-SYN & 93.95 \\ && & OPT-SYN & \textbf{93.97}\\ \hline \multirow{4}{*}{SVHN} & \multirow{4}{*}{ResNet34} & \multirow{4}{*}{95.94} & Random & 60.95\\ && & Auxiliary & 82.00 \\ && & DNN-SYN & \textbf{93.34} \\ && & OPT-SYN & 93.19\\ \hline \multirow{4}{*}{CIFAR10} & \multirow{4}{*}{ResNet18}& \multirow{4}{*}{91.12} & Random & 11.72\\ && & Auxiliary & 48.73 \\ && & DNN-SYN & 33.44 \\ && & OPT-SYN & \textbf{84.60}\\ \hline \multirow{4}{*}{CIFAR10} & \multirow{4}{*}{ResNet34}& \multirow{4}{*}{91.93} & Random & 14.45 \\ && & Auxiliary & 38.55\\ && & DNN-SYN & 12.69 \\ && & OPT-SYN & \textbf{80.79}\\ \hline \multirow{4}{*}{MNIST} & \multirow{4}{*}{LeNet5}& \multirow{4}{*}{99.10} & Random & 72.18 \\ && & Auxiliary & \textbf{98.96} \\ && & DNN-SYN & 91.02 \\ && & OPT-SYN & 92.03 \\ \hline \multirow{4}{*}{KMNIST} & \multirow{4}{*}{LeNet5}& \multirow{4}{*}{95.67} & Random & 56.39 \\ && & Auxiliary & 59.43 \\ && & DNN-SYN & 90.37 \\ && & OPT-SYN & \textbf{90.37}\\ \bottomrule \end{tabular} \vspace{-0.5em} \end{table} \subsection{Performance Evaluation} \label{eval:func} We evaluate the performance of \textit{ES Attacks} using two data synthesis approaches and compare them with two baseline attacks. We report the accuracy of model stealing attacks in Table~\ref{tab:function}. We compare the results with two baseline attacks that use randomly generated data (Random) and auxiliary data (Auxiliary) to steal the victim model. From the evaluation, we observe that \textit{OPT-SYN} can successfully steal the victim models over all the datasets and model architectures. Our proposed attacks achieve better performance compared with two baseline attacks. \textbf{On average, \textit{OPT-SYN} improves the best accuracy by 44.57\% compared to the best results of two baseline attacks. } \textit{OPT-SYN} performs as well as \textit{DNN-SYN} on the SVHN, MNIST, and KMNIST datasets. However, \textit{DNN-SYN} cannot achieve a good performance on the CIFAR10 dataset, which is a more complex dataset and the generator $G$ in \textit{DNN-SYN} may still cause the mode collapse problem. Both our proposed attacks perform worse than the attacks using auxiliary data (KMNIST) on the MNIST dataset, which suggests that the auxiliary data can be used in the model stealing if the auxiliary data well-represent the target task and the data are available to the adversary. \begin{figure}[!tb] \centering \begin{subfigure}{0.45\linewidth} \centering \includegraphics[width=\linewidth]{figs/svhn_resnet18.png} \caption{ResNet18 on SVHN} \end{subfigure} \begin{subfigure}{0.45\linewidth} \centering \includegraphics[width=\linewidth]{figs/svhn_resnet34.png} \caption{ResNet34 on SVHN} \end{subfigure} \begin{subfigure}{0.45\linewidth} \centering \includegraphics[width=\linewidth]{figs/cifar_resnet18.png} \caption{ResNet18 on CIFAR10} \end{subfigure} \begin{subfigure}{0.45\linewidth} \centering \includegraphics[width=\linewidth]{figs/cifar_resnet34.png} \caption{ResNet34 on CIFAR10} \end{subfigure} \begin{subfigure}{0.45\linewidth} \centering \includegraphics[width=\linewidth]{figs/mnist.png} \caption{LeNet5 on MNIST} \end{subfigure} \begin{subfigure}{0.45\linewidth} \centering \includegraphics[width=\linewidth]{figs/kmnist.png} \caption{LeNet5 on KMNIST} \end{subfigure} \vspace{-0.5em} \caption{\textbf{Substitute model accuracy during attacks.}} \label{fig:acc} \vspace{-0.5em} \end{figure} Note that we assume that the adversary has no knowledge of any victim's data, which means the adversary cannot evaluate the substitute model on a validation dataset and select the best substitute model during the attack. If the performance of the stealing attacks fluctuates, then the adversary cannot guarantee the best performance of the substitute model. The convergence of the substitute model is essential for stealing attacks without a validation dataset. Our experiments show that the performance of the substitute model converges after a few stealing epochs (Figure~\ref{fig:acc}). If the adversary has the knowledge of a validation dataset or the victim's test dataset $\mathcal{D}_{\text{test}}$, the adversary will achieve the best accuracy. Otherwise, the adversary will use the substitute model in the last stealing epoch ($t=N$). We observe the subtle difference between the best accuracy and the last accuracy achieved by the substitute model (0.79\% difference on average for \textit{OPT-SYN} and 1.53\% for \textit{DNN-SYN}). The stable convergence suggests that our proposed attacks do not rely on a validation dataset. \xy{We find that model stealing attacks do not require a large query budget in real-world settings. The query to the victim model only occurs in the E-Step, where the adversary uses the synthetic data to get the model prediction. In our experiments, to steal the victim model trained on the MNIST, KMNIST, and SVHN dataset using \textit{OPT-SYN}, the adversary only needs to pay \$30K for all the required queries (around 120M queries) according to the pricing of Amazon AWS~\cite{amazon}. For for the CIFAR10 dataset, it costs \$187.5K to steal the victim model (around 750M queries). The expenses are much less than hiring ML experts and collecting data from scratch. This indicates that the adversary can replicate the function of the existing MLaaS models with much less cost than the victim's actual cost of establishing a machine learning service. } \subsection{Sensitivity Analysis of DNN Architectures} \begin{table}[!tb] \renewcommand{\arraystretch}{1.3} \centering \caption{\textit{ES Attack}\xspace using Different DNN Architectures.} \label{tab:arch} \vspace{-0.5em} \begin{tabular}{@{}lllcc@{}} \toprule Dataset & \begin{tabular}[l]{@{}l@{}} Victim \\ model\end{tabular} & \begin{tabular}[l]{@{}l@{}} Substitute \\ model\end{tabular} & \begin{tabular}[c]{@{}c@{}} Victim \\accuracy (\%) \end{tabular} & \begin{tabular}[c]{@{}c@{}} Substitute \\accuracy (\%) \end{tabular} \\ \midrule \multirow{2}{*}{MNIST} & ResNet18 & LeNet5 & 99.31 & 97.28 \\ & LeNet5 & ResNet18 & 92.03 & 98.13 \\\hline \multirow{2}{*}{SVHN} & ResNet18 & ResNet34 & 95.40 & 94.64 \\ & ResNet34 & ResNet18 & 95.94 & 94.03 \\ \hline \multirow{2}{*}{CIFAR10} & ResNet18 & ResNet34 & 91.12 & 82.54 \\ & ResNet34 & ResNet18 & 91.93 & 62.73 \\ \bottomrule \end{tabular} \vspace{-0.5em} \end{table} \xy{In this section, we consider a more realistic scenario where the adversary has no knowledge of the victim model's architecture. The adversary may choose a different architecture of the substitute model from that of the victim model. \xyy{Thus, we investigate when the adversary uses a different neural network architecture from the victim. For the MNIST dataset, we use ResNet18 for the victim model and LeNet5 for the substitute model, and vise versa. For the SVHN and CIFAR10 datasets, we consider ResNet18 and ResNet34 as the victim model and the substitute model's architecture. Because \textit{OPT-SYN} outperforms \textit{DNN-SYN} in most model stealing attacks, we use \textit{OPT-SYN} to evaluate the sensitivity of DNN architectures. From Table~\ref{tab:arch}, we do not observe a significant performance loss due to different DNN architectures for the MNIST and SVHN dataset, compared with using the same architecture. For the CIFAR10 dataset, we observe subtle performance loss using ResNet34 to steal ResNet18 models. The only degradation of performance occurs when the adversary uses a small model ResNet18 to steal a large model ResNet34. } We believe the degradation is due to the gap between the size of the victim model and the substitute model. } We find similar performance degradation in many other tasks using knowledge distillation. The performance of the student model (substitute model in our paper) will be degraded if there is a gap between student and teacher (victim)~\cite{mirzadeh2019improved}. The adversary can easily avoid performance degradation by selecting a large model. From our experiments, if the adversary chooses a DNN model with the same size or the large size compared with the victim model, the adversary will be able to steal a substitute model with high accuracy. \subsection{Convergence of \textit{ES Attack}\xspace} Figure~\ref{fig:acc} illustrates the convergence of \textit{ES Attack}\xspace. We observe that the accuracy of the substitute model always converges at the end of the stealing. We observe the subtle difference between the best accuracy and the last accuracy achieved by the substitute model (0.79\% difference on average for \textit{OPT-SYN} and 1.53\% for \textit{DNN-SYN}). The stable convergence at the end of the attacks suggests that our proposed attacks do not rely on a test dataset. Hence, the adversary can successfully steal the victim model even without knowing test data, which suggests the practicality of \textit{ES Attack}\xspace and substantially raises the severity of model stealing attacks. \subsection{Quality Analysis of Synthetic Data} \label{eval:syn_data} In this section, we investigate the quality of synthetic data. Figure~\ref{fig:syn_data} shows examples of the synthetic data used in model stealing. We compare them with the victim's training data. Humans cannot recognize these images, yet our substitute model can be well-trained using these synthetic data. \input{synthetic_data} Therefore, we further investigate synthetic data in terms of quality and diversity. Inspired by the measurements for GANs, we use Inception Score (IS)~\cite{salimans2016improved} and Fr\'{e}chet Inception Distance (FID)~\cite{heusel2017gans} to evaluate the synthetic data. In the experiments, we observe that the synthetic data achieves better quality and higher diversity compared to the auxiliary data. \textbf{Inception Score (IS)} was originally proposed to measure the quality of generated images using a pre-trained Inception-V3 network. In our experiments, we replaced the Inception-V3 network with the victim models. To be consistent with the concept, we keep Inception Score as the name of our metric. Given the prediction provided by the victim models, Inception Score compares the conditional prediction distribution with the marginal prediction distribution: \begin{equation} \text{IS} = \exp(\mathbb{E}_{\bm{x}} D_{\text{KL}}(p(\bm{y}|\bm{x})) || p(\bm{y})), \end{equation} where $D_{\text{KL}}$ denotes the KL divergence. A high Inception Score indicates: 1) generated images are meaningful and predictable to the victim model, so that $p(\bm{y}|\bm{x})$ has low entropy; 2) generated images are diverse, so that $p(\bm{y})$ has high entropy. \textbf{Fr\'{e}chet Inception Distance (FID)} was proposed to improve IS by comparing the intermediate features of the victim model. FID models the real images and the synthesis data as two multivariate Gaussian distributions and calculates the distance between the two distributions: \begin{equation} \text{FID} = ||\mu_t - \mu_s||_2^2 + Tr(\Sigma_t + \Sigma_s - 2(\Sigma_t\Sigma_s)^{\frac{1}{2}}), \end{equation} where $(\mu_t, \Sigma_t)$ and $(\mu_s, \Sigma_s)$ denote the mean and covariance matrix of intermediate features predicted using training data and synthesis data. $Tr(\cdot)$ denotes the trace of a matrix. A low FID indicates better image quality and diversity. FID is shown to be more consistent with human perception than IS~\cite{heusel2017gans} and more robust to mode collapse~\cite{lucic2018gans}. In our experiments, we used the features from the layer before the last linear layer and compared our synthesis data with the training data using FID. These two metrics are widely used to measure the quality of generated images. \begin{table*}[!tb] \renewcommand{\arraystretch}{1.3} \centering \caption{Analysis of Synthetic Data using IS and FID.} \label{tab:data_eval} \vspace{-0.5em} \begin{tabular}{@{}llr|rr|rr|rr@{}} \toprule \multirow{2}{*}{Dataset} & \multirow{2}{*}{\shortstack{Model}} & \shortstack{Victim $\mathcal{D}_{\text{train}}$} & \multicolumn{2}{c|}{{Auxiliary $\mathcal{D}_{\text{aux}}$}} & \multicolumn{2}{c|}{{Random $\mathcal{D}_{syn}^{(0)}$}} & \multicolumn{2}{c}{{Synthetic $\mathcal{D}_{syn}^{(N)}$}} \\ \cline{3-9} & & IS & IS & FID & IS & FID & IS & FID \\ \hline MNIST & LeNet5 & 9.86 & 4.22 & 274.80 & 1.22 & 500.16 & 4.63 & 257.55 \\ KMNIST & LeNet5 & 9.96 & 4.75 & 1073.92 & 1.78 & 1498.75 & 4.70 & 962.47 \\ CIFAR10 & ResNet18 & 6.89 & 2.58 & 5.34 & 3.45 & 5.82 & 4.32 & 3.31 \\ CIFAR10 & ResNet34 & 7.64 & 4.16 & 18.16 & 6.75 & 14.88 & 6.65 & 18.29 \\ SVHN & ResNet18 & 6.89 & 2.24 & 7.62 & 3.45 & 5.82 & 4.32 & 3.31 \\ SVHN & ResNet34 & 7.64 & 4.16 & 18.16 & 6.75 & 14.88 & 6.65 & 18.29 \\ \bottomrule \end{tabular} \vspace{-0.5em} \end{table*} We compare the four types of data and report the average values of IS and FID in Table~\ref{tab:data_eval}: 1) victim's training dataset, 2) auxiliary dataset used in the baseline attack, 3) random data generated in the first initialization epoch ($t=0$), 4) the synthetic data generated in the last stealing epoch ($t=N$). The value of FID is evaluated by comparing the data with the victim's training data. From our analysis, we find that synthetic data usually achieves better quality and high diversity than the auxiliary data (higher IS value and lower FID value). On average over six settings, synthetic data $\mathcal{D}_{syn}^{(1)}$ achieves 60.58\% higher IS values and 27.64\% lower FID values than the auxiliary data $\mathcal{D}_{\text{aux}}$, which suggests better quality and higher diversity of synthetic images. The victim's training data always achieve the highest IS value: the training data is the best representation of the input space among data we investigate. The Random Data are always the worst data due to the low IS values and high FID values. \subsection{Rounding Prediction} The MLaaS providers fix the decimals of the output prediction and zero-out the rest to provide only the necessary information. For example, if we round the prediction with 2 decimals, then $round(0.2474, r=2) = 0.25$. We deploy rounding predictions with 2 decimals as a defensive strategy. Our experiments show that none of the model stealing attacks are affected by rounding to two decimals (Table~\ref{tab:defense}). On average, the best accuracy of the substitute model even increases by 0.55\% and the last accuracy only decreases by 0.30\%. \begin{table*}[!tb] \renewcommand{\arraystretch}{1.3} \centering \caption{Evaluation of defenses against model stealing.} \label{tab:defense} \vspace{-0.5em} \begin{tabular}{llrrr} \toprule Dataset & \begin{tabular}[l]{@{}l@{}} Model\end{tabular} &\begin{tabular}[l]{@{}l@{}} Accuracy without defense (\%)\end{tabular} &\begin{tabular}[l]{@{}l@{}} Accuracy with rounding (\%)\end{tabular} &\begin{tabular}[l]{@{}l@{}} Accuracy with Top-K (\%)\end{tabular}\\\hline SVHN & ResNet34 & 93.19 & 92.58 & 88.76\\ CIFAR10 & ResNet34 & 80.79 & 80.31 & 69.64\\ MNIST & LeNet5 & 92.03 & 96.69 & 95.43\\ KMNIST & LeNet5 & 90.37 & 90.03 & 91.11\\ \bottomrule \end{tabular} \vspace{-0.5em} \end{table*} We further investigate the impact of rounding decimals on the \textit{ES Attack}\xspace. Figure~\ref{fig:round_mnist} and~\ref{fig:round_kmnist} show the results of experiments with class probabilities rounded to 0-5 decimals. We compare the after-rounding classification accuracy of the substitute model and the victim model. Class probabilities rounded to 2 to 5 decimals have no effect on the adversary’s success. When rounding further to 1 decimal, the attack is weakened, but still successful. When we round the precision to 0 decimal - the victim model only outputs $0$ or $1$ - the attack is further weakened, but still can predict in most cases (over 80\% accuracy). We observe that rounded information brings the uncertainty of the prediction, while this uncertainty sometimes will slightly improve the training. \begin{figure}[!tb] \centering \includegraphics[width=0.7\linewidth]{figs/round_mnist.png} \caption{\textbf{Evaluation of Rounding Prediction on MNIST.}} \label{fig:round_mnist} \end{figure} \begin{figure}[!tb] \centering \includegraphics[width=0.7\linewidth]{figs/round_kmnist.png} \caption{\textbf{Evaluation of Rounding Prediction on KMNIST.}} \label{fig:round_kmnist} \vspace{-1em} \end{figure} \subsection{Top-K Prediction} Instead of providing the predictions of all the classes, MLaaS providers can provide partial information - predictions of K classes with the highest probabilities. Since this defense can be easily detected by the adversary, we assume the adversary is aware of the top-K defenses equipped by the MLaaS provider and will try to circumvent such defense. Therefore, the adversary can slightly change the attack by making up the missing probabilities of the rest classes. The adversary remains the probabilities of the Top-K classes and fills up the rest classes with the same probabilities. For example, given an prediction output of $[0.5, 0.02, 0.3, 0.02, 0.15, 0.01]$, by using Top-2 defense, MLaaS provider can hide the predictions of eight classes and only respond with the prediction of $[0.5, 0.0, 0.3, 0.0, 0.0, 0.0]$. By knowing the top-k defense, The adversary can then convert the predictions to $[0.5, 0.05, 0.3, 0.05, 0.05, 0.05]$ and resume \textit{ES Attack}\xspace. From the experiments, we observe that Top-1 prediction will not affect much on most datasets (Table~\ref{tab:defense}). For the MNIST and KMNIST datasets, we find that the accuracy of the substitute model even gets improved. Top-1 prediction is only effective in preventing model stealing on the CIFAR10 dataset. However, we believe Top-1 prediction is a very strong defense, which will also affect normal users by providing very limited information. On average, the best accuracy of the substitute model with Top-1 prediction is only decreased by 2.86\%. In addition, we investigate the impact of probabilities with different numbers ($K$) of classes on our model stealing attacks (Figure~\ref{fig:topk_mnist} and~\ref{fig:topk_kmnist}). The performance of model stealing attacks is not decreased with fewer classes providing probabilities (small $K$). We find our attacks are minimally impacted by reducing the informativeness of black-box predictions in the response. \begin{figure}[!tb] \centering \includegraphics[width=0.7\linewidth]{figs/topk_mnist.png} \caption{\textbf{Evaluation of Top-K Prediction on MNIST.}} \label{fig:topk_mnist} \vspace{-0.2cm} \end{figure} \begin{figure}[!tb] \centering \includegraphics[width=0.7\linewidth]{figs/topk_kmnist.png} \caption{\textbf{Evaluation of Top-K Prediction on KMNIST.}} \label{fig:topk_kmnist} \vspace{-1em} \end{figure} \subsection{Anomaly Detection} Anomaly detection identifies the abnormal queries sent from users and detects the abnormal behavior that deviates from normal ones. For example, PRADA assumes that the distance between normal queries follows Gaussian distribution and detects the abnormal queries~\cite{juuti2018prada}. By evaluating how deviated the distance from Gaussian distribution, PRADA detects model stealing attacks. For the details of PRADA, we refer readers to~\cite{juuti2018prada}. We evaluate the effectiveness of anomaly detection using PRADA against \textit{OPT-SYN} We analyzed 300,000 image samples from the first five stealing epochs on the MNIST dataset. None of the synthetic images can be detected by PRADA. We believe that because the images are generated starting from the Gaussian distribution, the distances between queried images are too small to be detected by PRADA. Moreover, we find it is not practical for MLaaS providers to deploy a PRADA detector due to its high response time. In our experiments, it takes about 33 hours to process 300,000 images (2.46 images per second on average). With more images to be detected, the average response time will be further increased. Therefore, PRADA is ineffective and infeasible to detect the proposed \textit{ES Attack}\xspace. \subsection{Model Stealing Attacks} Several studies have been proposed for model stealing attacks. Tramer \textit{et al}.\@\xspace investigated stealing model parameters using equation solving~\cite{tramer2016stealing}. However, this approach is hard to extend to DNNs, which contains a larger number of than conventional machine learning models do. Papernot \textit{et al}.\@\xspace proposed a similar framework to steal DNNs by training a substitute model~\cite{papernot2017practical}. Their goal is to approximate the victim model's decision boundaries to facilitate the adversarial attacks rather than to maximize the substitute model's accuracy. Thus their substitute model achieves a much lower classification accuracy compared to our work. In addition, to generate adversarial examples, their approach requires a small set of inputs that represents the input domain. \xyy{In our work, we eliminate this requirement, where the adversary does not need to have prior knowledge, making the attacks more feasible in the real world.} From the experimental results, the stolen model from \textit{ES Attack}\xspace achieves a higher accuracy compared to that from ~\cite{papernot2017practical}. Existing model stealing attacks against DNNs require an auxiliary dataset. Orekondy \textit{et al}.\@\xspace proposed stealing attacks that assume access to a large dataset and use active learning to select the best samples to query~\cite{orekondy2019knockoff}. Correia-Silva \textit{et al}.\@\xspace leveraged public datasets from the same task domain but with different distributions to steal DNNs. \xy{Different from these works, we assume the adversary does not have any auxiliary data related to the task domain. The experiments show that \textit{ES Attack}\xspace can achieve comparable performance, compared with the attacks using auxiliary datasets.} \xy{ Zhou~\textit{et al}.\@\xspace used the same assumption with our work - unknown victim's training data and leveraged a generative model to synthesize the training data~\cite{zhou2020dast}. However, the goal of DaST is to perform a successful adversarial attack, which is different from ours. In this paper, we aim to improve the prediction performance of the substitute model. Accordingly, the substitute model trained by DaST achieves much lower accuracy than \textit{ES Attack}\xspace. } \xy{ MAZE investigated a similar problem with our work, namely data-free model stealing attack~\cite{kariyappa2021maze}. To address the problem of unknown victim's training data, MAZE tried to solve the same challenge as our work, that is in generating synthetic data, the gradient for updating the synthetic data cannot be backpropagated using the victim model. MAZE addressed this issue by approximating the gradients from the victim model using zeroth-order gradient estimation, which is widely used in black-box adversarial attacks, whereas in our work, we generate the gradients by using the substitute model as a proxy of the victim model. Both approaches achieve comparable attacking performance. In addition, the two approaches are orthogonal and could be further integrated together for better performance. We will explore the new approach benefiting from \textit{ES Attack}\xspace and MAZE in the future. } \vspace{-0.5em} \subsection{Model Stealing Defenses} Several detection approaches have been proposed for model stealing attacks. Juuti \textit{et al}.\@\xspace detected the deviated distribution of queries from normal behavior~\cite{juuti2018prada}. Similarly, Kesarwani \textit{et al}.\@\xspace proposed a detection tool that uses information gain to measure the model learning rate by users with the increasing number of queries~\cite{kesarwani2018model}. The learning rate is measured to the coverage of the input feature space in the presence of collusion. We evaluate \cite{juuti2018prada} in our experiments and find that the detection approach is ineffective for our model stealing attacks. \subsection{Knowledge Distillation} \label{sec:related_knowledge} In our model stealing attacks, we use distillation to transfer knowledge from the victim model to the substitute model. Knowledge distillation is widely used in model compression by transferring the knowledge from one model (teacher model) to another (student model)~\cite{hinton2015distilling,bucilua2006model}. Most knowledge distillation approaches require the knowledge of training data. Recently, knowledge distillation without training data has recently been investigated~\cite{chen2019data,lopes2017data,nayak2019zero,yin2020dreaming,haroush2020knowledge} when the training data is infeasible due to large data size or privacy concerns. \xy{However, these data-free knowledge distillation approaches cannot be used for model stealing since the adversary cannot acquire the required information. For example, the model gradient is required to update the parameters of the generator in~\cite{chen2019data}. Similarly, model parameters are required to calculate class similarity in~\cite{nayak2019zero} or to calculate the feature map statistics in~\cite{yin2020dreaming} and batch normalization statistics in~\cite{haroush2020knowledge}. Therefore, beyond data-free knowledge distillation, we introduce two data synthesis approaches in \textit{ES Attack}\xspace to construct a novel data-free model stealing attack. } \section*{Synthetic Example Images by \textit{OPT-SYN}} We show the synthetic images using \textit{OPT-SYN} with the best substitute model. We compare them with the victim's training data in the SVHN, CIFAR-10, MNIST and KMNIST datasets (Figure~\ref{fig:svhn_img},~\ref{fig:cifar_img},~\ref{fig:mnist_img},~\ref{fig:kmnist_img}). First row: images in the victim's training dataset. Second row: images in the synthetic dataset. Third Row: corresponding labels of images. \begin{figure*}[!b] \centering \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_train_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/SVHN_syn_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering 0 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 1 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 2 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 3 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 4 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 5 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 6 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 7 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 8 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 9 \end{subfigure} \caption{\textbf{The SVHN Dataset}} \label{fig:svhn_img} \end{figure*} \begin{figure*}[!tb] \centering \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_train_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/CIFAR_syn_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering plane \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering car \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering bird \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering cat \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering deer \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering dog \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering frog \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering horse \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering ship \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering truck \end{subfigure} \caption{\textbf{The CIFAR-10 Dataset}} \label{fig:cifar_img} \end{figure*} \begin{figure*}[!tb] \centering \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_train_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/MNIST_syn_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering 0 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 1 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 2 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 3 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 4 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 5 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 6 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 7 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 8 \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering 9 \end{subfigure} \caption{\textbf{The MNIST Dataset}} \label{fig:mnist_img} \end{figure*} \begin{figure*}[!tb] \centering \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_train_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_0.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_1.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_2.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_3.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_4.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_5.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_6.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_7.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_8.png} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \includegraphics[width=0.9\linewidth]{figs/imgs/KMNIST_syn_9.png} \end{subfigure} \par\bigskip \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} お \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} き \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} す \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} つ \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} な \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} は \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} ま \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} や \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} れ \end{CJK} \end{subfigure} \begin{subfigure}{0.09\textwidth} \centering \begin{CJK}{UTF8}{min} を \end{CJK} \end{subfigure} \caption{\textbf{The KMNIST Dataset}} \label{fig:kmnist_img} \end{figure*} \subsection{Evaluation of Black-Box Attacks} We evaluate the black-box adversarial attack against the victim model using the substitute model. We implement a white-box $\ell_{\infty}$-PGD attacks~\cite{madry2017towards} and leverage the transferability of adversarial examples to conduct the attack. PGD attack is an iterative gradient-based attack in a white-box setting and has been proven effective in many machine learning models and tasks. In the experiment, we use the test dataset $\mathcal{D}_{test}$ as our evaluation dataset. We follow the adversarial settings in~\cite{madry2017towards} and consider the untargeted adversarial attacks, where adversarial examples can be classified as any classes other than the ground-truth class. For the MNIST and KMNIST dataset, we run 40 iterations of $\ell_{\infty}$-PGD attack with a step size of 0.01. We set the maximal perturbation size as $0.3$. For the SVHN and CIFAR10 dataset, we run 20 iterations with a step size of 2/255. The maximal perturbation size is set as $8/255$. We report the success rate of adversarial attacks against our substitute model and the victim model (transferring attack) in Table~\ref{tab:adversarial}. We compare the success rate of three adversarial attacks: 1) white-box attacks against the victim model, 2) white-box attacks against the substitute model, and 3) black-box attacks against the victim model via transferring. For the third attack, we evaluate the adversarial examples generated against substitute model (white-box attacks) on the victim model. We show the performance of the white-box $\ell_{\infty}$-PGD attack against the victim model as well. \begin{table}[!tb] \renewcommand{\arraystretch}{1.3} \centering \caption{Success rates of adversarial attacks.} \label{tab:adversarial} \vspace{-0.5em} \resizebox{\linewidth}{!}{% \begin{tabular}{@{}llrrr@{}} \toprule \multirow{3}{*}{Dataset} & \multirow{3}{*}{Model}& \multicolumn{3}{c}{Attack success rate (\%)}\\\cline{3-5} & & \begin{tabular}[r]{@{}r@{}} white-box\\victim model\end{tabular} & \begin{tabular}[c]{@{}c@{}} white-box\\substitute model\end{tabular} & \begin{tabular}[c]{@{}c@{}} black-box\\victim model\end{tabular} \\ \midrule SVHN& ResNet18 & 99.95 & 99.94 & 98.71 \\ SVHN& ResNet34 & 99.93 & 99.90 & 98.21 \\ CIFAR10& ResNet18 & 100.00 & 100.00 & 93.60 \\ CIFAR10& ResNet34 & 100.00 & 100.00 & 100.00 \\ MNIST& LeNet5 & 86.07 & 99.57 & 92.14 \\ KMNIST& LeNet5 & 66.44 & 99.72 & 98.99 \\ \bottomrule \end{tabular} } \vspace{-1em} \end{table} From the experimental results, the black-box adversarial attacks using the substitute model can achieve the same success rate as the white-box, which suggests that the substitute models can transfer the adversarial examples to the victim model successfully. Almost all black-box adversarial attacks achieve high accuracy rates (over 90\%). We observe that the success rates of the black-box attacks against the victim models are less than that of the white-box attacks against the substitute models, but the change is subtle. Hence, most adversarial examples can be transferred from the substitute model to the victim model. Surprisingly, the black-box attacks against the victim model perform even better than the white-box attacks against the victim model on the MNIST and KMNIST dataset. \section{Introduction}} \input{1-intro.tex} \section{Problem Statement} \input{2-background.tex} \section{\textit{ES Attack}\xspace} \input{3-steal.tex} \section{Evaluation of \textit{ES Attack}\xspace} \input{4-eval.tex} \subsection{Further Attacks: A Case Study on Black-Box Adversarial Attacks} \label{sec:adv} \input{adversarial.tex} \section{Countermeasures of Model Stealing} \label{sec:defense} \input{5-defenses.tex} \section{Related Work} \label{sec:related} \input{6-related.tex} \section{Conclusion} \input{8-conclusion.tex} \section*{Acknowledgments} This work was supported in part by National Science Foundation (CCF-2007210, CCF-2106610, and CCF-2106754). \bibliographystyle{IEEEtran}
{'timestamp': '2022-01-27T02:02:24', 'yymm': '2009', 'arxiv_id': '2009.09560', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09560'}
arxiv
\section{Introduction} We begin by recalling the usual set-up for neural differential equations. \subsection{Neural ordinary differential equations} The general approach of neural ordinary differential equations \citep{E2017,neural-odes} is to use ODEs as a learnable component of a differentiable framework. Typically the goal is to approximate a map $x \mapsto y$ by learning functions $\ell_1(\,\cdot\,,\phi)$, $\ell_2(\,\cdot\,,\psi)$ and $f(\,\cdot\,,\,\cdot\,, \theta)$, which are composed such that \begin{align} z(\tau) &= \ell_1(x, \phi),\nonumber\\ z(t) &= z(\tau) + \int_\tau^t f(s, z(s), \theta) \,\mathrm{d} s\nonumber\\ y &\approx \ell_2(z(T), \psi).\label{eq:node} \end{align} The variables $\phi$, $\theta$, $\psi$ denote learnable parameters and the ODE is solved over the interval $[\tau, T]$. We include the (often linear) maps $\ell_1(\,\cdot\,,\phi)$, $\ell_2(\,\cdot\,,\psi)$ for generality, as in many contexts they are important for the expressiveness of the model~\citep{augmented-node,zhang2020approximation}, though our contributions will be focused around the ODE component and will not depend on these maps. Here we will consider neural differential equations that may be interpreted as a neural ODE. \subsection{Applications}\label{section:applications} Neural differential equations have, to the best of our knowledge, three main applications: \begin{enumerate} \item Time series modeling. \citet{latent-odes} interleave Neural ODEs with RNNs to produce ODEs with jumps. \citet{kidger2020neuralcde} take $f(t, z, \theta) = g(z, \theta) \frac{\mathrm{d} X}{\mathrm{d} t}(t)$, dependent on some time-varying input $X$, to produce a neural \emph{controlled} differential equation. \item Continuous Normalising Flows as in \citet{neural-odes,ffjord}, in which the overall model acts as coupling or transformation between probability distributions, \item Modeling or controlling physical environments, for which a differential equation based model may be explicitly desired, see for example \citet{Zhong2020Symplectic}. \end{enumerate} \subsection{Adjoint equations} The integral in equation \eqref{eq:node} may be backpropagated through either by backpropagating through the internal operations of a numerical solver, or by solving the backwards-in-time \emph{adjoint equations} with respect to some (scalar) loss $L$: \begin{align} a_z(T) &= \frac{\mathrm{d} L}{\mathrm{d} z(T)},\nonumber\\ a_\theta(T) &= 0,\nonumber\\ a_t(T) &= \frac{\mathrm{d} L}{\mathrm{d} T},\nonumber\\ a_z(t) &= a_z(T) - \int_T^t a_z(s) \cdot \frac{\partial f}{\partial z}(s, z(s), \theta) \,\mathrm{d} s,\nonumber\\ a_\theta(t) &= a_\theta(T) - \int_T^t a_z(s) \cdot \frac{\partial f}{\partial \theta}(s, z(s), \theta) \,\mathrm{d} s,\nonumber\\ a_t(t) &= a_t(T) - \int_T^t a_z(s) \cdot \frac{\partial f}{\partial s}(s, z(s), \theta) \,\mathrm{d} s,\nonumber\\ \frac{\mathrm{d} L}{\mathrm{d} z(\tau)} &= a_z(\tau),\nonumber\\ \frac{\mathrm{d} L}{\mathrm{d} \theta} &= a_\theta(\tau),\nonumber\\ \frac{\mathrm{d} L}{\mathrm{d} \tau} &= a_t(\tau).\label{eq:adjoint} \end{align} These equations are typically solved together as a joint system $a(t) = [a_z(t), a_\theta(t), a_t(t)]$. (They are already coupled; the equations for $a_\theta$ and $a_t$ depend on $a_z$.) As additionally their integrands require $z(s)$, and as the results of the forward computation of equation \eqref{eq:node} are usually not stored, then the adjoint equations are typically additionally augmented by recovering $z$ by solving backwards-in-time \begin{equation}\label{eq:backward} z(t) = z(T) + \int_T^t f(s, z(s), \theta) \mathrm{d} s. \end{equation} \subsection{Contributions} We demonstrate that the particular structure of the adjoint equations implies that numerical equation solvers will typically take too many steps, that are too small, wasting time during backpropagation. Specifically, the accept/reject step of adaptive-step-size solvers is too stringent. By applying a correction to account for this, our method reduces the number of steps needed to solve the adjoint equations a median of 40\%. On some problems we observe a reduction in function evaluations by as much as 62\%. Factoring in the forward pass (which is unchanged), the overall training procedure is roughly twice as fast. The procedure we describe is simple to implement, does not affect model performance, and is hyperparameter-free and requires no tuning. \section{Method} \subsection{Numerical solvers} Both the forward pass given by equation \eqref{eq:node}, and the backward pass given by equations \eqref{eq:adjoint} and \eqref{eq:backward}, are solved by invoking a numerical differential equation solver. Our interest here is in adaptive-step-size solvers. Indeed the default choice for solving many equations is the adaptive-step-size Runge--Kutta 5(4) scheme of Dormand--Prince \citep{dopri5}, for example as implemented by \texttt{dopri5} in the \texttt{torchdiffeq} package or \texttt{ode45} in MATLAB. A full discussion of the internal operations of these solvers is beyond our scope here; the part of interest to us is the accept/reject scheme. Consider the case of solving the general ODE \begin{equation*} y(t) = y(\tau) + \int_\tau^t f(s, y(s)) \,\mathrm{d} s, \end{equation*} with $y(t) \in \mathbb{R}^d$. Suppose for some fixed $t$ the solver has computed some estimate $\widehat{y}(t) \approx y(t)$, and it now seeks to take a step $\Delta > 0$ to compute $\widehat{y}(t + \Delta) \approx y(t + \Delta)$. A step is made, and some candidate $\widehat{y}_\text{candidate}(t + \Delta)$ is generated. The solver additionally produces $y_\text{err} \in \mathbb{R}^d$ representing an estimate of the numerical error made in each channel during that step. Given some prespecified absolute tolerance $ATOL$ (for example $10^{-9}$), relative tolerance $RTOL$ (for example $10^{-6}$), and (semi)norm $\norm{\,\cdot\,} \colon \mathbb{R}^d \to [0, \infty)$ (for example $\norm{y} = \sqrt{\frac{1}{d} \sum_{i = 1}^d y_i^2}$ the RMS norm), then an estimate of the size of the solution to the equation is given by \begin{align} &SCALE =\nonumber\\& ATOL + RTOL \cdot \max(\widehat{y}(t), \widehat{y}_\text{candidate}(t + \Delta)) \in \mathbb{R}^d,\label{eq:scale} \end{align} where the maximum is taken channel-wise, and the error ratio $r$ is computed (with an element-wise division): \begin{equation}\label{eq:ratio} r = \norm{\frac{y_\text{err}}{SCALE}} \in \mathbb{R}. \end{equation} If $r \leq 1$ then the error is deemed acceptable, the step is accepted and we take $\widehat{y}(t + \Delta) = \widehat{y}_\text{candidate}(t + \Delta)$. If $r > 1$ then the error is deemed too large, the candidate $\widehat{y}_\text{candidate}(t + \Delta)$ is rejected, and the procedure is repeated with a smaller $\Delta$. Note the dependence on the choice of norm $\norm{\,\cdot\,}$: in particular this determines the relative importance of each channel towards the accept/reject criterion. \subsection{Adjoint seminorms} \paragraph{Not an ODE} The key observation is that $a_\theta$ (and in fact also $a_t$) does not appear anywhere in the vector fields of equation \eqref{eq:adjoint}. This means that (conditioned on knowing $z$ and $a_z$), the integral corresponding to $a_\theta$ is just an integral---not an ODE. As such, it is arguably inappropriate to solve it with an ODE solver, which makes the implicit assumption that small errors now may propagate to create large errors later. \paragraph{Accept/reject} This is made manifest in the accept/reject step of equation \eqref{eq:ratio}. Typical choices of norm $\norm{\,\cdot\,}$, such as $L^2$, will usually weight each channel equally. But we have just established that to solve the adjoint equations accurately, it is far more important that $z$ and $a_z$ be accurate than it is that $a_\theta$ be accurate. \paragraph{Seminorms} Thus, when solving the adjoint equations equation \eqref{eq:adjoint}, we propose to use a $\norm{\,\cdot\,}$ that scales down the effect in those channels corresponding to $a_\theta$. In practice, in our experiments, we scale $\norm{\,\cdot\,}$ all the way down by applying zero weight to the offending channels, so that $\norm{\,\cdot\,}$ is in fact a seminorm. This means that the integration steps are chosen solely for the computation of $a_z$ and $z$, and the values of $a_\theta$ are computed just by integrating with respect to those steps. \paragraph{Example} As an explicit example, note that $a_\theta(T) = 0$. When solving the adjoint equation numerically, this means for $t$ close to $T$ that the second term in equation \eqref{eq:scale} is small. As $ATOL$ is typically also small, then $SCALE$ is additionally small, and the error ratio $r$ in equation \eqref{eq:ratio} is large. This implies that it becomes easy for the error ratio $r$ to violate $r \leq 1$, and it is easy for the step to be rejected. Now there is nothing intrinsically bad about a step being rejected---we would like to solve the ODE accurately, after all---the problem is that this is a \emph{spurious rejection}, as the rejection occurred to ensure the accuracy of $a_\theta$, which is as already established unnecessary. In practice, we observe that spurious rejections may occur for any $t$, not just those near $T$. \paragraph{Other channels} In fact, essentially the same argument applies to $a_t$ as well: this does not affect the value of the vector field either. In a continuous normalising flow, the log-probability channel is also only an integral, rather than an ODE, and again the same argument may be applied. \paragraph{Does this reduce the accuracy of parameter gradients?} One obvious concern is that we are typically ultimately interested in the parameter gradients $a_\theta$, in order to train a model; with respect to this our approach seems counter-intuitive. However, we verify empirically that models still train without a reduction in performance. We explain this by noting that the $z$, $a_z$ channels truly are ODEs, so that small errors now do propagate to create larger errors later. Thus these are likely the dominant source of error overall. \paragraph{Code}\label{section:code} \texttt{torchdiffeq} \citep{neural-odes} now supports adjoint seminorms as a built-in option. This may be used by passing \texttt{odeint\_adjoint(..., adjoint\_options=dict(norm="seminorm"))}. The code for all our experiments can be found at \url{https://github.com/patrick-kidger/FasterNeuralDiffEq/}. \section{Experiments} We compare our proposed technique against conventionally-trained neural differential equations, across multiple tasks---time series, generative, and physics-informed. These are each drawn from the main applications of neural differential equations, discussed in Section \ref{section:applications}. In every case, the differential equation solver used is the Dormand--Prince 5(4) solver ``\texttt{dopri5}''. The default norm is a mixed $L^\infty/L^2$ norm used in \texttt{torchdiffeq}; see Appendix \ref{appendix:torchdiffeq}. For the sake of an interesting presentation, we investigate different aspects of each problem. In each case see Appendix \ref{appendix:experiments} for details on hyperparameters, optimisers and so on. \subsection{Neural Controlled Differential Equations}\label{section:ncde} Consider the Neural Controlled Differential Equation (Neural CDE) model of \citet{kidger2020neuralcde}. To recap, given some (potentially irregularly sampled) time series $\mathbf{x} = ((t_0, x_0), \ldots, (t_n, x_n))$, with each $t_i \in \mathbb{R}$ the timestamp of the observation $x_i \in \mathbb{R}^v$, let $X \colon [t_0, t_n] \to \mathbb{R}^{1 + v}$ be an interpolation such that $X(t_i) = (t_i, x_i)$. For example $X$ could be a natural cubic spline. Then take $f(t, z, \theta) = g(z, \theta) \frac{\mathrm{d} X}{\mathrm{d} t} (t)$ in a Neural ODE model, so that changes in $\mathbf{x}$ provoke changes in the vector field, and the model incorporates the incoming information $\mathbf{x}$. This may be thought of as a continuous-time RNN; indeed \citet{kidger2020neuralcde} use this to learn functions of (irregular) time series. \begin{table*}[t] \centering \ra{1.2} \setlength{\tabcolsep}{4pt} \caption{Results for Neural CDEs. The number of function evaluations (NFE) used in the adjoint equations---accumulated throughout training---are reported. Test set accuracy is additionally reported. Mean $\pm$ standard deviation over five repeats. Every model has 88,940 parameters.}\label{table:ncde} \begin{tabular}{@{} l c c c c c c @{}} \toprule & & \multicolumn{2}{c}{Default norm} & & \multicolumn{2}{c}{Seminorm} \\ \cmidrule(lr){3-4} \cmidrule(l){6-7} RTOL, ATOL & & Accuracy (\%) & Bwd. NFE ($10^6$) & & Accuracy (\%) & Bwd. NFE ($10^6$) \\ \midrule \vspace{0.2em}% $10^{-3}, 10^{-6}$ & & 92.6{\scriptsize $\pm$0.4} & 14.36{\scriptsize $\pm$1.09} & & 92.5{\scriptsize $\pm$0.5} & \textbf{8.67{\scriptsize $\pm$1.60}}\\ $10^{-4}, 10^{-7}$ & & 92.8{\scriptsize $\pm$0.4} & 30.67{\scriptsize $\pm$2.48} & & 92.5{\scriptsize $\pm$0.5} & \textbf{12.75{\scriptsize $\pm$2.00}} \\ $10^{-5}, 10^{-8}$ & & 92.4{\scriptsize $\pm$0.7} & 77.95{\scriptsize $\pm$4.47} & & 92.9{\scriptsize $\pm$0.4} & \textbf{29.39{\scriptsize $\pm$0.80}} \\ \bottomrule \end{tabular} \end{table*} \begin{figure*}[t] \centering \includegraphics[width=0.8\textwidth]{accuracy.png} \vspace{-0.5em} \includegraphics[width=0.8\textwidth]{nfe.png} \caption{Mean $\pm$ standard deviation, for accuracy and the number of function evaluations (NFE) for the backward pass, during training, for Neural CDEs.} \label{fig:ncde} \end{figure*} We apply a Neural CDE to the Speech Commands dataset \citep{speechcommands}. This is a dataset of one-second audio recordings of spoken words such as `left', `right' and so on. We take 34975 time series corresponding to 10 words, to produce a balanced classification problem. We preprocess the dataset by computing mel-frequency cepstrum coefficients so that each time series is then regularly spaced with length 161 and 20 channels. The data was then normalised to have zero mean and unit variance. We used the \texttt{torchcde} package \citep{torchcde}, which wraps \texttt{torchdiffeq}. The initial map $\ell_1$ (of equation \eqref{eq:node}) is taken to be linear on $(t_0, x_0)$. The terminal map $\ell_2$ is taken to be linear on $z(t_n)$. We investigate how the effect changes for varying tolerances by varying the pair $(RTOL, ATOL)$ over $(10^{-3}, 10^{-6})$, $(10^{-4}, 10^{-7})$, and $(10^{-5}, 10^{-8})$. For each such pair we run five repeated experiments. See Table \ref{table:ncde} for results on accuracy and number of function evaluations. We see that the accuracy of the model is unaffected by our proposed change, whilst the backward pass uses 40\%--62\% fewer steps, depending on tolerance. Next, we investigate how accuracy and function evaluations change during training. See Figure \ref{fig:ncde}. We see that accuracy quickly gets close to its maximum value during training, with only incremental improvements for most of the training procedure. In particular, this statement is true of both approaches, and we do not see any discrepancy between them. Additionally, we see that the number of function evaluations is much lower for the seminorm throughout training. \subsection{Continuous Normalising Flows} \begin{table*}[t] \centering \ra{1.2} \setlength{\tabcolsep}{4pt} \caption{Results for Continuous Normalising Flows. The number of function evaluations (NFE) used in the adjoint equations---accumulated throughout training---are reported. Test set bits/dim and number of parameters are additionally reported. Mean $\pm$ standard deviation over three repeats.} \label{tab:cnf} \begin{tabular}{@{} l c c c c c c @{}} \toprule & & \multicolumn{2}{c}{Default norm} & & \multicolumn{2}{c}{Seminorm} \\ \cmidrule(lr){3-4} \cmidrule(l){6-7} Model & Parameters & Test bits/dim & Bwd. NFE ($10^6$) & & Test bits/dim & Bwd. NFE ($10^6$) \\ \midrule \vspace{0.2em}% \begin{tabular}{@{}l@{}} CIFAR-10 ($d_h=64$) \end{tabular} & 1,200,600 & 3.3492{\scriptsize $\pm$0.0059} & 41.65{\scriptsize $\pm$1.97} & & 3.3428{\scriptsize $\pm$0.0121} & \textbf{38.93{\scriptsize $\pm$1.32}} \\ \begin{tabular}{@{}l@{}} MNIST ($d_h=32$) \end{tabular} & 281,928 & 0.9968{\scriptsize $\pm$0.0020} & 41.50{\scriptsize $\pm$2.35} & & 0.9942{\scriptsize $\pm$0.0013} & \textbf{37.03{\scriptsize $\pm$0.96}}\\ \begin{tabular}{@{}l@{}} MNIST ($d_h=64$) \end{tabular} & 1,005,384 & 0.9623{\scriptsize $\pm$0.0020} & 44.24{\scriptsize $\pm$1.78} & & 0.9603{\scriptsize $\pm$0.0021} & \textbf{37.85{\scriptsize $\pm$0.94}} \\ \begin{tabular}{@{}l@{}} MNIST ($d_h=128$) \end{tabular} & 3,779,400 & 0.9439{\scriptsize $\pm$0.0030} & 48.60{\scriptsize $\pm$2.30} & & 0.9466{\scriptsize $\pm$0.0048} & \textbf{41.84{\scriptsize $\pm$1.92}} \\ \bottomrule \end{tabular} \end{table*} Continuous Normalising Flows (CNF)~\citep{neural-odes} are a class of generative models that define a probability distribution as the transformation of a simpler distribution by following the vector field parameterised by a Neural ODE. Let $p(z_0)$ be an arbitrary base distribution that we can efficiently sample from, and compute its density. Then let $z(t)$ be the solution of the initial value problem \begin{align*} z(0) &\sim p(z_0),\\ \frac{dz(t)}{zt} &= f(t, z(t), \theta),\\ \frac{d\log p(z(t))}{dt} &= - \text{tr}\left(\frac{\partial f}{\partial z} (t, z(t), \theta)\right), \end{align*} for which the initial point is randomly sampled from $p(z_0)$, and for which the change in log probability density is also tracked as the sample is transformed through the vector field. The distribution at an arbitrary time value $T$ can be trained with maximum likelihood to match data samples, resulting in a generative model of data with the distribution $p(z(T))$. Furthermore, \citet{ffjord} combines this with a stochastic trace estimator~\citep{hutchinson1989stochastic} to create an efficient and unbiased estimator of the log probability for data samples $x$: \begin{align} &\log p(z(T) = x) = \log p (z(0)) +\nonumber\\ &\hspace{4em}\mathbb{E}_{v\sim \mathcal{N}(0, 1)} \left[ \int_{T}^0 v^T \left(\frac{\partial f}{\partial z} (t, z(t), \theta)\right) v \; dt \right].\label{eq:loglikelihood} \end{align} In Table~\ref{tab:cnf} we show the final test performance and the total number of function evaluations (NFEs) used in the adjoint method over 100 epochs. We see substantially fewer NFEs in experiments on both MNIST and CIFAR-10. Next, we investigate changing model size, by varying the complexity of the vector field $f$, which is a CNN with $d_h$ hidden channels. We find that using the seminorm, the backward NFE does not increase as much as when using the default norm. In particular, we can use roughly same NFEs as the smaller ($d_h=32$) model to train a larger ($d_h=128$) model and in doing so achieve a substantial gain in performance ($1.00 \rightarrow 0.95$). \subsection{Hamiltonian dynamics} We consider the problem of learning Hamiltonian dynamics, using the Symplectic ODE-Net model of \citet{Zhong2020Symplectic}. Under Hamiltonian mechanics, the vector field is parameterised as \begin{equation*} f(t, z, \theta) = \begin{bmatrix} \frac{\mathrm{d} H}{\mathrm{d} p} (q, p, \theta)\\ g(q, \theta) u -\frac{\mathrm{d} H}{\mathrm{d} q}(q, p, \theta)\\ 0 \end{bmatrix}, \end{equation*} where $z = (q, p, u)$ is the state decomposed into (generalised) positions $q$, momenta $p$, and control $u$. $H$ is a Hamiltonian and $g$ is an input term, both parameterised as neural networks. The input $g$ offers a way to control the system, which can be understood via energy shaping. This parameterisation lends itself to being interpretable. $H$ learns to encode the physics of the system in the form of Hamiltonian mechanics, whilst $g$ learns to encode the way in which inputs affect the system. This can then be used to construct controls $u$ driving the system to a desired state. In this context (unlike the other problems we consider here), $z$ is not a hidden state but instead the output of the model. The evolution of $z$ is matched against the observed state at multiple times $z(t_1)$, $z(t_2)$, $\ldots$, and trained with $L^2$ loss. We consider the fully-actuated double pendulum (``acrobot'') problem. Training data involves small oscillations under constant forcing. We investigate several quantities of interest. First we investigate the number of function evaluations. See Table \ref{tab:hnn}. We see that the model successfully learns the dynamics, with very small loss (order $\mathcal{O}(10^{-4})$) in both cases. However, under our proposed change the model is trained using 43\% fewer function evaluations on the backward pass. \begin{table*}[t] \centering \ra{1.2} \setlength{\tabcolsep}{4pt} \caption{Results for Symplectic ODE-Net on a fully-actuated double pendulum. The number of function evaluations (NFE) used in the adjoint equations---accumulated throughout training---are reported. Test set loss is additionally reported. Mean $\pm$ standard deviation over five repeats. The model has 509,108 parameters. } \begin{tabular}{@{} l c c c c c c @{}} \toprule & & \multicolumn{2}{c}{Default norm} & & \multicolumn{2}{c}{Seminorm} \\ \cmidrule(lr){3-4} \cmidrule(l){6-7} & & Test $L^2$ loss ($10^{-4}$) & Bwd. NFE ($10^4$) & & Test $L^2$ loss ($10^{-4}$) & Bwd. NFE ($10^4$) \\ \midrule \vspace{0.2em}% & & 1.247{\scriptsize $\pm$0.520} & 46.45{\scriptsize $\pm$0.01} & & 2.995{\scriptsize $\pm$2.190} & \textbf{26.55{\scriptsize $\pm$0.01}} \\ \bottomrule \end{tabular} \label{tab:hnn} \end{table*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{true-frames.png} \caption{Frames from controlling the fully-actuated double pendulum to the full-upright position.} \label{fig:hnn-control} \includegraphics[width=\textwidth]{true-graph.png} \caption{Evolution of the state $z = (q, \dot{q}, u)$ whilst controlling the fully-actuated double pendulum from the full-down to the full-upright position. $q_1$ denotes the angle of the first joint, and $q_2$ denotes the angle of the second joint.} \label{fig:hnn-control2} \end{figure*} \begin{figure*}[t] \includegraphics[width=0.95\textwidth]{hist1.png} \vspace{-1em} \caption{Location of function evaluations for the adjoint equations, during training for the fully-actuated double pendulum problem. All evaluations over five runs are shown.} \label{fig:hnn-hist1} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=0.95\textwidth]{hist2.png} \vspace{-1.5em} \caption{Location of rejected steps during training for the fully-actuated double pendulum problem. All steps over five runs are shown. There were no rejected steps for the seminorm.} \label{fig:hnn-hist2} \end{figure*} Next, we verify that the end goal of controlling the system is still achievable, using a seminorm-trained model. See Figures \ref{fig:hnn-control} and \ref{fig:hnn-control2}, in which the double pendulum is successfully controlled from the full-down to the full-upright position, using the seminorm-trained model. Third, we investigate the locations of the function evaluations. See Figure \ref{fig:hnn-hist1}. We see that the default norm makes consistently more evaluations for every time $t$. This is interesting as our initial hypothesis was that there would be more spurious rejections for $t$ near the terminal time $T$, where $a_\theta(t)$ is small, as $a_\theta(T) = 0$. In fact we observe consistent improvements for all $t$. Fourth and finally, we investigate the locations of the rejected steps. See Figure \ref{fig:hnn-hist2}. We see that the seminorm produces almost no rejected steps. This accounts for the tight grouping seen in Figure \ref{fig:hnn-hist1}, as for each batch the evaluations times are typically at the same locations. Moreover, we observe an interesting structure to the the location of the rejected steps with the default norm. We suspect this is due to the time-varying physics of the problem. Note that the Dormand--Prince solver makes 6 function evaluations per step, which is the reason for the difference in scale between Figures \ref{fig:hnn-hist1} and \ref{fig:hnn-hist2}. \subsection{Where do improvements come from?} \begin{figure}\centering \includegraphics[width=0.45\textwidth]{fig-ratio.png} \caption{Parameter-state ratio against improvement, as given by the relative decrease in backward NFE. Only one neural CDE experiment (RTOL=$10^{-3}$, ATOL=$10^{-6}$) is shown as the others use different tolerances. CNFs are averaged over their different blocks.}\label{fig:parameter-state} \end{figure} \paragraph{Parameter-state ratio} We hypothesised that the ratio between size of state and number of parameters may explain the differences between the smaller improvements for continuous normalising flows against the substantial improvements for Hamiltonian neural networks and neural CDEs (corresponding to the proportion of channels that can no longer cause rejections). Given a model with $p$ parameters and state $z(t) \in \mathbb{R}^d$, then seminorms reduce the number of rejection-causing channels from $1 + 2d + p$ to just $1 + 2d$. We plot the (log) ratio $\nicefrac{1 + 2d + p}{1 + 2d}$ against the percentage improvement in backward steps. See Figure \ref{fig:parameter-state}. We see that this hypothesis partly explains things: broadly speaking continuous normalising flows (which have $\mathcal{O}(10^3)$ state variables) see small improvements, whilst the neural CDEs and Hamiltonian neural networks (with $\mathcal{O}(10^1)$ state variables) see larger improvements. There are still many differences between problems (tolerances, complexity of vector field, and so on); see for example the variation amongst the continuous normalising flows. Thus for any given problem this serves more as a rule-of-thumb. \newcommand{\multiline}[1]{\begin{tabular}[c]{@{}l@{}}#1\end{tabular}} \begin{table*}[t]\centering \caption{Number of rejected and accepted backward steps on one pass over the test set.}\label{tab:rejections} \begin{tabular}{l c rr c rr c rr} \toprule & & \multicolumn{2}{c}{Rejected steps ($10^3$)} & & \multicolumn{2}{c}{Accepted steps ($10^3$)} & & \multicolumn{2}{c}{Proportion rejected}\\ \cmidrule(lr){3-4} \cmidrule(lr){6-7} \cmidrule(lr){9-10} Experiment & & Default & Seminorm & & Default & Seminorm & & Default & Seminorm\\ \midrule \multiline{NCDE (small)} & & \textbf{0.13{\scriptsize $\pm$0.02}} & 0.15{\scriptsize $\pm$0.02} & & 3.45 {\scriptsize $\pm$ 0.26} & \textbf{1.92 {\scriptsize $\pm$ 0.18}} & & \textbf{3.63\%} & 7.25\%\\ \multiline{NCDE (medium)} & & 1.01{\scriptsize $\pm$0.18}& \textbf{0.17{\scriptsize $\pm$0.05}} & & 8.38 {\scriptsize $\pm$ 0.86} & \textbf{3.25 {\scriptsize $\pm$ 0.43}} & & 10.76\% & \textbf{4.97\%}\\ \multiline{NCDE (large)} & & 10.91{\scriptsize $\pm$ 1.03}& \textbf{1.16{\scriptsize $\pm$0.13}} & & 28.86 {\scriptsize $\pm$ 2.15} & \textbf{8.61 {\scriptsize $\pm$ 0.45}} & & 27.43\% & \textbf{11.87\%}\\ CIFAR-10 & & 11.04{\scriptsize $\pm$0.29} & \textbf{9.30{\scriptsize $\pm$1.92}} & & 23.50 {\scriptsize $\pm$ 1.19} & \textbf{22.82 {\scriptsize $\pm$ 1.34}} & & 31.96\% & \textbf{28.95\%}\\ \multiline{MNIST ($d_h = 32$)} & & 5.54{\scriptsize $\pm$0.99} & \textbf{4.51{\scriptsize $\pm$1.01}} & & 20.91 {\scriptsize $\pm$ 0.90} & \textbf{19.93 {\scriptsize $\pm$ 0.42}} & & 20.95\% & \textbf{18.45\%}\\ \multiline{MNIST ($d_h = 64$)} & & 7.79{\scriptsize $\pm$0.81} & \textbf{4.29{\scriptsize $\pm$0.69}} & & 22.95 {\scriptsize $\pm$ 1.02} & \textbf{19.73 {\scriptsize $\pm$ 0.99}} & & 38.53\% & \textbf{17.86\%}\\ \multiline{MNIST ($d_h = 128$)} & & 8.88{\scriptsize $\pm$0.21} & \textbf{7.40{\scriptsize $\pm$1.17}} & & 26.54 {\scriptsize $\pm$ 0.91} & \textbf{25.01 {\scriptsize $\pm$ 1.17}} & & 25.07\% & \textbf{22.83\%}\\ HNN & & 0.11{\scriptsize $\pm$0.00} & \textbf{0.00{\scriptsize $\pm$0.00}} & & 0.18 {\scriptsize $\pm$ 0.00} & \textbf{0.16 {\scriptsize $\pm$ 0.00}} & & 37.93\% & \textbf{0.00\%}\\ \bottomrule \end{tabular} \end{table*} \paragraph{Number of accepted/rejected steps} Next we investigate the improvements for each problem, broken down by accepted and rejected steps (over a single backward pass). See Table \ref{tab:rejections}. We begin by noting that the absolute number of accepted and rejected steps nearly always decreased. (In the case of modelling Hamiltonian dynamics, the seminorm actually produced \textit{zero} rejected steps.) However beyond this, the \textit{proportion} of rejected steps nearly always decreased. This highlights that the benefit of seminorms is two-fold. First, that the number of accepted steps is reduced indicates that use of seminorms means systems are treated as smaller and so easier-to-solve, allowing larger step sizes. Second, the reduced proportion of rejected steps means that the differential equation solve is more efficient, with fewer wasted steps. \section{Related work} Several works have sought techniques for speeding up training of neural differential equations. \subsection{Techniques included here} \citet{augmented-node} and \citet{dissecting} note that adding extra dimensions to the Neural ODE improve expressivity and training. Indeed this has arguably now become a standard part of the model; we include this via the linear $\ell_1$ in equation \eqref{eq:node}. \citet{neural-odes} mention regularizing the differential equation using weight decay; we include this throughout our experiments. When backpropagating through the internal operations of the solver (so not the adjoint method used here), \citet{aca} note that backpropagating through rejected steps is unnecessary. This is implicitly used here as this is now the default behaviour in \texttt{torchdiffeq}. \subsection{Model-specific techniques} For Neural ODEs only, \citet{steer} regularise the neural ODE by randomly selecting the terminal integration time. Much like this work, this is a simple change with immediate benefit. Specialised for Continuous Normalising Flows, \citet{how-to-train-node} and \citet{easy} investigate regularising the higher-order derivatives of the model. The idea is that this encourages simpler trajectories that are easier to integrate. However, this improvement must be weighed against the extra cost of computing the regularisation term. Thus whilst \citet{how-to-train-node} describe speed improvements for CNFs, \citet{easy} describe slower training as a result of this extra cost. For Continuous Normalizing Flows, \citet{ffjord}, \citet{chen2019neural}, and \citet{onken2020ot} have proposed specific architectural choices to reduce training cost. \subsection{Other techniques} \citet{Quaglino2020SNODE} describe speeding up training via spectral approximation. Unfortunately, this method is rather involved, and to our knowledge does not have a reference implementation \citet{hypersolvers} discuss hypersolvers, which are hybrids of neural networks and numerical differential equation solvers, trained to efficiently solve a desired Neural ODE. However the Neural ODE changes during training, making these most useful after training, to speed up inference. Independent of modifications to the model or training procedure, \citet{rackauckas2017differentialequations} and \citet{rackauckas2019diffeqflux} claim speed-ups simply through an improved implementation. \section{Further work} Our seminorm-based approach means that the integrals for $a_\theta$, $a_t$ in equation \eqref{eq:adjoint} are estimated based on the points selected to solve the equation for $a_z$. One can sensibly imagine refinements of the technique described here, by combining ODE solvers for $z$ and $a_z$ with quadrature rules for $a_\theta$ and $a_t$. \section{Conclusion} We have introduced a method for reducing the number of function evaluations required to train a neural differential equation, by reducing the number of rejected steps during the adjoint (backward) pass. Doing so offers substantial speed-ups across a variety of applications with no observed downsides. \subsubsection*{Acknowledgments} PK was supported by the EPSRC grant EP/L015811/1. PK and TL were supported by the Alan Turing Institute under the EPSRC grant EP/N510129/1.
{'timestamp': '2021-05-11T02:34:27', 'yymm': '2009', 'arxiv_id': '2009.09457', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09457'}
arxiv
\section{Introduction} ACM's consolidated article template, introduced in 2017, provides a consistent \LaTeX\ style for use across ACM publications, and incorporates accessibility and metadata-extraction functionality necessary for future Digital Library endeavors. Numerous ACM and SIG-specific \LaTeX\ templates have been examined, and their unique features incorporated into this single new template. If you are new to publishing with ACM, this document is a valuable guide to the process of preparing your work for publication. If you have published with ACM before, this document provides insight and instruction into more recent changes to the article template. The ``\verb|acmart|'' document class can be used to prepare articles for any ACM publication --- conference or journal, and for any stage of publication, from review to final ``camera-ready'' copy, to the author's own version, with {\itshape very} few changes to the source. \section{Template Overview} As noted in the introduction, the ``\verb|acmart|'' document class can be used to prepare many different kinds of documentation --- a double-blind initial submission of a full-length technical paper, a two-page SIGGRAPH Emerging Technologies abstract, a ``camera-ready'' journal article, a SIGCHI Extended Abstract, and more --- all by selecting the appropriate {\itshape template style} and {\itshape template parameters}. This document will explain the major features of the document class. For further information, the {\itshape \LaTeX\ User's Guide} is available from \url{https://www.acm.org/publications/proceedings-template}. \subsection{Template Styles} The primary parameter given to the ``\verb|acmart|'' document class is the {\itshape template style} which corresponds to the kind of publication or SIG publishing the work. This parameter is enclosed in square brackets and is a part of the {\verb|documentclass|} command: \begin{verbatim} \documentclass[STYLE]{acmart} \end{verbatim} Journals use one of three template styles. All but three ACM journals use the {\verb|acmsmall|} template style: \begin{itemize} \item {\verb|acmsmall|}: The default journal template style. \item {\verb|acmlarge|}: Used by JOCCH and TAP. \item {\verb|acmtog|}: Used by TOG. \end{itemize} The majority of conference proceedings documentation will use the {\verb|acmconf|} template style. \begin{itemize} \item {\verb|acmconf|}: The default proceedings template style. \item{\verb|sigchi|}: Used for SIGCHI conference articles. \item{\verb|sigchi-a|}: Used for SIGCHI ``Extended Abstract'' articles. \item{\verb|sigplan|}: Used for SIGPLAN conference articles. \end{itemize} \subsection{Template Parameters} In addition to specifying the {\itshape template style} to be used in formatting your work, there are a number of {\itshape template parameters} which modify some part of the applied template style. A complete list of these parameters can be found in the {\itshape \LaTeX\ User's Guide.} Frequently-used parameters, or combinations of parameters, include: \begin{itemize} \item {\verb|anonymous,review|}: Suitable for a ``double-blind'' conference submission. Anonymizes the work and includes line numbers. Use with the \verb|\acmSubmissionID| command to print the submission's unique ID on each page of the work. \item{\verb|authorversion|}: Produces a version of the work suitable for posting by the author. \item{\verb|screen|}: Produces colored hyperlinks. \end{itemize} This document uses the following string as the first command in the source file: \begin{verbatim} \documentclass[sigconf,authordraft]{acmart} \end{verbatim} \section{Modifications} Modifying the template --- including but not limited to: adjusting margins, typeface sizes, line spacing, paragraph and list definitions, and the use of the \verb|\vspace| command to manually adjust the vertical spacing between elements of your work --- is not allowed. {\bfseries Your document will be returned to you for revision if modifications are discovered.} \section{Typefaces} The ``\verb|acmart|'' document class requires the use of the ``Libertine'' typeface family. Your \TeX\ installation should include this set of packages. Please do not substitute other typefaces. The ``\verb|lmodern|'' and ``\verb|ltimes|'' packages should not be used, as they will override the built-in typeface families. \section{Title Information} The title of your work should use capital letters appropriately - \url{https://capitalizemytitle.com/} has useful rules for capitalization. Use the {\verb|title|} command to define the title of your work. If your work has a subtitle, define it with the {\verb|subtitle|} command. Do not insert line breaks in your title. If your title is lengthy, you must define a short version to be used in the page headers, to prevent overlapping text. The \verb|title| command has a ``short title'' parameter: \begin{verbatim} \title[short title]{full title} \end{verbatim} \section{Authors and Affiliations} Each author must be defined separately for accurate metadata identification. Multiple authors may share one affiliation. Authors' names should not be abbreviated; use full first names wherever possible. Include authors' e-mail addresses whenever possible. Grouping authors' names or e-mail addresses, or providing an ``e-mail alias,'' as shown below, is not acceptable: \begin{verbatim} \author{Brooke Aster, David Mehldau} \email{dave,judy,[email protected]} \email{[email protected]} \end{verbatim} The \verb|authornote| and \verb|authornotemark| commands allow a note to apply to multiple authors --- for example, if the first two authors of an article contributed equally to the work. If your author list is lengthy, you must define a shortened version of the list of authors to be used in the page headers, to prevent overlapping text. The following command should be placed just after the last \verb|\author{}| definition: \begin{verbatim} \renewcommand{\shortauthors}{McCartney, et al.} \end{verbatim} Omitting this command will force the use of a concatenated list of all of the authors' names, which may result in overlapping text in the page headers. The article template's documentation, available at \url{https://www.acm.org/publications/proceedings-template}, has a complete explanation of these commands and tips for their effective use. Note that authors' addresses are mandatory for journal articles. \section{Rights Information} Authors of any work published by ACM will need to complete a rights form. Depending on the kind of work, and the rights management choice made by the author, this may be copyright transfer, permission, license, or an OA (open access) agreement. Regardless of the rights management choice, the author will receive a copy of the completed rights form once it has been submitted. This form contains \LaTeX\ commands that must be copied into the source document. When the document source is compiled, these commands and their parameters add formatted text to several areas of the final document: \begin{itemize} \item the ``ACM Reference Format'' text on the first page. \item the ``rights management'' text on the first page. \item the conference information in the page header(s). \end{itemize} Rights information is unique to the work; if you are preparing several works for an event, make sure to use the correct set of commands with each of the works. The ACM Reference Format text is required for all articles over one page in length, and is optional for one-page articles (abstracts). \section{CCS Concepts and User-Defined Keywords} Two elements of the ``acmart'' document class provide powerful taxonomic tools for you to help readers find your work in an online search. The ACM Computing Classification System --- \url{https://www.acm.org/publications/class-2012} --- is a set of classifiers and concepts that describe the computing discipline. Authors can select entries from this classification system, via \url{https://dl.acm.org/ccs/ccs.cfm}, and generate the commands to be included in the \LaTeX\ source. User-defined keywords are a comma-separated list of words and phrases of the authors' choosing, providing a more flexible way of describing the research being presented. CCS concepts and user-defined keywords are required for for all articles over two pages in length, and are optional for one- and two-page articles (or abstracts). \section{Sectioning Commands} Your work should use standard \LaTeX\ sectioning commands: \verb|section|, \verb|subsection|, \verb|subsubsection|, and \verb|paragraph|. They should be numbered; do not remove the numbering from the commands. Simulating a sectioning command by setting the first word or words of a paragraph in boldface or italicized text is {\bfseries not allowed.} \section{Tables} The ``\verb|acmart|'' document class includes the ``\verb|booktabs|'' package --- \url{https://ctan.org/pkg/booktabs} --- for preparing high-quality tables. Table captions are placed {\itshape above} the table. Because tables cannot be split across pages, the best placement for them is typically the top of the page nearest their initial cite. To ensure this proper ``floating'' placement of tables, use the environment \textbf{table} to enclose the table's contents and the table caption. The contents of the table itself must go in the \textbf{tabular} environment, to be aligned properly in rows and columns, with the desired horizontal and vertical rules. Again, detailed instructions on \textbf{tabular} material are found in the \textit{\LaTeX\ User's Guide}. Immediately following this sentence is the point at which Table~\ref{tab:freq} is included in the input file; compare the placement of the table here with the table in the printed output of this document. \begin{table} \caption{Frequency of Special Characters} \label{tab:freq} \begin{tabular}{ccl} \toprule Non-English or Math&Frequency&Comments\\ \midrule \O & 1 in 1,000& For Swedish names\\ $\pi$ & 1 in 5& Common in math\\ \$ & 4 in 5 & Used in business\\ $\Psi^2_1$ & 1 in 40,000& Unexplained usage\\ \bottomrule \end{tabular} \end{table} To set a wider table, which takes up the whole width of the page's live area, use the environment \textbf{table*} to enclose the table's contents and the table caption. As with a single-column table, this wide table will ``float'' to a location deemed more desirable. Immediately following this sentence is the point at which Table~\ref{tab:commands} is included in the input file; again, it is instructive to compare the placement of the table here with the table in the printed output of this document. \begin{table*} \caption{Some Typical Commands} \label{tab:commands} \begin{tabular}{ccl} \toprule Command &A Number & Comments\\ \midrule \texttt{{\char'134}author} & 100& Author \\ \texttt{{\char'134}table}& 300 & For tables\\ \texttt{{\char'134}table*}& 400& For wider tables\\ \bottomrule \end{tabular} \end{table*} \section{Math Equations} You may want to display math equations in three distinct styles: inline, numbered or non-numbered display. Each of the three are discussed in the next sections. \subsection{Inline (In-text) Equations} A formula that appears in the running text is called an inline or in-text formula. It is produced by the \textbf{math} environment, which can be invoked with the usual \texttt{{\char'134}begin\,\ldots{\char'134}end} construction or with the short form \texttt{\$\,\ldots\$}. You can use any of the symbols and structures, from $\alpha$ to $\omega$, available in \LaTeX~\cite{Lamport:LaTeX}; this section will simply show a few examples of in-text equations in context. Notice how this equation: \begin{math} \lim_{n\rightarrow \infty}x=0 \end{math}, set here in in-line math style, looks slightly different when set in display style. (See next section). \subsection{Display Equations} A numbered display equation---one set off by vertical space from the text and centered horizontally---is produced by the \textbf{equation} environment. An unnumbered display equation is produced by the \textbf{displaymath} environment. Again, in either environment, you can use any of the symbols and structures available in \LaTeX\@; this section will just give a couple of examples of display equations in context. First, consider the equation, shown as an inline equation above: \begin{equation} \lim_{n\rightarrow \infty}x=0 \end{equation} Notice how it is formatted somewhat differently in the \textbf{displaymath} environment. Now, we'll enter an unnumbered equation: \begin{displaymath} \sum_{i=0}^{\infty} x + 1 \end{displaymath} and follow it with another numbered equation: \begin{equation} \sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f \end{equation} just to demonstrate \LaTeX's able handling of numbering. \section{Figures} The ``\verb|figure|'' environment should be used for figures. One or more images can be placed within a figure. If your figure contains third-party material, you must clearly identify it as such, as shown in the example below. \begin{figure}[h] \centering \includegraphics[width=\linewidth]{sample-franklin} \caption{1907 Franklin Model D roadster. Photograph by Harris \& Ewing, Inc. [Public domain], via Wikimedia Commons. (\url{https://goo.gl/VLCRBB}).} \Description{The 1907 Franklin Model D roadster.} \end{figure} Your figures should contain a caption which describes the figure to the reader. Figure captions go below the figure. Your figures should {\bfseries also} include a description suitable for screen readers, to assist the visually-challenged to better understand your work. Figure captions are placed {\itshape below} the figure. \subsection{The ``Teaser Figure''} A ``teaser figure'' is an image, or set of images in one figure, that are placed after all author and affiliation information, and before the body of the article, spanning the page. If you wish to have such a figure in your article, place the command immediately before the \verb|\maketitle| command: \begin{verbatim} \begin{teaserfigure} \includegraphics[width=\textwidth]{sampleteaser} \caption{figure caption} \Description{figure description} \end{teaserfigure} \end{verbatim} \section{Citations and Bibliographies} The use of \BibTeX\ for the preparation and formatting of one's references is strongly recommended. Authors' names should be complete --- use full first names (``Donald E. Knuth'') not initials (``D. E. Knuth'') --- and the salient identifying features of a reference should be included: title, year, volume, number, pages, article DOI, etc. The bibliography is included in your source document with these two commands, placed just before the \verb|\end{document}| command: \begin{verbatim} \bibliographystyle{ACM-Reference-Format} \section{Appendix} \label{sec:appendix} \subsection{Irreducibility of the Closed Queueing System} \label{sec:app-0} \begin{prop} The Markov chain describing the queueing system in Sect. ~\ref{sec:modelSingleJobType} is irreducible. \end{prop}% \vspace{-10pt} \begin{proof} It is sufficient to show that the states $(n,0,0)$ and $(x,y,zk)$ communicate. To show that $(x,y,zk)$ can be reached from $(n,0,0)$ in finite steps with positive probability, we show that each of the intermediate states in the following can be reached in finite steps with positive probability: \begin{align*} &(n,0,0) \xrightarrow{} (n-k,k,0) \xrightarrow{} (n-y-zk,y+zk,0)\\ &\xrightarrow{} (n-y-zk,y+(l-1)k,k) \xrightarrow{} (n-y-zk,y,zk). \end{align*} Starting from $(n,0,0)$, $(n-k,k,0)$ is reached in $k$ steps with probability 1. This is due to the fact that there can not be any batching unless there are at least $k$ jobs at the batching station. Further, $(n-y-zk,y+zk,0)$ is reached in another $y+(l-1)k$ steps where the $r$th step has probability $p_r = P[X_r<Y]$. Here, $X_r$ is an exponential variable with mean $1/((n-k-r+1) \lambda)$ and $Y$ is another independent exponential variable with mean $1/M$. Each of these steps corresponds to the outcome that the producer sends a job to the batcher before it could form a batch. Again, $(n-y-zk,y+(l-1)k,k)$ is reached from $(n-y-zk,y+zk,0)$ in a single step with probability $P[Y<X)]$ where $X$ is another independent exponential variable with mean $1/((n-y-zk) \lambda)$. That is, a batch is formed by the batcher before the dispatcher could send a new job. Finally, $(n-y-zk,y,zk)$ is reached in another $(l-1)$ step where the $r$th step has probability $P[Y<\min(X,Z_r)]$, $Z_r$ being an exponential variable with mean $1/(\min(n,r) \mu(k))$. Each step describes the event that the batching station merges a batch before either the dispatcher could send a new job or the sever could finish serving a batch. Similarly, we can show that starting from $(x,y,zk)$, there exists a way to reach $(n,0,0)$ in finite steps with positive probability, completing the proof. \end{proof} Since the Markov chain describing the states of the queueing system in Sect. \ref{sec:modelSingleJobType} is finite and irreducible, it is positive recurrent as well. Thus, there exists a unique steady state distribution for this chain that is obtainable by solving the equation $\pmb{\pi} \cdot \mathbf{Q} = 0$. Similarly, we can argue about the existence and uniqueness of the steady state distribution for the system described in Sect. \ref{sec:modelMultJobType}. \subsection{System with Two Job Types and Non-preemptive Priority} \label{sec:app-A} Unlike the case with preemptive priority in Sect. ~\ref{sec:modelMultJobTypeBig}, the case with non-preemption requires the number of type $1$ jobs in service explicitly. The system can be uniquely described by the tuple $(x,y_1,y_2,u_1 k_1,v_1 k_1)$ where $x$ is the number of active clients, $y_{\iota}$ is the number of type $\iota$ jobs not yet batched, $u_1$ is the number of type $1$ batches waiting in the queue and $v_1$ is the number of type $1$ batches in service and $s = (x,y_1,y_2,u_1 k_1,v_1 k_1)$ belongs to the state space \vspace{-10pt} \begin{align*} \mc{S}=\cbrac{(x_1,x_2,x_3,x_4,x_5):\in \mb{Z}_+^5: \mathbf{x}.\mathbf{1} \le n, k|x_4, k|x_5}. \end{align*} Here $\mathbf{1}$ denotes the column vector of ones whose size is implied from the context. Note that the number of type $2$ batches is given by $z_2 = (n-s.\mathbf{1})/k_2$ out of which $v_2 = \min(m-v_1,z_2)$ many are in service. The system evolves as CTMC and the jump rates are: \begin{align} \label{eq:jumpRatesNonPreemptive} s &\xrightarrow[\text{}]{\lambda x p} s-\mathbf{e_1}+\mathbf{e_2}, \thinspace x>0 \nonumber \\ &\xrightarrow[\text{}]{\lambda x (1-p)} s-\mathbf{e_1}+\mathbf{e_3}, \thinspace x>0 \nonumber \\ &\xrightarrow[\text{}]{M_1(k_1)\floor{y_1/k_1}} s-k_1\mathbf{e_2}+k_1\mathbf{e_4}, \thinspace y_1 \ge k_1, v=m \nonumber \\ &\xrightarrow[\text{}]{M_1(k_1)\floor{y_1/k_1}} s-k_1\mathbf{e_2}+k_1\mathbf{e_5}, \thinspace y_1 \ge k_1, v<m \nonumber \\ &\xrightarrow[\text{}]{M_2(k_2)\floor{y_2/k_2}} s-k_2\mathbf{e_2}, \thinspace y_2 \ge k_2 \nonumber \\ &\xrightarrow[\text{}]{v_1\mu_1(k_1)} s+k_1\mathbf{e_1}-k_1\mathbf{e_5}, \thinspace v_1 \ge 1, u_1=0 \nonumber\\ &\xrightarrow[\text{}]{v_1\mu_1(k_1)} s+k_1\mathbf{e_1}-k_1\mathbf{e_4}, \thinspace v_1 \ge 1, u_1 \ge 1 \nonumber\\ &\xrightarrow[\text{}]{v_2\mu_2(k_2)} s+k_2\mathbf{e_1}, \thinspace v_2 \ge 1, u_1 = 0 \nonumber\\ &\xrightarrow[\text{}]{v_2\mu_2(k_2)} s+k_2\mathbf{e_1}-k_1\mathbf{e_4}+k_1\mathbf{e_5}, \thinspace v_2 \ge 1, u_1 \ge 1, \end{align} where $s=(x,y_1,y_2,z_1 k_1)$ and $v=v_1+v_2$ denotes the total number of busy servers. The jump rates to any other state is zero. Similar to Sect. ~\ref{sec:modelMultJobType}, we can solve $\pmb{\pi} \cdot \mathbf{Q} = 0$ to get the steady state distribution $\pmb{\pi}_0$, derive the optimal throughput and find the optimal batch size $k^*$ for maximum throughput. \subsection{Extension to Multiple Job Types with Preemptive Priority} \label{sec:manyJobManyService} Let us recall the framework described in Sect. \ref{subsec:mFTwoJobs} and consider the case that there are $r$ types of jobs in the system with job of type $i_1$ having preemptive priority over type $i_2$ whenever $i_1<i_2$. We suppose that each client produces a job of type $i$ with probability $p_i$ where $\sum p_i = 1$. Further, we assume batches go through $d$ levels of service before being unbatched and finally individual responses are sent back to the clients. The workflow of the system requires that after each level of service, batches wait in a common queue if all servers of the next stage\footnote{we use level/stage interchangeably} are busy. Let $k_i$ denote the batch size for job type $i$ for all stages, $m_j$ denote the total number of servers at stage $j$ and $\mu_{ij}(k_i)$ denote the service rate of type $i$ at level $j$ for batch size $k_i$. We will suppress the argument for $\mu_{ij}$ when the dependence is clear. If $X_{ij}^{(n)}(t)$ denotes the number of type $i$ jobs that are waiting for or are at $j$-th level of service, we see that $(X_{ij}^{(n)}(t), 1\le i \le r, 1 \le j \le d, t\geq 0)$ is Markov on state space $\mc{S}=\cbrac{(x_{ij})\in \mb{Z}_+^{rd}: \sum_{i=1}^r \sum_{j=1}^d x_{i,j} \leq n}$. Note that $X_{1j}$ includes unbatched jobs of type $j$ as well whereas $X_{ij}$, $i>1$, only comprises of batches. We consider the corresponding scaled process $w^{(n)}(t)=(w_{ij}^{(n)}(t))$,$w_{ij}^{(n)}(t)=X_{ij}^{(n)}(t)/n$, $1\le i \le r, 1 \le j \le d$. We have \begin{align}\label{eq:diffMultServMultType} \dot w_{11} &= \lambda p_1 \brac{1-\sum_{a,b} w_{ab}}- \mu_{11} w_{11}, \\ \nonumber \dot w_{i1} &= \lambda p_i \brac{1-\sum_{a,b} w_{ab}}- \mu_{i1} \min \brac{w_{i1},\max \brac{0,\alpha_1-\sum_{l<i}\frac{w_{l1}}{k_l}}k_i },\\ \nonumber \dot w_{1j} &= \mu_{1(j-1)} w_{1(j-1)}- \mu_{1j} w_{1j}, \\ \nonumber \dot w_{ij} &= \mu_{i(j-1)} \min \brac{w_{i(j-1)},\max \brac{0,\alpha_{j-1}-\sum_{l<i}\frac{w_{l(j-1)}}{k_l}}k_i } \\ \nonumber &- \mu_{ij} \min \brac{w_{ij},\max \brac{0,\alpha_j-\sum_{l<i}\frac{w_{lj}}{k_l}}k_i }, 2\le i \le r, 2 \le j \le d, \end{align} where $m_j/n \to \alpha_j$ and $\sum_{i,j} w_{ij} \le 1$. We use the shorthand notation $\frac{d\mathbf{w}}{dt} = \mathbf{F}(\mathbf{w})$ for \eqref{eq:diffMultServMultType}. We notice that $\mathbf{F}$ is Lipschitz continuous which follows from arguments identical to part (i) of Thm. \ref{thm:meanfield_onetype}. Also, the stationary measure $\pi_w^{(n)}$ is tight as it is defined on the compact space $[0,1]^{rd}$. We observe that the dynamical system given by \eqref{eq:diffMultServMultType} is piecewise linear and we investigate global attraction to the fixed point when $k_i=k$ and there is only one level of service. \begin{theorem}\label{thm:glbalAttractionMultJob} Consider the system in \eqref{eq:diffMultServMultType} when $k_i=k$, $1\le i \le r$ and $d=1$. The system is globally attractive to \begin{align*} \mathbf{w}^*=\begin{cases} \mathbf{A}^{-1} \mathbf{c_a}, \quad \text{if } \langle \mathbf{A}^{-1} \mathbf{c_a}, 1 \rangle < k \alpha\\ \mathbf{B}^{-1} \mathbf{c_b}, \quad \text{otherwise}, \end{cases} \end{align*} where \begin{align*} \mathbf{A} &= \begin{bmatrix} -\mu_1- \lambda p_1 & - \lambda p_1 & \dots & - \lambda p_1\\ -\mu_2 & -\mu_2- \lambda p_2 & \dots & - \lambda p_2\\ \dots & \dots & \dots & \dots \\ -\mu_r & -\mu_r & \dots & -\mu_r- \lambda p_r \end{bmatrix},\\ \mathbf{B} &= \begin{bmatrix} -\mu_1- \lambda p_1 & - \lambda p_1 & \dots & - \lambda p_1\\ -\mu_2 & -\mu_2- \lambda p_2 & \dots & - \lambda p_2\\ \dots & \dots & \dots & \dots \\ \mu_r- \lambda p_r & \mu_r- \lambda p_r & \dots & -\lambda p_r \end{bmatrix},\\ \mathbf{c_a} &= \begin{bmatrix} - \lambda p_1 \\ - \lambda p_2\\ \dots \\ - \lambda p_r \end{bmatrix} , \mathbf{c_b} = \begin{bmatrix} - \lambda p_1 \\ - \lambda p_2\\ \dots \\ - \lambda p_r + k \alpha \mu_r \end{bmatrix}. \end{align*} \end{theorem} \begin{proof} When $k_i=k$, $\alpha_1=\alpha$ and $d=1$, we can suppress the service stage index $j$ and the ODE's from \eqref{eq:diffMultServMultType} reduces to: \begin{align}\label{eq:diffOneServMultType} \dot w_{1} &= \lambda p_1 \brac{1-\sum_{a} w_{a}}- \mu_{1} w_{1}, \nonumber \\ \dot w_{i} &= \lambda p_i \brac{1-\sum_{a} w_{a}}- \mu_{i} \min \brac{w_{i},\max \brac{0,k \alpha-\sum_{l<i}w_{l}}}, 2\le i \le r. \end{align} Next we show that $\mathbf{B}$ is non-singular and real parts of its eigenvalues are negative. Same holds for $\mathbf{A}$ which can be proved in a similar, although simpler, way. Let $\mathbf{Bx} = \mathbf{0}$ with $\mathbf{x} \ne \mathbf{0}$. Then \begin{align*} \begin{bmatrix} \mu_1 x_1\\ \mu_2 x_2\\ \dots \\ \mu_r x_r \end{bmatrix} & = - \sum_l x_l \begin{bmatrix} \lambda p_1\\ \lambda p_2\\ \dots \\ \lambda p_r - \mu_r \end{bmatrix}. \end{align*} Since $\mathbf{x} \ne \mathbf{0}$, we have $\sum_l x_l \ne 0$ and \begin{align*} & \sum_l x_l = -\lambda \brac{\sum_l x_l } \brac{\sum_l \frac{p_l}{\mu_l} }+ \sum_l x_l \\ \text{i.e.,} \quad & \lambda \sum_l \frac{p_l}{\mu_l} = 0, \end{align*} which contradicts positivity of $\lambda$, $\mu_i$'s and $p_i$'s. Next we prove that the eigenvalues of $\mathbf{B}$ have negative real part. Let $\theta$ be an eigenvalue and $\mathbf{u}$ be a corresponding eigenvector. For $\theta \ne -\mu_j ~\forall j$, we have \begin{align*} & u_j(\theta+ \mu_j) = -\lambda p_j \sum_{l} u_l, \quad 1 \le j \le r-1 \\ \text{and} \quad & u_r(\theta+ \mu_r) = \brac{-\lambda p_r + \mu_r} \sum_{l} u_l. \end{align*} Since $\theta \ne -\mu_j ~\forall j$ and $\mathbf{u} \ne \mathbf{0}$, we have $\sum_{l} u_l \ne 0$ and \begin{align*} &\sum_l u_l = \brac{-\frac{\mu_r}{\mu_r + \theta}+ \sum_l \frac{- \lambda p_l}{\mu_l + \theta}} \brac{\sum_l u_l}, \\ \text{i.e.,}~ & \sum_l \frac{\lambda p_l}{\mu_l + \theta} = -1 +\frac{\mu_r}{\mu_r + \theta}, \\ \text{i.e.,}~ & \sum_l \frac{\lambda p_l (\mu_l + \Re{(\theta)})}{|\mu_l + \theta|^2} = -1 + \frac{\mu_r (\mu_r + \Re{(\theta)})}{|\mu_r + \theta|^2}. \end{align*} The left and right hand sides have different signs unless $\Re{(\theta)}<0$. If $\theta = -\mu_j$ for some $j$, we are done anyway. Now we return to \eqref{eq:diffOneServMultType} and prove global attraction to the unique fixed point under different scenarios. {\bf Case 1}: $k \alpha \ge 1$ \\ In this case, \eqref{eq:diffOneServMultType} becomes \begin{align*} \frac{d\mathbf{w}}{dt}= \mathbf{A} \mathbf{w} - \mathbf{c_a}. \end{align*} and the system is globally attractive to the unique fixed point $\mathbf{A}^{-1} \mathbf{c_a}$ as $\mathbf{A}$ is non-singular and all its eigenvalues have negative real part. {\bf Case 2}: $k \alpha < 1$ \\ We start by showing $\langle \mathbf{A}^{-1} \mathbf{c_a}, 1 \rangle < k \alpha$ iff $\langle \mathbf{B}^{-1} \mathbf{c_b}, 1 \rangle < k \alpha$. For if $\mathbf{A} \mathbf{x} = \mathbf{c_a}$ and $\mathbf{B} \mathbf{y} = \mathbf{c_b}$, we have \begin{align*} \sum_l x_l &= \frac{\sum_l \frac{\lambda p_l}{\mu_l}}{1+\sum_l \frac{\lambda p_l}{\mu_l}} \\ \text{and}~ \sum_l y_l &= \frac{\sum_l \frac{\lambda p_l}{\mu_l}- k \alpha}{\sum_l \frac{\lambda p_l}{\mu_l}}. \end{align*} And \begin{align*} \frac{\sum_l \frac{\lambda p_l}{\mu_l}}{1+\sum_l\frac{\lambda p_l}{\mu_l}} < k \alpha \iff \frac{\sum_l \frac{\lambda p_l}{\mu_l}- k \alpha}{\sum_l \frac{\lambda p_l}{\mu_l}} < k \alpha. \end{align*} Next, we observe that the system eventually enters the region $\sum_{i \le r-1} w_{i} < k \alpha$. This is because existence of a lowest index $i_0<r-1$ with $\sum_{i\le i_0} w_{i} \ge k \alpha$ implies $\frac{dw_i}{dt} \ge 0$ for $i \ge i_0$, since the domain of interest is $\sum_{i} w_{ij} \le 1$. This is an unstable system with $w_i$, $i>i_0$ increasing forever and thus it eventually enters the region $\sum_{i \le r-1} w_{i}< k \alpha$. Let us assume $\langle \mathbf{A}^{-1} \mathbf{c_a}, 1 \rangle < k \alpha$. If we start the system in the subregion $\sum_{i \le r} w_{i}< k \alpha$, the system evolves in a fashion similar to the case $k \alpha \ge 1$ and converges to $ \mathbf{A}^{-1} \mathbf{c_a}$. When the system is started in the subregion $\sum_{i \le r} w_{i} \ge k \alpha$, the evolution is given by \begin{align*} \frac{d\mathbf{w}}{dt}= \mathbf{B} \mathbf{w} - \mathbf{c_b}. \end{align*} We see that $\mathbf{B}$ is non singular and the eigenvalues have negative real part. Hence the system move toward the point $ \mathbf{B}^{-1} \mathbf{c_b}$. However, $\langle \mathbf{A}^{-1} \mathbf{c_a}, 1 \rangle < k \alpha$ implies $\langle \mathbf{B}^{-1} \mathbf{c_b}, 1 \rangle < k \alpha$. Hence, the system eventually enters the subregion $\sum_{i \le r} w_{i}< k \alpha$ and converges to $ \mathbf{A}^{-1} \mathbf{c_a}$. For the case $\langle \mathbf{A}^{-1} \mathbf{c_a}, 1 \rangle > k \alpha$, the system converges to $ \mathbf{B}^{-1} \mathbf{c_b}$ and the proof proceeds similarly. \end{proof} \newpage \section{Conclusion}\label{sec:conclusion} In this work, we optimize the throughput of closed data-processing systems that process incoming jobs in batches. Through modelling the system as a closed queueing network, where batches observe a sub-additive speedup in execution, we obtain the optimal throughput as a function of the batch size for $n$ clients and $m$ servers. The considered system resembles standard database systems where clients wait for the result of an input query to generate the next one. We contribute a mean-field model that captures the system throughput in the asymptotic regime and show that the analytical results accurately provide the optimal throughput, as well as, the corresponding optimal batch size in simulation, as well as, for a prototype of a large commercial system. \vspace{-2pt} \section{Evaluation} \label{sec:numerical} In this section, we evaluate the performance of our model for throughput optimization using both simulations and an application to a research prototype of a large commercial database system. We first show accuracy of our model for simulation results and subsequently describe the details of experimental evaluations which includes the system layout, the experiment description, data collection and the model performance. \subsection{Simulations} \label{sec:numericalEval_} We first numerically compare our exact and asymptotic results to corresponding simulation results. For all comparisons, the \textit{exact} model obtains the throughput by solving for the steady state distribution numerically whereas for \textit{simulations}, we plot the observed throughput when the system is simulated using \eqref{eq:jumpRates}. The unit of time for simulations is seconds and a linear form of speedup is assumed. Further, the following system parameters are used for the single job type case (The parameters correspond to the range of values observed in the prototype system described in the next section): \begin{itemize} \item job generation rate $\lambda = 5\cdot 10^{3}$, \item batch service time $1/\mu(k) = 3.6\cdot 10^{-4}+5.2\cdot 10^{-5} ~k$, \item batching time $1/M(k) = 7.2\cdot 10^{-6}+1\cdot 10^{-6} ~k$. \end{itemize} For two job types, type $1$ job has higher priority and is generated with $20\%$ probability. We modify the service rates as below and keep other parameters unchanged. \begin{itemize} \item type $1$ service time $1/\mu_1(k) = 1/(5 \cdot \mu_2(k))$ \item type $2$ service time $1/\mu_2(k) = 5.4\cdot 10^{-4}+5.3\cdot 10^{-4} ~k$ \end{itemize} In Figures~\ref{fig:optTPut-vs-n-1job}-\ref{fig:tPutCompare3}, we compare the steady state throughput for the non-asymptotic/exact model, the mean-field model and simulations, for both the one-job type and the two-job type cases with preemptive priority. In all figures we vary the number of servers $m$ and obtain the corresponding steady state throughput as a function of the number of clients $n$ or of the batch size $k$. \begin{figure*}[t!] \centering \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/steadyTputCompare_noServer_4.pdf} \caption{\label{fig:tPutCompare4serv}% $m=4$} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/steadyTputCompare_noServer_8.pdf} \caption{\label{fig:tPutCompare8serv}% $m=8$} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/steadyTputCompare_noServer_16.pdf} \caption{\label{fig:tPutCompare16serv}% $m=16$} \end{subfigure} \caption{\label{fig:tPutCompare3}% Steady state throughput of the system for one job-type for several values of the number of servers $m$; each set of lines corresponds to a value of $n \in [50, 100, 300, 500, 1000]$ in an increasing order (from left to right). Observe that the exact and simulated throughput decreases sharply at points where the number of maximum possible active server drops by one, becoming more apparent for larger batch sizes due to higher relative change. Both the exact and the mean-field model accurately mimic the steady state throughput and accurately capture the optimal batch sizes $k^*$ (from the peak point). }% \end{figure*} \begin{figure*}[t!] \centering \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/steadyTputComparePreemptive00_noServer_4.pdf} \caption{\label{fig:tPutCompare4servPreEmp}% $m=4$} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/steadyTputComparePreemptive00_noServer_8.pdf} \caption{\label{fig:tPutCompare8servPreEmp}% $m=8$} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/steadyTputComparePreemptive00_noServer_16.pdf} \caption{\label{fig:tPutCompare16servPreEmp}% $m=16$} \end{subfigure} \caption{\label{fig:tPutCompare3PreEmp}% Steady state throughput with two job-types and preemptive priority for several values of $m \in [4,8,16]$; each set of lines corresponds to a value of $n \in [50, 100, 200]$ in an increasing order (from left to right).}% \end{figure*} \begin{figure}[h!] \centering \begin{subfigure}[t]{0.48\columnwidth} \centering \includegraphics[width=1\textwidth]{figures/avgActiveServerWithOptHash200ag.pdf} \caption{\label{fig:avgActiveServer}% Average number of active servers $\eta$ in the steady state with $300$ clients attached.} \end{subfigure} \hfill \begin{subfigure}[t]{0.48\columnwidth} \centering \includegraphics[width=1\textwidth]{figures/mixingPlotLinLog10hash2.pdf} \caption{\label{fig:mixing}% Total variation distance with steady state distribution $\pmb{\pi_0}$ over time.} \end{subfigure} \caption{\label{fig:others2}% Steady state and transient characteristics from exact analysis for the system with $n=300$ clients with one job type. Fig.~\ref{fig:others2}(a) shows the average number of active servers $\eta$ in the steady state. The annotated optimal batch sizes show the point until which the speedup compensates for diminishing server utilization. Fig.~\ref{fig:others2}(b) shows the total variation distance with the steady state distribution $\pmb{\pi_0}$ for the respective optimal batch sizes over time, i.e., how the marginal distribution of the system states gets reasonably close to the steady state distribution $\pmb{\pi_0}$ within $10$~ms. }% \vspace{-10pt} \end{figure} In Fig.~\ref{fig:optTPut-vs-n-1job} we show the optimal steady state throughput as a function of the number of clients $n$, for fixed values of the number of servers $m$. The non-asymptotic/exact model and more interestingly the mean-field model accurately capture the optimal steady state throughput obtained from simulations. The optimal throughput is concave in the number of clients $n$, as it is given by the mean-field analysis as $m k^* \mu(k^*)$ in the limit with $k^*$ from~\eqref{eq:optimal_k_mean_field}. Similar observations hold in Fig.~\ref{fig:optTPut-vs-n-2jobs} depicting the optimal total steady state throughput for the two job-type case with preemptive priority. The next set of results in Figs.~\ref{fig:tPutCompare3}-\ref{fig:tPutCompare3PreEmp} concern with the steady state throughput as a function of the batch size $k$. In Fig.~\ref{fig:tPutCompare3} we show how the exact/non-asymptotic model and the mean-field model accurately capture the simulated steady state throughput and provide the optimal batch sizes $k$. Figure~\ref{fig:tPutCompare3PreEmp} shows the total throughput for the case of two job-types with preemptive priority. Next, we consider the trade-off between the speedup and the idling of servers. Fig. \ref{fig:avgActiveServer} shows the extent to which the effect of idling is compensated by the batching speedup for a set-up with $n=300$ clients and different number of servers. For this same set-up, we also look at the convergence rate of the system to the steady state in Fig. \ref{fig:mixing}, but only for the optimal batch size given by the exact analysis. We assume the system starts at the state where all jobs are at the producer/clients station and numerically compute the marginal distribution at regular time intervals. To visualize the distance of the marginal with the steady state distribution of the system, we use the total variation distance as defined in~\cite{LevinPeresWilmer2006}. \looseness=-1 To conclude this subsection, we note that the mean-field results accurately capture both the optimal steady state throughput and the corresponding optimal batch size $k^*$ of the system. \subsection{Experimental Evaluation} In this section, we discuss the performance of our system for experimental evaluations. We start with the description of the system and data collection before comparing our results to actual observation. \subsubsection{System Layout} \label{subsec:system_layout} Here we provide an overview of our system and the Telecom Application Transaction Processing (TATP) benchmark \cite{neuvonen2009tatp} that is used to retrieve the data for our model. We run our experiments in a research prototype based on a commercial in-memory database. The database receives a client-request as an SQL string and compiles it to optimized execution plans or extracts such plan from a plan cache, if the string was already compiled for a previous request. Each plan consists of several data-operators, e.g., for accessing tables by index or scanning, or aggregating results, as well as operators for sending the results back to the requesting client. \looseness = -1 Fig.~\ref{fig:system_layout} shows that incoming requests are not executed instantly but rather wait in a queue, until the number of waiting requests reaches a certain threshold (i.e., the batch size). Once this event occurs, the number of requests to grab from the waiting queue is determined, we extract that amount of requests, preferring the write jobs and create one SQL string from the requests. The service thread then compiles and executes the merged SQL string, which produces a shared result. Finally, the service thread splits the shared result to return to each client its individual result. Service threads execute three tasks on a merged batch taken from the waiting queue: \begin{enumerate*} \item\label{enum:compile} compilation, \item\label{enum:exec} execution, and \item\label{enum:split} splitting the results. \end{enumerate*} For merging, we need to execute some string operations to create the merged SQL string. The processing time of this step depends on the number of requests extracted from the waiting queue. In comparison, step (\ref{enum:compile}) first looks up the cache, whether that SQL string was already compiled and only if this is not the case, it compiles the string itself. This is a crucial step, because compiling a string into an executable plan is a time consuming task. The execution of a batch in step (\ref{enum:exec}) heavily depends on the table format (row-store or column-store \cite{turner1979columnstore}) and whether an index exists on the filtered column or the column needs to be scanned. And finally, in the last step (\ref{enum:split}), the service thread scans the shared result for each client that belongs to the batch and sends back the matching rows. \subsubsection{Experiment and Data Description} \label{sec:expDesc} For our experiments, we focus on two transactions of the TATP benchmark \cite{neuvonen2009tatp}, a well known Online Transactional Processing (OLTP) benchmark for databases. The two transactions used are GET\_SUBSCRIBER\_DATA, consisting of one read operation and the DELETE\_CALL\_FORWARDING, consisting of one read and one write, namely a delete operation. Each operation is expressed as an SQL string, which is sent to the database and processed on the server side, as described earlier. Each of the reading and writing operations access only one row of exactly one table to read or delete from and are usually processed in less than \SI{1}{\milli\second}. We adjust the DELETE\_CALL\_FORWARDING transaction in such a way that it submits a single read operation in 80\% of all cases and a delete operation in the remaining 20\%. We run our experiments on a base table size of $10^4$ rows with a varying number of clients. The database and the clients run on different sockets of the same server with SUSE Linux Enterprise Server 12 SP1 (kernel: 4.1.36-44-default), having \SI{512}{\giga\byte} of main memory, four sockets with \SI{10}{cores} each and no hyperthreading. The server runs on Intel(R) Xeon(R) CPU E7-4870, with a speed of \SI{2.4}{\giga\hertz} and a cache size of \SI{30}{M\byte}. Internally, we keep track of the job arrival and retrieval times from the queue, as well as the execution time of its batch. This sums up the data retrieved from the experiments and used for creating and validating the model. \begin{figure}[t] \centering \includegraphics[width=0.98\linewidth]{figures/System_Layout.pdf} \caption{Query Batching in the Database System. Requests of the same SQL string are merged and executed as a batch. } \label{fig:system_layout} \vspace{-5pt} \end{figure} \subsubsection{Fitting the Experimental Data} \label{subsec:dataFitting} In the following, we employ standard optimal experiment design techniques to characterize the service distributions for all batch sizes, while letting the batch-processing system run only for some selected batch sizes. To this end, we estimate the batching speedup and characterize the corresponding service distributions. For the sake of brevity, we describe the estimation process for only one job type; the two job-type case proceeds similarly. First, we express the batching speedup through the function $g:\mathbb{N} \mapsto \setOfReals_{+}$ where $g(k) = 1/\mu(k)$. To avoid triviality, we assume sub-additivity, i.e., $g(k_1+k_2) \le g(k_1)+g(k_2)$. In the experimental evaluation, we consider the best fit of the empirical data to have one of the following speedup forms: \begin{itemize} \item $g_1(k) = ak+b$ with $a<1$ \item $g_2(k) = \gamma k^\alpha$ with $\alpha<1$ \item $g_3(k) = c \log k+d$ with $c<1$. \end{itemize} Each speedup function is characterized by some parameters which are estimated by fitting the mean service times for different batch sizes. To estimate the speedup function in the given commercial database system we calculate a set of batch sizes which minimize the estimation error. Our approach is based on a linear regression where we transform the speedup function into a linear combination of weights $\mathbf{w}$ and feature vectors $\pmb{\phi}(k)$. Assuming a Gaussian distribution on the error of the responses of this model, i.e., the mean service times, the standard linear model can be used and hence the ordinary least square (OLS) regression estimate of the regression weights can be found. For the experiment design on the batch-processing system, i.e., deciding on the set $A$ containing which batch sizes to run for the subsequent fitting, we employ a D-optimal design \cite{pukelsheim1993optimal} to minimize the log determinant of the covariance matrix of the OLS estimator. The size of the subset $A$ is usually set in accordance with time and cost considerations. We solve this integer optimization problem numerically after relaxation using the CVX package \cite{grant2008cvx}. Finally, we denote the set of sample service times corresponding to the batch size $k \in A$ as $S_k$, and the respective mean service times as $\mathbf{E}[Y(k)]$, and find the speedup function $g$ minimizing the corresponding OLS estimation error, i.e., $g = g_m$ where $m = \argmin_{i} e_i$ and $e_i = \sum_{k \in A} \big( g_i(k|\hat{\mathbf{\theta_i}})-\mathbf{E}[Y(k)] \big)^2$. Here, we express the parameter space corresponding to the parameter vector $\mathbf{\theta_i}$ of the speedup function $g_i$ as $\mathbf{\Theta_i}$, and adopt an OLS approach to estimate $\mathbf{\theta_i}$ through $ \hat{\mathbf{\theta_i}} = \argmin_{\theta_i \in \Theta_i} \sum_{k \in A} \big( g_i(k)-\mathbf{E}[Y(k)] \big)^2$.\looseness=-1 \begin{figure}[t!] \centering \begin{subfigure}[t]{0.48\columnwidth} \centering \includegraphics[width=1\textwidth]{figures/roComparisonClents100.pdf} \caption{\label{fig:serverWiseOptBatch100}% $n=100$} \end{subfigure} \hfill \begin{subfigure}[t]{0.48\columnwidth} \centering \includegraphics[width=1\textwidth]{figures/roComparisonClents300.pdf} \caption{\label{fig:serverWiseOptBatch300}% $n=300$} \end{subfigure} \caption{\label{fig:others1}% Experimental evaluation: Comparison of the observed optimal batch sizes $k^*$ and the model estimates with increasing number of servers. The system receives only one job type, i.e., \textit{read} jobs, and the comparison is done for a varying number of clients. As expected the optimal batch size decreases with increasing number of servers due to server idling.}% \vspace{-7pt} \end{figure} \begin{figure}[t!] \centering \begin{subfigure}[t]{0.48\columnwidth} \centering \includegraphics[width=1\textwidth]{figures/comparePreNonPre4.pdf} \caption{\label{fig:preNpCompare4}% $m=4$} \end{subfigure} \hfill \begin{subfigure}[t]{0.48\columnwidth} \centering \includegraphics[width=1\textwidth]{figures/comparePreNonPre8.pdf} \caption{\label{fig:preNpCompare8}% $m=8$} \end{subfigure} \caption{\label{fig:preNpCompare}% Equivalence of preemptive and non-preemptive priority in terms of the steady state throughput for a simulated system with two job-types; each set of lines corresponds to a value of $n \in [50, 100, 300]$ in an increasing order (from left to right).}% \vspace{-10pt} \end{figure} \subsubsection{Evaluation} For the experimental evaluation we set a measurement budget for the fitting and parameter estimation, i.e., we estimate the service times and the speedup based on measurement runs for only $\sim5\%$ of all possible batch sizes. Using the optimal experimental design approach from the previous section we calculate the set of batch sizes to be measured $A$ for $n\in\{100,300\}$ clients. For each $n$ we estimate the mean batching and service times for each batch size $k \in A$ from independent runs. The mean service times for batch sizes $k \in A$ are then used to estimate the speedup. \looseness=-1 Equipped with the estimated service and batching rates, we populate the intensity matrix $Q$ using~\eqref{eq:jumpRates} and subsequently solve for the steady state distribution. We further calculate the steady state throughput using \eqref{eq:steadyThroughput} and obtain the corresponding optimal batch size. We repeat the same process for a varying number of servers $m$ and for a varying number of clients $n$ up to $300$. Note that the database prototype at hand has at most $m=10$ available servers. In addition, we run an exhaustive experiment for all possible batch sizes to find the empirical optimum for the set-up with a varying number of servers and clients for the sake of completeness. Fig.~\ref{fig:others1} shows a comparison of the modelled and observed optimal batch sizes $k^*$ for an increasing number of servers and different number of clients $n$. We observe that our models are accurate. Both the non-asymptotic/exact model as well as the mean-field model capture the decline in the optimal batch size with an increasing number of servers $m$. \begin{figure}[t] \centering \includegraphics[width=0.98\linewidth]{figures/rwComparisonServer4.pdf} \caption{ Optimal batch sizes for \textit{read} and \textit{write} job types with $m=4$ servers and a varying number of clients $n$. The system implements non-preemptive priority of \texttt{write} jobs over \texttt{read} jobs. For mean field analysis, optima are approximated by the preemptive model in Sect. ~\ref{subsec:mFTwoJobs} whereas the exact model follows the workflow in Sect. ~\ref{sec:app-A}. As expected, modelled and observed optima rise in close proximity. } \label{fig:compareRW} \vspace{-10pt} \end{figure}% We also conduct experiments where the submitted jobs can be of two types: \textit{read} or \textit{write}. A new request can be a \textit{read} query with probability $0.8$ and a \textit{write} query with probability $0.2$. Further, the \textit{write} jobs have priority over the \textit{read} jobs. The prototype system provides a non-preemptive priority to the \textit{write} jobs; however, the difference in the system throughput diminishes in the stationary asymptotic regime, as illustrated through simulations in Fig. ~\ref{fig:preNpCompare}. In Fig.~\ref{fig:compareRW} we compare the modelled and the actual optimal batch sizes in the system for the two job case for a varying number of clients and observe a reasonably close match. The contributed mean-field model is seen to capture the system behavior very well. \section{Introduction} A key technique to cutback overhead in data-processing systems is \textit{service batching}, i.e., collecting the inputs to form batches that are then processed as one entity. The rationale lies in the overhead amortization with increasing the batch size. A prominent example highlighting the benefits of service batching is a Linux-based system in which the network-card throughput can be substantially increased by batching data packets~\cite{linux-packetbatching}. Similar improvements hold in software-defined networks by passing switching rule updates in batches from controllers to network switches~\cite{Wen-ICDCS16}. In this work, we analyze the benefits of service batching in the context of large-scale data-processing systems, and in particular of a large commercial database system. We consider a closed system in which $n$ clients generate jobs to be processed by $m$ parallel servers. Each client alternates between being in either an \emph{active} or an \emph{inactive} state; in the former it produces a job and in the latter it awaits the job to be fully processed. We note that each client can have at most one job in the system, i.e., a client produces a new job no sooner than its previous one finished execution. The servers process jobs in batches of size $k$, i.e., once $k$ clients produce $k$ jobs these are sent for batch processing -- and may have to wait in a central queue if all servers are busy; see Fig.~\ref{fig:closedSystemDesc}\footnote{All times are exponentially distributed with the rates $\lambda$, $M$, and $\mu$, the last two depending on the batch size $k$; we will show that this technically convenient assumption is valid by fitting our model's parameters from a real-world system.}. This model is representative for some real-world data-processing systems such as databases employing Multi Query Optimization \cite{Thomson:2012:CFD:2213836.2213838:Calvin,rehrmann2018oltpshare,Sellis:1988:MO:42201.42203:MQO}. Besides a model with a single job type, we also consider a generalized model with two job types. A typical example would be \textit{read} and \textit{write} jobs in a database system; such jobs not only have different average processing times but some are prioritized over the others, e.g., the \textit{write} jobs have non-preemptive priority over the \textit{read} jobs for consistency reasons. \begin{figure}[t] \centering \includegraphics[width=0.99\linewidth]{figures/closedSystemDesc.pdf} \caption{A closed queueing system with $n$ clients and $m$ servers. Clients are either active or inactive and produce jobs at rate $\lambda x$ when $x$ of them are \emph{active}. The batcher produces batches of size $k$ at rate $M\floor{y/k}$ when there are $y$ available jobs. The service station consists of a single queue and $m$ parallel servers, each having a service rate $\mu$; the overall \emph{batch} service rate is $\mu\min(m,z)$ when $z$ batches are available. } \label{fig:closedSystemDesc} \vspace{-10pt} \end{figure}% Classical approaches to queueing systems with batch arrivals and batch service disciplines have been intensively studied, e.g., in \cite{bailey1954queueing,deb1978optimal,chaudhry1983first,Bolch:2005} and the references therein. Most of these studies were either mainly concerned with open queueing systems or focused on different properties of interest such as the product form; for a more thorough discussion see Sect.~\ref{sec:related_work}. To the best of our knowledge the closed queueing system from Fig.~\ref{fig:closedSystemDesc} is new, i.e., it does not fit existing models. The main contribution of this paper consists in the throughput optimization in a closed batching system characteristic to a large production system; this involves finding the optimal batch sizes. We first provide the exact analysis by solving for the balance equations in a Markov model, an approach requiring at least $\omega\left(n^4\right)$ computational time. We also provide the corresponding mean-field models which yield exact results in an asymptotic regime whereby both $n$ and $m$ are proportionally scaled. This second approach yields the optimal (asymptotic) throughput in $O(1)$, which is particularly appealing given that existing empirical approaches rely on extensive numerical searches for the optimal batch sizes, a process which typically runs in the order of days\footnote{According to personal communications with engineers from a large commercial database system}. To find the asymptotically optimal batch size, we first prove that the dynamics of the system converges to a deterministic mean-field limit as $n,m \to \infty$. We then find a closed form solution of the stationary point of the mean-field and prove that it is globally attractive. Using the stationary point of the mean-field we characterize the throughput of the system as a function of the batch size. This finally leads to a simple optimization problem which can be solved either in closed form or numerically in constant time to find the asymptotically optimal batch size. Recently, mean-field techniques have been used successfully in various models of large scale service systems, such as web server farms \cite{arpan2016tcns}, cloud data centers \cite{xie2015sigmetrics}, and caching systems \cite{gast2015sigmmetrics}, where an exact solution of the stationary distribution is computationally infeasible due to the large size of the state space. In such systems, the key idea is to approximate the Markovian dynamics of the system by a deterministic dynamical system, called {\em the mean-field limit}, typically described by a system of ordinary differential equations (ODEs). Such an approximation is exact in the limit as the system becomes large. The stationary behaviour of the limiting system can be described by the stationary point of the mean-field which can either be found in closed form or computed in constant time. The key challenge is to prove the uniqueness and existence of the stationary point and the fact that all possible trajectories of the mean-field limit converges to this unique stationary point (global attraction) \cite{budhiraja2015ejp,benny2019sigm}. To demonstrate the practical relevance of our results we analyze a large commercial database system. In such a system a job refers to a query, e.g., an SQL string, which can execute \textit{read} or \textit{write} operations. A client can only send a new query once the previous query has been processed, i.e., each client can have at most one outstanding query at any time. Job/query batching involves merging multiple similar queries into a new SQL string, whose execution time depends on many factors such as the operations' types. Moreover, the shared overhead amongst the individual queries lends itself to a certain speedup in the batch execution time which was empirically shown to be around a factor of $2$ in~\cite{rehrmann2018oltpshare}; the speedup is generally a function of both the number of batched jobs $k$ and the jobs' types, e.g. \textit{read} or \textit{write}. The remainder of the paper is structured as follows. We first discuss related work and then describe the queueing model and the optimization formulation. In Sect.~\ref{sec:meanField} we provide the mean-field model and the corresponding asymptotic result. In Sect.~\ref{sec:modelMultJobTypeBig} we provide the generalized model for the two types of jobs case, and then present numerical and experimental evaluation results for the optimal batch sizing approach in Sect.~\ref{sec:numerical}. Lastly we conclude the paper in Sect. ~\ref{sec:conclusion}. \section{mean-field Model}\label{sec:meanField} In practical data-processing systems, the number of clients served is usually large. From a computational point of view, the standard Markovian approach followed in Sect.~\ref{sec:modelSingleJobType} becomes increasingly computationally infeasible when growing the number of clients. Consequently, we adopt a mean-field approach where the number of servers~$m$ scales with the number of clients~$n$. We assume that the batching step is instantaneous, i.e., the number of jobs in the batching station jumps accordingly from $(k-1)$ to $0$ upon the arrival of a new job. This assumption not only simplifies our analysis but is also motivated by empirical observations; for instance, in the commercial database system where we run the evaluation experiments, the batching step is approximately $50$ times faster than the service step. Let $X^{(n)}(t)$ denote the number of active clients in the system at time $t \geq 0$. Hence, the number of queries in the system at time $t$ is $n-X^{(n)}(t)$. Then, $(X^{(n)}(t), t\geq 0)$ is a Markov process with the state space $\cbrac{0,1,\ldots,n}$ and the following rates: \begin{align*} q^{(n)}(x \to x-1)&=\lambda x\\ q^{(n)}(x \to x+k)&=\mu(k) \min \brac{m,\floor{\frac{n-x}{k}}}~, \end{align*} where $x\in \cbrac{0,1,\ldots,n}$ and $q(i \to j)$ denotes the transition rate from state $i$ to state $j$. The Markov process $(X^{(n)}(t), t\geq 0)$ is ergodic because it is irreducible and has a finite state space. However, it is extremely difficult to obtain a closed form solution of the stationary distribution $\pi^{(n)}$ by solving the matrix equation $\pi^{(n)} Q^{(n)}=0$ because of the non-linear state dependent rates, as mentioned in the previous section. An alternative and immediate approach is to obtain a bound on the system throughput as follows. Under the stationary distribution the following must hold: \begin{equation} \lambda \expect{X}=k \mu(k) \expect{\min \brac{m,\floor{\frac{n-X}{k}}}}~. \label{eq:rate_balance} \end{equation} Using Jensen's inequality we obtain \begin{align*} \lambda \expect{X} \leq k \mu(k) \min \brac{m,\frac{n-\expect{X}}{k}}~, \end{align*} which yields the following bound on $\expect{X}$ \begin{equation} \expect{X} \leq \min \brac{\frac{n \mu(k)}{\lambda+\mu(k)},\frac{k \mu(k)m}{\lambda}}~. \end{equation} The throughput of the system is given by the RHS of \eqref{eq:rate_balance}. Hence, an upper bound on the throughput $\Theta^{(n)}$ is given by \begin{equation} \expect{\Theta^{(n)}} \leq \min \brac{k \mu(k)m,\frac{n \lambda \mu(k)}{\lambda+\mu(k)}}~.\label{eq:upperboundthroughput} \end{equation} (note that we dropped the dependency on $k$ in $\Theta^{(n)}$ for brevity.) In addition to having this bound on the throughput for finite values of $n$ and $m$, we will next show that the bound is asymptotically tight as $n,m \to \infty$ with $m=\alpha n$ for some fixed $\alpha>0$. We first consider the process $(w^{(n)}(t), t\geq 0)$, where $$w^{(n)}(t):=X^{(n)}(t)/n$$ denotes the fraction of active clients in the system. The process $(w^{(n)}(t), t\geq 0)$ is a {\em density dependent jump Markov process} \cite{Kurtz_ODE,Mitzenmacher_thesis,ArpanSSY} with rates \begin{align*} q^{(n)}(w \to w-1/n)&=n\lambda w\\ q^{(n)}(w \to w+k/n)&=n\mu(k) \min \brac{\alpha,\frac{1}{n}\floor{\frac{n-nw}{k}}}~, \end{align*} where $w:=x/n$. Next we prove the following main result: \begin{theorem} \label{thm:meanfield_onetype} \begin{enumerate}[(i)] \item If $w^{(n)}(0) \to w_0 \in [0,1]$ as $n \to \infty$ in probability, then we have $$\sup_{0\leq t \leq T} \norm{w^{(n)}(t)-w(t)} \to 0$$ in probability as $n \to \infty$, where $(w(t), t\geq 0)$ is the unique solution of the following ODE: \begin{equation} \dot w(t) = f(w(t)), \qquad w(0)=w_0, \end{equation} with $f:[0,1] \to \mb{R}$ defined as \begin{equation} f(w)= k \mu(k) \min \brac{\alpha, \frac{1-w}{k}} -\lambda w~. \end{equation} \item For any $w_0 \in [0,1]$, we have $w(t) \to w^*$ exponentially fast as $t \to \infty$, where $w^*$ is the unique solution of $f(w^*)=0$ and is given by \begin{equation} w^*=\min \brac{\frac{\mu(k)}{\lambda+\mu(k)}, \frac{\alpha k \mu(k)}{\lambda}} \label{eq:fixed_point} \end{equation} \item The sequence of stationary measures $\pi_w^{(n)}$ of the process\\ $(w^{(n)}(t), t \geq 0)$ converges weakly to $\delta_{w^*}$ as $n \to \infty$. \end{enumerate} \end{theorem} \begin{proof} To show part (i), we first note that the limiting expected drift of the process $(w^{(n)}(t),t\geq 0)$ conditioned on $w^{(n)}(t)=w$ converges point-wise (and hence uniformly) to the continuous function $f$, i.e., for each $w \in [0,1]$ we have \begin{equation} \lim_{n \to \infty} \lim_{h \to 0} \frac{1}{h}\expect{w^{(n)}(t+h)-w^{(n)}(t) \vert w^{(n)}(t)=w}=f(w)~. \end{equation} Furthermore, it is easy to see that $f:[0,1] \to \mb{R}$ is Lipschitz continuous which follows from the facts (1) any linear function is Lipschitz continuous, (2) if $F,G$ are Lipschitz continuous, then $cF+dG$ is Lipschitz continuous for any $c,d \in \mb{R}$, (3) $\abs{F}$ is Lipschitz continuous when $F$ is Lipschitz continuous, and (4) $\min(F,G)=\frac{F+G}{2}-\frac{\abs{F-G}}{2}$. Part (i) now follows from Theorem 3.1 of \cite{Kurtz_ODE}. To prove part (ii), we first observe that the unique solution to the equation $f(w^*)=0$ is given by \eqref{eq:fixed_point}. Without loss of generality we assume that $w_0 \geq w^*$. Then $w(t) \geq w^*$ for all $t \geq 0$ due to the continuity of the process $w(t)$ and the fact that $\dot w(t)=0$ when $w(t)=w^*$. We define the distance function $\phi(t)=w(t)-w^*$. Clearly, $\phi(t) \geq 0$ for all $t \geq 0$. Now we have \begin{align*} \dot{\phi}(t)=\dot{w}(t)&=f(w)\\ &=f(w)-f(w^*)\\ &=-\lambda(w-w^*)+\\ & \quad k \mu(k) \sbrac{\min\brac{\alpha, \frac{1-w(t)}{k}}-\min\brac{\alpha, \frac{1-w^*}{k}}} \\ &\leq -\lambda \phi, \end{align*} where the last inequality follows since $w(t) \geq w^*$ for all $t \geq 0$. From the above we see that $\phi(t) \leq \phi(0) e^{-\lambda t}$. This implies that $$w(t) \to w^*$$ as required. To show part (iii), we first note that the stationary measure $\pi_w^{(n)}$ is tight as it is defined on the compact space $[0,1]$. Hence, part (iii) follows from Theorem 2 of \cite{Gast_chap}. \end{proof} The above theorem implies the weaker result that $$\lim_{n \to \infty} \lim_{t \to \infty}\expect{w^{(n)}(t)}=\lim_{t\to \infty} \lim_{n\to \infty} \expect{w^{(n)}(t)}=w^*.$$ Equivalently, we have the following convergence of the normalized throughput $\Theta^{(n)}/n$ $$\lim_{n \to \infty} \expect{\Theta^{(n)}/n}=\lambda w^*,$$ which proves the asymptotic tightness of the bound from (\ref{eq:upperboundthroughput}). The optimal asymptotic throughput further follows by maximizing the fraction of active clients $w^*$ with respect to the batch size $k$. The asymptotically optimal batch size is the solution to the following optimization problem \begin{equation} \underset{k}{\max} \min \brac{\frac{\mu(k)}{\lambda+\mu(k)}, \frac{\alpha k \mu(k)}{\lambda}} \label{eq:k_opt}~. \end{equation} In the particular case when $\mu(k)$ is a non-increasing function of $k$ and $k \mu(k)$ is a non-decreasing function of $k$, the optimal solution $k^*$ is simply the solution to the following equation \begin{equation} \frac{\mu(k)}{\lambda+\mu(k)}= \frac{\alpha k \mu(k)}{\lambda}~. \label{eq:optimal_k_mean_field} \end{equation} Therefore, we have just showed that $k^*$ can simply be found by solving a polynomial equation. We can approximate the optimal batch size for finite systems by $k^*$ as long as $n$ and $m$ are large. The advantage is that solving the polynomial equation can be done in time independent of the system size $n$; moreover, as we will show in our numerical experiments, the approximation is numerically accurate in practical regimes. \section{Queueing Model and Optimization Goal}\label{sec:modelSingleJobType} We consider a closed queueing system where jobs are routed along three stations: job producer, job batcher, and service station. The producer station has $n$ clients, each being assigned a token enabling them to submit a new job/query\footnote{We use the terms \textit{job} and \textit{query} interchangeably.}. Upon submission, the token is revoked and the query is passed to the job batcher which creates a merged query at rate $M(k)$, once $k$ queries become available to form a batch of size $k$. Each batch is forwarded to the service station consisting of $m$ serving units, or servers, processing batches in a FCFS order at rate $\mu(k)$, i.e., the number of \emph{batches} served per unit time. Further, the merged query is compiled, executed, and the result is split and sent back to the respective clients. Along with receiving a result, each client also receives its token back and becomes ready to submit a new query. We note that the rate at which a new query is submitted to the batching station depends on the number of \emph{active} clients, i.e., clients with a token, rather than the total number of clients. It is also important to observe that the total number jobs in the system is the same as the number of clients $n$. For a schematic representation of the system recall Fig.~\ref{fig:closedSystemDesc}. A key observation is that the additional time spent on batching is compensated by the reduction in the total execution time of the jobs, owing to the amortization of associated operational overhead characteristic to jobs of the same type. The gain from batching usually grows when increasing the batch size, an effect which is commonly referred to as \textit{speedup}. However, increasing the batch size beyond a certain threshold can lead to an excessive idling of the available servers. This is due to the fact that batch formation takes longer and also the number of batches in the system can become less than the number of servers. In other words, higher speedups can idle more servers, which raises an interesting performance tradeoff. Our objective is to find the optimal batch size $k^*$ maximizing the system's throughput, i.e., the number of jobs served at the service station per unit time. To this end, we will first model the closed queueing system as a continuous time Markov chain (CTMC) and find its steady state distribution. We assume that the time for each client to produce a job is exponentially distributed with rate $\lambda$; denoting by $x$ the number of active clients (i.e., having a token), the producer station forwards a job to the batcher at rate $\lambda x$. Let us also denote by $y$ and $z$ as the number of jobs at the batcher and the number of batches at the server, respectively. The state of the system can thus be uniquely described by the triple $(x,y,zk)$ belonging to the state space $$\mc{S}=\cbrac{(x_1,x_2,x_3)\in \mb{Z}_+^3: x_1+x_2+x_3 = n, k|x_3}~.$$ Although $(x,y,zk)$ is determined by any two of its components, we retain the triple representation due to a more convenient visualisation. The state of the system clearly evolves as a continuous-time Markov chain and the rates at which the system jumps to another state from the state $(x,y,zk)$ are given by \begin{align} \label{eq:jumpRates} (x,y,zk) &\xrightarrow[\text{}]{\lambda x} (x-1,y+1,zk), \thinspace x>0 \nonumber \\ &\xrightarrow[\text{}]{M(k)\floor{y/k}} (x,y-k,(z+1)k), \thinspace y \ge k \nonumber \\ &\xrightarrow[\text{}]{\mu(k)\min(m,z)} (x+k,y,(z-1)k), \thinspace z>0~. \end{align} Informally, when the system is in state $(x,y,zk)$, either one job can move from the producer to the batcher at rate $\lambda x$ when there are $x$ active clients, \emph{or} $k$ jobs can move from the batcher to the server at rate $M(k)\floor{y/k}$, \emph{or} $k$ more clients become active (i.e., receive their tokens back) at rate $\min(m,z)\mu(k)$. The rates to all other states are zero. The system attains a steady state with the unique distribution $\pmb{\pi}_0$ given by the solution of the equation $\pmb{\pi} \cdot \mathbf{Q} = 0$. This is due to the fact that the chain is irreducible, whereas the finiteness of the state space guarantees positive recurrence; for a rigorous argument see Sect. ~\ref{sec:app-0} in the Appendix. Here, $\mathbf{Q}(r,s)$ denotes the jump rate from state $r$ to $s$ where $r$, $s$ are of the form $(x,y,zk)$, as specified in \eqref{eq:jumpRates}. Given the non-linear state dependent rates, we can only obtain the solution $\pmb{\pi}_0$ numerically rather than in closed form. Further, the steady state distribution $\pmb{\pi}$ immediately lends itself to the steady state system throughput, i.e., \begin{align}\label{eq:steadyThroughput} \Theta(k) := \sum_{(x,y,zk) \in \mc{S}} \pmb{\pi}_0(x,y,zk) \thinspace k\mu(k)\min(m,z)~, \end{align} which implicitly yields the optimal batch size \begin{align} \label{optFormulation} k^* := \argmax_{k \in \mc{K}} \Theta(k)~. \end{align} Here $\mc{K}=\{1,2,3,\dots,K\}$ and $K$ is the maximum possible batch size imposed by the underlying queueing system. Note that finding the solution of \eqref{optFormulation} runs in $\omega\left(n^4\right)$ time as it involves solving $\pmb{\pi} \cdot \mathbf{Q} = 0$~ for every $1 \leq k\leq K$ in \eqref{eq:steadyThroughput}; for a particular batch size $k$, the dimension of $\mathbf{Q}$ is of order $\frac{n^2}{k}$. \section{Related Work} \label{sec:related_work} We overview some open and closed queueing systems with batching, and practical approaches to batching in database systems. In the open queueing systems literature, one of the earliest examples of batching is \cite{bailey1954queueing} which derives the expected value of the steady state queue length and waiting time assuming exponential inter-arrival and Chi-squared service time. In \cite{deb1973optimal}, the authors consider a queueing system with Poisson arrivals and general batch service time, independent of the batch size; both the execution time and batch size can be dynamically controlled subject to real-world constraints on the maximum possible batch size. If a batch is forwarded to the server only at the points when the server is free, or there is an arrival or departure, it is shown that it is optimal to serve all jobs in a batch only when the queue length exceeds a certain threshold. Batching in the context of running a shuttle service between two end points has been considered in \cite{deb1978optimal}, which provides an optimal batching policy for minimizing the expected total discounted cost over an infinite horizon. Here it is assumed that the customers arrive according to independent Poisson processes. The authors in \cite{berg1998optimal} consider a discrete time system with incoming jobs having a strict delay guarantee. Given a certain form of serving cost which incentivizes batching and arrival distribution, the authors lay down a strategy that minimizes the expected long term cost per unit time. Further, in \cite{glazer1987equilibrium}, a queueing system with bulk service at scheduled time points has been considered where the customers can pick their arrival time to minimize the waiting time. Under some given conditions, the authors show that it is optimal to arrive just the moment before a service starts. In turn, a key objective in the closed queueing systems literature was proving the product form property of the steady state queues' distribution. Gordon and Newell \cite{gordon1967closed} considered a closed network with multiple service stages and a set of probabilities governing the routing among these stages and showed the product form property under the assumption of exponential service times. In the seminal work on BCMP networks \cite{baskett1975open}, the authors considered the more general case of open, closed, and mixed networks, and also multiple job classes. Inspired by the functioning of central processors, data channels, terminals among others, sufficient conditions have been provided for each of these cases for the network to have a product form equilibrium distribution. Further, in \cite{chandy1977product}, the authors generalized the idea of local balance to station balance that explains the conditions for a network with non-exponential service times to have a product form. These findings were further extended under a more general set-up in \cite{chandy1983characterization}, which investigated the existence of product form equilibrium distribution under certain restrictions on the service discipline which can however be class dependent. The existence of product form in closed queueing networks with service batching was investigated in \cite{henderson1990closed}, which derives conditions for the existence of product form distribution in a discrete-time setting with state-independent routing, allowing multiple events to occur in a single time slot. The results were further extended to a continuous-time setting allowing for batch arrivals in \cite{henderson1990product}. For the particular closed queueing network with service batching from this paper, it is certainly of interest to determine whether the product form property applies. However, aforementioned works do not apply to our problem as the conditional routing probabilities of jobs/batches in our case is state-dependent due the FCFS nature of service. Further, even if we approximate FCFS order by random service order, we cannot \emph{directly} compute the system throughput from these works as they lack a method to derive the normalizing constant for the corresponding product form. In the context of batching in databases, one of the earliest and influential work is \cite{dewitt1984groupcommit} whereby transactions are executed as sequence of jobs and batches of jobs access the same log page. Once that page is full, the log is flushed and the batch is executed, thus decreasing the I/O. Naturally, the batch size is fixed to the page size; in turn, in our work, we allow for flexible batch sizes in relation to the number of clients and specifically focus on optimizing throughput rather than I/O reduction. In comparison, \textit{SharedDB} \cite{giannikis2012shareddb} executes all incoming jobs as a big batch. Jobs that enter the system, while a batch is executed, are queued and batched, once the previous batch finished execution. In contrast to our work, SharedDB executes batches of different sizes sequentially and does not classify job types or consider job sizes. A similar work to SharedDB is \textit{BatchDB} \cite{makreshanski2017batchdb} in which incoming analytic jobs are batched where the execution is interleaved with writing jobs, as they occur. Alike SharedDB, BatchDB does not classify their jobs or focus on the size of batches in relation to clients. The closest system to our work is \textit{OLTPShare} \cite{rehrmann2018oltpshare}, where the authors use a fixed time interval to collect incoming jobs into batches. In contrast, our approach of using a count-based batching (i.e., each batch has exactly $k$ jobs) has the practical benefit of utilizing cached batch queries. These batch jobs are compiled SQL strings that have been requested before. Using the interval approach results in batches of various sizes diminishing the efficiency of caching previously seen batch requests. \section{Response to Reviewer's Comments} \label{sec:response} \subsection{Review A} \label{sec:reviewer1} \textbf{What area of the paper need improvement?} The assumption of using at most 3 nodes and 2 job types restricts significance \looseness=-1 \textcolor{brown}{We added Sect. \ref{sec:manyJobManyService} which extends the analysis to multiple job types and multiple levels of service for the case with preemptive priority. We prove global attraction for equal batch sizes and one level of service.} Lack of comparison with other model classes or existing approximations \textcolor{brown}{We now briefly discuss the inapplicability of the result from \cite{henderson1990closed} to FCFS scheduling in Sect. \ref{sec:related_work}. A more detailed argument is given below under \emph{Other comments for author}.} Technical derivations appear rather standard \textbf{Other comments for author} Generally, I found the paper well-executed, both in the mathematical part, where the derivations have a high level of rigor, and in the experimental part, e.g. D-optimal designs to collect the data. The authors claim that the class of models is new. They refer in particular to Hendersen et al. in [19], as a term of comparison. Although they do not fully develop the comparison, which I think they should have done instead, I tend to agree that the model here seems different since the one in [19] supports Poisson distributed batch sizes. However, works such as [19] have been seminal in developing product-form stochastic Petri nets (SPNs), therefore the authors should look deeper in the literature prior to concluding that their work is entirely original. I believe it is for the dual priority case, since SPNs are not particularly suited to this case, but I have some doubts about the single-class case. In the fluid limit, there is probably little difference between using FCFS scheduling and service in random order, therefore I would expect the model results to match product-form SPNs. I think the authors should develop a full comparison. \textcolor{brown}{ The main reason for not adopting the framework of Hendeson {et al.}~ \cite{henderson1990closed} is its inapplicability for FCFS scheduling. For FCFS policy, the position of a job/batch in a node (station) is important and the conditional routing probability $p_j(s_j,a_j)$ in \cite{henderson1990closed} is state dependent. For example, the position of an incoming job in the batching station will depend on the number of existing jobs there. This can be circumvented by using random scheduling as the reviewer commented. However, we chose the fluid approximation over random service order approximation as our framework could then be extended to multiple job types with priority. We have included this discussion under Sect. \ref{sec:related_work} now. Further, a full-fledged comparison with SPNs is beyond the scope of this paper.} The simulation results are convincing. The real system experimentation is rather narrow. I feel more breadth of systems and problems should be explored. \looseness=-1 \textcolor{brown}{We provide in this paper simulation as well as real-world experimentation results in a database system. While there are many systems that benefit from batching we opted to concentrate on this specific problem in this paper.}\looseness=-1 My primary concern at the moment is, however, the focus on assuming a small topology as done by the authors. The framework proposed by the authors is based on Kurtz's theorem, which is rather general, therefore I do not see the reason why the framework cannot be extended to an arbitrary number of queues and types. I can see that it may be harder to characterize global attraction, but it seems possible to develop the relevant ODEs. This shortcoming restricts the significance of the paper. \textcolor{brown}{We have extended the analysis to include the system dynamics for multiple job types and multiple levels of service under preemptive priority in Sect. \ref{sec:manyJobManyService}. We show global attraction, however, only for equal batch size and single level of service.} \textbf{Other comments: } Section A.2 is under-developed. End of column 2 in page 2. The point about product-forms is not entirely sound. You can efficiently compute throughputs from product forms if you can determine the normalizing constants. You should better say that there aren't methods to do so in [19]. \textcolor{brown}{We have now rephrased the comparison in Sect. \ref{sec:related_work}.} Typos (not shown here). \textcolor{brown}{Corrected.} \vspace{-10pt} \subsection{Review B} \label{sec:reviewer2} \textbf{What area of the paper need improvement?} Model assumptions need to be described better \smallskip The manner in which the model scales service rate with batch size is unclear. \textcolor{brown}{The function which defines the dependence of batch service time (and hence rate) on batch size is termed as \emph{speedup} in our work. In principle, it could be any subadditive function but the exact forms considered for evaluations are described as function $g$ in the second paragraph of Sect.~\ref{subsec:dataFitting}.} Not sure if the time savings from the approximation are significant for practical ranges of system parameters \textcolor{brown}{In web applications, handling requests with low latency, is critical, e.g., [X1] reports that the probability of bounces increases by $32\%$ for page-load times of 1 to 3 seconds. In addition, [X2] reports an empirical increase of performance for every second saved in page-loading time. Works analyzing Amazon shows that a $1\%$ revenue increase is expected for every \SI{100}{\milli\second} of page-load time improvement. } \textcolor{brown}{Keeping such low latency is especially difficult in overload spikes, such as \textit{Black Friday}, \textit{Cyber Monday}, or \textit{Christmas}.} \textcolor{brown}{As every page view requires to load daily offers, user profiles and preferences, as well as last user transactions, a page view is translated to multiple jobs within the database. In consequence, the load on the database may be increased by an order of magnitude, compared to the number of requests in the app server.} \textcolor{brown}{Usually, every request submitted by the application server is executed in a few micro seconds; from our internal measurements, we know that simple jobs run in about \SI{100}{\micro\second}, while jobs consisting of complex calculations run in \SI{300}{\micro\second}. Obviously, the calculation of a reasonable batch-size has to be processed with a very low execution overhead. Thus, the time savings from approximation are critical for practical enterprise applications, where an increase of latency results in monetary loss.} \textcolor{brown}{\noindent[X1] Daniel An. 2017.Find Out How You Stack Up to New Industry Benchmarks for Mobile Page Speed. Technical Report. Google Global Product Lead, Mobile Web. 11 pages\newline [X2] Akamai Technologies Inc. 2017. State of Online Retail Performance. Technical Report. Akamai Technologies, Inc. 18 pages. } \smallskip \textbf{Other comments for author} The paper is written well and addresses an interesting problem. I particularly liked the validation of the analytic technique on a real system. The results look convincing. I suggest the following issues be addressed in the next version. \smallskip Real life systems have many features, e.g., queuing for software resources such as buffers/locks, that the current model does not represent. In light of these, the assumptions made need to be better described. \textcolor{brown}{It is true that certain intricacies of real systems are abstracted away in the model. However, we would like to point out that the results from the prototype system and the model agree for this particular setup as seen in Fig. \ref{fig:others1} and \ref{fig:compareRW}.} The work seems to assume some kind of linear speedup of service rate with respect to batch size. This needs to be justified. It is also not clear how this speedup is represented in the approximation. \textcolor{brown}{For analytical derivations, speedup could be any subadditive function to avoid triviality. However, for evaluations, we have experimented with three forms of speedup as described in the second paragraph of Sect. \ref{subsec:dataFitting}. The linear speedup seemed to fit the system data best among these. This was stated clearly in the paper and is specific to the prototype system that we built. Further, the dependence of optimal batch size on the speedup function is shown through the function $\mu(k)$ in \eqref{eq:k_opt}. However, the reviewer is right in pointing out that the argument $k$ has been suppressed in the following sections for brevity.} The CTMC will give exact solutions in reasonable time if the system is small scale. Would this be sufficient for most real life systems, i.e., is the CTMC enough for most practical ranges of system parameters such as batch size? The paper could perhaps give examples of real systems where application of the CTMC will not be feasible. \textcolor{brown}{Our experiment results show that the CTMC modeling is accurate. However, the reviewer is right that there are other systems, where batching plays a role, e.g. where service times are heavy-tailed, where the CTMC assumption may not be feasible.} It will be interesting to see a comparison with simpler models. For example, would an open model simplify the analysis while giving comparable results? \textcolor{brown}{An open model would not work as the it fails to capture the waiting for response phenomena of the database application. We have actually conducted this analysis and seen that the open model optima are quite far from the behavior of the real system (which is a closed one by construction).} \vspace{-12pt} \subsection{Review C} \label{sec:reviewer2} \textbf{What area of the paper need improvement?} The analytical techniques applied in the proofs appear to be standard. The proofs of the convergence of the fluid model (ODE) to a unique equilibrium appear to be the most technical part in the proofs, in particular for the two-job type case, but are finally quite straight forward. The proofs of the stochastic convergence are mostly about verifying conditions of existing results from the literature. Also, mean field models have been recently developed and analyzed extensively in various parallel server/queue problems. Thus, from a methodological stand point the contributions are limited. \textcolor{brown}{We have now included a new result for multiple job types in Sect. \ref{sec:manyJobManyService} where equal batch size and preemptive priority is assumed.} It is difficult to say if the model is important or relevant from the application context point of view, as this reviewer is not really an expert on performance models for optimizing database queries. \textcolor{brown}{As mentioned in Sect. \ref{sec:related_work}, batching has drawn attention of the database community quite sometime back \cite{dewitt1984groupcommit} and is still relevant \cite{makreshanski2017batchdb}. Further, our findings are compared against outcomes of experiments done in a commercial system showing the accuracy of the analysis. Please also check a similar remark by Reviewer B.} The proofs in two job type model need some reworking, in my opinion, see my detailed comments. The result is given for a more general case than the proof currently considers. \textcolor{brown}{We reworked the proof of Thm. \ref{thm:meanFieldTwoJobs} without assuming $k_1 = k_2$.} The readability of Section 6 (numerical results) is not that good and there are some minor concerns with figures, see my detailed comments. \textcolor{brown}{Responses added under detailed comments.} \textbf{Other comments for author} p. 3, Section 3: If the number of clients n goes to infinity and the per-client request generation rate $\nu$ goes to zero such that $n*\nu -> \lambda$, wouldn't you get the normal Poisson arrival process and your model would correspond to an open network with a contant arrival rate $\lambda$ in any state? Why not model the system like this? Is the assumption of a finite client population somehow essential? \textcolor{brown}{In our framework, the per client generation rate is constant. Also, an open network fails to capture the dependence of job arrivals and job completion. We have seen that the optimal batch sizes from an open model and the system do not agree. We opted to show in the paper the appropriate modelling since the system that is used for the experiments is a closed one by construction.} p. 6: In Theorem 5.1, the proof of the convergence of the ODE and uniqueness of the equilibrium point is only shown for $k_1 = k_2$. The text mentions that the proof for $k_1 \neq k_2$ is exactly the same. However, in my opinion the authors should show this more rigorously than just by stating this claim. Otherwise, the theorem needs to be modified such that it is assumed that $k_1=k_2$, which is anyway assumed later on also in the optimization. \textcolor{brown}{We reworked the proof of Thm. \ref{thm:meanFieldTwoJobs}. It is now updated for the general case.} \looseness=-1 p. 7, Section 6: What is the role of Section 6.2 and 6.3 for Section 6.4? Sections 6.2/6.3 discuss experimental setup, while 6.4 only uses simulations until the very end shortly in Section 6.4.2, where the experimental work is discussed. Also, presently the experimentation part gets a lot of exposure in terms of text length, but finally there are not that many experiments carried out. It might be better to have a separate section for simulations, i.e., Section 6.1, and then use Section 6.2 for experimentation with all the related text under that subsection. \textcolor{brown}{We have rearranged Sect. \ref{sec:numerical} as suggested.} p. 9, Section 6.4.1: Throughout the section, what is actually meant by simulation? What model is then simulated, the original one obeying (1) or the simplified Markov model? In the text, I assume exact model to mean the numerical solution of the corresponding Markov model and mean field is the fluid model solution. \textcolor{brown}{The simulation was done as per (1) for the single job type and similarly for two job types. Further, the terms \emph{exact} and \emph{mean field} indeed refer to numerical solution of the steady state equation and the fluid model solution, respectively. We added this clarification to the paper. This is now mentioned towards the beginning of Sect. \ref{sec:numericalEval_}.} p. 9, Section 6.4.1 (and throughout in Section 6): There is incomplete information on numerical parameters, also service time parameters are not given, constants in linear speed up function not given. Not possible to replicate results. \textcolor{brown}{Simulation parameters are included towards the beginning of Sect. \ref{sec:numericalEval_}.} p. 9 Figure 5: In third picture (m=16), the orange exact solution representing the numerical solution for the throughput from the corresponding Markov model has strange non-smooth behavior for n=1000 at k=80 (just before the optimal point). Why is the numerical solution to the Markov model behaving like this? Similar strange behavior can be seen in Figure 6 (c) in the exact solution curves for n=200 with larger batch sizes. Why is the throughput behaving in such jagged, non-smooth manner as a function of the batch size? I could understand if this would be a simulated curve and the simulation time is too short, but the text refers to this as the "exact" result, which I take to mean the numerical solution form the corresponding Markov model. \textcolor{brown}{The throughput goes down sharply at points where the number of maximum possible active server drops by one. This becomes even more pronounced as the relative change of the number of active servers increases. For example, for $300$ jobs and $4$ servers, as the batch size increases from $75$ to $76$, the number of maximum possible active servers decreases from $4$ to $3$, causing a sharp drop in the throughput. The reduction is even higher when batch size increases from $100$ to $101$. This is mentioned in Fig. \ref{fig:tPutCompare3} now.} p. 10, Figure 6: The mean field model does not seem to be very accurate with these values of m and n. How large should the system really be in order to have a better accuracy? \textcolor{brown}{For the metric we are interested in, which happens to be the optimal batch size/throughput in this system, the mean field model accuracy is reasonable as seen in Fig. \ref{fig:others1} and Fig.~\ref{fig:compareRW}. Note in Fig.~\ref{fig:compareRW} that the batch size is in $\mathbb{N_+}$. The reviewer is correct however in the remark that with a higher number of clients, the mean field model accuracy is expected to be higher.} p. 10, Figure 7(b): not sure how much information this figure and the test really contains? Why is this important to have? \textcolor{brown}{This is to explain how quickly the steady-state solution applies to the system.}\looseness=-1 Typos (not shown here). \textcolor{brown} {Corrected.} \section{The Two Job-Type Case}\label{sec:modelMultJobTypeBig} \subsection{Queueing Model and Exact Solution}\label{sec:modelMultJobType} We now consider the case when jobs can be of two types, e.g., \textit{write} and \textit{read} in a database system. Each of these types benefits from batching and can possibly have different speedups; we note that batching involves jobs of the same type, which is typically the case in database systems. Additionally, we consider priority service scheduling between the two types, which can be either preemptive or non-preemptive. In a database system, where queries can be of type \textit{write} or \textit{read}, the former is usually prioritized. In our model, we assume without loss of generality that the first type is given priority in the service station. Below we describe the system dynamics and the required state space representation before providing the mean-field formulation. Recall that the producer station has $n$ clients, each producing one job with rate $\lambda$ once becoming active (i.e., once receiving their token back); also, the number of active clients is denoted by $x$. In the two job-type model, each \emph{active} client produces a job of type $1$ with probability $p$ or a job of type $2$ with probability $(1-p)$. The number of type $1$ and type $2$ jobs in the batching station is denoted by $y_1$ and $y_2$, respectively. The batching station groups $k_i$ jobs of type $i$ into a batch with rate $M_i(k_i)\floor{y_i/k_i}$ whenever $y_i \ge k_i$, $i \in \{1,2\}$, and forwards batches to the service station. Further, the service station has $m$ parallel servers which give \textit{preemptive priority} to the type $1$ jobs; the alternative case of non-preemptive priority is discussed in Sect. ~\ref{sec:app-A} of the Appendix. Let us denote the total number of type $1$ batches by $z_1$. Due to preemptive priority, the actual number of type $1$ batches in service is $v_1 = \min(m,z_1)$. The rest of the servers may be occupied by batches of type $2$. The state of the system can be uniquely described by the quadruple $(x,y_1,y_2,z_1 k_1)$, where $(x,y_1,y_2,z_1 k_1)$ belongs to the state space \begin{align*} \mc{S}=\cbrac{(x_1,x_2,x_3,x_4):\in \mb{Z}_+^4: x_1+x_2+x_3+x_4 \le n, k|x_4}. \end{align*} Note that the number of type $2$ jobs in the system which are already batched is $$z_2 k_2 = (n-x-y_1-y_2-z_1 k_1)~,$$ out of which $v_2 k_2$ are at the server and the rest are queued for service; here, \begin{align} \label{eq:type2batchesInServicePreemptive} v_2 = \min(\max(0,m-z_1),z_2)~. \end{align} Clearly, the system evolves as a continuous-time Markov chain with the jump rates \begin{align} \label{eq:jumpRatesPreemptive} s &\xrightarrow[\text{}]{\lambda x p} s-\mathbf{e_1}+\mathbf{e_2}, \thinspace x>0 \nonumber \\ &\xrightarrow[\text{}]{\lambda x (1-p)} s-\mathbf{e_1}+\mathbf{e_3}, \thinspace x>0 \nonumber \\ &\xrightarrow[\text{}]{M_1(k_1)\floor{y_1/k_1}} s-k_1\mathbf{e_2}+k_1\mathbf{e_4}, \thinspace y_1 \ge k_1 \nonumber \\ &\xrightarrow[\text{}]{v_1\mu_1(k_1)} s+k_1\mathbf{e_1}-k_1\mathbf{e_4}, \thinspace z_1 \ge 1 \nonumber\\ &\xrightarrow[\text{}]{v_2\mu_2(k_2)} s+k_2\mathbf{e_1}, \thinspace v_2 \ge 1~, \end{align} where $s=(x,y_1,y_2,z_1 k_1)$ and $e_j$ is the unit vector of appropriate size whose $j$-th component is unity. The jump rates to all the other state are zero. The chain is irreducible whereas the finiteness of the state space guarantees positive recurrence. Thus, we can derive the rate matrix $\mathbf{Q}$ using ~\eqref{eq:jumpRatesPreemptive} and derive the steady state distribution $\pmb{\pi}_0$ by solving $\pmb{\pi} \cdot \mathbf{Q} = 0$. While we could jointly optimize for $k_1$ and $k_2$, database batching argues for using a uniform batch size across all job types (see, e.g.,~\cite{Sellis:1988:MO:42201.42203:MQO,giannikis2012shareddb,rehrmann2018oltpshare}); in particular, standard multi-query optimization methods in databases batch requests through fixed compiling of the execution of multiple queries into one SQL string which renders equal batch sizes regardless of type. Denoting $k:=k_1=k_2$, the steady state throughput is \begin{align}\label{eq:steadyThroughputPreemptive} \Theta_p(k) = \sum_{s \in \mc{S}} \pmb{\pi}_0(s) k(\mu_1(k) v_1+\mu_2(k) v_2)~, \end{align} where $s = (x,y_1,y_2,z_1k)$ and $v_2$ is derived in ~\eqref{eq:type2batchesInServicePreemptive}. The optimal batch size is \begin{align} \label{optFormulationPreemptive} k^* = \argmax_{k \in \mc{K}} \Theta_p(k)~. \end{align} Here, $\mc{K}=\{1,2,3,\dots,K\}$ and $K$ is the maximum possible batch size for the considered system. \subsection{Mean-field Formulation: Preemptive Priority}\label{subsec:mFTwoJobs} We now discuss the preemptive priority case in the context of the mean-field formulation from Sect.~\ref{sec:meanField}. The system can now be uniquely described by the number of active clients and the number of type $1$ jobs in the system. This is due to the fact that there can be at most $(k_1-1)$ jobs of type $1$ that have not formed a batch; the number of un-batched jobs is $mod(x_2,k_1)$, where $x_2$ is number of type~$1$ jobs in the system. This phenomenon also applies to the type~$2$ jobs and lets us derive the number of type~$2$ jobs which are not yet batched. Assuming work conservingness of the server and the preemptive priority of type $1$ over type $2$, we can derive the number of batches in service for each type. Note that we use the notation $\mu_1$ and $\mu_2$ instead of $\mu_1(k_1)$ and $\mu_2(k_2)$ when the dependence is clear. Let $X_1^{(n)}(t)$ and $X_2^{(n)}(t)$ denote the numbers of active clients and the total number of type 1 jobs in the system at time $t \geq 0$, respectively. Then at time $t \geq 0$, the number of type 2 jobs in the system is $n-X_1^{(n)}(t)-X_2^{(n)}(t)$, the number of type 1 batches being served is $\min\brac{m,\floor{X_2^{(n)}(t)/k_1}}$, and the number of type 2 batches being served is $$\min\brac{m-\min\brac{m,\floor{X_2^{(n)}(t)/k_1}}, \floor{(n-X_1^{(n)}(t)-X_2^{(n)}(t))/k_2}},$$ which simplifies to $$\min\brac{\max\brac{0,m-\floor{X_2^{(n)}(t)/k_1}}, \floor{(n-X_1^{(n)}(t)-X_2^{(n)}(t))/k_2}}.$$ Clearly, $(X_1^{(n)}(t),X_2^{(n)}(t), t\geq 0)$ is Markov process on state space $\mc{S}=\cbrac{(x_1,x_2)\in \mb{Z}_+^2: x_1+x_2 \leq n}$ with the following rates: \begin{align*} &q((x_1,x_2) \to (x_1-1,x_2+1))= \lambda p x_1\\ &q((x_1,x_2) \to (x_1-1,x_2))= \lambda (1-p) x_1\\ &q((x_1,x_2) \to (x_1+k_1,x_2-k_1))= \mu_1 \min\brac{m,\floor{\frac{x_2}{k_1}}}\\ &q((x_1,x_2) \to (x_1+k_1,x_2-k_1))= \mu_1 \min\brac{m,\floor{\frac{x_2}{k_1}}}\\ &q((x_1,x_2) \to (x_1+k_2,x_2))= \\ &\qquad \mu_2 \min\brac{\max\brac{0,m-\floor{\frac{x_2}{k_1}}},\floor{\frac{n-x_1-x_2}{k_2}}}\\ \end{align*} As in the previous section, we consider the scaled process $w^{(n)}(t)=(w_1^{(n)}(t), w_2^{(n)}(t))$ with $w_i^{(n)}(t)=X_i^{(n)}(t)/n$, $i=1:2$. We show the following theorem \begin{theorem}\label{thm:meanFieldTwoJobs} \begin{enumerate}[(i)] \item If $w^{(n)}(0) \to w_0 \in [0,1]^2$ as $n \to \infty$ in probability, then we have $$\sup_{0\leq t \leq T} \norm{w^{(n)}(t)-w(t)} \to 0$$ in probability as $n \to \infty$, where $(w(t)=(w_1(t),w_2(t)), t\geq 0)$ is the unique solution of the following system of ODEs: \begin{equation} \dot w_1(t) = f_1(w(t)), \qquad \dot w_2(t) = f_2(w(t)), \quad w(0)=w_0, \end{equation} with $f=(f_1,f_2):[0,1]^2 \to \mb{R}^2$ defined as \begin{align} f_1(w) &= - \lambda w_1+k_1 \mu_1 \min \brac{\alpha, \frac{w_2}{k_1}}+ \nonumber \\ & \qquad k_2\mu_2 \min\brac{\max\brac{0,\alpha-\frac{w_2}{k_1}},\frac{1-w_1-w_2}{k_2}} \\ f_2(w) &= \lambda p w_1- k_1 \mu_1 \min \brac{\alpha, \frac{w_2}{k_1}} \end{align} \item For any $w_0 \in [0,1]^2$, we have $w(t) \to w^*$ as $t \to \infty$, where $w^*=(w_1^*,w_2^*)$ is the unique solution of $f(w^*)=0$ and is given by \begin{align} w_1^* & = \min \brac{\frac{\mu_1 \mu_2}{\mu_1 \lambda (1-p)+\mu_2 \lambda p+ \mu_1 \mu_2}, \frac{k_1 k_2 \mu_1 \mu_2 \alpha}{k_1 \mu_1 \lambda (1-p)+k_2 \mu_2 \lambda p}}\\ w_2^* &=\frac{\lambda p w_1^*}{\mu_1} \label{eq:fixed_point_two_types} \end{align} \item The sequence of stationary measures $\pi_w^{(n)}$ of the process\\ $(w^{(n)}(t), t \geq 0)$ converges weakly to $\delta_{w^*}$ as $n \to \infty$. \end{enumerate} \end{theorem} \begin{proof} Part (i) can be shown using arguments similar to the proof of Part (i) of Theorem~\ref{thm:meanfield_onetype}. To show part (ii), we first note that $w^*$ is the unique solution of $f(w^*)=0$. We now show that $w^*$ is globally attractive. We first define a linear transform $(w_1,w_2) \to (z_1,z_2)$ defined as $z_1=w_1+w_2$ and $z_2=w_2$. Under this transformation the system is described as follows: \begin{align} \frac{dz_1}{dt}&=\begin{cases} -\lambda (1-p)(z_1-z_2), \quad \text{if } z_2 \geq k_1 \alpha\\ -\lambda (1-p)(z_1-z_2)+\mu_2(1-z_1), \quad \text{if } \frac{1-z_1}{k_2}+\frac{z_2}{k_1}<\alpha\\ -\lambda (1-p)(z_1-z_2)-\frac{k_2}{k_1}\mu_2 z_2 +k_2 \mu_2 \alpha, ~ \text{if } \frac{1-z_1}{k_2}+\frac{z_2}{k_1} \ge \alpha \end{cases}\\ \frac{dz_2}{dt}&=\begin{cases} \lambda p (z_1-z_2)-k_1 \mu_1 \alpha, \quad \text{if } z_2 \geq k_1 \alpha\\ \lambda p(z_1-z_2) -\mu_1 z_2, \quad \text{otherwise}. \end{cases} \end{align} Furthermore, the stationary point is mapped to $(z_1^*,z_2^*)$, where $z_1^* = \min (z_{11}^*,z_{12}^*)$ and $z_2^* =\eta z_1^*$ with $z_{11}^* = \frac{(\mu_1+ \lambda p) \mu_2}{\mu_1 \lambda (1-p)+\mu_2 \lambda p+ \mu_1 \mu_2}$, $z_{12}^* = \frac{k_1 k_2 (\mu_1+ \lambda p) \mu_2 \alpha}{k_1 \mu_1 \lambda (1-p)+k_2 \mu_2 \lambda p}$, $\eta = \frac{\lambda p }{\mu_1+ \lambda p}$. Clearly, the system is a piece-wise linear system. We consider the stability of each region individually: {\bf Case 1}: $k_1 \alpha \geq 1$, $k_2 \alpha \geq 1$\\ In this case, the system reduces to the following system (since the domain of interest is $1\geq z_1 \geq z_2 \geq 0$): \begin{align}\label{eq:evolutionTwoTypesCase1} \frac{dz_1}{dt}&=-\lambda(1-p)(z_1-z_2)+\mu_2(1-z_1) \nonumber\\ \frac{dz_2}{dt}&=\lambda p(z_1-z_2)-\mu_1z_2 \end{align} The above system can be represented as a linear dynamical system $\dot z=Az+b$, where the eigenvalues $\theta$ of $A \in \mb {R}^{2\times 2}$ satisfy $$\theta^2+(\lambda + \mu_1 + \mu_2)\theta+c_0=0,$$ for some constant $c_0$. Clearly, the real parts of the eigenvalues are strictly negative. Hence, the system is globally attractive to the unique stationary point $(z_{11}^*, \eta z_{11}^*)$. {\bf Case 2}: $k_1 \alpha \geq 1$, $k_2 \alpha < 1$\\ In this case, we see that the domain of interest is divided into two regions by the line \begin{align*} L_1: z_2 &=\frac{k_1}{k_2}(k_2 \alpha -1 + z_1), \end{align*} having respective linear equations. Let us also consider the line \begin{align*} L_2: z_2 & = \eta z_1. \end{align*} Note that $\dot z_2(t) \ge 0$ iff $z$ lies below $L_1$. Thus, if the system starts below $L_1$, it stays there and vice-versa and the fixed point(s) of the system, if exist(s), lie(s) on $L_2$. Let $z_{10}$ denote $z_1$-coordinate of the intersection point of these lines, i.e., \begin{align*} z_{10} = \frac{k_1 (\mu_1+ \lambda p) (1- k_2 \alpha)}{k_1 \mu_1 +k_1 \lambda p - k_2 \lambda p}. \end{align*} Let us assume \begin{align*} z_{11}^* \le z_{12}^*. \end{align*} Calculations show that this implies $z_{10} \le z_{11}^* \le z_{12}^*$. If the system starts from a point below $L_1$, the evolution of the system is given by \eqref{eq:evolutionTwoTypesCase1} and a similar argument as \emph{Case 1} shows that the system converges to the fixed point $(z_{11}^*, \eta z_{11}^*)$. In case the initial point lies above $L_1$, the evolution in the starting phase is given by \begin{align} \label{eq:evolutionTwoTypesCase2New} \frac{dz_1}{dt}&=-\lambda(1-p)(z_1-z_2)+ k_2 \mu_2(\alpha -\frac{z_2}{k_1}) \nonumber\\ \frac{dz_2}{dt}&=\lambda p(z_1-z_2)-\mu_1z_2 \end{align} Calculations show that the real parts of the corresponding eigenvalues are negative and the fixed point for this system is given by $(z_{12}^*, \eta z_{12}^*)$. Thus the system crosses $L_1$ where the evolution is governed by \eqref{eq:evolutionTwoTypesCase1}. From the perspective of convergence, this is equivalent to having the initial point below $L_1$ in which is case the convergence to $(z_{11}^*, \eta z_{11}^*)$ is already established. Thus, the system always converges to $(z_{11}^*, \eta z_{11}^*)$ when $z_{11}^* \le z_{12}^*$. For the case \begin{align*} z_{11}^* > z_{12}^*, \end{align*} we notice that $z_{10} \ge z_{11}^* \ge z_{12}^*$ and a similar argument shows convergence of the system to $(z_{12}^*, \eta z_{12}^*)$. {\bf Case 3}: $k_1 \alpha < 1$, $k_2 \alpha < 1$\\ In this case, we can have different possibilities for the initial state. We first consider the case where we start with a vector $(z_1,z_2)$ such that $1\geq z_1 \geq z_2 \geq k_1 \alpha$. We will show that the system eventually reaches a state where $z_2 \leq k_1 \alpha$. In this case, until we have $z_1 \leq k_1 \alpha$, the evolution is given by \begin{align}\label{eq:evolutionTwoTypesCase2Old} \frac{dz_1}{dt}&=-\lambda (1-p)(z_1-z_2) \nonumber\\ \frac{dz_2}{dt}&=\lambda p (z_1-z_2)-k_1 \mu_1 \alpha \end{align} The above is clearly a unstable system with $z_1$ and $z_2$ decreasing indefinitely for ever. Therefore, there exists $t \geq 0$ such that $z_2(t) \leq k_1 \alpha$. Now without loss of generality we start our system with $z_2 \leq k \alpha$. Thus, without loss of generality, we take an initial point satisfying $z_2 \le k_1 \alpha$. Let us assume \begin{align*} \eta \le k_1 \alpha, \end{align*} Like \emph{Case 2}, we observe that either $z_{10} \le z_{11}^* \le z_{12}^*$ or $z_{10} \ge z_{11}^* \ge z_{12}^*$ and the proof follows the same line of argument as \emph{Case 2}. Now let's consider the scenario when \begin{align*} \eta > k_1 \alpha. \end{align*} We show that $z_{11}^* \ge z_{12}^*$ which holds if and only if \begin{align*} \mu_1 \mu_2 k_1 k_2 \alpha \le k_1 \mu_1 \lambda (1-p) (1- k_2 \alpha) +k_2 \mu_2 \lambda p (1- k_1 \alpha). \end{align*} Since, $\eta > k_1 \alpha$, it suffices to show \begin{align*} \mu_1 \mu_2 k_2 \eta \le k_1 \mu_1 \lambda (1-p) (1- k_2 \alpha) +k_2 \mu_2 \lambda p (1- \eta), \end{align*} which is equivalent to $k_1 (\mu_1 + \lambda p) (1-p) (1- k_2 \alpha) \ge 0$. Similar to \emph{Case 2}, we see that if the initial point lies above $L_1$, the evolution is given by \eqref{eq:evolutionTwoTypesCase2New} and the system converges to $(z_{12}^*, \eta z_{12}^*)$. When started below $L_1$, the evolution is governed by \eqref{eq:evolutionTwoTypesCase1} initially and the system moves towards $(z_{11}^*, \eta z_{11}^*)$. This eventually changes the evolution dynamics to \eqref{eq:evolutionTwoTypesCase2New} and the system converges to $(z_{12}^*, \eta z_{12}^*)$ in either case. {\bf Case 4}: $k_1 \alpha < 1$, $k_2 \alpha \ge 1$\\ Using the same argument as \emph{Case 2}, we take an initial point with $z_2 \le k_1 \alpha$. Let us first assume \begin{align*} \eta \le k_1 \alpha. \end{align*} Similar to the argument of \emph{Case 3} when $\eta > k_1 \alpha$ and using the fact that $k_2 \alpha \ge 1$, we observe this implies $z_{11}^* \le z_{12}^*$. The convergence from an initial point below or above $L_1$ follows in a similar fashion. The remaining scenario is \begin{align*} \eta > k_1 \alpha. \end{align*} Similar to \emph{Case 2}, we observe that either $z_{10} \le z_{11}^* \le z_{12}^*$ or $z_{10} \ge z_{11}^* \ge z_{12}^*$ and convergence can be shown to $(z_{11}^*, \eta z_{11}^*)$ or $(z_{12}^*, \eta z_{12}^*)$, respectively, using the same line of argument presented there. Thus global attraction is established under all scenarios. Note that we have mentioned the actual limit as $(z_{11}^*, \eta z_{11}^*)$ or $(z_{12}^*, \eta z_{12}^*)$, as applicable. Finally Part (iii) of the theorem follows by the same line arguments as in the proof of Part (iii) of Theorem~\ref{thm:meanfield_onetype}. A more general result under the assumption of equal batch sizes is given in Appendix \ref{sec:manyJobManyService}. \end{proof} \begin{figure*}[h!] \centering \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/tputCompareSingleVsN_noServer_4.pdf} \caption{\label{fig:optTCompare4servSingle}% $m=4$ (servers)} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/tputCompareSingleVsN_noServer_8.pdf} \caption{\label{fig:optTPutCompare8servSingle}% $m=8$} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/tputCompareSingleVsN_noServer_16.pdf} \caption{\label{fig:optTCompare16servSingle}% $m=16$} \end{subfigure} \caption{\label{fig:optTPut-vs-n-1job}% The optimal steady state throughput as a function of the number of clients/jobs $n$, for the single job type case; results from the mean-field model, the non-asymptotic/exact formulation, and simulations, for several values of the number of servers $m$ and a linear service speedup. For a fixed $m$, the optimal throughput is known from the mean-field analysis to be $m k^* \mu(k^*)$, where $k^*$ is given in~\eqref{eq:optimal_k_mean_field}.}% \end{figure*} \begin{figure*}[h!] \centering \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/tputComparePreemptiveVsN_noServer_4.pdf} \caption{\label{fig:optTCompare4servPreEmp}% $m=4$} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/tputComparePreemptiveVsN_noServer_8.pdf} \caption{\label{fig:optTPutCompare8servPreEmp}% $m=8$} \end{subfigure} \hfill \begin{subfigure}[t]{0.32\textwidth} \centering \includegraphics[width=1\textwidth]{figures/tputComparePreemptiveVsN_noServer_16.pdf} \caption{\label{fig:optTCompare16servPreEmp}% $m=16$} \end{subfigure} \caption{\label{fig:optTPut-vs-n-2jobs}% The optimal total steady state throughput for the two-job types case, preemptive priority, and linear speedup.}% \end{figure*} From the above theorem it follows that the asymptotic throughput is a linear combination of $w_1^*$ and $w_2^*$. Given the forms of the speedup functions $\mu_1(k)$ and $\mu_2(k)$, we can optimize the asymptotic throughput jointly over $k_1$ and $k_2$. The time taken to find the asymptotic optimal batch sizes is clearly independent of the system size $n$ and these asymptotic solutions serve as accurate estimates for batch sizes for finite systems, as we will show in Sec.~\ref{sec:numerical}.
{'timestamp': '2020-09-22T02:16:50', 'yymm': '2009', 'arxiv_id': '2009.09433', 'language': 'en', 'url': 'https://arxiv.org/abs/2009.09433'}
arxiv
\section{Introduction} One of the most explored problems in remote sensing is the pixelwise labeling of satellite imagery. Such a labeling is used in a wide range of practical applications, such as precision agriculture and urban planning. Recent technological developments have substantially increased the availability and resolution of satellite data. Besides the computational complexity issues that arise, these advances are posing new challenges in the processing of the images. Notably, the fact that large surfaces are covered introduces a significant variability in the appearance of the objects. In addition, the fine details in high-resolution images make it difficult to classify the pixels from elementary cues. For example, the different parts of an object often contrast more with each other than with other objects \cite{buildingDetection}. Using high-level contextual features thus plays a crucial role at distinguishing object classes. Convolutional neural networks (CNNs) \cite{lecunNets} are receiving an increasing attention, due to their ability to automatically discover relevant contextual features in image categorization problems. CNNs have already been used in the context of remote sensing \cite{mnih,paragiosBuildingDetection}, featuring powerful recognition capabilities. However, when the goal is to label images at the pixel level, the output classification maps are too coarse. For example, buildings are successfully detected but their boundaries in the classification map rarely coincide with the real object boundaries. We can identify two main reasons for this coarseness in the classification: \textit{a)} There is a structural limitation of CNNs to carry out fine-grained classification. If we wish to keep a low number of learnable parameters, the ability to learn long-range contextual features comes at the cost of losing spatial accuracy, i.e., a trade-off between detection and localization. This is a well-known issue and still a scientific challenge \cite{deeplab,fcn}. \textit{b)} In the specific context of remote sensing imagery, there is a significant lack of spatially accurate reference data for training. For example, the OpenStreetMap collaborative database provides large amounts of free-access maps over the earth, but irregular misregistrations and omissions are frequent all over the dataset. In such circumstances, CNNs cannot do better than learning rough estimates of the objects' locations, given that the boundaries are hardly located on real edges in the training set. Let us remark that in the particular context of high-resolution satellite imagery, the spatial precision of the classification maps is of paramount importance. Objects are small and a boundary misplaced by a few pixels significantly hampers the overall classification quality. In other application domains, such as semantic segmentation of natural scenes, while there have been recent efforts to better shape the output objects, a high resolution output seems to be less of a priority. For example, in the popular Pascal VOC semantic segmentation dataset, there is a band of several unlabeled pixels around the objects, where accuracy is not computed to assess the performance of the methods. \begin{figure} \begin{subfigure}{0.49\linewidth} \centering \includegraphics[scale=0.35]{figs/gt/osm-1} \caption{OpenStreetMap} \end{subfigure} \begin{subfigure}{0.49\linewidth} \centering \includegraphics[scale=0.35]{figs/gt/precise-1} \caption{Manual labeling} \end{subfigure} \caption{Samples of reference data for the \emph{building} class. Imprecise OpenStreetMap data vs manually labeled data.} \label{f:gt_samples} \end{figure} There are two recent approaches to overcome the structural issues that lead to coarse classification maps. One of them is to use new types of CNN architectures, specifically designed for pixel labeling, that seek to address the detection/localization trade-off. For example, Noh et al.~\cite{deconv} duplicate a base classification CNN by attaching a reflected ``deconvolution'' network, which learns to upsample the coarse classification maps. Another tendency is to use first the base CNN as a rough classifier of the objects' locations, and then process this classification using the original image as guidance, so that the output objects better align to real image edges. For example, Zheng et al.~\cite{crfrnn} use a fully connected CRF in this manner, and Chen et al.~\cite{dt} diffuse the classification probabilities with an edge-stopping function based on image features. Both approaches have also been adopted by the remote sensing community, mostly in the context of the ISPRS Semantic Labeling Contest, to produce fine-grained labelings of high-resolution aerial images~\cite{volpi,isprs_effective,kampf}. While all these works have certainly pushed the boundaries of CNN capabilities for pixel labeling, they assume the availability of large amounts of precisely labeled training data. This paper targets the task of dealing with more realistic datasets, seeking to provide a means to refine classification maps that are too coarse due to poor reference data The first scheme, i.e., the use of novel CNN architectures, seems unfeasible in the context of large-scale satellite imagery, due to the nature of the available training data. Even if an advanced architecture could eventually learn to conduct a more precise labeling, this is not useful when the training data itself is inaccurate. We thus here adopt the second strategy, reinjecting image information to an enhancement module that sharpens the coarse classification maps around the objects. To train or set the parameters of this enhancement module, as well as to validate the algorithms, we assume we can afford to manually label small amounts of data. In Fig.~\ref{f:gt_samples}(a) we show an example of imprecise data to which we have access in large quantities, and in Fig.~\ref{f:gt_samples}(b) we show a portion of manually labeled data. In our approach, the first type of data is used to train a large CNN to learn the generalities of the object classes, and the second to tune and validate the algorithm that enhances the coarse classification maps outputted by the CNN. An algorithm to enhance coarse classification maps would require, on the one hand, to define the image features to which the objects must be attached. This is data-dependent, not every image edge being necessarily an object boundary. On the other hand, we must also decide which enhancement algorithm to use, and tune it. Besides the efforts that this requires, we could also imagine that the optimal approach would go beyond the algorithms presented in the literature. For example we could perform different types of corrections on the different classes, based on the type of errors that are often present in each of them. Our goal is to create a system that learns the appropriate enhancement algorithm itself, instead of designing it by hand. This involves learning not only the relevant features but also the rationale behind the enhancement technique, thus intensively leveraging the power of machine learning. To achieve this, we first formulate a generic partial differential equation governing a broad family of iterative enhancement algorithms. This generic equation conveys the idea of progressively refining a classification map based on local cues, yet it does not provide the specifics of the algorithm. We then observe that such an equation can be expressed as a combination of common neural network layers, whose learnable parameters define the specific behavior of the algorithm. We then see the whole iterative enhancement process as a recurrent neural network (RNN). The RNN is provided with a small piece of manually labeled image, and trained end to end to improve coarse classification maps. It automatically discovers relevant data-dependent features to enhance the classification as well as the equations that govern every enhancement iteration. \subsection{Related work} A common way to tackle the aerial image labeling problem is to use classifiers such as support vector machines~\cite{svmHyperspectral} or neural networks \cite{nnHyperspectral} on the individual pixel spectral signatures (i.e., a pixel's ``color'' but not limited to RGB bands). In some cases, a few neighboring pixels are analyzed jointly to enhance the prediction and enforce the spatial smoothness of the output classification maps \cite{spectralSpatial}. Hand-designed features such as textural features have also been used \cite{nnTexture}. The use of an iterative classification enhancement process on top of hand-designed features has also been explored in the context of image labeling \cite{autocontext}. Following the recent advent of deep learning and to address the new challenges posed by large-scale aerial imagery, Penatti et al.~\cite{doDeepFeaturesGeneralizeToRemoteSensing} used CNNs to assign aerial image patches to categories (e.g., `residential', `harbor') and Vakalopoulou et al.~\cite{paragiosBuildingDetection} addressed building detection using CNNs. Mnih \cite{mnih} and Maggiori et al.~\cite{maggiori2016fully,maggiori2017convolutional} used CNNs to learn long-range contextual features to produce classification maps. These networks require some degree of downsampling in order to consider large contexts with a reduced number of parameters. They perform well at detecting the presence of objects but do not outline them accurately. Our work can also be related to the area of natural image semantic segmentation. Notably, fully convolutional networks (FCN) \cite{fcn} are becoming increasingly popular to conduct pixelwise image labeling. FCN networks are made up of a stack of convolutional and pooling layers followed by so-called deconvolutional layers that upsample the resolution of the classification maps, possibly combining features at different scales. The output classification maps being too coarse, the authors of the Deeplab network \cite{deeplab} added a fully connected conditional random field (CRF) on top of both the FCN and the input color image, in order to enhance the classification maps. Most of the strategies developed for natural images segmentation have been adapted to high-resolution aerial image labeling and tested on the ISPRS benchmark, including advanced FCNs~\cite{volpi} and CNNs coupled with CRFs~\cite{isprs_effective}. Zheng et al.~\cite{crfrnn} recently reformulated the fully connected CRF of Deeplab as an RNN, and Chen et al.~\cite{dt} designed an RNN that emulates the domain transform filter \cite{gastal2011domain}. Such a filter is used to sharpen the classification maps around image edges, which are themselves detected with a CNN. In these methods the refinement algorithm is designed beforehand and only few parameters that rule the algorithm are learned as part of the network's parameters. The innovating aspect of these approaches is that both steps (coarse classification and enhancement) can be seen as a single end-to-end network and optimized simultaneously. Instead of predefining the algorithmic details as in previous works, we formulate a general iterative refinement algorithm through an RNN and let the network learn the specific algorithm. To our knowledge, little work has explored the idea of learning an iterative algorithm. In the context of image restoration, the preliminary work by Liu et al.~\cite{learnPDE2,learnPDE} proposed to optimize the coefficients of a linear combination of predefined terms. Chen et al.~\cite{chen2015learning} later modeled this problem as a diffusion process and used an RNN to learn the linear filters involved as well as the coefficients of a parametrized nonlinear function. Our problem is however different, in that we use the image as guidance to update a classification map, and not to restore the image itself. Besides, while we drew inspiration on diffusion processes, we are also interested in imitating other iterative processes like active contours, thus we do not restrict our system to diffusions but consider all PDEs. \section{Enhancing classification maps with RNNs} Let us assume we are given a set of score (or ``heat'') maps $u_k$, one for each possible class $k \in \mathcal{L}$, in a pixelwise labeling problem. The score of a pixel reflects the likelihood of belonging to a class, according to the classifier's predictions. The final class assigned to every pixel is the one with maximal value $u_k$. Alternatively, a softmax function can be used to interpret the results as probability scores: $P(k) = e^{u_k} / \sum_{j \in \mathcal{L}} e^{u_j}$. Fig.~\ref{f:heatmap} shows a sample of the type of fuzzy heat map outputted by a CNN in the context of satellite image classification, for the class `building'. Our goal is to combine the score maps $u_k$ with information derived from the input image (e.g.,~edge features) to sharpen the scores near the real objects in order to enhance the classification. \begin{figure} \centering \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.37]{figs/heatmap/color} \caption{Color image} \end{subfigure} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.37]{figs/heatmap/hm} \caption{CNN heat map} \end{subfigure} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.37]{figs/heatmap/gt} \caption{Ground truth} \end{subfigure} \caption{Sample classification of buildings with a CNN. The output classification map is overly fuzzy due to the imprecision of reference data and structural limitations of CNNs.} \label{f:heatmap} \end{figure} One way to perform such a task is to progressively enhance the score maps by using partial differential equations (PDEs). In this section we first describe different types of PDEs we could certainly imagine to design in order to solve our problem. Instead of discussing which one is the best, we then propose a generic iterative process to enhance the classification maps without specific constraints on the algorithm rationale. Finally, we show how this equation can be expressed and trained as a recurrent neural network (RNN). \subsection{Partial differential equations (PDEs)} We can formulate a variety of diffusion processes applied to the maps $u_k$ as partial differential equations. For example, the heat flow is described as: \begin{equation} \frac{\partial u_{k} (x)}{\partial t} = \text{div} ( \nabla u_k (x) ), \label{eq:heatFlow} \end{equation} where $\text{div}(\cdot)$ denotes the divergence operator in the spatial domain of $x$. Applying such a diffusion process in our context would smooth out the heat maps. Instead, our goal is to design an image-dependent smoothing process that aligns the heat maps to the image features. A natural way of doing this is to modulate the gradient in Eq.~\ref{eq:heatFlow} by a scalar function $g(x,I)$ that depends on the input image $I$: \begin{equation} \frac{\partial u_{k} (x)}{\partial t} = \text{div} ( g(I,x) \nabla u_k (x) ). \label{eq:peronaMalik} \end{equation} Eq.~\ref{eq:peronaMalik} is similar to the Perona-Malik diffusion \cite{peronaMalik} with the exception that Perona-Malik uses the smoothed function itself to guide the diffusion. $g(I,x)$ denotes an edge-stopping function that takes low values near borders of $I(x)$ in order to slow down the smoothing process there. Another possibility would be to consider a more general variant in which $g(I,x)$ is replaced by a matrix $D(I,x)$, acting as a diffusion tensor that redirects the flow based on image properties instead of just slowing it down near edges: \begin{equation} \frac{\partial u_{k} (x)}{\partial t} = \text{div} ( D(I,x) \nabla u_k (x) ). \label{eq:anisDiff} \end{equation} This formulation relates to the so-called anisotropic diffusion process \cite{weickertBook}. Alternatively, one can draw inspiration from the level set framework. For example, the geodesic active contours technique formulated as level sets translates into: \begin{equation} \frac{\partial u_{k} (x)}{\partial t} = |\nabla u_{k}(x)| \text{div} \left( g(I,x) \frac{\nabla u_k (x)}{|\nabla u_k(x)|} \right). \label{eq:gac} \end{equation} Such a formulation favors the zero level set to align with minima of $g(I,x)$ \cite{gac}. Schemes based on Eq.~\ref{eq:gac} could then be used to improve heat maps $u_k$, provided they are scaled so that segmentation boundaries match zero levels. As shown above, many different PDE approaches can be devised to enhance classification maps. However, several choices must be made to select the appropriate PDE and tailor it to our problem. For example, one must choose the edge-stopping function $g(I,x)$ in Eqs.~\ref{eq:peronaMalik}, \ref{eq:gac}. Common choices are exponential or rational functions on the image gradient~\cite{peronaMalik}, which in turn requires to set an edge-sensitivity parameter. Extensions to the original Perona-Malik approach could also be considered, such as a popular regularized variant that computes the gradient on a Gaussian-smoothed version of the input image \cite{weickertBook}. In the case of opting for anisotropic diffusion, one must design $D(I,x)$. Instead of using trial and error to perform such design, our goal is to let a machine learning approach discover by itself a useful iterative process for our task. \subsection{A generic classification enhancement process} PDEs are usually discretized in space by using finite differences, which represent derivatives as discrete convolution filters. We build upon this scheme to write a generic discrete formulation of an enhancement iterative process. Let us consider that we take as input a score map $u_k$ (for class $k$) and, in the most general case, an arbitrary number of feature maps $\{g_1,...,g_p\}$ derived from image~$I$. In order to perform differential operations, of the type $\{\frac{\partial}{\partial x},\frac{\partial}{\partial y}, \frac{\partial^2}{\partial x \partial y}, \frac{\partial^2}{\partial x^2},...\}$, we consider convolution kernels $\{M_1,M_2,...\}$ and $\{N_1^j, N_2^j,...\}$ to be applied to the heat map $u_k$ and to the features $g_j$ derived from image $I$, respectively. While we could certainly directly provide a bank of filters $M_i$ and $N_i^j$ in the form of Sobel operators, Laplacian operators, etc., we may simply let the system learn the required filters. We group all the feature maps that result from applying these convolutions, in a single set: \begin{equation} \Phi(u_k, I) = \left\{ M_i \ast u_k,\; \;N_l^j \ast g_j(I)\; ;\;\; \forall i,j,l\right\}. \label{eq:functionals} \end{equation} Let us now define a generic discretized scheme as: \begin{equation} \frac{\partial u_{k} (x)}{\partial t} = f_k \big( \; \Phi(u_k,I)(x)\; \big), \label{eq:spaceDiscretization_new} \end{equation} where $f_k$ is a function that takes as input the values of all the features in $\Phi(u_k,I)$ at an image point $x$, and combines them. While convolutions $M_i$ and $N_i^j$ convey the ``spatial'' reasoning, e.g., gradients, $f_k$ captures the combination of these elements, such as the products in Eqs.~\ref{eq:peronaMalik} and \ref{eq:gac}. Instead of deriving an arbitrary number of possibly complex features $N_i^j \ast g_j(I)$ from image $I$, we can think of a simplified scheme in which we directly operate on $I$, by considering only convolutions: $N_i \ast I$. The list of functionals considered in Eq.~\ref{eq:spaceDiscretization_new} is then \begin{equation} \Phi(u_k, I) = \Big\{ M_i \ast u_k, \;\;N_j \ast I \; ; \;\; \forall i,j \Big\} \label{eq:functionals_simplified} \end{equation} and consists only of convolutional kernels directly applied to the heat maps $u_k$ and to the image $I$. From now on, we here stick to this simpler formulation, yet we acknowledge that it might be eventually useful to work on a higher-level representation rather than on the input image itself. Note that if one restricts functions $f_k$ in Eq.~\ref{eq:spaceDiscretization_new} to be linear, we still obtain the set of all linear PDEs. We consider \emph{any} function $f_k$, introducing non-linearities. PDEs are usually discretized in time, taking the form: \begin{equation} u_{k,t+1} (x) = u_{k,t} (x) + \delta u_{k,t} (x), \label{eq:timeDiscretization} \end{equation} where $\delta u_{k,t} $ denotes the overall update of $u_{k,t}$ at time~$t$. Note that the convolution filters in Eqs.~\ref{eq:functionals} and \ref{eq:functionals_simplified} are class-agnostic: $M_i$, $N_j$ and $N_l^j$ do not depend on $k$, while $f_k$ may be a different function for each class~$k$. Function $f_k$ thus determines the contribution of each feature to the equation, contemplating the case in which a different evolution might be optimal for each of the classes, even if just in terms of a time-step factor. In the next section we detail a way to learn the update functions $\delta u_{k,t}$ from training data. \subsection{Iterative processes as RNNs} \label{s:PDEasRNN} \begin{figure*} \centering \includegraphics[scale=0.67]{figs/rnn_iter} \caption{One enhancement iteration represented as common neural network layers. Features are extracted both from the input image $I$ and the heat map of the previous iteration $u_t$. These are then concatenated and inputted to an MLP, which computes the update $\delta u_t$. The heat map $u_t$ is added to the update $\delta u_t$ to yield the modified map $u_{t+1}$.} \label{f:rnn_oneiter} \end{figure*} We now show that the generic iterative process can be implemented as an RNN, and thus trained from labeled data. This stage requires to provide the system with a piece of accurately labeled ground truth (see e.g., Fig.~\ref{f:gt_samples}b) Let us first show that one iteration, as defined in Eqs.~\ref{eq:spaceDiscretization_new}-\ref{eq:timeDiscretization}, can be expressed in terms of common neural network layers. Let us focus on a single pixel for a specific class, simplifying the notation from $u_{k,t} (x)$ to $u_t$. Fig.~\ref{f:rnn_oneiter} illustrates the proposed network architecture. Each iteration takes as input the image $I$ and a given heat map $u_t$ to enhance at time $t$. In the first iteration, $u_t$ is the initial coarse heat map to be improved, outputted by another pre-trained neural network in our case. From the heat map $u_t$ we derive a series of filter responses, which correspond to $M_i \ast u_t$ in Eq.~\ref{eq:functionals_simplified}. These responses are found by computing the dot product between a set of filters $M_i$ and the values of $u_{k,t}(\cdot)$ in a spatial neighborhood of a given point. Analogously, a set of filter responses are computed at the same spatial location on the input image, corresponding to the different $N_j \ast I$ of Eq.~\ref{eq:functionals_simplified}. These operations are convolutions when performed densely in space, $N_j\ast I$ and $M_i\ast u_t$ being feature maps of the filter responses. These filters are then ``concatenated'', forming a pool of features $\Phi$ coming from both the input image and the heat map, as in Eq.~\ref{eq:functionals_simplified}, and inputted to $f_k$ in Eq.~\ref{eq:spaceDiscretization_new}. We must now learn the function $\delta u_t$ that describes how the heat map $u_t$ is updated at iteration $t$ (cf.~Eq.~\ref{eq:timeDiscretization}), based on these features. Eq.~\ref{eq:spaceDiscretization_new} does not introduce specifics about function $f_k$. In (\ref{eq:heatFlow})-(\ref{eq:gac}), for example, it includes products between different terms, but we could certainly imagine other functions. We therefore model $\delta u_t$ through a multilayer perceptron (MLP), because it can approximate any function within a bounded error. We include one hidden layer with nonlinear activation functions followed by an output neuron with a linear activation (a typical configuration for regression problems), although other MLP architectures could be used. Applying this MLP densely is equivalent to performing convolutions with $1\times1$ kernels at every layer. The implementation to densely label entire images is then straightforward. The value of $\delta u_t$ is then added to $u_{t}$ in order to generate the updated map $u_{t+1}$. This addition is performed pixel by pixel in the case of a dense input. Note that although we could have removed this addition and let the MLP directly output the updated map $u_{t+1}$, we opted for this architecture since it is more closely related to the equations and better conveys the intention of a progressive refinement of the classification map. Moreover, learning $\delta u_t$ instead of $u_{t+1}$ has a significant advantage at training time: a random initialization of the networks' parameters centered around zero means that the initial RNN represents an iterative process close to the identity (with some noise). Training uses the asymmetry induced by this noise to progressively move from the identity to a more useful iterative process. The overall iterative process is implemented by unrolling a finite number of iterations, as illustrated in Fig.~\ref{f:rnn_manyiter}, under the constraint that the parameters are shared among all iterations. Such sharing is enforced at training time by a simple modification to the back-propagation training algorithm where the derivatives of every instance of a weight at different iterations are averaged \cite{backpropThroughTime}. Note that issues with vanishing or exploding gradients may arise when too many iterations are unrolled, an issue inherent to deep network architectures. Note also that the spatial features are shared across the classes, while a different MLP is learned for each of them, following Eq.~\ref{eq:spaceDiscretization_new}. As depicted by Fig.~\ref{f:rnn_manyiter} and conveyed in the equations, the features extracted from the input image are independent of the iteration. \begin{figure*} \centering \includegraphics[scale=0.85]{figs/rnn_iters} \caption{The modules of Fig.~\ref{f:rnn_oneiter} are stacked (while sharing parameters) to implement the iterative process as an RNN.} \label{f:rnn_manyiter} \end{figure*} The RNN of Fig.~\ref{f:rnn_manyiter} represents then a dynamical system that iteratively improves the class heat maps. Training such an RNN amounts to finding the optimal dynamical system for our enhancement task. \section{Implementation details} \label{s:implDetails} We first describe the CNN used to produce the coarse predictions, then detail our RNN. The network architecture was implemented using Caffe deep learning library \cite{caffe}. Our coarse prediction CNN is based on a previous remote sensing network presented by Mnih \cite{mnih}. We create a fully convolutional~\cite{fcn} version of Mnih's network, since recent remote sensing work has shown the theoretical and practical advantages of this type of architecture~\cite{kampffmeyer2016semantic,maggiori2016fully}. The CNN takes 3-band color image patches at 1m$^2$ resolution and produces as many heat maps as classes considered. The resulting four-layer architecture is as follows: 64 conv.~filters ($12\times 12$, stride 4) $\rightarrow$ 128 conv.~filters ($3\times 3$) $\rightarrow$ 128 conv.~filters ($3\times 3$) $\rightarrow$ 3 conv.~filters ($9\times9$). Since the first convolution is performed with a stride of 4, the resulting feature maps have a quarter of the input resolution. Therefore, a deconvolutional layer \cite{fcn} is added on top to upsample the classification maps to the original resolution. The activation functions used in the hidden layers are rectified linear units. This network is trained on patches randomly selected from the training dataset. We group 64 patches with classification maps of size $64\times 64$ into mini-batches (following \cite{mnih}) to estimate the gradient of the network's parameters and back-propagate them. Our loss function is the cross-entropy between the target and predicted class probabilities. Stochastic gradient descent is used for optimization, with learning rate 0.01, momentum 0.9 and an L2 weight regularization of 0.0002. We did not however optimized these parameters nor the networks' architectures. We now detail the implementation of the RNN described in Sec.~\ref{s:PDEasRNN}. Let us remark that at this stage we fix the weights of the initial coarse CNN and the manually labeled tile is used to train the RNN only. Our RNN learns 32 $M_i$ and 32 $N_j$ filters, both of spatial dimensions $5 \times 5$. An independent MLP is learned for every class, using 32 hidden neurons each and with rectified linear activations, while $M_i$ and $N_j$ filters are shared across the different classes (in accordance to Equations~\ref{eq:spaceDiscretization_new} and~\ref{eq:functionals_simplified}). This highlights the fact that $M_i$ and $N_j$ capture low-level features while the MLPs convey class-specific behavior. We unroll five RNN iterations, which enables us to significantly improve the classification maps without exhausting our GPU's memory. Training is performed on random patches and with the cross-entropy loss function, as done with the coarse CNN. The employed gradient descent algorithm is AdaGrad~\cite{adagrad}, which exhibits a faster convergence in our case, using a base learning rate of 0.01 (higher values make the loss diverge). All weights are initialized randomly by sampling from a distribution that depends on the number of neuron inputs~\cite{xavier}. We trained the RNN for 50,000 iterations, until observing convergence of the training loss, which took around four hours on a single GPU. \section{Experiments} We perform our experiments on images acquired by a Pl\'eiades satellite over the area of Forez, France. An RGB color image is used, obtained by pansharpening \cite{pansharpening} the satellite data, which provides a spatial resolution of 0.5 $\text{m}^2$. Since the networks described in Sec.~\ref{s:implDetails} are specifically designed for 1 $\text{m}^2$ resolution images, we downsample the Pl\'eiades images before feeding them to our networks and bilinearly upsample the outputs. \begin{figure} \centering \begin{subfigure}{0.5\linewidth} \centering \includegraphics[scale=0.04]{figs/tuning_tile/img} \end{subfigure}% \begin{subfigure}{0.5\linewidth} \centering \includegraphics[scale=0.04]{figs/tuning_tile/ref} \end{subfigure}% \caption{Manually labeled tile used to train the RNN for the classification enhancement task.} \label{f:fineTuningTile} \end{figure} \begin{figure*} \centering \begin{subfigure}[t]{0.2\linewidth} \centering \begin{subfigure}{0.49\linewidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/classif_it0_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/colors_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/colors_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/colors_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/colors_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/colors_selection-0007} \caption*{Color} \end{subfigure} \begin{subfigure}{0.48\linewidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/classif_it0_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/colors_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/colors_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/colors_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/colors_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/colors_selection-0001} \caption*{CNN map} \end{subfigure} (RNN input) \end{subfigure} \hspace{10pt} \begin{subfigure}{0.41\linewidth} \centering \begin{subfigure}{0.235\textwidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/classif_it0_selection-0002} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/colors_selection-0002} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/colors_selection-0002} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/colors_selection-0002} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/colors_selection-0002} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/colors_selection-0002} \end{subfigure} \begin{subfigure}{0.235\textwidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/classif_it0_selection-0003} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/colors_selection-0003} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/colors_selection-0003} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/colors_selection-0003} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/colors_selection-0003} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/colors_selection-0003} \end{subfigure} \begin{subfigure}{0.235\textwidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/classif_it0_selection-0004} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/colors_selection-0004} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/colors_selection-0004} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/colors_selection-0004} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/colors_selection-0004} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/colors_selection-0004} \end{subfigure} \begin{subfigure}{0.235\textwidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/classif_it0_selection-0005} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/colors_selection-0005} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/colors_selection-0005} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/colors_selection-0005} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/colors_selection-0005} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/colors_selection-0005} \end{subfigure} \caption*{--- Intermediate RNN iterations ---} \end{subfigure} \begin{subfigure}{0.12\linewidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/classif_it0_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/colors_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/colors_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/colors_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/colors_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/colors_selection-0006} \caption*{RNN output} \end{subfigure} \begin{subfigure}{0.12\linewidth} \centering \includegraphics[scale=0.231]{figs/frags/frag4/gt} \vspace{1.5pt} \includegraphics[scale=0.202]{figs/frags/frag8/gt} \vspace{1.5pt} \includegraphics[scale=0.317]{figs/frags/frag12/gt} \vspace{1.5pt} \includegraphics[scale=0.44]{figs/frags/frag9/gt_build} \vspace{1.5pt} \includegraphics[scale=0.427]{figs/frags/frag10/gt_build} \vspace{1.5pt} \includegraphics[scale=0.254]{figs/frags/frag11/gt_road} \caption*{\mbox{Ground truth}} \end{subfigure} \caption{Evolution of fragments of classification maps (top rows) and single-class fuzzy scores (bottom rows) through RNN iterations. The classification maps are progressively sharpened around object's edges.} \label{f:frags_iterations} \end{figure*} From this image we selected an area with OpenStreetMap (OSM) \cite{osm} coverage to create a 22.5 $\text{km}^2$ training dataset for the classes \emph{building}, \emph{road} and \emph{background}. The reference data was obtained by rasterizing the raw OSM maps. Misregistrations and omissions are present all over the dataset (see, e.g., Fig.~\ref{f:gt_samples}a). Buildings tend to be misaligned or omitted, while many roads in the ground truth are not visible in the image (or the other way around). Moreover, since OSM's roads are represented by polylines, we set a fixed road width of 7 m to rasterize this class (following~\cite{mnih}), which makes their classification particularly challenging. This dataset is used to train the initial coarse CNNs. We manually labeled two 2.25 $\text{km}^2$ tiles to train and test the RNN at enhancing the predictions of the coarse network. We denote them by enhancement and test sets, respectively. Note that our RNN system must discover an algorithm to refine an existing classification map, and not to conduct the classification itself, hence a smaller training set should be sufficient for this stage. The enhancement set is depicted in Fig.~\ref{f:fineTuningTile} while the test set is shown in Figs.~\ref{f:large_results}(a)/(f). In the following, we report the results obtained by using the proposed method on the \mbox{Pl\'eiades} dataset. Fig.~\ref{f:frags_iterations} provides closeups of results on different fragments of the test dataset. The initial and final maps (before and after the RNN enhancement) are depicted, as well as the intermediate results through the RNN iterations. We show both a set of final classification maps and some single-class fuzzy probability maps. We can observe that as the RNN iterations go by, the classification maps are refined and the objects better align to image edges. The fuzzy probabilities become more confident, sharpening object boundaries. To quantitatively assess this improvement we compute two measures on the test set: the overall accuracy (proportion of correctly classified pixels) and the intersection over union (IoU)~\cite{fcn}. Mean IoU has become the standard in semantic segmentation since it is more reliable in the presence of imbalanced classes (such as \emph{background} class, which is included to compute the mean)~\cite{acc}. As summarized in the table of Fig.~\ref{f:quantitative}(a), the performance of the original coarse CNN (denoted by \textsc{cnn}) is significantly improved by attaching our RNN (\textsc{cnn+rnn}). Both measures increase monotonously along the intermediate RNN iterations, as depicted in Fig.~\ref{f:quantitative}(b). \begin{figure} \begin{subfigure}{\linewidth} \centering \setlength{\tabcolsep}{4pt} \small \begin{tabular}{ccc|ccc} & Overall & Mean & \multicolumn{3}{c}{Class-specific IoU} \\ Method & \hspace{-5pt} accuracy \hspace{-5pt} & IoU & Build. & Road & Backg. \\ \hline CNN & 96.72 & 48.32 & 38.92 & 9.34 & 96.69 \\ CNN+CRF & 96.96 & 44.15 & 29.05 & 6.62 & 96.78 \\ CNN+RNN$^=$ & 97.78 & 65.30 & 59.12 & 39.03 & 97.74 \\ CNN+RNN & \textbf{98.24} & \textbf{72.90} & \textbf{69.16} & \textbf{51.32} & \textbf{98.20} \\ \hline \end{tabular} \caption{Numerical comparison (in \%)} \end{subfigure} \begin{subfigure}{\linewidth} \centering \includegraphics[scale=0.55]{figs/rnniter-eps-converted-to} \includegraphics[scale=0.55]{figs/rnniter_iou-eps-converted-to} \caption{Evolution through RNN iterations} \end{subfigure} \caption{Quantitative evaluation on Pl\'eaiades images test set over Forez, France.} \vspace{10pt} \label{f:quantitative} \end{figure} \begin{comment} \begin{figure*} \begin{subfigure}{0.24\linewidth} \centering \includegraphics[scale=0.16]{figs/frags/frag2/classif_it0_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.258]{figs/frags/frag1/classif_it0_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.144]{figs/frags/frag3/classif_it0_selection-0007} \caption*{Color image} \end{subfigure} \begin{subfigure}{0.24\linewidth} \centering \includegraphics[scale=0.16]{figs/frags/frag2/classif_it0_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.258]{figs/frags/frag1/classif_it0_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.144]{figs/frags/frag3/classif_it0_selection-0001} \caption*{Coarse CNN classif.} \end{subfigure} \begin{subfigure}{0.24\linewidth} \centering \includegraphics[scale=0.16]{figs/frags/frag2/classif_it0_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.258]{figs/frags/frag1/classif_it0_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.144]{figs/frags/frag3/classif_it0_selection-0006} \caption*{RNN output} \end{subfigure} \begin{subfigure}{0.24\linewidth} \centering \includegraphics[scale=0.16]{figs/frags/frag2/gt} \vspace{1.5pt} \includegraphics[scale=0.258]{figs/frags/frag1/gt} \vspace{1.5pt} \includegraphics[scale=0.144]{figs/frags/frag3/gt} \caption*{Ground truth} \end{subfigure} \caption{Initial coarse classifications and the enhanced maps by using RNNs.} \label{f:beforeAfter} \end{figure*} \end{comment} \begin{figure} \begin{subfigure}{0.25\linewidth} \centering \includegraphics[scale=0.114]{figs/frags/frag2/classif_it0_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.183]{figs/frags/frag1/classif_it0_selection-0007} \vspace{1.5pt} \includegraphics[scale=0.102]{figs/frags/frag3/classif_it0_selection-0007} \caption*{Color image} \end{subfigure}% \begin{subfigure}{0.25\linewidth} \centering \includegraphics[scale=0.114]{figs/frags/frag2/classif_it0_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.183]{figs/frags/frag1/classif_it0_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.102]{figs/frags/frag3/classif_it0_selection-0001} \caption*{Coarse CNN } \end{subfigure}% \begin{subfigure}{0.25\linewidth} \centering \includegraphics[scale=0.114]{figs/frags/frag2/classif_it0_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.183]{figs/frags/frag1/classif_it0_selection-0006} \vspace{1.5pt} \includegraphics[scale=0.102]{figs/frags/frag3/classif_it0_selection-0006} \caption*{RNN output} \end{subfigure}% \begin{subfigure}{0.25\linewidth} \centering \includegraphics[scale=0.114]{figs/frags/frag2/gt} \vspace{1.5pt} \includegraphics[scale=0.183]{figs/frags/frag1/gt} \vspace{1.5pt} \includegraphics[scale=0.102]{figs/frags/frag3/gt} \caption*{Ground truth} \end{subfigure}% \caption{Initial coarse classifications and the enhanced maps by using RNNs.} \label{f:beforeAfter} \end{figure} The initial classification of roads has an overlap of less than 10\% with the roads in the ground truth, as shown by its individual IoU. The RNN makes them emerge from the background class, now overlapping the ground truth roads by over 50\%. Buildings also become better aligned to the real boundaries, going from less than 40\% to over 70\% overlap with the ground truth buildings. This constitutes a multiplication of the IoU by a factor of 5 for roads and 2 for buildings, which indicates a significant improvement at outlining and not just detecting objects. Additional visual fragments before and after the RNN refinement are shown in Fig.~\ref{f:beforeAfter}. We can observe in the last row how the iterative process learned by the RNN both thickens and narrows the roads depending on the location. \begin{figure*} \centering \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.055]{figs/largeresults/colorjpg} \caption{Color image} \end{subfigure} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.055]{figs/largeresults/it0} \caption{Coarse CNN} \end{subfigure} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.055]{figs/largeresults/crf} \caption{CNN+CRF} \end{subfigure} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.055]{figs/largeresults/notIndep} \caption{Class-agnostic CNN+RNN} \end{subfigure} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.055]{figs/largeresults/it5} \caption{CNN+RNN} \end{subfigure} \begin{subfigure}{0.32\linewidth} \centering \includegraphics[scale=0.055]{figs/largeresults/gt} \caption{Ground truth} \end{subfigure} \caption{Visual comparison on a Pl\'eiades satellite image tile of size 3000$\times$3000 covering 2.25 km$^2$.} \label{f:large_results} \end{figure*} \begin{figure*} \captionsetup[subfigure]{justification=centering} \centering \begin{subfigure}[t]{0.161\linewidth} \centering \includegraphics[scale=0.22]{figs/frags/frag13/colors_selection-0003} \vspace{1.5pt} \includegraphics[scale=0.405]{figs/frags/frag14/colors_selection-0003} \vspace{1.5pt} \includegraphics[scale=0.156]{figs/frags/frag15/colors_selection-0003} \caption*{Color image} \end{subfigure} \begin{subfigure}[t]{0.161\linewidth} \centering \includegraphics[scale=0.22]{figs/frags/frag13/colors_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.405]{figs/frags/frag14/colors_selection-0001} \vspace{1.5pt} \includegraphics[scale=0.156]{figs/frags/frag15/colors_selection-0001} \caption*{Coarse CNN} \end{subfigure} \begin{subfigure}[t]{0.161\linewidth} \centering \includegraphics[scale=0.22]{figs/frags/frag13/crf} \vspace{1.5pt} \includegraphics[scale=0.405]{figs/frags/frag14/crf} \vspace{1.5pt} \includegraphics[scale=0.156]{figs/frags/frag15/crf} \caption*{CNN+CRF} \end{subfigure} \begin{subfigure}[t]{0.161\linewidth} \centering \includegraphics[scale=0.22]{figs/frags/frag13/notIndep} \vspace{1.5pt} \includegraphics[scale=0.405]{figs/frags/frag14/notIndep} \vspace{1.5pt} \includegraphics[scale=0.156]{figs/frags/frag15/notIndep} \caption*{Class-agnostic CNN+RNN} \end{subfigure} \begin{subfigure}[t]{0.161\linewidth} \centering \includegraphics[scale=0.22]{figs/frags/frag13/colors_selection-0002} \vspace{1.5pt} \includegraphics[scale=0.405]{figs/frags/frag14/colors_selection-0002} \vspace{1.5pt} \includegraphics[scale=0.156]{figs/frags/frag15/colors_selection-0002} \caption*{CNN+RNN} \end{subfigure} \begin{subfigure}[t]{0.161\linewidth} \centering \includegraphics[scale=0.22]{figs/frags/frag13/gt} \vspace{1.5pt} \includegraphics[scale=0.405]{figs/frags/frag14/gt} \vspace{1.5pt} \includegraphics[scale=0.156]{figs/frags/frag15/gt} \caption*{Ground truth} \end{subfigure} \caption{Visual comparison on closeups of the Pl\'eiades dataset.} \label{f:comparison} \end{figure*} We also compare our RNN to the approach in~\cite{deeplab} (here denoted by \textsc{cnn+crf}), where a fully-connected CRF is coupled both to the input image and the coarse CNN output, in order to refine the predictions. This is the idea behind the so-called Deeplab network, which constitutes one of the most important current baselines in the semantic segmentation community. While the CRF itself could also be implemented as an RNN~\cite{crfrnn}, we here stick to the original formulation because the CRF as RNN idea is only interesting if we want to train the system end to end (i.e., together with the coarse prediction network). In our case we wish to leave the coarse network as is, otherwise we risk overfitting it to this much smaller set. We thus simply use the CRF as in~\cite{deeplab} and tune the energy parameters by performing a grid search using the enhancement set as a reference. Five iterations of inference on the fully-connected CRF were preformed in every case. To further analyze our method, we also consider an alternative enhancement RNN in which the weights of the MLP are shared across the different classes (which we denote by ``class-agnostic \textsc{cnn+rnn}''). This forces the system to learn the same function to update all the classes, instead of a class-specific function. Numerical results are included in the table of Fig.~\ref{f:quantitative}(a) and the classification maps are shown in in Fig.~\ref{f:large_results}. Close-ups of these maps are included in Fig.~\ref{f:comparison} to facilitate comparison. The CNN+CRF approach does sharpen the maps but this often occurs around the wrong edges. It also makes small objects disappear in favor of larger objects (usually the background class) when edges are not well marked, which explains the mild increase in overall accuracy but the decrease in mean IoU. While the class-agnostic CNN+RNN outperforms the CRF, both quantitative and visual results are beaten by the CNN+RNN, supporting the importance of learning a class-specific enhancement function. To validate the importance of using a recurrent architecture, and following Zheng et al.~\cite{crfrnn}, we retrained our system considering every iteration of the RNN as an independent step with its own parameters. After training for the same number of iterations, it yields a lower performance on the test set compared to the RNN and a higher performance on the training set. If we keep on training, the non-recurrent network still enhances its training accuracy while performing poorly on the test set, implying a significant degree of overfitting with this variant of the architecture. This provides evidence that constraining our network to learn an iterative enhancement process is crucial for its success. \subsection{Feature visualization} Though it is difficult to interpret the overall function learned by the RNN, especially the part of the multi-layer perceptron, there are some things we expect to find if we analyze the spatial filters $M_i$ and $N_j$ learned by the RNN (see Eq.~\ref{eq:functionals_simplified}). Carrying out this analysis is a way of validating the behavior of the network. The iterative process learned by the RNN should combine information from both the heat maps and the image at every iteration (since the heat maps constitute the prior on where the objects are located, and the image guides the enhancement of these heat maps). A logical way of enhancing the classification is to align the high-gradient areas of the heat maps with the object boundaries. We expect then to find derivative operators among the filters $N_j$ applied to the heat maps. Concerning the image filters $N_j$, we expect to find data-dependent filters (e.g.,~image edge detectors) that help identify the location of object boundaries. To interpret the meaning of the filters learned by the RNN we plot the map of responses of a sample input to the different filters. We here show some examples. Fig.~\ref{f:filters}(a) illustrates fragments of heat maps of the \emph{building} and \emph{road} classes, and the responses to two of the filters $M_i$ learned by the RNN. When analyzing these responses we can observe that they act as gradients in different directions, confirming the expected behavior. Fig.~\ref{f:filters}(b) illustrates a fragment of the color image and its response to two filters $N_j$. One of them acts as a gradient operator an the other one highlights green vegetation, suggesting that this information is used to enhance the classification maps. \begin{figure} \begin{subfigure}{\linewidth} \begin{subfigure}[t]{0.32\linewidth} \centering Heat maps \includegraphics[scale=0.17]{figs/feats/b} \vspace{1.5pt} \includegraphics[scale=0.17]{figs/feats/r} \end{subfigure} \begin{subfigure}[t]{0.65\linewidth} \centering Feature responses \begin{subfigure}{0.49\linewidth} \centering \includegraphics[scale=0.17]{figs/feats/b24} \vspace{1.5pt} \includegraphics[scale=0.17]{figs/feats/r24} {\small $M_1$} \end{subfigure} \begin{subfigure}{0.49\linewidth} \centering \includegraphics[scale=0.17]{figs/feats/b11} \vspace{1.5pt} \includegraphics[scale=0.17]{figs/feats/r11} {\small $M_2$} \end{subfigure} \end{subfigure} \caption{Filter $M_1$ acts like a gradient operator in the South-East direction and $M_2$ in the North direction (top: building, bottom: road).} \end{subfigure} \vspace{3pt} \begin{subfigure}{\linewidth} \begin{subfigure}[t]{0.32\linewidth} \centering Color image \includegraphics[scale=0.17]{figs/feats/im} \end{subfigure} \begin{subfigure}[t]{0.65\linewidth} \centering Feature responses \begin{subfigure}{0.49\linewidth} \centering \includegraphics[scale=0.17]{figs/feats/im2} {\small$N_1$} \end{subfigure} \begin{subfigure}{0.49\linewidth} \centering \includegraphics[scale=0.17]{figs/feats/im20} {\small$N_2$} \end{subfigure} \end{subfigure} \caption{$N_1$ acts like a gradient operator in the North direction and $N_2$ highlights green vegetation.} \end{subfigure} \caption{Feature responses (red: high, blue: low) to selected $M_i$ and $N_j$ filters, applied to the heat maps and input image respectively (see Eq.~\ref{eq:functionals_simplified}). } \label{f:filters} \end{figure} \section{Concluding remarks} In this work we presented an RNN that learns how to refine the coarse output of another neural network, in the context of pixelwise image labeling. The inputs are both the coarse classification maps to be corrected and the original color image. The output at every RNN iteration is an update to the classification map of the previous iteration, using the color image for guidance. Little human intervention is required, since the specifics of the refinement algorithm are not provided by the user but learned by the network itself. For this, we analyzed different iterative alternatives and devised a general formulation that can be interpreted as a stack of common neuron layers. At training time, the RNN discovers the relevant features to be taken both from the classification map and from the input image, as well as the function that combines them. The experiments on satellite imagery show that the classification maps are improved significantly, increasing the overlap of the foreground classes with the ground truth, and outperforming other approaches by a large margin. Thus, the proposed method not only detects but also outlines the objects. To conclude, we demonstrated that RNNs succeed in learning iterative processes for classification enhancement tasks. \section*{Acknowledgment} All Pl\'eiades images are \copyright CNES (2012 and 2013), distribution \mbox{Airbus}~DS / SpotImage. The authors would like to thank the CNES for initializing and funding the study, and providing Pl\'eiades data. \bibliographystyle{IEEEbib}
{'timestamp': '2017-04-24T02:04:55', 'yymm': '1608', 'arxiv_id': '1608.03440', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03440'}
arxiv
\section{Introduction} \label{sec:intro} One of the most fundamental problems in game theory is to find a Nash equilibrium of a game. Often, we are not interested in finding any Nash equilibrium, but instead we want to find one that also satisfies certain constraints. For example, we may want to find a Nash equilibrium that provides high \emph{social welfare}, which is the sum of the players' payoffs. In this paper we study such problems for \emph{bimatrix games}, which are two-player strategic-form games. Unfortunately, for bimatrix games, it is known that these problems are hard. Finding any Nash equilibrium of a bimatrix game is \ensuremath{\mathtt{PPAD}}\xspace-complete~\cite{DGP09}, while finding a constrained Nash equilibrium turns out to be even harder. Gilboa and Zemel~\cite{GZ89} studied several decision problems related to Nash equilibria. They proved that it is \ensuremath{\mathtt{NP}}\xspace-complete to decide whether there exist Nash equilibria in bimatrix games with some ``desirable'' properties, such as high social welfare. Conitzer and Sandholm~\cite{CS08} extended the list of \ensuremath{\mathtt{NP}}\xspace-complete problems of~\cite{GZ89} and furthermore proved inapproximability results for some of them. Recently, Garg et al.~\cite{GMVY} and Bilo and Mavronicolas~\cite{BM16,BM17} extended these results to many player games and provided \ensuremath{\mathtt{ETR}}\xspace-completeness results for them. \noindent \textbf{Approximate equilibria.} Due to the apparent hardness of finding exact Nash equilibria, focus has shifted to \emph{approximate} equilibria. There are two natural notions of approximate equilibrium, both of which will be studied in this paper. An \emph{$\epsilon$-approximate Nash equilibrium} ($\epsilon$-NE) requires that each player has an expected payoff that is within $\epsilon$ of their best response payoff. An \emph{$\epsilon$-well-supported Nash equilibrium} ($\epsilon$-WSNE) requires that both players only play strategies whose payoff is within $\epsilon$ of the best response payoff. Every $\epsilon$-WSNE is an $\epsilon$-NE but the converse does not hold, so a WSNE is a more restrictive notion. There has been a long line of work on finding approximate equilibria \cite{BBM10,CDFFJS,DMP07,DMP09,FGSS12,KS10,TS08}. Since we use an additive notion of approximation, it is common to rescale the game so that the payoffs lie in $[0, 1]$, which allows different algorithms to be compared. The state of the art for polynomial-time algorithms is the following. There is a polynomial-time algorithm that computes an $0.3393$-NE~\cite{TS08}, and a polynomial-time algorithm that computes a $0.6528$-WSNE~\cite{CDFFJS}. There is also a \emph{quasi-polynomial time approximation scheme} (QPTAS) for finding approximate Nash equilibria. The algorithm of Lipton, Markakis, and Mehta finds an $\epsilon$-NE in $n^{O(\frac{\log n}{\epsilon^2})}$ time~\cite{LMM03}. They proved that there is always an $\epsilon$-NE with support of logarithmic size, and then they use a brute-force search over all possible candidates to find one. We will refer to their algorithm as the LMM algorithm. A recent breakthrough of Rubinstein implies that we cannot do better than a QPTAS like the LMM algorithm~\cite{R16}: assuming an exponential time hypothesis for \ensuremath{\mathtt{PPAD}}\xspace (PETH), there is a small constant, $\ensuremath{\epsilon}\xspace^*$, such that for $\ensuremath{\epsilon}\xspace < \ensuremath{\epsilon}\xspace^*$, every algorithm for finding an \ensuremath{\epsilon}\xspace-NE requires quasi-polynomial time. Briefly, PETH is the conjecture that \textsc{EndOfTheLine}\xspace, the canonical \ensuremath{\mathtt{PPAD}}\xspace-complete problem, cannot be solved faster than exponential time. \noindent \textbf{Constrained approximate Nash equilibria.} While deciding whether a game has an exact Nash equilibrium that satisfies certain constraints is \ensuremath{\mathtt{NP}}\xspace-hard for most interesting constraints, this is not the case for approximate equilibria, because the LMM algorithm can be adapted to provide a QPTAS for them. The question then arises whether one can do better. Let the problem $\ensuremath{\epsilon}\xspace$-NE $\delta$-SW be the problem of finding an $\epsilon$-NE whose social welfare is within $\delta$ of the best social welfare that can be achieved by an $\ensuremath{\epsilon}\xspace$-NE. Hazan and Krauthgamer~\cite{HK11} and Austrin, Braverman and Chlamtac~\cite{ABC13} proved that there is a small but constant $\ensuremath{\epsilon}\xspace$ such that $\ensuremath{\epsilon}\xspace$-NE $\ensuremath{\epsilon}\xspace$-SW is at least as hard as finding a hidden clique of size $\mathrm{O}(\log n)$ in the random graph $G_{n, 1/2}$. This was further strengthened by Braverman, Ko, and Weinstein~\cite{BKW15} who showed a lower bound based on the \emph{exponential-time hypothesis} (ETH), which is the conjecture that any deterministic algorithm for 3SAT requires $2^{\mathrm{\Omega}(n)}$ time. More precisely, they showed that under ETH there is a small constant \ensuremath{\epsilon}\xspace such that any algorithm for $\mathrm{O}(\ensuremath{\epsilon}\xspace)$-NE $\mathrm{O}(\ensuremath{\epsilon}\xspace)$-SW% \footnote{While the proof in~\cite{BKW15} produces a lower bound for $0.8$-NE $(1 - \mathrm{O}(\ensuremath{\epsilon}\xspace))$-SW, this is in a game with maximum payoff $\mathrm{O}(1/\ensuremath{\epsilon}\xspace)$. Therefore, when the payoffs in this game are rescaled to $[0, 1]$, the resulting lower bound only applies to $\ensuremath{\epsilon}\xspace$-NE $\ensuremath{\epsilon}\xspace$-SW.} requires $n^{\text{poly}(\ensuremath{\epsilon}\xspace) \log(n)^{1 - o(1)}}$ time% \footnote{Although the paper claims that they obtain a $n^{\mathrm{\widetilde O}(\log n)}$ lower bound, the proof reduces from the \emph{low error} result from~\cite{AIM14} (cf. Theorem 36 in~\cite{AIM14arx}), which gives only the weaker lower bound of $n^{\text{poly}(\ensuremath{\epsilon}\xspace) \log(n)^{1 - o(1)}}$.}. We shall refer to this as the BKW result. It is worth noting that the Rubinstein's hardness result~\cite{R16} almost makes this result redundant. If one is willing to accept that PETH is true, which is a stronger conjecture than ETH, then Rubinstein's result says that for small $\ensuremath{\epsilon}\xspace$ we require quasi-polynomial time to find \emph{any} $\ensuremath{\epsilon}\xspace$-NE, which obviously implies that the same lower bound applies to $\ensuremath{\epsilon}\xspace$-NE $\delta$-SW for any $\delta$. \noindent \textbf{Our results.} Our first result is a lower bound for the problem of finding $\ensuremath{\epsilon}\xspace$-NE $\delta$-SW. We show that, assuming ETH, that there exists a small constant $\delta$ such that the problem $\left(\frac{1 - 4 g \cdot \delta}{8}\right)$-NE $\left(\frac{g \cdot \delta}{4}\right)$-SW requires $n^{\mathrm{\widetilde\Omega}( \log n)}$ time% \footnote{Here $\mathrm{\widetilde \Omega}(\log n)$ means $\mathrm{\Omega}(\frac{\log n}{(\log \log n)^c})$ for some constant $c$.}, where $g = \frac{1}{138}$ To understand this result, let us compare it to the BKW result. First, observe that as $\delta$ gets smaller, the $\ensuremath{\epsilon}\xspace$ in our $\ensuremath{\epsilon}\xspace$-NE gets larger, whereas in the BKW result, $\ensuremath{\epsilon}\xspace$ get smaller. Asymptotically, our $\ensuremath{\epsilon}\xspace$ approaches $1/8$. Moreover, since $\delta \le 1$, our lower bound applies to all $\ensuremath{\epsilon}\xspace$-NE with $\ensuremath{\epsilon}\xspace \le \frac{1 - 4g}{8} \approx 0.1214$. This is orders of magnitude larger than the inapproximability bound given by Rubinstein's hardness result, and so is not made redundant by that result. In short, our hardness result is about the hardness of obtaining good social welfare, rather than the hardness of simply finding an approximate equilibrium. Secondly, when compared to the BKW result, we obtain a slightly better lower bound. The exponent in their lower bound is logarithmic only in the limit, while ours is always logarithmic. The second set of results in this paper show that, once we have our lower bound on the problem of finding $\ensuremath{\epsilon}\xspace$-NE $\delta$-SW, we use it to prove lower bounds for other problems regarding constrained approximate NEs and WSNEs. Table~\ref{tab:problems} gives a list of the problems that we consider. For each one, we provide a reduction from $\ensuremath{\epsilon}\xspace$-NE $\delta$-SW to that problem. Ultimately, we prove that if ETH is true, then for every $\ensuremath{\epsilon}\xspace < \frac{1}{8}$ finding an $\ensuremath{\epsilon}\xspace$-NE with the given property in an $n \times n$ bimatrix game requires $n^{\mathrm{\widetilde \Omega}(\log n)}$ time. \probc{probc:largep} \probc{probc:restrictedweak} \probc{probc:difcomp} \probc{probc:maxprob} \probc{probc:smalltp} \probc{probc:smallp} \probc{probc:totalmaxsupport} \probc{probc:minmaxsupport} \probc{probc:maxsupport} \probc{probc:restricting} \renewcommand*{\arraystretch}{1.6} \setlength{\tabcolsep}{7pt} \begin{table}[htpb!] \centering \resizebox{\textwidth}{!}{ \begin{tabular}{|p{0.45\textwidth}|p{0.55\textwidth}|} \hline \textbf{Problem description} & \textbf{Problem definition} \\ \hline \hline Problem~\ref{probc:largep}: Large payoffs $u \in (0,1]$ & Is there an \ensuremath{\epsilon}\xspace-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that $\min(\ensuremath{\mathbf{x}}\xspace^TR\ensuremath{\mathbf{y}}\xspace,\ensuremath{\mathbf{x}}\xspace^TC\ensuremath{\mathbf{y}}\xspace) \geq u$?\\ \hline Problem~\ref{probc:restrictedweak}: Restricted support $S \subset [n]$ & Is there an \ensuremath{\epsilon}\xspace-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ with $\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace) \subseteq S$? \\ \hline Problem~\ref{probc:difcomp}: Two \ensuremath{\epsilon}\xspace-NE $d \in (0,1]$ apart in Total Variation (TV) distance & Are there two \ensuremath{\epsilon}\xspace-NE with TV distance $\ge d$? \\ \hline Problem~\ref{probc:maxprob}: Small largest probability $p \in (0,1)$ & Is there an \ensuremath{\epsilon}\xspace-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ with $\max_i\ensuremath{\mathbf{x}}\xspace_i \leq p$?\\ \hline Problem~\ref{probc:smalltp}: Small total payoff $v \in [0,2)$ & Is there an \ensuremath{\epsilon}\xspace-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that $\ensuremath{\mathbf{x}}\xspace^TR\ensuremath{\mathbf{y}}\xspace + \ensuremath{\mathbf{x}}\xspace^TC\ensuremath{\mathbf{y}}\xspace \leq v$? \\ \hline Problem~\ref{probc:smallp}: Small payoff $u \in [0,1)$ & Is there an \ensuremath{\epsilon}\xspace-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that $\ensuremath{\mathbf{x}}\xspace^TR\ensuremath{\mathbf{y}}\xspace \leq u$?\\ \hline Problem~\ref{probc:totalmaxsupport}: Large total support size $k \in [n]$ & Is there an \ensuremath{\epsilon}\xspace-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that $|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)| + |\mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)| \geq 2k$?\\ \hline Problem~\ref{probc:minmaxsupport}: Large smallest support size $k \in [n]$ & Is there an \ensuremath{\epsilon}\xspace-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that $\min\{|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)|, |\mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)|\} \geq k$?\\ \hline Problem~\ref{probc:maxsupport}: Large support size $k \in [n]$ & Is there an \ensuremath{\epsilon}\xspace-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that $|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)| \geq k$?\\ \hline Problem~\ref{probc:restricting}: Restricted support $S_R \subseteq [n]$ & Is there an \ensuremath{\epsilon}\xspace-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ with $S_R \subseteq \mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)$? \\ \hline \end{tabular} } \medskip \caption{The decision problems that we consider. All of them take as input a bimatrix game $(R,C)$ and a quality of approximation $\ensuremath{\epsilon}\xspace \in (0,1)$. Problems~\ref{probc:largep}~-~\ref{probc:maxprob} relate to \ensuremath{\epsilon}\xspace-NE, and Problems~\ref{probc:totalmaxsupport}~-~\ref{probc:restricting} relate to \ensuremath{\epsilon}\xspace-WSNE. } \label{tab:problems} \end{table} \paragraph{\bf Techniques} At a high level, the proof of our first result is similar in spirit to the proof of the BKW result. They reduce from the problem of approximating the value of a \emph{free game}. Aaronson, Impagliazzo, and Moshkovitz showed quasi-polynomial lower bounds for this problem assuming ETH~\cite{AIM14}. A free game is played between to players named \ensuremath{\mathrm{Merlin}_1}\xspace and \ensuremath{\mathrm{Merlin}_2}\xspace, and a referee named \ensuremath{\mathrm{Arthur}}\xspace. The BKW result creates a bimatrix game that simulates the free game, where the two players take the role of \ensuremath{\mathrm{Merlin}_1}\xspace and \ensuremath{\mathrm{Merlin}_2}\xspace, while \ensuremath{\mathrm{Arthur}}\xspace is simulated using a zero-sum game. Our result will also be proved by producing a bimatrix game that simulates a free game. However, there are a number of key differences that allow us to prove the stronger lower bounds described above. The first key difference is that we use a different zero-sum game to simulate \ensuremath{\mathrm{Arthur}}\xspace. Our zero-sum game is inspired by the one used by Feder, Nazerzadeh, and Saberi~\cite{FNS07}. The advantage of this construction is that it is capable of ensuring that play distributions that a very close to uniform in all approximate Nash equilibria, which in turn gives us a very accurate simulation of \ensuremath{\mathrm{Arthur}}\xspace. The downside of this zero-sum game is that it requires $2^n$ rows to force the column player to mix close to uniformly over $n$ rows. \ensuremath{\mathrm{Arthur}}\xspace is required to pick two \emph{questions} uniformly from a set of possible questions. The free games provided by Aaronson, Impagliazzo, and Moshkovitz have question sets of linear size, so if we reduce directly from these games, we would end up with an exponentially sized bimatrix game. The conference version of this paper~\cite{DFS16} resolved the issue by using a sub-sampling lemma, also proved by Aaronson, Impagliazzo, and Moshkovitz, that produces a free game with logarithmically sized question sets. This allowed us to produce polynomially sized bimatrix games, but at the cost of needing randomization to implement the reduction, and so the result depended on the randomized version of the ETH. In this version, we show that we are able to assume only the ETH by using a stronger result that was discovered by Babichenko, Papadimitriou, and Rubinstein~\cite{BPR16}. Their results imply that approximating the value of a free game requires quasipolynomial time even when the size of the question sets is logarithmic in the game size. They do not explicitly formulate this result, but it is clearly implied by their techniques. For the sake of completeness, we provide an exposition of their ideas in Section~\ref{sec:bpr}. The second main difference between our result and the BKW result is that we use a different starting point. The BKW result uses the PCP theorem of Moshkovitz and Raz~\cite{MR10}, which provides a completeness/soundness gap of $1$ vs $\delta$ for arbitrarily small constant $\delta$ in the label cover problem. The use of this powerful PCP theorem is necessary, as their proof relies on the large completeness/soundness gap produced by that theorem. This choice of PCP theorem directly impacts the running time lower bound that they produce, as the $(\log n)^{1 - o(1)}$ term in the exponent arises from the blowup of $n^{1 + o(1)}$ from the PCP theorem. In contrast to this, our stronger simulation of \ensuremath{\mathrm{Arthur}}\xspace allows us to use the PCP theorem of Dinur~\cite{Dinur07} as our starting point. This PCP theorem only involves a blowup of $n \polylog(n)$, which directly leads to the improved $\widetilde{\Omega}(\log n)$ exponent in our lower bound. The improved blowup of the PCP theorem comes at the cost of providing a completeness/soundness gap of only 1 vs $1 - \ensuremath{\epsilon}\xspace$ for $\ensuremath{\epsilon}\xspace < \frac{1}{8}$, but our simulation is strong enough to deal with this. It is also worth noting that if a PCP theorem with a constant completeness/soundness gap and linear blow up is devised in the future, then the exponent in our lower bound will improve to $\Omega(\log n)$. One final point of comparison is the size of the payoffs used in our simulation. The zero-sum games that we use have payoffs in the range $(-4, 4)$, which directly leads to the $\frac{1-4g\cdot \delta}{8}$ bound on the quality of approximation. In contrast to this, the zero-sum games used by the BKW result have payoffs of size $O(\frac{1}{\ensuremath{\epsilon}\xspace})$, which ultimately means that their lower bound only applies to the problem $\ensuremath{\epsilon}\xspace$-NE $\ensuremath{\epsilon}\xspace$-SW. \paragraph{\bf Other related work} The only positive result for finding $\ensuremath{\epsilon}\xspace$-NE with good social welfare that we are aware of was given by Czumaj, Fasoulakis, and Jurdzi\'nski~\cite{CFJ15,CFJ16}. In~\cite{CFJ15}, they showed that if there is a polynomial-time algorithm for finding an $\ensuremath{\epsilon}\xspace$-NE, then for all $\ensuremath{\epsilon}\xspace' > \ensuremath{\epsilon}\xspace$ there is also a polynomial-time algorithm for finding an $\ensuremath{\epsilon}\xspace'$-NE that is within a constant multiplicative approximation of the best social welfare. They also give further results for the case where $\ensuremath{\epsilon}\xspace > \frac{1}{2}$. In~\cite{CFJ16} they derived polynomial-time algorithms that compute \ensuremath{\epsilon}\xspace-NE for $\ensuremath{\epsilon}\xspace \geq \frac{3-\sqrt{5}}{2}$ that approximate the quality of plutocratic and egalitarian Nash equilibria to various degrees. \section{Preliminaries} \label{sec:pre} Throughout the paper, we use $[n]$ to denote the set of integers $\{1, 2, \dots, n\}$. An $n \times n$ bimatrix game is a pair $(R,C)$ of two $n \times n$ matrices: $R$ gives payoffs for the \emph{row} player and $C$ gives the payoffs for the \emph{column} player. Each player has $n$ \emph{pure} strategies. To play the game, both players simultaneously select a pure strategy: the row player selects a row $i \in [n]$, and the column player selects a column $j \in [n]$. The row player then receives payoff $R_{i,j}$, and the column player receives payoff $C_{i,j}$. A \emph{mixed strategy} is a probability distribution over $[n]$. We denote a mixed strategy for the row player as a vector \ensuremath{\mathbf{x}}\xspace of length $n$, such that $\ensuremath{\mathbf{x}}\xspace_i$ is the probability that the row player assigns to pure strategy $i$. A mixed strategy of the column player is a vector \ensuremath{\mathbf{y}}\xspace of length $n$, with the same interpretation. If \ensuremath{\mathbf{x}}\xspace and~\ensuremath{\mathbf{y}}\xspace are mixed strategies for the row and the column player, respectively, then we call $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ a \emph{mixed strategy profile}. The expected payoff for the row player under strategy profile $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is given by $\ensuremath{\mathbf{x}}\xspace^T R \ensuremath{\mathbf{y}}\xspace$ and for the column player by $\ensuremath{\mathbf{x}}\xspace^T C \ensuremath{\mathbf{y}}\xspace$. We denote the \emph{support} of a strategy $\ensuremath{\mathbf{x}}\xspace$ as $\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)$, which gives the set of pure strategies~$i$ such that $\ensuremath{\mathbf{x}}\xspace_i > 0$. \paragraph{\bf Nash equilibria} Let $\ensuremath{\mathbf{y}}\xspace$ be a mixed strategy for the column player. The set of \emph{pure best responses} against $\ensuremath{\mathbf{y}}\xspace$ for the row player is the set of pure strategies that maximize the payoff against $\ensuremath{\mathbf{y}}\xspace$. More formally, a pure strategy $i \in [n]$ is a best response against $\ensuremath{\mathbf{y}}\xspace$ if, for all pure strategies $i' \in [n]$ we have: $\sum_{j \in \protect [n]} \ensuremath{\mathbf{y}}\xspace_j \cdot R_{i, j} \ge \sum_{j \in \protect [n]} \ensuremath{\mathbf{y}}\xspace_j \cdot R_{i', j}$. Column player best responses are defined analogously. A mixed strategy profile $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is a \emph{mixed Nash equilibrium} if every pure strategy in $\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)$ is a best response against~$\ensuremath{\mathbf{y}}\xspace$, and every pure strategy in $\mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)$ is a best response against~$\ensuremath{\mathbf{x}}\xspace$. Nash~\cite{N51} showed that every bimatrix game has a mixed Nash equilibrium. Observe that in a Nash equilibrium, each player's expected payoff is equal to their best response payoff. \paragraph{\bf Approximate Equilibria} There are two commonly studied notions of approximate equilibrium, and we consider both of them in this paper. The first notion is that of an \emph{$\epsilon$-approximate Nash equilibrium} ($\epsilon$-NE), which weakens the requirement that a player's expected payoff should be equal to their best response payoff. Formally, given a strategy profile $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$, we define the \emph{regret} suffered by the row player to be the difference between the best response payoff and the actual payoff: $\max_{i\in [n]} \big((R\cdot y)_i\big) - \ensuremath{\mathbf{x}}\xspace^T \cdot R \cdot \ensuremath{\mathbf{y}}\xspace.$ Regret for the column player is defined analogously. We have that $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is an $\epsilon$-NE if and only if both players have regret less than or equal to $\epsilon$. The other notion is that of an $\epsilon$-approximate-well-supported equilibrium ($\epsilon$-WSNE), which weakens the requirement that players only place probability on best response strategies. We say that a pure strategy $j \in [n]$ of the row player is an $\epsilon$-best-response against $\ensuremath{\mathbf{y}}\xspace$ if: \begin{equation*} \max_{i \in [n]}\big((R\cdot y)_i\big) - (R\cdot y)_j \le \epsilon. \end{equation*} An $\epsilon$-WSNE requires that both players only place probability on $\epsilon$-best-responses. Formally, the row player's \emph{pure strategy regret} under $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is defined to be: $\max_{i \in [n]}\big((R\cdot y)_i\big) - \min_{i \in \mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)}\big((R\cdot y)_i\big).$ Pure strategy regret for the column player is defined analogously. A strategy profile $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is an $\epsilon$-WSNE if both players have pure strategy regret less than or equal to $\epsilon$. Since approximate Nash equilibria use an additive notion of approximation, it is standard practice to rescale the input game so that all payoffs lie in the range $[0, 1]$, which allows us to compare different results on this topic. For the most part, we follow this convention. However, for our result in Section~\ref{sec:bday}, we will construct a game whose payoffs do not lie in $[0,1]$. In order to simplify the proof, we will prove results about approximate Nash equilibria in the unscaled game, and then rescale the game to $[0, 1]$ at the very end. To avoid confusion, we will refer to an $\ensuremath{\epsilon}\xspace$-approximate Nash equilibrium in this game as an $\ensuremath{\epsilon}\xspace$-UNE, to mark that it is an additive approximation in an unscaled game. \paragraph{\bf Two-prover games} A two-prover game is defined as follows. \begin{definition}[Two-prover game] A two-prover game $\mathcal{T}$ is defined by a tuple $(X, Y, A, B, \mathcal{D}, V)$ where $X$ and $Y$ are finite sets of \emph{questions}, $A$ and $B$ are finite sets of \emph{answers}, \ensuremath{\mathcal{D}}\xspace is a probability distribution defined over $X \times Y$, and $V$ is a \emph{verification function} of the form $V: X \times Y \times A \times B \rightarrow \{0,1\}$. \end{definition} The game is a co-operative and played between two players, who are called \ensuremath{\mathrm{Merlin}_1}\xspace and \ensuremath{\mathrm{Merlin}_2}\xspace, and an adjudicator called \ensuremath{\mathrm{Arthur}}\xspace. At the start of the game, \ensuremath{\mathrm{Arthur}}\xspace chooses a question pair $(x,y) \in X \times Y$ randomly according to~$\ensuremath{\mathcal{D}}\xspace$. He then sends $x$ to \ensuremath{\mathrm{Merlin}_1}\xspace and $y$ to $\ensuremath{\mathrm{Merlin}_2}\xspace$. Crucially, \ensuremath{\mathrm{Merlin}_1}\xspace does not know the question sent to \ensuremath{\mathrm{Merlin}_2}\xspace and vice versa. Having received $x$, \ensuremath{\mathrm{Merlin}_1}\xspace then chooses an answer from $A$ and sends it back to \ensuremath{\mathrm{Arthur}}\xspace. \ensuremath{\mathrm{Merlin}_2}\xspace similarly picks an answer from $B$ and returns it to \ensuremath{\mathrm{Arthur}}\xspace. \ensuremath{\mathrm{Arthur}}\xspace then computes $p = V(x, y, a, b)$ and awards payoff $p$ to both players. The size of the game, denoted $|\mathcal{T}| = | X \times Y \times A \times B|$ is the total number of entries needed to represent $V$ as a table. A \emph{strategy} for \ensuremath{\mathrm{Merlin}_1}\xspace is a function $a: X \rightarrow A$ that gives an answer for every possible question, and likewise a strategy for \ensuremath{\mathrm{Merlin}_2}\xspace is a function $b: Y \rightarrow B$. We define $S_i$ to be the set of all strategies for \ensuremath{\mathrm{Merlin}_i}\xspace. The \emph{payoff} of the game under a pair of strategies $(s_1, s_2) \in S_1 \times S_2$ is denoted as \begin{equation*} p(\mathcal{T}, s_1, s_2) = E_{(x,y) \sim \ensuremath{\mathcal{D}}\xspace}[V(x, y, s_1(x), s_2(y))]. \end{equation*} The \emph{value} of the game, denoted $\omega(\ensuremath{\mathcal{T}}\xspace)$, is the maximum expected payoff to the Merlins when they play optimally: \begin{equation*} \omega(\mathcal{T}) = \max_{s_1 \in S_1} \max_{s_2 \in S_2} p(\mathcal{T}, s_1, s_2). \end{equation*} \paragraph{\bf Free games} A two-prover game is called a \emph{free game} if the probability distribution~\ensuremath{\mathcal{D}}\xspace is the uniform distribution \ensuremath{\mathcal{U}}\xspace over $X \times Y$. In particular, this means that there is no correlation between the question sent to \ensuremath{\mathrm{Merlin}_1}\xspace and the question sent to \ensuremath{\mathrm{Merlin}_2}\xspace. We are interested in the problem of approximating the value of a free game within an additive error of $\delta$. \bigskip \begin{tcolorbox}[title=\ensuremath{\textsc{FreeGame}_\delta}\xspace] Input: A free game $\mathcal{T}$ and a constant $\delta > 0$. \medskip Output: A value $p$ such that $| \; \omega(\ensuremath{\mathcal{T}}\xspace) - p \; | \le \delta$. \end{tcolorbox} \section{Hardness of approximating free games} \label{sec:bpr} The \emph{exponential time hypothesis (ETH)} is the conjecture that any deterministic algorithm for solving 3SAT requires $2^{\mathrm{\Omega}(n)}$ time. Aaronson, Impagliazzo, and Moshkovitz have shown that, if ETH holds, then there exists a small constant $\ensuremath{\epsilon}\xspace > 0$ such that approximating the value of a free game within an additive error of $\ensuremath{\epsilon}\xspace$ requires quasi-polynomial time. However, their result is not suitable for our purposes, because it produces a free game in which the question and answer sets have the same size, and to prove our result, we will require that the question sets have logarithmic size when compared to the answer sets. The conference version of this paper~\cite{DFS16} solved this issue by using a sub-sampling lemma, also proved by Aaronson, Impagliazzo, and Moshkovitz, which shows that if we randomly choose logarithmically many questions from the original game, the value of the resulting sub-game is close the value of the original. However, this comes at the cost of needing randomness in the reduction, and so our result depended on the truth of the \emph{randomized} ETH, which is a stronger conjecture. In this exposition, we will instead use a technique of Babichenko, Papadimitriou, and Rubinstein~\cite{BPR16}, which allows us to produce a free game with a logarithmic size question set in a deterministic way. The result that we need is a clear consequence of their ideas, but is not explicitly formulated in their paper. For the sake of completeness, in the rest of this section we provide our own exposition of their ideas. \paragraph{\bf The PCP theorem} The starting point of the result will be a 3SAT instance~$\phi$. We say that the size of a formula~$\phi$ is the number of variables and clauses in the formula. We define $\textsc{3Sat}\xspace(\phi) \in [0, 1]$ to be the maximum fraction of clauses that can be satisfied in $\phi$. The first step is to apply a PCP theorem. \begin{theorem}[Dinur's PCP Theorem~\cite{Dinur07}] \label{thm:dinur} Given any 3SAT instance $\phi$ of size $n$, and a constant $\epsilon$ in the range $0 < \epsilon < \frac{1}{8}$, we can produce in polynomial time a 3SAT instance $\psi$ where: \begin{itemize} \item The size of $\psi$ is $n \cdot \polylog(n)$. \item Every clause of $\psi$ contains exactly 3 variables and every variable is contained in at most $d$ clauses, where $d$ is a constant. \item If $\textsc{3Sat}\xspace(\phi) = 1$, then $\textsc{3Sat}\xspace(\psi) = 1$. \item If $\textsc{3Sat}\xspace(\phi) < 1$, then $\textsc{3Sat}\xspace(\psi) < 1 - \epsilon$. \end{itemize} \end{theorem} After applying the PCP theorem given above, we then directly construct a free game. Observe that a 3SAT formula can be viewed as a bipartite graph in which the vertices are variables and clauses, and there is an edge between a variable $x_i$ and a clause $C_j$ if and only if $x_i$ is appears in $C_j$. In particular, the 3SAT formulas produced by Theorem~\ref{thm:dinur} correspond to bipartite graphs with constant degree, since each clause has degree at most 3, and each variable has degree at most $d$. The first step is to apply the following lemma, which allows us to partition the vertices of this bipartite graph. The lemma and proof are essentially identical to~\cite[Lemma 6]{BPR16}, although we generalise the formulation slightly, because the original lemma requires that the two sides of the graph have exactly the same number of nodes and that the graph is $d$-regular. \begin{lemma}[\cite{BPR16}] \label{lem:split} Let $(V, E)$ be a bipartite graph with $|V| = n$, where $V = U \cup W$ are the two sides of the graph, and where each node has degree at most $d$. Suppose that $U$ and $W$ both have a constant fraction of the vertices, and hence $|U| = c_1 \cdot n$ and $|W| = c_2 = (1-c_1) \cdot n$ for some constants $c_1 < 1$ and $c_2 < 1$. We can efficiently find a partition $S_1, S_2, \dots, S_{\sqrt n}$ of $U$ and a partition $T_1, T_2, \dots, T_{\sqrt n}$ of $W$ such that each set has size at most $2 \sqrt n$, and for all $i$ and~$j$ we have \begin{equation*} |(S_i \times T_j) \cap E| \le 2 d^2. \end{equation*} \end{lemma} \begin{proof} The algorithm is as follows. First we arbitrarily split $U$ into $\sqrt n$ many sets $S_1, S_2, \dots, S_{\sqrt n}$, and so each set $S_i$ has size $c_1 \sqrt n < 2 \sqrt n$. Then we iteratively construct the partition of $W$ into sets $T_1, T_2, \dots, T_{\sqrt n}$ in the following way. We initialize each set $T_j$ to be the empty set. In each iteration, we pick a vertex of $w \in W$ that has not already been assigned to a set. We find a set $T_j$ such that $|T_j| \le 2 \cdot \sqrt{n}$, and such that for all $i$ we have $|(S_i \times T_j) \cap E| \le 2 \cdot d^2$. We assign $w$ to $T_j$ and repeat. Obviously, for the algorithm to be correct, we must prove that for each vertex $w$ that is considered, there does exist a set $T_j$ that satisfies the required constraints. For this, we rely on the following two properties. \begin{itemize} \item The average number of vertices in a set $T_j$ is at most $c_2 \sqrt n < \sqrt n$, and so by Markov's inequality strictly less than half the sets can have size more than $2 \sqrt n$, and so we lose strictly less than half the sets $T_j$ to the size constraint. \item Since each vertex has degree at most $d$, the graph has at most $dn$ edges, and so the average number of edges between each pair of sets $S_i$ and $T_j$ is $dn/(\sqrt{n} \cdot \sqrt{n}) = d$. Again, using Markov's inequality we can conclude that there are at most $1/2d$ pairs of sets $S_i$ and $T_j$ that have more than $2d^2$ edges between them. Hence, even in the worst case, we can lose at most $1/2d$ sets $T_j$ to the edge constraints. \end{itemize} So, we lose strictly less than half the sets to the size constraints, and $1/2d \le 1/2$ the sets to the edge constraints. Hence, by the union bound, we have shown that there is at least one set $T_j$ that satisfies both constraints simultaneously. \qed \end{proof} \paragraph{\bf A free game} Note that Lemma~\ref{lem:split} can be applied to the 3SAT formula that arises from Dinur's PCP theorem, because the number of variables and number of constraints are both a constant fraction of the number of nodes in the associated bipartite graph, and because each vertex has either has degree $d$ or degree $3$. We use this to construct the following free game, which is highly reminiscent of the clause variable game given by Aaronson, Impagliazzo, and Moshkovitz~\cite{AIM14}. \begin{definition} Given a 3SAT formula $\phi$ of size $n$, we define a free game $\mathcal{F}_\phi$ in the following way. \begin{enumerate} \item \ensuremath{\mathrm{Arthur}}\xspace begins by applying Dinur's PCP theorem to $\phi$ to obtain a formula $\psi$ of size $N = n \polylog(n)$, and then uses Lemma~\ref{lem:split} to split the variables of $\psi$ into sets $S_1, S_2, \dots, S_{\sqrt{n}}$ and the clauses of $\psi$ into sets $T_1, T_2, \dots, T_{\sqrt{N}}$. \item \ensuremath{\mathrm{Arthur}}\xspace picks an index $i$ uniformly at random from $[\sqrt{N}]$, and independently an index $j$ uniformly at random from $[\sqrt{N}]$. He sends $S_i$ to \ensuremath{\mathrm{Merlin}_1}\xspace and $T_j$ to \ensuremath{\mathrm{Merlin}_2}\xspace. \item \ensuremath{\mathrm{Merlin}_1}\xspace responds by giving a truth assignment to every variable in $S_i$, and \ensuremath{\mathrm{Merlin}_2}\xspace responds by giving a truth assignment to every variable that is involved with a clause in $T_j$. \item \ensuremath{\mathrm{Arthur}}\xspace awards the Merlins payoff $1$ if and only if both of the following conditions hold. \begin{itemize} \item \ensuremath{\mathrm{Merlin}_2}\xspace returns an assignment that satisfies all clauses in $T_j$. \item For every variable $v$ that appears in $S_i$ and some clause of $T_j$, the assignment to $v$ given by $\ensuremath{\mathrm{Merlin}_1}\xspace$ agrees with the assignment to $v$ given by $\ensuremath{\mathrm{Merlin}_2}\xspace$. Note that this condition is always satisfied when $S_i$ and $T_j$ share no variables. \end{itemize} \ensuremath{\mathrm{Arthur}}\xspace awards payoff $0$ otherwise. \end{enumerate} \end{definition} If $n$ is the size of $\phi$, then when we write $\mathcal{F}_\phi$ down as a free game $(X, Y, A, B, \mathcal{D}, V)$, the number of questions in the sets $X$ and $Y$ is $\sqrt{n \polylog(n)}$, and the number of answers in $A$ and $B$ is $2^{2\sqrt{n \polylog(n)}}$, where the extra $\polylog(n)$ factor arises due to the application of the PCP theorem. The following lemma shows that if $\phi$ is unsatisfiable, then the value of this free game is bounded away from $1$. Again, the ideas used to prove this lemma are clearly evident in the work of Babichenko, Papadimitriou, and Rubinstein~\cite{BPR16}. \begin{lemma}[\cite{BPR16}] \label{lem:csgap} If $\phi$ is satisfiable then $\omega(\mathcal{F}_\phi) = 1$. If $\phi$ is unsatisfiable then $\omega(\mathcal{F}_\phi) \le 1 - \ensuremath{\epsilon}\xspace/2d$. \end{lemma} \begin{proof} The case where $\textsc{3Sat}\xspace(\phi) = 1$ is straightforward. Since there exists a satisfying assignment for $\phi$, there also exists a satisfying assignment for $\psi$. If the two Merlins play according to this satisfying assignment, then they obviously achieve an expected payoff of $1$. For the other claim, first observe that we can assume that both Merlins play deterministic strategies, since the game is co-operative, and therefore nothing can be gained through randomization. So, let $s_1$ be a strategy for \ensuremath{\mathrm{Merlin}_1}\xspace. Observe that since $S_1, S_2, \dots, S_{\sqrt{N}}$ partition the variables of $\psi$, we have that $s_1$ yields an assignment to the variables of $\psi$. Let us fix an arbitrary deterministic strategy $s_1$ for \ensuremath{\mathrm{Merlin}_1}\xspace. We have that the payoff to \ensuremath{\mathrm{Merlin}_2}\xspace for an individual question $T_j$ can be computed as follows: \begin{itemize} \item For every set $S_i$ for which there are no edges between the variables in $S_i$ and $T_j$, \ensuremath{\mathrm{Merlin}_2}\xspace gets payoff $1$ ``for free.'' \item Otherwise, \ensuremath{\mathrm{Merlin}_2}\xspace gets payoff $1$ only if the assignments to the clauses agree with the assignment implied by $s_1$. \end{itemize} From this, we can see that when \ensuremath{\mathrm{Merlin}_1}\xspace plays $s_1$, \ensuremath{\mathrm{Merlin}_2}\xspace can maximize his payoff by playing the strategy that agrees everywhere with the assignment chosen by \ensuremath{\mathrm{Merlin}_1}\xspace. So let $s_2$ denote this strategy. Since $\phi$ is unsatisfiable, the PCP theorem tells us that $\textsc{3Sat}\xspace(\psi) < 1 - \ensuremath{\epsilon}\xspace$. Thus, there are at least $\ensuremath{\epsilon}\xspace d N$ clauses that are not satisfied when $s_1$ is played against $s_2$. Since Lemma~\ref{lem:split} ensures that the maximum number of edges between two sets is $2d^2$, there must therefore be at least $\ensuremath{\epsilon}\xspace dN/2d^2 = \ensuremath{\epsilon}\xspace N/2d$ pairs of sets that give payoff $0$ to the Merlins under $s_1$ and $s_2$. Since there are exactly $N$ pairs of sets in total, this means that the expected payoff to the Merlins is bounded by $1 - \ensuremath{\epsilon}\xspace/2d$. \qed \end{proof} Finally, we can formulate the lower bound that we will use in this paper. The proof is the same as the one given in~\cite{AIM14}, but we use the free game $\mathcal{F}_\phi$, rather than the construction originally given in that paper. \begin{theorem}[\cite{BPR16}] \label{thm:qplower} Assuming ETH, there is a small constant $\delta$ below which the problem \ensuremath{\textsc{FreeGame}_\delta}\xspace cannot be solved faster than $N^{\mathrm{\widetilde O}(\log N)}$, even when the question sets have size $\log N$. \end{theorem} \begin{proof} Lemma~\ref{lem:csgap} implies that if we can approximate the value of $\mathcal{F}_\phi$ with an additive error of less than $\ensuremath{\epsilon}\xspace/2d$, then we can solve the satisfiability problem for~$\phi$. Assume, for the sake of contradiction, that there exists an algorithm that can solve the \ensuremath{\textsc{FreeGame}_\delta}\xspace problem in time $N^{o\left(\frac{\log N}{(\log \log N)^c}\right)}$ for some constant $c$ that will be fixed later. Observe that the free game~$\mathcal{F}_\phi$ has size $N = O(2^{\sqrt{n \polylog(n)}})$, and so the hypothesized algorithm would run in time: \begin{align*} & \exp\left( o \left( \frac{ \log^2 N } {(\log\log(N))^c} \right) \right) = \exp\left( o \left( \frac{ n \polylog(n) } {(\log( \sqrt{n} \polylog(n)))^c} \right) \right). \end{align*} If we set $c$ to be greater than the degree of the polynomial in the $\polylog(n)$ from the numerator, then we can conclude that the running time would be $2^{o(n)}$, which would violate the ETH. \qed \end{proof} \section{Hardness of approximating social welfare} \label{sec:bday} \paragraph{\bf Overview} In this section, we study the following \emph{social welfare} problem for a bimatrix game $\ensuremath{\mathcal{G}}\xspace = (R,C)$. The \emph{social welfare} of a strategy profile $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is denoted by $\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ and is defined to be $\ensuremath{\mathbf{x}}\xspace^TR\ensuremath{\mathbf{y}}\xspace + \ensuremath{\mathbf{x}}\xspace^TC\ensuremath{\mathbf{y}}\xspace$. Given an $\ensuremath{\epsilon}\xspace \ge 0$, we define the set of all $\ensuremath{\epsilon}\xspace$ equilibria as \begin{equation*} \ensuremath{E^{\eps}}\xspace = \{(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) \; : \; (\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) \text{ is an } \ensuremath{\epsilon}\xspace\text{-NE}\}. \end{equation*} Then, we define the \emph{best social welfare} achievable by an $\ensuremath{\epsilon}\xspace$-NE in $\mathcal{G}$ as \begin{equation*} \bsw(\ensuremath{\mathcal{G}}\xspace, \ensuremath{\epsilon}\xspace) = \max\{\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) \; : \; (\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) \in \ensuremath{E^{\eps}}\xspace\}. \end{equation*} Using these definitions we now define the main problem that we consider: \bigskip \begin{tcolorbox}[title=$\ensuremath{\epsilon}\xspace$-NE $\delta$-SW] Input: A bimatrix game $\mathcal{G}$, and two constants $\ensuremath{\epsilon}\xspace, \delta > 0$. \smallskip Output: An $\ensuremath{\epsilon}\xspace$-NE $(\ensuremath{\mathbf{x}}\xspace,\ensuremath{\mathbf{y}}\xspace)$ s.t. $\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is within $\delta$ of $\bsw(\ensuremath{\mathcal{G}}\xspace, \ensuremath{\epsilon}\xspace)$. \end{tcolorbox} \noindent We show a lower bound for this problem by reducing from \ensuremath{\textsc{FreeGame}_\delta}\xspace. Let~$\mathcal{F}$ be a free game of size $n$ from the family of free games that were used to prove Theorem~\ref{thm:qplower} (from now on we will drop the subscript $\phi$, since the exact construction of $\mathcal{F}$ is not relevant to us.) We have that either $\omega(\mathcal{F}) = 1$ or $\omega(\mathcal{F}) < 1 - \delta$ for some fixed constant $\delta$, and that it is hard to determine which of these is the case. We will construct a game $\mathcal{G}$ such that for $\ensuremath{\epsilon}\xspace = 1 - 4g \cdot \delta$, where $g < \frac{5}{12}$ is a fixed constant that we will define at the end of the proof, we have the following properties. \begin{itemize} \item (\textbf{Completeness}) If $\omega(\mathcal{F}) = 1$, then the unscaled $\bsw(\mathcal{G}, \ensuremath{\epsilon}\xspace) = 2$. \item (\textbf{Soundness}) If $\omega(\mathcal{F}) < 1 - \delta$, then the unscaled $\bsw(\mathcal{G}, \ensuremath{\epsilon}\xspace) < 2(1 - g \cdot \delta)$. \end{itemize} This will allow us to prove our lower bound using Theorem~\ref{thm:qplower}. \subsection{The construction} We use $\ensuremath{\mathcal{F}}\xspace$ to construct a bimatrix game, which we will denote as $\mathcal{G}$ throughout the rest of this section. The game is built out of four subgames, which are arranged and defined as follows. \begin{center} {\small \bimatrixgame{3.5mm}{2}{2}{I}{II}% {{ }{ }}% {{ }{ }}% { \payoffpairs{1}{{$R$}{$-D_2$}}{{$C$}{$D_2$}} \payoffpairs{2}{{$D_1$}{$0$}}{{$-D_1$}{$0$}} } } \end{center} \begin{itemize} \item The game $(R, C)$ is built from $\ensuremath{\mathcal{F}}\xspace$ in the following way. Each row of the game corresponds to a pair $(x,a) \in X \times A$ and each column corresponds to a pair $(y,b) \in Y \times B$. Since all free games are cooperative, the payoff for each strategy pair $(x,a),(y,b)$ is defined to be $R_{(x,a),(y,b)} = C_{(x,a),(y,b)} = V(x, y, a(x), b(y)).$ \item The game $(D_1, -D_1)$ is a zero-sum game. The game is a slightly modified version of a game devised by Feder, Nazerzadeh, and Saberi~\cite{FNS07}. Let $H$ be the set of all functions of the form $f : Y \rightarrow \{0, 1\}$ such that $f(y) = 1$ for exactly half% \footnote{If $|Y|$ is not even, then we can create a new free game in which each question in $|Y|$ appears twice. This will not change the value of the free game.} of the elements $y \in Y$. The game has $|Y \times B|$ columns and $|H|$ rows. For all $f \in H$ and all $(y, b) \in Y$ the payoffs are \begin{equation*} \left(D_1\right)_{f, (y, b)} = \begin{cases} \frac{4}{1 + 4g \cdot \delta} & \text{if $f(y) = 1$,} \\ 0 & \text{otherwise.} \end{cases} \end{equation*} \item The game $(-D_2, D_2)$ is built in the same way as the game $(D_1, -D_1)$, but with the roles of the players swapped. That is, each column of $(-D_2, D_2)$ corresponds to a function that picks half of the elements of $X$. \item The game $(0, 0)$ is a game in which both players have zero matrices. \end{itemize} Observe that the size of $(R, C)$ is the same as the size of $\mathcal{F}$. The game $(D_1, -D_1)$ has the same number of columns as~$C$, and the number of rows is at most $2^{|Y|} \le 2^{ O(\log |\mathcal{F}|)} = |\mathcal{F}|^{O(1)}$, where we are crucially using the fact that Theorem~\ref{thm:qplower} allows us to assume that the size of $Y$ is $O(\log |\mathcal{F}|)$. By the same reasoning, the number of columns in $(-D_2, D_2)$ is at most $|\mathcal{F}|^{O(1)}$. Thus, the size of $\mathcal{G}$ is $|\mathcal{F}|^{O(1)}$, and so this reduction is polynomial. \subsection{Completeness} To prove completeness, it suffices to show that, if $\omega(\ensuremath{\mathcal{F}}\xspace) = 1$, then there exists a $(1 - 4g \cdot \delta)$-UNE of $\mathcal{G}$ that has social welfare $2$. To do this, assume that~$\omega(\ensuremath{\mathcal{F}}\xspace) = 1$, and take a pair of optimal strategies $(s_1, s_2)$ for $\ensuremath{\mathcal{F}}\xspace$ and turn them into strategies for the players in~$\mathcal{G}$. More precisely, the row player will place probability $\frac{1}{|X|}$ on each answer chosen by $s_1$, and the column player will place probability $\frac{1}{|Y|}$ on each answer chosen by $s_2$. By construction, this gives both players payoff $1$, and hence the social welfare is $2$. The harder part is to show that this is an approximate equilibrium, and in particular, that neither player can gain by playing a strategy in $(D_1, -D_1)$ or $(-D_2, D_2)$. We prove this in the following lemma. \begin{lemma} \label{lem:complete} If $\omega(\ensuremath{\mathcal{F}}\xspace) = 1$, then there exists a $(1 - 4g \cdot \delta)$-UNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ of $\mathcal{G}$ with $\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) = 2$. \end{lemma} \begin{proof} Let $(s_1, s_2) \in S_1 \times S_2$ be a pair of optimal strategies for \ensuremath{\mathrm{Merlin}_1}\xspace and \ensuremath{\mathrm{Merlin}_2}\xspace in \ensuremath{\mathcal{F}}\xspace. For each $(x, a) \in X \times A$ and each $(y, b) \in Y \times B$, we define \begin{align*} \ensuremath{\mathbf{x}}\xspace(x, a) = \begin{cases} \frac{1}{|X|} & \text{if $s_1(x) = a$.} \\ 0 & \text{otherwise.} \end{cases} && \ensuremath{\mathbf{y}}\xspace(y, b) = \begin{cases} \frac{1}{|Y|} & \text{if $s_2(y) = b$.} \\ 0 & \text{otherwise.} \end{cases} \end{align*} Clearly, by construction, we have that the payoff to the row player under $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is equal to $p(\ensuremath{\mathcal{F}}\xspace, s_1, s_2) = 1$, and therefore $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ has social welfare~$2$. On the other hand, we must prove that $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is a $(1-4g\cdot\delta)$-UNE. To do so, we will show that neither player has a deviation that increases their payoff by more than $(1-4g\cdot\delta)$. We will show this for the row player; the proof for the column player is symmetric. There are two types of row to consider. \begin{itemize} \item First suppose that $r$ is a row in the sub-game $(R, C)$. We claim that the payoff of $r$ is at most $1$. This is because the maximum payoff in $R$ is~$1$, while the maximum payoff in $-D_2$ is $0$. Since the row player already obtains payoff $1$ in $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$, row $r$ cannot be a profitable deviation. \item Next suppose that $r$ is a row in the sub-game $(D_1, -D_1)$. Since we have $\sum_{b \in B} \ensuremath{\mathbf{y}}\xspace(y, b) = \frac{1}{|Y|}$ for every question $y$, we have that all rows in~$D_1$ have the same payoff. This payoff is \begin{equation*} \frac{1}{2} \cdot \left( \frac{4}{1 + 4\cdot \delta} \right) = \frac{2}{1 + 4g\cdot \delta} = 2 - \frac{8g \cdot \delta}{1 + 4g \cdot \delta}\ . \end{equation*} Since $\delta \le 1$ and $g \le \frac{1}{4}$ we have \begin{equation*} \frac{8}{1 + 4g \cdot \delta} \ge \frac{8}{1 + 4g} \ge 4\ . \end{equation*} Thus, we have shown that the payoff of $r$ is at most $2 - 4 g \cdot \delta$. Thus the row player's regret is at most $1 - 4g \cdot \delta$. \qed \end{itemize} \end{proof} \subsection{Soundness} We now suppose that $\omega(\ensuremath{\mathcal{F}}\xspace) < 1 - \delta/2$, and we will prove that all $(1 - 4g \cdot \delta)$-UNE provide social welfare at most $2 - 2g \cdot \delta$. Throughout this subsection, we will fix $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ to be a $(1 - 4g \cdot \delta)$-UNE of $\mathcal{G}$. We begin by making a simple observation about the amount of probability that is placed on the subgame $(R, C)$. \begin{lemma} \label{lem:problp} If $\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) > 2 - 2g \cdot \delta$, then \begin{itemize} \item $\ensuremath{\mathbf{x}}\xspace$ places at least $(1 - g \cdot \delta)$ probability on rows in $(R, C)$, and \item $\ensuremath{\mathbf{y}}\xspace$ places at least $(1 - g \cdot \delta)$ probability on columns in~$(R, C)$. \end{itemize} \end{lemma} \begin{proof} We will prove the lemma for $\ensuremath{\mathbf{x}}\xspace$; the proof for $\ensuremath{\mathbf{y}}\xspace$ is entirely symmetric. For the sake of contradiction, suppose that $\ensuremath{\mathbf{x}}\xspace$ places strictly less than $(1 - g \cdot \delta)$ probability on rows in $(R, C)$. Observe that every subgame of $\mathcal{G}$ other than $(R, C)$ is a zero-sum game. Thus, any probability assigned to these sub-games contributes nothing to the social welfare. On the other hand, the payoffs in $(R, C)$ are at most $1$. So, even if the column player places all probability on columns in $C$, the social welfare $\sw(\ensuremath{\mathbf{x}}\xspace,\ensuremath{\mathbf{y}}\xspace)$ will be strictly less than $2 \cdot (1 - g \cdot \delta) + g \cdot \delta \cdot 0 = 2 - 2 g \cdot \delta$, a contradiction. \qed \end{proof} So, for the rest of this subsection, we can assume that both $\ensuremath{\mathbf{x}}\xspace$ and~$\ensuremath{\mathbf{y}}\xspace$ place at least $1 - g \cdot \delta$ probability on the subgame $(R, C)$. We will ultimately show that, if this is the case, then both players have payoff at most $1 - \frac{1}{2} \cdot \delta + m g \cdot \delta$ for some constant $m$ that will be derived during the proof. Choosing $g = 1/(2m + 2)$ then ensures that both players have payoff at most $1 - g \cdot \delta$, and therefore that the social welfare is at most $2 - 2g \cdot \delta$. \paragraph{\bf A two-prover game} We use $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ to create a two-prover game. First, we define two distributions that capture the marginal probability that a question is played by $\ensuremath{\mathbf{x}}\xspace$ or $\ensuremath{\mathbf{y}}\xspace$. Formally, we define a distribution $\ensuremath{\mathbf{x}}\xspace'$ over $X$ and a distribution $\ensuremath{\mathbf{y}}\xspace'$ over $Y$ such that for all $x \in X$ and $y \in Y$ we have $\ensuremath{\mathbf{x}}\xspace'(x) = \sum_{a \in A} \ensuremath{\mathbf{x}}\xspace(x, a),$ and $\ensuremath{\mathbf{y}}\xspace'(y) = \sum_{b \in B} \ensuremath{\mathbf{y}}\xspace(y, b).$ By Lemma~\ref{lem:problp}, we can assume that $\| \ensuremath{\mathbf{x}}\xspace' \|_1 \ge 1 - g \cdot \delta$ and $\| \ensuremath{\mathbf{y}}\xspace' \|_1 \ge 1 - g \cdot \delta$. Our two-prover game will have the same question sets, answer sets, and verification function as \ensuremath{\mathcal{F}}\xspace, but a different distribution over the question sets. Let $\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace = (X, Y, A, B, \mathcal{D}, V)$, where $\mathcal{D}$ is the product of $\ensuremath{\mathbf{x}}\xspace'$ and $\ensuremath{\mathbf{y}}\xspace'$. Note that we have cheated slightly here, since $\mathcal{D}$ is not actually a probability distribution. If $\| \mathcal{D} \|_1 = c < 1$, then we can think of this as Arthur having a $1 - c$ probability of not sending any questions to the Merlins and awarding them payoff $0$. The strategies $\ensuremath{\mathbf{x}}\xspace$ and $\ensuremath{\mathbf{y}}\xspace$ can also be used to give a us a strategy for the Merlins in $\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace$. Without loss of generality, we can assume that for each question $x \in X$ there is exactly one answer $a \in A$ such that $\ensuremath{\mathbf{x}}\xspace(x, a) > 0$, because if there are two answers $a_1$ and $a_2$ such that $\ensuremath{\mathbf{x}}\xspace(x, a_1) > 0$ and $\ensuremath{\mathbf{x}}\xspace(x, a_2) > 0$, then we can shift all probability onto the answer with (weakly) higher payoff, and (weakly) improve the payoff to the row player. Since $(R, C)$ is cooperative, this can only improve the payoff of the columns in $(R, C)$, and since the row player does not move probability between questions, the payoff of the columns in $(-D_2, D_2)$ does not change either. Thus, after shifting, we arrive at a $(1 - 4g \cdot \delta)$-UNE of $\mathcal{G}$ whose social welfare is at least as good as $\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$. Similarly, we can assume that for each question $y \in Y$ there is exactly one answer $b \in B$ such that $\ensuremath{\mathbf{y}}\xspace(y, b) > 0$. So, we can define a strategy $s_\ensuremath{\mathbf{x}}\xspace$ for \ensuremath{\mathrm{Merlin}_1}\xspace in the following way. For each question $x \in X$, the strategy $s_\ensuremath{\mathbf{x}}\xspace$ selects the unique answer $a \in A$ such that~$\ensuremath{\mathbf{x}}\xspace(x, a) > 0$. The strategy $s_\ensuremath{\mathbf{y}}\xspace$ for \ensuremath{\mathrm{Merlin}_2}\xspace is defined symmetrically. We will use $\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace$ as an intermediary between $\mathcal{G}$ and $\ensuremath{\mathcal{F}}\xspace$ by showing that the payoff of $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ in $\mathcal{G}$ is close to the payoff of $(s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ in $\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace$, and that the payoff of $(s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ in $\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace$ is close to the payoff of $(s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ in \ensuremath{\mathcal{F}}\xspace. Since we have a bound on the payoff of any pair of strategies in \ensuremath{\mathcal{F}}\xspace, this will ultimately allow us to bound the payoff to both players when $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is played in $\mathcal{G}$. \paragraph{\bf Relating $\mathcal{G}$ to \ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace} For notational convenience, let us define $p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ and $p_c(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ to be the payoff to the row player and column player, respectively, when $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is played in $\mathcal{G}$. We begin by showing that the difference between $p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ and $p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ is small. Once again we prove this for the payoff of the row player, but the analogous result also holds for the column player. \begin{lemma} \label{lem:pfcomp} We have $| p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) - p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) | \le 4 g \cdot \delta.$ \end{lemma} \begin{proof} By construction, $p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ is equal to the payoff that the row player obtains from the subgame $(R, C)$, and so we have $p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) \le p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) $. On the other hand, since the row player places at most $g \cdot \delta$ probability on rows not in $(R, C)$, and since these rows have payoff at most $\frac{4}{1 + 4g \cdot \delta} < 4$, we have $ p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) \le p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) + 4g \cdot \delta$. \qed \end{proof} \paragraph{\bf Relating $\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace$ to $\ensuremath{\mathcal{F}}\xspace$} First we show that if $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is indeed a $(1 - 4g \cdot \delta)$-UNE, then $\ensuremath{\mathbf{x}}\xspace'$ and $\ensuremath{\mathbf{y}}\xspace'$ must be close to uniform over the questions. We prove this for~$\ensuremath{\mathbf{y}}\xspace'$, but the proof can equally well be applied to $\ensuremath{\mathbf{x}}\xspace'$. The idea is that, if $\ensuremath{\mathbf{y}}\xspace'$ is sufficiently far from uniform, then there is set $B \subseteq Y$ of $|Y|/2$ columns where $\ensuremath{\mathbf{y}}\xspace'$ places significantly more than $0.5$ probability. This, in turn, means that the row of $(D_1, -D_1)$ that corresponds to $B$, will have payoff at least $2$, while the payoff of $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ can be at most $1 + 3g \cdot \delta$, and so $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ would not be a $(1 - 4g \cdot \delta)$-UNE. We formalise this idea in the following lemma. Define $\ensuremath{\mathbf{u}}\xspace_X$ to be the uniform distribution over $X$, and $\ensuremath{\mathbf{u}}\xspace_Y$ to be the uniform distribution over $Y$. \begin{lemma} \label{lem:dbound} We have $\| \ensuremath{\mathbf{u}}\xspace_Y - \ensuremath{\mathbf{y}}\xspace' \|_1 < 16 g \cdot \delta$ and $\| \ensuremath{\mathbf{u}}\xspace_X - \ensuremath{\mathbf{x}}\xspace' \|_1 < 16 g \cdot \delta$. \end{lemma} We begin by proving an auxiliary lemma. \begin{lemma} \label{lem:subset} If $\| \ensuremath{\mathbf{u}}\xspace_Y - \ensuremath{\mathbf{y}}\xspace' \|_1 \ge c$ then there exists a set $B \subseteq Y$ of size $|Y|/2$ such that \begin{equation*} \sum_{i \in B} \ensuremath{\mathbf{y}}\xspace'_i > \frac{1}{2} + \frac{c}{4} - 2 g \cdot \delta. \end{equation*} \end{lemma} \begin{proof} We first define $\ensuremath{\mathbf{d}}\xspace = \ensuremath{\mathbf{y}}\xspace' - \ensuremath{\mathbf{u}}\xspace_Y$, and then we partition $Y$ as follows \begin{align*} U &= \{ y \in Y \; : \; \ensuremath{\mathbf{d}}\xspace_y > \frac{1}{|Y|} \}, \\ L &= \{ y \in Y \; : \; \ensuremath{\mathbf{d}}\xspace_y \le \frac{1}{|Y|} \}. \end{align*} Since $\| \ensuremath{\mathbf{y}}\xspace' \|_1 \ge 1 - g \cdot \delta$ and $\| \ensuremath{\mathbf{u}}\xspace \|_1 = 1$, we have that \begin{align*} \sum_{y \in U} \ensuremath{\mathbf{d}}\xspace_y &\ge c/2 - g \cdot \delta, \\ \sum_{y \in L} \ensuremath{\mathbf{d}}\xspace_y &\le -c/2 + g \cdot \delta. \end{align*} We will prove that there exists a set $B \subseteq Y$ of size $|Y|/2$ such that $\sum_{y \in B} \ensuremath{\mathbf{d}}\xspace_y \ge c/4 - g \cdot \delta$. We have two cases to consider, depending on the size of $U$. \begin{itemize} \item First suppose that $|U| > |Y|/2$. If this is the case, then there must exist a set $B \subseteq U$ with $|B| = |U|/2$ and $\sum_{i \in B} \ensuremath{\mathbf{d}}\xspace_i \ge c/4 - g \cdot \delta$. We can then add arbitrary columns from $U \setminus B$ to $B$ in order to make $|B| = |Y|/2$, and since $\ensuremath{\mathbf{d}}\xspace_i > 0$ for all $i \in U$, this cannot decrease $\sum_{i \in B} \ensuremath{\mathbf{d}}\xspace_i$. Thus, we have completed the proof for this case. \item Now suppose that $|U| \le |Y|/2$. If this is the case, then there must exist a set $C \subseteq L$ with $|C| = |L|/2$ and $\sum_{i \in C} \ensuremath{\mathbf{d}}\xspace_i \ge -\frac{c}{4} + g \cdot \delta$. So, let $C' \subseteq C$ be an arbitrarily chosen subset such that $|C'| + |U| = |Y|/2$. This is possible since $|L| = |Y| - |U|$ and hence $|L|/2 = |Y|/2 - |U|/2$, which implies that $|L|/2 + |U| > |Y|/2$. Setting $B = C' \cup U$ therefore gives us a set with $|B| = |Y|/2$ such that \begin{align*} \sum_{i \in B} \ensuremath{\mathbf{d}}\xspace_i &\ge \left(c/2 - g \cdot \delta\right) - \left(c/4 + g \cdot \delta \right) \\ &= c/4 - 2 \cdot g \cdot \delta\ . \end{align*} So we have completed the proof of this case, and the lemma as a whole. \qed \end{itemize} \end{proof} We can now proceed with the proof of Lemma~\ref{lem:dbound}. \begin{proof}[Proof of Lemma~\ref{lem:dbound}] Suppose, for the sake of contradiction that one of these two properties fails. Without loss of generality, let us assume that $\| \ensuremath{\mathbf{u}}\xspace_Y - \ensuremath{\mathbf{y}}\xspace' \|_1 \ge c$. We will show that the row player can gain more than $1$ in payoff by deviating to a new strategy, which will show that $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is not a~$1$-UNE, contradicting our assumption that it is a $(1 - 4 g \cdot \delta)$-UNE. By assumption, $\ensuremath{\mathbf{x}}\xspace$ places at least $1 - g \cdot \delta$ probability on rows in $(R, C)$. The maximum payoff in $R$ is $1$, and the maximum payoff in $-D_2$ is $0$. On the one hand, the rows in $D_2$ give payoff at most $8/(2 + g \cdot \delta) \le 4$. So the row player's payoff under $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is bounded by \begin{equation*} \left(1 - g \cdot \delta\right) \cdot 1 + \left(g \cdot \delta\right) \cdot 4 = 1 + 3 g \cdot \delta. \end{equation*} On the other hand, we can apply Lemma~\ref{lem:subset} with $c = 16 g \cdot \delta$ to find a set $B \subseteq Y$ such that \begin{align*} \sum_{i \in B} \ensuremath{\mathbf{y}}\xspace'(i) &> \frac{1}{2} + \frac{16g \cdot \delta}{4} - 2 g \cdot \delta. \\ &= \frac{1}{2} + 2 g \cdot \delta \\ &= \frac{1 + 4g \cdot \delta}{2}. \end{align*} So, let $r_B$ be the row of $D_1$ that corresponds to $B$. This row has payoff $\frac{8}{2 + g \cdot \delta}$ for every entry in $B$. So, the payoff of row $r_B$ must be at least \begin{equation*} \left( \frac{1 + 4g \cdot \delta}{2} \right) \cdot \left( \frac{4}{1 + 4g \cdot \delta} \right) = 2. \end{equation*} Thus, the row player can deviate to $r_B$ and increase his payoff by at least $1 - 3 g \cdot \delta$, and $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is not a $(1 - 4 g \cdot \delta)$-UNE. \qed \end{proof} With Lemma~\ref{lem:dbound} at hand, we can now prove that the difference between $p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ and $p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ must be small. This is because the question distribution $\mathcal{D}$ used in \ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace is a product of two distributions that are close to uniform, while the question distribution $\mathcal{U}$ used in \ensuremath{\mathcal{F}}\xspace is a product of two uniform distributions. In the following lemma, we show that if we transform $\mathcal{D}$ into $\mathcal{U}$, then we do not change the payoff of $(s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ very much. \begin{lemma} \label{lem:tfcomp} We have $| p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) - p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) | \le 64 g \cdot \delta.$ \end{lemma} \begin{proof} The distribution used in \ensuremath{\mathcal{F}}\xspace is the product of $\ensuremath{\mathbf{u}}\xspace_Y$ and $\ensuremath{\mathbf{u}}\xspace_X$, while the distribution used in \ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace is the product of $\ensuremath{\mathbf{y}}\xspace$' and $\ensuremath{\mathbf{x}}\xspace'$. Furthermore, Lemma~\ref{lem:dbound} tells us that $\| \ensuremath{\mathbf{u}}\xspace_Y - \ensuremath{\mathbf{y}}\xspace' \|_1 < 16 g \cdot \delta$ and $\| \ensuremath{\mathbf{u}}\xspace_X - \ensuremath{\mathbf{x}}\xspace' \|_1 < 16 g \cdot \delta$. Our approach is to transform $\ensuremath{\mathbf{u}}\xspace_X$ to $\ensuremath{\mathbf{x}}\xspace'$ while bounding the amount that $p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ changes. Once we have this, we can apply the same transformation to $\ensuremath{\mathbf{u}}\xspace_Y$ and $\ensuremath{\mathbf{y}}\xspace'$. Consider the effect of shifting probability from a question $x_1 \in X$ to a different question $x_2 \in X$. Since all entries of $V$ are in $\{0, 1\}$, if we shift~$q$ probability from $x_1$ to $x_2$, then $p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ can change by at most $2q$. This bound also holds if we remove probability from $x_1$ without adding it to $x_2$ (which we might do since $\| \ensuremath{\mathbf{x}}\xspace \|_1$ may not be $1$.) Thus, if we shift probability to transform $\ensuremath{\mathbf{u}}\xspace_X$ into $\ensuremath{\mathbf{x}}\xspace'$, then we can change $p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ by at most $ 32 g \cdot \delta$. The same reasoning holds for transforming $\ensuremath{\mathbf{u}}\xspace_Y$ into $\ensuremath{\mathbf{y}}\xspace'$. This means that we can transform \ensuremath{\mathcal{F}}\xspace to \ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace while changing the payoff of $(s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace)$ by at most $64 g \cdot \delta$, which completes the proof. \qed \end{proof} \paragraph{\bf Completing the soundness proof} The following lemma uses the bounds derived in Lemmas~\ref{lem:pfcomp} and~\ref{lem:tfcomp}, along with a suitable setting for~$g$, to bound the payoff of both players when $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is played in $\mathcal{G}$. \begin{lemma} \label{lem:sound} If $g = \frac{1}{138}$, then both players have payoff at most $1 - g \cdot \delta$ when $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is played in $\mathcal{G}$. \end{lemma} \begin{proof} Lemmas~\ref{lem:pfcomp} and~\ref{lem:tfcomp} tell us that \begin{align*} | \; p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) - p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) | &\le 4g \cdot \delta, \\ | \; p(\ensuremath{\mathcal{T}_{(\xbf, \ybf)}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) - p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) | &\le 64g \cdot \delta. \end{align*} Hence, we have $| \; p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) - p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) | \le 68g \cdot \delta$. However, we know that $p(\ensuremath{\mathcal{F}}\xspace, s_\ensuremath{\mathbf{x}}\xspace, s_\ensuremath{\mathbf{y}}\xspace) \le 1 - \delta/2$. So, if we set $g = \frac{1}{138}$, then we we will have that \begin{align*} p_r(\mathcal{G}, \ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) &\le 1 - \frac{1}{2} \cdot \delta + \frac{68}{138} \cdot \delta \\ &= 1 - \frac{1}{138} \cdot \delta\\ &= 1 - g \cdot \delta. \end{align*} \qed \end{proof} \noindent Hence, we have proved that $\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) \le 2 - 2g \cdot \delta$. \subsection{The result} We can now state the theorem that we have proved in this section. We first rescale the game so that it lies in $[0, 1]$. The maximum payoff in $\mathcal{G}$ is $\frac{4}{1 + 4g \cdot \delta} \le 4$, and the minimum payoff is $- \frac{4}{1 + 4g \cdot \delta} \ge -4$. To rescale this game, we add $4$ to all the payoffs, and then divide by $8$. Let us refer to the scaled game as $\mathcal{G}_s$. Observe that an $\ensuremath{\epsilon}\xspace$-UNE in $\mathcal{G}$ is a $\frac{\ensuremath{\epsilon}\xspace}{8}$-NE in $\mathcal{G}_s$ since adding a constant to all payoffs does not change the approximation guarantee, but dividing all payoffs by a constant does change the approximation guarantee. So, we have the following theorem. \begin{theorem} \label{thm:main} If ETH holds, then there exists a constant $\delta$ below which the problem $(\frac{1 - 4 g \cdot \delta}{8})$-NE $(\frac{g}{4}\cdot \delta)$-SW, where $g = \frac{1}{138}$, requires $n^{\widetilde \Omega(\log n)}$ time. \end{theorem} \begin{proof} By Lemmas~\ref{lem:complete} and~\ref{lem:sound}, we have \begin{itemize} \item if $\omega(\mathcal{F}) = 1$ then there exists a $(1 - 4g \cdot \delta)$-UNE of $\mathcal{G}$ with social welfare $1 + 1 = 2$. In the rescaled game this translates to a $(\frac{1 - 4 g \cdot \delta}{8})$-NE of $\mathcal{G}_s$ with social welfare $\frac{1+4}{8} + \frac{1+4}{8} = \frac{10}{8}$. \item if $\omega(\mathcal{F}) < 1 - \delta$ then all $(1 - 4 g \cdot \delta)$-UNE of $\mathcal{G}$ have social welfare at most $(1 - g \cdot \delta) + (1 - g \cdot \delta) = 2 - 2g \cdot \delta$. After rescaling, we have that all $(\frac{1 - 4 g \cdot \delta}{8})$-NE of $\mathcal{G}_s$ have social welfare social welfare at most \begin{equation*} \frac{5 - g \cdot \delta}{8} + \frac{5 - g \cdot \delta}{8} = \frac{10}{8} - \frac{g \cdot \delta}{4} \end{equation*} \end{itemize} By Theorem~\ref{thm:qplower}, assuming ETH we require $|\mathcal{F}|^{\widetilde{\Omega}(\log |\mathcal{F}|)}$ time to decide whether the value of $\mathcal{F}$ is $1$ or $1 - \delta$ for some small constant $\delta$. Thus, we also require $n^{\widetilde{\Omega}(\log |n|)}$ to solve the problem $(\frac{1 - 4 g \cdot \delta}{8})$-NE $(\frac{g}{4}\cdot \delta)$-SW. \qed \end{proof} \section{Hardness results for other decision problems} \label{sec:problems} In this section we study a range of decision problems associated with approximate equilibria. Table~\ref{tab:problems} shows all of the decision problems that we consider. Most are known to be \ensuremath{\mathtt{NP}}\xspace-complete for the case of exact Nash equilibria~\cite{GZ89,CS08}. For each problem in Table~\ref{tab:problems}, the input includes a bimatrix game and a quality of approximation $\ensuremath{\epsilon}\xspace \in (0,1)$. We consider decision problems related to both \ensuremath{\epsilon}\xspace-NE and \ensuremath{\epsilon}\xspace-WSNE. Since \ensuremath{\epsilon}\xspace-NE is a weaker solution concept than \ensuremath{\epsilon}\xspace-WSNE, i.e., every \ensuremath{\epsilon}\xspace-WSNE is an \ensuremath{\epsilon}\xspace-NE, the hardness results for \ensuremath{\epsilon}\xspace-NE imply the same hardness for \ensuremath{\epsilon}\xspace-WSNE. We consider problems for \ensuremath{\epsilon}\xspace-WNSE only where the corresponding problem for \ensuremath{\epsilon}\xspace-NE is trivial. For example, observe that deciding if there is an \ensuremath{\epsilon}\xspace-NE with large support is a trivial problem, since we can always add a tiny amount of probability to each pure strategy without changing our expected payoff very much. Our conditional quasi-polynomial lower bounds will hold for all $\ensuremath{\epsilon}\xspace<\frac{1}{8}$, so let us fix $\ensuremath{\epsilon}\xspace^* < \frac{1}{8}$ for the rest of this section. Using Theorem~\ref{thm:main}, we compute from~$\ensuremath{\epsilon}\xspace^*$ the parameters $n$ and $\delta$ that we require to apply Theorem~\ref{thm:main}. In particular, set $\delta^*$ to solve $\ensuremath{\epsilon}\xspace^* = (\frac{1 - 4 g \cdot \delta^*}{8})$, and choose $n^*$ as $\frac{1}{\delta^*}$. Then, for $n>n^*$ and $\delta=\delta^*$ we can apply Theorem~\ref{thm:main} to bound the social welfare achievable if $\omega(\ensuremath{\mathcal{F}}\xspace) < 1 - \delta^*$ as $$\ensuremath{\mathfrak{u}}\xspace := \frac{10}{8} - \frac{1}{522}\delta^*.$$ Theorem~\ref{thm:main} implies that in order to decide whether the game $\ensuremath{\mathcal{G}}\xspace_s$ possesses an $\ensuremath{\epsilon}\xspace^*$-NE that yields social welfare strictly greater than $\ensuremath{\mathfrak{u}}\xspace$ requires $n^{\tilde{O}(\log n)}$ time, where $\delta$ no longer appears in the exponent since we have fixed it as the constant~$\delta^*$. Problem~\ref{probc:largep} asks to decide whether a bimatrix game possesses an $\ensuremath{\epsilon}\xspace^*$-NE where the expected payoff for each player is at least $u$, where $u$ is an input to the problem. When we set $u = \frac{5}{8}$, the conditional hardness of this problem is an immediate corollary of Theorem~\ref{thm:main}. For Problems~\mbox{\ref{probc:restrictedweak}~-~\ref{probc:maxsupport}}, we use $\ensuremath{\mathcal{G}}\xspace_s$ to construct a new game \ensuremath{\mathcal{G}'}\xspace, which adds one row \ensuremath{\mathfrak{i}}\xspace and one column \ensuremath{\mathfrak{j}}\xspace to $\ensuremath{\mathcal{G}}\xspace_s$. The payoffs are defined using the constants $\ensuremath{\mathfrak{u}}\xspace$ and~$\ensuremath{\epsilon}\xspace^*$, as shown in Figure~\ref{fig:gcalp}. \begin{figure}[tbph!] \begin{center} \setlength{\extrarowheight}{2pt} \hspace{-10mm} \resizebox{0.7\textwidth}{!}{ \begin{tabular}{cc|P{1.5cm}|c|P{1.5cm}|P{1.75cm}|} \multirow{6}{*}{\Large \ensuremath{\mathcal{G}'}\xspace =} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{\large $\ensuremath{\mathfrak{j}}\xspace$} \\\cline{3-6} & & \multicolumn{3}{|c|}{} & $0, \frac{5}{8}+\ensuremath{\epsilon}\xspace^*$ \\ \cline{6-6} & & \multicolumn{3}{|c|}{\Large $\ensuremath{\mathcal{G}}\xspace_s$} & $\vdots$ \\ \cline{6-6} & & \multicolumn{3}{|c|}{} & $0, \frac{5}{8}+\ensuremath{\epsilon}\xspace^*$ \\ \cline{3-6} & {\large $\ensuremath{\mathfrak{i}}\xspace$} & $\frac{5}{8}+\ensuremath{\epsilon}\xspace^*, 0$ & $\cdots$ & $\frac{5}{8}+\ensuremath{\epsilon}\xspace^*, 0$ & $1, 1$ \\\cline{3-6} \end{tabular} } \end{center} \medskip \caption{The game \ensuremath{\mathcal{G}'}\xspace.} \label{fig:gcalp} \end{figure} In \ensuremath{\mathcal{G}'}\xspace, the expected payoff for the row player for~\ensuremath{\mathfrak{i}}\xspace is at least $\frac{5}{8}+\ensuremath{\epsilon}\xspace^*$ irrespective of the column player's strategy. Similarly, the expected payoff for~\ensuremath{\mathfrak{j}}\xspace is at least~${\frac{5}{8}+\ensuremath{\epsilon}\xspace^*}$ irrespective of the row player's strategy. This means that: \begin{itemize} \item If $\ensuremath{\mathcal{G}}\xspace_s$ possesses an $\ensuremath{\epsilon}\xspace^*$-NE with social welfare $\frac{10}{8}$, then \ensuremath{\mathcal{G}'}\xspace possesses at least one $\ensuremath{\epsilon}\xspace^*$-NE where the players do not play the pure strategies \ensuremath{\mathfrak{i}}\xspace and~\ensuremath{\mathfrak{j}}\xspace. \item If every $\ensuremath{\epsilon}\xspace^*$-NE of $\ensuremath{\mathcal{G}}\xspace_s$ yields social welfare at most \ensuremath{\mathfrak{u}}\xspace, then in \emph{every} $\ensuremath{\epsilon}\xspace^*$-NE of \ensuremath{\mathcal{G}'}\xspace, the players place almost all of their probability on \ensuremath{\mathfrak{i}}\xspace and \ensuremath{\mathfrak{j}}\xspace respectively. Note that $(\ensuremath{\mathfrak{i}}\xspace,\ensuremath{\mathfrak{j}}\xspace)$ is a pure exact Nash equilibrium. \end{itemize} Problem~\ref{probc:restrictedweak} asks whether a bimatrix game possesses an $\ensuremath{\epsilon}\xspace$-NE where the row player plays with positive probability only strategies in a given set $S$. Let $S_R$ ($S_C$) denote the set of pure strategies available to the row (column) player from the subgame~$(R, C)$ of $\ensuremath{\mathcal{G}}\xspace_s$. To show the hardness of Problem~\ref{probc:restrictedweak}, we will set we set $S=S_R$. Recall that $\ensuremath{\mathcal{G}}\xspace_s$ is created from \ensuremath{\mathcal{F}}\xspace. First, we prove in Lemma~\ref{lem:groupa-yes} that if~${\omega(\ensuremath{\mathcal{F}}\xspace)=1}$, then $\ensuremath{\mathcal{G}}\xspace'$ possesses an $\ensuremath{\epsilon}\xspace^*$-NE such that the answer to Problem~\ref{probc:restrictedweak} is ``Yes''. Note that we actually argue in Lemma~\ref{lem:groupa-yes} about the existence of an $\ensuremath{\epsilon}\xspace^*$-WSNE, since this stronger claim will be useful when we come to deal with Problems~\ref{probc:totalmaxsupport}~-~\ref{probc:maxsupport}. \begin{lemma} \label{lem:groupa-yes} If $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then $\ensuremath{\mathcal{G}}\xspace'$ possesses an $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that ${\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace) \subseteq S_R}$. Under $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$, both players get payoff $\frac{5}{8}$, so $\sw(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace) = \frac{10}{8}$. Moreover, $|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)| = |X|$ and $\max_i \ensuremath{\mathbf{x}}\xspace_i \leq \frac{1}{|X|}$, where $X$ is the question set of \ensuremath{\mathrm{Merlin}_1}\xspace in \ensuremath{\mathcal{F}}\xspace. \end{lemma} \begin{proof} The proof of Lemma~\ref{lem:complete} shows that, if $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then $\ensuremath{\mathcal{G}}\xspace$ possesses an $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ where the expected payoff for each player is $1$ and ${\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace) \subseteq S_R}$. The reason that $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is well supported is that all rows in $\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)$ have equal expected payoff. Moreover, \ensuremath{\mathbf{x}}\xspace is a uniform mixture over a pure strategy set of size $|X|$, where $X$ is the question set of \ensuremath{\mathrm{Merlin}_1}\xspace in \ensuremath{\mathcal{F}}\xspace. Since $\ensuremath{\mathcal{G}}\xspace_s$ is obtained from~$\ensuremath{\mathcal{G}}\xspace$ by adding 4 to the payoffs and dividing by 8, $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is as an $\ensuremath{\epsilon}\xspace^*$-NE in $\ensuremath{\mathcal{G}}\xspace_s$ where each player has payoff $\frac{5}{8}$. To complete the proof we show that $(\ensuremath{\mathbf{x}}\xspace,\ensuremath{\mathbf{y}}\xspace)$ in an $\ensuremath{\epsilon}\xspace^*$-NE for $\ensuremath{\mathcal{G}}\xspace'$, which is the same as $\ensuremath{\mathcal{G}}\xspace_s$ apart from the additional pure strategies~$\ensuremath{\mathfrak{i}}\xspace$ and~$\ensuremath{\mathfrak{j}}\xspace$. Since $\ensuremath{\mathfrak{i}}\xspace$ and~$\ensuremath{\mathfrak{j}}\xspace$ yield payoff $\frac{5}{8}+\ensuremath{\epsilon}\xspace^*$, but not more, the claim holds. \qed \end{proof} Next we prove that if $\omega(\ensuremath{\mathcal{F}}\xspace) < 1-\delta^*$, then the answer to Problem~\ref{probc:restrictedweak} is ``No''. \begin{lemma} \label{lem:groupa-no} If $\omega(\ensuremath{\mathcal{F}}\xspace) < 1-\delta^*$, then in every $\ensuremath{\epsilon}\xspace^*$-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ of \ensuremath{\mathcal{G}'}\xspace it holds that $\ensuremath{\xbf_\ifrak}\xspace > 1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ and $\ensuremath{\ybf_\jfrak}\xspace > 1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ . \end{lemma} \begin{proof} Let $\ensuremath{\mathcal{G}}\xspace_s := (P, Q)$ and suppose that $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is an $\ensuremath{\epsilon}\xspace^*$-NE of \ensuremath{\mathcal{G}'}\xspace. From Theorem~\ref{thm:main} we know that if $\omega(\ensuremath{\mathcal{F}}\xspace) < 1-\delta^*$, then in any $\ensuremath{\epsilon}\xspace^*$-NE of $\ensuremath{\mathcal{G}}\xspace_s$ we have that each player gets payoff at most $\frac{\ensuremath{\mathfrak{u}}\xspace}{2} < \frac{5}{8}$. Under $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ in \ensuremath{\mathcal{G}'}\xspace the row player gets payoff \begin{align*} \ensuremath{\mathbf{x}}\xspace^T P \ensuremath{\mathbf{y}}\xspace & < (1-\ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace)\cdot(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\cdot \frac{5}{8} + \ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace \cdot(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace) (\frac{5}{8}+ \ensuremath{\epsilon}\xspace^*) + \ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace\cdot\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace \\ & = \ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace\cdot \left( (1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace) \cdot \ensuremath{\epsilon}\xspace^* + \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace \right) + (1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace) \cdot \frac{5}{8}. \end{align*} From the pure strategy \ensuremath{\mathfrak{i}}\xspace, the row player gets $$P_\ensuremath{\mathfrak{i}}\xspace\cdot\ensuremath{\mathbf{y}}\xspace = (1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)(\frac{5}{8}+\ensuremath{\epsilon}\xspace^*) + \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace.$$ In order for $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ to be an $\ensuremath{\epsilon}\xspace^*$-NE it must hold that $\ensuremath{\mathbf{x}}\xspace^T P \ensuremath{\mathbf{y}}\xspace \geq P_\ensuremath{\mathfrak{i}}\xspace\ensuremath{\mathbf{y}}\xspace - \ensuremath{\epsilon}\xspace^*$. Using the upper bound on $\ensuremath{\mathbf{x}}\xspace^T P\ensuremath{\mathbf{y}}\xspace$ that we just derived, we get: \begin{align} \label{eq:xbound} \ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace > 1 - \frac{\ensuremath{\epsilon}\xspace^*}{(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\cdot \ensuremath{\epsilon}\xspace^* + \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace}. \end{align} By symmetry, we also have that the column player must play \ensuremath{\mathfrak{j}}\xspace with probability: \begin{align} \label{eq:ybound} \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace > 1 - \frac{\ensuremath{\epsilon}\xspace^*}{(1-\ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace)\cdot \ensuremath{\epsilon}\xspace^* + \ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace}. \end{align} Recall that in this section $\ensuremath{\epsilon}\xspace^*$ is a constant. Observe that the right-hand side of~\eqref{eq:ybound} is increasing in $\ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace$, and we can thus use it to replace $\ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace$ in~\eqref{eq:ybound} as follows: \begin{align*} \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace & > 1- \frac{\ensuremath{\epsilon}\xspace^*}{(1-1+\frac{\ensuremath{\epsilon}\xspace^*}{(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\ensuremath{\epsilon}\xspace^*+\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace})\ensuremath{\epsilon}\xspace^*+ 1-\frac{\ensuremath{\epsilon}\xspace^*}{(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\ensuremath{\epsilon}\xspace^*+\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace}}\\ & = 1- \frac{\ensuremath{\epsilon}\xspace^*}{\frac{\ensuremath{\epsilon}\xspace^{*^2}}{(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\ensuremath{\epsilon}\xspace^*+\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace}+ 1-\frac{\ensuremath{\epsilon}\xspace^*}{(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\ensuremath{\epsilon}\xspace^*+\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace}}\\ & = 1- \frac{(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\ensuremath{\epsilon}\xspace^{*^2} + \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace \ensuremath{\epsilon}\xspace^*}{\ensuremath{\epsilon}\xspace^{*^2}+(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\ensuremath{\epsilon}\xspace^*+\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace-\ensuremath{\epsilon}\xspace^*}. \end{align*} Noting that $(\ensuremath{\epsilon}\xspace^{*^2}+(1-\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace)\ensuremath{\epsilon}\xspace^*+\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace-\ensuremath{\epsilon}\xspace^*) \ge 0$, by rearranging we get that $$\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace^2(1-\ensuremath{\epsilon}\xspace^*) + \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace(2\ensuremath{\epsilon}\xspace^*-1) > 0.$$ Then, since $\ensuremath{\epsilon}\xspace^*<\frac{1}{8}$, we have $1-\ensuremath{\epsilon}\xspace ^*> 0$, and we get that \begin{align*} \ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace > \frac{1-2\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*} = 1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}. \end{align*} By symmetry, we have $\ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace > 1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$, which completes the proof.\qed \end{proof} Next we recall Problems~\ref{probc:difcomp} and~\ref{probc:maxprob} and we show that, as for Problem~\ref{probc:restrictedweak}, Lemmas~\ref{lem:groupa-yes} and~\ref{lem:groupa-no} can also be used to immediately show that there are instances of these decision problems where the answer is ``Yes'' if and only if $\omega(\ensuremath{\mathcal{F}}\xspace)=1$. Given two probability distributions $\ensuremath{\mathbf{x}}\xspace$ and $\ensuremath{\mathbf{x}}\xspace'$, the \emph{Total Variation (TV)} distance between them is $\max_i \{ |\ensuremath{\mathbf{x}}\xspace_i - \ensuremath{\mathbf{x}}\xspace'_i| \}$. We define the TV distance between two strategy profiles $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ and $(\ensuremath{\mathbf{x}}\xspace', \ensuremath{\mathbf{y}}\xspace')$ to be the maximum over the TV distance of $\ensuremath{\mathbf{x}}\xspace$ and $\ensuremath{\mathbf{x}}\xspace'$ and the TV distance of $\ensuremath{\mathbf{y}}\xspace$ and $\ensuremath{\mathbf{y}}\xspace'$. Problem~\ref{probc:difcomp} asks whether a bimatrix game possesses two \ensuremath{\epsilon}\xspace -NEs with TV distance at least $d$. In order to apply Lemmas~\ref{lem:groupa-yes} and~\ref{lem:groupa-no}, we will set $d=1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$. Then an instance $\ensuremath{\mathcal{G}'}\xspace$ of Problem~\ref{probc:difcomp} is ``Yes'' when $\omega(\ensuremath{\mathcal{F}}\xspace)=1$ since the $\ensuremath{\epsilon}\xspace^*$-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ identified in Lemma~\ref{lem:groupa-yes}, has TV distance one from the pure exact Nash equilbrium $(\ensuremath{\mathfrak{i}}\xspace,\ensuremath{\mathfrak{j}}\xspace)$. Lemma~\ref{lem:groupa-no} says that, if $\omega(\ensuremath{\mathcal{F}}\xspace) < 1-\delta^*$, every $\ensuremath{\epsilon}\xspace^*$-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ of \ensuremath{\mathcal{G}'}\xspace has $\ensuremath{\xbf_\ifrak}\xspace > 1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ and so all $\ensuremath{\epsilon}\xspace^*$-NE are within TV distance $1-\frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ of each other. Problem~\ref{probc:maxprob} asks to decide whether there exists an \ensuremath{\epsilon}\xspace-NE where the row player does not play any pure strategy with probability more than $p$. For this problem, we set $p = \frac{1}{|X|}$, where $X$ is the question set for \ensuremath{\mathrm{Merlin}_1}\xspace. According Lemma~\ref{lem:groupa-yes}, if $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then an instance $\ensuremath{\mathcal{G}'}\xspace$ of Problem~\ref{probc:maxprob} is a ``Yes''. Lemma~\ref{lem:groupa-no} says that, if $\omega(\ensuremath{\mathcal{F}}\xspace) < 1-\delta^*$, then for all $\ensuremath{\epsilon}\xspace^*$-NE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ of \ensuremath{\mathcal{G}'}\xspace, $\max_i\ensuremath{\mathbf{x}}\xspace_i \geq \ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace > 1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*} > \frac{1}{|X|}$. Problem~\ref{probc:smalltp} asks whether a bimatrix game possesses an $\ensuremath{\epsilon}\xspace$-NE with social welfare at most $v$, and Problem~\ref{probc:smallp} asks whether a bimatrix game possesses an \ensuremath{\epsilon}\xspace -NE where the expected payoff of the row player is at most $u$. We fix $v = \frac{10}{8}$ for Problem~\ref{probc:smalltp}, and for Problem~\ref{probc:smallp} we fix $u = \frac{5}{8}$. As we have already explained in the proof of Lemma~\ref{lem:groupa-yes}, if $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then there is an $\ensuremath{\epsilon}\xspace^*$-NE for $\ensuremath{\mathcal{G}}\xspace'$ such that the expected payoff for each player is $\frac{5}{8}$ and thus the social welfare is $\frac{10}{8}$. So, if $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then the answer to Problems~\ref{probc:smalltp} and~\ref{probc:smallp} is ``Yes''. On the other hand, from the proof of Lemma~\ref{lem:groupa-no} we know that if $\omega(\ensuremath{\mathcal{F}}\xspace) < 1-\delta^*$, then in any $\ensuremath{\epsilon}\xspace^*$-NE of \ensuremath{\mathcal{G}'}\xspace both players play the strategies \ensuremath{\mathfrak{i}}\xspace and \ensuremath{\mathfrak{j}}\xspace with probability at least $1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$. So, each player gets payoff at least $(1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*})^2 > \frac{5}{8}$, since $\ensuremath{\epsilon}\xspace^* < \frac{1}{8}$, from their pure strategies \ensuremath{\mathfrak{i}}\xspace and \ensuremath{\mathfrak{j}}\xspace. So, if $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta^*$, then the answer to Problems~\ref{probc:smalltp} and~\ref{probc:smallp} is ``No''. Problems~\ref{probc:totalmaxsupport}~-~\ref{probc:maxsupport} relate to deciding if there exist approximate \emph{well-supported} equilibria with large supports (for \ensuremath{\epsilon}\xspace-NE these problems would be trivial). Problem~\ref{probc:totalmaxsupport} asks whether a bimatrix game possesses an \ensuremath{\epsilon}\xspace-WSNE~$(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ with $|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)| + |\mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)| \geq 2k$. Problem~\ref{probc:minmaxsupport} asks whether a bimatrix game possesses an {}\ensuremath{\epsilon}\xspace-WSNE~$(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ with $\min\{|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)|, |\mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)|\} \geq k$. Problem~\ref{probc:maxsupport} asks whether a bimatrix game possesses an \ensuremath{\epsilon}\xspace-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ with $|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)| \geq k$. Recall that $X$ and~$Y$ are the question sets of \ensuremath{\mathrm{Merlin}_1}\xspace and \ensuremath{\mathrm{Merlin}_2}\xspace respectively that were used to define \ensuremath{\mathcal{F}}\xspace and in turn $\ensuremath{\mathcal{G}}\xspace_s$. We will fix $k = |X| = |Y|$ for all three problems. If $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then Lemma~\ref{lem:groupa-yes} says that there exists an $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ for~\ensuremath{\mathcal{G}'}\xspace such that $|\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)|= |\mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)|=k$ and thus the answer to Problems~\ref{probc:totalmaxsupport}~-~\ref{probc:maxsupport} is ``Yes''. On the other hand, if $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta$, then we will prove that there is a unique $\ensuremath{\epsilon}\xspace^*$-WSNE where the row player plays only the pure strategy \ensuremath{\mathfrak{i}}\xspace and the column player plays the pure strategy \ensuremath{\mathfrak{j}}\xspace. \begin{lemma} \label{lem:groupc} If $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta^*$, then there is a unique $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ in \ensuremath{\mathcal{G}'}\xspace such that $\ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace=1$ and $\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace=1$. \end{lemma} \begin{proof} We consider only the case that $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta^*$. Then Lemma~\ref{lem:groupa-no} says that in every $\ensuremath{\epsilon}\xspace^*$-NE of \ensuremath{\mathcal{G}'}\xspace the column player plays the pure strategy \ensuremath{\mathfrak{j}}\xspace with probability at least $1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$. Against \ensuremath{\mathfrak{j}}\xspace, the row player gets $0$ for all pure strategies $i \neq \ensuremath{\mathfrak{i}}\xspace$ and $1$ for \ensuremath{\mathfrak{i}}\xspace. Thus, in any $\ensuremath{\epsilon}\xspace^*$-NE of \ensuremath{\mathcal{G}'}\xspace, for every pure strategy $i \neq \ensuremath{\mathfrak{i}}\xspace$, the row player gets at most $\frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ from every pure strategy $i$, and the row player gets at least $1 - \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ from \ensuremath{\mathfrak{i}}\xspace. So, in every $\ensuremath{\epsilon}\xspace^*$-WSNE the row player must play only the pure strategy \ensuremath{\mathfrak{i}}\xspace since from every other pure strategy the player suffers regret at least $1 - \frac{2\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$, which is strictly larger than $\ensuremath{\epsilon}\xspace^*$ for every $\ensuremath{\epsilon}\xspace^* < \frac{1}{8}$. In turn, against~\ensuremath{\mathfrak{i}}\xspace, every pure strategy $j \neq \ensuremath{\mathfrak{j}}\xspace$ for the column player yields zero payoff while the strategy \ensuremath{\mathfrak{j}}\xspace yields payoff 1. So, the unique $\ensuremath{\epsilon}\xspace^*$-WSNE of \ensuremath{\mathcal{G}'}\xspace is $\ensuremath{\mathbf{x}}\xspace_\ensuremath{\mathfrak{i}}\xspace=1$ and~$\ensuremath{\mathbf{y}}\xspace_\ensuremath{\mathfrak{j}}\xspace=1$. \qed \end{proof} Hence, when $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta^*$ the answer to Problems~\ref{probc:totalmaxsupport}~-~\ref{probc:maxsupport} is ``No''. Thus, we have shown the following: \begin{theorem} \label{thm:groupc} Assuming ETH, any algorithm that solves the Problems~\ref{probc:restrictedweak} -~\ref{probc:maxsupport} for any constant $\ensuremath{\epsilon}\xspace< \frac{1}{8}$ requires $n^{\tilde{\Omega}(\log n)}$ time. \end{theorem} Finally, for Problem~\ref{probc:restricting}, we define a new game \ensuremath{\mathcal{G}''}\xspace by extending \ensuremath{\mathcal{G}'}\xspace. We add the new pure strategies \ensuremath{\mathfrak{i}'}\xspace for the row player and \ensuremath{\mathfrak{j}'}\xspace for the column player. The payoffs are shown in Figure~\ref{fig:gcalpp}. Recall that Problem~\ref{probc:restricting} asks whether a bimatrix game possesses an \ensuremath{\epsilon}\xspace-WSNE such that every strategy from a given set $S$ is played with positive probability. In order to prove our result we fix $S=\ensuremath{\mathfrak{i}'}\xspace$. First, we prove that if ${\omega(\ensuremath{\mathcal{F}}\xspace)=1}$ then the game \ensuremath{\mathcal{G}''}\xspace possesses an $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that $\ensuremath{\mathfrak{i}'}\xspace \in \mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)$. Then we prove that if $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta$, then for any $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ it holds that~${\ensuremath{\mathfrak{i}'}\xspace \notin \mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)}$. \begin{figure}[tbph!] \hspace{1cm} \setlength{\extrarowheight}{2pt} \resizebox{0.7\textwidth}{!}{ \begin{tabular}{cc|P{1.5cm}|c|P{1.5cm}|P{1.75cm}|} \multirow{6}{*}{\Large \ensuremath{\mathcal{G}''}\xspace =} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{\large $\ensuremath{\mathfrak{j}'}\xspace$} \\\cline{3-6} & & \multicolumn{3}{|c|}{} & $\frac{5}{8}, \frac{5}{8}$ \\ \cline{6-6} & & \multicolumn{3}{|c|}{\Large \ensuremath{\mathcal{G}'}\xspace} & $\vdots$ \\ \cline{6-6} & & \multicolumn{3}{|c|}{} & $\frac{5}{8}, \frac{5}{8}$ \\ \cline{3-6} & {\large $\ensuremath{\mathfrak{i}'}\xspace$} & $\frac{5}{8}, \frac{5}{8}$ & $\cdots$ & $\frac{5}{8}, \frac{5}{8}$ & $0, 0$ \\\cline{3-6} \end{tabular} } \medskip \caption{The game \ensuremath{\mathcal{G}''}\xspace.} \label{fig:gcalpp} \end{figure} \begin{lemma} \label{lem:ipinsup} If $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then \ensuremath{\mathcal{G}''}\xspace possesses an $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ such that ${\ensuremath{\mathfrak{i}'}\xspace \in \mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)}$. \end{lemma} \begin{proof} Lemma~\ref{lem:groupa-yes} says that if $\omega(\ensuremath{\mathcal{F}}\xspace)=1$, then \ensuremath{\mathcal{G}'}\xspace possesses an $\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace', \ensuremath{\mathbf{y}}\xspace')$ that gives payoff $\frac{5}{8}$ for each player, and $\ensuremath{\mathbf{x}}\xspace'$ is uniform on a set of size~$|X|$. We construct the required $\ensuremath{\epsilon}\xspace^*$-WSNE of \ensuremath{\mathcal{G}''}\xspace from $(\ensuremath{\mathbf{x}}\xspace', \ensuremath{\mathbf{y}}\xspace')$ as follows. We add~\ensuremath{\mathfrak{i}'}\xspace to the support of $\ensuremath{\mathbf{x}}\xspace'$ so that \ensuremath{\mathbf{x}}\xspace is a uniform mixture over $\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace')\cup\ensuremath{\mathfrak{i}'}\xspace$. For the column player, we extend $\ensuremath{\mathbf{y}}\xspace'$ by adding zero probability for \ensuremath{\mathfrak{j}'}\xspace. Against \ensuremath{\mathbf{y}}\xspace, pure strategies in $\mathrm{supp}(\ensuremath{\mathbf{x}}\xspace')$ give payoff $\frac{5}{8}$, pure strategy \ensuremath{\mathfrak{i}}\xspace in \ensuremath{\mathcal{G}'}\xspace yields payoff $\frac{5}{8}+\ensuremath{\epsilon}\xspace^*$, and \ensuremath{\mathfrak{i}'}\xspace gives payoff $\frac{5}{8}$. Thus, since $(\ensuremath{\mathbf{x}}\xspace', \ensuremath{\mathbf{y}}\xspace')$ is an $\ensuremath{\epsilon}\xspace^*$-WSNE of \ensuremath{\mathcal{G}'}\xspace, \ensuremath{\mathbf{x}}\xspace has pure regret at most $\ensuremath{\epsilon}\xspace^*$ against \ensuremath{\mathbf{y}}\xspace, as required. What remains is to show that the pure regret of \ensuremath{\mathbf{y}}\xspace is no more than $\ensuremath{\epsilon}\xspace^*$ against \ensuremath{\mathbf{x}}\xspace. Recall that, in \ensuremath{\mathcal{G}'}\xspace, against $\ensuremath{\mathbf{x}}\xspace'$, the payoff of each pure strategy in $\mathrm{supp}(\ensuremath{\mathbf{y}}\xspace')$ is~$\frac{5}{8}$. Now consider~\ensuremath{\mathcal{G}''}\xspace. Since, against $\ensuremath{\mathfrak{i}'}\xspace$, the column player gets $\frac{5}{8}$ for all $j \in \mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)$, the column player still gets $\frac{5}{8}$ against~$\ensuremath{\mathbf{x}}\xspace$ for all $j \in \mathrm{supp}(\ensuremath{\mathbf{y}}\xspace)$. Moreover, against $\ensuremath{\mathbf{x}}\xspace$, the payoff of $\ensuremath{\mathfrak{j}}\xspace'$ is $\frac{|X|}{|X|+1} \cdot \frac{5}{8} < \frac{5}{8}$. Thus, since $(\ensuremath{\mathbf{x}}\xspace', \ensuremath{\mathbf{y}}\xspace')$ is an $\ensuremath{\epsilon}\xspace^*$-WSNE of \ensuremath{\mathcal{G}'}\xspace, we have that $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ is an $\ensuremath{\epsilon}\xspace^*$-WSNE of \ensuremath{\mathcal{G}''}\xspace with $\ensuremath{\mathfrak{i}'}\xspace \in \mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)$, which completes the proof. \qed \end{proof} \begin{lemma} \label{lem:ipninsup} If $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta^*$, then for any~$\ensuremath{\epsilon}\xspace^*$-WSNE $(\ensuremath{\mathbf{x}}\xspace, \ensuremath{\mathbf{y}}\xspace)$ of \ensuremath{\mathcal{G}''}\xspace it holds that $\ensuremath{\mathfrak{i}'}\xspace \notin \mathrm{supp}(\ensuremath{\mathbf{x}}\xspace)$. \end{lemma} \begin{proof} We prove that the unique $\ensuremath{\epsilon}\xspace^*$-WSNE of \ensuremath{\mathcal{G}''}\xspace is the pure profile~$(\ensuremath{\mathfrak{i}}\xspace, \ensuremath{\mathfrak{j}}\xspace)$. Using exactly the same arguments as in the proof of Lemma~\ref{lem:groupa-no} we can prove that if $\omega(\ensuremath{\mathcal{F}}\xspace)<1-\delta^*$, then in any $\ensuremath{\epsilon}\xspace^*$-NE of \ensuremath{\mathcal{G}''}\xspace it holds that $\ensuremath{\xbf_\ifrak}\xspace > 1- \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ and $\ensuremath{\ybf_\jfrak}\xspace > 1- \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$. Then, using exactly the same arguments as in Lemma~\ref{lem:groupc} we can get that the pure strategy \ensuremath{\mathfrak{j}}\xspace for the column player yields payoff at least $1- \frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$ while any other pure strategy, including \ensuremath{\mathfrak{j}'}\xspace, yields payoff at most $\frac{\ensuremath{\epsilon}\xspace^*}{1-\ensuremath{\epsilon}\xspace^*}$. Hence, in any $\ensuremath{\epsilon}\xspace^*$-WSNE of \ensuremath{\mathcal{G}''}\xspace the column player must play only the pure strategy \ensuremath{\mathfrak{j}}\xspace. Then, in order to be in an $\ensuremath{\epsilon}\xspace^*$-WSNE the row player must play the pure strategy~\ensuremath{\mathfrak{i}}\xspace. Our claim follows. \qed \end{proof} The combination of Lemmas~\ref{lem:ipinsup} and~\ref{lem:ipninsup} gives the following theorem. \begin{theorem} \label{thm:main2} Assuming the ETH, any algorithm that solves the Problem~\ref{probc:restricting} for any constant $\ensuremath{\epsilon}\xspace < \frac{1}{8}$ requires $n^{\mathrm{\tilde{\Omega}}(\log n)}$ time. \end{theorem} \paragraph{\bf Acknowledgements} We would like to thank Aviad Rubinstein for alerting us to the existence of Theorem~\ref{thm:qplower}. \newpage \section*{\refname}
{'timestamp': '2017-04-26T02:04:34', 'yymm': '1608', 'arxiv_id': '1608.03574', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03574'}
arxiv
\section{\label{sec:intro}Introduction} Metric graph theory is a study of geometric properties of graphs based on a notion of the shortest or geodesic path between the nodes defined as the path through the smallest number of edges~\cite{BC08a}. \revc{1}{1./3}{Metric graph properties have proved very useful in the study of complex networks in the past}~\cite{Mil67,Fre77,WS98}. Independently of these efforts, metric graph theorists have been interested in understanding convexity in a given graph~\cite{HN81,FJ86,Van93,Pel13}\revc{2}{1}{}. Consider a simple connected graph and a subgraph on some subset of nodes $S$. The subgraph is \emph{induced} if all edges between the nodes in $S$ in the graph are also included in the subgraph. Next, the subgraph is said to be \emph{isometric} if at least one geodesic path joining each two nodes in $S$ is entirely included within $S$. Finally, the subgraph is a \emph{convex subgraph} if all geodesic paths between the nodes in $S$ are entirely included within $S$. For instance, every complete subgraph or a clique is obviously a convex subgraph. Notice that any convex subgraph is also isometric, while any isometric subgraph must necessarily be induced. For better understanding, \figref{convex} compares standard definitions of convexity for \revc{1}{1}{different mathematical objects}. In all cases, convexity of a mathematical object is defined through the inclusion of the shortest or geodesic paths between its parts. \begin{figure} \includegraphics[width=0.95\textwidth]{fig1}% \caption{\label{fig:convex}Standard definitions of convexity for different mathematical objects. (\emph{left})~Real-valued function $f(x)$ is convex if the line segment between any two points $(x_1,f(x_1))$ and $(x_2,f(x_2))$ is above or on the graph of $f$, $\forall t\in[0,1]\colon\: tf(x_1)+(1-t)f(x_2)\geq f(tx_1+(1-t)x_2)$. (\emph{middle})~Set $S\subset\mathbb{R}^2$ is convex if the line segment between any two points $x_1,x_2\in S$ lies entirely within $S$, $\forall t\in[0,1]\colon\: tx_1+(1-t)x_2\in S$. (\emph{right})~Connected subgraph induced by a subset of nodes $S$ is convex if any geodesic path between two nodes in $S$ goes exclusively through $S$ (\dfn{diamonds}). Otherwise, the subgraph is non-convex (\dfa{squares}).} \end{figure} Convex subgraphs provide an insight into the metric structure of graphs as building blocks for embedding them in simple metric spaces~\cite{Van93,BC08a,Pel13}\revc{2}{1}{}. See the two graphs shown in the left side of~\figref{examps}. The first one is a star graph representing hub-and-spokes arrangement found in airline transportation networks~\cite{Bar11b} and the Internet~\cite{GSA07a}. The second one is a bipartite graph suitable for modeling two-mode affiliation networks~\cite{DGG41} or word adjacency networks~\cite{MIKLSASA04}. From the perspective of either graph theory or network science, these two graphs would be deemed different. However, they both contain no triangles and $10$ or $9$ connected triples of nodes, which is quite similar. On the other hand, all connected triples of nodes in the first graph are convex subgraphs (\dfn{diamonds}), whereas none is convex in the second graph (\dfa{squares}). In this way, convex subgraphs are very sensitive to how they are intertwined with the rest of the graph. \begin{figure} \includegraphics[width=0.6\textwidth]{fig2}% \caption{\label{fig:examps}Pairs of different graphs with the same or similar number of induced subgraphs, but varying numbers of convex (\dfn{diamonds}) and non-convex (\dfa{squares}) subgraphs. For instance, all connected triples of nodes are convex subgraphs in the first graph of each pair.} \end{figure} One probably noticed that the two graphs differ in the number of nodes and edges. The right side of~\figref{examps} therefore shows two additional graphs that are identical up to $3$-node subgraphs.\revc{1}{1}{} Yet, the graphs are obviously different. Looking at their convex subgraphs again nicely discriminates between the two as all subgraphs in the first graph are convex. Convex subgraphs explore convexity in graphs only locally. Define the \emph{convex hull} $\conv{S}$ of a subset of nodes $S$ to be the smallest convex subgraph including $S$~\cite{HN81}. Since the intersection of convex subgraphs is also a convex subgraph, $\conv{S}$ is uniquely defined. Now the \emph{hull number} of a graph is the size of the smallest $S$ whose $\conv{S}$ is the entire graph~\cite{ES85}. This number can be interpreted as a convexity-based measure exploring the global macroscopic structure of a graph. For instance, the hull numbers of the two graphs in the left side of~\figref{examps} are $5$ and $2$, while computing the hull number of a general graph is NP-hard~\cite{DGKPS09}. The concept of convexity is by no means novel to the study of networks. Social networks literature defines a clique to be a maximal group of \revc{1}{4}{nodes} directly connected by \hl{an edge}. As such definition might be too crude for larger groups, a $k$-clique is defined as a group of \hl{nodes} at distance at most $k$~\cite{Luc50}. For $k=1$, one recovers the original definition of a clique. Finally, a $k$-clan further restricts that all geodesic paths must lie within the group~\cite{WF94}, which is precisely our understanding of convexity. Still, there is no restriction on the maximum distance $k$ in the definition of a convex subgraph. The nodes can be \revc{1}{5}{at} any distance as long as the subgraph is convex. \revc{1}{1./6}{}The analysis of small subgraphs or fragments~\cite{Bat88,EK15} in empirical networks is else known under different terms. Motifs refer to not necessarily induced subgraphs whose frequency is greater than in an appropriate random graph model~\cite{MSIKCA02}. Graphlets, however, are induced subgraphs that represent specific local patterns found in biological and other networks~\cite{PCJ04}. Small subgraphs have proven extremely useful in network comparison~\cite{MIKLSASA04,Prv07a} and, recently, for uncovering higher-order connectivity in networks~\cite{XWC16,BGL16}. Note that some of the subgraphs are convex by construction or very (un)likely to be convex under any random graph model. In this sense, the above work already provides a glimpse of convexity in complex networks. In this paper we study convexity in more general terms by asking ``What is convexity \emph{in} complex networks?''. (Similarly as a subset of a plane can be convex or not, while a plane is always convex, a subgraph can be convex or not, whereas a connected graph would always be convex. Thus, asking ``What is convexity \emph{of} complex networks?'' would make little sense.) \revc{1}{1./7}{We try to answer this question by expanding randomly grown subsets of nodes to convex subgraphs and observing their growth, and by comparing the frequency of small convex subgraphs to non-convex subgraphs. This allows us to study convexity from a global macroscopic perspective while also locally. We demonstrate several distinct forms of convexity in graphs and networks. Networks characterized by a tree-like or clique-like structure are globally convex meaning that any connected subset of nodes will likely induce a convex subgraph. This is in contrast with random graphs that are merely locally convex meaning that only subgraphs of size smaller than the average geodesic distance between the nodes are convex. Core-periphery networks are found to be regionally convex as they can be divided into a non-convex core surrounded by a convex periphery. Convexity is thus an inherent structural property of many networks that is not present in a random graph. It can be seen as an indication of uniqueness of geodesic paths in a network, which in fact unifies the structure of tree-like and clique-like networks. This property is neither captured by standard network measures nor is convexity reproduced by standard network models. We therefore propose different measures of convexity and argue for its use in the future studies of networks.} \hl{The rest of the paper is structured as follows.} In~\secref{expans}, we first study convexity from a global perspective by analyzing the expansion of convex subsets of nodes. In~\secref{freqs}, we support our findings by analyzing convexity also locally through the frequency of small convex subgraphs. \secref{measures} discusses various forms of convexity observed in graphs and networks, and proposes different measures of convexity. \secref{concs} concludes the paper with the discussion of network convexity and \hl{prominent directions for} future work. \section{\label{sec:expans}Expansion of convex subsets of nodes} We study convexity in different regular and random graphs, synthetic networks and nine empirical networks from various domains. These represent power supply lines of the western US power grid~\cite{WS98}, highways between European cities part of the E-road network in 2010~\cite{SB11d}, coauthorships between network scientists parsed from the bibliographies of two review papers in 2006~\cite{New06a}, Internet map at the level of autonomous systems reconstructed from the University of Oregon Route Views Project in 2000~\cite{LKF07}, protein-protein interactions of the nematode \emph{Caenorhabditis elegans}\xspace collected from the BioGRID repository in 2016~\cite{SBRBBT06}, connections between US airports compiled from the Bureau of Transportation Statistics data in 2010~\cite{Kun13}, citations between scientometrics papers published in \emph{Journal of Informetrics}, \emph{Scientometrics} or \emph{JASIST} between 2009-2013 as in the Web of Science database~\cite{SVW16a}, hyperlinks between weblogs on the US presidential election of 2004~\cite{AG05} and predator-prey relationships between the species of Little Rock Lake~\cite{WM00}. \begin{table}% \caption{\label{tbl:nets}\emph{Basic statistics of empirical networks studied in the paper. These show the number of nodes $n$ and edges $m$, the average node degree $\avg{k}$ and clustering coefficient $\avg{C}$, and the average geodesic distance between the nodes $\avg{\ell}$.}} \begin{tabular}{lrrrrr} \hline\hline Network & $n$ & $m$ & $\avg{k}$ & $\avg{C}$ & $\avg{\ell}$ \\\hline Western US power grid\xspace & $4941$ & $6594$ & $2.67$ & $0.08$ & $18.99$ \\ European highways\xspace & $1039$ & $1305$ & $2.51$ & $0.02$ & $18.40$ \\ Networks coauthorships\xspace & $379$ & $914$ & $4.82$ & $0.74$ & $6.04$ \\ Oregon Internet map\xspace & $767$ & $1734$ & $4.52$ & $0.29$ & $3.03$ \\ \emph{Caenorhabditis elegans}\xspace & $3747$ & $7762$ & $4.14$ & $0.06$ & $4.32$ \\ US airports connections\xspace & $1572$ & $17214$ & $21.90$ & $0.50$ & $3.12$ \\ Scientometrics citations\xspace & $1878$ & $5412$ & $5.76$ & $0.13$ & $5.52$ \\ US election weblogs\xspace & $1222$ & $16714$ & $27.36$ & $0.32$ & $2.74$ \\ Little Rock food web\xspace & $183$ & $2434$ & $26.60$ & $0.32$ & $2.15$ \\\hline\hline \end{tabular} \end{table} The networks are listed in~\tblref{nets}. Although some of the networks are directed, all are represented with simple undirected graphs and reduced to the largest connected component. \tblref{nets} also shows the basic statistics of the networks including the number of nodes $n$ and edges $m$, the average node degree $\avg{k}$, $\avg{k}=2m/n$, the average node clustering coefficient $\avg{C}$~\cite{WS98} with the clustering coefficient of node $i$ defined as $C_i = \frac{2t_i}{k_i(k_i-1)}$, where $k_i$ is the degree and $t_i$ is the number of triangles including node $i$, and the average geodesic distance between the nodes $\avg{\ell}$, $\avg{\ell}=\frac{1}{n}\sum_i\ell_i$, where $\ell_i=\frac{1}{n-1}\sum_{j\neq i}d_{ij}$ and $d_{ij}$ is the geodesic distance between the nodes $i$ and $j$ defined as the number of edges in the geodesic path. The networks are ordered roughly by decreasing average geodesic distance $\avg{\ell}$, which will become clear later on. Given a particular network or graph, we define a subset of nodes $S$ to be a \emph{convex subset} when the subgraph induced by $S$ is a convex subgraph. In what follows, we study convexity by analyzing the growth of convex subsets of nodes and observing how fast they expand. Recall the hull number defined as the size of the smallest subset $S$ whose convex hull $\conv{S}$ spans the entire network~\cite{ES85}. Since $\conv{S}$ is the smallest convex subgraph including $S$, the hull number measures how \emph{quickly} convex subsets can grow. We here take the opposite stance and analyze how \emph{slowly} randomly grown convex subsets expand. We use an algorithm for expansion of convex subsets, which we present next. We start by initializing \revc{1}{8}{a} subset $S$ with a randomly selected seed node. We then grow $S$ one node at a time and observe the evolution of its size. To ensure convexity, $S$ is expanded to the nodes of its convex hull $\conv{S}$ on each step. Every $S$ realized by the algorithm is thus a convex subset. Newly added nodes are selected among the neighbors of nodes in $S$ by following a random edge leading outside of $S$. In other words, new nodes are selected with the probability proportional to the number of neighbors they have in $S$. This ensures that $S$ is a slowly growing connected subset of nodes. An alternative approach would be to select new nodes uniformly at random from the neighboring nodes. Let $\neigh{i}$ denote the set of neighbors of node $i$. The complete algorithm for convex subset expansion is given below. \begin{enumerate} \item Select random seed node $i$ and set $S=\set{i}$. \item Until $S$ contains all nodes repeat the following: \begin{enumerate} \item Select node $i\notin S$ with probability $\propto |\neigh{i}\cap S|$. \item Expand $S$ to the nodes of $\conv{S\cup\set{i}}$. \end{enumerate} \end{enumerate} Before looking at the results, it is instructive to consider the evolution of $S$ in the first few steps of the algorithm. Initially, $S$ contains a single node $i$, $S=\set{i}$, which is a convex subset. Next, one of its neighbors $j$ is added, $S=\set{i,j}$, which is still convex. On the next step, a neighbor $k$ of say $j$ is added to $S$, $S=\set{i,j,k}$. If $k$ is also a neighbor of $i$, $S$ is a convex subset. This is expected in a network that is locally clique-like indicated by high clustering coefficient $\avg{C}>0.5$. Similarly, in a (locally) tree-like network with zero clustering coefficient $\avg{C}\approx 0$, every connected triple of nodes including $S$ is expected to be convex. In any other case, $S$ would have to be expanded with all common neighbors of $i$ and $k$, which may demand additional nodes and so on, possibly resulting in an abrupt growth of $S$. Therefore, in the early steps of the algorithm, the expansion of convex subsets quantifies the presence of locally tree-like or clique-like structure in a network. In the later steps, the algorithm explores also higher-order connectivity, whether a network is tree-like or clique-like as a whole. In the extreme case of a tree or a complete graph, every connected subset of nodes induces either a tree or a clique, which are both convex subgraphs. \figref{graphs} shows the evolution of $S$ in a randomly grown tree on $169$ nodes, triangular lattice with the side of $13$ nodes and a random graph~\cite{ER59} with $169$ nodes and the same number of edges as the lattice. The plots show the fraction of nodes $s(t)$ included in the subset $S$ at different steps $t$ of the algorithm, $t\geq 0$. Note that $t$ is the number of expansion steps (2.\ step), disregarding the initialization step (1.\ step). Hence, $s(0)=1/n$, $s(1)=2/n$ and $s(2)\geq 3/n$. In general, $s(t)\geq (t+1)/n$. \begin{figure} \includegraphics[width=0.8\textwidth]{fig3-1}\\\hskip16pt \includegraphics[width=0.2667\textwidth]{fig3-2}% \includegraphics[width=0.2667\textwidth]{fig3-3}% \includegraphics[width=0.2667\textwidth]{fig3-4}% \caption{\label{fig:graphs}Expansion of convex subsets of nodes in a randomly grown tree (\dfn{diamonds}), triangular lattice of the same size (\dfa{squares}) and the corresponding random graph (\dft{ellipses}). (\emph{top})~The fractions of nodes $s(t)$ in the growing convex subsets at different steps $t$ of our algorithm. The subsets are grown from a seed node selected uniformly at random and the most central node with the smallest geodesic distance $\ell$ to other nodes. The markers are estimates of the mean over $100$ runs, while error bars show the $99\%$ confidence intervals. (\emph{bottom})~Highlighted subgraphs show particular realizations of convex subsets grown from the most central node for $15$ steps as in the plots above. The labels of the nodes indicate the step $t$ in which they were included in the convex subset.} \end{figure} As anticipated above, convex subsets grow one node at a time in a tree graph (\dfn{diamonds} in~\figref{graphs}). Although somewhat counterintuitive, the same slow growth also occurs in a complete graph (results not shown). Relatively modest growth is observed in a triangular lattice due to its nearly clique-like structure (\dfa{squares} in~\figref{graphs}). However, in a random graph (\dft{ellipses} in~\figref{graphs}), convex subsets grow slowly only in the first few steps, due to its locally tree-like structure, upon which they expand rapidly to include all the nodes. \revc{1}{9}{}\figref{expans} shows the evolution of $S$ in empirical networks introduced in~\tblref{nets}, random graphs with the same number of nodes $n$ and edges $m$~\cite{ER59} \revc{1}{9}{and random graphs with the same node degree sequence $k_1,k_2,\dots,k_n$. These are obtained by randomly rewiring the original networks using $10m$ steps of degree preserving randomization}~\cite{MS02}\revc{1}{10}{}. For relevant comparison, we ensure that all realizations of random graphs are simple and connected. \begin{figure} \includegraphics[width=0.8\textwidth]{fig4}% \caption{\label{fig:expans}Expansion of convex subsets of nodes in empirical networks (\dfn{diamonds}), randomly rewired networks (\dfa{squares}) and the corresponding Erd{\H o}s-R{\'e}nyi random graphs (\dft{ellipses}). Plots show the fractions of nodes $s(t)$ in the growing convex subsets at different steps $t$ of our algorithm. The markers are estimates of the mean over $100$ runs, while error bars show the $99\%$ confidence intervals.} \end{figure} Notice substantial differences between the networks (\dfn{diamonds} in~\figref{expans}). Convex subsets grow almost one node at a time in the western US power grid and European highways network. These are both spatial infrastructure networks that are locally tree-like with very low clustering coefficient $\avg{C}\approx 0$. The same slow growth is also observed in the coauthorship graph that is locally clique-like with $\avg{C}=0.74$. Note that the lack of any sudden growth indicates that the structure of these networks is throughout tree-like or clique-like. In other networks, convex subsets expand relatively quickly in the early steps, whereas the growth settles after a certain fraction of nodes has been included. This occurs after including $42\%$ of the nodes in \emph{C.\ elegans}\xspace protein network, while over $83\%$ in the weblogs graph. Finally, the growth in the food web is almost instantaneous, where convex subsets expand by entire trophic levels and thus cover the network in just a couple of steps. Erd{\H o}s-R{\'e}nyi random graphs fail to reproduce the trends observed in empirical networks (\dft{ellipses} in~\figref{expans}). In the top row of~\figref{expans}, random graphs match the growth in networks only in the first few steps, due to reasons explained above, whereupon the convex subsets expand quite rapidly. The difference is most pronounced in the case of the coauthorship graph. We consider this an important finding as it shows that convexity is an inherent property of some networks. In contrast, in the bottom rows of~\figref{expans}, convex subsets initially grow faster in networks than in random graphs, while they settle already after including some finite fraction of nodes. Notice, however, that the expansion always occurs at about the same number of steps, which is best observed in the citation network. \revc{1}{9}{Randomly rewired networks} show similar trends as random graphs (\dfa{squares} in~\figref{expans}), yet the convex subsets settle much sooner. In a particular case of \emph{C.\ elegans}\xspace protein network, the growth of convex subsets seems to be entirely explained by node degrees. According to our perception of convexity, a convex network or graph is such in which every connected subset of nodes is convex. Convexity is therefore associated with extremely slow growth of convex subsets as in the spatial infrastructure networks and social coauthorship graph, whereas non-convexity can be identified by instantaneous growth as in the food web. By measuring this growth, one can analyze convexity quantitatively. We return to this in~\secref{measures}, while next, in~\secref{sizes}, we first show that the expansion of convex subsets in networks occurs when the number of steps of our algorithm exceeds the average geodesic distance between the nodes and, in~\secref{cores}, that the growth settles when the convex subsets extend to the network core. \subsection{\label{sec:sizes}Size of convex subsets of nodes} Expansion of convex subsets in empirical networks and random graphs occurs at about the same number of steps of our algorithm (see bottom row of~\figref{expans}). Below we show that this happens when the number of steps $t$ of the algorithm exceeds the average geodesic distance $\avg{\ell}$ in a network, $t>\avg{\ell}$, or an appropriate estimate for a regular or random graph. Top row of~\figref{diams} shows the evolution of convex subsets $S$ in rectangular lattices with the side of $5$ and $10$ nodes (\dfa{squares}), Erd{\H o}s-R{\'e}nyi random graphs with the number of nodes $n$ equal to $1000$ and $2500$, and the average node degree $\avg{k}$ equal to $12.5$ and $5$, respectively (\dft{ellipses}), and two empirical networks with relatively different average geodesic distance $\avg{\ell}$ (\dfn{diamonds}). These pairs of graphs and networks were specifically selected since they show distinct trends with the expansion occurring at different number of steps~$t$. \begin{figure} \includegraphics[width=0.8\textwidth]{fig5}% \caption{\label{fig:diams}Expansion of convex subsets of nodes in rectangular lattices with different number of nodes $n$ (\dfa{squares}), Erd{\H o}s-R{\'e}nyi random graphs with different $n$ but the same number of edges $m$ (\dft{ellipses}) and empirical networks with different average geodesic distance $\avg{\ell}$ (\dfn{diamonds}). (\emph{top})~The fractions of nodes $s(t)$ in the growing convex subsets at different steps $t$ of our algorithm. (\emph{middle})~The graphs of $s(t)$ with the steps $t$ rescaled by the average geodesic distance between the nodes. (\emph{bottom})~The growth of the diameter $D(t)$ of convex subgraphs at different steps $t$ shown using the rescaled variables as above. The markers are estimates of the mean over $100$ runs, while error bars show the $99\%$ confidence intervals.} \end{figure} \revc{1}{11}{The} middle row of~\figref{diams} shows the evolution of $S$ with the steps $t$ rescaled by the average geodesic distance between the nodes. We use the empirical value $\avg{\ell}$ for networks, and the analytical estimates $\sqrt{n}$ for lattices and $\ln{n}/\ln{\avg{k}}$ for random graphs~\cite{New10}. \revc{1}{12}{Notice that the expansion of convex subsets in graphs and networks occurs when the rescaled number of steps $t\ln{\avg{k}}/\ln{n}$ or $t/\avg{\ell}$, respectively, becomes larger than one.} There is a sudden transition in random graphs at $t=\ln{n}/\ln{\avg{k}}$, while the growth is much more gradual in networks and settles when $\avg{\ell}<t<2\avg{\ell}$. Similar trend is observed also in rectangular lattices. In what follows, we give a probabilistic argument for this behavior relevant for networks and graphs, while we \revc{1}{2./13}{further formalize the results} for random graphs in~\appref{sizes}. Consider a pair of nodes at the maximum geodesic distance or diameter in the subgraph induced by $S$. Let $D(t)$ be the diameter of the subgraph at step $t$ and let $d(t)$ be the geodesic distance between the mentioned nodes in the complete network or graph that is internally disjoint from $S$. Note that $S$ is a convex subset only if $d(t)>D(t)$. For $d(t)\leq D(t)$, not all geodesic paths between the mentioned nodes are included in the subgraph and the expansion of $S$ occurs. If $S$ is small enough then the average geodesic distance $\avg{\ell}$ in the network is almost identical as in the remaining network obtained after removing all the nodes in $S$ but the mentioned ones. Now assume that $D(t)\geq \avg{\ell}$. Since the mentioned nodes can be considered arbitrary in the remaining network, simply by the properties of an average $\prob{d(t) \leq D(t)}>0.5$. Hence, when the diameter of the subgraph $D(t)$ exceeds the average geodesic distance $\avg{\ell}$ in a network or an appropriate estimate for a graph, there is a significant probability that $S$ is not a convex subset and that the expansion of $S$~will~occur. Bottom row of~\figref{diams} shows the evolution of subgraph diameter $D(t)$. Due to small diameter of graphs and networks considered, $D(t)$ initially grows linearly with the number of steps $t$. In the case of rectangular lattices, every convex subset $S$ induces a rectangular sublattice with the side of the sublattice increased by one on each step $t$. It is thus easy to see that $D(t)=t$. In networks and random graphs, $D(t)\approx t$ as long as the number of steps $t$ is below the average geodesic distance $\avg{\ell}$ in a network or $\ln{n}/\ln{\avg{k}}$ in a random graph. However, when $t\geq\avg{\ell}$ or $t\geq\ln{n}/\ln{\avg{k}}$, also $D(t)\geq\avg{\ell}$ or $D(t)\geq\ln{n}/\ln{\avg{k}}$, and by the above argument the expansion of $S$ is expected to occur. Regardless of this equivalence, the expansion of convex subsets in networks and random graphs is still notably different (see middle row of~\figref{diams}). There is a sudden growth in random graphs at $t=\ln{n}/\ln{\avg{k}}$, whereas every connected subset with up to $\ln{n}/\ln{\avg{k}}$ nodes is almost certainly convex (see \revc{1}{2./13}{derivation in}~\appref{sizes}). We refer to this as \emph{local convexity}. On the other hand, networks in~\figref{diams} are not locally convex with the expansion starting already when $t<\avg{\ell}$. Furthermore, in~\secref{freqs}, we show that even the most convex infrastructure networks and coauthorship graph from the beginning of~\secref{expans} do not match the local convexity of random graphs. \subsection{\label{sec:cores}Non-convex core and convex periphery} Expansion of convex subsets in empirical networks settles after including a certain fraction of nodes (see bottom rows of~\figref{expans}). Although every run of our algorithm is of course different, convex subsets actually converge to the same subsets of nodes in these networks. More precisely, for sufficient number of runs of the algorithm, each node is included in either more than $90$-$95\%$ or less than $10$-$15\%$ of the grown convex subsets, with no node in between. Below we analyze the convex subsets grown for $15$ steps as in~\figsref{graphs}{diams} and show that these are in fact the cores of the networks. Core-periphery structure refers to a natural division of many networks into a densely connected core surrounded by a sparse disconnected periphery~\cite{BE00}. There exist different interpretations of core-periphery structure~\cite{Hol05} including those based on the $k$-core decomposition~\cite{Sei83}, blockmodeling~\cite{DBF05}, stochastic block models~\cite{ZMN15}, conductance cuts~\cite{LLDM09}, overlapping communities~\cite{YL12a} and others~\cite{RPFM14}. Formally, core-periphery structure can be defined by requiring that the probability of connection within the core is larger than between the core and the periphery, which is further larger than within the periphery. For the division into core and periphery inferred from the grown convex subsets in the Internet map and airline transportation network in~\figref{exmpls}, these probabilities are $36.8\permil$, $6.5\permil$, $0.9\permil$ and $40.4\permil$, $2.2\permil$, $0.5\permil$, respectively. \begin{figure} \includegraphics[width=0.5\textwidth]{fig6-1}% \includegraphics[width=0.5\textwidth]{fig6-2}% \caption{\label{fig:exmpls}Division of (\emph{left})~the Internet map and (\emph{right})~airline transportation network into core (\dfn{diamonds}) and periphery (\dfa{squares}). The cores are convex subsets grown for $15$ steps of our algorithm. Network layouts were computed with Large Graph Layout~\protect\cite{ADWM04}.} \end{figure} Hereafter we refer to the nodes included in at least $90\%$ of the grown convex subsets as the convexity core or c-core for short and to the remaining nodes as the periphery. Top row of~\figref{cores} shows different distributions separately for the nodes in the c-core (\dfn{diamonds}) and the periphery (\dfa{squares}). These are the distributions of node degree $k$ and the average geodesic distance to other nodes $\ell$, $\ell_i=\frac{1}{n-1}\sum_{j\neq i}d_{ij}$, for \emph{C.\ elegans}\xspace protein network, and the distribution of corrected node clustering coefficient $C^\mu$~\cite{Bat16}, where $C_i^\mu = \frac{2t_i}{k_i\mu}$ and $\mu$ is the maximum number of triangles a single edge belongs to, for airline transportation network due to low clustering of the former (see~\tblref{nets}). Notice that the nodes in the c-core have higher degrees and also clustering coefficient than peripheral nodes, while they also occupy a more central position in the network with lower geodesic distances to other nodes. Besides, network degree distribution seems to be entirely governed by the c-core, whereas the nodes in the periphery follow a different seemingly scale-free distribution. Although interesting on its own, we do not investigate this further here. \begin{figure} \includegraphics[width=0.8\textwidth]{fig7}% \caption{\label{fig:cores}Analysis of the core-periphery structure identified by our algorithm in empirical networks. (\emph{top})~The distributions of node degree $k$ and geodesic distance $\ell$ in \emph{C.\ elegans}\xspace protein network, and the distribution of corrected node clustering coefficient $C^{\mu}$ in airline transportation network, separately for the nodes in the c-core (\dfn{diamonds}) and the periphery (\dfa{squares}). (\emph{bottom})~Comparison between the c-core and the $k$-core decomposition. Plots show the fractions of nodes in the intersection of c-core and $k$-core for different $k$ relative to the size of one or the other, and the Jaccard coefficient of the two subsets. The markers are estimates of the mean over $100$ runs, while error bars show the standard~deviation.} \end{figure} Core-periphery division identified by our algorithm is compared against the $k$-core decomposition~\cite{Sei83} that gained much attention recently~\cite{BDLMG15,YDSH16,HGA16}. A $k$-core is a maximal subset of nodes in which every node is connected to at least $k$ others. It can be identified by iteratively pruning the nodes with degree less than $k$ until no such node remains~\cite{BZ11}. Since every $k$-core is a subset of a $(k-1)$-core and so on, $k$-cores form a nested decomposition of a network, with $1$-core being the set of all nodes in a connected network. Nodes in a $k$-core that are not part of a $(k+1)$-core are called a $k$-shell. Note that $k$-cores can be disconnected, which is not the case for the networks below. Bottom row of~\figref{cores} shows the fraction of nodes in the intersection of c-core and $k$-core for different $k$ relative to the number of nodes in one subset or the other. In the case of \emph{C.\ elegans}\xspace protein network, the c-core is almost entirely included within the $2$-core and contains $88\%$ of the nodes of the $2$-core and $95\%$ of the nodes of the $3$-core. In airline transportation network, the c-core best matches the $4$-core and contains $90\%$ of its nodes, while it also contains nodes from the $3$-shell and $2$-shell. On the other hand, the c-core of the Internet map shows low similarity to any $k$-core. Core-periphery structure identified by our algorithm thus differs from the $k$-core decomposition. \revc{1}{15}{According to our knowledge, this is the first study of the core-periphery structure based on the \emph{inclusion} of geodesic paths, whereas the length and number of geodesic paths has already been considered before}~\cite{Hol05,CRLP16}. We stress that despite the fact that the c-core of these networks is a convex subset by definition, a c-core is a \emph{non-convex} core surrounded by a \emph{convex} periphery according to our understanding of convexity. This is because convex subsets expand very quickly until they reach the edge of the c-core beyond which the growth settles. In other words, the c-core is the smallest convex subset including the network core. Convexity in core-periphery networks can therefore be interpreted in terms of the size of the c-core. In this sense, convex infrastructure networks from the beginning of~\secref{expans} have no \reva{1}{c-core}, while non-convex food web lacks periphery. \section{\label{sec:freqs}Frequency of small convex subgraphs} \secref{expans} explores convexity in graphs and networks from a global macroscopic perspective, while in this section we analyze convexity also locally. We study small connected induced subgraphs or graphlets in biological networks jargon~\cite{PCJ04,Prv07a} and ask whether induced subgraphs found in empirical networks are convex subgraphs. Note that this is fundamentally different from expanding subsets of nodes to convex subgraphs and observing their growth as in~\secref{expans}. We nevertheless expect networks that have proven extremely convex or non-convex in that global sense to be such also locally. We consider subgraphs $G_i$ with at most four nodes shown in~\figref{subgraphs}. Note that prior probabilities of convexity vary across subgraphs. The clique subgraphs $G_0$, $G_2$ and $G_8$ are convex by construction (\dfn{diamonds}), whereas the path subgraph $G_3$ is the least likely to be convex. The frequencies of induced subgraphs are computed with a combinatorial method \cite{HD14}, while we use our own implementation for convex~subgraphs. \begin{figure} \includegraphics[width=0.8\textwidth]{fig8}% \caption{\label{fig:subgraphs}Connected non-isomorphic subgraphs with up to four nodes. Highlighted subgraphs are convex by construction (\dfn{diamonds}), while the trivial edge subgraph $G_0$ is shown only for reasons of completeness.} \end{figure} \figref{freqs} shows the frequencies of induced (\dfa{squares}) and convex (\dfn{diamonds}) subgraphs $G_i$ in networks from~\tblref{nets}. In the case of infrastructure networks, most induced subgraphs are convex subgraphs. Similar holds for the coauthorship graph. On the contrary, only a small fraction of subgraphs is convex in the food web or the weblogs graph (mind logarithmic scales). These are precisely the networks that were identified as either particularly convex or non-convex by the expansion of convex subsets in~\figref{expans}. This confirms that convexity is an inherent property of some networks independent of the specific view taken. There are a few differences relative to before which we~discuss~below. \begin{figure} \includegraphics[width=0.8\textwidth]{fig9}% \caption{\label{fig:freqs}Frequency of small non-isomorphic subgraphs $G_i$ in empirical networks. Plots show the number of induced subgraphs $g_i$ (\dfa{squares}) and the number of these that are convex $c_i$ (\dfn{diamonds}). The subgraphs $G_i$ are listed in~\figref{subgraphs}, while the lines are merely a guide for the eye.} \end{figure} \begin{figure} \includegraphics[width=0.8\textwidth]{fig10}% \caption{\label{fig:probs}Probability of convex subgraphs $G_i$ in empirical networks $P_i$ (\dfn{diamonds}) and the corresponding Erd{\H o}s-R{\'e}nyi random graphs $\rnd{P}_i$ (\dfa{squares}). The frequencies of subgraphs $G_i$ are shown in~\figref{freqs}, while the lines are merely a guide for the eye.} \end{figure} Let $g_i$ be the number of induced subgraphs $G_i$ in a network and let $c_i$ be the number of these that are convex subgraphs. The empirical probability $P_i$ that a randomly selected subgraph $G_i$ is convex is then \begin{eqnarray} P_i & = & \frac{c_i}{g_i}. \label{eq:Pi} \end{eqnarray} In~\appref{probs}, we also derive the analytical priors $\rnd{P}_i$ that a random subgraph $G_i$ is convex in a corresponding Erd{\H o}s-R{\'e}nyi random graph. As already shown in~\secref{sizes}, random graphs are locally convex meaning that any connected subgraph with up to $\ln{n}/\ln{\avg{k}}$~nodes is expected to be convex. This includes also the subgraphs $G_i$ in all but very dense~graphs. \figref{probs} shows the empirical probabilities $P_i$ (\dfn{diamonds}) excluding those of clique subgraphs for obvious reasons. As observed above, most subgraphs are convex in the infrastructure networks with $P_i\approx 80\%$, while almost none is convex in the food web or the weblogs graph with $P_i\approx 0\%$. Notice, however, that no square subgraph $G_5$ is convex in the coauthorship graph that was previously classified as convex. Yet, only seven subgraphs $G_5$ appear in the entire network, thus a random subgraph is still more likely to be convex. Non-negligible fractions of subgraphs are convex $P_i>50\%$ also in the Internet map and \emph{C.\ elegans}\xspace protein network. Recall that both of these networks have a pronounced core-periphery structure with a relatively small c-core (see~\secref{cores}). The majority of subgraphs is thus found in the periphery which is convex. \figref{probs} shows also the prior probabilities $\rnd{P}_i$ (\dfa{squares}) that are consistently higher $\rnd{P}_i>P_i$ and tend to $100\%$ in sparse networks. Note that notably lower $\rnd{P}_i$ in airline transportation network, the weblogs graph and the food web are due to much higher density of these networks $\avg{k}>20$ (see~\tblref{nets}). In the case of all other networks, every subgraph $G_i$ is almost certainly convex in a corresponding random graph $\rnd{P}_i\approx 100\%$. Hence, even the most convex infrastructure networks do not match the local convexity of random graphs, despite being considerably more convex from a global point of view. \section{\label{sec:measures}Measures of convexity in networks} \secsref{expans}{freqs} explore convexity from a local and global perspective, and demonstrate various forms of convexity in graphs and networks (see~\figref{forms}). In contrast to other networks, convex subsets expand very slowly in tree-like infrastructure networks and clique-like collaboration graph. We refer to this as \emph{global convexity}. On the other hand, random graphs are \emph{locally convex} meaning that any small connected subgraph is almost certainly convex. Finally, core-periphery networks consist of a non-convex c-core surrounded by a convex periphery, which we denote \emph{regional convexity}. Note, however, that convex periphery is only a specific type of regional convexity. \begin{figure} \includegraphics[width=0.33\textwidth]{fig11-1}% \includegraphics[width=0.33\textwidth]{fig11-2}% \includegraphics[width=0.33\textwidth]{fig11-3}% \caption{\label{fig:forms}Expansion of convex subsets of nodes in (\emph{left})~globally convex collaboration graph, (\emph{middle})~regionally convex Internet map and (\emph{right})~locally convex random graph. Graphs show particular realizations of convex subsets grown from the most central node with the smallest geodesic distance $\ell$ to other nodes. The nodes included in the growing subsets by construction are shown with \dfn{diamonds}, while \dfa{squares} are the nodes included by expansion to convex subsets. The labels of the nodes indicate the step $t$ in which they were included, while the layouts were computed with Large Graph Layout~\protect\cite{ADWM04}.} \end{figure} In what follows, we introduce different measures of convexity in graphs and networks. In~\secref{globals}, we propose a measure called $c$-convexity suitable for assessing global and regional convexity, while, in~\secref{locals}, we propose different measures of local convexity. \subsection{\label{sec:globals}Global and regional convexity in networks} Global and regional convexity in graphs and networks can be assessed by measuring the growth of convex subsets within our algorithm presented in~\secref{expans}. Recall $s(t)$ being the fraction of nodes included in the convex subsets at step $t$ of the algorithm, $s(t)\geq (t+1)/n$, where $n$ is the number of nodes in a network. Furthermore, let $t'$ be the number of steps needed for the convex subsets to expand to the entire network, $s(t')=1$. For notational convenience, let $s(t)=1$ for every $t\geq t'$. We define the growth at step $t$ of the algorithm as $\Delta s(t)=s(t)-s(t-1)$, which is compared against the growth in an appropriate null model. A common choice is to select some random graph model in order to eliminate the effects that are merely an artifact of network density or node degree distribution~\cite{ER59,NSW01}. However, random graphs are locally convex and thus can not be used as a non-convex null model. For this reason, we rather compare networks, and also random graphs, with a fully convex graph. Such graph is a collection of cliques connected together in a tree-like manner in which the growth equals $1/n$ at each step $t$. Notice that this definition includes also a tree and a complete graph that are both convex graphs. Let $c$ be a free parameter properly explained below, $c\geq 1$. We define $c$-convexity $X_c$ of a network as the difference $\Delta s(t)-1/n$ over all steps $t$ of the algorithm, which is subtracted from one in order to get higher values in convex networks where $\Delta s(t)\approx 1/n$. Hence, \begin{eqnarray} X_c & = & 1-\sum_{t=1}^{t'}\sqrt[c]{\Delta s(t)-1/n} \nonumber \\ & = & 1-\sum_{t=1}^{t'}\sqrt[c]{s(t)-s(t-1)-1/n} \label{eq:Xc} \\ & = & 1-\sum_{t=1}^{n-1}\sqrt[c]{\max\{ s(t)-s(t-1)-1/n,\,0\,\}}. \label{eq:Xn} \end{eqnarray} For $c=1$, most of the terms of the sum in~\eqref{Xc} cancel out and $1$-convexity $X_1$ can be written as \begin{eqnarray} X_1 & = & 1-\sum_{t=1}^{t'}s(t)-s(t-1)-\frac{1}{n} \nonumber \\ & = & 1-s(t')+s(0)+\frac{t'}{n} \nonumber \\ & = & \frac{t'+1}{n}. \label{eq:X1} \end{eqnarray} $X_1$ simply measures the number of steps needed to cover the network $t'$ relative to its size $n$, $X_1\in[0,1]$. In this way, $X_1$ is an estimate of global convexity in a network. In core-periphery networks, $X_1$ can also be interpreted in terms of a non-convex c-core defined in~\secref{cores}. Let $n_c$ be the number of nodes in the network c-core and let $\avg{\ell}$ be the average distance between the nodes. Then, \begin{eqnarray} X_1 & \approx & \frac{2\avg{\ell}+1}{n}+\frac{n-n_c}{n} \nonumber \\ & = & 1-\frac{n_c-2\avg{\ell}-1}{n}, \end{eqnarray} where $2\avg{\ell}$ is approximately the number of steps needed for the convex subsets to cover the network c-core, which actually occurs at some step $\avg{\ell}<t<2\avg{\ell}$ as shown in~\secref{sizes}, and $n-n_c$ is the number of nodes in the convex periphery. In this way, $X_1$ is an estimate of regional convexity in a network. For $c>1$, $c$-convexity $X_c$ also takes into account the growth of convex subsets itself by emphasizing any superlinear growth in $s(t)$. Consequently, $X_c$ becomes negative in a network with a sudden expansion of convex subsets as it occurs in random graphs, $X_c\in(-\infty,1]$. Note that the sum in~\eqref{Xn} does not have to be computed entirely. After the growth of convex subsets settles, all subsequent terms of the sum are zero or close to zero and thus negligible even for very large networks. We approximate $X_c$ from the first $100$ terms of the sum in~\eqref{Xn}, which is sufficient for our purposes here. \begin{table}% \caption{\label{tbl:globals}\emph{Global and regional convexity in graphs and networks. Columns show $c$-convexity of empirical networks $X_c$, randomly rewired networks $\cmd{X}_{c}$ and the corresponding Erd{\H o}s-R{\'e}nyi random graphs $\rnd{X}_{c}$. The values are estimates of the mean over $100$ runs.}} \begin{tabular}{lrrrrrr} \hline\hline Network & $X_{1}$ & $\cmd{X}_{1}$ & $\rnd{X}_{1}$ & $X_{1.1}$ & $\cmd{X}_{1.1}$ & $\rnd{X}_{1.1}$ \\\hline Western US power grid\xspace & $0.95$ & $0.32$ & $0.24$ & $0.91$ & $0.10$ & $0.01$ \\ European highways\xspace & $0.66$ & $0.23$ & $0.27$ & $0.44$ & $-0.02$ & $0.06$ \\ Networks coauthorships\xspace & $0.91$ & $0.09$ & $0.06$ & $0.83$ & $-0.05$ & $-0.09$ \\ Oregon Internet map\xspace & $0.68$ & $0.36$ & $0.06$ & $0.53$ & $0.20$ & $-0.09$ \\ \emph{Caenorhabditis elegans}\xspace & $0.57$ & $0.54$ & $0.07$ & $0.43$ & $0.40$ & $-0.13$ \\ US airports connections\xspace & $0.43$ & $0.24$ & $0.00$ & $0.30$ & $0.16$ & $-0.07$ \\ Scientometrics citations\xspace & $0.24$ & $0.16$ & $0.02$ & $0.04$ & $0.00$ & $-0.13$ \\ US election weblogs\xspace & $0.17$ & $0.12$ & $0.00$ & $0.06$ & $0.04$ & $-0.08$ \\ Little Rock food web\xspace & $0.03$ & $0.03$ & $0.02$ & $-0.06$ & $-0.02$ & $-0.02$ \\\hline\hline \end{tabular} \end{table} \tblref{globals} shows $c$-convexity $X_c$ of empirical networks from~\tblref{nets}, randomly rewired networks\revc{1}{16}{} $\cmd{X}_{c}$ and the corresponding Erd{\H o}s-R{\'e}nyi random graphs $\rnd{X}_{c}$. The results confirm our observations from~\secref{expans}. $c$-convexity is much higher in networks than random graphs with $X_c>\cmd{X}_{c}>\rnd{X}_{c}$ in all cases except the food web. This is best observed in the values of $1.1$-convexity $X_{1.1}$ that are negative in random graphs $\rnd{X}_{1.1}<0$. Standard models of small-world and scale-free networks~\cite{WS98,BA99} also fail to reproduce convexity in these networks (results not shown). According to $1$-convexity $X_{1}$, most convex networks are tree-like power grid and clique-like coauthorship graph with $X_1>0.9$. Both these networks are globally convex. On the other hand, the food web is the only network that is truly non-convex with $X_{1.1}<0$. \emph{C.\ elegans}\xspace protein network represents a particular case of a regionally convex network with $X_1>0.5$ which is merely a consequence of its degree distribution $X_1\approx\cmd{X}_{1}$. Other regionally convex networks are also the Internet map and airline transportation network with $X_1\approx 0.5$. Convexity of information networks, however, is very moderate with~$X_{1.1}\approx 0$. \revc{1}{17}{The} $c$-convexity is a global measure of convexity in graphs and networks such as the hull number of a graph~\cite{ES85} introduced in~\secref{intro}. Yet, it has a number of advantages over the hull number. It is not sensitive to small perturbations, has polynomial computational complexity and also a clear interpretation in core-periphery networks. \subsection{\label{sec:locals}Local convexity in networks} Local convexity in graphs and networks can be assessed either by measuring the growth of convex subsets in the first few steps of our algorithm or by computing the probabilities of convex subgraphs as done in~\secref{freqs}. We start with the latter. As before, consider subgraphs $G_i$ with up to four nodes shown in~\figref{subgraphs}. Recall $g_i$~being the number of induced subgraphs $G_i$ in a network, $c_i$ the number of these that are convex and $P_i$ the empirical probability that a subgraph $G_i$ is convex defined in~\eqref{Pi}. The probability $P$ that a randomly selected subgraph of a network is convex is then \begin{eqnarray} P & = & \sum_i \frac{g_i}{\sum_i g_i} P_i \nonumber \\ & = & \frac{\sum_i c_i}{\sum_i g_i}. \label{eq:Pc} \end{eqnarray} Furthermore, let $\rnd{g}_i$ be the average number of induced subgraphs $G_i$ in a corresponding Erd{\H o}s-R{\'e}nyi random graph and $\rnd{P}_i$ the analytical probability that a subgraph $G_i$ is convex derived in~\appref{probs}. The probability $\rnd{P}$ that a randomly selected subgraph of a random graph is convex is then \begin{eqnarray} \rnd{P} & = & \sum_i \frac{\rnd{g}_i}{\sum_i \rnd{g}_i} \rnd{P}_i. \end{eqnarray} First two columns of~\tblref{locals} show the probability of convex subgraphs $P$ in empirical networks from~\tblref{nets} and the corresponding random graphs $\rnd{P}$. Observe that the probability is much higher in random graphs than networks with $P<\rnd{P}$ in all cases except the food web. As shown in~\secref{sizes}, random graphs are locally convex with $\rnd{P}\approx 100\%$ as long as the average distance between the nodes $\ln{n}/\ln{\avg{k}}$ is larger than the size of the subgraphs. Notice that globally convex infrastructure networks are also fairly locally convex with $P\approx 80\%$. Some local convexity $P>50\%$ is observed also in regionally convex networks such as the Internet map and \emph{C.\ elegans}\xspace protein network, where most of the subgraphs are found in the convex periphery. On the other hand, airline transportation network is not locally convex with $P\approx 0\%$, even though the network is regionally convex. However, as one can observe in~\figref{exmpls}, the periphery of airline transportation network consists of mostly pendant nodes, which is ignored by the subgraphs. \begin{table}% \caption{\label{tbl:locals}\emph{Local convexity in graphs and networks. Columns show the probability of convex subgraphs in empirical networks $P$ and the corresponding Erd{\H o}s-R{\'e}nyi random graphs $\rnd{P}$, and the maximum size of convex subsets in networks $L_c$ and graphs $\rnd{L}_{c}$. The values in brackets are the values of $L_t$ that are different from $L_1$, while last column is the analytically derived estimate of $\rnd{L}_{1}$. The values are estimates of the mean over $100$ runs.}} \begin{tabular}{lrrrrr} \hline\hline Network & $P$ & $\rnd{P}$ & $L_1$ ($L_t$) & $\rnd{L}_1$ & $\ln{n}/\ln{\avg{k}}$ \\\hline Western US power grid\xspace & $77.0\%$ & $99.4\%$ & $6$ ($14$) & $9$ & $8.66$ \\ European highways\xspace & $83.2\%$ & $97.6\%$ & $7$ ($16$) & $7$ & $7.54$ \\ Networks coauthorships\xspace & $53.3\%$ & $71.3\%$ & $7$ ($17$) & $4$ & $3.77$ \\ Oregon Internet map\xspace & $56.0\%$ & $86.4\%$ & $3$ & $4$ & $4.40$ \\ \emph{Caenorhabditis elegans}\xspace & $77.8\%$ & $97.6\%$ & $2$ & $5$ & $5.79$ \\ US airports connections\xspace & $5.5\%$ & $12.9\%$ & $2$ & $3$ & $2.38$ \\ Scientometrics citations\xspace & $30.5\%$ & $89.2\%$ & $3$ & $4$ & $4.30$ \\ US election weblogs\xspace & $2.7\%$ & $6.0\%$ & $2$ & $2$ & $2.15$ \\ Little Rock food web\xspace & $2.2\%$ & $0.3\%$ & $2$ & $2$ & $1.59$ \\\hline\hline \end{tabular} \end{table} In the remaining, we assess local convexity in graphs and networks also by measuring the growth of convex subsets in the first few steps of our algorithm from~\secref{expans}. In particular, we measure the number of steps for which the convex subsets grow one node at a time and therefore no expansion occurs. The fraction of nodes $s(t)$ included in the convex subsets at step $t$ of the algorithm must thus be $s(t)\approx (t+1)/n$. This gives an estimate of local convexity seen as the maximum size of the subsets of nodes that are still expected to be convex. Note that this is different than above where we have fixed the maximum size and also the type of subgraphs, while we grow random subsets of nodes below. We define the maximum size of convex subsets $L_c$ as \begin{eqnarray} L_c & = & 1+\max\{\,t\mid s(t)<(t+c+1)/n\,\}, \label{eq:Lc} \end{eqnarray} where $c$ is a free parameter different than in~\eqref{Xc}, $c>0$. For $c=1$, $L_1$ measures the maximum size of the subsets of nodes that on average require less than one additional node in order to be convex $s(t)<(t+2)/n$. For $c=t$, one gets a more relaxed definition $L_t$ requiring that less than one additional node needs be included for each node in the subset or, equivalently, at each step $t$ of the algorithm $s(t)<(2t+1)/n$. To account for randomness, we use the lower bound of the $99\%$ confidence interval of $s(t)$ in~\eqref{Lc}. Second two columns of~\tblref{locals} show the maximum size of convex subsets $L_c$ in empirical networks from~\tblref{nets} and the corresponding Erd{\H o}s-R{\'e}nyi random graphs $\rnd{L}_c$. Consider first the values of $L_1$ and $\rnd{L}_1$. These further confirm that random graphs are locally more convex than networks with $L_1\leq\rnd{L}_1$ in all cases except one. Notice also that $\rnd{L}_1$ well coincides with the analytical estimate for random graphs $\ln{n}/\ln{\avg{k}}$ derived in~\appref{sizes}. In regionally convex or non-convex networks, only very small subsets of nodes are expected to be convex with $L_1\leq 3$. On the contrary, much larger subsets are convex in globally convex infrastructure networks and collaboration graph with $L_1\approx 7$. Considering also the relaxed definitions $L_t$ and $\rnd{L}_t$, only three values change in~\tblref{locals}. The maximum size of convex subsets more than doubles in globally convex networks with $L_t\approx 16$, while the values remain exactly the same in all other networks $L_t=L_1$ and random graphs $\rnd{L}_t=\rnd{L}_1$. Hence, under this loose definition, globally convex networks are actually even more locally convex than random graphs. Global convexity in networks thus implies also strong local convexity. Regionally convex networks, however, are not necessarily locally convex. This is due to a specific type of regional convexity observed in networks. Although a convex periphery can cover a large majority of the nodes in a network, these are by definition disconnected and are connected only through a non-convex c-core as shown in~\secref{cores}. Therefore, one can not grow large convex subsets solely out of the nodes in the periphery. \section{\label{sec:concs}Conclusions} In this paper we have studied convexity in complex networks through mathematical definition of a convex subgraph. We explored convexity from a local and global perspective by observing the expansion of convex subsets of nodes and the frequency of convex subgraphs. We \reva{2}{have} demonstrated three distinct forms of convexity in graphs and networks. Global convexity refers to a tree-like or clique-like structure of a network in which convex subsets grow very slowly and thus any connected subset of nodes is likely to be convex. Globally convex networks are spatial infrastructure networks and social collaboration graphs. This is in contrast with random graphs~\cite{ER59}, where there is a sudden expansion of convex subsets when their size exceeds $\ln{n}/\ln{\avg{k}}$ nodes. In fact, the only network studied that is globally less convex than a random graph is the food~web. Random graphs, however, are locally convex meaning that any connected subgraph with up to $\ln{n}/\ln{\avg{k}}$ nodes is almost certainly convex. Globally convex networks are also fairly locally convex, or even more convex than random graphs under a loose definition of local convexity, whereas almost any other network studied is locally less convex than a random graph. On the other hand, most of these networks are regionally convex. Regional convexity refers to any type of heterogeneous network structure that is only partly convex. For instance, networks with core-periphery structure can be divided into a non-convex c-core surrounded by a convex periphery. Such are the Internet map, \emph{C.\ elegans}\xspace protein and airline transportation networks. Note that this type of regional convexity does not necessarily imply local convexity. This is because the nodes in convex periphery are generally disconnected and are connected only through the non-convex c-core. We have proposed different measures of local, regional and global convexity in networks. Among them, $c$-convexity can be used to assess global convexity and measures whether the structure of a network is either tree-like or clique-like, \revc{1}{18}{differently from random graphs}. There are many measures that separate networks from random graphs like the average node clustering coefficient~\cite{WS98} and network modularity~\cite{NG04}. However, these clearly distinguish between tree-like structure of infrastructure networks and clique-like structure of collaboration graphs. Yet, the two regimes are equivalent according to $c$-convexity. This is because they represent the border cases of networks with deterministic structure. The fact might be interesting since many of the results in network science are known only for tree-like or locally tree-like networks~\cite{DGM08,New10}. Convexity is thus an inherent structural property of \reva{3}{many} networks. Random graph models~\cite{ER59,NSW01} and also standard network models~\cite{WS98,BA99} fail to reproduce convexity in networks. This is not surprising as most models are based on the existence of individual edges between the nodes and not on the inclusion of the entire geodesic paths. Development of realistic models of network convexity represents an important direction for future work. The study of convexity should also be extended to directed and weighted networks, where the definition of geodesic paths changes, \revc{1}{14}{and disconnected networks, where geodesic paths are ill-defined.} Frequency of small subgraphs is often used in network comparison or alignment~\cite{Prv07a,YMDLJKSP14} and for revealing distinct classes of networks~\cite{MIKLSASA04}. While the frequency of non-induced subgraphs or motifs~\cite{MSIKCA02} must necessarily be compared against some null model, induced subgraphs or graphlets~\cite{PCJ04} are specific local structures found in networks. Moreover, convex subgraphs are special types of induced subgraphs and might as such enable even more detailed classification of networks. This could also represent an important contribution to understanding geometric properties of networks~\cite{CE16a,CE16b}. Another prominent direction for future work is to investigate convexity in the context of different mesoscopic structures observed in networks. We have studied convexity only in the case of core-periphery structure~\cite{BE00} and proposed a novel characterization of core and periphery, which might be of separate interest. However, other examples include also node communities~\cite{GN02}, overlapping communities~\cite{PDFV05}, disassortative groups~\cite{NL07}, role models~\cite{RW07} and hierarchical structure~\cite{CMN08}. \revc{1}{6}{In fact, many community detection methods adopt a definition of community that can actually be seen as an approximation of a convex subgraph}~\cite{RB08}. Network convexity is an indication of uniqueness of geodesic paths in a network. The geodesic paths are mostly unique in convex infrastructure networks due to high cost of connections, while largely redundant in a non-convex food web in order for the ecosystem to survive. Convex networks thus represent locally self-sufficient systems. As such convexity can be seen as a measure of network redundancy, a concept closely related to robustness and resilience~\cite{AJB00,Bar16}. Convexity is probably most commonly associated with its benefits in mathematical optimization~\cite{BV04a,HLB15}. For instance, many NP-complete problems in general graphs become polynomial in chordal graphs~\cite{Gav74} which can be seen as a model of convex graphs. There seems to be no good reason why such results could not be derived also for convex networks. \section*{Acknowledgments} The authors thank Tim Evans, Vladimir Batagelj, Jure Leskovec and Zoran Levnaji\'{c} for valuable comments and suggestions, and Ludo Waltman for providing citation data from the Web of Science bibliographic database. This work has been supported in part by the Slovenian Research Agency under programs P1-0297 and P2-0359.
{'timestamp': '2017-05-12T02:07:22', 'yymm': '1608', 'arxiv_id': '1608.03402', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03402'}
arxiv
\subsection*{Proof of~\Cref{#2}}} {\subsection*{Proof of~\Cref{#2} ({#1})}} \label{#2-proof} }% {} \section{Introduction}\label{intro:sec} \input{introduction.tex} \section{Why going abstract?}\label{mot:sec} \input{motivation.tex} \section{Global views as Graphs }\label{cho:sec} \input{graphs} \section{Hypergraphs of events}\label{hyper:sec} \input{hyper} \section{Semantics of Choreographies }\label{sem:sec} \input{sem} \section{Languages of Choreographies }\label{lang:sec} \input{lang} \section{Projecting on Communicating Machines}\label{proj:sec \input{cfsm} \input{proj} \section{Conclusions}\label{conc:sec} \input{conc.tex} \nocite{*} \bibliographystyle{eptcs}
{'timestamp': '2016-08-12T02:01:36', 'yymm': '1608', 'arxiv_id': '1608.03323', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03323'}
arxiv
\section{Experimental Methodology and Implementation} \label{exp} In this section we present the implementation of the MAC in a widely used, mainstream programming language, the Java language. The implementation has to take into account the transparency of parallel computation from the user's perspective and the functions that are exposed by the abstract class. The outline of the implementation is presented in Listing \ref{lst:ogc}. As shown in the operational semantics in section \ref{opr}, the default policy schedules the idle objects non-deterministically. However, there is the possibility to overload the policy using the runtime information to allow a preferential selection of the active objects. Furthermore, the current selection method presented is minimal, in the sense that it can be overloaded with different arguments to provide more selection options based on application specific requirements. \subsection{Actor Abstract Class} \par The Java module creates an abstract class, \textbf{Actor}, that provides a runtime system for queuing and activation of messages. It exposes two methods to the outside world for interaction, namely \textit{send(Object message)} and \textit{getNewWorker(Object... parameters)}. This layout is used to allow a clear separation between internal object selection, message delivery and execution. This class is the mediator between the outside applications and the active objects defined by the internal interface \textbf{ActiveObject}. These Active Objects will be assigned execution of the requests sent to the actor. Our abstract class contains a queue of \textit{availableWorkers} and a set of \textit{busyWorkers} separating those objects that are idle from those that have been assigned a request. Parallel execution and control is ensured through a specific Java Fork Join Pool \textit{mainExecutor} that handles the invocations assigned to the internal objects and is optimized for small tasks executing in parallel. The class uses a special queue, named \textit{messageQueue}, that is independent of the thread execution. It is used to store incoming messages and model the \textbf{shared queue} of the group. This message queue is initialized with a comparator(ordering function) that selects the first available message according to the rule \texttt{(SCHED-MSG)} specified in Section \ref{opr}. To use this abstract class as a specific model, it needs to be extended by each interface defined in our language in order to be initialized as an Actor. \par The default behavior of the exposed method \textit{getNewWorker(Object... parameters)} is to select a worker from the \textit{availableWorkers} queue. The workers are inserted in a first-in-first-out(FIFO) order with a blocking message delivery if there is no available worker (i.e. the \textit{availableWorkers} queue is empty). While the behavior of this method is hidden from the user, it needs to be exposed such that the user has a clear view of the selection, before sending a request. The second exposed function, \textit{send(Object message, Set\texttt{<}Object\texttt{>} data}, takes the first argument in the form of a lambda expression, that models the request. The format of the lambda expression must be \begin{verbatim} () -> ( getNewWorker() ).m() \end{verbatim} The second argument specifies a set of objects that the method \textit{m()} needs to lock and maintain data consistency on. Therefore when a request is made for a method \textit{m()} the runtime system must also select an \textit{Active Object} from the \textit{availableWorkers} queue to be assigned the request, as well a set of data that needs concurrency control. Execution is then forwarded to the \textit{mainExecutor} which returns a Java Future to the user for synchronization with the rest of the application outside the actor. The selection of the \textit{ActiveObject} is important to form the lambda expression that saves the application from having a significant number of suspended threads if the set of data that is required is locked. \par The application outside of the Actor sends requests asynchronously and must be free to continue execution regardless of the completion of the request. To this end we provide the class \textbf{Message} illustrated in Listing \ref{lst:mess} which creates an object from the arguments of the \textit{send} method and initializes a future from the lambda expression. \lstinputlisting[float=!ht,caption={Message Class in Java}\label{lst:mess},language=Java,basicstyle=\fontsize{7}{9}\selectfont, frame=single, tabsize=4]{Message.java} This class contains the specific parts of a message which are the \textit{lambdaExpression}, the \textit{syncData} on which the request need exclusive access and the Future \textit{f} which captures the result of the request. To maintain a temporal order on messages synchronize on the same messages the class also contains a static field \textit{queuePriority} which determines a new message's \textit{priority} upon creation and insertion in the queue. \par The Actor runs as a process that receives requests and runs them in parallel while maintaining data-consistency throughout its lifetime. The abstraction is data-oriented as it is a stateful object maintaining records of all the data that its workers are processing. It contains a set of \textit{busyData} specifying which objects are currently locked by the running active objects. An internal method, named \textit{reportSynchronizedData} is defined to determine if a set of data corresponding to a possible candidate message for execution is intersecting with the current set of \textit{busyData}. This method is used as part of the comparator defined in the \textit{messageQueue} to order the messages based on their availability. The main process running the Actor is then responsible to take the message at the head of the queue and schedule it for execution and add the data locked by the message to the set of \textit{busyData}. It is possible that at some point during execution, all messages present in the \textit{messagesQueue} are not able to execute due to their data being locked by the requests that are currently executing. To ensure that our Actor does not busy-wait, we forward all the messages into a \textit{lockedQueue} such that the Actor thread suspends. \par The Actor is a solution that makes parallel computation transparent to the user through the internal class implementation of its worker actors. These objects are synchronized and can undertake one assignment at a time. Each request may have a set of synchronized variable to which it has exclusive access while executing. At the end of the execution, the active object calls the \textit{freeWorker(ActiveObject worker, Object ... data)} method that removes itself from the \textit{busyWorkers} set and becomes available again by inserting itself in the \textit{availableWorkers} queue. At this point, the \textit{lockedQueue} is flushed into the \textit{messageQueue} such that all previously locked messages may be checked as candidates for running again. All of the objects that were locked by this ActiveObject are also passed to this method such that they can be removed from the \textit{busyData} set and possibly release existing messages in the newly filled \textit{messageQueue} for execution. This control flow is illustrated in an example in the next section, however our motivation is to modify this module into an API and use it as a basis for a compiler from the modeling language to Java. \subsection{Service Example and Analysis} \par Listing \ref{lst:bank} shows the implementation of a \textbf{Bank} service as an \textbf{Actor}. As a default behavior, whenever a new concrete extension of an Actor is made, the constructor or the \textit{addWorkers} method may create one or more instances of the internal Active Object. \lstinputlisting[float=h,caption={Bank Class in Java}\label{lst:bank},language=Java,basicstyle=\fontsize{7}{7}\selectfont, frame=single, tabsize=4]{Bank.java} The behavior of \textit{getNewWorker(Object... parameters)} is overridden to ensure the return of a specific internal Active Object with exposed methods, in this case the \textbf{BankEmployee}. This internal class implements the general \textit{Active Object} interface and exposes a few simple methods of a general Bank Service. The methods \textit{withdraw, deposit, transfer} and \textit{checkSavings} all perform their respective operations on one or more references of the internal class Account a reference which is made available through the method \textit{createAccount}. The MAC behavior is inherited from the Actor and only the specific banking operations are implemented. \par To test the functionality, as well as the performance of the MAC we implement a simple scenario that creates a fixed number of users each operating on their own bank account. We issue between 100 and 1 million requests distributed evenly over the fixed number of accounts. To ensure that some messages have to respect a temporal order and forced await execution of prior requests on the same account we issue sets of 10 calls for each account. This also ensures that the selection rule \texttt{(SCHED-MSG)} does not become too large of a bottleneck as in the case of issuing all operations for one bank account at a time. We measure the time taken to process the requests based on a varying number of Active Objects inside in the \textbf{Bank} Service. The performance figures for a MAC with 1,2 and 4 available \textit{Active Objects} is presented in Figure \ref{fig:time} \begin{figure}[!ht] \centering \begin{minipage}{.99\textwidth} \centering \includegraphics[scale=0.4]{time.png} \caption{Performance Times for processing 100-1M messages} \label{fig:time} \end{minipage} \begin{minipage}{.99\textwidth} \centering \includegraphics[scale=0.4]{throughput.png} \caption{Throughput for processing 1M messages} \label{fig:th} \end{minipage} \end{figure} The results validate our solution in the sense that the time:message ratio is almost linear with very little overhead introduced by the message format and the selection function. Furthermore the benefit of parallelism is maintained with the increasing volume of request issued to the service. To emphasize this we computed the throughput of the service in relation to the number of \textit{Active Objects} running and present it in Figure \ref{fig:th}. From these results we can infer the scalability of the MAC for parallel computation. \lstinputlisting[float=!ht,caption={Actor Abstract Class in Java}\label{lst:ogc},language=Java,basicstyle=\fontsize{7}{8}\selectfont, frame=single, tabsize=4]{Jelly.java} \section{Introduction} Object-oriented programs organize data and corresponding operations by means of a hierarchical structure of classes. A class can be dynamically instantiated and as such extends the concept of a module. Operations are performed by corresponding method calls on class instances, namely objects. In most object-oriented languages, like Java, method calls are executed by a thread of control which gives rise to a stack of call frames. In a distributed setting, where objects are instantiated over different machines, remote method calls involve a \emph{synchronous rendez-vous} between caller and callee. It is generally recognized that \emph{asynchronous} communication is better suited for distributed applications. In the Actor-based programming model of concurrency \cite{Agha90} actors communicate via asynchronous messages. In an object-oriented setting such a message specifies a method of the callee and includes the corresponding actual parameters. Messages in general are queued and trigger execution of the body of the specified method by the callee, when dequeued. The caller object proceeds with its own execution and may synchronize on the return value by means of \emph{futures} \cite{BoerCJ07}. In \cite{SchaferP10} JCoBox, a Java extension with an actor-like concurrency model based on the notion of concurrently running object groups, the concept of coboxes is introduced which integrates thread-based synchronous method calls with asynchronous communication of messages in a \emph{Global Asynchronous, Local Synchronous (GALS)} manner. More specifically, synchronous communication of method calls is restricted to objects belonging to the same cobox. Objects belonging to the same cobox share control, consequently within a cobox at most one thread of synchronous method calls is executing. Only objects belonging to different coboxes can communicate via asynchronous messages. Instead of sharing control, in this paper we introduce an Actor-based language which features new programming abstractions for parallel processing of messages. The basic distinction the language supports is that between the instantiation of an Actor class which gives rise to the initialization of a group of active objects sharing a queue and that which adds a new active object to an existing group. Such a group of active objects sharing a message queue constitutes a multi-threaded actor which features the parallel processing of its messages. The distinction between actors and active objects is reflected by the type system which includes an explicit type for actors and which is used to restrict the communication between actors to asynchronous method calls. In contrast to the concept of a cobox, a group of active objects sharing a queue has its own distinct identity (which coincides with the initial active object). This distinction further allows, by means of simple typing rules, to restrict the communication between active objects to synchronous method calls. When an active object fetches a message from the shared message queue, the object starts executing a corresponding thread in parallel with all the other threads. This basic mechanism gives rise to the new programming concept of a \emph{Multi-threaded Actor (MAC)} which provides a powerful Actor-based abstraction of the notion of a \emph{thread pool}, as for example, implemented by the Java library \emph{java.util.concurrent.ExecutorService}. We further extend the concept of a MAC with a powerful high-level concept of synchronized data to constrain the parallel execution of messages. In this paper we provide a formal operational semantics like Plotkin \cite{Plotkin04a}, and a description of a Java-based implementation for the basic programming abstractions describing sharing of message queues between active objects. The proposed run-time system is based on the ExecutorService interface and the use of \emph{lambda expressions} in the implementation of asynchronous execution and messaging. \paragraph{Related work} Since Agha introduced in \cite{Agha90} the basic Actor model of concurrent computation in distributed systems, a great variety of Actor-based programming languages have been developed. In most of these languages, e.g., Scala \cite{Haller2009202}, Creol \cite{JohnsenO07}, ABS \cite{johnsen10fmco}, JCoBox \cite{SchaferP10}, Encore \cite{brandauer2015parallel}, ProActive \cite{Caromel08}, AmbientTalk \cite{MBDM07}, Rebeca \cite{Sirjani06}, actors execute messages stored in their own message queue. The Akka library for Actor-based programming however does support sharing of message queues between actors. In this paper we introduce a new corresponding Actor-based programming abstraction which integrates a thread-based execution of messages with event-based asynchronous message passing. Our work complements in a natural manner that of \cite{SchaferP10} which introduces groups of actors sharing control. Another approach to extending the Actor-based concurrency model is that of Multi-threaded active objects (MAO) \cite{henrio2013multi} and Parallel Actor Monitors (PAM) \cite{ScholliersTM14} which allow the parallel execution of the different method invocations within an actor. Another approach is followed in the language Encore which provides an explicit construct for describing parallelism within the execution of one method \cite{part2016}. In contrast to these languages, we do allow the parallel execution of different asynchronous method invocation inside a group of active objects which provides an overall functionality as that of an actor, e.g., it supports an interface for asynchronous method calls and a unique identity. Further we provide a new high-level language construct for specifying that certain parameters of a method are \textit{synchronized}, which allows a fine-grained parameter-based scheduling of messages. In contrast, the more coarse-grained standard scheduling of methods as provided by Java, PAM, and MAO, and JAC \cite{haustein2006jac} in general only specify which methods can run in parallel independent of the actual parameters. \cite{williams2001method} also shows the notion of Microsoft COM (Component Object Model)'s multi-threaded apartment. In this model, calls to methods of objects in the multi-threaded apartment can be run on any thread in the apartment. It however lacks the ability of setting scheduling strategies (e.g. partial order of incoming messages in the next section). Multi-threaded actors offer a higher level of abstraction to parallel programming and can be viewed as similar to the OpenMP \cite{dagum1998openmp} specification for parallel programming in C, C++ and Fortran. \par The rest of this paper is organized as follows: In section \ref{mot}, an application example is established, by which we introduce the key features of MAC. Section \ref{syn} describes the syntax of MAC and the type system. Section \ref{opr} presents the operational semantics. In Section \ref{exp} we show the implementation of MAC in the Java language and explain its features through an example. We draw some conclusions in Section \ref{concl} where we briefly discuss extensions and variations describing static group interfaces, support for the cooperative scheduling of the method invocations within an actor (as described in for example \cite{JohnsenO07}), synchronization between the threads of a MAC, and encapsulation of the active objects belonging to the same actor. \section{Conclusion and Future Work} \label{concl} In this paper we have introduced the notion of multi-threaded actors, that is, an actor-based programming abstraction which allows to model an actor as a group of active objects which share a message queue. Encapsulation of the active objects which share a queue can be obtained by simply not allowing active objects to be passed around in asynchronous messages. Cooperative scheduling of the method invocations within an active object (as described in for example \cite{JohnsenO07}), can be obtained by introduction of a lock for each active object. In general, synchronization mechanisms between threads is an orthogonal issue and as such can be easily integrated, e.g., lock on objects, synchronized methods (with reentrance), or even synchronization by the compatibility relationship between methods as defined in \cite{haustein2006jac} and \cite{henrio2013multi}. Other extensions and variations describing dynamic group interfaces can be considered along the lines of \cite{Johnsen2016}. Future work will be dedicated toward the development of the compiler which allows importing Java libraries, and further development of the runtime system, as well as benchmarking on the performance. Other work of interest is to investigate into dynamic interfaces for the multi-threaded actors and programming abstractions for application-specific scheduling of multi-threaded actors. \nocite{*} \bibliographystyle{eptcs} \section{Motivating Example}\label{mot} In this section, we explain an example which is used in the rest of the paper to show the notion of MAC. We also raise a challenge regarding this example which is solved later in our proposed solution. We present a simple concurrent bank service where the requests such as withdrawal, checking, and transferring credit on bank accounts are supported. The requests can be submitted in parallel by several clients of the bank. The system should respect the temporal order of the submitted requests on the same accounts. For instance, checking the credit of an account should return the amount of credit for the account after withdrawal, if there is a withdrawal request for that account which precedes the check request. The requests can be sent asynchronously. Therefore, respecting temporal order of two events means that there is a happens-before relation between termination of the execution of the former event and starting the execution of the latter. Existing technologies are either not able to implement this property or they need ad-hoc explicit synchronization mechanism which can be complicated and erroneous. Using locks on accounts (e.g. \textit{synchronized} block in Java) may cause deadlock or violate the ordering, unless managed explicitly at the lower level, since two accounts are involved in transferring credit. Another approach is to implement the scheduler in PAM \cite{ScholliersTM14} to support such ordering which raises synchronization complexities. The last alternative we investigate in this section is that to implement the service as a thread pool (e.g. ExecutorService in Java), where the above ordering is respected explicitly via passing the \textit{future} variable corresponding to the previous task, to the current one. The variable is then used to force the happens-before relation by suspending the process until the future is resolved (e.g. \textit{get} method in Java). One challenge is that the approach requires that the submitter knows and has access to the future variables associated to the previous task (or tasks in case the task being submitted is a \textit{transfer}). The other challenge is that, in a parallel setting with multiple concurrent source of task submitters, how to provide such knowledge. Last but not least, the approach first activates the task by allocating a thread and then the task may be blocked which imposes overhead, while a desirable solution forces the ordering upon the task activation. As shown in the rest of the paper, we provide the notion of MAC which overcomes this issue only via annotating the parameters based on which we aim to respect the temporal order. \section{Operational Semantics}\label{opr} \paragraph{Runtime concepts} We assume given an infinite set of active object and future references, with typical element $o$ and $f$, respectively. We assume distinguished fields \textit{myactor}, \textit{I}, and \textit{L} which denote the identity of the actor, the type of the active object, and the set of pairs of synchronized entries locked by the active object, respectively. A local environment $\tau$ assigns values to the local variables (which includes the distinguished variables \textit{this} and \textit{dest}, where the latter is used to store the future reference of the return value). A closure $c=(\tau,s)$ consists of a local environment $\tau$ and a statement $s$. A thread $t$ is a sequence (i.e., a stack) of closures. A process $p$ of the form $(o, t)$ is a runtime representation of an active object $o$ with an active thread $t$. An actor $a$ denotes a pair $(o,P)$ consisting of an object reference $o$, uniquely identifying the actor as a group of active objects, and a set of processes $P$. A set $A$ denotes a set of actors. By $e$ we denote an event $m(\bar{v})$ which corresponds to an asynchronous method call with the method name $m$ and values $\overline{v}$. For notational convenience, we simply assume that each event also includes information about the method signature. A queue $q$ is a sequence of events. A (global) context $\gamma$ consists of the following (partial) functions: $\gamma_{h}$, which denotes for each existing object its local state, that is, an assignment of values to its fields; $\gamma_q$, which denotes for each existing object identifying an actor its queue of events, and, finally, $\gamma_f$, which assigns to each existing future its value ($\perp$, in case it is undefined). \paragraph{Some auxiliary functions and notations.} By $\gamma[o\leftarrow \sigma]$ we denote the assignment of the local state $\sigma$, which assigns values to the fields of $o$, to the object $o$ (affecting $\gamma_h$); by $\gamma[o.x\leftarrow v]$ we denote the assignment of the value $v$ to the field $x$ of object $o$ (affecting $\gamma_h$); by $\gamma[o\leftarrow q]$ we denote the assignment of the queue of events $q$ to the object reference $o$ (affecting $\gamma_q$); and, finally, by $\gamma[f\leftarrow v]$ we denote the assignment of value $v$ to the future $f$ (affecting $\gamma_f$). By $\textit{act-dom}(\gamma)$ and $\textit{fut-dom}(\gamma)$ we denote the actors and futures specified by the context $\gamma$. We assume the evaluation function $val_{\gamma,\tau}(e)$. The function $\textit{sync-call}(o, m, \overline{v})$ generates the closure corresponding to a call to the method $m$ of the actor $o$ with the values $\overline{v}$ of the actual parameters. The function $\textit{async-call}(o,m, \overline{v})$ returns the closure corresponding to the message $m(\overline{v})$, where $\bar{v}$ includes the future generated by the corresponding call (which will be assigned to the local variable \textit{dest}), $o$ denotes the active object which has been scheduled to execute this method. In both cases we simply assume that the class name can be extracted from the identity $o$ of the active object (to retrieve the method body). The function $\textit{init-act}(o, \overline{v}, o')$ returns the initial state of the new active object $o$. The additional parameter $o'$ denotes the the actor identity which contains $o$, which is used to initialize the field $myactor$ of $o$. The function $\textit{sg}(m(\overline{v}))$ returns the signature of the event $m(\overline{v})$. Finally, $sync_m(\bar{v})$ returns the synchronized arguments of event $m(\bar{v})$ together with their locks (i.e., the arguments specified by \textbf{sync}\texttt{<}$l$\texttt{>} modifier in the syntax where \textit{l} is the lock). \input{os2} \section{Syntax of MAC} \label{syn} Figure \ref{syntax} specifies the syntax. A \emph{MAC} program \emph{P} defines interfaces and classes, and a main statement. An interface \emph{IF} has a name \emph{I} and method signatures \emph{Sg}. A class \emph{CL} has a name \emph{C}, interfaces $\overline{I}$ that \emph{C} implements (that specify the possible types for its instances), formal parameters and attributes $\overline{x}$ of type $\overline{T}$, and methods $\overline{M}$. A multi-threaded actor consisting of a group of active objects (a MAC) which share a queue of messages of type $I$ is denoted by \textbf{Actor}\texttt{<}I\texttt{>}. The type \textbf{Fut}\texttt{<}T\texttt{>} denotes futures which store return values of type $T$. The \emph{fields} of the class consist of both its parameters and its attributes. A method signature \emph{Sg} declares a method with name \emph{m} and the formal parameters $\overline{x}$ of types $\overline{T}$ with optional \textbf{sync}\texttt{<}l\texttt{>} modifier which is used to indicate that the corresponding parameter contains synchronized data. The user-defined label l allows to introduce different locks for the same data type. Informally, a message which consists of such synchronized data can only be activated if the specified data has not been locked. \begin{figure}[h] \begin{align*} T::=\ &\ \text{Bool}\ |\ I\ |\ \textbf{Actor}\texttt{<}I\texttt{>}\ |\ \textbf{Fut}\texttt{<}T\texttt{>} \\ P::=\ &\overline{IF}\ \overline{CL}\ \{\overline{T}\ \overline{x}; s\}\\ CL::=\ &\textbf{class}\ C [(\overline{T}\ \overline{x})]\ \textbf{implements}\ \overline{I} \{\overline{T}\ \overline{x}; \overline{M}\}\\ IF::=\ &\textbf{interface}\ I \{\overline{Sg}\}\\ Sg::=\ &\overline{[\textbf{sync}\texttt{<}l\texttt{>}]}\ T\ m(\overline{[\textbf{sync}\texttt{<}l\texttt{>}]}\ \overline{T}\ \overline{x})\\ M::=\ &Sg\{\overline{T}\ \overline{x}; s\}\\ s::=\ &\ x=e\ |\ s;s\ |\ e.\textbf{get}\ |\ \textbf{if}\ b\{s_1\}\textbf{else}\{s_2\}\ |\ \textbf{while}\ b\{s\}\\ e::=\ &\textbf{null}\ |\ b\ | \ x\ |\ \textbf{this}\ |\ \textbf{new }[\textbf{actor}]\ C[(\overline{e})]\ |\ e.m(\overline{e})\ |\ e!m(\overline{e})\\ b::=\ &e?\ |\ b\ |\ b\land b\\ \end{align*} \caption{Syntax}\label{syntax} \end{figure} Statements have access to the local variables and the fields of the enclosing class. Statements are standard for sequential composition, assignment, \textbf{if} and \textbf{while} constructs. The statement $e.\textbf{get}$, where $e$ is a future variable, blocks the current thread until $x$ stores the return value. Evaluation of a right-hand side expression \textbf{new} \emph{C}($\overline{e}$) returns a reference to a new active object within the same group of the executing object, whereas \textbf{new actor} \emph{C}($\overline{e}$) returns a reference to a new actor which forms a new group of active objects. By $e.m(\overline{e})$ we denote a synchronous method call. Here $e$ is assumed to denote an active object, i.e., $e$ is an expression of some type $I$, whereas $e!m(\overline{e})$ denotes an asynchronous method call on an actor $e$, i.e., $e$ is of some type \textbf{Actor}\texttt{<}I\texttt{>}. Listing \ref{lst:syn} contains an example of an actor $bank$ which implements a bank service. The services provided by a bank are specified by the interface \texttt{IEmployee} which is implemented by the class \texttt{Employee}. A bank is created by a statement \texttt{Actor <IEmployee> bank = new actor Employee()}. New employees can be created on the fly by the addEmp method. The actual data of the bank is represented by the instances of the class \texttt{Account} which implements the interface \texttt{IAccount} and which contains the actual methods for transferring credit, checking and withdrawal. A simple scenario is the following: \begin{lstlisting}[language=Java, basicstyle=\fontsize{9}{10}\selectfont] (1) Fut<Int> f = bank!createAcc(...); (2) Int acc1 = f.get; (3) Fut<Bool> f3 = bank!withdraw(acc1, 50); (4) Fut<Int> f2 = bank!check(acc1); \end{lstlisting} Line 1 models a request to create an account by an asynchronous method call. The result of this call is a number of the newly created account. Lines 3 and 4 then describe a withdrawal operation followed by a check on this account by means of corresponding asynchronous method calls. These calls are stored in the message queue of the actor $bank$ and dispatched for execution by its empoyees, thus allowing a parallel processing of these requests. However, in this particular scenario such a parallel processing of requests involving the same account clearly may give rise to inconsistent results. For example a main challenge in this setting arises how to ensure that the messages are \emph{activated} in the right order, i.e., the order in which they have been queued. Note that the \emph{execution} of messages can be synchronized by means of standard synchronization mechanisms, e.g., synchronized methods in Java. Another approach is to use transactional memory to recover from inconsistent states. However both approaches do not guarantee in general that the messages are activated in the right order because they do not provide direct control of their {activation}. By declaring in Listing \ref{lst:syn} all the parameters of the methods of the interface \texttt{IEmployee} which involve account numbers as synchronized by means of a single lock ''a'' we ensure mutual exclusive access to the corresponding accounts. More specifically, the selection for execution of a queued message which contains a request to {withdraw} a certain amount for a specified account, for example, requires that (1) no employee is currently holding the lock ''a'' on that account and (2) no preceding message in the queue requires the lock ''a'' on that account. Similarly, a message which contains a transfer request, which involves two accounts, requires that (1) no employee is currently holding the lock ''a'' on one of the specified accounts and (2) no preceding message in the queue requires the lock ''a'' on one of these accounts. The formal details of this synchronization mechanism is described in the following section. \lstinputlisting[caption={Syntax Example}\label{lst:syn},language=Java,frame=single,basicstyle=\fontsize{8}{9}\selectfont]{syntax.mag}
{'timestamp': '2016-08-12T02:01:36', 'yymm': '1608', 'arxiv_id': '1608.03322', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03322'}
arxiv
\section{Introduction} Since 1984, the Bureau of Labor Statistics (BLS) has served as the principal Federal agency responsible for measuring labor market activity, working conditions, and price changes in the economy. Data collected by the BLS can be sorted into four categories: Prices (e.g. Consumer Price Index), employment and unemployment, compensation and working conditions, and productivity. This data is collected via surveys designed by economists and statisticians to acquire information regarding demographic and industrial statistics, which are then released in a report to the public. Results of the surveys are compiled in the \textit{Employment Situation Report}. This critical, monthly assessment of the state of labor in the United States is released by the Bureau of Labor Statistics (BLS) at 8:30 AM on the first Friday of the month. The ``Jobs Report'', as it is popularly called, is based on the Current Population Survey, which surveys individual households and the Current Employment Statistics Survey, which surveys employers. Together, these two surveys give a snapshot of the number of employed and unemployed Americans, how many hours they are working, and a variety of other facts and figures. Recently, for example, data from this report was used to measure economic and political solutions to the 2008 downturn, as well as the performance of politicians themselves during that time. As a result of such insights, news media widely publicizes the upcoming release of the report each month and follows the publication with widespread analyses and critiques. The report is more recently being used as a forecasting tool by firms on Wall Street, largely because the report is an indicator of investor and employer confidence in the economy \cite{mahorney_what_2013}. The report is delivered on the BLS website in both PDF and HTML format, comprised mostly of text and tabular information and is well suited for deep study rather than rapid analysis. Because of the report's forecasting power and journalistic impact, a holistic interpretation of the report's information is essential; however, the current format does not lend itself well to the quick derivation of insights. Moreover, the report is not as easily accessible to a general audience, favoring economic language and measurements. A visual analytics methodology \cite{keim_mastering_2010} using information visualization techniques could benefit the \textit{Employment Situation Report}, allowing for swift interpretation of the current employment situation in the United States. In order to assess the comprehensibility and utility of their website, the BLS, characteristically, conducts a survey on customer satisfaction. Figure \ref{CustSat} provides the customer satisfaction results from July 1, 2009 - June, 30 2011. The average satisfaction level was 75, which implies that the website has room for improvement. Our work aims to increase customer satisfaction and provide a more satisfying and dynamic experience for the data-seeking users. We gather data contained in thousands of tables and present it so that is easily navigable and enables users conduct visual analytic exploration of the dataset. The tools presented here were designed to be easy to use, visually clear, and capable of evoking insights by users. It is the designer's job to manipulate the perception, cognition, and communicative intent of a visualization \cite{agrawala2011design} by understanding the principles that make for a good design. Producing a ``friendly data graphic'' \cite{tufte1983visual} requires the designers to include a balance of useful features while also remaining aesthetically pleasing and not overwhelming to users. Well-chosen colors \cite{macdonald1999using}, fonts \cite{moere2011role}, and transitions \cite{heer2007animated} have been shown to affect usability of a visualization and have been strategically considered in the present work. The combination of computer analytical processes with the human ability to quickly understand patterns leads to a reasoning system of discovery through interaction \cite{green_visual_2008}. This work focuses on compiling and arranging the tabular BLS data into an easily navigable interface that allows users to see trends in the data, from which to potentially draw immediate insights. The goal of these interactive visualization tools is to significantly improve the user interface of the current BLS website and benefit the entire labor statistics community. \begin{figure}[t] \centering \includegraphics[width=0.9\textwidth]{figures/BLSSurvey_ppt.png} \caption{BLS customer satisfaction survey for July, 1 2009 - June, 30 2011.} \label{CustSat} \end{figure} \section{The BLS Data Pipeline} The Jobs Report is released monthly based primarily on two national surveys: the Current Population Survey and the Current Employment Statistics Survey. Data was also ingested from state and metropolitan surveys: the Local Area Unemployment Statistics survey and Current Employment Statistics for State and Metropolitan economic divisions. Using these data sources created a unique challenge for a visual analytics data product - the system had to be able to adapt and acquire new information automatically, and to display important headlines on demand. Our initial architecture therefore relied on the ``data science pipeline'' \cite{ojeda_practical_2014}, an analytical framework, which includes preparatory analytical steps of ingestion, wrangling, storage, and pre-computation. Inferential and modeling statistical methods were replaced with visual analysis. The resulting ``BLS Data Pipeline'' is described by Figure~\ref{fig:pipline}. The ingestion component utilized the BLS API to download individual time series, which then had to be wrangled to normalize the data and input missing values for storage. Initial computations were then run on the data set to generate other data sources (e.g. percent change over time). The data storage then powered an interactive API that was utilized by our visual front-end. \begin{figure}[!h] \centering \includegraphics[width=0.9\textwidth]{figures/pipeline.png} \caption{The BLS data pipeline, a model for combining monthly data ingestion with a visual analytics workflow.}~\label{fig:pipline} \end{figure} \subsection{Data Sources} The Bureau of Labor Statistics provides an expansive amount of data gathered by surveys conducted by various organizations of the United States Department of Labor. Several separate surveys, including the Current Population Survey, the Current Employment Statistics Survey, and the Local Area Unemployment Statistics Survey constitute the information that is used in our application to explore the employment situation of the United States at both the national and state levels. Each of these data sources adds dimensions to a variety of visual analyses, and when contextualized together provides the best possible opportunity for insight discovery. The primary data source for the Jobs Report is the Current Population Survey (CPS) \cite{_labor_????}, which is a monthly survey of households. This survey focuses on the relationship between demographics and employment and, at the national scale, provides a comprehensive data set on the labor force, unemployment, earnings, hours of work, and other labor characteristics. This survey gathers demographic statistics like gender, age, education level, and ethnicity. A secondary source for the Jobs report, the Current Employment Statistics Survey (CES) surveys employers rather than households for labor force information \cite{_current_2015}. The CES survey is not only national, but also provides granular data for state and metropolitan geographies as well. In the application presented here, national and local CES surveys are differentiated with the acronyms CES and CESSM, respectively. This survey focuses on industry-specific details of employment, hours, payroll, and earnings and is useful as a classification for different labor categories rather than demographics. Finally, the Local Area Unemployment Statistics Survey (LAUS) fills in local regional information that relates demographic information to employment where the CPS only describes the national level \cite{_local_2015}. LAUS provides monthly employment, unemployment, and labor force data by census divisions that include states, counties, metropolitan areas, and many cities. Because LAUS is a household survey (by place of residence) the employment characteristics can give a much more focused view of how demographic trends influence employment at the local level. Finally, datasets can be grouped by a variety of dimensions. The employment dimensions include ``employment'', ``unemployment'', ``unemployment rate'', and ``labor force''. CES dimensions included industry descriptions like ``Mining and Construction'', whereas CPS and LAUS focused on demographic dimensions like age, gender, ethnicity, or level of education. Geographic dimensions had to be included for the CESSM and LAUS data sets, ordered by both U.S. Census economic divisions as well as by state. \subsection{Data Ingestion} The Bureau of Labor statistics provides two public data APIs that use RESTful state transfer mechanisms to deliver data on demand to users for particular time series information in various BLS programs. The APIs accept HTTP requests for information to URL endpoints that describe the required resource, then return information in paginated JSON format. Version 2.0 implementation of the BLS API was used, which requires registration to obtain an API key. Such registration allows BLS to better understand what applications are using its data, but also allows developers more flexible access to the BLS data source. A Python tool for downloading BLS data was created by providing a list of BLS IDs for each time series. There are three primary ways of ingesting time series: by downloading a single source or multiple sources to an endpoint that only allows downloading of data for the past three years, or by using the registration endpoint to specify the start and end years for ingesting multiple time series. Data was ingested for the current millennium: from January, 2000 to February, 2015, obtaining over 305,445 records from 1,684 time series. A custom web scraper obtained a list of time series from the "most popular" pages on the BLS website. \subsection{Data Wrangling and Storage} Although the data is returned in JSON format, each data source from individual surveys may be formulated differently. Data wrangling efforts primarily dealt with inputing missing data (from years where surveys were not collected) and correcting mistakes in the ingestion process (e.g. mislabeled series information). Data type conversion was also required as JSON is a string format. The result of the wrangling process was a normalized, relational data set that could be stored in a PostgreSQL database management system. The data wrangling system also computed ``extra'' data sources that might be interesting to the front end visualization. An example includes computing the percent rate of change of a surveyed category. We hoped that by including pre-computed data sets such as these, the visual exploration mechanism could combine both human and computer analytical efforts. Data wrangling also involved initial data exploration efforts. We discovered that in order to power the geographic analyses, the tool required some sort of regional information (e.g. FIPS identification codes or larger economic areas). The BLS website, while providing information particularly related to a time series, provided no \textit{meta information} about the data source, which required data retrieved from other sources. For example, although there might be a time series entitled ``Tennessee, Professional and Business Services, Not seasonally adjusted - labor force'' - this series had to be manually assigned the Tennessee FIPS code, 42, and parsed out whether or not the data set was seasonally adjusted, which dataset it related to (labor force), and which modifier should be used (Professional and Business Services). To do this for 1684 data sources, we built an automated mechanism to parse time series names. The challenges of adapting the data straight from the BLS website took up over 80\% of the development effort, and perhaps highlights how vital a visual analysis tool is for this type and quantity of data. \subsection{System Architecture} The ingestion mechanism can be polled on a monthly basis to retrieve new information from the BLS API, keeping the application up to date for immediate use by journalists. The data backend then powers a RESTful API built using Python and the Flask framework that serves a front-end javascript single page application, which primarily uses D3 for visualization methodologies. Other notable implementation details can be found on the Github project page: \url{https://github.com/bbengfort/jobs-report/}, where the authors have made our system open source using the MIT license. The project itself is currently deployed on Heroku and can be accessed via \url{http://elmr.herokuapp.com/}. \section{First Inspirational Prototype} \begin{figure*}[!ht] \centering \includegraphics[width=0.9\textwidth]{figures/time_series_new_1-min.png} \caption{The time series explorer dashboard allows users to visualize multiple raw time series information in two different charts for ease of comparison with different data ranges. The year slider allows zooming and filtering by year. Finally, this dashboard attempts to add important headlines as listed by the Jobs Report.} \label{fig:time_series} \end{figure*} Our first inspirational prototype supports dynamic discovery in both time series and geography. Although each individual time series did not contain massive amounts of information (approximately 182 data points representing each month in this millenium), the number of time series themselves exceed the ability for a human to organize and digest the various information. In order to provide a visual mechanism of exploration and interactive reasoning, our design philosophy was that of a ``dashboard of visualizations'' where users could select appropriate visualizations, and interact with them though the ``overview first, zoom and filter, details on demand'' sense-making process. The primary filtering process involved time sliders to create windows of time to explore, as well as selectively choose which data to include in the visualizations. Three dashboards were implemented to explore these techniques, each in their own separate tabs across the top of the application: \begin{enumerate} \item \textbf{"Time Series" Explorer}: Explore and compare specific time series data sets in a dual-graph display. \item \textbf{"Geography" Choropleth}: Explore time series according to their regional factors and influences, and how regions change over time. \item \textbf{"Export Data" Utility}: Export data for use in another visualization or analysis tool. \end{enumerate} The visual analysis process requires a ``dashboard'' methodology - where users can interactively control as many aspects of the visualization as possible, and where multiple visualizations are adapted simultaneously. Each tab described above is a dashboard with its own custom controls. The Time Series Explorer allows users to explore all of the available time series with two chart windows and filter and zoom by a range of years. It also provides a ``headline view'' which attempts to highlight key information, such as percent change over a selected time period. The Geography Choropleth allows users to explore regional information in the continental United States, while also filtering for percent change. Finally, a data export dashboard allows users to download specific data with filters applied so that they can manipulate the data in their favorite visualization tools. \subsection{Time Series Explorer} Figure~\ref{fig:time_series} provides a snapshot of our design for the time series dashboard. The primary focus of this dashboard is two vertically stacked time series graphs, which allow for a visualization of multiple datasets at once. This is especially helpful if the two quantities are of different dimensional units (e.g. population and unemployment rate) and could not otherwise be plotted together. In order to better describe the dashboard, it was divided into six regions labeled A-F. \begin{figure*}[ht] \centering \includegraphics[width=0.9\textwidth]{figures/select-min.png} \caption{In order to minimize error, users select bls time series data sets through a grouped, alphabetized dropdown.} \label{fig:select} \end{figure*} Region A shows tab navigation bars which allow users to switch between the three dashboards. The tab display is consistent across all dashboards, and as more visualizations are added, more tabs can be added as well. If the list of tabs grows too long, the authors intend to allow users to select tabs for a personalized display that gives them quick access to the dashboards they use most (for example, national reporters may be less interested in local employment statistics). Region B contains an ``at-a-glance headline view'' and year slider control. The headline view is intended to be an eye-catching ``at-a-glance'' instant insight framework that is based heavily on the headline in the Employment Situation Report. The headline is tied to the two major pieces of information that are published at the top of the report - the unemployment rate and the number of non-farm jobs. The at-a-glance headline also displays important information regarding the amount of \textit{change} from the last period - a major piece of information that most users want to know. It is for this reason that these headlines have such a prominent place in our application. The year slider control also shown in Region B is the primary mechanism for zooming and filtering information for every dashboard in the app. The year range slider allows users to select a time period within the available time span and zoom the data into that range. Other dashboards have period selectors rather than ranges, which allows users to identify trends or data for a specific period. Regions C and D contain the primary controls for the time series displays in regions E and F, respectively. This application contains 1684 downloaded data sets, each of which can be displayed. The challenge is how to allow users to select data sets of interest quickly. Although using an autocomplete or search mechanism was considered, the prototype implementation simply uses a grouped, auto complete dropdown as shown in Figure~\ref{fig:select}. This design follows ``prevent error'' rule in the Eight Golden Rules of User Interface Design \cite{shneiderman_eight_????} as users can only select the databases that are available through our drop-down menu. \subsection{Geography Choropleth} \begin{figure*}[!ht] \centering \includegraphics[width=0.9\textwidth]{figures/geography_new_1_small.png} \caption{The Geography Choropleth dashboard implements a chorpleth style heatmap on the AlbersUSA projection of the United States, particularly at the state and regional level. Users can control the data set and colors with the control bar, and select the time period to visualize with a slider.} \label{fig:Geography} \end{figure*} Our second visual dashboard focused particularly on regional and state visual analyses. It implements a highly interactive choropleth map of the United States using the AlbersUSA projection, as shown in Figure~\ref{fig:Geography}. The dominant feature of this dashboard is the choropleth map of the United States which is directly connected to a selectable dataset from either the CESSM or LAUS datasets. By interacting with the controls on the left, users can select the data set, whether or not to implement seasonal adjustments, choose to show the rate of change calculation, and even select the color map. A slider at the top of the visualization controls the year for the map. This style map was the first design for the application, and its implementation was large focus of the efforts. However, we observed that the datasets were heavily weighted towards the larger states of California and Texas, reducing the usability of a choropleth, which requires a color scale to be effective. Data was normalized using "percent change" computations as described in the wrangling section. In this case users can explore the magnitude of change in a time series per state, which is much more effective in the choropleth setting. Region C is designed for users to select and adapt the data set they want to visualize. A grouped, alphabetized drop-down menu is used for users to select a data source from either LAUS or CESSM. Two check boxes allow users to specify whether they want to show ``seasonally adjusted'' data and/or the percentage of change from the previous month. Then users click on the ``Change Database'' button to refresh the map. To offer users flexibility, the application provides color scales to plot the data. Depending on the specific quantity plotted, users may prefer a particular form of color scale, e.g. sequential, diverging, etc. Region E is the main choropleth that displays the continental United States as well as Alaska and Hawaii. The legend shows the color scale at the bottom left. If users hover over an individual state, a tooltip pops up with detailed information. Users can also click on a state to zoom in and see specific information about that state. \subsection{Data Export} Finally, the last dashboard implements a data exporting feature so users can use other software, such as Excel or Tableau, to perform their analyses. The ingestion and wrangling of time series data is not difficult, but it is time consuming. By allowing users to directly export data from the tool, we hope to increase the number of analyses available and the insights that can be gained. Datasets are then downloaded in CSV or JSON format. \subsection{Data Management} Because the ingestion utility is real-time and visual analysis dashboards will change over time, an admin screen gives users an at-a-glance look at the system state (Figure~\ref{fig:admin}). This page conveys the effort it took to wrangle and gather the data and provides a means for interacting with the real-time ingestion system. For example, an ingestion log shows when data was fetched from the BLS web site, as well as the magnitude of the ingestion process. Other details include the current version of the application and the timestamps of the updates or ingestions. The status bar gives a quick view of any required maintenance for the system. A GREEN status indicates that the app is within a month of the last ingestion, YELLOW indicates that the app is less than six months since ingestion, and RED indicates that the app has not been updated in over six months. Database records also indicate the state and size of the database. Creating an open utility that shows the ingestion process and the database state allows users to view the analytic process, encoraging collaborative efforts to improve the system. Our software is open source on Github, with links to full documentation, agile development boards, API documentation, and more. Future goals are to allow direct administration from this page, by kicking off ingestion, or editing time series directly. \begin{figure*}[h] \centering \includegraphics[width=0.9\textwidth]{figures/Admin-min.png} \caption{Illustration of Admin resources.} \label{fig:admin} \end{figure*} \section{Second Inspirational Prototype} The dashboard applications in the previous sections provide a foundation from which to assess the strengths and weaknesses of visualizing the employment report. Through iterative testing and redesign, we developed a second inspirational prototype for organizing and plotting the time series data. A new tool, titled BLSVisualizer, allows users to clearly and interactively navigate through the employment data, which is conveniently organized in a hierarchical format. The main feature of BLSVisualizer is the use of an interactive tree structure to locate data. The tree structure is generated by implementing a parent-children hierarchy, from which users can select their her desired dataset. Much work has gone into studying the effectiveness of tree structures from both practical \cite{barlow2001comparison, plaisant2002spacetree} and aesthetic \cite{wetherell1979tidy, reingold1981tidier} standpoints. Barlow and Neville performed a parameter study on hierarchy visualizations by asking users to perform decision tree analyses on four different chart types: Organizational chart (or tree structure), icicle plot, tree ring, and treemap. Based on user response time and response accuracy, the authors concluded that the tree structure and icicle plots produced the most effective visualizations. Therefore, we implemented the hierarchical tree structure, due to its widespread familiarity, ease of implementation, and aesthetic appeal. The second feature of BLSVisualizer is the real-time drag-and-drop plot area, where users can view the time series data in the form of two-dimensional line charts. While previously users were forced to deal with hundreds of tables of data to compile a single time series, users can now locate and plot the data quickly, ideally leading to more efficient data analysis. Data was acquired via the API provided by the BLS in comma separated value (CSV) format. The CSV formatted data was converted to JSON format in order to more easily implement the hierarchical parent-child tree structure. \begin{figure*}[t] \centering \includegraphics[width=1\textwidth]{figures/MainApp.png} \caption{Example layout of BLSVisualizer } \label{BLSVLayout} \end{figure*} \subsection{Tree Structure} A primary step in any design process is to identify the design space. In this case, the space consists of multi-leveled categorical data. The nature of the design space lends itself to be organized in a hierarchical format. Hierarchies are typically displayed using a geometrically-transformed display \cite{keim2002information}. This is done in the present work in the form of an interactively transforming tree structure, primarily written using the D3 library titled ``Collapsible Tree Layout''. The smooth transitions are meant to be aesthetically pleasing as well as visually effective. Wetherell and Shannon \cite{wetherell1979tidy} provide a detailed description on what makes for an effective tree visualization. They identify three key \textit{aesthetics}, which were implemented into BLSVisualizer: \begin{itemize} \item \textit{Aesthetic 1}: Nodes of a tree at the same level should be along a straight line \item \textit{Aesthetic 2}: Left and right children should remain left and right of the parent \item \textit{Aesthetic 3}: Parent should be centered over its children \end{itemize} Another feature Wetherell and Shannon suggested was to minimize the width of the tree as much as possible. However, the present authors and Reingold et al. \cite{reingold1981tidier} found this technique to cause a cluttered workspace and too narrow of a visualization. Most of the data, when exported from the BLS website, comes organized in a conveniently hierarchical manner. However, data was further condensed to be organized in a more logical manner under more appropriate parent levels. To maintain a clutter-free environment, as users expand the tree, only the bottom-most levels are visible. To return to a previous level, users can re-click on the last expanded parent, collapsing the bottom level and returning the previous level into view. The colors of each item correspond to either dimensional values (orange) or non-dimensional values (green), such as rates or percentages. Since this is a rather large dataset, this minor color coding will help users more quickly identify the dataset they desire. The entire tree interface specifically complies with three of the Eight Golden Rules \cite{shneiderman_eight_????}: Strive for consistency, easy reversal of actions, and reduce short-term memory load. \begin{figure}[h] \centering \includegraphics[width=1\textwidth]{figures/TreeLevels.png} \caption{Interactive hierarchical tree structure. (Left) One level into the hierarchy and (right) two levels into the hierarchy, during which the first level is pushed off-screen.} \label{TreeStructure} \end{figure} \subsection{Drag-and-Drop Plot} To plot the time series data, users select a particular category and drag-and-drop that node into one of the middle boxes labeled ``Plot 1-3''. Each plot allows up to six items to be plotted at any one time. In order to preserve an easy reversal of actions, users may simply click on the item in the plotting list to remove it from the chart. The ``clear'' button at the top of each plotting area provides a one-click option to clear the plot of all items. Again in compliance with the Eight Golden Rules, in order to ``prevent errors'' the application prevents users from adding the same category more than once to the same chart. \subsection{Chart Area} The most important component of the visualization is the time series chart area. Dragging components into the center boxes causes the charts on the right to interactively update with the currently listed items. The time series data suggests that the shape of the graphic be a rectangular plot with the horizontal axis containing the date of each released BLS report. Line color was selected using the cartography tool ColorBrewer \cite{harrower2003colorbrewer}. This tool provided an array of six colors, arranged with the intention of plotting data with qualitative differences. This is opposed to a quantitative color scale, e.g. light red to dark red, that would indicate the quantitative relationship between the items plotted. However, the two datasets of ``Employment Level - Men'' and ``Employment Level - Women'', for example, have no quantitative relationship. Thus, a color scale that provides significant contrast and legibility between the individual lines is ideal. BLSVisualizer, as a whole, complies well with the popular mantra for designing an effective visualization of ``Overview first, zoom and filter, then details-on-demand'' \cite{shneiderman_eyes_1996}. The tree itself acts as an overview-to-zoom interactive element, allowing users to dive deeper into the data, getting more detailed with each subsequent level. Additionally, the line charts, plotted from years 2000 to 2015 provide an overview in the sense that it is a line showing the trend of data over 15 years. However, upon hovering over the plot, a tooltip box provides the discrete monthly data points at the current cursor location. To help users identify where along the x-axis the cursor is located, a vertical line spanning the height of the plot follows the cursor as it travels horizontally across the figure. The vertical position-indicator line is colored gray and is significantly thinner than the plotted time series data. The contrast in line weight represents a contrast in meaning, with the greater meaning given to the line with greater weight \cite{tufte1983visual}. Figure \ref{TablePlot} provides a comparison of how the data is presented in both the current BLS website and in the BLSVisualizer. It is clearly shown that BLSVisualizer provides a service in terms of observational insightfulness when viewing the data that the current BLS website does not provide. \begin{figure*}[h] \centering \includegraphics[width=1\textwidth]{figures/PlotTable.png} \caption{Comparison of the two proposed sets of BLS data. (Left) Tabular data presently employed on the BLS website and (right) its equivalent visual counterpart presented in BLSVisualizer.} \label{TablePlot} \end{figure*} \subsection{Usability Study} To examine BLSVisualizer, remote and in-person usability tests were performed with five users, about whom we collected the basic information of age, gender, occupation, and experience with visualization tools. All five were students, but only three participants had previous experience with visualization tools. Due to the relative simplicity of the tool's user interface, which was the primary focus of the study, a small sample size of five users with varying technological backgrounds was deemed sufficient. The 5-10 minute test was designed to progressively increase in difficulty, and went as follows: \begin{enumerate} \item Create 3 graphs for the following categories: \begin{itemize} \item Population level \item Unemployment level \item Marginal inflows to employment \end{itemize} \item Change ``Unemployment level'' to ``Employment level'' \item What was the white population level at 11/2011? \item Between 1/2008 to 1/2010, who had a larger increase in labor force flows from unemployment to employment: Men or Women? \item Compare, on the same graph, the effect of education level on unemployment rate. \item Compare the employment level of four different industries (both sexes). \begin{itemize} \item Identify the largest industry (in terms of employment level) and compare the distribution of men and women for that industry. \end{itemize} \end{enumerate} Question \#1 simply asks users to plot three separate datasets, which are all located on the first level of the tree, on the three chart areas. After reading the ``About'' section at the top of the page that describes how to use the tool, none of the users had an issue plotting the data. Two users brought up the fact that they were not aware that the ``About'' button was even an option. A clearer button label would have remedied that issue. Question \#2 asks users to remove one of the datasets they plotted and replace it with another. This question tests the ease of undoing an action, which is a very important feature in a visualization tool. Again, after locating the ``About'' pop-up window, all users were able to easily perform this task. Question \#3 tests the plausibility of replacing the current table look-up style of presenting the data with this interactive visualization. This task asked users to plot a time series and identify its value at a particular date (month/year). This task can be done in BLSVisualizer in two clicks, whereas on the BLS website it would likely take up to six clicks while visually sifting through dataset titles. Question \#4 attempts to do what the current BLS data presentation cannot provide: Insights based on data visualization. Users are asked to identify a way to compare the effect of education level on unemployment rate. This question gave several users some trouble. They were not sure what exactly they were asked to do, but after exploring the categories and understanding what options they had to work with, all five users eventually produced the correct plot and drew the same conclusion. The conclusion was that the more educated you are the less likely you are to be unemployed. The final task of the usability test asked users to plot the employment level of four industries of their choice and identify the one with the highest level of employment. Once this dataset was located, they were asked to break that data down into a demographic study of male and female. This question was created to show users that this visualization promotes breaking the data down into its parts to identify sources of a particular trend in the data. Users had minor difficulties with this task; however, once the task was completed, their comments conveyed that they were impressed with the overall utility of the tool. One of the test users, an Australian exchange journalism student, commented: "One major aspect of journalism is detecting changes in trends over time, or noticing irregular disparities between two sub-groups of society. This can be quite difficult to do, due to either a lack or disorganization of relevant data. This [visualization tool] allows you to quickly access data, collect it into one place, and easily divide it into subgroups to visualize trends. Journalists can use this to pick up on interesting irregularities in the data and create a story about it." The most common criticisms and suggestions to improve the BLSVisualizer interface were: \begin{itemize} \item Search bar \item Option to add more plots \item Option to export data \item Increased font size \item Category titles that do not overlap other text \end{itemize} \section{Conclusions and Future Work} Our work focuses on improving the user interface of the current Bureau of Labor Statistics website by compiling and arranging the fixed tabular BLS data into an easily navigable interface to support dynamic discovery of trends in the data. The tool aggregates a large dataset of over a thousand time series, ingested using the BLS API on a monthly basis. We implemented two inspirational prototypes: a Geographic Choropleth map to investigate changes in employment according to demographics or industry at the state level, and a Time Series explorer, where users can compare and contrast multiple time series through a stacked overlay. These dashboard applications, made primarily through the use of the D3 Javascript library, provided a foundation from which to assess the viability of an interactive visualization for this dataset. Through iterative designs and usability tests, we determined that visualization tools improved the user experience. Taking the initial dashboard tool a step further and improving upon the time series application, a hierarchical tree structure was introduced for more intuitive navigation. Additionally, a drag-and-drop method of plotting was introduced to give users control over where the data was plotted and in what order. The chart area was also refined to provide discrete values at the point where the cursor is located. A small usability test with five users concluded that this application is more useful, in terms of both finding the desired data and gathering conclusions based on trends. Usability testing also highlighted several areas of improvement for the visualization. The font and inter-category spacing will be made larger for improved legibility. Also, the ``Help/About'' sections will be more clear as to what capabilities the application has to offer. The most prominent user feedback, however, was the desire for a search bar to locate particular datasets. This work provides a step toward making the BLS website more accessible to a wider range of users. The inspirational prototypes presented here provide a base design to build upon, and the feedback and observations should be considered when building dynamic discovery tools to supplement the current BLS website. \section{Acknowledgments} This work was a team effort and many people collaborated on both the ELMR and BLSVisualizer projects. We would especially like to thank Bor-Chun Chen, Xintong Han, Jonggi Hong, Rotem Katzir, Assaf Magen, and Hao Zhou for all their support. Together they assisted us with software development, usability studies, and creating videos and demos. We would also like to thank those who participated in our usability study, and who critiqued our work. We would also like to thank Jonathan Schwabish of the Urban Institute who provided the framework for the project and the Bureau of Labor Statistics staff, particularly Emily Liddel and Tyrone Grandison who gave us guidance with the BLS API, offered specific information about the data sets being used, and arranged for our presentation at BLS to Commissioner Groshen and staff. \section{Links and Resources} The following links contain more information relevant to the project as well as resources for further exploration (they have been shortened by the ter.ps URL shortner project for print format). \begin{enumerate} \item ELMR Application: \url{http://ter.ps/985} \item ELMR Video Tutorial: \url{http://ter.ps/983} \item BLSVisualizer Application: \url{http://ter.ps/9zu} \item BLSVisualizer Tutorial: \url{http://ter.ps/9zv} \item Github Repository: \url{http://ter.ps/984} \item Project Wiki: \url{http://ter.ps/986} \end{enumerate} \bibliographystyle{apacite}
{'timestamp': '2016-08-12T02:10:39', 'yymm': '1608', 'arxiv_id': '1608.03569', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03569'}
arxiv
\section{Introduction}\label{sec:intro} A growing amount of research in natural language understanding (NLU) explores end-to-end deep neural network (DNN) architectures for tasks such as text classification \cite{zhang2015character}, relation extraction \cite{nguyen2015relation}, and question answering \cite{DBLP:journals/corr/WestonBCM15}. These models offer the potential to remove the intermediate steps traditionally involved in processing natural language data by operating on increasingly raw forms of text input, even unprocessed character or byte sequences. Furthermore, while these tasks are often studied in isolation, DNNs have the potential to combine multiple forms of reasoning within a single model. Supervised training of DNNs often requires a large amount of high-quality training data. To this end, we introduce a novel prediction task and accompanying large-scale dataset with a range of sub-tasks combining text classification and information extraction. The dataset is made publicly-available at \url{http://goo.gl/wikireading}. The task, which we call \textsc{WikiReading}, is to predict textual values from the open knowledge base \emph{Wikidata} \cite{VK:wikidata14} given text from the corresponding articles on \emph{Wikipedia} \cite{ayers2008wikipedia}. Example instances are shown in Table~\ref{tab:examples}, illustrating the variety of subject matter and sub-tasks. The dataset contains 18.87M instances across 867 sub-tasks, split roughly evenly between classification and extraction (see Section \ref{sec:wikireading} for more details). \begin{table*} \small \begin{tabular}{|p{1.4cm}|p{3.1cm}|p{3.1cm}|p{3.1cm}|p{3.1cm}|} \hline & \multicolumn{2}{c}{{\bf Categorization}} \vline & \multicolumn{2}{c}{{\bf Extraction}} \vline \\ \hline {\bf Document} & Folkart Towers are twin skyscrapers in the Bayrakli district of the Turkish city of Izmir. Reaching a structural height of 200 m (656 ft) above ground level, they are the tallest \dots & Angeles blancos is a Mexican telenovela produced by Carlos Sotomayor for Televisa in 1990. Jacqueline Andere, Rogelio Guerra and Alfonso Iturralde star as the main \dots & Canada is a country in the northern part of North America. Its ten provinces and three territories extend from the {\bf Atlantic} to the {\bf Pacific} and northward into the {\bf Arctic Ocean}, \dots & Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. The show originally aired on the AMC network for five seasons, from {\bf January 20, 2008}, to \dots \\\hline {\bf Property} & country & original language of work & located next to body of water & start time \\\hline\hline {\bf Answer} & Turkey & Spanish & Atlantic Ocean, Arctic Ocean, Pacific Ocean & 20 January 2008 \\\hline \end{tabular} \caption{Examples instances from \textsc{WikiReading}. The task is to predict the answer given the document and property. Answer tokens that can be extracted are shown in bold, the remaining instances require classification or another form of inference.}\label{tab:examples} \end{table*} In addition to its diversity, the \textsc{WikiReading} dataset is also at least an order of magnitude larger than related NLU datasets. Many natural language datasets for question answering (QA), such as \textsc{WikiQA} \cite{yang2015wikiqa}, have only thousands of examples and are thus too small for training end-to-end models. \newcite{DBLP:journals/corr/HermannKGEKSB15} proposed a task similar to QA, predicting entities in news summaries from the text of the original news articles, and generated a \textsc{News} dataset with 1M instances. The bAbI dataset \cite{DBLP:journals/corr/WestonBCM15} requires multiple forms of reasoning, but is composed of synthetically generated documents. \textsc{WikiQA} and \textsc{News} only involve pointing to locations within the document, and text classification datasets often have small numbers of output classes. In contrast, \textsc{WikiReading} has a rich output space of millions of answers, making it a challenging benchmark for state-of-the-art DNN architectures for QA or text classification. We implemented a large suite of recent models, and for the first time evaluate them on common grounds, placing the complexity of the task in context and illustrating the tradeoffs inherent in each approach. The highest score of 71.8\% is achieved by a sequence to sequence model \cite{DBLP:journals/corr/KalchbrennerB13,cho-al-emnlp14} operating on word-level input and output sequences, with special handing for out-of-vocabulary words. \section{\textsc{WikiReading}}\label{sec:wikireading} We now provide background information relating to Wikidata, followed by a detailed description of the \textsc{WikiReading} prediction task and dataset. \subsection{Wikidata}\label{sec:wikidata} Wikidata is a free collaborative knowledge base containing information about approximately 16M \textit{items} \cite{VK:wikidata14}. Knowledge related to each item is expressed in a set of \textit{statements}, each consisting of a (\texttt{property, value}) tuple. For example, the item \texttt{Paris} might have associated statements asserting \texttt{(instance of, city)} or \texttt{(country, France)}. Wikidata contains over 80M such statements across over 800 properties. Items may be linked to articles on Wikipedia. \subsection{Dataset}\label{sec:dataset} We constructed the \textsc{WikiReading} dataset from Wikidata and Wikipedia as follows: We consolidated all Wikidata statements with the same item and property into a single \texttt{(item, property, answer)} triple, where \texttt{answer} is a set of values. Replacing each \texttt{item} with the text of the linked Wikipedia article (discarding unlinked items) yields a dataset of 18.58M \texttt{(document, property, answer)} instances. Importantly, all elements in each instance are human-readable strings, making the task entirely textual. The only modification we made to these strings was to convert timestamps into a human-readable format (e.g., ``4 July 1776''). The \textsc{WikiReading} task, then, is to predict the answer string for each tuple given the document and property strings. This setup can be seen as similar to information extraction, or question answering where the property acts as a ``question''. We assigned each instance randomly to either training (around 16.03M instances), validation (1.89M), and test (0.95M) sets following a 85/10/5 distribution. \subsection{Documents} The dataset contains 4.7M unique Wikipedia articles, meaning that roughly 80\% of the English-language Wikipedia is represented. Multiple instances can share the same document, with a mean of 5.31 instances per article (median: 4, max: 879). The most common categories of documents are \texttt{human}, \texttt{taxon}, \texttt{film}, \texttt{album}, and \texttt{human settlement}, making up 48.8\% of the documents and 9.1\% of the instances. The mean and median document lengths are 489.2 and 203 words. \subsection{Properties}\label{sec:properties} The dataset contains 867 unique properties, though the distribution of properties across instances is highly skewed: The top 20 properties cover 75\% of the dataset, with 99\% coverage achieved after 180 properties. We divide the properties broadly into two groups: \textit{Categorical} properties, such as \texttt{instance of}, \texttt{gender} and \texttt{country}, require selecting between a relatively small number of possible answers, while \textit{relational} properties, such as \texttt{date of birth}, \texttt{parent}, and \texttt{capital}, typically require extracting rare or totally unique answers from the document. To quantify this difference, we compute the entropy of the answer distribution $A$ for each property $p$, scaled to the $[0, 1]$ range by dividing by the entropy of a uniform distribution with the same number of values, i.e., $\hat{H}(p) = H(A_p) / \log{|A_p|}$. Properties that represent essentially one-to-one mappings score near $1.0$, while a property with just a single answer would score $0.0$. Table \ref{tab:entropy} lists entropy values for a subset of properties, showing that the dataset contains a spectrum of sub-tasks. We label properties with an entropy less than 0.7 as categorical, and those with a higher entropy as relational. Categorical properties cover 56.7\% of the instances in the dataset, with the remaining 43.3\% being relational. \begin{table} \small \begin{tabular}{|l|r|c|} \hline {\bf Property} & {\bf Frequency} & {\bf Entropy}\\ \hline instance of & 3,245,856 & 0.429 \\ sex or gender & 1,143,126 & 0.186 \\ country & 986,587 & 0.518 \\ date of birth & 953,481 & 0.916 \\ given name & 932,147 & 0.755 \\ occupation & 869,333 & 0.588 \\ country of citizenship & 819,301 & 0.508 \\ located in \dots entity & 582,110 & 0.800 \\ place of birth & 467,066 & 0.795 \\ date of death & 442,514 & 0.922 \\ \hline \end{tabular} \caption{Training set frequency and scaled answer entropy for the 10 most frequent properties.}\label{tab:entropy} \end{table} \subsection{Answers} The distribution of properties described above has implications for the answer distribution. There are a relatively small number of very high frequency ``head'' answers, mostly for categorical properties, and a vast number of very low frequency ``tail'' answers, such as names and dates. At the extremes, the most frequent answer \texttt{human} accounts for almost 7\% of the dataset, while 54.7\% of the answers in the dataset are unique. There are some special categories of answers which are systematically related, in particular \emph{dates}, which comprise 8.9\% of the dataset (with 7.2\% being unique). This distribution means that methods focused on either head or tail answers can each perform moderately well, but only a method that handles both types of answers can achieve maximum performance. Another consequence of the long tail of answers is that many (30.0\%) of the answers in the test set never appear in the training set, meaning they must be read out of the document. An answer is present verbatim in the document for 45.6\% of the instances. \section{Methods}\label{sec:methods} Recently, neural network architectures for NLU have been shown to meet or exceed the performance of traditional methods \cite{zhang2015character,dai2015semi}. The move to deep neural networks also allows for new ways of combining the property and document, inspired by recent research in the field of question answering (with the property serving as a question). In sequential models such as Recurrent Neural Networks (RNNs), the question could be prepended to the document, allowing the model to ``read'' the document differently for each question \cite{DBLP:journals/corr/HermannKGEKSB15}. Alternatively, the question could be used to compute a form of \emph{attention} \cite{bahdanau2014neural} over the document, to effectively focus the model on the most predictive words or phrases \cite{DBLP:journals/corr/SukhbaatarSWF15,DBLP:journals/corr/HermannKGEKSB15}. As this is currently an ongoing field of research, we implemented a range of recent models and for the first time compare them on common grounds. We now describe these methods, grouping them into broad categories by general approach and noting necessary modifications. Later, we introduce some novel variations of these models. \subsection{Answer Classification}\label{sec:answer-classification} Perhaps the most straightforward approach to \textsc{WikiReading} is to consider it as a special case of document classification. To fit \textsc{WikiReading} into this framework, we consider each possible answer as a class label, and incorporate features based on the property so that the model can make different predictions for the same document. While the number of potential answers is too large to be practical (and unbounded in principle), a substantial portion of the dataset can be covered by a model with a tractable number of answers. \subsubsection{Baseline}\label{sec:baseline} \newcommand{N_{\operatorname{w}}}{N_{\operatorname{w}}} The most common approach to document classification is to fit a linear model (e.g., Logistic Regression) over bag of words (BoW) features. To serve as a baseline for our task, the linear model needs to make different predictions for the same Wikipedia article depending on the property. We enable this behavior by computing two $N_{\operatorname{w}}$ element BoW vectors, one each for the document and property, and concatenating them into a single $2N_{\operatorname{w}}$ feature vector. \subsubsection{Neural Network Methods} \newcommand{d_{\operatorname{in}}}{d_{\operatorname{in}}} \newcommand{d_{\operatorname{out}}}{d_{\operatorname{out}}} \newcommand{N_{\operatorname{ans}}}{N_{\operatorname{ans}}} \newcommand{N_{\operatorname{doc}}}{N_{\operatorname{doc}}} \newcommand{\mathbf{y}}{\mathbf{y}} \newcommand{\mathbf{x}}{\mathbf{x}} \newcommand{\mathbf{z}}{\mathbf{z}} All of the methods described in this section encode the property and document into a \emph{joint representation} $\mathbf{y} \in \mathbb{R}^{d_{\operatorname{out}}}$, which serves as input for a final softmax layer computing a probability distribution over the top $N_{\operatorname{ans}}$ answers. Namely, for each answer $i \in \{1,\dots,N_{\operatorname{ans}}\}$, we have: \begin{equation} P(i|\mathbf{x}) = e^{\mathbf{y}^\top\mathbf{a}_i} / \textstyle\sum_{j=1}^{N_{\operatorname{ans}}}e^{\mathbf{y}^\top\mathbf{a}_j}, \end{equation} where $\mathbf{a}_i \in \mathbb{R}^{d_{\operatorname{out}}}$ corresponds to a learned vector associated with answer $i$. Thus, these models differ primarily in how they combine the property and document to produce the joint representation. For existing models from the literature, we provide a brief description and note any important differences in our implementation, but refer the reader to the original papers for further details. Except for character-level models, documents and properties are tokenized into words. The $N_{\operatorname{w}}$ most frequent words are mapped to a vector in $\mathbb{R}^{d_{\operatorname{in}}}$ using a learned embedding matrix\footnote{Limited experimentation with initialization from publicly-available word2vec embeddings \cite{mikolov2013distributed} yielded no improvement in performance.}. Other words are all mapped to a special out of vocabulary (OOV) token, which also has a learned embedding. $d_{\operatorname{in}}$ and $d_{\operatorname{out}}$ are hyperparameters for these models. \paragraph{Averaged Embeddings (BoW):} This is the neural network version of the baseline method described in Section \ref{sec:baseline}. Embeddings for words in the document and property are separately averaged. The concatenation of the resulting vectors forms the joint representation of size $2d_{\operatorname{in}}$. \paragraph{Paragraph Vector:} We explore a variant of the previous model where the document is encoded as a \emph{paragraph vector} \cite{DBLP:journals/corr/LeM14}. We apply the PV-DBOW variant that learns an embedding for a document by optimizing the prediction of its constituent words. These unsupervised document embeddings are treated as a fixed input to the supervised classifier, with no fine-tuning. \paragraph{LSTM Reader:} This model is a simplified version of the Deep LSTM Reader proposed by \newcite{DBLP:journals/corr/HermannKGEKSB15}. In this model, an LSTM \cite{hochreiter1997long} reads the property and document sequences word-by-word and the final state is used as the joint representation. This is the simplest model that respects the order of the words in the document. In our implementation we use a single layer instead of two and a larger hidden size. More details on the architecture can be found in Section~\ref{sec:training} and in Table~\ref{tab:params}. \newcommand{\mathbf{u}}{\mathbf{u}} \newcommand{\mathbf{m}}{\mathbf{m}} \newcommand{\mathbf{v}}{\mathbf{v}} \newcommand{\operatorname{concat}}{\operatorname{concat}} \paragraph{Attentive Reader:} This model, also presented in \newcite{DBLP:journals/corr/HermannKGEKSB15}, uses an attention mechanism to better focus on the relevant part of the document for a given property. Specifically, Attentive Reader first generates a representation $\mathbf{u}$ of the property using the final state of an LSTM while a second LSTM is used to read the document and generate a representation $\mathbf{z}_t$ for each word. Then, conditioned on the property encoding $\mathbf{u}$, a normalized attention is computed over the document to produce a weighted average of the word representations $\mathbf{z}_t$, which is then used to generate the joint representation $\mathbf{y}$. More precisely: \begin{align*} \mathbf{m}_t &= \operatorname{tanh}( W_1 \operatorname{concat}(\mathbf{z}_t,\mathbf{u})) \\ \alpha_t & = \operatorname{exp} \left( \mathbf{v}^{\intercal} \mathbf{m}_t \right) \\ \mathbf{r} &= \textstyle\sum_t \tfrac{\alpha_t }{\sum_{\tau} \alpha_{\tau}}\mathbf{z}_t \\ \mathbf{y} &= \operatorname{tanh}( W_2 \operatorname{concat}(\mathbf{r},\mathbf{u}) ), \end{align*} where $W_1$, $W_2$, and $\mathbf{v}$ are learned parameters. \paragraph{Memory Network:} Our implementation closely follows the End-to-End Memory Network proposed in \newcite{DBLP:journals/corr/SukhbaatarSWF15}. This model maps a property $p$ and a list of sentences $\mathbf{x}_1,\dots,\mathbf{x}_n$ to a joint representation $\mathbf{y}$ by attending over sentences in the document as follows: The input encoder $I$ converts a sequence of words $\mathbf{x}_i = ( x_{i1}, \dots, x_{iL_i} )$ into a vector using an embedding matrix (equation~\ref{eq:memnet_encoder}), where $L_i$ is the length of sentence $i$.\footnote{Our final results use the position encoding method proposed by \newcite{DBLP:journals/corr/SukhbaatarSWF15}, which incorporates positional information in addition to word embeddings.} The property is encoded with the embedding matrix $U$ (eqn.~\ref{eq:memnet_question}). Each sentence is encoded into two vectors, a memory vector (eqn.~\ref{eq:memnet_memory}) and an output vector (eqn.~\ref{eq:memnet_output}), with embedding matrices $M$ and $C$, respectively. The property encoding is used to compute a normalized attention vector over the memories (eqn.~\ref{eq:memnet_attention}).\footnote{Instead of the linearization method of \newcite{DBLP:journals/corr/SukhbaatarSWF15}, we applied an entropy regularizer for the softmax attention as described in \newcite{kurach2015neural}.} The joint representation is the sum of the output vectors weighted by this attention (eqn.~\ref{eq:memnet_answer}). \begin{align} I(x_i,W) &= \textstyle\sum_{j} Wx_{ij} \label{eq:memnet_encoder} \\ \mathbf{u} &= I(p, U) \label{eq:memnet_question} \\ \mathbf{m}_i &= I(x_i, M) \label{eq:memnet_memory} \\ \mathbf{c}_i &= I(x_i, C) \label{eq:memnet_output} \\ \mathbf{p}_i &= \softmax(\mathbf{q}^{\intercal}\mathbf{m}_i) \label{eq:memnet_attention} \\ \mathbf{y} &= \mathbf{u} + \textstyle\sum_i \mathbf{p}_i \mathbf{c}_i \label{eq:memnet_answer} \end{align} \subsection{Answer Extraction}\label{sec:rnn_labeler} Relational properties involve mappings between arbitrary entities (e.g., \texttt{date of birth}, \texttt{mother}, and \texttt{author}) and thus are less amenable to document classification. For these, approaches from information extraction (especially relation extraction) are much more appropriate. In general, these methods seek to identify a word or phrase in the text that stands in a particular relation to a (possibly implicit) subject. Section \ref{sec:related} contains a discussion of prior work applying NLP techniques involving entity recognition and syntactic parsing to this problem. RNNs provide a natural fit for extraction, as they can predict a value at every position in a sequence, conditioned on the entire previous sequence. The most straightforward application to \textsc{WikiReading} is to predict the probability that a word at a given location is part of an answer. We test this approach using an RNN that operates on the sequence of words. At each time step, we use a sigmoid activation for estimating whether the current word is part of the answer or not. We refer to this model as the \emph{RNN Labeler} and present it graphically in Figure~\ref{fig:rnn_models}a. \begin{figure} \includegraphics[scale=0.40]{rnn_models.pdf} \caption{Illustration of RNN models. Blocks with same color share parameters. Red words are out of vocabulary and all share a common embedding.}\label{fig:rnn_models} \end{figure} For training, we label all locations where any answer appears in the document with a $1$, and other positions with a $0$ (similar to distant supervision \cite{Mintz:2009:DSR:1690219.1690287}). For multi-word answers, the word sequences in the document and answer must fully match\footnote{Dates were matched semantically to increase recall.}. Instances where no answer appears in the document are discarded for training. The cost function is the average cross-entropy for the outputs across the sequence. When performing inference on the test set, sequences of consecutive locations scoring above a threshold are chunked together as a single answer, and the top-scoring answer is recorded for submission.\footnote{We chose an arbitrary threshold of 0.5 for chunking. The score of each chunk is obtained from the harmonic mean of the predicted probabilities of its elements.} \subsection{Sequence to Sequence} Recently, sequence to sequence learning (or \emph{seq2seq}) has shown promise for natural language tasks, especially machine translation \cite{cho-al-emnlp14}. These models combine two RNNs: an \emph{encoder}, which transforms the input sequence into a vector representation, and a \emph{decoder}, which converts the encoder vector into a sequence of output tokens, one token at a time. This makes them capable, in principle, of approximating any function mapping sequential inputs to sequential outputs. Importantly, they are the first model we consider that can perform any combination of answer classification and extraction. \subsubsection{Basic seq2seq}\label{sec:basic_seq2seq} This model resembles LSTM Reader augmented with a second RNN to decode the answer as a sequence of words. The embedding matrix is shared across the two RNNs but their state to state transition matrices are different (Figure~\ref{fig:rnn_models}b). This method extends the set of possible answers to any sequence of words from the document vocabulary. \subsubsection{Placeholder seq2seq}\label{sec:ph_sec2sec} While Basic seq2seq already expands the expressiveness of LSTM Reader, it still has a limited vocabulary and thus is unable to generate some answers. As mentioned in Section \ref{sec:rnn_labeler}, RNN Labeler can extract any sequence of words present in the document, even if some are OOV. We extend the basic seq2seq model to handle OOV words by adding \emph{placeholders} to our vocabulary, increasing the vocabulary size from $N_{\operatorname{w}}$ to $N_{\operatorname{w}} + N_{\operatorname{doc}}$. Then, when an OOV word occurs in the document, it is replaced at random (without replacement). by one of these placeholders. We also replace the corresponding OOV words in the target output sequence by the same placeholder,\footnote{The same OOV word may occur several times in the document. Our simplified approach will attribute a different placeholder for each of these and will use the first occurrence for the target answer.} as shown in Figure \ref{fig:rnn_models}c. \newcite{luong-EtAl:2015:ACL-IJCNLP} developed a similar procedure for dealing with rare words in machine translation, copying their locations into the output sequence for further processing. This makes the input and output sequences a mixture of known words and placeholders, and allows the model to produce any answer the RNN Labeler can produce, in addition to the ones that the basic seq2seq model could already produce. This approach is comparable to \emph{entity anonymization} used in \newcite{DBLP:journals/corr/HermannKGEKSB15}, which replaces named entities with random ids, but simpler because we use word-level placeholders without entity recognition. \subsubsection{Basic Character seq2seq}\label{sec:char_seq2seq} Another way of handling rare words is to process the input and output text as sequences of characters or bytes. RNNs have shown some promise working with character-level input, including state-of-the-art performance on a Wikipedia text classification benchmark \cite{dai2015semi}. A model that outputs answers character by character can in principle generate any of the answers in the test set, a major advantage for \textsc{WikiReading}. This model, shown in Figure~\ref{fig:char-seq2seq2}, operates only on sequences of mixed-case characters. The property encoder RNN transforms the property, as a character sequence, into a fixed-length vector. This property encoding becomes the initial hidden state for the second layer of a two-layer document encoder RNN, which reads the document, again, character by character. Finally, the answer decoder RNN uses the final state of the previous RNN to decode the character sequence for the answer. \begin{figure} \begin{center} \includegraphics[width=0.45\textwidth]{char_seq2seq} \caption{Character seq2seq model. Blocks with the same color share parameters. The same example as in Figure~\ref{fig:rnn_models} is fed character by character. } \label{fig:char-seq2seq2} \end{center} \end{figure} \subsubsection{Character seq2seq with Pretraining} Unfortunately, at the character level the length of all sequences (documents, properties, and answers) is greatly increased. This adds more sequential steps to the RNN, requiring gradients to propagate further, and increasing the chance of an error during decoding. To address this issue in a classification context, \newcite{dai2015semi} showed that initializing an LSTM classifier with weights from a language model (LM) improved its accuracy. Inspired by this result, we apply this principle to the character seq2seq model with a two-phase training process: In the first phase, we train a character-level LM on the input character sequences from the \textsc{WikiReading} training set (no new data is introduced). In the second phase, the weights from this LM are used to initialize the first layer of the encoder and the decoder (purple and green blocks in Figure~\ref{fig:char-seq2seq2}). After initialization, training proceeds as in the basic character seq2seq model. \newcommand{\mathbf{g}}{\mathbf{g}} \section{Experiments}\label{sec:experiments} \begin{table*}[t] \small \begin{center} \begin{tabular}{|l|c|c|c|c|c|r|} \hline {\bf Method} & {\bf Mean F1} & {\bf Bound} & {\bf Categorical} & {\bf Relational} & {\bf Date} & {\bf Params} \\ \hline \multicolumn{7}{|l|}{{\bf Answer Classifier}}\\ \hline Sparse BoW Baseline & 0.438 & \multirow{6}{*}{0.831} & 0.725 & 0.063 & 0.004 & 500.5M \\ Averaged Embeddings & 0.583 && 0.849 & 0.234 & 0.080 & 120M \\ Paragraph Vector & 0.552 && 0.787 & 0.227 & 0.033 & 30M \\ LSTM Reader & 0.680 && 0.880 & 0.421 & 0.311 & 45M \\ Attentive Reader & 0.693 && {\bf 0.886} & 0.441 & 0.337 & 56M \\ Memory Network & 0.612 && 0.861 & 0.288 & 0.055 & 90.1M \\ \hline \multicolumn{7}{|l|}{{\bf Answer Extraction}}\\ \hline RNN Labeler & 0.357 & 0.471 & 0.240 & 0.536 & 0.626 & 41M \\ \hline \multicolumn{7}{|l|}{{\bf Sequence to Sequence}}\\ \hline Basic seq2seq & 0.708 & 0.925 & 0.844 & 0.530 & {\bf 0.738} & 32M \\ Placeholder seq2seq & 0.{\bf 718} & 0.948 & 0.835 & {\bf 0.565} & 0.730 & 32M \\ Character seq2seq & 0.677 & {\bf 0.963} & 0.841 & 0.462 & 0.731 & 4.1M \\ Character seq2seq (LM) & 0.699 & {\bf 0.963} & 0.851 & 0.501 & 0.733 & 4.1M \\ \hline \end{tabular} \end{center} \caption{ Results for all methods described in Section \ref{sec:methods} on the test set. {\it F1} is the Mean F1 score described in \ref{sec:experiments}. {\it Bound} is the upper bound on Mean F1 imposed by constraints in the method (see text for details). The remaining columns provide score breakdowns by property type and the number of model parameters. }\label{tab:results} \end{table*} We evaluated all methods from Section~\ref{sec:methods} on the full test set with a single scoring framework. An answer is correct when there is an exact string match between the predicted answer and the gold answer. However, as describe in Section~\ref{sec:dataset}, some answers are composed from a set of values (e.g. third example in Table~\ref{tab:examples}). To handle this, we define the \emph{Mean F1} score as follows: For each instance, we compute the F1-score (harmonic mean of precision and recall) as a measure of the degree of overlap between the predicted answer set and the gold set for a given instance. The resulting per-instance F1 scores are then averaged to produce a single dataset-level score. This allows a method to obtain partial credit for an instance when it answers with at least one value from the golden set. In this paper, we only consider methods for answering with a single value, and most answers in the dataset are also composed of a single value, so this Mean F1 metric is closely related to accuracy. More precisely, a method using a single value as answer is bounded by a Mean F1 of 0.963. \subsection{Training Details}\label{sec:training} We implemented all models in a single framework based on TensorFlow \cite{abaditensorflow} with shared pre-processing and comparable hyperparameters whenever possible. All documents are truncated to the first $300$ words except for Character seq2seq, which uses $400$ characters. The embedding matrix used to encode words in the document uses $d_{\operatorname{in}}=300$ dimensions for the $N_{\operatorname{w}}=100,000$ most frequent words. Similarly, answer classification over the $N_{\operatorname{ans}}=50,000$ most frequent answers is performed using an answer representation of size $d_{\operatorname{out}}=300$.\footnote{For models like Averaged Embedding and Paragraph Vector, the concatenation imposes a greater $d_{\operatorname{out}}$.} The first $10$ words of the properties are embedded using the document embedding matrix. Following \newcite{cho-al-emnlp14}, RNNs in seq2seq models use a GRU cell with a hidden state size of $1024$. More details on parameters are reported in Table~\ref{tab:params}. \begin{table}[h] \begin{centering} \small \begin{tabular}{|m{1.3cm}|m{0.9cm}|m{1cm}|m{1.2cm}|m{1cm}|} \hline {\bf Method} & {\bf Emb. Dims} & {\bf Doc. Length} & {\bf Property Length} & {\bf Doc. Vocab. Size}\\ \hline Sparse BoW Baseline & N/A & 300 words & 10 words & 50K words\\\hline Paragraph Vector & N/A & N/A & 10 words & N/A \\\hline Character seq2seq & 30 & 400 chars & 20 chars & 76 chars \\\hline All others & 300 & 300 words & 10 words & 100K words \\\hline \end{tabular} \caption{Structural model parameters. Note that the Paragraph Vector method uses the output from a separate, unsupervised model as a document encoding, which is not counted in these parameters. }\label{tab:params} \end{centering} \end{table} Optimization was performed with the Adam stochastic optimizer\footnote{Using $\beta_1=0.9$, $\beta_2=0.999$ and $\epsilon=10^{-8}$.} \cite{kingma2015method} over mini-batches of $128$ samples. Gradient clipping \footnote{When the norm of gradient $\mathbf{g}$ exceeds a threshold $C$, it is scaled down i.e. $\mathbf{g} \leftarrow \mathbf{g} \cdot \min \left( 1, \frac{C}{||\mathbf{g}||} \right)$.} \cite{DBLP:journals/corr/Graves13} is used to prevent instability in training RNNs. We performed a search over 50 randomly-sampled hyperparameter configurations for the learning rate and gradient clip threshold, selecting the one with the highest Mean F1 on the validation set. Learning rate and clipping threshold are sampled uniformly, on a logarithmic scale, over the range $[10^{-5},10^{-2}]$ and $[10^{-3},10^{1}]$ respectively. \subsection{Results and Discussion}\label{sec:results} \begin{table*}[t] \small \begin{center} \begin{tabular}{|m{1.41cm}|m{1.0cm}|m{1.4cm}|m{1.25cm}|m{1.4cm}|m{1.2cm}|m{1.6cm}|m{1.4cm}|m{1.4cm}|} \hline & & \multicolumn{7}{c|}{{\bf Mean F1}} \\\cline{3-9} {\bf Property} & {\bf Test Instances} & {\bf Averaged Embeddings} & {\bf Attentive Reader} & {\bf Memory Network} & {\bf Basic seq2seq} & {\bf Placeholder seq2seq} & {\bf Character seq2seq} & {\bf Character seq2seq (LM)} \\ \hline \multicolumn{9}{|l|}{{\bf Categorical Properties}}\\ \hline instance of & 191157 & 0.8545 & {\bf 0.8978} & 0.8720 & 0.8877 & 0.8775 & 0.8548 & 0.8659 \\\hline sex or gender & 66875 & 0.9917 & 0.9966 & 0.9936 & {\bf 0.9968} & 0.9952 & 0.9943 & 0.9941 \\\hline genre & 8117 & 0.5320 & {\bf 0.6225 } & 0.5625 & 0.5511 & 0.5260 & 0.5096 & 0.5283 \\\hline instrument & 890 & 0.7621 & {\bf 0.8415 } & 0.7886 & 0.8377 & 0.8172 & 0.7529 & 0.7832 \\\hline \multicolumn{9}{|l|}{{\bf Relational Properties}}\\ \hline given name & 54624 & 0.4973 & 0.8486 & 0.7206 & 0.8669 & {\bf 0.8868} & 0.8606 & 0.8729 \\\hline located in & 34250 & 0.4140 & 0.6195 & 0.4832 & 0.5484 & {\bf 0.6978} & 0.5496 & 0.6365 \\\hline parent taxon & 15494 & 0.1990 & 0.3467 & 0.2077 & 0.2044 & {\bf 0.7997} & 0.4979 & 0.5748 \\\hline author & 2356 & 0.0309 & 0.2088 & 0.1050 & 0.6094 & {\bf 0.6572} & 0.1403 & 0.3748 \\\hline \multicolumn{9}{|l|}{{\bf Date Properties}}\\ \hline date of birth & 56221 & 0.0626 & 0.3677 & 0.0016 & {\bf 0.8306} & 0.8259 & 0.8294 & 0.8303 \\\hline date of death & 26213 & 0.0417 & 0.2949 & 0.0506 & {\bf 0.7974} & 0.7874 & 0.7897 & 0.7924 \\\hline publication date & 7680 & 0.3909 & 0.5549 & 0.4851 & {\bf 0.5988} & 0.5902 & 0.5903 & 0.5943 \\\hline date of official opening & 269 & 0.1510 & 0.3047 & 0.1725 & {\bf 0.3333} & 0.3012 & 0.1457 & 0.1635 \\\hline \end{tabular} \end{center} \caption{Property-level Mean F1 scores on the test set for selected methods and properties. For each property type, the two most frequent properties are shown followed by two less frequent properties to illustrate long-tail behavior.}\label{tab:results-per-relation} \end{table*} Results for all models on the held-out set of test instances are presented in Table \ref{tab:results}. In addition to the overall Mean F1 scores, the model families differ significantly in Mean F1 upper bound, and their relative performance on the relational and categorical properties defined in Section \ref{sec:properties}. We also report scores for properties containing dates, a subset of relational properties, as a separate column since they have a distinct format and organization. For examples of model performance on individual properties, see Table \ref{tab:results-per-relation}. As expected, all classifier models perform well for categorical properties, with more sophisticated classifiers generally outperforming simpler ones. The difference in precision reading ability between models that use broad document statistics, like Averaged Embeddings and Paragraph Vectors, and the RNN-based classifiers is revealed in the scores for relational and especially date properties. As shown in Table \ref{tab:results-per-relation}, this difference is magnified in situations that are more difficult for a classifier, such as relational properties or properties with fewer training examples, where Attentive Reader outperforms Averaged Embeddings by a wide margin. This model family also has a high upper bound, as perfect classification across the $50,000$ most frequent answers would yield a Mean F1 of 0.831. However, none of them approaches this limit. Part of the reason is that their accuracy for a given answer decreases quickly as the frequency of the answer in the training set decreases, as illustrated in Figure \ref{fig:ans_freq}. As these models have to learn a separate weight vector for each answer as part of the softmax layer (see Section \ref{sec:answer-classification}), this may suggest that they fail to generalize across answers effectively and thus require significant number of training examples per answer. \begin{figure} \begin{center} \includegraphics[width=0.45\textwidth]{ans_freq.png} \caption{Per-answer Mean F1 scores for Attentive Reader (moving average of 1000), illustrating the decline in prediction quality as the number of training examples per answer decreases.}\label{fig:ans_freq} \end{center} \end{figure} The only answer extraction model evaluated, RNN Labeler, shows a complementary set of strengths, performing better on relational properties than categorical ones. While the Mean F1 upper bound for this model is just 0.434 because it can only produce answers that are present verbatim in the document text, it manages to achieve most of this potential. The improvement on date properties over the classifier models demonstrates its ability to identify answers that are typically present in the document. We suspect that answer extraction may be simpler than answer classification because the model can learn robust patterns that indicate a location without needing to learn about each answer, as the classifier models must. The sequence to sequence models show a greater degree of balance between relational and categorical properties, reaching performance consistent with classifiers on the categorical questions and with RNN Labeler on relational questions. Placeholder seq2seq can in principle produce any answer that RNN Labeler can, and the performance on relational properties is indeed similar. As shown in Table \ref{tab:results-per-relation}, Placeholder seq2seq performs especially well for properties where the answer typically contains rare words such as the name of a place or person. When the set of possible answer tokens is more constrained, such as in categorical or date properties, the Basic seq2seq often performs slightly better. Character seq2seq has the highest upper bound, limited to 0.963 only because it cannot produce an answer set with multiple elements. LM pretraining consistently improves the performance of the Character seq2seq model, especially for relational properties as shown in Table \ref{tab:results-per-relation}. The performance of the Character seq2seq, especially with LM pretraining, is a surprising result: It performs comparably to the word-level seq2seq models even though it must copy long character strings when doing extraction and has access to a smaller portion of the document. We found the character based models to be particularly sensitive to hyperparameters. However, using a pretrained language model reduced this issue and significantly accelerated training while improving the final score. We believe that further research on pretraining for character based models could improve this result. \section{Related Work}\label{sec:related} The goal of automatically extracting structured information from unstructured Wikipedia text was first advanced by \newcite{wu2007autonomously}. As Wikidata did not exist at that time, the authors relied on the structured \emph{infoboxes} included in some Wikipedia articles for a relational representation of Wikipedia content. Wikidata is a cleaner data source, as the infobox data contains many slight variations in schema related to page formatting. Partially to get around this issue, the authors restrict their prediction model Kylin to 4 specific infobox classes, and only common attributes within each class. A substantial body of work in relation extraction (RE) follows the distant supervision paradigm \cite{Craven:1999:CBK:645634.663209}, where sentences containing both arguments of a knowledge base (KB) triple are assumed to express the triple's relation. Broadly, these models use these distant labels to identify syntactic features relating the subject and object entities in text that are indicative of the relation. \newcite{Mintz:2009:DSR:1690219.1690287} apply distant supervision to extracting Freebase triples \cite{Bollacker:2008:FCC:1376616.1376746} from Wikipedia text, analogous to the relational part of \textsc{WikiReading}. Extensions to distant supervision include explicitly modelling whether the relation is actually expressed in the sentence \cite{riedel2010modeling}, and jointly reasoning over larger sets of sentences and relations \cite{surdeanu2012multi}. Recently, \newcite{rocktaschel2015injecting} developed methods for reducing the number of distant supervision examples required by sharing information between relations. \section{Conclusion} We have demonstrated the complexity of the \textsc{WikiReading} task and its suitability as a benchmark to guide future development of DNN models for natural language understanding. After comparing a diverse array of models spanning classification and extraction, we conclude that end-to-end sequence to sequence models are the most promising. These models simultaneously learned to classify documents and copy arbitrary strings from them. In light of this finding, we suggest some focus areas for future research. Our character-level model improved substantially after language model pretraining, suggesting that further training optimizations may yield continued gains. Document length poses a problem for RNN-based models, which might be addressed with convolutional neural networks that are easier to parallelize. Finally, we note that these models are not intrinsically limited to English, as they rely on little or no pre-processing with traditional NLP systems. This means that they should generalize effectively to other languages, which could be demonstrated by a multilingual version of \textsc{WikiReading}. \section*{Acknowledgments} We thank Jonathan Berant for many helpful comments on early drafts of the paper, and Catherine Finegan-Dollak for an early implementation of RNN Labeler.
{'timestamp': '2017-03-17T01:01:08', 'yymm': '1608', 'arxiv_id': '1608.03542', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03542'}
arxiv
\section*{ABSTRACT} We develop a framework for warm-starting Bayesian optimization, that reduces the solution time required to solve an optimization problem that is one in a sequence of related problems. This is useful when optimizing the output of a stochastic simulator that fails to provide derivative information, for which Bayesian optimization methods are well-suited. Solving sequences of related optimization problems arises when making several business decisions using one optimization model and input data collected over different time periods or markets. While many gradient-based methods can be warm started by initiating optimization at the solution to the previous problem, this warm start approach does not apply to Bayesian optimization methods, which carry a full metamodel of the objective function from iteration to iteration. Our approach builds a joint statistical model of the entire collection of related objective functions, and uses a value of information calculation to recommend points to evaluate. \newpage \section{INTRODUCTION} \label{section_introduction} Businesses that use optimization to make operational decisions often solve collections of related optimization problems. Consider three examples: \begin{itemize} \item First, consider a ride-sharing company, such as Uber or Lyft, that makes real-time decisions about how to assign requests for rides to drivers that may fulfill those requests. Such a company might have a single algorithm for making these decisions: its performance depends crucially on tunable parameters. Given a particular distributional forecast of demand patterns, tuned to the particular next time period, and a simulator to estimate the performance of the algorithm using this forecast, this company might wish to optimize the parameters every few hours to find a configuration that would best achieve their goals in that time interval. Such distributional forecasts would be likely to change across hours within a day and across days within a week due to seasonality, and would also vary from week to week as distributional forecasts include more recent historical data due to changing weather, sporting events, etc. \item Second, consider a company managing inventory: to avoid overstocking or outages, an inventory management system has to decide what quantity of each item to hold in stock and how to set the threshold levels to order supplies. To maximize the profit, not only the current market prices have to be taken into account but also holding costs, delivery times affecting the lead times, and patterns in the demand. Thus, the company would re-optimize the parameters of its inventory management system on a regular schedule and whenever any of the key factors change. \item Third, consider a business that relies on machine learning models to predict the behavior of their clients. Suppose that such a model is used to predict ``click-rates'' for ads displayed on a collection of webpages. These predictions are subsequently used to decide which ad is to be displayed to each visitor, based on the user's profile but also on the targets agreed on in the advertising campaigns. To obtain the most accurate predictions, the company would want to retrain the parameters of their model frequently based on the latest historical data, some of which typically have to be fit by a derivative-free method. \end{itemize} The common characteristic of all these problems is that we are to solve very similar problems over and over again. To squeeze the most out of the real time availability of data, we would wish to ``shortcut'' the optimization process, thereby saving time and money and most importantly gaining an edge over competitors, \emph{without} negatively affecting the quality of solutions. One way to avoid a ``cold start'', i.e.\ starting from scratch each time, is to exploit knowledge obtained while previously tackling related problems. This comprises not only the final solutions that were actually used in the application, but also all those evaluated in the respective optimization processes. The idea of using previous solutions to speed up the optimization process is ubiquitous for applications in mathematical programming: in particular, the number of iterations that interior points methods for linear programming require to obtain an almost optimal solution can be reduced by a warm start, e.g., see~\cite{yw02,gw04,jw08}. Typically this is achieved simply by using the solution to a previous optimization problem as the starting point when solving the current problem. This same technique can be used when using stochastic gradient ascent to solve optimization via simulation problems whose objective function evaluations provide stochastic gradients. However, when evaluations of the objective function are derivative-free, as they commonly are when optimizing complex simulators, many of the optimization methods that are most effective for solving a single optimization problem instance lack the structure that would permit warm starting them using this technique. In this article, we create the ability to warm start Bayesian optimization methods. Bayesian optimization methods are effective for solving optimization via simulation problems in which the objective does not provide gradients, is expensive to evaluate, and takes a small number (< 20) of real- or integer-valued inputs. For an overview, see Bayesian optimization tutorials and surveys \cite{fw16,BrCoFr10,kleijnen2014simulation}. Bayesian optimization methods belong to a wider set of optimization via simulation methods that leverage Bayesian statistics and value of information calculations. See, e.g., the surveys of \cite{chick2000,Frazier2011b}. Bayesian optimization methods iteratively construct a Gaussian process metamodel over the objective function and use this metamodel to decide whether to sample next. Because the information carried from iteration to iteration is not just a single point but the full metamodel, simply carrying the solution from a previous problem as a starting point does not provide a warm starting capability to Bayesian optimization, necessitating a more sophisticated approach. While one can partially warm start Bayesian optimization by performing function evaluations of the current problem at solutions to previous problems, this fails to take full advantage of the set of previous evaluations at non-optimal points. In this article, we propose a Bayesian framework that captures the observed relationship of the current black-box function to previous ones. This enables us to perform a ``warm start'' and hence to zoom in on an optimal solution faster. Our approach puts an emphasis on conceptual simplicity and wide applicability. In particular, we will model the tasks and their relationships by a Gaussian Process, whose covariance structure is tailored to capture the differences of the current task and the previous ones. To optimize the current objective, we iteratively sample the search space, using the Knowledge Gradient acquisition criterion proposed by Frazier, Powell, and Dayanik~\cite{FrPoDa_Correlated}; besides its one-step Bayes optimality, this criterion has the advantage that it has a simple form and can be computed efficiently. However, our statistical model is independent of the acquisition function and can be combined with others if that seems beneficial for the application under consideration. \medskip \noindent{\textbf{Related Literature.}} The previous work most directly relevant to warm starting Bayesian optimization and optimization of expensive functions more generally comes from the machine learning literature, where hyper-parameters in machine learning models are fit by solving optimization problems with expensive derivative-free evaluations. Within this literature, the most relevant previous work is due to Swersky, Snoek, and Adams~\cite{ssa13}, who developed a warm start algorithm to tune hyper-parameters of machine learning models using Bayesian Optimization. They demonstrate that their algorithm can speed up the fine-tuning process for hyper-parameters of convolutional neural networks and logistic regression for image classification. Their approach is similar to ours, as they also construct a Gaussian Process model to quantify the relationships between all previous instances and then use an acquisition function, in their case Entropy Search, to optimize the hyper-parameters for the new instance. We believe that our covariance kernel has the following advantages. Their model assumes the covariance of each pair of tasks to be uniform over the whole domain. Moreover, they require that all tasks are positively correlated. Our covariance function does not impose these restrictions and in particular allows for the relationship of tasks to vary over the domain. Additionally, we quantify biases between the objective functions of different tasks. Finally, the inference of the parameters of their kernel requires an expensive sampling-based step, involving slice sampling, whereas our approach performs inference in closed form. In other related work from machine learning, Feurer, Springenberg, and Hutter~\cite{fsh14} proposed a meta-learning procedure that improves the performance of a machine learning algorithm by selecting a small set of start-up configurations. The selection procedure explores the new task and then ranks previous tasks (and their corresponding optimal solutions) based on a metric that relies on an evaluation of the ``metafeatures'' that grasp the characteristics of each dataset. The authors demonstrate that their approach can speed up the process of optimizing hyper-parameters for Support Vector Machines and Algorithm Selection models. This approach differs from ours in three ways: first, the metafeatures and distance functions it develops are specific to machine learning, and extending this approach in a generic way to optimization via simulation problems encountered in operations research would require substantial effort; second, it uses only the final solution from each previous problem, while our approach uses the full set of function evaluations; third, it requires that solutions from previous problems be evaluated under the current objective before they provide useful information, while our approach utilitizes this information directly without requiring additional expensive evaluations. Finally, in the aerospace engineering literature, Gano, Renaud, and Sanders~\cite{grs04} studied the optimization of expensive-to-evaluate functions in a multi-fidelity setting and showed that warm starting optimization of an expensive high-fidelity objective using inexpensive evaluations of a low-fidelity model can reduce the number of high fidelity queries required. This previous work is focused on engineering design problems in which computational codes of various expense and fidelities all model the same objective, while we focus on a sequence of optimization problems with different objectives, that are not ordered by fidelity, and do not necessarily have different computational costs. \medskip \noindent{\textbf{Outline of the Paper.}} The problem is stated formally in Sect.~\ref{section_problem_def}. The warm start algorithm is described in Sect.~\ref{section_model_overall}. The results of an experimental evaluation of the algorithm are presented in Sect.~\ref{section_experiments}. \section{PROBLEM DEFINITION} \label{section_problem_def} We give a formal exposition of the setup. We indicate the current problem to be solved by $\Task_0$, and tasks that have been solved previously by $\Task_\ell$, for $\ell > 0$. We also refer to these optimization problems as ``instances'' or ``tasks'' in the sequel. Let $M$ be the number of previously solved problems, and define~$[M] := \{1,2,\ldots,M\}$ and~$[M]_0 := [M] \cup \{0\}$. We suppose that evaluating~$\Task_\ell$, $\ell\ge0$, at input parameter~$x$ yields independently and normally distributed observations with mean~$f(\ell,x)$ and variance~$\lambda_\ell(x)$, i.e.\ $f(\ell,x)$ denotes the objective value of~$x$ for the current task. We also suppose that accompanying this evaluation is an estimate of $\lambda_\ell(x)$. This assumption of normally distributed noise accompanied by an estimate of the noise's variance is approximately valid when each evaluation is actually an average of many independent and identically distribution observations, whose sample variance provides an estimate of~$\lambda_\ell(x)$. We indicate the current optimization problem's feasible set by $\domain$. This feasible set may be shared with previous problems, or previous problems may have different feasible sets. We assume that $\domain$ is a compact subset of $\mathbb{R}^d$, and that membership in this set can be determined simply without evaluating an expensive function. For example, $\domain$ might be a hyper-rectangle or a simplex. Our goal is to optimize the current task, i.e., to find ~$\argmax_{x \in \domain} f(0,x)$. To support us in this task we have evaluations of previous tasks, in the form of a collection of tuples $(\ell,x,y_\ell(x),\lambda_\ell(x))$, where $y_\ell(x)$ is the sum of $f(\ell,x)$ and independent normally distributed noise with variance $\lambda_\ell(x)$. Typically these would be obtained from runs of the optimization algorithm we propose, or some other optimization algorithm, when solving these previous tasks. Evaluations obtained for other simulation studies can also be included. During optimization for the current task, we assume that previous tasks cannot be evaluated. We make this assumption because maintaining the ability to evaluate previous tasks may present greater practical engineering challenges than simply storing previous evaluations, if previous tasks used different versions of the simulation software, or required access to large historical datasets. In contrast, under the assumptions made below, previous evaluations do not consume a great deal of memory, and can be stored simply in a flat file or database. We make a few additional assumptions that should be met for our proposed methodology to be useful in comparison to other methods. \begin{enumerate} \item First, we suppose that evaluations of $\Task_\ell$ do not provide first- or second-order derivative information. If derivative information is available, it would be more productive to instead use a gradient-based method. \item Second, we suppose that evaluations are expensive to obtain, limiting the number of evaluations that can be performed to at most a few hundred evaluations per problem. When the number of evaluations possible grows substantially larger, the computational expense incurred by our method grows, decreasing its utility. \item Third, we will model both the current problem's objective $x \mapsto f(0,x)$ and the collection of all objectives $(\ell,x) \mapsto f(\ell,x)$ with Gaussian processes, and so we assume that these objectives are amenable to Gaussian process modeling. While Gaussian processes are flexible, and can handle a wide variety of objective functions, they require continuity of $x\mapsto f(\ell,x)$ for each $\ell$ to work well. \item Fourth, while our mathematical approach does not make restrictions on $d$, our numerical experiments all assume that $d\le 8$. Other work on Bayesian optimization suggests that performance degrades on high-dimensional problem, suggesting that the method we develop will provide value only for problems with $d\le 20$. \end{enumerate} \section{WARM START ALGORITHM} \label{section_model_overall} The key idea of our approach is to use samples of the objectives from previous optimization problems to learn about the current optimization problem's objective. To accomplish this, we use a Bayesian prior probability distribution that models the relationship between past objectives $x\mapsto f(\ell,x)$ and the current objective $f(0,x)$. Thereby we begin our optimization of~$\Task_0$ with substantial information obtained from previous tasks, allowing us to find one of its optima faster. More specifically, we place a Gaussian process prior on~$f$, which models the relationships between the tasks. We emphasize that the Gaussian process prior is not just over $x \mapsto f(\ell,x)$ for a single $\ell$, as is typical in Bayesian optimization, but instead is over $(\ell,x) \mapsto f(\ell,x)$. Modeling the objective jointly across tasks allows our approach to learn about the current task from previous ones. This is described in Sect.~\ref{section_model}. The Gaussian process prior utilizes a parametrized class of covariance functions: we describe in Sect.~\ref{section_hyper_estimation} how the parameters for the covariance function can be obtained in our problem setting. These parameters describe the fundamental characteristics of the instances, and therefore are typically robust. We suggest to optimize them periodically rather than for every new task. Then, using this Gaussian process prior over the collection of tasks, we apply Gaussian process regression to update our belief on~$f(0,\cdot)$ based on samples obtained from previously tasks. Although this application of Gaussian process regression is relatively straightforward, we provide a detailed description for completeness in Sect.~\ref{section_gp_prior_and_post} showing how to calculate posterior probability distribution on $f(0,\cdot)$ given the prior from Sect.~\ref{section_model} and samples from previous tasks. Finally, starting from this Gaussian process posterior over the current task's objective $f(0,\cdot)$, we use samples of $f(0,\cdot)$ to localize the optimum. Points are chosen by our algorithm to sample by iteratively solving a sub-optimization problem, in which we find the point to evaluate that maximizes some acquisition function, sample this point, use it to update the posterior, and repeat until our budget of samples is exhausted. We choose as our acquisition function the Knowledge Gradient (KG) proposed by Frazier, Powell, and Dayanik~\cite{FrPoDa_Correlated}; a succinct exposition is given in Sect.~\ref{section_algorithm}. \paragraph*{The Algorithm \WSKG.} The proposed algorithm for warm starting Bayesian optimization proceeds as follows: \begin{enumerate} \item Using samples of previous tasks, and the prior distribution described in Sect.~\ref{section_model}: \begin{enumerate} \item Estimate hyper-parameters of the Gaussian process prior as described in Sect.~\ref{section_hyper_estimation}. \item Use the prior with the estimated hyper-parameters and the samples on previous tasks to calculate a posterior on $f(0,\cdot)$, as described in Sect.~\ref{section_gp_prior_and_post}. \end{enumerate} \item Until the budget of samples on the current task is exhausted: \begin{enumerate} \item Choose the point $x$ at which to sample $f(0,x)$ next by maximizing the KG factor, as described in Sect.~\ref{section_algorithm}. \item Update the posterior distribution to include the new sample of $f(0,\cdot)$, as described in Sect.~\ref{section_gp_prior_and_post}, so that it includes all previous samples on the current and previous tasks. \end{enumerate} \item Choose as our solution the point with the largest estimated value according to the current posterior. \end{enumerate} \subsection{Construction of the Prior} \label{section_model} We begin by describing the construction of the Gaussian Process prior, which models the relationship between previous tasks and the current one. Let~$\delta_\ell(x)$ denote the difference in objective value of any design~$x$ between~$\Task_0$ and~$\Task_\ell$: \begin{equation} \delta_\ell(x) = f(\ell,x) - f(0,x). \end{equation} We construct our Bayesian prior probability distribution over $f$ by supposing that each~$\delta_\ell(\cdot)$ with $\ell>0$ is drawn from an independent Gaussian Process prior with mean function~$\mu_\ell$ and covariance kernel~$\Sigma_\ell$, where~$\mu_\ell(\cdot)$ and~$\Sigma_\ell(\cdot,\cdot)$ belong to some pre-specified parametrized class of functions. For example, we assume in our numerical experiments that $\mu_\ell(\cdot) = 0$, and that~$\Sigma_\ell(\cdot,\cdot)$ belongs to the Mat\'{e}rn covariance functions, a popular class of stationary kernels (see chapter~4.2 in Rasmussen and Williams~\cite{rw06} for details). It would also be possible to set the prior mean $\mu_\ell(\cdot)$ to a constant. Hyper-parameters determining the specific choices for $\mu_\ell$ and $\Sigma_\ell$ from their respective parameterized class can be fit from data in an automated process, as we describe in more detail in Sect.~\ref{section_hyper_estimation}. This $\delta_\ell(x)$ models the difference between previous tasks and the current task. By using knowledge of the typical values of $\delta_\ell(x)$, inferred from the hyper-parameters and from evaluations of $f(\ell,x')$ and $f(0,x'')$ for $x'$ and $x''$ nearby to $x$, we can learn about $f(0,x)$ from knowledge of $f(\ell,\cdot)$. We also suppose that $f(0,x)$ is drawn from another independent Gaussian process with mean function $\mu_0$ and covariance kernel $\Sigma_0$, which also belong to some pre-specified parameterized class of functions. As with $\mu_\ell$ and $\Sigma_\ell$ for $\ell>0$, these parameters may also be chosen automatically as described in Sect.~\ref{section_hyper_estimation}. This specification of the (joint) distribution of $(\ell,x) \mapsto \delta_\ell(x)$ and $x \mapsto f(0,x)$, together with the specification of $f(\ell,x)$ in terms of these quantities, defines a joint Gaussian process probability distribution over $f$. This is because each $f(\ell,x)$ is a linear function of quantities that are themselves jointly Gaussian. By specifying the mean function and covariance kernel of this Gaussian process, which we call $\mu$ and $\Sigma$ respectively, we may leverage standard software for Gaussian process regression. We calculate the functions $\mu$ and $\Sigma$ as follows. For the ease of notation let~$\delta_0(x) = 0$ for all~$x \in \domain$, then we can write~$f$ as $f(\ell,x) = f(0,x) + \delta_\ell(x)$. Then, for $\ell \in [M]_0$, we calculate the mean function as, \begin{equation*} \mu(\ell,x) = \E\left[f(\ell,x)\right] = \E\left[f(0,x) + \delta_\ell(x)\right] = \mu_0(x) + \E\left[\delta_\ell(x)\right] = \mu_0(x), \end{equation*} since~$\E\left[\delta_\ell(x)\right] = 0$. For~$\ell,m \in [M]_0$ and~$x,x' \in \domain$, the covariance kernel is given by \begin{align*} \Sigma\left((\ell,x),(m,x')\right) & = Cov(f(\ell,x),f(m,x'))\\ & = Cov(f(0,x) + \delta_\ell(x), f(0,x') + \delta_m(x')),\\ & = Cov ( f(0,x), f(0,x')) + Cov(\delta_\ell(x), \delta_m(x'))\\ \intertext{and since the Gaussian processes~$\delta_\ell$ and~$\delta_m$ are independent iff~$\ell \neq m$ holds,} & = \Sigma_0(x,x') + \I_{\ell,m} \cdot \Sigma_\ell(x,x'), \end{align*} where we use the indicator variable~$\I_{\ell,m}$ that is one if~$\ell = m$ and~$\ell \geq 1$, and zero otherwise. \subsection{Estimation of the Hyper-Parameters} \label{section_hyper_estimation} When designing the method, we aimed for a wide applicability, and therefore do not assume that further information on the current optimization task~$\Task_0$ and its relationship with previous tasks is given explicitly. Rather we will estimate the important quantities from historical data in an automated fashion as follows. Let~$\theta$ denote the parameters of the covariance function~$\Sigma_\ell$: for instance, in case of the Squared Exponential Kernel~$K(x,y) = \alpha_\ell \exp(\sum_{i = 1}^d \beta_{\ell,i} (x_i - y_i)^2)$ for~$x,y \in \mathbb{R}^d$ there are~$d+1$ parameters. Since we believe that~$\theta$ changes little from instance to instance, we formulate a prior distribution based on previously optimal choices for~$\theta$: let~$p(\theta)$ be the probability under that prior. Moreover, our statistical model provides the likelihood of observations~$Y$ conditioned on the samples~$X$ and~$\theta$, denoted by~$p(Y \mid X, \theta)$. Thinking of~$\theta$ as a random variable, the probability of an outcome for~$\theta$ conditioned on the observations equals the product~$p(Y \mid X, \theta) \cdot p(\theta)$. Thus, the method of maximum a posteriori (MAP) estimation the chooses the hyper-parameters that maximize this product, or equivalently as $\argmax_{\theta} \ln(p(Y \mid X, \theta)) + \ln(p(\theta))$, where~$\ln(\cdot)$ is the natural logarithm. The optimal parameters can be computed efficiently via gradient methods. We refer to Sect.~5.4.1 in~\cite{rw06} for details. \subsection{Acquisition Function} \label{section_algorithm} The proposed algorithm takes as input the historical data, i.e.\ samples obtained in the optimization on previous tasks, and an ``oracle access'' to the current task~$\Task_0$; that is, we consider the objective function a black-box. The actual optimization process is conducted in an iterative manner, where in each iteration a so-called acquisition function selects a point~$x$ to sample. A wide range of these functions has been proposed in the literature. We suggest using the Knowledge Gradient~\cite{FrPoDa_Correlated}: this greedy strategy is known to be one-step (Bayes) optimal and moreover converges to an optimal solution in settings where a finite number of alternatives is given with a multivariate normal prior. From the practical point of view, the main advantage of the Knowledge Gradient is that has been shown to produce good results, but nonetheless can be computed very efficiently (see their paper for details on the implementation). For the sake of a self-contained presentation, we give a brief description of the method. We assume that we have already observed~$n$ points for~$\Task_0$ and are now to decide the next sample. Let~$\mu^{(n)}(x) = \E_n[f(0,x)]$, where~$\E_n$ denotes the expected value under the posterior distribution. Thus, based on our current knowledge, the best~$x \in \domain$ for task~$\Task_0$ has an expected objective value of~$\max_{x \in \domain}\mu^{(n)}(x)$. Note that this value can be computed with our information after observing the~$n$-th sample. Then the Knowledge Gradient~(\KG) selects a design~$x^{(n+1)} \in \domain$ that maximizes $\mathbb{E}_n\left[\max_{x' \in \domain} \mu^{(n+1)}(x') \;\middle|\; x^{(n+1)} = x\right] - \max_{x' \in \domain} \mu^{(n)}(x')$. We obtain an approximation by replacing~$\domain$ by a discrete set of points, denoted by~$\discretedomain$: \begin{equation} \label{Eq_approx_voi_per_cost_def} \mathbb{E}_n\left[\max_{x' \in \discretedomain} \mu^{(n+1)}(x') \;\middle|\; x^{(n+1)} = x\right] - \max_{x' \in \discretedomain} \mu^{(n)}(x'). \end{equation} Set~$\discretedomain$ can either be obtained by randomly sampling from~$\domain$, for example using a Latin Hypercube design to ensure an even coverage. If certain regions of~$\domain$ seem particularly relevant, then~$\discretedomain$ can represent it with higher resolution. Note that the first summand of Eq.~(\ref{Eq_approx_voi_per_cost_def}), the conditional expectation for fixed~$x$, can be calculated from the posterior distribution: recall that~$\mu^{(n)}$ is mean vector and let~$\Sigma^{(n)}$ denote the covariance matrix of the posterior distribution after observing~$n$ samples. Define $\tilde{\sigma}_{x'}(x) = \Sigma^{(n)}_{(0,x'),(0,x)} / (\Sigma^{(n)}_{(0,x),(0,x)} + \lambda_0(x))^{\frac{1}{2}}$. It is well-known (e.g., see~\cite{kailath1968,FrPoDa_Correlated}) that the random variables~$\mu^{(n+1)}(x')$ and~$\mu^{(n)}(x') + \tilde{\sigma}_{x'}(x) \cdot Z$ have the same distributions conditioned on the previous samples. Here~$Z$ is a standard normal random variable. Thus we have that $\mu^{(n+1)}(x') \overset{d}{=} \mu^{(n)}(x') + \tilde{\sigma}_{x'}(x) \cdot Z$ holds for every~$x' \in \discretedomain$. Based on that observation, we can either enumerate all~$x \in \discretedomain$ and pick a point that maximizes Eq.~(\ref{Eq_approx_voi_per_cost_def}), which may be useful if the cost of evaluating the task is very expensive (compared to the computational cost of the enumeration). Or we utilize that the gradient of the~\KG can be computed efficiently (e.g., see~\cite{fxc11,sfp11,pwf16}) and perform a local search over~$\domain$, for instance using a multi-start gradient ascent method. In this case we would require that the noise functions~$\lambda_\ell(\cdot)$ are differentiable. \section{EXPERIMENTAL EVALUATION} \label{section_experiments} We have evaluated the warm start algorithm on two benchmark suites. The first set comprises variants of the two-dimensional Rosenbrock function that is a standard test problem in Bayesian optimization. The second family of testbed instances in this evaluation are taken from the Assemble-To-Order (\ATO) problem that was introduced by Hong and Nelson~\cite{hong2006discrete}. In this eight-dimensional simulation optimization scenario the task is to optimize the target of each item under a continuous-review base stock policy that manages the inventory of a production facility. In order to evaluate the objective value of a specific choice of the parameters, we run the simulator of Xie, Frazier, and Chick~\cite{simopt_ato} available on the SimOpt website. The performance of the warm start algorithm (\WSKG) is compared to two traditional methods that do not benefit from previous optimizations of related tasks. \medskip \noindent\textbf{\EGO.} The first baseline method is the well-known~\EGO algorithm of Jones, Schonlau, and Welch~\cite{JoScWe98}. \EGO is also a myopic algorithm that iteratively selects one point to sample. \EGO's acquisition criterion is to optimize the expected improvement~(\EI): for this exposition suppose that the case that observations are noiseless and that~$y^\ast$ is the best objective value that was sampled so far. Let~$Y_x$ be the random variable that is distributed (normally) according to the posterior distribution of the objective value of some design~$x$, then we call $\EI\left(x\right) := \E\left[\max\left\{Y_x - y^\ast, 0\right\}\right]$ the \emph{expected improvement} for~$x$. In each iteration \EGO greedily samples an~$x$ that maximizes this expectation. \medskip \noindent\textbf{\KG.} In order to assess the benefit of taking data on previous tasks into account, we also compare the new method to the ``vanilla version'' of the Knowledge Gradient~(\KG)~\cite{FrPoDa_Correlated}; see Sect.~\ref{section_algorithm}. \medskip \noindent\textbf{Experimental Setup.} In our evaluation all algorithms are given the same initial data points drawn randomly for each instance and each run. The warm start algorithm is additionally provided with one data set for the Rosenbrock instances and two for~\ATO: each set contains the samples collected during a single run on a related instance. A single run consists of~25 steps (also referred to as iterations) for each of the Rosenbrock instances and~50 steps for the Assemble-to-Order suite. The hyper-parameters of the Gaussian Process affect how accurate the posterior distribution predicts the objective function of the current task. In accordance with our scenario, we optimized the hyper-parameters once for a single instance of each suite and then invoked~\WSKG with this fixed setting for all instances. For the baseline methods~\EGO and~\KG we optimized these parameters for each instance in advance, thereby possibly giving them an edge over~\WSKG in this respect. The plots below provide the mean of the gain over the initial solution for each iteration. Error bars are shown at the mean plus and minus two standard errors, averaged over at least~100 replications. \subsection{The Rosenbrock Family} \label{section_rosenbrock} The basis of these instances is the 2D Rosenbrock function \begin{align*} \label{eq:rosenbrock} RB_1(x_1,x_2) & = (1-x_1)^2 + 100 \cdot (x_2 - x_1^2)^2, \intertext{which subject to the following modifications:} RB_2(x_1,x_2) &= RB_1(x_1,x_2) + .01 \cdot \sin(10 \cdot x_1 + 5 \cdot x_2)\\ RB_3(x_1,x_2) &= RB_1(x_1 + .01,x_2 - .005)\\ RB_4(x_1,x2) &= RB_2(x_1,x_2) + .01\cdot x_1 \end{align*} Moreover, each function evaluation is subject to i.i.d.\ noise with mean zero and variance~$.25$. The task is to optimize the respective function on the domain~$[-2,2]^2$. The results are summarized in Fig.~\ref{fig_rb_1}: the warm start algorithm is able to exploit the knowledge from a single run on a related instance and samples better solutions than the other methods from the first iteration on. In particular, \WSKG obtains a near-optimal solution already after only one or two samples. \KG and~\EGO are distanced, with~\KG showing a superior performance to~\EGO. \begin{figure} \begin{minipage}[t]{0.48\textwidth} \includegraphics[width=\linewidth]{rbCvanN} \includegraphics[width=\linewidth]{rbCsinN} \end{minipage} \hfill \begin{minipage}[t]{0.48\textwidth} \includegraphics[width=\linewidth]{rbCslshN} \includegraphics[width=\linewidth]{rbCbiasN} \end{minipage} \caption{(ul)~The basic Rosenbrock function~$RB_1$. (ur)~The Rosenbrock function~$RB_2$ with an additive sine. (bl)~The shifted Rosenbrock function~$RB_3$. (br)~The Rosenbrock function~$RB_4$ with an additive sine and a bias depending on~$x_1$.} \label{fig_rb_1} \end{figure} \subsection{The Assemble-To-Order Benchmark} In the Assemble-To-Order problem we consider a production facility that sells~$m$ different products that are assembled on demand whenever a customer request comes in. Products are manufactured from a selection of~$n$ different items, where we distinguish for each product between \emph{key items} and \emph{non-key items}: when a product is ordered whose key items are all stocked, then it is assembled and sold. Otherwise the customer is lost. Non-key items are optional and used if available; they increase the revenue. On the other hand, items kept in the inventory inflict \emph{holding cost}, therefore the facility would like to avoid overstocking. The inventory is managed by a continuous-review base stock policy that sets a target stock base for each item and triggers a replenishment order if an item is requested. The delivery time for supplies is normally distributed and varies over the items. Moreover, the orders for products vary, too, and are modeled by~$m$ Poisson arrival processes. The goal is to choose the target stock base used by the inventory management system so that the expected daily profit is maximized. Hong and Nelson~\cite{hong2006discrete} proposed a setting (referred to as \ATO1) for~$n=8$ items,~$m=5$ products, and search domain~$[0,20]^8$. We have created three additional instances based on \ATO1: In the first time period~\ATO2 the forecast sees a change in the customer behavior: the expected demand for the two products that had been most popular before drops by~$3-5\%$. On the other hand, the popularity of two other products grows by up to~$5\%$. Additionally, the profit of some of the items increases by~$1-2\%$ on average. In the next period~\ATO3 the delivery of some of the items is delayed; the expected waiting time increases by about~$3\%$. Moreover, all products see a higher demand and the profits for several items increase. In the final period~\ATO4 the production facility experiences holding costs rising by~$5\%$. Moreover, the profits of several items drop slightly. \begin{figure} \begin{minipage}[t]{0.48\textwidth} \includegraphics[width=\linewidth]{atoC_vanilla} \end{minipage} \hfill \begin{minipage}[t]{0.48\textwidth} \includegraphics[width=\linewidth]{atoC_var2} \end{minipage} \caption{(l) \ATO1 (r) \ATO2: All algorithms have the same initial data for the current problem. \WSKG has also access to samples of two runs on related instances, but its hyper-parameters are not optimized for the current instance.} \label{fig_ato_1} \label{fig_ato_2} \end{figure} \begin{figure} \begin{minipage}[t]{0.48\textwidth} \includegraphics[width=\linewidth]{atoC_var3} \end{minipage} \hfill \begin{minipage}[t]{0.48\textwidth} \includegraphics[width=\linewidth]{atoC_var4} \end{minipage} \caption{(l) \ATO3 (r) \ATO4: \WSKG has received the samples of two runs on related instances.} \label{fig_ato_3} \label{fig_ato_4} \end{figure} When comparing the performance of the three algorithms given in Fig~\ref{fig_ato_1} and Fig~\ref{fig_ato_3} for the task of selecting the inventory levels used by the stocking policy, we see that \WSKG consistently performs significantly better than its competitors, achieving about~$95\%$ of the optimum after only ten samples. Among the two distanced methods, the \KG policy achieves better solutions than~\EGO for the Assemble-To-Order problem. Looking closer, \KG's solution is typically about~$25\%$ away of the optimum after~10 steps, about~$15\%$ after~20 steps, and still about~$4\%$ after~50 steps, depending on the instance. \EGO achieves less than half of the optimum after~20 iterations, and only about~$50-60\%$ after~50 steps. Notably, \EGO shows a large discrepancy between the performance of single runs; the error bar displays the mean averaged over~100 runs. \section{CONCLUSION} \label{section_conclusion} We have proposed an algorithm to warm start Bayesian optimization and demonstrated its usefulness for an application in simulation optimization. The design of the algorithm is conceptually simple and computationally efficient. A typical drawback of such Bayesian optimization methods is their ability to scale to larger input sizes. For the chosen acquisition function, Poloczek, Wang, and Frazier~\cite{pwf16} recently suggested a novel parallelization that efficiently utilizes several multi-core CPUs. Thus, the acquisition function poses no longer the bottleneck of the approach if access to a computing cluster is provided. However, in order to obtain the predictive distribution of the Gaussian Process model involves calculating the Cholesky decomposition to compute the inverse of a matrix, whose running time dependency on the number of previous observations is cubic. There are several approaches to address this and we believe it is worthwhile to combine one of them with the proposed method. On the one hand, a possible direction is to replace the Gaussian Process by a scalable approximation. Several such techniques have been proposed lately, e.g., see~\cite{fwnns15,wn15} and the references therein. A complementary approach to speed up the computations is to reduce the number of data points: instead of the whole data set, a ``sketch'' reduces the number of data points significantly, while the predictions made based on the sketch are nearly indistinguishable from the full dataset. Geppert et al.~\cite{gimqs15} proposed such an approximation and demonstrated its usefulness for applications in Bayesian linear regression. Another approach also based on a linear projection of the dataset to a subspace was given by Banerjee, Dunson, and Tokdar~\cite{bdt12}. Another interesting direction is to extend our statistical model. We sketch two ideas. Recall that the statistical model in Sect.~\ref{section_model} describes the previous tasks as deviations from the current objective~$g(x)$, where each deviation is given by a Gaussian processes~$\delta_\ell$. In particular,~$\delta_\ell$ and~$\delta_{\ell'}$ are supposed to be \emph{independent} for~$\ell \neq \ell'$. Alternatively, we could apply the formulation described in Sect.~2.2 of~\cite{pwf16} to additionally incorporate correlations among previous tasks. A second approach is to suppose that all tasks are derived from an ``ideal'' problem. Then~$f(1,x) = g(x) = f(0,x) + \delta_1(x)$ gives the current task that we want to optimize, and~$f(\ell,x) = f(0,x) + \delta_\ell$ for~$\ell \geq 2$ are the previous tasks. Note that~$f(0,x)$ is not observable in this case and obtained via Gaussian process regression. Both approaches can be implemented with little additional effort. Therefore, we have a collection of flexible models to choose from, depending on the characteristics of the optimization problem at hand.
{'timestamp': '2016-08-12T02:10:53', 'yymm': '1608', 'arxiv_id': '1608.03585', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03585'}
arxiv
\section{Introduction} \IEEEPARstart{U}{biquitous} devices such as smart phones and tablets have fueled the demand for data intensive applications, including ultra high-definition video streaming, social networking and e-gaming. This puts significant pressure on the traditional cellular networks, which are not designed to support such high data rates and reliability requirements. As a consequence, current research on fifth generation (5G) wireless networks is geared towards developing intelligent ways of data dissemination by deviating from the traditional host centric network architecture to a more versatile information centric architecture. Caching in the IP networks has already proved to be a promising way to reduce the overhead of backhaul communication. Borrowing from these principles, caching at the edge of the cellular networks potentially reduces the backhaul access cost in terms of capacity, latency and energy consumption by turning memory into bandwidth \cite{bastug2014living}. Recent observations have indicated that the data traffic consists of a lot of duplications of multimedia content requested by various users in the same vicinity\cite{woo2013comparison}. Therefore, users can leverage this trend to their advantage by accessing information pre-downloaded by their neighboring users using Direct device-to-device (D2D) communication. D2D communication is a promising technique to improve the coverage and throughput of cellular networks \cite{lin2014overview}. Mobile users in close physical proximity can exchange popular files without the intervention of the base station (BS). This not only offloads the burden of duplicate transmissions from the BS, but it also provides higher rates due to short range D2D communication \cite{malandrino2014toward}. Several techniques have been proposed to materialize the concept of integrating D2D communication with cellular networks. The major design questions are: Should D2D communication operate in the cellular uplink or downlink, licensed spectrum or unlicensed spectrum, and in the licensed spectrum should it be underlay or overlay, coordinated by the BS or uncoordinated? In this paper, we focus on coordinated in-band overlay D2D communication in the cellular downlink, where a macro base station (MBS) establishes, manages and arbitrates a D2D connection \cite{fodor2012design}. The reader is referred to a detailed discussion of the other D2D implementation techniques in \cite{asadi2014survey} and the references therein. So, the novelty of this paper is as follows. We propose a new information-centric offloading mechanism, whereby the MBS maintains a record of the previously downloaded contents by the users in its long term-coverage region. Based on this information, the MBS schedules a D2D link between a user and one of its $k$ neighboring D2D helpers subject to the content availability and helper selection scheme. These D2D helper devices can be considered as users which are not receiving any data form the MBS in the current radio frame and can transmit their data. We consider two different helper selection schemes, namely, 1) nearest helper selection (NS): where the MBS selects the D2D helper closest to the user possessing the requested content and 2) uniform selection (US): where the MBS uniformly selects a D2D helper first and checks for content availability later. The estimation of a user's location is much accurate thanks to the in-built GPS and location apps in smart phones. Fig. \ref{fig:SystemModel} displays a simple example of the scenario under consideration. The MBS examines its records for the arrived content requests and schedules possible D2D transmissions. Here, User\#1 is served by its second nearest D2D helper, while User\#2 is served by the MBS as none of its $k$ neighboring helpers have the content. \textcolor{black}{We analyze such a system with the help of }stochastic geometry to quantify the performance improvement compared to conventional and cache enabled single tier cellular networks. Stochastic geometry has recently emerged as a powerful tool to accurately analyze the performance of large scale cellular networks \cite{haenggi2012stochastic}. We make use of the Poisson point process (PPP) assumption in modeling the locations of the MBSs and D2D to derive tractable expressions for various performance metrics. The main contributions of this article are summarized as follows. \begin{itemize} \item For the information-centric offloading paradigm, we consider that both the D2D helpers and BSs are equipped with caches and an arbitrary user requests a certain content based on its popularity. It is important to note that in this work, we focus on devising efficient data dissemination techniques for a given content placement strategy. Based on the content placement strategy, helper selection schemes and other caching parameters, we derive expressions for the probability that an arbitrary user is served in D2D mode for both the NS and US schemes. We obtain bounds on this probability and study its behavior as the number of candidate helpers $k$ grows. \item With the help of our stochastic geometry framework, we derive the distribution of distance between an arbitrary user and its $i$th nearest D2D helper within the cell using a disk approximation for a Voronoi cell. We show that this approximation is fairly accurate for various values of $i$ and compare it with the distribution of distance between the requesting user and its $i$th nearest D2D helper not necessarily present inside the cell. We investigate the conditions in which our derived distribution reduces to the unconstrained case. \item We characterize the coverage probability for individual D2D links and the probability that an arbitrary user is in coverage when it requests a particular content and operates in D2D mode with the NS and US schemes. We also validate our results with network simulations. \item We explore the two important performance metrics, including the overall coverage probability and the average rate experienced by an arbitrary user requesting a particular content $c$. We show that there exists an optimal number of candidate D2D helpers $k$ which maximize the overall coverage and the average rate. The optimal $k$ maximizing the coverage probability is independent of caching parameters or the requested content and only depends on the network parameters. However, that is not the case for the optimal $k$ maximizing the average rate. We also show that high performance gains can be harnessed compared to conventional cellular communication when the most popular contents are requested. \begin{figure} \begin{centering} \includegraphics[scale=0.7]{SystemLevelDiagram} \par\end{centering} \centering{}\caption{Illustration of cache-enabled coordinated D2D network. The MBS pairs the requesting users with one of their $k$ neighbors depending on the content availability and helper selection scheme. If none of the $k$ neighbors have the content, the MBS serves the user itself. \label{fig:SystemModel}} \end{figure} \end{itemize} \subsection{Related Work} Characterization of the performance of caching enabled cellular networks has been widely studied in \cite{ji2014fundamental,ji2016wireless,golrezaei2014base} to name a few. However, all these works make use of the simplistic protocol model, where outage occurs if the intended receiver is at a distance greater than a fixed distance from the transmitter or there is another interfering transmitter present within the range of the receiver. The other approach, which makes use of the physical model, is where the outage occurs on the basis of the received signal-to-interference-and-noise ratio (SINR). Stochastic geometry has been widely applied to analyze the physical layer metrics of the large scale wireless networks. For the case of cache enabled cellular networks, the dynamics of content popularity, propagation conditions and spatial locations are employed in \cite{PerabathiniBKDC15,sarzaidi2015,tamoor2015modeling,bastug2014cache,afshang2015fundamentals,chen2016cooperative,afshang2015modeling,AltieriPVG14} to quantify the performance gains. The analysis of rate and energy efficiency for single-tier cache enabled cellular networks is carried out in \cite{bastug2014cache} and \cite{chen2016cooperative}. An optimal content placement strategy is devised in \cite{chen2016cooperative}, which maximizes the rate coverage and the energy efficiency of the single-tier cellular networks. The authors in \cite{afshang2015modeling} and \cite{AltieriPVG14} consider clustered D2D networks, which operate in isolation from the underlying cellular network. In \cite{afshang2015modeling}, the authors consider clustering to mimic spatial content locality without explicitly considering content popularity and storage. It is assumed that for a user in a given cluster, there will always be a device in that cluster with the requested content i.e., a D2D wireless link is always established. Whereas, the authors in \cite{AltieriPVG14} consider D2D devices with caching and a Zipf type content popularity distribution. Here, clustering is considered so that there are finite transmissions within the cluster multiplexed in time as in TDMA and one link is active at a given time. In \cite{afshang2015fundamentals}, the analysis is carried out with different D2D transmitter selection schemes, but this work makes use of the same clustered users model as in \cite{afshang2015modeling}. All these works do not take into account the coexistence of D2D communication with cellular networks and that if D2D communication is infeasible, the users can communicate with the MBS. For the case of multi-tier analysis with caching, the authors in \cite{sarzaidi2015} and \cite{tamoor2015modeling} consider distributed caching, where a user can access data from the caches of multiple small base stations (SBSs) inside a cell. However, in case of the content availability in any one of the SBSs within the cell, the user is always served by its nearest SBS assuming that the content transfer takes place among the SBSs. This is different from our case as we cannot expect such level of cooperation between D2D helpers and need explicit characterization of the distances of the individual D2D helpers from the arbitrary user. The selection of cellular and D2D modes is studied for the uplink in \cite{lin2014spectrum} and \cite{elsawy2014analytical}. In \cite{lin2014spectrum}, the decision to transmit in D2D mode is based on the distance to the receiver uniformly placed around the D2D transmitter, while in \cite{elsawy2014analytical}, it also depends on the distance from the BS. Both of these approaches ignore the aspects of content availability, popularity and storage. Various content replacement policies and storage techniques are studied in \cite{niesen2014coded,dabirmoghaddam2014understanding,bacstuug2015transfer}. \cite{dabirmoghaddam2014understanding} shows how updating a cache by evicting the least recently used (LRU) content could provide performance gains. It is shown that least frequently used (LFU) policy outperforms LRU in \cite{fricker2012impact}. \cite{bacstuug2015transfer} explores how caches could be updated by exploiting social ties between users using transfer learning approach. \cite{niesen2014coded} proposes coded caching for delay sensitive applications. In \cite{blaszczyszyn2015optimal} and \cite{avrachenkov2016optimization}, the authors explore the effect of geometric placement of caches to devise optimal content placement strategies. A simpler, fixed-caching approach is adopted in \cite{bastug2014cache,LiuY15,AltieriPVG14} and \cite{tamoor2015modeling}, where the cache is not updated and the stored files are simply considered to follow the popularity distribution. The remainder of this paper is organized as follows: Section \ref{sec:System-Model} describes the spatial setup, signal propagation, content popularity and caching models, and the information-centric offloading paradigm for both the NS and US schemes. Section \ref{sec:Distance-to-the} provides the derivation of the distance between an arbitrary user and its $i$th nearest D2D helper within the cell. The distribution of this distance is then used to characterize the overall coverage and the average rate for the NS and US schemes in Section \ref{sec:Link-Spectral-Efficiency}. Section \ref{sec:Results-and-Performance} discusses the results and validates our analysis with network simulations. Section \ref{sec:Conclusion} concludes the paper. \section{System Model\label{sec:System-Model}} We consider a cellular downlink (DL) scenario of MBSs overlaid with D2D helpers. The MBS schedules a requesting user with one of its neighboring D2D helpers inside the cell if the helper has the requested file. The network description and the key assumptions now follow. \subsection{Spatial Model} \begin{figure} \begin{centering} \includegraphics[scale=0.7]{SystemModel} \par\end{centering} \centering{}\caption{Spatial model of the network. MBSs are depicted by blue, filled diamonds; D2D helpers by red, filled triangles; and the requesting user by a filled magenta square. The $k$ candidate D2D helpers for D2D communication are marked with black asterisks (here, $k=4$) and $\lambda_{d}=10\lambda_{m}.$ \label{fig:SpatialModel}} \end{figure} According to the theory of HPPPs, the distribution of $\Phi\left(\mathcal{A}\right)$, where $\mathcal{A}$ is a bounded borel set in $\mathbb{R}^{2}$, is given as \begin{equation} \mathbb{P}[\Phi\left(\mathcal{A}\right)=n]=\frac{\left(\lambda\mu(\mathcal{A})\right)^{n}}{n!}\text{exp}\left(-\lambda\mu(\mathcal{A})\right), \end{equation} where $\lambda$ is the intensity of the HPPP and $\mu\left(\mathcal{A}\right)=\intop_{\mathcal{A}}dx$ is the Lebesgue measure on $\mathbb{R}^{2}$. For a disc of radius $r$ in $\mathbb{R}^{2}$, $\mu\left(\mathcal{A}\right)=\pi r^{2}.$ We consider that the MBSs, D2D helpers and the requesting users are distributed according to independent HPPPs $\Phi_{m}$, $\Phi_{d}$, and $\Phi_{u}$ with intensities $\lambda_{m}$, $\lambda_{d}$ and $\lambda_{u}$ respectively, where $\lambda_{u},\lambda_{d}\gg\lambda_{m}$. The requesting users are associated to the nearest MBS and the user association region is defined as \begin{eqnarray} \mathcal{S}_{i} & \overset{def}{=} & x\in\mathbb{R}^{2}\::\,\Vert y{}_{i}-x\Vert<\Vert y{}_{j}-x\Vert,\nonumber \\ & & \forall\,y{}_{i},y{}_{j}\in\Phi_{m},i\neq j,\label{eq:vcell} \end{eqnarray} where $\mathcal{S}_{i}$ represents a Voronoi cell of the MBS located at $y_{i}\in\Phi_{m}$\footnote{We use the same notation to denote the the node itself and its distance to the origin.}. Without any loss of generality, we measure performance at the requesting user located at the origin. This follows from the palm distribution of HPPPs and Slivnyak's theorem \cite{stoyan1987stochastic}. The MBS selects one of the $k$ closest D2D helpers and establishes a D2D link (the selection process is described in detail in the next section). A realization of the spatial setup is shown in Fig. \ref{fig:SpatialModel}. \subsection{Propagation Model and Spectrum Access} We assume that both the cellular and D2D links experience channel impairments including path loss and small-scale Rayleigh fading. The power received at the origin from the MBS/ D2D helper located at $y\in\Phi_{n},n=\{m,d\}$ is given as $P_{n}h\,y^{-\alpha}\text{,}$ wher \begin{comment} the power decay due to path-loss is modeled by $\Vert\textbf{y}-\textbf{x}\Vert^{-\alpha}$. \end{comment} {} $P_{m}$ and $P_{d}$ are the transmit powers of the MBS and D2D helper respectively, $\alpha$ represents the path loss exponent ranging between 2 and 5 and $h$ is the channel power. We assume that $h$ is a unit-mean exponential RV representing the squared-envelope of Rayleigh fading. We consider an in-band overlay spectrum access strategy, where fixed bandwidths $W_{m}$ and $W_{d}$ are allocated for cellular and D2D communication respectively. We assume that there is universal frequency reuse across the network, but the number of resource blocks is greater than the number of users within the cell and hence, there is no intra-cell interference. \begin{comment} \subsection{Spectrum Access Model} LTE standard defines DL bandwidth (BW) ranging from 1.25-20MHz. A resource block (RB) is the smallest time-frequency slot that a MBS can allocate to a user. It has the bandwidth of 180kHz and time duration of 0.5 ms (half sub-frame) \cite{lte}. and instead of reserving a particular BW or number of RBs for D2D communication, We propose to reserve a fraction $\beta$ of the available DL resources for D2D communication and the remaining $1-\beta$ for cellular communication. \end{comment} \subsection{Content Popularity and Caching Model \label{subsec:Content-Popularity-and}} The performance of caching is crucially determined by the content popularity distribution. It has been observed that the popularity of data follows a Zipf popularity distribution where, the popularity of the $c$th content is proportional to the inverse of $c^{\zeta}$ for some real, positive, skewness parameter $\zeta$. It is mathematically represented as \begin{equation} pop(c)=\rho c^{-\zeta}\;\;1\leq c\leq L,\label{eq:zipf} \end{equation} where $\rho=\left(\sum_{l=1}^{L}l^{-\zeta}\right)^{-1}$ is the distribution normalizing factor and $L$ is the file library size. $\zeta=0$ corresponds to uniform popularity while a higher value of $\zeta$ results in a more skewed distribution. Empirical evidence shows that the value for $\zeta$ exists between 0.6 to 0.8 for different content types including web, file sharing, user generated content (UGC) and video on demand (VoD) \cite{fricker2012impact}. We consider that the MBS and the D2D helpers are equipped with caches of sizes $C_{m}$ and $C_{d}$ respectively. All files are considered to have a unit size. Our analysis can easily be extended for variable file sizes as each memory slot will then contain a chunk of a file. We further assume that user requests follow the independent reference model (IRM) as introduced in \cite{fricker2012impact}. According to the IRM, the user requests for a file in the library are independently generated following the popularity distribution and there is no spatio-temporal locality, i.e. identical contents have the same popularity in space and time \cite{sarzaidi2015}. \subsubsection{Content Placement} We consider that the MBS stores $C_{m}$ most popular files in its cache. The MBS caches the most popular contents, which coincides with the least frequently used (LFU) content placement strategy. Because the content popularity does not rapidly change in time, LFU placement is shown to be well-suited for the MBS. The cellular hit rate for content $c$, which is the probability that the content $c$ is present in the MBS's cache is given as \begin{equation} h_{m}(c)=\mathbb{I}_{c\leq C_{m}}, \end{equation} where $\mathbb{I}_{c\leq C_{m}}$ is an indicator variable taking the value 1 when $c=\{1,..,C_{m}\}$ and 0 otherwise. When there is a set of candidate D2D helpers which can serve a single user, the LFU placement for all D2D helpers is not optimal. Such a scenario requires a collaborative content placement strategy which takes into account the number and the locations of the D2D helpers \cite{blaszczyszyn2015optimal,avrachenkov2016optimization}. Investigating the optimal content placement strategy for D2D helpers for this network setup is a research issue in itself and left for future work. We consider a sub-optimal but tractable content placement strategy for the D2D helpers to quantify the advantage of employing content-centric offloading on D2D mode. We consider that each D2D helper stores the content $c$ in each memory slot independently according to the popularity distribution $pop(c)$. The D2D hit rate for content $c$, is then given as \begin{eqnarray} h_{d}(c) & = & 1-\mathbb{P}[\textnormal{Content }c\text{ not present in }C_{d}\text{ slots}]\nonumber \\ & = & 1-[1-\rho c^{-\zeta}]^{C_{d}}.\label{eq:hitid} \end{eqnarray} \section{Information-Centric Offloading} We assume that for a typical user requesting content $c$, the MBS will examine the contents of up to $k$ neighboring D2D helpers within the cell. The selection of the D2D helper depends on the helper selection scheme and the popularity of the requested content itself. The following proposition gives the probability for the selection of a particular D2D helper. \begin{figure} \begin{centering} \subfloat[\label{fig:Mode-Selection-Probability}]{\begin{centering} \includegraphics[scale=0.65]{pd2d2_FINAL} \par\end{centering} }\hfill{}\subfloat[\label{fig:Effect-of-}]{\centering{}\includegraphics[scale=0.65]{pd2dK}} \par\end{centering} \caption{Effect of helper selection schemes, requested contents, $k$ and $\zeta$ on the probability of D2D and cellular modes.} \end{figure} \begin{prop} The probability that an arbitrary user requesting content 'c' is served by the ith nearest D2D helper within the cell under NS and US schemes is given by \begin{equation} p_{d,NS}^{(k)}(i,c)=\frac{343}{30}\sqrt{\frac{14}{\pi}}\frac{\textnormal{\ensuremath{\Gamma}}(i+3.5)\,\eta_{d}^{i}\,\tensor[_{2}]{F}{_{1}}\left(1,i+3.5;i+1;\frac{\eta_{d}}{(\eta_{d}+3.5)}\right)}{i!\,(\eta_{D}+3.5)^{i+3.5}}\left(1-h_{d}(c)\right)^{i-1}h_{d}(c),\label{eq:pd2diNS} \end{equation} and \begin{eqnarray} p_{d,US}^{(k)}(i,c) & = & h_{d}(c)\biggl[\frac{343}{30}\sqrt{\frac{14}{\pi}}\frac{\textnormal{\ensuremath{\Gamma}}(k+4.5)\,\eta_{d}^{k+1}\,\tensor[_{2}]{F}{_{1}}\left(1,k+4.5;k+2;\frac{\eta_{d}}{(\eta_{d}+3.5)}\right)}{k(k+1)!\,(\eta_{d}+3.5)^{k+4.5}}+\label{eq:pd2diUS}\\ & & \sum_{j=0}^{k-i}\frac{3.5^{3.5}\textnormal{\ensuremath{\Gamma}}(i+j+3.5)\eta_{d}^{i+j}}{\textnormal{\ensuremath{\Gamma}}(3.5)\,(i+j)\,(i+j)!\,(\eta_{d}+3.5)^{i+j+3.5}}\biggr]\nonumber \end{eqnarray} respectively, where $\eta_{d}=\lambda_{d}/\lambda_{m}$, $i=\{1,..k\},$ $\textnormal{\ensuremath{\Gamma}}(a)$ is the complete Gamma function and $\tensor[_{2}]{F}{_{1}}\left(a,b;c;x\right)$ is the generalized hypergeometric function. \end{prop} \begin{IEEEproof} For the user to be served by the $i$th nearest D2D helper, there must be at least $i$ D2D helpers inside the cell. In the NS scheme, the user is served by the $i$th helper if no closer helper has the requested content. This implies \begin{eqnarray} p_{d,NS}^{(k)}(i,c) & = & \mathbb{P}\left[N_{d}\geqslant i\right]\left(1-h_{d}(c)\right)^{i-1}h_{d}(c),\label{eq:pd2di} \end{eqnarray} where $N_{d}$ is the number of D2D helpers in a Voronoi cell whose probability mass function is given as \cite{yu2013downlink} \begin{equation} \mathbb{P}\left[N_{d}=j\right]=\frac{3.5^{3.5}\textnormal{\ensuremath{\Gamma}}(j+3.5)(\lambda_{d}/\lambda_{m})^{j}}{\textnormal{\ensuremath{\Gamma}}(3.5)\,i!\,(\lambda_{d}/\lambda_{m}+3.5)^{i+3.5}}. \end{equation} This implies $\mathbb{P}\left[N_{d}\geqslant i\right]=1-\sum_{j=0}^{i-1}\mathbb{P}\left[N_{d}=j\right]$. Substituting this expression in (\ref{eq:pd2di}) gives (\ref{eq:pd2diNS}). For the US scheme, the user is served by the $i$th helper if it is uniformly selected and has the requested content. This implies \begin{equation} p_{d,US}^{(k)}(i,c)=h_{d}(c)\left[\frac{1}{k}\mathbb{P}\left[N_{d}>k\right]+\sum_{j=0}^{k-i}\frac{1}{i+j}\mathbb{P}\left[N_{d}=i+j\right]\right],\label{eq:pdUSi} \end{equation} Substituting the expressions for $\mathbb{P}\left[N_{d}>k\right]$ and $\mathbb{P}\left[N_{d}=i+j\right]$ completes the proof. \end{IEEEproof} The probability that an arbitrary user is served in D2D mode under NS and US schemes is a straightforward summation of $p_{d,NS}^{(k)}(i,c)$ and $p_{d,US}^{(k)}(i,c)$ over $i=\{1,2..,k\}.$ This gives \begin{equation} p_{d,NS}^{(k)}(c)=\sum_{i=1}^{k}p_{d,NS}^{(k)}(i,c),\label{eq:pd2dNSc} \end{equation} and \begin{equation} p_{d,US}^{(k)}(c)=p_{d,US}^{(1)}(c)=h_{d}(c)\left[1-(1+3.5^{-1}\eta_{d})^{-3.5}\right].\label{eq:pd2dUSc} \end{equation} It is interesting to note that in case of the US scheme, $p_{d,US}^{(k)}(c)$ is independent of $k$. This is because the probability of the D2D mode depends on the contents of only one helper selected at random. \begin{cor} \label{cor:hitSimple} The bounds on $p_{d,\varPi}^{(k)}(i,c),\varPi=\{NS,US\}$ with respect to $\eta_{d}$ are given as \begin{equation} p_{d,NS}^{(k)}(i,c)\leq\left(1-h_{d}(c)\right)^{i-1}h_{d}(c)\label{eq:pdiNSsimple} \end{equation} \begin{comment} \begin{equation} p_{d,NS}^{(k)}(c)\leq1-[1-\rho c^{-\zeta}]^{k\,C_{d}}\label{eq:pdNSsimple} \end{equation} \end{comment} and \begin{equation} p_{d,US}^{(k)}(i,c)\leq\frac{1}{k}h_{d}(c)\label{eq:pdiUSsimple} \end{equation} \begin{comment} \begin{equation} p_{d,US}^{(k)}(c)\leq1-[1-\rho c^{-\zeta}]^{C_{d}},\label{eq:pdUSsimple} \end{equation} \end{comment} {} where the equalities hold when $\lambda_{d}\gg\lambda_{m}$ and $\eta_{d}\rightarrow\infty$. \end{cor} \begin{IEEEproof} As $\eta_{d}\rightarrow\infty$, $\mathbb{P}\left[N_{d}\geqslant k\right]\rightarrow1$, i.e. there are definitely at least $k$ D2D helpers within the cell and (\ref{eq:pd2di}) reduces to $\left(1-h_{d}(c)\right)^{i-1}h_{d}(c)$. It can be easily seen from (\ref{eq:pdUSi}) that as $\mathbb{P}\left[N_{d}\geqslant k\right]\rightarrow1$, $\mathbb{P}\left[N_{d}=i+j\right]\rightarrow0,$ where $i+j<k$. Hence, $p_{d,US}^{(k)}(c)$ reduces to $h_{d}(c)$. \end{IEEEproof} Before moving on to further analysis, we explore the behavior of the D2D mode probability in Figs. \ref{fig:Mode-Selection-Probability} and \ref{fig:Effect-of-}. The values of the simulation parameters used in plotting the results are listed further on in Table \ref{tab:List} unless stated otherwise. We can see that there is a rapid increase in $p_{d,NS}^{(k)}(c)$ initially with the increase in $k$, but diminishing gains are observed when $k$ is further increased. A sharp decrease in $p_{d,NS}^{(k)}(c)$ is observed as the requested content becomes less popular or the skewness parameter $\zeta$ decreases. As established in (\ref{eq:pd2dUSc}), we see that there is no effect of increasing $k$ on $p_{d,US}^{(k)}(c).$ In Fig. \ref{fig:D2Dapprox}, we plot the D2D mode probabilities $p_{d,\varPi}^{(k)}(c)=\sum_{i=1}^{k}p_{d,\varPi}^{(k)}(i,c),\varPi=\{NS,US\}$ using the upper bounds from Corollary \ref{cor:hitSimple} and compare them for the actual values of $p_{d,\varPi}^{(k)}(c)$ in (\ref{eq:pd2dNSc}) and (\ref{eq:pd2dUSc}). We see that the deviation for the NS scheme becomes large as the value of $k$ increases, but convergence is fast and the bounds are fairly tight for $\eta_{d}\geq10$. \begin{figure} \centering{}\includegraphics[scale=0.65]{pd2dKapprox}\caption{Effect of helper density on D2D mode probability.\label{fig:D2Dapprox}} \end{figure} \section{Distance to the $i$th nearest D2D helper within a Macrocell\label{sec:Distance-to-the}} One of the main contributions of this paper is to characterize the distribution of the distance between the typical user and the $i$th nearest D2D helper within the macro cell. It is a well-known fact that the distance between the nearest neighbors for a 2-D Poisson process is Rayleigh distributed and this has been widely adopted for the stochastic geometry analysis of cellular networks \cite{lin2014spectrum,elsawy2014analytical}, \cite{andrews2011tractable,bastug2014cache}. In our case, however, the MBS only keeps a record of the files stored in the memory of D2D helpers within its coverage region. Therefore, it can only connect the requesting user with the helpers within its cell. Fig. \ref{fig:SpatialModel} illustrates that in our spatial setup, the $i$th nearest D2D helper is not always within the macrocell. Hence, this adds a layer of complexity to our model as the distance is no longer independent of the geometrical attributes of the cell, including its shape and size. The distribution of the exact shape and size of a typical Voronoi cell in a 2-D Poisson Voronoi tessellation is still unknown. In their analysis of bivariate Poisson processes in \cite{foss1996voronoi}, Foss and Zuyev make use of the maximal disk approximation for the Voronoi cell. The maximal disk, $B_{max}$, is the largest disk centered at the MBS inscribing the Voronoi cell. The exact characterization of the distribution of the radius $X$ of $B_{max}$ is straight forward as it is the probability that there is no other BS at a distance $2x$ from the tagged BS and is expressed as $\mathbb{P}[X\geq2x]=\text{exp}\left(-4\lambda_{m}\pi x^{2}\right).$ This implies \begin{equation} f_{X}(x)=8\lambda_{m}\pi x\text{ exp}(-4\lambda_{m}\pi x^{2}).\label{eq:rhomax} \end{equation} In this work, we utilize the maximal ball approximation for the Voronoi cell to derive the distribution of the distance between the typical user and its $i$th nearest D2D helper\footnote{In our previous work in \cite{aafzal2016}, we show that the maximal disk approximation is not accurate when the user is placed at a fixed distance from the MBS. In fact, a disk with the same area as the Voronoi cell better approximates the distance. However, in this case, we will show that when the distance $Y$ between the requesting user and the MBS is random, the inscribed disk approximation accurately approximates the distance.}. The following Lemmas provide some useful preliminary results which are necessary conditions for the characterization of the distance distribution. \begin{lem} The probability that the typical user lies inside $B_{max}$ is the probability that the radius of $B_{max}$ is greater than the distance between the MBS and typical user. It is a constant value and is equal to \begin{equation} p_{in}=\mathbb{P}\left[X\geq Y\right]=1/5,\label{eq:pin} \end{equation} where $f_{Y}(y)=2\lambda_{m}\pi y\,\textnormal{exp}(-\lambda_{m}\pi y^{2}).$ \end{lem} \begin{IEEEproof} The distance between the typical user and its tagged MBS is Rayleigh distributed \cite{andrews2011tractable}. This implies $p_{in}=\int_{0}^{\infty}\left[1-F_{X}(y)\right]f_{Y}(y)\,dy$, where $F_{X}(y)=\int_{0}^{y}f_{X}(x)\,dx$. Solving the integrals we get (\ref{eq:pin}). \end{IEEEproof} \begin{lem} The probability that there are at least i D2D helpers inside $B_{max}$ is given as \begin{equation} p_{N_{d}}^{(i)}=5(1+4\eta_{d}^{-1})^{-i}+\frac{10}{3}(1+6\eta_{d}^{-1})^{-i}-8(1+5\eta_{d}^{-1})^{-i}.\label{eq:pNdi} \end{equation} \end{lem} \begin{IEEEproof} Given a disk $B_{max}$ with radius $X=x$, the probability that there are at least $i$ D2D helpers inside the disk is given as \begin{eqnarray*} \mathbb{P}\left[N_{d}\geq i|X=x\right] & = & 1-\sum_{j=0}^{i-1}\frac{\left(\lambda_{d}\pi x^{2}\right)^{j}}{j!}\textnormal{exp}\left(-\lambda_{d}\pi x^{2}\right)=1-\frac{\textnormal{\ensuremath{\Gamma}}(i,\lambda_{d}\pi x^{2})}{\textnormal{\ensuremath{\Gamma}}(i)}. \end{eqnarray*} Integrating over $X=x$ while ensuring $X>D$, we obtain \begin{equation} p_{N_{d}}^{(i)}=\intop_{0}^{\infty}\biggl[\intop_{y}^{\infty}\left[1-\frac{\textnormal{\ensuremath{\Gamma}}(i,\lambda_{d}\pi x^{2})}{\textnormal{\ensuremath{\Gamma}}(i)}\right]\,f_{X}(x)\,F_{Y}(x)\,dx\biggr]\,f_{Y}(y)\,dy, \end{equation} where $F_{Y}(x)=\int_{0}^{x}f_{Y}(y)\,dy$. Simplification after evaluating the integrals and normalizing with $p_{in}$ yields (\ref{eq:pNdi}). \end{IEEEproof} We now give the distribution of distance in the following Theorem. \begin{thm} \label{prop:dist}The distribution of the distance between the typical user and its ith nearest D2D helper within the cell can be well approximated using the inscribed disk approximation for a Voronoi cell and is given as \begin{multline} f_{R_{i}}(r)=\biggl[\intop_{0}^{\infty}f_{Y}(y)\intop_{a_{1}}^{a_{2}}f_{i,1}(r,y,x)\,f_{X}(x)\,F_{Y}(x)dx\,dy+f_{i,2}(r)\kappa(r)\biggr]\frac{1}{p_{in}\,p_{N_{d}}^{(i)}},\label{eq:fr} \end{multline} where, \begin{equation} f_{i,1}(r)=\frac{\lambda_{d}^{i}}{\textnormal{\ensuremath{\Gamma}}(i)}\nabla(r,y,x)^{i-1}\nabla^{'}(r,y,x)\,\textnormal{exp}(-\lambda_{d}\nabla(r,y,x)),\label{eq:f1r} \end{equation} \begin{equation} f_{i,2}(r)=2\frac{\left(\lambda_{d}\pi\right)^{i}}{\textnormal{\ensuremath{\Gamma}}(i)}r^{2i-1}\textnormal{exp}(-\lambda_{d}\pi r^{2}),\label{eq:f2r} \end{equation} \begin{eqnarray} \kappa(r) & = & \frac{\textnormal{exp}\left(-4b\right)}{15}+b\sqrt{\pi}\biggl[\frac{\sqrt{6}}{9}\textnormal{exp}\left(\frac{b}{6}\right)\textnormal{erfc}\left(\frac{5\sqrt{6b}}{6}\right)-\frac{4\sqrt{5}}{25}\textnormal{exp}\left(-\frac{4b}{5}\right)\textnormal{erfc}\left(\frac{4\sqrt{5b}}{5}\right)\biggr],\nonumber \\ \label{eq:kappaR} \end{eqnarray} where $b=\lambda_{m}\pi r^{2}$, $\nabla(r,y,x)=r^{2}\arccos\left(\frac{\omega_{1}}{2y\,r}\right)+x^{2}\arccos\left(\frac{\omega_{2}}{2y\,x}\right)-\frac{1}{2}\sqrt{4y^{2}x^{2}-\omega_{2}^{2}}$, $\omega_{1}=r^{2}+y^{2}-x^{2}$, $\omega_{2}=x^{2}+y^{2}-r^{2}$, $\nabla^{'}(r,y,x)$ is the derivative of $\nabla(r,y,x)$ with respect to $r$, $a_{1}=\max(y,r-y)$ and $a_{2}=r+y$. \end{thm} \begin{IEEEproof} Please refer to Appendix \ref{sec:Proof1}. \end{IEEEproof} The expression in (\ref{eq:fr}) is validated with network simulations in Section \ref{sec:Results-and-Performance}. Before further analysis, we develop some insights on the derived distance distribution in (\ref{eq:fr}). We can write $f_{R_{i}}=T_{1}+T_{2}$, where $T_{1}=(p_{in}\,p_{N_{d}}^{(i)})^{-1}\intop_{0}^{\infty}\intop_{a_{1}}^{a_{2}}f_{i,1}(r,y,x)\,f_{X}(x)\,F_{Y}(x)dx\,f_{Y}(y)dy$ and $T_{2}=(p_{in}\,p_{N_{d}}^{(i)})^{-1}f_{i,2}(r)\kappa(r)$. We wish to see how the density of MBSs impacts $T_{1}$ and $T_{2}$ and in turn $f_{R_{i}}$. \begin{cor} \label{cor:sparseDist}For sparse networks, i.e. when $\lambda_{m}\rightarrow0(\eta_{d}\rightarrow\infty),$ $f_{R_{i}}(r)$ reduces to the distribution of distance to the unconstrained nearest D2D helper and is given by (\ref{eq:f2r}). \end{cor} \begin{IEEEproof} Referring to Appendix \ref{sec:Proof1}, we see that when $\lambda_{m}\rightarrow0$, $x\gg r$ and $b(o,r)$ almost surely lies inside $B_{max}$. This in turn means $T_{1}\rightarrow0$. However, as $\lambda_{m}\rightarrow0$, we see from (\ref{eq:kappaR}) and (\ref{eq:pNdi}) that $\kappa(r)=1/15$ and $p_{N_{d}}^{(i)}=1/3$. As $p_{in}=1/5$ is fixed, $T_{2}$ reduces to $f_{i,2}(r)$. \end{IEEEproof} Fig. \ref{fig:T1T2} reinforces the result in Cor. \ref{cor:sparseDist}. We compare (\ref{eq:fr}) with the unconstrained $i$th nearest neighbor distribution \cite{moltchanov2012survey}. We see that when the network is sparse, the term $T_{2}$ dominates $f_{R_{i}}(r)$ and the distribution of the distance to the $i$th nearest neighbor essentially approaches that of unconstrained case. This conclusion can be intuitively explained as we would expect that for very large cell sizes, the $i$th nearest D2D helper will reside in the same macrocell. However, as the MBS density increases, $T_{1}$ begins to increase and cannot be ignored. That is when (\ref{eq:fr}) begins to significantly deviate from (\ref{eq:f2r}). \section{Performance Analysis under NS and US schemes\label{sec:Link-Spectral-Efficiency}} To assess the performance of cellular networks enhanced with coordinated D2D communication, we define the following quality-of-service (QoS) parameters. \subsection{Overall coverage probability } The typical user is in coverage in cellular mode when the received signal to interference and noise ratio (SINR) is greater than a certain modulation dependent decoding threshold $\tau_{m}$. This is mathematically characterized as \[ \varGamma_{m}=\mathbb{P}\left[SINR_{m}\geq\tau_{m}\right]. \] Similarly, in D2D mode, when the user is served by its $i$th nearest D2D helper, the coverage probability is written as \[ \Gamma_{d,i}=\mathbb{P}\left[SINR_{d,i}\geq\tau_{d}\right], \] where $\tau_{d}$ is the SINR threshold in D2D mode. We define the overall coverage probability $\Gamma_{\varPi}^{(k)}(c)$ of an arbitrary user requesting content $c$ by the following expression \begin{equation} \Gamma_{\varPi}^{(k)}(c)=(1-p_{d,\varPi}^{(k)}(c))\Gamma_{m}+p_{d,\varPi}^{(k)}(c)\Gamma_{d,\varPi}^{(k)}(c),\label{eq:OverallCov} \end{equation} where $\Gamma_{d,\varPi}^{(k)}(c)$ is the probability of coverage in D2D mode for a given $k$, content request $c$ and D2D helper selection scheme $\varPi=\{NS,US\}$. Here, $p_{d,\varPi}^{(k)}(c)$ and $\left(1-p_{d,\varPi}^{(k)}(c)\right)$ are the probabilities for D2D and cellular modes respectively. Our first step is to obtain the D2D and cellular coverage probabilities of a typical link. When the typical user is operating in cellular mode, we have from \cite{andrews2011tractable} \begin{equation} \Gamma_{m}=\pi\lambda_{m}\int_{0}^{\infty}\textnormal{exp}\left(-\pi\lambda_{m}\nu\left(1+\delta_{m}(s_{m},\alpha)\right)-\frac{\tau_{m}\sigma^{2}}{P_{m}}\nu^{\alpha/2}\right),\label{eq:covC} \end{equation} where $\Gamma_{m}$ is the cellular coverage probability, $s_{m}=\tau_{m}\nu^{\alpha}$ and $\delta_{m}(s_{m},\alpha)=\tau_{m}^{2/\alpha}\intop_{\tau_{m}^{-2/\alpha}}(1+u^{\alpha/2})du$. \begin{figure} \begin{centering} \includegraphics[scale=0.65]{PDF_T1_T2} \par\end{centering} \caption{Effect of varying $\lambda_{m}$ on $T_{1}$ and $T_{2}$: $i=1,\lambda_{d}=200/A,A=\pi500^{2}.$ \label{fig:T1T2}} \end{figure} \begin{prop} \label{prop:covD}Given that the typical user is served in D2D mode, the probability of coverage under the NS and US schemes can be expressed as \begin{equation} \Gamma_{d,\varPi}^{(k)}(c)=\frac{\sum_{i=1}^{k}p_{d,\varPi}^{(k)}(i,c)\Gamma_{d,i}}{\sum_{i=1}^{k}p_{d,\varPi}^{(k)}(i,c)},\;\varPi=\{NS,US\},\label{eq:covDk} \end{equation} where $\Gamma_{d,i}$ is the coverage probability when the typical user is served by the ith nearest D2D helper and is given as \begin{eqnarray} \varGamma_{d,i} & \approx & \intop_{r=0}^{\infty}\textnormal{exp}\left(-2\pi\frac{s_{d}\tilde{\lambda}_{m}\delta_{d}(s_{d},\alpha)}{(\alpha-2)}\right)\textnormal{exp}\left(-s_{d}\frac{\sigma^{2}}{P_{d}}\right)f_{R_{i}}(r)\,dr\label{eq:covD2D} \end{eqnarray} where $s_{d}=\tau_{d}r^{\alpha}$, $\delta_{D}(s,\alpha)=\mathbb{E}_{Q}\left[q^{-(\alpha-2)}\tensor[_{2}]{F}{_{1}}\left(1,\bar{\alpha};1+\bar{\alpha};-sq^{-\alpha}\right)\right]$, $\bar{\alpha}=1-2/\alpha$ and $f_{Q}(q)=2\pi\tilde{\lambda}_{M}q\,\textnormal{\textnormal{\textnormal{exp}}}(-\tilde{\lambda}_{M}\pi q^{2}).$ \end{prop} \begin{comment} \begin{prop} \begin{equation} \mathbb{E}_{q}\left[\text{exp}\left(-\pi\lambda_{m}s^{2/\alpha_{d}}\intop_{u_{min}}^{\infty}\frac{1}{1+u^{\alpha_{d/2}}}du\right)\right]\label{eq:} \end{equation} with $u_{min}=\left(\frac{q}{r\tau^{1/\alpha_{d}}}\right)^{2}$. \end{prop} \begin{IEEEproof} After applying a change of variables to (\ref{eq:laplaceD2D})-$(c)$, we obtain (\ref{eq:}). \end{IEEEproof} \end{comment} \begin{IEEEproof} Please refer to Appendix \ref{sec:Proof2} \end{IEEEproof} \subsection{Average Rate} Using a similar exposition as in the previous subsection, we express the average rate $T_{\varPi}^{(k)}(c)$ experienced by an arbitrary user requesting content $c$ under the NS and US schemes as \begin{equation} T_{\varPi}^{(k)}(c)=\left(1-p_{d,\varPi}^{(k)}(c)\right)\overline{R_{m,\varPi}}(c)+p_{d,\varPi}^{(k)}(c)\overline{R_{d,\varPi}}(c)\text{\;bps},\label{eq:tp} \end{equation} where $p_{d,\varPi}^{(k)}(c)$ and $\left(1-p_{d,\varPi}^{(k)}(c)\right)$ are the probabilities for D2D and cellular communication and $\overline{R_{m,\varPi}}(c)$ and $\overline{R_{d,\varPi}}(c)$ are respectively the average cellular and D2D rates. \begin{prop} \label{prop:Rd}The average rate experienced by an arbitrary user requesting content 'c' in D2D mode under NS and US schemes is expressed as \begin{equation} \overline{R_{d,\varPi}^{(k)}}(c)=W_{d}\gamma\left(\eta_{u_{d,\varPi}}\right)\frac{\sum_{i=1}^{k}p_{d,\varPi}^{(k)}(i,c)R_{d,i}}{p_{d,\varPi}^{(k)}(c)}, \end{equation} \begin{equation} R_{d,i}=\mathbb{E}\left[\textnormal{log}_{2}(1+SINR_{d,i})\right],\label{eq:Rdi} \end{equation} where $\varPi=\{NS,US\}$, $\gamma(a)=\left(1-\textnormal{exp}\left(-a\right)\right)/a$, $W_{d}$ is the bandwidth reserved for D2D communication and $\eta_{u_{d,\varPi}}=\lambda_{u_{d,\varPi}}/\lambda_{m}$. Here, $\lambda_{u_{d,\varPi}}=\lambda_{u}\rho\sum_{c=1}^{L}c^{-\zeta}p_{d,\varPi}^{(k)}(c)$ is the average density of users operating in D2D mode. \end{prop} \begin{IEEEproof} The average D2D rate can be written as \begin{equation} \overline{R_{d,\varPi}^{(k)}}(c)=\mathbb{E}\left[\frac{W_{d}}{N_{u_{d,\varPi}}}\right]R_{d,\varPi}^{(k)}(c), \end{equation} where $R_{d,\varPi}^{(k)}(c)$ is the\textcolor{black}{{} average capacity of the link when content $c$ is requested. It is obtained by taking the expectation of (\ref{eq:Rdi}), which is the average ergodic capacity of a D2D link between an arbitrary user and its $i$th nearest D2D helper.} $\mathbb{E}\left[W_{d}/N_{u_{d,\varPi}}\right]$ is the average bandwidth available for the communication on a D2D link where $N_{u_{d,\varPi}}\sim\textnormal{Poisson }(\eta_{u_{d,\varPi}})$ is the number of simultaneously active users in D2D mode inside the cell\footnote{To simplify the analysis, we assume that the number of users in D2D mode is the same as the number of active D2D helpers. This might not be the case in reality as one helper can serve multiple users in its vicinity if they request the same file. With our analysis, such a situation will translate into the transmission of the same file by the same D2D helper but on a separate portion of the spectrum. }. Hence, \begin{eqnarray} \mathbb{E}\left[1/N_{u_{d,\varPi}}\right] & = & \sum_{n=1}^{\infty}\frac{1}{n}\frac{(\eta_{u_{d,\varPi}})^{n-1}}{(n-1)!}\textnormal{exp}\left(-\eta_{u_{d,\varPi}}\right),\nonumber \\ & = & \eta_{u_{d,\varPi}}^{-1}\left(1-\textnormal{exp}\left(-\eta_{u_{d,\varPi}}\right)\right). \end{eqnarray} where the summation starts from $n=1$ to account for the presence of the user under consideration. \end{IEEEproof} \begin{prop} \label{prop:Rc}The average rate experienced by an arbitrary user requesting content 'c' in cellular mode under NS and US schemes is expressed as \begin{equation} \overline{R_{m,\varPi}^{(k)}}(c)=W_{m}\hat{R}_{m}\gamma\left(\eta_{u_{m,\varPi}}\right) \end{equation} where $\hat{R}_{m}(c)=R_{m}\left(\mathbb{I}_{c\leq C_{m}}+\beta\,\mathbb{I}_{c>C_{m}}\right)$ is the average capacity of cellular links, $\mathbb{I}_{c\leq C_{m}}$ and $\mathbb{I}_{c>C_{m}}$ are respectively the cellular hit and miss rates, $R_{m}=\mathbb{E}\left[\textnormal{log}_{2}(1+SINR_{m})\right]$ , $\beta$ is the backhaul delay coefficienct, $W_{m}$ is the cellular bandwidth, and $\eta_{u_{m,\varPi}}=\lambda_{u_{m,\varPi}}/\lambda_{m}$ with $\lambda_{u_{m,\varPi}}=\lambda_{u}(1-\rho\sum_{c=1}^{L}c^{-\zeta}p_{d,\varPi}^{(k)}(c))$. \end{prop} \begin{IEEEproof} The proof is on the similar lines as Proposition \ref{prop:Rd} with the exception that the average density of cellular users is $\lambda_{u}-\lambda_{u_{d,\varPi}}$, i.e. all the users which are not operating in D2D mode are shifted to cellular mode. Furthermore, when the requested content is not present in the MBS cache, the average rate of the cellular link is reduced by a factor $\beta$, which accounts for the delay introduced by fetching the content from backhaul. \end{IEEEproof} \section{Results and Discussion\label{sec:Results-and-Performance}} \begin{table}[t] \begin{centering} \begin{tabular}{|l|l|l|} \hline Parameter & Description & Value\tabularnewline \hline \hline $\alpha$ & Path loss exponent & 4\tabularnewline \hline $\lambda_{m},\lambda_{d},\lambda_{u}$ & MBS, D2D helper and user density & $[10,100,200]/\pi500^{2}$\tabularnewline \hline $\zeta$ & Popularity skewness parameter & 0.8\tabularnewline \hline $c,L$ & Requested content, Library size & 1, $10^{4}$\tabularnewline \hline $\beta$ & Backhaul delay coefficient & 0.8\tabularnewline \hline $C_{d},C_{m}$ & D2D and MBS cache sizes & 20, 500\tabularnewline \hline $W_{m},W_{d}$ & Cellular and D2D bandwidth & $[7,3]$ MHz \tabularnewline \hline $P_{m},P_{d}$ & Cellular and D2D transmit power & $[30,23]$ dBm\tabularnewline \hline $\tau_{m},\tau_{d}$ & Cellular and D2D SINR threshold & $[30,30]$ dBm\tabularnewline \hline $\sigma^{2}$ & Noise power & -110 dBm\tabularnewline \hline \end{tabular} \par\end{centering} \caption{List of simulation parameters\label{tab:List}} \end{table} In this section, we will give some key results and verify our analysis with Monte Carlo simulations. For our simulation setup, the MBSs and D2D helpers are distributed according to HPPPs with intensities $\lambda_{m}$ and $\lambda_{d}$ respectively and the performance is measured at the origin. We first validate the distribution of distance to the $i$th nearest D2D helper derived in Theorem \ref{prop:dist} for various values of $i$. For the simulations, we ignore the realizations in which the number of D2D helpers is less than $i$ in the typical cell. In case of the disk approximation, the realizations in which the typical user lies outside $B_{max}$, or there are less than $i$ D2D helpers inside $B_{max}$, are all ignored. Fig. \ref{fig:Dist} shows that the disk approximation is very accurate, while the unconstrained nearest neighbor distribution in (\ref{eq:f2r}) does not encapsulate the behavior of the distance distribution and the deviations from the actual distribution become large as the value of $i$ increases. \begin{figure} \centering{}\includegraphics[scale=0.6]{PDF_rk1_rk2_rk3_20_200}\caption{Distribution of the distance to the $i$th nearest D2D helper from the tagged user within the Voronoi cell, where $\lambda_{m}=20/\pi500^{2},$ and $\lambda_{d}=200/\pi500^{2}$.\label{fig:Dist}} \end{figure} Fig. \ref{fig:covD} validates our analysis of the probability of coverage $\Gamma_{d,i}$ when the typical user is being served by the $i$th nearest D2D helper ((\ref{eq:covD2D}) in Theorem \ref{prop:covD}). We see that the disk approximation holds fairly accurately for all values of $i$. The slight deviation of the analysis using the disk approximation from the simulations using disk approximation is because of the equi-dense HPPP approximation for the D2D interferers. As expected, we see a decrease in $\Gamma_{d,i}$ with the increases in $i$ for a fixed SINR threshold. This is because, as $i$ increases, the distance between the transmitting D2D helper and the typical user increases, thereby aggravating the path loss. For comparison, we also plot the cellular coverage $\Gamma_{m}$ given in (\ref{eq:covC}). For a given SINR threshold, we see that small values of $i$ result in a much better coverage for a D2D link compared to the cellular link. \begin{figure} \centering{}\includegraphics[scale=0.65]{SINRd_k2}\caption{Probability of coverage when a typical user is served by the MBS or the $i$th nearest D2D helper. \label{fig:covD}} \end{figure} Fig. \ref{fig:Overall-D2D-coverage} illustrates the probability of being in coverage in D2D mode. We also validate the D2D coverage probability $\Gamma_{d,\varPi}^{(k)}(c),\varPi=\{NS,US\}$ derived in Theorem \ref{prop:covD} (\ref{eq:covDk}). For each simulation trial, maximum $k$ closest D2D helpers are first checked for content availability. The content availability ($c=1$ in this case) is a Bernoulli event with probability $h_{d}(c)$. Out of the successful D2D helpers (if there are any), the helper is selected either uniformly (US scheme) or closest to the origin (NS scheme). We see that the D2D coverage probability for the NS scheme outperforms the US scheme. This is because in the US scheme, a D2D helper is uniformly selected out of the maximum $k$ closest helpers, while the closest helper is given preference in the NS scheme. \begin{figure}[b] \subfloat{\rule[0.5ex]{0.75\paperwidth}{0.9pt}} \begin{equation} \Gamma_{US}^{(k)}(c)\approx\left[1-\rho c^{-\zeta}\right]^{C_{d}}\Gamma_{m}+\frac{1}{k}\left(1-\left[1-\rho c^{-\zeta}\right]^{C_{d}}\right)\sum_{i=1}^{k}\Gamma_{d,i}\label{eq:CovUSsimp} \end{equation} \begin{equation} \Gamma_{NS}^{(k)}(c)\approx\left[1-\rho c^{-\zeta}\right]^{kC_{d}}\Gamma_{m}+\left(1-\left[1-\rho c^{-\zeta}\right]^{C_{d}}\right)\sum_{i=1}^{k}\left[1-\rho c^{-\zeta}\right]^{(i-1)C_{d}}\Gamma_{d,i}\label{eq:CovNSsimp} \end{equation} \end{figure} \begin{figure} \centering{}\includegraphics[scale=0.65]{SINRd_k_AVGvsUniform_B10D100}\caption{\label{fig:Overall-D2D-coverage}Coverage probability in D2D mode under the NS and US schemes. } \end{figure} The behavior of the D2D coverage probability $\Gamma_{d,\varPi}^{(k)}(c),\varPi=\{NS,US\}$ is further investigated when the value of $k$ is changed. We can see from Fig. \ref{fig:D2D-coverage-for} that the increase in $k$ adversely affects $\Gamma_{d,US}^{(k)}(c)$. However, the effect on $\Gamma_{d,NS}^{(k)}(c)$ is much less pronounced. \begin{figure} \centering{}\includegraphics[scale=0.65]{SINRd_k_NearestVsUniform_Analysis}\caption{\label{fig:D2D-coverage-for}D2D coverage for various values of $k$ (increasing to the left). } \end{figure} \begin{figure} \centering{}\includegraphics[scale=0.6]{AvgCoverage}\caption{\label{fig:OverallCov}Effect of increasing $k$ on the overall coverage probability for various content requests. } \end{figure} \begin{figure} \begin{centering} \includegraphics[scale=0.6]{AvgCoverageNSoptK} \par\end{centering} \caption{Effect of D2D caching parameters on $k_{NS}^{*}$.\label{fig:kOptNS}} \end{figure} \begin{figure} \begin{centering} \includegraphics[scale=0.6]{CovGain} \par\end{centering} \caption{Percentage maximum gain in the overall coverage with coordinated D2D under NS and US schemes.\label{fig:Percentage-gain-in}} \end{figure} \subsection{Performance Evaluation} \begin{figure}[b] \subfloat{\rule[0.5ex]{0.75\paperwidth}{0.9pt}} \begin{equation} T_{US}^{(k)}(c)\approx\left[1-\rho c^{-\zeta}\right]^{C_{d}}W_{m}\gamma\left(\eta_{u_{m,US}}\right)\hat{R}_{m}(c)+\frac{W_{d}}{k}\gamma\left(\eta_{u_{d,US}}\right)\left(1-\left[1-\rho c^{-\zeta}\right]^{C_{d}}\right)\sum_{i=1}^{k}R_{d,i}\label{eq:tpsimpUS} \end{equation} \begin{eqnarray} T_{NS}^{(k)}(c) & \approx & \left[1-\rho c^{-\zeta}\right]^{kC_{d}}W_{m}\gamma\left(\eta_{u_{m,NS}}\right)\hat{R}_{m}(c)\nonumber \\ & & +W_{d}\gamma\left(\eta_{u_{d,NS}}\right)\left(1-\left[1-\rho c^{-\zeta}\right]^{C_{d}}\right)\sum_{i=1}^{k}\left[1-\rho c^{-\zeta}\right]^{(i-1)C_{d}}R_{d,i}\label{eq:tpsimpNS} \end{eqnarray} \end{figure} We now study the performance metrics defined in Sec. \ref{sec:Link-Spectral-Efficiency} with respect to the two key parameters, namely, the number of candidate neighboring D2D helpers $k$ and the requested content $c$. We first consider the overall coverage probability $\Gamma_{\varPi}^{(k)}(c),\varPi=\{NS,US\}$ given in (\ref{eq:OverallCov}). The simplified expressions for $\Gamma_{\varPi}^{(k)}(c)$ are presented in (\ref{eq:CovUSsimp}) and (\ref{eq:CovNSsimp}) using the upper bounds for $p_{\varPi}^{(k)}(i,c)$ from Corollary \ref{cor:hitSimple}. In Fig. \ref{fig:OverallCov}, the overall coverage probability for the US scheme $\Gamma_{US}^{(k)}(c)$ is seen to monotonically decrease with the increase in $k$, starting with a maximum value at $k_{US}^{*}=1$. This is because, from Fig. \ref{fig:covD} we see that the D2D link coverage $\Gamma_{d,i}$ decreases as $i$ increases and even gets worse compared to the cellular link coverage $\Gamma_{m}$. As $k$ increases in (\ref{eq:CovUSsimp}), the contribution of $\Gamma_{d,1}$ decreases in the second term corresponding to the coverage in D2D mode. Intuitively, this means that the MBS does not make an intelligent decision in the selection of the D2D helper and may select a helper farther from the requesting user for D2D communication. As the first term in (\ref{eq:CovUSsimp}) is independent of $k$, and $\Gamma_{d,i}$ is a decreasing function in $i$, (\ref{eq:CovUSsimp}) is always maximized when $k_{US}^{*}=1$. On the contrary, the plots for $\Gamma_{NS}^{(k)}(c)$ reveal an interesting trade off in the selection of $k$ to maximize the overall coverage. We see that for a given SINR threshold (and also $\tau_{d}=\tau_{m}$), there exists an optimal value of $k=k_{NS}^{*}$, which maximizes $\Gamma_{NS}^{(k)}(c)$ (shown by the dotted line). The explanation for this phenomenon is given as follows. We see that as $k$ is increased, the probability of cellular mode is decreased as the term $\left[1-\rho c^{-\zeta}\right]^{kC_{d}}$ premultiplied with $\Gamma_{m}$ in (\ref{eq:CovNSsimp}) decreases. Initially, $\Gamma_{NS}^{(k)}(c)$ rises with the increase in $k$ and attains a maximum value at $k_{NS}^{*}$, but with further increase in $k$, the coverage $\Gamma_{d,i}$ with the activated D2D links is no longer better than the cellular coverage as already seen from Fig. \ref{fig:covD}, hence, $\Gamma_{NS}^{(k)}(c)$ begins to drop. We observe that as the requested content $c$ becomes less popular, both $p_{NS}^{(k)}(c)$ and $p_{US}^{(k)}(c)$ drop, and for the least popular requested content $\Gamma_{\varPi}^{(k)}(c)\rightarrow\Gamma_{m}$ as $h_{d}(c)\rightarrow0$ implying that the requesting user can only be served in cellular mode. It can also be seen that varying $c$ does not affect the optimal value $k_{NS}^{*}$. In Fig. \ref{fig:kOptNS}, we also observe the effect of the other crucial D2D caching parameters, $\zeta$ and $C_{d}$ on $\Gamma_{NS}^{(k)}(c)$. We see that $k_{NS}^{*}$ is also resilient to the changes in $\zeta$ and $C_{d}$, but the maximum value of the overall coverage $\Gamma_{NS}^{(k)}(c)$ increases with the increase in $\zeta$ and $C_{d}$. This is due to the fact that popular content $c$ or higher values of $\zeta$ and $C_{d}$ all translate into a higher probability of being served by the $i$th nearest D2D helper as $p_{\varPi}^{(k)}(i,c)$ increases $\forall i=\{1,..,k\}$, but these parameters do not affect the link quality ($\Gamma_{m}$ and $\Gamma_{d,i}$). Therefore, $k_{NS}^{*}$ is independent of the caching parameters. To better visualize the improvement in coverage compared to the conventional cellular network scenario, we compute the gain in the overall coverage probability. It is the percentage difference between the maximum attainable overall coverage probability under the NS and US schemes $\Gamma_{\varPi}^{(k_{\varPi}^{*})}(c),\varPi=\{NS,US\}$ and the conventional cellular coverage probability. It is given as \[ G(c)=\frac{\Gamma_{\varPi}^{(k_{\varPi}^{*})}(c)-\Gamma_{m}}{\Gamma_{m}}\times100\%. \] Figure \ref{fig:Percentage-gain-in} shows that for popular content requests and skewed popularity distribution, more than 50\% better coverage can be obtained with the NS scheme compared to the conventional scenario. The US scheme does not perform as good as the NS scheme, but it yields sufficient gains (35\% at best under the given network setting). \begin{figure} \centering{}\includegraphics[scale=0.7]{AvgRateVsK_VaryingC}\caption{Effect of increasing $k$ on the average rate experienced by an arbitrary user for various content requests.\label{fig:AvgRateC}} \end{figure} We will now focus on the analysis of average rate experienced by the user in the US and NS schemes to gain some more useful insights on the design of cellular networks enabled with coordinated D2D communication. The simplified expressions for $T_{US}^{(k)}(c)$ and $T_{NS}^{(k)}(c)$ using Corollary \ref{cor:hitSimple} are given in (\ref{eq:tpsimpUS}) and (\ref{eq:tpsimpNS}) respectively. For the average rate with the US scheme, we see from (\ref{eq:tpsimpUS}) that $T_{US}^{(k)}(c)$ exhibits the same behavior as $\Gamma_{US}^{(k)}(c)$ the increase in $k$ reduces the average rate in D2D mode because D2D helpers located farther from the requesting user are selected with the probability equal to the nearest helpers. Hence, $\Gamma_{US}^{(k)}(c)$ is only maximized when $k=k_{US}^{*}=1$. To visualize when maximum gains can be harnessed with the NS scheme, we plot the $\Gamma_{NS}^{(k)}(c)$ in Fig. \ref{fig:AvgRateC} and compare it with the rates experienced by the user in a cellular only network. The rate experienced by the user in a cellular network where the MBS is equipped with caching capability is given as \begin{equation} T_{m}^{(ca)}=(W_{m}+W_{d})\gamma\left(\eta_{u}\right)R_{m}. \end{equation} Notice that all of the bandwidth $W_{d}+W_{c}$ is used for cellular communication and $\eta_{u}=\lambda_{u}/\lambda_{m}$ as all the requesting users in the cell share the cellular link capacity. When there is no caching at the MBS, the rate is reduced by a fraction $\beta$ due to the delay introduced by the backhaul communication and is given as \begin{equation} T_{m}^{(bh)}=\beta T_{m}^{(ca)}. \end{equation} The following conclusions can be drawn from Fig. \ref{fig:AvgRateC}. Coordinated D2D communication with content centric mode selection greatly enhances data rates compared to cellular only scenarios when popular contents are requested. This is because we know that for small $c$, $h_{d}(c)$ (and in turn $p_{NS}^{(k)}(i,c)$) increases implying that more users can be served by their nearest D2D helper in D2D mode. For least popular contents, the rate experienced by the requesting user is severely degraded and is even lower than the cellular only scenario. This is because, $h_{d}(c)\rightarrow0$ and the user is pushed to communicate in cellular band $W_{m}$, which is less than the total bandwidth $W_{m}+W_{d}$ of the cellular only scenario. Yet again, there exists a trade off in the selection of the number of neighboring D2D helpers $k$ which maximizes the average throughput experienced by an arbitrary user. The existence of the optimal value of $k=k_{NS}^{*}$ for $T_{NS}^{(k)}(c)$ follows the same reasoning as $\Gamma_{NS}^{(k)}(c)$, as $R_{d,i}$ follows the same trend as $\Gamma_{d,i}$ and is decreasing in $i.$ However, Unlike the $\Gamma_{NS}^{(k)}(c)$, this value of $k=k_{NS}^{*}$ does vary with the changes in $c$ and increases as $c$ increases. This is because, as we have from Proposition \ref{prop:Rd} \begin{eqnarray*} \eta_{u_{d,NS}} & = & \frac{\lambda_{u}}{\lambda_{m}}\left[\rho\sum_{c=1}^{L}c^{-\zeta}p_{d,NS}^{(k)}(c)\right]\\ & = & \frac{\lambda_{u}}{\lambda_{m}}\left[1-\rho\sum_{c=1}^{L}c^{-\zeta}[1-\rho c^{-\zeta}]^{kC_{d}}\right], \end{eqnarray*} where $\gamma\left(\eta_{u_{d,NS}}\right)=\eta_{u_{d,\varPi}}^{-1}\left(1-\textnormal{exp}\left(-\eta_{u_{d,\varPi}}\right)\right)$ is a decreasing function in $k$. This means that more users are offloaded from cellular to D2D mode as $k$ increases and the available bandwidth \textbf{$W_{d}\gamma\left(\eta_{u_{d,NS}}\right)$ }for a user in D2D mode decreases. When $k\rightarrow\infty,$ $\gamma\left(\eta_{u_{d,NS}}\right)\rightarrow\gamma\left(\eta_{u}\right)$ implying that all the requesting users are served in D2D mode. We know that as $c$ increases, then the term $1-\left[1-\rho c^{-\zeta}\right]^{C_{d}}$ decreases in (\ref{eq:tpsimpNS}) and the D2D rate decreases. To effectively utilize the D2D bandwidth $W_{d}$, more users need to be activated in D2D mode and hence, $k_{NS}^{*}$ increases. \section{Conclusion\label{sec:Conclusion}} In this paper, we presented a novel framework for the analysis of cache-enabled cellular networks with coordinated D2D communication. The arbitrary user requesting a particular content is offloaded to communicate with one of its $k$ neighboring D2D helpers within the cell based on the content availability and helper selection schemes. We derived the distribution of the distance between the user and its $i$th nearest D2D helper within the cell using disk cell approximation, which is shown to be fairly accurate. We obtained the probabilities for being served in cellular and D2D modes and the coverage and data rates experienced by the user in both these modes. With the help of our analysis, we showed that the information-centric offloading with coordinated D2D results in high performance gain. However, to maximize the performance, the number of candidate D2D helpers $k$ has to be carefully tuned. \appendices{} \section{Proof of Theorem\label{sec:Proof1} \ref{prop:dist}} The probability that the distance between the requesting user and the $i$th nearest D2D helper within the cell is at least $r$ is the probability that there are exactly $i-1$ helpers inside the region $\mathcal{A}$. It can be expressed as \begin{equation} 1-F_{R_{i}|X=x,X>D,N_{d}\geq i}(r)=\frac{\left(\lambda_{d}\mathcal{A}\right)^{i-1}}{(i-1)!}\,\textnormal{exp}\left(-\lambda_{d}\mathcal{A}\right),\label{eq:cdflens} \end{equation} where $\mathcal{A}$ is the area of intersection between $B_{m}$ and $b(o,r).$ As shown in Fig. \ref{fig:distnearest}, this area can be divided into two regimes given as follows. \begin{itemize} \item Regime 1 - When $b(o,r)$ partly overlaps $B_{m}$, i.e. $x-y<r<x+y$. The overlapping area $\mathcal{A}$ in this case can be written as \cite{weisstein2003circle} \\ \begin{eqnarray} \nabla(r,y,x) & = & r^{2}\arccos\left(\frac{\omega_{1}}{2y\,r}\right)+x^{2}\arccos\left(\frac{\omega_{2}}{2y\,x}\right)-\frac{1}{2}\sqrt{4y^{2}x^{2}-\omega_{2}^{2}},\label{eq:lens} \end{eqnarray} where $\omega_{1}=r^{2}+y^{2}-x^{2}$ and $\omega_{2}=x^{2}+y-r^{2}$. \item Regime 2 - When $b(o,r)$ lies inside $B_{m}$ i.e. $0<r<x-y$. The overlapping area in this case is straightforward and is given as $\mathcal{A}=\pi r^{2}.$ \end{itemize} Differentiating $F_{R_{i}|X=x,X>D,N_{d}\geq i}(r)$ in (\ref{eq:cdflens}) with respect to $r$ gives (\ref{eq:f1r}) and (\ref{eq:f2r}) for regimes 1 and 2 respectively. The unconditional distance distribution $f_{R_{i}}(r)$ in (\ref{eq:fr}) is obtained by averaging over $X$ and $Y$, where $X>Y$ and $N_{d}\geq i$. \begin{figure} \begin{centering} \subfloat[]{\centering{}\includegraphics[scale=0.6]{DistanceWithinCircularCell}}\enskip{}\subfloat[]{\centering{}\includegraphics[scale=0.6]{DistanceWithinCircularCellLens}} \par\end{centering} \caption{Distance to the nearest D2D neighbor within the circular Voronoi cell: (a) when $b(o,r)$ is inside $B_{max}$, (b) when $b(o,r)$ partly overlaps $B_{max}$. \label{fig:distnearest} } \end{figure} \section{Proof of Proposition\label{sec:Proof2} \ref{prop:covD}} The probability of coverage for the typical user served by the $i$th nearest D2D helper can be expressed as \begin{eqnarray} \varGamma_{d,i} & = & \mathbb{P}\left\{ \frac{h_{i}\,r^{-\alpha}}{\sigma^{2}/P_{d}+I_{d}}>\tau_{d}\right\} \label{eq:covD} \end{eqnarray} where $I_{d}=\sum_{z_{j}\in\Phi_{d}^{int}}g_{j}\,z_{j}^{-\alpha}$ is the inter-cell interference from other active D2D helpers, which is the sum of powers from the active D2D helpers constituting $\Phi_{d}^{int}$. Here, $z_{j}$ is the distance of the the interfering D2D helper from the typical user and $g_{j}$ is the channel power for the interfering link $j$. Because of the exponentially distributed channel power $h_{i}$ in (\ref{eq:covD}), we get \begin{equation} \varGamma_{d,i}=\mathbb{E}_{R_{i}}\left[\exp\left(-s_{d}\sigma^{2}/P_{d}\right)\mathcal{L}_{I_{d}}\left(s_{d}\right)\right],\label{eq:Covdi} \end{equation} where $s_{d}=\tau_{d}r^{\alpha}$ and $\mathcal{L}_{I_{d}}\left(s_{d}\right)=\mathbb{E}_{I_{d}}\left[\exp\left(-s_{d}I_{d}\right)\right]$ is the Laplace transform of D2D interference. Because only one D2D helper can be active at one channel in a given macrocell, we employ a key assumption that $\Phi_{d}^{int}$ is a HPPP with intensity $\tilde{\lambda}_{m}=p_{int}\times\lambda_{m}$ \footnote{The equi-dense HPPP assumptions ignores the correlations due to the position of helpers inside a cell, but is more tractable. \cite{elsawy2014analytical}}. Here, $p_{int}=1-\left(1+3.5^{-1}\eta_{d}\right)^{-3.5}$ is the probability that at least one interfering D2D helper is present in a cell. $\mathcal{L}_{I_{d}}\left(s_{d}\right)$ can then be presented as \begin{eqnarray} \mathcal{L}_{I_{d}}\left(s_{d}\right) & = & \mathbb{E}\left[\text{exp}\left(-s_{d}\sum_{\textbf{z}_{j}\in\Theta_{d}}g_{j}\,z_{j}^{-\alpha}\right)\right]\nonumber \\ & \overset{(a)}{=} & \mathbb{E}_{Q}\biggl[\exp\biggl(-2\pi\tilde{\lambda}_{m}\intop_{q}^{\infty}\frac{\nu}{1+s_{d}^{-1}\nu^{\alpha}}\,d\nu\biggr)\biggr]\label{eq:laplaceD2D} \end{eqnarray} where $(a)$ follows from the generating functional of a HPPP and the exponential distribution of the channel power $g$. The lower limit of the integral in (\ref{eq:laplaceD2D}) represents the guard zone. Notice that the lower limit $q$ in this case is governed by the nearest active D2D interferer, where $f_{Q}(q)=2\pi\tilde{\lambda}_{m}q\,\text{exp}(-\tilde{\lambda}_{m}\pi q^{2})$ because of the equi-dense HPPP approximation. As $\tilde{\lambda}_{M}$ is quite small, we can apply Jensen's inequality to achieve a tight bound for (\ref{eq:laplaceD2D}) \begin{equation} \mathcal{L}_{I_{d}}\left(s_{d}\right)\thickapprox\exp\left(-2\pi\tilde{\lambda}_{m}\mathbb{E}_{Q}\left[\intop_{q}^{\infty}\frac{\nu}{1+s_{d}^{-1}\nu^{\alpha}}\,d\nu\right]\right).\label{eq:lapDJen} \end{equation} Substituting (\ref{eq:lapDJen}) into (\ref{eq:Covdi}) gives (\ref{eq:covD2D}). The overall D2D coverage probability for NS and US schemes and a particular content request in (\ref{eq:covDk}) is obtained by taking expectation over $i$ and by conditioning over the probability of D2D mode. \bibliographystyle{IEEEtran}
{'timestamp': '2017-12-21T02:07:03', 'yymm': '1608', 'arxiv_id': '1608.03429', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03429'}
arxiv
\section{Introduction} Testing software components without access to source code or hand-crafted models is challenging because there is no guidance for the selection of test inputs. Selection is invariably guided by intuition or, if automated, by random or quasi-random input generation algorithms \cite{Hamlet1994,Chen2004,Claessen2011}. Left to chance alone, random test sets can easily fail to expose facets of software behaviour that depend upon specific input characteristics. Furthermore it can become exceedingly difficult to reason about the adequacy of a randomly-generated test set, especially for non-numerical programs without an operational profile \cite{Hamlet1994}. Recently, several ``Learning-Based Testing'' (LBT) techniques have emerged \cite{Raffelt2009,Walkinshaw2009,Lei2013,Fraser2015} that aim to address these limitations. LBT techniques are based on the idea, first espoused by Weyuker \cite{Weyuker1983} and Budd and Angluin \cite{Budd1982}, that there is a natural duality between inductive model inference and software testing. The former seeks to infer a general model of behaviour for a system from an incomplete sample of observations of its behaviour. The latter seeks to identify the smallest possible set of observations that are required to expose the full range of behaviour. Although the ultimate purposes are different, both are bound by an intrinsic challenge: attempting to establish the link between the often infinite range of externally observable behaviour of a system and a finite sample of observations (or vice versa). LBT techniques seek to exploit this duality by using Machine Learning algorithms to infer input / output models from test executions. These models can then be used to derive new test cases. The rationale is that this ought to form a virtuous loop (or, to adopt Popper's terminology, a cycle of ``conjecture and refutation'' \cite{Popper1953}) where the inferred models become increasingly detailed and accurate, and thereby drive the test generation to produce increasingly rigorous test sets. The step of generating new test inputs from an inferred model is especially important. New test inputs ought ideally to expose `new' aspects of software behaviour that have not featured in previous test executions. Intuitively, the test generation approach tends to be closely tied to the type of inferred model (e.g., if an approach infers a state machine, it will tend to adopt a state machine testing algorithm to derive new tests \cite{Walkinshaw2009,Meinke2011}). Unfortunately, there are two barriers that currently restrict LBT approaches to relatively specific classes of relatively small-scale software systems: \begin{compactenum} \item The dependence between the type of inferred model and the test generation approach can be highly limiting. Whole families of powerful Machine Learning algorithms have to be excluded as they do not produce explicit, `testable' models. \item The application of model-based test generation approaches to inferred models can yield large numbers of test cases, which hampers scalability. Many of the generated tests are of little \emph{utility} to the learner. Whereas the goal is to find `counter-examples' to the inferred models, the majority of test cases can merely end up corroborating what is already known. \end{compactenum} In this paper we investigate the possibility of using an Active Learning query strategy frameworks \cite{Settles2010,Seung1992} to circumvent these limitations. In Machine Learning, query strategy frameworks provide a means by which to use an existing inferred model (or set of models) to select further samples that are most likely to be of ``high utility'' to the learner -- i.e. provide information that is not already contained within the training set. These tend to be based on the principle that the best samples are those whose prediction elicits the highest degree of \emph{uncertainty} with respect to the current model. In the context of LBT, if one accepts the existence of a relationship between the adequacy of a test set and the accuracy of a model inferred from it, then it should follow that test cases selected by an effective uncertainty sampling technique should form an effective basis for test case selection. In detail, the contributions of this paper are as follows: \begin{compactitem} \item We introduce the first application of query strategy frameworks to test generation (Section~\ref{sec:qbc_test}). \item We present an implementation of a query strategy framework for test generation using Query By Committee~\cite{Seung1992} on inferred models (Section~\ref{sec:qbc_test}). \item We propose the use of Genetic Programming~\cite{Koza1992} as a basis for model inference, as it directly enables Query By Committee (Section~\ref{sec:qbc_test}). \item We present an implementation of an LBT-based testing using query strategy frameworks, based on Genetic Programming and Query By Committee (Section~\ref{sec:qbc_test}). \item We present an empirical evaluation on eight functions provided within the Apache Commons Math and JodaTime frameworks, using mutation testing to assess the effectiveness of the generated test cases (Section~\ref{sec:eval}). \end{compactitem} Our experiments demonstrate that uncertainty sampling leads to a higher mean number of mutants detected than random or adaptive random testing (the baseline techniques we use in this paper). It also tends to require fewer test executions to produce higher numbers of mutants. This is especially valuable for test-scenarios where there is a non-trivial cost associated with test execution (e.g. tests take a prohibitive amount of time, or their outputs need to be checked by a human test-oracle). \section{Automated Black-box Testing} Black-box testing in general refers to the concept of testing a software system without access to its source code. Ideally, black-box testing is driven by detailed formal specifications or test models, which enable techniques to automatically generate tests, and act as test oracle that decides whether a given test execution revealed a fault or not. In practice, such specifications are not always available, in which case automated generation of tests is limited to few options. \subsection{Random Testing} The most common approach to test automation in the absence of formal specifications and source code is to randomly select tests, for example using a uniform distribution on the input space or an operational profile \cite{Hamlet1994}. The effectiveness of random testing highly depends on the specifics of the system under test: Random testing is generally unlikely to find specific input values~\cite{Arcuri2012}, and may perform poorly at covering the underlying behaviour of the program. Adaptive Random Testing (ART)~\cite{Chen2004} aims to alleviate these problems by ensuring that tests are spread out across the program input space as much as possible. In general, ART works iteratively by repeatedly sampling a set of random inputs, and out of this set selecting the input that is most different to previously executed tests as the next test to run on the system under test. While there is evidence that this approach makes the selected tests more effective than a completely random selection, every test input adds to complexity of generating the next test input, because there is an additional point in euclidean space against which to measure the next group of random inputs. If running a test on a system under test is cheap, then pure random testing may be more effective than ART~\cite{Arcuri2011} as it can simply execute significantly more tests in the same time as ART. However, in practice test execution can often take a long time, and the absence of an automated oracle (e.g., a formal specification) may make it necessary to manually investigate every single test outcome. Thus, we assume that it is desirable to generate the most effective set of tests, rather than relying on the ability to run large sets of potentially redundant tests. \subsection{Learning-Based Testing} We use the term `Learning-Based Testing' (LBT) to refer to the (now relatively broad) family of techniques that seek to use Machine Learning to support the generation of test cases. The idea was first explored by Weyuker \cite{Weyuker1983} and Budd and Angluin \cite{Budd1982} in the early eighties. For the subsequent 15 years it was the subject of some predominantly theoretical research \cite{Cherniavsky1987,Zhu1992,Romanik1997}. However, over the subsequent 15 years it adopted a more practical bent, with several authors developing accompanying proof-of-concept tools \cite{Bergadano1996,Raffelt2009,Lei2013,Walkinshaw2009,Meinke2011,Fraser2015,Papadopoulos2015}. \addtolength{\textfloatsep}{-\baselineskip} \begin{algorithm}[t] \SetKwInput{KwUses}{Uses} \KwIn{$SUT$,$TestInputs$} \KwUses{$terminate$, $execute$, $selectInputs$, $inferModel$} \KwResult{$TestInputs$} $hyp$ $\leftarrow \emptyset$ \; $Executions$ $\leftarrow \emptyset$ \; \For{($input \leftarrow TestInputs$)}{ $Executions \leftarrow Executions \cup execute(input)$\; } \While{($\neg$ terminate($Executions$,$hyp$,$SUT$))}{ $hyp$ $\leftarrow$ inferModel($Executions$)\; $NewInputs$ $\leftarrow$ selectInputs($hyp$,$SUT$)\; $Executions \leftarrow Executions \cup execute(SUT,NewInputs)$\; $TestInputs \leftarrow TestInputs \cup NewInputs$\; } \Return{$TestInputs$}\; \caption{Generic LBT procedure} \label{alg:iterativeAlgorithm} \end{algorithm} \addtolength{\textfloatsep}{1\baselineskip} Algorithm \ref{alg:iterativeAlgorithm} shows the main generic LBT steps: \begin{compactitem} \item The algorithm starts with an initial set $TestInputs$ of inputs to the program. This may be empty, but it may also be an established test set that we wish to improve. \item The loop of model inference and test generation is executed until a stopping criterion \textbf{terminate($Executions$,$hyp$)} evaluates to true. For example, it might attempt to establish the equivalence between the inferred model $hyp$ and the system under test $SUT$, and return true if the model is sufficiently similar in some sense \cite{Raffelt2009}. It might alternatively simply terminate after a fixed number of iterations, if $Tests$ reaches a particular size, or there has been no change to $hyp$ after a certain number of iterations. \item In this loop, the first step is to infer a predictive input/output model \textbf{hyp} of the program using the function \textbf{inferModel($Executions$)}. The type of the model can vary, and depends on the nature of the system under test. Proposed techniques have adopted state machines \cite{Raffelt2009,Walkinshaw2009}, decision trees \cite{Briand2009,Fraser2015} and Daikon invariants~\cite{Ghani2008}. \item The input to the \textbf{inferModel} function are the executions, i.e., the input/output pairs resulting from executing the test inputs $TestInputs$ on the system under test $SUT$ using function \textbf{execute($SUT$,$Inputs$)}. \item Finally, \textbf{selectInputs($hyp$,$SUT$)} selects new inputs. The test generation strategy might be random \cite{Papadopoulos2015}, driven by source code coverage~\cite{Fraser2015}, or using a model-based test algorithm with respect to $Mod$ \cite{Raffelt2009}. \end{compactitem} Much of the research on combining inference and testing has focussed on the interplay between the \emph{terminate} and \emph{inferModel} functions --- on the ability to leverage inference mechanisms to provide more meaningful adequacy criteria. This is what motivated most of the early research into the area as well~\cite{Weyuker1983,Cherniavsky1987,Zhu1992}. Recent inference and test generation techniques have been combined to guarantee that the behaviour of the system has been exercised to a certain extent. For example, several researchers have combined Angluin's $L*$ inference technique~\cite{Angluin1987} with established state machine testing techniques~\cite{Raffelt2009,Lei2013} and showed that these lead to strong guarantees that the inferred model accurately represents what has been explored. \begin{figure}[t] \includegraphics[width=\columnwidth]{problem} \vspace{-2em} \caption{The relationship between `learnability' and `testability' in LBT.} \label{fig:problem} \vspace{-1em} \end{figure} \subsection{Limitations of Learning-Based Testing} LBT techniques tend to be limited in their practical applicability because they rely on the inference of models that not only approximate the behaviour of the SUT, but are \emph{also} usable as a basis for automated test generation. As illustrated in Figure \ref{fig:problem}, the processes of inference and testing are highly interdependent; the model has to be \emph{learnable} from the SUT \cite{Valiant1984}, but also has to be \emph{testable}, in the sense that it can provide a suitable basis for the generation of new test cases. This explains why LBT techniques so far have been largely restricted to state machines \cite{Raffelt2009,Walkinshaw2009,Lei2013}, decision trees \cite{Briand2009,Papadopoulos2015}, and invariants~\cite{Ghani2008}. As a consequence, entire families of Machine Learning algorithms that infer models that are harder to subject to symbolic reasoning are excluded, even if they could potentially infer more accurate models from a broader class of SUT's. These include kernel-method techniques such as SVM \cite{Vapnik1995}, Neural Net learners \cite{Bishop1995}, and Genetic Programming~\cite{Koza1992}. Aside from the constraints mentioned above, the use of `off-the-shelf' test generation techniques, coupled with the iterative nature of the approach, can lead to scalability problems. Test generation algorithms generate test cases without considering the test cases that have been generated in previous iterations. This can produce very large test sets, especially if the testing algorithm in question produces large numbers of test cases anyway (e.g., the popular W-Method \cite{Chow1978} for state machines is a good example of an algorithm that does not scale well, and has often used for test-driven model inference \cite{Raffelt2009}). The primary challenge addressed in this paper is to find a means by which to remove the constraints on the classes of Machine Learners that can be applied to LBT. Although we want to remove the constraints on the types of models that are inferred, it is crucial that they can still guide test generation, and do so in a scalable way that does not needlessly re-test behaviour that has already been tested. \section{Query Strategy Frameworks} \label{sec:uncertainty_sampling} In this paper we will show how the above problem can be solved by the use of query strategy frameworks, a core facet of active learning techniques \cite{Settles2010} in Machine Learning. Precisely how this is achieved will be described in the next section. Here we provide a generic introduction to query strategy frameworks and Query by Committee. \subsection{Query Strategy Frameworks} Machine Learning algorithms can be broadly categorised into conventional (\emph{passive}) Machine Learners and \emph{active} Machine Learners. Passive learners infer models from data that is given to them before learning commences. Active learners might start from some given data, but crucially are also imbued with the ability to obtain further data. The learner might surmise that the inferred model is incomplete because the initial sample lacked data of a certain characteristic, so the learner can set out to obtain more relevant data, which it can use to refine its model. The active learning setting gives rise to the \emph{query strategy problem} \cite{Settles2010}. The process of obtaining a sample might be expensive, so it is consequently important to keep the number of queries (additional samples) down to a minimum. However, any additional data that \emph{is} sampled must be of a \emph{high utility} --- i.e., it must lead to improvements in the model inferred by the learner. This problem has been the subject of a large amount of research over the past two decades (a good overview is provided by Settles \cite{Settles2010}). The essential goal is to avoid selecting a query that fails to add new information that is of value to the learner. Any new data should ideally confound the predictions of the current model. One factor that plays a key role in selecting queries is the notion of \emph{uncertainty}. Given a data-point that was not part of the original training set (referred to as a `query'), the degree of uncertainty exhibited by the current hypothesis model as to how it should be classified can provide an indication of how useful it would be to obtain a real sample. The goal is thus to identify queries for which the level of confidence in the corresponding output is at its lowest, with the aim of eliciting aspects of behaviour that were perhaps under-represented in the training sample. One key challenge is to find a suitable metric that can be used to assess this ``uncertainty'' for a given model prediction. For statistical Machine Learners, where the output is often in the form of a probability distribution, numerous uncertainty sampling techniques have been developed \cite{Settles2010}. However, in the context of LBT, models such as inferred state machines tend not to be probabilistic. \subsection{Query By Committee} There is a `trick' that enables the application of uncertainty sampling even when the inferred models are themselves not probabilistic. If one can, from a given sample, infer \emph{multiple} different models, then it becomes possible to use their mutual agreement / disagreement to estimate a level of uncertainty and use this as a basis for uncertainty sampling \cite{Seung1992}. Algorithm \ref{alg:qbc} shows the Query By Committee (QBC) approach proposed by Seung \emph{et al.} \cite{Seung1992}. \begin{algorithm}[t] \SetKwInput{KwUses}{Uses} \KwIn{$Train$, $i$, $s$,$comitteeSize$,$randomPoolSize$} \KwUses{$learnMultiple$,$best$, $computeUtility$, $randomPoints$} \KwResult{$Hyp$} $Hyp$ $\leftarrow \emptyset$ \; \For{$i$ iterations}{ $Hyp \leftarrow learnMultiple(Train,comitteeSize)$\; $U \leftarrow randomPoints(randomPoolSize)$\; \For{$s$ iterations}{ \tcp{Pick a point $u \in U$ with max utility} $u = argmax_{x \in U}||computeUtility(Hyp,x)||$\; $l = label(u)$\; $Train \leftarrow Train \cup \{l\}$\; $U \leftarrow U \setminus \{u\}$\; } } $Hyp \leftarrow learnMultiple(Train)$\; \Return{$best(Hyp)$}\; \caption{Query By Committee} \label{alg:qbc} \end{algorithm} \begin{compactitem} \item The entire process iterates for a fixed number of iterations~($i$). \item At each iteration, the \textbf{learnMultiple} function produces a ``committee'' of hypothesis models. This is conventionally achieved by Ensemble Methods \cite{Melville2004}, which produce different hypotheses by inferring models from different samples of the training set (in this paper we will illustrate an alternative approach of using the population generated by a Genetic Programming algorithm). \item Once the models have been inferred, the \textbf{randomPoints} function generates a set of random `inputs' $U$ -- in Machine Learning terms this is a set of \emph{unlabelled} data points. The size of $U$ is determined by the $randomPoolSize$ parameter. \item The nested for-loop then essentially picks a subset of $s$ points in $U$. These are selected by evaluating each point in $U$ to determine those points about which the inferred models $Hyp$ are \emph{least} in agreement (as computed by the \textbf{computeUtility} function). In other words, these points would be of most \emph{utility} to the learner. \item Once these points are selected, they are labelled with the \textbf{label} function, added to the training set, and the process iterates. \item After the final iteration, a set of models is inferred from the aggregate training set, and a model is selected to be returned by the \textbf{best} function. The selection criteria can vary depending on the inference approach -- one straightforward option (adopted in this paper) is to return the model that best predicts the outputs (or `labels') produced by $Train$. \end{compactitem} There is a clear similarity between the QBC algorithm and the LBT algorithm in Algorithm \ref{alg:iterativeAlgorithm}. Both involve loops, where models are inferred at each iteration. In both cases, the models are used as a basis for selecting more data (test inputs in the testing context, unlabelled data points in the Machine Learning case). There are also two significant differences. In the case of QBC, the output is the final inferred model, whereas in LBT the output is the data that was used to infer the model (the test set with its outputs). In LBT, there is no fixed approach to generate test data -- it could be random, or adopt a model-based testing algorithm. In QBC, there is only one approach; regardless of the type of model or system, a random pool of unlabelled data points are generated, and the best $s$ points are chosen based on the `uncertainty' that they elicit from the inferred committee of models. \section{Applying QBC to Test Generation} \label{sec:qbc_test} In the context of Machine Learning, QBC enables uncertainty-based sampling to occur, regardless of the type of model that is inferred. In this paper we produce the Testing By Committee approach, which applies QBC to LBT to circumvent the dependence between the model inference algorithm and the test-generation algorithm. In principle this enables LBT to use \emph{any} model inference algorithm, and to select test cases based on the combined uncertainty of the inferred models. In this section we first set out our \emph{Test By Committee} algorithm, which combines LBT with QBC. We then provide technique that implements this approach using Genetic Programming as a basis for the model inference. \subsection{Test By Committee} \begin{algorithm}[t] \SetKwInput{KwUses}{Uses} \KwIn{$SUT$,$Tests$,$s$,$i$,$comitteeSize$,$randomPoolSize$} \KwUses{$execute$,$learnMultiple$, $randomInputs$,$computeUtility$} \KwResult{$Tests$} $Hyp$ $\leftarrow \emptyset$ \; \For{$i$ iterations}{ $Hyp \leftarrow learnMultiple(Tests,comitteeSize)$\; $U \leftarrow randomInputs(SUT,randomPoolSize)$\; \For{$s$ iterations}{ $u = argmax_{x \in U}||computeUtility(Hyp,x)||$\; $l = execute(u)$\; $Tests \leftarrow Tests \cup \{l\}$\; $U \leftarrow U \setminus \{u\}$\; } } \Return{$Tests$}\; \caption{Testing By Committee} \label{alg:qbc-test} \end{algorithm} Our proposed `Test By Committee' (TBC) algorithm is shown in Algorithm \ref{alg:qbc-test}. It clearly combines Algorithms \ref{alg:iterativeAlgorithm} and \ref{alg:qbc}. The key similarities and dissimilarities are as follows: \begin{compactitem} \item As with QBC, we limit the number of iterations to a fixed number $i$ (though it would certainly be possible to integrate something more elaborate, along the lines of the $terminate$ function in Algorithm \ref{alg:iterativeAlgorithm}). \item The step of $learnMultiple$ is the same as in Algorithm \ref{alg:qbc}; a population of models are inferred using either ensemble methods or, as we will demonstrate, population-based learners such as Genetic Programming. \item To generate the candidate test inputs, we introduce a new function \textbf{randominputs}. The $SUT$ is only used to gain information about its interface. Once the types of the interface are known, inputs are formulated as combinations of random values of the appropriate types. \item The process of adding new tests to the test set is the same as in Algorithm \ref{alg:qbc}. For $s$ iterations, the best candidate is selected from $U$ by seeing which candidate test case causes the most disagreement amongst models in $Hyp$. The chosen test is then executed to identify its actual output, and this is then added to $Tests$ (it is also removed from $U$ to avoid re-selection). \end{compactitem} Many of the steps are in effect the same as they are in conventional LBT. However, two steps are very different, and therefore require a more in-depth discussion. The model inference step ($learnMultiple$) requires multiple models. The process of selecting the best candidate test case ($computeUtility$) is also new in the context of testing, and requires more details. In both cases, there are many possible ways in which they could be implemented. In the following two subsections, we describe how we have chosen to implement them for our proof of concept. \subsection{Learning Multiple Models by Genetic Programming} \label{sub:gp_qbc} To produce the models required for Query-by-Committee it is possible to use a Genetic Programming (GP) inference engine \cite{Poli2008}. A GP evolves programs of a given target language towards an optimisation goal, specified by a fitness function. As mentioned previously, in principle any inference technique could be applied (underpinned by Ensemble Methods \cite{Dietterich2000}). However, (a) the intrinsic population-based nature of GPs renders them suitable for QBC, and (b) GPs can easily be adapted to different types of languages, making them well suited for modelling programs in different domains. For space reasons, we only provide the essential details of GPs here, and refer the reader to Poli \emph{et al.}'s GP field guide \cite{Poli2008}, along with our source code\footnote{https://bitbucket.org/nwalkinshaw/efsminferencetool} for further details. In (tree-based) GPs, candidate programs are `evolved' as abstract syntax trees, where branch nodes correspond to `non-terminals' representing functions, and leaf-nodes represent atomic values or variables (terminals). The basic loop is as follows (details on the terms in italics will be elaborated in the next section): \begin{compactenum} \item Generate an initial population of programs as random compositions of non-terminals and terminals. \item Execute each evolved program and evaluate it according to some \emph{fitness function}. \item \emph{Select} the best programs from the population. \item Create a new population by a process of \emph{cross-over} and \emph{mutation}. \item Repeat from step 2 until some stopping criterion is met. \end{compactenum} In its traditional application, the result of the GP is the program with the best fitness value, which represents the best solution. In our case, we can exploit the population-based nature of the GP: At the end of the search, the population consists of a range of slightly varied candidate solutions optimised for the problem at hand. \subsection{Generating Test Cases by QBC} The first step to applying QBC is to select the committee. For this we select the fittest set of chromosomes $Hyp$. The size of this set is determined by the parameter $committeeSize$. The query generation step involves generating a pool of random inputs $U$, and then assessing every $u \in U$ to find the one that creates most `uncertainty' according to the set of inferred models in $Hyp$ (in our case the set of chromosomes inferred by the GP). Every potential test input $u$ is executed on every model $h\in Hyp$, and the outputs are recorded. The input that produces the greatest spread of predictions is then chosen to be executed on the real SUT. \section{Implementation} We have implemented the approach described in the previous section. The implementation targets numeric programs without side-effects returning single outputs. In this section, we provide details of this implementation. \subsection{A GP for Programs with Primitive Types} In this section we elaborate the detailed aspects of the generic GP algorithm shown in Section~\ref{sub:gp_qbc}. \textbf{Fitness function:} The fitness function provides a metric for the accuracy of the inferred program to predict the SUT. Fitness is evaluated by executing a candidate program on all existing test inputs, and comparing the outputs to those that were actually observed in the trace data. \textbf{Selection:} Step 3 selects good candidates from the population, so that they can be fed into the next generation. A popular approach, which we adopt here, is Tournament Selection \cite{Poli2008}. In our case the selection process is \emph{elitist}, this means that the best individual from one generation is always preserved for the next one. \textbf{Crossover and Mutation:} The candidates that were selected in step 3 are subjected to a mixture of crossover and mutation (the frequency at which they occur is given in probabilistic terms). We choose to use the most common form cross-over called \emph{subtree-crossover} \cite{Poli2008}. Mutation is carried out by selecting a random node in a tree and changing it. If the selected node happens to be a terminal, its value is simply changed. If it is a non-terminal, we replace its subtree with a randomly generated one. Arbitrary crossover or mutation can easily lead to nonsensical programs - for example by using String terminals with a function that expects integer parameters. Strongly-typed GP \cite{Poli2008} prevents this from happening by ensuring that every terminal and non-terminal has a declared type. \textbf{Termination and result:} The loop terminates once a candidate has been identified that cannot improve in terms of fitness, or once the number of iterations hits a given limit. \begin{table}[t] \caption{Non-terminals and Terminals chosen for our experiments} \label{tab:terms} \def1.5{1.5} \begin{tabular}{p{0.1 \columnwidth}p{0.8 \columnwidth}}\toprule \multicolumn{2}{l}{\textbf{Non-Terminals}}\\ \midrule Double (D) & add(x:D,y:D), subtract(x:D,y:D), multiply(x:D,y:D), divide(x:D,y:D), power(x:D,y:D), root(x:D, y:D), cast(x:I), if(x:B,y:D,z:D), cos(x:D), exp(x:D),log(x:D)\\ \midrule Integer (I) & cast(x:D)\\ \midrule Boolean (B) & and(x:B,y:B), or(x:B, y:B), LT(x:D,y:D), GT(x:D,y:D), EQ(x:B,y:B), EQArith(x:D,y:D),EQString(x:S,y:S)\\ \midrule Logic (all) & if-then-else(a:B,b:D,c:D),if-then-else(a:B,b:I,c:I),if-then-else(a:B,b:S,c:S),if-then-else(a:B,b:B,c:B)\\ \midrule \multicolumn{2}{l}{\textbf{Terminals}}\\ \midrule Double (D) & all variable names in $Vars$ of type double, one free variable limited to the interval $[-2,2]$, -1.0\\ \midrule Integer (I) & all variable names in $Vars$ of type integer, one free variable limited to the interval $[-2,2]$, 0\\ \midrule Booleans (B) & All variable names in $Vars$ of type Boolean, \texttt{true}, \texttt{false}.\\ \midrule Strings (S)& All variable names in $Vars$ of type String, any customised pre-defined String values.\\ \bottomrule \end{tabular} \vspace{-1em} \end{table} \textbf{Terminals and Non-Terminals:} The choices of terminals and non-terminals are shown in Table \ref{tab:terms}. In general, of course, the choice of GP operators is flexible, and is ideally informed by knowledge about the system being inferred. In our case, we sought a reasonably general set that can be applied across a range of programs. The question of how to refine the selection of terminals and non-terminals to best suit a SUT is part of our ongoing work. \subsection{Generating Test Cases by QBC} For the purpose of this work (as a proof of concept), we are restricting ourselves to a particular class of system that produces single numerical outputs (either integers or numbers with decimal places). Our initial use of standard deviation proved to be problematic, as it could often produce a misleadingly high value for the situation where most of the models were in fact in agreement, but one ``rogue'' model had produced an extreme value. To address this problem, we instead opted for the Mean Absolute Deviation (MAD) value \cite{Kader1999}, which is less vulnerable to data-spikes. For a set of values $X=\{x_1,\ldots,x_n\}$, $MAD(X) = \frac{1}{n} \sum_{i=1}^{n}|x_i-m(X)|$, where $M(X)$ calculates the mean of $X$. It is necessary to select a value to accommodate the situation where an inferred model returns either infinity or Not a Number (e.g., because an inferred model divides by zero), but the SUT returns a valid value. The value should be high, to indicate that the model is incorrect, but cannot be too high (e.g., Double.MAX\_VALUE), because this prevents the calculation of an accurate mean over multiple outputs. In this case, we substitute the result with a value of 10,000,000 (this was a somewhat ad-hoc choice, and establishing a more justified value is part of our future work). \subsection{Example -- The BMI Calculator} \label{sub:illustration} This section contains a brief walk-through of TBC. As a SUT we choose a simple BMI calculator. This takes as input two numbers (height in meters and weight in kilograms), and returns a ``Body Mass Index'' value, calculated as $\frac{weight}{height^2}$. For our technique to operate, we do not need to be able to look at the internal implementation, but only need to know of the interface. However, to provide a complete overview, let us assume that the calculator is implemented as a bash script, with the following source code: \begin{lstlisting}[language=Bash,mathescape=false] #!/bin/bash awk "BEGIN {print $2 / ($1 * $1)}" \end{lstlisting} Our implementation accepts a specification of the interface in the following self-explanatory JSON format. \begin{lstlisting}[style=json,mathescape=false] { "command": "bmi.sh", "parameters":[ { "name": "height", "type": "double", "max": "100", "min": "-100" }, { "name": "weight", "type": "double", "max": "100", "min": "-100" } ], "output":[ { "name": "output", "type": "double" } ] } \end{lstlisting} Finally, we provide an existing basic test set that we wish to improve upon. Our implementation accepts a space-separated text file, where the order of values is taken to be the order of parameters in the specification file (height followed by weight): \begin{lstlisting}[style=json,mathescape=false] 1.7 50 1.8 70 1.9 100 1.7 110 0.0 5 5.0 0 \end{lstlisting} With reference to the TBC process in Algorithm \ref{alg:qbc-test}, the BMI represents the $SUT$, and the above list of test sets represents $TestInputs$. For the sake of illustration, we will only show one iteration ($i=1$), and we will only add a single test set in this iteration $s=1$. To illustrate how new test cases are selected, we set $randomPoolSize$ to 3, although this would usually be much higher (in the evaluation we will set it to 1000). The TBC algorithm begins by inferring the ``committee'' $Hyp$ via $learnMultiple$. In our case, this produces the top 10 chromosomes. To give an idea of what is inferred, two of the fittest GP programs after the first iteration is as follows: \begin{lstlisting}[mathescape=false] gp1: Mult(weight,Exp(-1.1518922634307343))) gp2: Div(height,Exp(height-Log(weight)) \end{lstlisting} Although they are clearly inaccurate, we can assume that (as the fittest members of their pool of solutions), they at least \emph{approximate} the output. This is illustrated in Figure \ref{fig:gpOut}, which plots outputs (the dashed and dotted lines) against the expected output (the plain line), for all test inputs. \begin{figure}[t] \includegraphics[width=\columnwidth]{bmi_inferred} \vspace{-2em} \caption{Comparison of expected versus inferred outputs after one iteration wrt. BMI example.} \label{fig:gpOut} \vspace{-1em} \end{figure} As the next step, $randominputs$ produces a set of $randomPoolSize$ inputs (in this case three). The resulting inputs are shown on the left in Table \ref{tab:inputs}. For each input, the disagreement between the models is calculated as the Maximum Average Deviation (as described previously), shown in the right-hand column. From this, it is clear that the second input produced a huge divergence between the two inferred models. The input with the highest MAD value is thus added to the test set, and the TBC process moves to the next iteration. This time, thanks to the new test execution, the inferred models ought to be more precise, and lead to test cases that explore new aspects of the input domain. \begin{table} \caption{Proposed inputs and MAD calculation} \label{tab:inputs} \centering \begin{tabular}{rrr}\toprule \textbf{height} & \textbf{weight} & \textbf{MAD}\\ \midrule 87.95 & 50.49 & 3.99\\ \textcolor{red}{-62.41}&\textcolor{red}{91.14} & \textcolor{red}{\textbf{1.80E+30}}\\ 26.44 & 56.65 & 4.48\\ \bottomrule \end{tabular} \vspace{-1em} \end{table} \section{Evaluation} \label{sec:eval} In this section we seek to assess the effectiveness of TBC at generating rigorous test sets. Of primary concern is the question of whether TBC can detect more faults than baseline testing techniques. In this evaluation we use random testing and Adaptive Random Testing \cite{Chen2004} as the baseline. Accordingly, the first research question is as follows: \vspace{0.5em} \noindent\textbf{RQ1: Do TBC-generated test sets expose more faults than random and ART-generated test sets?} \vspace{0.5em} One further question is concerned with the \emph{efficiency}. In the even that TBC does not ultimately expose a larger number of errors than other techniques, it might still expose the same number of faults, but after executing fewer tests, which would render it more efficient: \vspace{0.5em} \noindent\textbf{RQ2: Are TBC-generated test sets more efficient at exposing faults than random and ART-generated test sets?} \subsection{Subjects} \label{sub:subjects} We chose six units within the Apache Commons Math framework (version 3.6)\footnote{\url{https://commons.apache.org/proper/commons-math/}} and two units within JodaTime (version 2.9.3)\footnote{\url{http://www.joda.org/joda-time/}}. The units were chosen on the following criteria: \begin{compactitem} \item It must accept a single (set of) input parameters -- i.e., it must not require sequences of method calls (apart from the call to the constructor, which was included in the test-wrapper, see below). \item It must produce a single output value. \item The parameters accepted by the unit under test (and the output value returned by it) must either be primitive data types that are supported by our GP implementation, or be complex objects where the constructor accepts primitive data types. \item The unit in question must be invoked by one of the Apache Commons Math or JodaTime test sets (so that we can obtain use these tests to infer the first model). \end{compactitem} \begin{table} \caption{Subject Systems.} \label{tab:systems} \resizebox{\columnwidth}{!}{ \begin{tabular}{@{}lp{2.7cm}rr@{}} \toprule \textbf{Component} & \textbf{Functionality} & \textbf{Exec. LOC}& \textbf{Tests}\\ \midrule \texttt{\scriptsize BesselJ} & \texttt{\scriptsize value}&1,211 & 699\\ \texttt{\scriptsize Binomial} & \texttt{\scriptsize binomialCoefficientDouble}&501 & 3,000*\\ \texttt{\scriptsize DerivativeStructure} & \texttt{\scriptsize asinh} & 360& 3,000*\\ \texttt{\scriptsize Gamma} & \texttt{\scriptsize regularizedGammaQ}&783&4\\ \texttt{\scriptsize Erf} & \texttt{\scriptsize erf} & 763& 116 \\ \texttt{\scriptsize RombergIntegrator} & \texttt{\scriptsize RombergIntegrator} & 735& 4 \\ \texttt{\scriptsize Period} & \texttt{\scriptsize toStandardWeeks} & 1128& 5 \\ \texttt{\scriptsize Days} & \texttt{\scriptsize daysBetween} & 1251& 8 \\ \bottomrule \end{tabular} } \vspace{-1em} \end{table} The eight units in Table \ref{tab:systems} represent the first units that were encountered in each system. Where a package contained a large number of possible varieties (e.g., calculations of derivatives), we chose one at random, and avoided choosing multiple units in the same collection. Where an initial test set was particularly large (in some cases they contained $>$ 20,000 executions of the SUT), we sampled 3000 executions at random to ensure that the fitness functions in the GP could be evaluated in a reasonable amount of time. These are marked with a `*' in Table \ref{tab:systems}. Apache Commons Math and JodaTime were chosen because they are written in Java, which enables us to use the Major mutation framework \cite{Just2011} and because they have a reasonably extensive set of unit tests (enabling us to use these as a starting point for the learning-based testing). Their details are shown in Table \ref{tab:systems}. The sizes of the various functionalities have to be treated as approximate. To provide the LOC of the entire libraries would be a gross overestimation. To provide the LOC for a single class would be a gross underestimation (especially in the case of Apache Commons Math, where a large portion of the functionality is contained within the very large \texttt{org.apache.commons.math4.util.FastMath} class). We provide the total LOC within the library tracked (using IntelliJ) when executing all generated test sets for a given SUT. \begin{table} \centering \caption{Mean number of mutants killed after 60 iterations. Highest values are in bold. The significance of the Mann-Whitney test is indicated in parentheses. No significance - $p>0.05$ is (-) , $p<0.05$ is (*), and $p <0.001$ is (***).} \label{tab:means} \resizebox{\columnwidth}{!}{ \begin{tabular}{lrrlrl} \toprule SUT & TBC & \multicolumn{2}{c}{Random} & \multicolumn{2}{c}{ART} \\ \midrule BesselJ & \textbf{447.50} & 442.83 & (***) &442.93 & (*) \\ Binomial & \textbf{30.53} & 29.03 &(***) & 29.20 & (***) \\ DerivativeSin & \textbf{55.93} & 51.20 &(***) & 50.07 & (***) \\ Erf & \textbf{190.52} & 188.62 &(***) & 189.33 & (***) \\ Gamma & \textbf{208.23} & 206.90 &(-) & 205.60 & (-) \\ Romberg Integrator &\textbf{87.77}& 87.63 &(-) & 87.46 &(-) \\ periodToWeeks&\textbf{304.95}& 249.52 &(*) & 271.58 &(-) \\ daysBetween&\textbf{72.13}& 50 &(-) & 49.53 &(*) \\ \bottomrule \end{tabular} } \vspace{-1em} \end{table} It is important to note that these selection criteria are in part so restrictive for the sake of control in our experiment. In practice, if we wanted to test a system for which our current GP was not sufficient, we would resort to a different Machine Learner, or add the requisite terminals and non-terminals to the GP. However, in our case, this special treatment would obviously bias the results. To avoid bias, we thus restrict ourselves to a subset of systems that are at least compatible with our choice of GP. \subsection{Methodology} To gauge the performance of TBC in comparison with the `state of the art', we compared the mutation scores for its test sets against randomly generated test inputs, and test sets generated by Adaptive Random Testing (ART) \cite{Chen2004}. For ART, an important factor is the choice of distance function to distinguish test sets. In our case, since most of the inputs were numerical, we chose the Euclidean distance function, which tends to be the distance measure of choice. All of the techniques were provided with an interface specification file, which contained the various parameters, and the ranges for any numerical parameters. If parameters were strings, the potential value-selections were explicitly enumerated. To avoid biasing results, we did not use any domain to set numerical variable range boundaries, and adopted a conservative approach; we looked at the ranges in the given test sets, and expanding these ranges with a substantial buffer in either direction (e.g., if the range of the test cases was from 0 to 10, we would set the range from -100 to 100). The full configuration files, along with all other materials used for this experiment are available online\footnote{Omitted for double-blinding }. \begin{figure*}[t] \centering \setlength{\tabcolsep}{0.5em} \begin{tabular}{cccc} \includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{Binomial} & \includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{BesselJ}& \includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{Gammaq}& \includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{Romberg}\\ \includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{DerivativeSin} &\includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{ERF}& \includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{DaysBetween} &\includegraphics[trim={0.7cm 0.5cm 0.25cm 0.1cm},clip,width=0.18\textwidth]{PeriodToWeeks} \end{tabular} \vspace{-1em} \caption{Mutation Scores after 60 iterations, starting from given test sets.} \label{fig:boxplots} \end{figure*} To gauge how effective a test set is at exposing faults, we employed mutation testing \cite{Jia2011}. We used the Major Java mutation testing framework (version 1.6, with all mutants)~\cite{Just2011}. We seeded mutants conservatively, by selecting any classes that were executed by the initial set of tests (we could not seed mutants in every class in the system because of the resource constraints of mutation testing). It does not make sense to measure the mutation score as the proportion of mutants killed, because the conservative seeding strategy will invariably mean that this proportion is liable to be very small (for example, all of the units use a fraction of the \texttt{org.apache.commons.math4.util.FastMath} class). Instead, we simply compare the absolute numbers of mutants detected, which suffices to provide valid answers to our two research questions. To prevent any bias arising from configurations, we used the same configuration for TBC across all experiments. For the GP configuration we used the set of terminals and non-terminals detailed in Table \ref{tab:terms}. We used a population size of 800, with a crossover-rate of 0.9, a mutation rate of 0.1, a maximum term-depth of 10 and a tournament size of 6 \cite{Poli2008}. We set the number of tests generated per iteration 1000, and the number selected for addition to the test set to 5. To answer RQ1, we analysed the mutation scores that were computed after 60 iterations, grouped according to the technique (TBC, ART, and Random). To compare them we carried out two (non-parametric) Wilcoxon Rank Sum tests per SUT (having confirmed that the distributions are not normally distributed according to the Shapiro Wilks test). The first null-hypothesis was that the mutation scores for TBC are smaller than those for random tests. The second null-hypothesis was that the mutation scores for TBC are smaller than those for ART tests. The distributions were also visualised as box-plots. To answer RQ2 (how much more effective is TBC?), we recorded the last iteration at which TBC produced the highest mutation score (versus ART and Random). We also plotted the trajectories of the means to show how the trajectories differed over the course of the 60 iterations. \begin{figure*}[t] \centering \includegraphics[width = \textwidth]{apachePlots} \vspace{-1em} \caption{Mutation Scores for every iteration, starting from given test sets.} \label{fig:trajectories} \vspace{-1em} \end{figure*} \subsection{Results for RQ1: Effectiveness} The mean numbers of mutants killed for each system are shown in Table \ref{tab:means}. The distributions are also visualised as box-plots in Figure \ref{fig:boxplots}. The table shows that, after 60 iterations, TBC has killed the highest mean number of mutants for every program. The improvement over ART and random testing varies substantially between the systems. For BesselJ, Binomial, Derivative Sinh, and ERF, the difference is statistically significant; this is corroborated in the box plots. In three of these systems (Binomial, Derivative Sinh and ERF), difference is so marked that the lower quartile for TBC is higher than the upper quartile for ART and Random. For Gamma, Romberg, PeriodToWeeks and DaysBetween although the mean is higher for TBC, the differences are not statistically significant (they are partially significant for PeriodToWeeks and DaysBetween). Looking at the box plots, in all cases apart from PeriodToWeeks the boxes for TBC are noticeably elevated. In the case of PeriodToWeeks, the median score for TBC is the same as ART (even thought the mean score is substantially higher). This is largely due to one particular execution that achieved a particularly large number of mutations. In all cases, the difference in distributions is particularly marked at the lower end; ART and Random have lower minimum scores, and lower lower-quartiles than TBC, which indicates that TBC is more consistent. \begin{result} RQ1: In our experiments, TBC was more effective than random testing and ART. In all cases there was a higher mean number of mutants killed, and the difference in distributions was significant in 4/8 SUTs. \end{result} \subsection{Results for RQ2: Efficiency} We discuss the relative efficiency of TBC versus ART and random testing by looking at how rapidly TBC out-performs the other approaches (by achieving a higher mean number of mutation faults without being overtaken in subsequent iterations). Figure \ref{fig:trajectories} shows the average mutation scores and their standard deviations throughout the 60 iterations. It is important to note the differences in scales; the different SUTs give rise to markedly different numbers of mutants. This means that similar differentials in the mean numbers of mutants on different plots can appear markedly different. We discuss the various trajectories by starting with the systems where the performances are most similar. In all of the studied systems, TBC eventually kills more mutants on average than random and ART testing. In some systems the numbers of faults detected remain similar throughout, whereas in others TBC significantly outperforms ART and Random from the start. These cases are discussed in more detail below. As one might expect from the results for RQ1, the trajectories in the Romberg and Gammaq SUTs are visually similar; these are the systems where the relative performance between the techniques is at its closest. In the Romberg SUT, TBC is consistently better than ART from iteration 20 onwards, but only outperforms random testing after iteration 50. In Gammaq, TBC consistently outperforms ART and random from iteration 23 onwards, though only marginally. Perhaps more surprisingly for both JodaTime systems PeriodToWeeks and DaysBetween the trajectory for TBC is noticeably higher than for ART and Random. For PeriodToWeeks, the number of mutants killed for TBC rapidly increases after 10 iterations to a level that ART and Random only start to approach after 40-50 iterations. In ERF, both ART and TBC outperform random testing from the start. ART and TBC are similar up to iteration 40, where ART continues to plateau at 189 whilst the mean number of killed mutants for TBC rises to over 190. In Binomial, BesselJ, and DerivativeSinh, the results for TBC are markedly better from the start. In the case of BesselJ the difference may look smaller, but this is because of the scale of the graphs. In BesselJ the mean TBC score after 60 iterations is 447.5, whereas for scores for ART and Random are approximately 443; this difference of 5 is in fact larger than the differences in the other systems. \begin{result} RQ2: In our experiments, TBC was significantly more efficient at exposing faults than random testing and ART. \end{result} \subsection{Threats to Validity} \textbf{Threats to external validity: } The answers to RQ1 and RQ2 can only validly be applied to systems of a similar character to those tested here. We have only tested eight systems from two frameworks. This means that they will often have shared developers, and they all deal with similar domains. We have additionally restricted ourselves to units that are functional, which do not accept sequential inputs (as discussed in Section \ref{sub:subjects}). To attenuate this risk, we attempted to make the selection of SUTs as indiscriminate as possible within our broader selection constraints. The SUTs presented here are the first ones we encountered that fitted our criteria. However, to truly address this threat a larger study on a more diverse range of SUTs is needed, which is what we will be doing in our future work. As mentioned previously, the choice of value ranges for the parameters is important for all of the techniques. There is a high probability that our choice of ranges is not ideal (given that we avoided using domain knowledge to avoid bias). It is possible that, for certain range limitations, the differences between the various techniques are reduced (i.e., if the value ranges are reduced). Investigating the relationship between the selection of value ranges and the relative performance of these techniques is something that we are exploring as part of our ongoing and future work. \textbf{Threats to internal validity: } The mutation score depends upon the seeding of mutants. It is possible that code was executed that was not seeded with mutants, thus skewing the results. We attempted to limit this possibility by tracking the execution of code with profiling tools. \subsection{Discussion} The results indicate that TBC tends to detect more faults with fewer tests than the baseline techniques. However, during the experiments a further factor became apparent that did not favour TBC: time. For ART every test input adds to complexity of generating the next test input, because there is an additional point in euclidean space against which to measure the next group of random inputs. Arcuri and Briand made this point in their critique of ART \cite{Arcuri2011}, where they showed that if time is taken into account instead of the number of tests, then ART was by some distance inferior to conventional random testing. This question of time is even more pertinent to TBC than ART (indeed, it applies to every LBT technique). LBT involves the repeated execution of the given (and increasing) set of tests (Random and ART do not). It involves model inference, which again takes time. With the use of GP, inference time is tied to the number of available tests (since these evaluate the fitness function). For the Binomial system (the most time-consuming system studied), the full 60 iterations took on average 12 hours. For ERF (one of the least time consuming systems) it took on average 89 minutes. The timing question is clearly an important one to address, and a larger empirical study will be incorporating this. Looking at some of the trajectories in Figure \ref{fig:trajectories} (such as Binomial and DerivativeSin) it is doubtful whether random tests would catch up with TBC, even if we did allow for a large disparity in the number of tests. In any case, it is not necessarily always possible; some test cases simply take long to execute (e.g. if they involve complex processing or network communications), so the ability to execute huge numbers of tests rapidly is not always an option. Also, even if it is an option, the availability of many tests is not necessarily desirable either, especially if checking the outputs is a non-trivial task. \section{Conclusions and Future Work} In this paper we have made an explicit connection between the problems of test data generation in Software Engineering and sampling in active Machine Learning. Our solution proposes the use of uncertainty sampling as a means by which to generate suitable test data. We have provided a proof of concept implementation, along with the results of an empirical study of eight units within the Apache Commons Math and JodaTime frameworks. The initial results are encouraging. Our TBC approach outperforms random testing and Adaptive Random Testing. Although promising, the approach has also given rise to several important questions, which were touched upon in the discussion of the threats to validity for the study. We have not yet studied the specific relationship between the variable-range constraints and the strength of the results. We have not examined the relationship between the amount of data in the initial test set, and the value of the final model. We have not studied the relationship between the accuracy of the final model and the effectiveness of the final test set. In our ongoing and future work we will seek to explore these questions. We will carry out experiments to examine the effect of variable range on the number of mutants killed. We will look at the accuracy of the inferred model to see if, in this context, it leads to better test sets (building upon the work by Fraser \emph{et al.} \cite{Fraser2015}). We will also investigate the adoption of alternative Machine Learning algorithms that can model more sophisticated types of functionalities, such as complex data structures and sequential behaviour.
{'timestamp': '2016-08-11T02:07:43', 'yymm': '1608', 'arxiv_id': '1608.03181', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03181'}
arxiv
\section{Sparse coding extension of PQ and RVQ}\label{sec:sparse} In the absence of specific constraints on the $M$ dictionaries, the proposed quantized sparse coding can be seen as a generalization of residual vector quantization (RVQ), with linear combinations rather than only sums of centroids. Hierarchical code structure and search methods (see Section~\ref{sec:search} below) are analog. To highlight this relationship, we will denote ``\mbox{Q$\alpha$-RVQ} " the proposed encoder. In case dictionaries are constrained to stem from predefined orthogonal sub-spaces $V_{m}$s such that $\mathbb{R}^D=\bigoplus_{m=1}^M V_m$, the proposed approach simplifies notably. Encoding vectors and learning dictionaries can be done independently in each subspace, instead of in sequence. In particular, when each subspace is spanned by $D/M$ (assuming $M$ divides $D$) successive canonical vectors, \emph{e.g.}, $V_1 = \mrm{span}(\mbf{e}_1\cdots\mbf{e}_{D/M})$, our proposed approach is similar to product quantization (PQ), which it extends through the use of quantized coefficients. We will denote ``\mbox{Q$\alpha$-PQ}" our approach in this specific set-up: all vectors are partitioned into $M$ sub-vectors of dimension $D/M$ and each sub-vector is approximated independently, with one codeword in PQ, with the multiple of one atom in \mbox{Q$\alpha$-PQ}. \\ \begin{algorithm} \small \caption{Learning \mbox{Q$\alpha$-RVQ}} \label{alg:qaRQ_learn} \begin{algorithmic}[1] \State Input: $\mbf{z}_{1:R}$ \State Ouput: $C^{1:M},A$ \State $\mbf{r}_{1:R} \leftarrow \mbf{z}_{1:R}$ \For {$m=1\cdots M$} \State $C^m \leftarrow $ {\sc Spher\_k-Means}($\mbf{r}_{1:R}$) \For{$r=1\cdots R$} \State $k_{m,r} \leftarrow \arg\!\max_{k\in\llbracket 1,K \rrbracket} \trsp{\mbf{r}_r}\mbf{c}_k^{m}$ \State $\mbf{r}_r \leftarrow \mbf{r}_r - (\trsp{\mbf{r}_r}\mbf{c}_{k_{m,r}}^{m}) \mbf{c}^m_{k_{m,r}}$ \EndFor \EndFor \For{$r=1\cdots R$} \State $\mbs{\alpha}_r \leftarrow \pinv{[\mbf{c}^1_{k_{1,r}}\cdots \mbf{c}^M_{k_{M,r}}]}\mbf{z}_r$ \EndFor \State $A \leftarrow$ {\sc k-Means}($\mbs{\alpha}_{1:R}$) \end{algorithmic} \end{algorithm} \begin{algorithm} \small \caption{Vector encoding with \mbox{Q$\alpha$-RVQ}} \label{alg:qaRQ} \begin{algorithmic}[1] \State Input: $\mbf{x},[\mbf{c}^{1:M}_{1:K}],[\mbf{a}_{1:P}]$ \State Output: $\mbf{k}=[k_{1:M}],p$ \State $\mbf{r} \leftarrow \mbf{x}$ \For {$m=1\cdots M$} \State $k_{m} \leftarrow \arg\!\max_{k\in\llbracket 1,K \rrbracket} \trsp{\mbf{r}}\mbf{c}_k^{m}$ \State $\mbf{r} \leftarrow \mbf{r} - (\trsp{\mbf{r}}\mbf{c}_{k_{m}}^{m}) \mbf{c}^m_{k_m}$ \EndFor \State $\mbs{\alpha} \leftarrow \pinv{[\mbf{c}^1_{k_1}\cdots \mbf{c}^M_{k_M}]}\mbf{x}$ \State $p\leftarrow \arg\!\min_{p\in\llbracket 1,P \rrbracket} \|\mbs{\alpha} - \mbf{a}_p\|$ \end{algorithmic} \end{algorithm} \begin{algorithm} \small \caption{Learning \mbox{Q$\alpha$-PQ}} \label{alg:qaPQ_learn} \begin{algorithmic}[1] \State Input: $\mbf{z}_{1:R}$ \State Output: $\tilde{C}^{1:M},A$ \For{$r=1\cdots R$} \State $[\trsp\tilde{\mbf{z}}_{1,r} \cdots \trsp\tilde{\mbf{z}}_{M,r}] \leftarrow \trsp{\mbf{z}_{r}}$ \EndFor \For {$m=1\cdots M$} \State $\tilde{C}^m \leftarrow $ {\sc Spher\_k-Means}($\tilde{\mbf{z}}_{m,1:R}$) \For{$r=1\cdots R$} \State $k\leftarrow \arg\!\max_{k\in\llbracket 1,K \rrbracket} \trsp{\tilde{\mbf{z}}_{m,r}}\tilde{\mbf{c}}_k^{m}$ \State $\alpha_{m,r} \leftarrow \trsp{\tilde{\mbf{z}}_{m,r}}\tilde{\mbf{c}}_{k}^{m}$ \EndFor \EndFor \State $A \leftarrow$ {\sc k-Means}($\mbs{\alpha}_{1:R}$) \end{algorithmic} \end{algorithm} \begin{algorithm} \small \caption{Vector encoding with \mbox{Q$\alpha$-PQ}} \label{alg:qaPQ} \begin{algorithmic}[1] \State Input: $\mbf{x},[\tilde{\mbf{c}}^{1:M}_{1:K}],[\mbf{a}_{1:P}]$ \State Output: $\mbf{k}=[k_{1:M}],p$ \State $[\trsp{\tilde{\mbf{x}}_1}\cdots \trsp{\tilde{\mbf{x}}_M}] \leftarrow \trsp{\mbf{x}}$ \For {$m=1\cdots M$} \State $k_{m} \leftarrow \arg\!\max_{k\in\llbracket 1,K \rrbracket} \trsp{\tilde{\mbf{x}}_m}\tilde{\mbf{c}}_k^{m}$ \State $\alpha_{m} \leftarrow \trsp{\tilde{\mbf{x}}_m}\tilde{\mbf{c}}_{k_{m}}^{m}$ \EndFor \State $p\leftarrow \arg\!\min_{p\in\llbracket 1,P \rrbracket} \|\mbs{\alpha} - \mbf{a}_p\|$ \end{algorithmic} \end{algorithm} Learning the dictionaries $C^m$s and the codebook $A$ for \mbox{Q$\alpha$-RVQ}~is summarized in Alg. 1, and the encoding of a vector with them is in Alg. 2. Learning and encoding in the product case (\mbox{Q$\alpha$-PQ}) are respectively summarized in Algs. 3 and 4, where all training and test vectors are partitioned in $M$ sub-vectors of dimension $D/M$, denoted with tilde. \section{Approximate search}\label{sec:search} Three related types of nearest neighbor (NN) search are used in practice, depending on how the (dis)similarity between vectors is measured in $\mathbb{R}^D$: minimum Euclidean distance, maximum cosine-similarity or maximum inner-product. The three are equivalent when all vectors are $\ell^2$-normalized. In visual search, classical descriptors (either at local level or image level) can be normalized in a variety of ways, \emph{e.g.}, $\ell^2$, $\ell^1$ or blockwise $\ell^2$, exactly or approximately. With cosine-similarity (CS) for instance, the vector closest the query $\mbf{y}$ in the database $\mcl{X}$ is $\arg\max_{\mbf{x}\in\mcl{X}}\frac{\trsp{\mbf{y}}\mbf{x}}{\|\mbf{x}\|}$, where the norm of the query is ignored for it has no influence on the answer. Considering approximations of database vectors with existing or proposed methods, approximate NN (aNN) search can be conducted without approximating the query (asymmetric aNN \cite{JDS11}): \begin{equation} \mrm{CS-aNN:~~} \arg\max_{\mbf{x}\in\mcl{X}}\frac{\trsp{\mbf{y}}Q(\mbf{x})}{\|Q(\mbf{x})\|}. \label{eq:cs_ann} \end{equation} As with structured encoding schemes, the form of the approximation in \eqref{eq:qarq} permits to expedite the search. Indeed, for $\mbf{x}$ encoded by $(\mbf{k},p)\in \llbracket 1,K \rrbracket^M \times \llbracket 1,P \rrbracket$, the approximate cosine-similarity reads \begin{equation} \frac{\trsp{\mbf{y}}C(\mbf{k})\mbf{a}_p}{\|C(\mbf{k})\mbf{a}_p\|}, \label{eq:qaRQ_search} \end{equation} where the $M$ inner products in $\trsp{\mbf{y}}C(\mbf{k})$ are among the $MK$ ones in $\trsp{\mbf{y}}C$, which can be computed once and stored for a given query. For each database vector $\mbf{x}$, computing the numerator then requires $M$ look-ups, $M$ multiplications and $M-1$ sums. We discuss the denominator below. In the \mbox{Q$\alpha$-PQ}~setup, as the $M$ unit atoms involved in $C(\mbf{k})$ are mutually orthogonal, the denominator is equal to $\|\mbf{a}_p\|$, that is one among $P$ values that are independent of the queries and simply pre-computed once for all. In $\mbox{Q$\alpha$-RVQ}$ however, as in other quantizers with non-orthogonal codebooks, the computation of \begin{equation} \|C(\mbf{k})\mbf{a}_p\| = \Big(\sum_{m,n=1}^M a_{mp}a_{np}\mbf{c}^{m\top}_{k_m}\mbf{c}^n_{k_n}\Big)^{1/2} \end{equation} constitutes an overhead. Two methods are suggested in \cite{BL14} to handle this problem. The first one consists in precomputing and storing for look-up all inter-dictionary inner products of atoms, \emph{i.e.}\, $\trsp{C}C$. For a given query, the denominator can then be computed with $\bigo{M^2}$ operations. The second method is to compute the norms for all approximated database vectors and to encode them with a non-uniform scalar quantizer (typically with 256 values) learned on the training set. This adds an extra byte to the database vector encoding but avoids the search time overhead incurred by the first method. This computational saving is worth the memory expense for very large scale systems (See experiments on 1 billion vectors in the next section). Using the Euclidean distance instead of the cosine similarity, \emph{i.e.}, solving $\arg\min_{\mbf{x}\in\mcl{X}} \left\{\|Q(\mbf{x})\|^2 - 2~\trsp{\mbf{y}}Q(\mbf{x})\right\}$ leads to very similar derivations. The performance of the proposed framework is equivalent for these two popular metrics. \medskip \section{Quantized sparse representations}\label{sec:approach} \textbf{A sparse coding view of structured quantization} \quad Given $M$ codebooks, structured quantization represents each database vector $\mbf{x}$ as a sum~\eqref{eq:ac} of $M$ codewords, one from each codebook. Using this decomposition, search can be expedited by working at the atom level (see Section \ref{sec:search}). Taking a sparse coding viewpoint, we propose a more general approach whereby $M$ dictionaries\footnote{Throughout we use the terminology \textit{codebook} for a collection of vectors, the \textit{codewords}, that can be added, and \textit{dictionary} for a collection of normalized vectors, the \textit{atoms}, which can be linearly combined.}, $C^m = [\mbf{c}^m_1\cdots\mbf{c}^m_K]_{D\times K}$, $m=1\cdots M$, each with $K$ normalized atoms, are learned and a database vector $\mbf{x}\in\mathbb{R}^D$ is represented as a linear combination: \begin{equation} Q(\mbf{x}) = \sum_{m=1}^M \alpha_m(\mbf{x}) \mbf{c}^m_{k_m(\mbf{x})}, \label{eq:coding} \end{equation} where $\alpha_m(\mbf{x})\in\mathbb{R}$ and $k_{m}(\mbf{x})\in\llbracket 1,K \rrbracket$. Next, we shall drop the explicit dependence in $\mbf{x}$ for notational convenience. As we shall see in Section \ref{sec:experiments} (Fig. \ref{fig:dst}), the additional degrees of freedom provided by the weights in (\ref{eq:coding}) allow more accurate vector approximation. However, with no constraints on the weights, this representation is not discrete, spanning a union of $M$-dimensional sub-spaces in $\mathbb{R}^{D}$. To produce compact codes, it must be restricted. Before addressing this point, we show first how it is obtained and how it relates to existing coding schemes. If dictionaries are given, trying to compute $Q(\mbf{x})$ as the best $\ell^2$-norm approximation of $\mbf{x}$ is a special case of sparse coding, with the constraint of using exactly one atom from each dictionary. Unless dictionaries are mutually orthogonal, it is a combinatorial problem that can only be solved approximately. Greedy techniques such as projection pursuit \cite{friedman1981projection} and matching pursuit \cite{mallat1993matching} provide particularly simple ways to compute sparse representations. We propose the following pursuit for our problem: for $m = 1\cdots M$, \begin{equation} k_{m} = \arg\!\max_{k\in\llbracket 1,K \rrbracket} \trsp{\mbf{r}_m}\mbf{c}_k^{m},~~ \alpha_{m} = \trsp{\mbf{r}_m}\mbf{c}_{k_{m}}^{m}, \label{eq:pursuit} \end{equation} with $\mbf{r}_1=\mbf{x}$ and $\mbf{r}_{m+1} = \mbf{r}_{m} - \alpha_{m}\mbf{c}^m_{k_m}$. Encoding proceeds recursively, selecting in the current dictionary the atom with maximum inner-product with the current residual.\footnote{\emph{Not} maximum absolute inner-product as in matching pursuit. This permits to get a tighter distribution of weights, which will make easier their subsequent quantization.} Once atoms have all been sequentially selected, \emph{i.e.}, the support of the $M$-sparse representation is fixed, the approximation (\ref{eq:coding}) is refined by jointly recomputing the weights as \begin{equation} \hat{\mbs{\alpha}} = \arg\!\min_{\mbs{\alpha}\in\mathbb{R}^M} \|\mbf{x} - C(\mbf{k})\mbs{\alpha}\|_2^2 = \pinv{C(\mbf{k})}\mbf{x}, \label{eq:alpha} \end{equation} with $\mbf{k} = [k_m]_{m=1}^M \in \llbracket 1,K \rrbracket^{M}$ the vector formed by the selected atom indices, $C(\mbf{k}) = [\mbf{c}^1_{k_1}\cdots \mbf{c}^M_{k_M}]_{D \times M}$ the corresponding atom matrix and $(\cdot)^{\dagger}$ the Moore-Penrose pseudo-inverse. Vector $\hat{\mbs{\alpha}}$ contains the $M$ weights, out of $KM$, associated to the selected support. Note that the proposed method is related to \cite{zepeda2011jstsp,zepeda2010mmsp}.\\ \noindent\textbf{Learning dictionaries} \quad In structured vector quantization, the $M$ codebooks are learned on a limited training set, usually through $k$-means. In a similar fashion, $k$-SVD on a training set of vectors is a classic way to learn dictionaries for sparse coding \cite{elad2010sparse}. In both cases, encoding of training vectors and optimal update of atoms/codewords alternate until a criterion is met, starting from a sensible initialization (\emph{e.g.}, based on a random selection of training vectors). Staying closer to the spirit of vector quantization, we also rely on $k$-means in its spherical variant which fits well our needs: spherical $k$-means iteratively clusters vector \textit{directions}, thus delivering meaningful unit atoms. Given a set $\mcl{Z} = \{\mbf{z}_1\cdots \mbf{z}_R\}$ of $R$ training vectors, the learning of one dictionary of $K$ atoms proceeds iteratively according to: \begin{align} \mrm{Assignment:~} & k_r = \arg\max_{k\in\llbracket 1,K \rrbracket} \trsp{\mbf{z}_r}{\mbf{c}_k},~ \forall r\in\llbracket 1,R \rrbracket, \\ \mrm{Update:~}& \mbf{c}_k \propto\!\!\!\! \sum_{r:k_r=k} \!\!\! \mbf{z}_r,~\|\mbf{c}_k\|=1,~\forall k\in\llbracket 1,K \rrbracket. \end{align} This procedure is used to learn the $M$ dictionaries. The first dictionary is learned on the training vector themselves, the following ones on corresponding residual vectors. However, in the particular case where dictionaries are chosen within prescribed mutually orthogonal sub-spaces, they can be learned independently after projection in each-subspace, as discussed in Section \ref{sec:sparse}.\\ \noindent\textbf{Quantizing coefficients}\quad To use the proposed representation for large-scale search, we need to limit the possible values of coefficients while maintaining good approximation quality. Sparse representations with discrete weights have been proposed in image and audio compression \cite{frossard2004posteriori,yaghoobi2007quantized}, however with scalar coefficients that are quantized independently and not in the prospect of approximate search. We propose a novel approach that serves our aim better, namely employing vector quantization of coefficient vectors $\hat{\mbs{\alpha}}$. These vectors are of modest size, \emph{i.e.}, $M$ is between 4 and 16 in our experiments. Classical $k$-means clustering is thus well adapted to produce a codebook $A=[\mbf{a}_1\cdots\mbf{a}_P]_{M\times P}$ for their quantization. This is done after the main dictionaries have been learned.\footnote{Alternate refinement of the vector dictionaries $C^m$s and of the coefficient codebook $A$ led to no improvement. A possible reason is that dictionaries update does not take into account that the coefficients are vector quantized, and we do not see a principled way to do so. } Denoting $p(\mbs{\alpha})=\arg\!\min_{p\in\llbracket 1,P \rrbracket} \|\mbs{\alpha}-\mbf{a}_p\|$ the index of the vector-quantization of $\mbs{\alpha}$ with this codebook, the final approximation of vector $\mbf{x}$ reads: \begin{equation} Q(\mbf{x}) = C(\mbf{k}) \mbf{a}_{p(\hat{\mbs{\alpha}})}, \label{eq:qarq} \end{equation} with $\mbf{k}$ function of $\mbf{x}$ (Eq. \ref{eq:pursuit}) and $\hat{\mbs{\alpha}}= \pinv{C(\mbf{k})}\mbf{x}$ (Eq. \ref{eq:alpha}) function of $\mbf{k}$ and $\mbf{x}$.\\ \noindent\textbf{Code size}\quad A key feature of structured quantization is that it provides the approximation accuracy of extremely large codebooks while limiting learning, coding and search complexities: The $M$ codebooks of size $K$ are as expensive to learn and use as a single codebook of size $MK$ but give effectively access to $K^M$ codewords. In the typical setting where $M=8$ and $K=256$, the effective number of possible encodings is $2^{64}$, that is more than $10^{19}$. This 64-bit encoding capability is obtained by learning and using only $8$-bit quantizers. Similarly, quantized sparse coding offers up to $K^M\times P$ encoding vectors, which amounts to $M\log_2K+\log_2 P$ bits. Structured quantization with $M+1$ codebooks, all of size $K$ except one of size $P$ has the same code-size, but leads to a different discretization of the ambient vector space $\mathbb{R}^{D}$. The aim of the experiments will be to understand how trading part of the vector encoding budget for encoding jointly the scalar weights can benefit approximate search. \section{Experiments}\label{sec:experiments} We compare on various datasets the proposed methods, $\mbox{Q$\alpha$-RVQ}$ and $\mbox{Q$\alpha$-PQ}$, to the structured quantization techniques they extend, RVQ and PQ respectively. We use three main datasets: SIFT1M \cite{JDS09}, GIST1M \cite{JDS11} and VLAD500K \cite{AZ13}.\footnote{VLAD vectors, as kindly provided by Relja Arandjelovi\'c, are PCA-compressed to 128 dimensions and unit $\ell^2$-normalized; SIFT vectors are 128-dimensional and have almost constant $\ell^2$-norm of 512, yielding almost identical nearest-neighbors for cosine similarity and $\ell^2$ distance.} For PQ and $\mbox{Q$\alpha$-PQ}$ on GIST and VLAD vectors, PCA rotation and random coordinate permutation are applied, as they have been shown to improve performance in previous works. Each dataset includes a main set to be searched ($\mcl{X}$ of size $N$), a training set ($\mcl{Z}$ of size $R$) and $S$ query vectors. These sizes and input dimension $D$ are as follows: \medskip \centerline{\small \begin{tabular}{c r r r r} \toprule Dataset & $D$ & $R$ & $N$ & $S$ \\ \midrule SIFT1M & \quad 128 & \quad 100K & \quad 1M & \quad 10K \\ GIST1M & 960 & 500K & 1M & 1K \\ VLAD500K & 128 & 400K & 0.5M & 1K \\ \bottomrule \end{tabular}} ~ As classically done, we report performance in terms of recall@{\tt R}, \emph{i.e.}, the proportion of query vectors for which the true nearest neighbor is present among the {\tt R} nearest neighbors returned by the approximate search. \medskip \noindent\textbf{Introducing coefficients}\quad Before moving to the main experiments, we first investigate how the key idea of including scalar coefficients into structured quantization allows more accurate vector encoding. To this end, we compare average reconstruction errors, $\frac{1}{N}\sum_{\mbf{x}\in\mcl{X}}\|\mbf{x}-Q(\mbf{x})\|^2_2$, obtained on the different datasets by RVQ (resp. PQ) and the proposed approach \textit{before vector quantization of coefficient vector}, which we denote \mbox{$\alpha$-RVQ}~(resp. \mbox{$\alpha$-PQ}), see Fig. \ref{fig:dst}. Three structure granularities are considered, $M=4,~8$ and $16$. Note that in RVQ and \mbox{$\alpha$-RVQ}, increasing the number of layers from $M$ to $M'>M$ simply amounts to resuming recursive encoding of residuals. For PQ and \mbox{$\alpha$-PQ}~ however, it means considering two different partitions of the input vectors: the underlying codebooks/dictionaries and the resulting encodings have nothing in common. \begin{figure*} \centering \scriptsize \begin{tabular}{ccc} \includegraphics[trim = 0mm 3mm 0mm 1mm, clip, width=.33\textwidth]{figs/distortion_SIFT1M.pdf}& \includegraphics[trim = 0mm 3mm 0mm 1mm, clip, width=.33\textwidth]{figs/distortion_GIST1M.pdf}& \includegraphics[trim = 0mm 3mm 0mm 1mm, clip, width=.33\textwidth]{figs/distortion_VLAD500K.pdf}\\ SIFT1M & GIST1M & VLAD500K \end{tabular} \caption{{\bf Accuracy of structured encoding, with and without coefficients}. Squared reconstruction errors produced by structured encoding (PQ and RVQ) and proposed sparse encoding extensions (\mbox{$\alpha$-PQ}~ and \mbox{$\alpha$-RVQ}). For each method, $M=4,8,16$ and $\log_2 K =8,12$ are reported. In absence of coefficient quantization here, each code has $M\log_2 K$ bits, \emph{i.e.}\, 64 bits for $(M,K)=(8,256)$.} \label{fig:dst} \end{figure*} Reconstruction errors (distortions) are also reported for $K=2^8$ and $2^{12}$ respectively. For a given method, reconstruction error decreases when $M$ or $K$ increases. Also, as expected, \mbox{$\alpha$-RVQ}~ (resp. \mbox{$\alpha$-PQ}) is more accurate than RVQ (resp. PQ) for the same $(M,K)$. As we shall see next, most of this accuracy gain is retained after quantizing, even quite coarsely, the coefficient vectors. \medskip \noindent\textbf{Quantizing coefficients}\quad Figure~\ref{fig:r@r_qapq} shows the effect of this quantization on the performance, in comparison to no quantization (sparse encoding) and to classic structured quantization without coefficients. For these plots, we have used one byte encoding for $\mbs{\alpha}$, \emph{i.e.}, $P=256$, along with $M\in\{4, 8, 16\}$ and $K=256$. With this setting, \mbox{Q$\alpha$-RVQ}~ (resp. \mbox{Q$\alpha$-PQ}) is compared to both \mbox{$\alpha$-RVQ}~and RVQ (resp. \mbox{$\alpha$-PQ}~and PQ) with the same values of $M$ and $K$. This means in particular that \mbox{Q$\alpha$-RVQ}~ (resp. \mbox{Q$\alpha$-PQ}) benefits from one extra byte compared to RVQ (resp. PQ). Note that allowing one more byte for RVQ/PQ encoding would significantly increase its learning, encoding and search practical complexities. \begin{figure*} \scriptsize \begin{tabular}{ccc} \includegraphics[trim = 0mm 1mm 0mm 1mm, clip, width=.33\textwidth]{figs/qarvq_recall_SIFT1M.pdf} & \includegraphics[trim = 0mm 1mm 0mm 1mm, clip, width=.33\textwidth]{figs/qarvq_recall_GIST1M.pdf} & \includegraphics[trim = 0mm 1mm 0mm 1mm, clip, width=.33\textwidth]{figs/qarvq_recall_VLAD500K.pdf}\\ \includegraphics[trim = 0mm 1mm 0mm 1mm, clip, width=.33\textwidth]{figs/qapq_recall_SIFT1M.pdf} & \includegraphics[trim = 0mm 1mm 0mm 1mm, clip, width=.33\textwidth]{figs/qapq_recall_GIST1M.pdf} & \includegraphics[trim = 0mm 1mm 0mm 1mm, clip, width=.33\textwidth]{figs/qapq_recall_VLAD500K.pdf}\\ SIFT1M & GIST1M & VLAD500K \end{tabular} \caption{{\bf Impact of 1-byte $\mbs{\alpha}$ quantization on performance}. Recall@{\tt R} curves for \mbox{Q$\alpha$-RVQ}, \mbox{$\alpha$-RVQ}~and RVQ (resp. \mbox{Q$\alpha$-PQ}, \mbox{$\alpha$-PQ}~and PQ) on the three datasets, with $M\in\{4,8,16\}$, $K=256$ and $P=256$.} \label{fig:r@r_qapq} \end{figure*} Since $\mbs{\alpha}$ has $M$ dimensions, its quantization with a single byte gets cruder as $M$ increases, leading to a larger relative loss of performance as compared to no quantization. For $M=4$, one byte quantization suffices in both structures to almost match the good performance of unquantized sparse representation. For $M=16$, the increased degradation remains small within \mbox{Q$\alpha$-RVQ}. However it is important with \mbox{Q$\alpha$-PQ}: for a small budget allocated to the quantization of $\mbs{\alpha}$, it is even outperformed by the PQ baseline. This observation is counter-intuitive (with additional information, there is a loss). The reason is that the assignment is greedy: while the weights are better approximated w.r.t. a square loss, the vector reconstruction is inferior with Eqn~\ref{eq:coding}. A non-greedy exploration strategy as in AQ would address this problem but would also dramatically increase the assignment cost. This suggests that the size $P$ of the codebook associated with $\mbs{\alpha}$ should be adapted to the number $M$ of layers. Hereafter, we measure for each dataset the minimum number of bits that must be dedicated to coefficients quantization ($\log_2 P$) to ensure that the reconstruction error with structured sparse coding remains below the one of the corresponding structured quantization method. The results are as follows (SIFT/GIST/VLAD): \begin{center}{\small \begin{tabular}{lcc} & \mbox{Q$\alpha$-RVQ}~ vs. RVQ & \mbox{Q$\alpha$-PQ}~ vs. PQ \\ \hline\hline $M=4$ & $1/1/1$ & $3/3/2$ \\ \hline $M=8$ & $1/1/1$ & $6/5/5$ \\ \hline $M=16$ & $1/1/1$ & $15/11/12$ \\ \hline \end{tabular}} \end{center} Interestingly, the first bit allocated to $\mbs{\alpha}$ improve upon RVQ for all the settings and datasets. In contrast and as discussed before, for \mbox{Q$\alpha$-PQ}, more bits must be allocated to the weights for larger $M$ to guarantee a better representation. For instance, an overhead of 6 bits is required for $M=8$. \medskip \noindent\textbf{Comparing at fixed code size}\quad For large scale search, considering (almost) equal encoding sizes is a good footing for comparisons. This can be achieved in different ways. In the case of RVQ and \mbox{Q$\alpha$-RVQ}, the recursive nature of encoding provides a natural way to allocate the same encoding budget for the two approaches: we compare \mbox{Q$\alpha$-RVQ}~with $(M,K,P)$ to RVQ with $M$ codebooks of size $K$ and a last one of size $P$. For PQ and \mbox{Q$\alpha$-PQ}, things are less simple: adding one codebook to PQ to match the code size of \mbox{Q$\alpha$-PQ}~ leads to a completely different partition of vectors, creating new possible sources of behavior discrepancies between the two compared methods. Instead, we compare PQ with $M$ codebooks of size $K$ to \mbox{Q$\alpha$-PQ}~ with $M$ dictionaries of size $K/2$ and $P=2^M$ codewords for coefficient vectors. This way, vector partitions are the same for both, as well as the corresponding code sizes ($M \log_2 K$ bits for PQ and $M\log_2 \frac{K}{2} + \log_2 2^M = M \log_2 K$ bits for \mbox{Q$\alpha$-PQ}). Sticking to these rules, we shall compare next structured quantization and quantized sparse representation for equal encoding sizes. \medskip \begin{figure*} \centering \scriptsize \begin{tabular}{ccc} \includegraphics[trim = 0mm 1mm 0mm 3mm, clip, width=.33\textwidth]{figs/recall_at_1_SIFT1M.pdf}& \includegraphics[trim = 0mm 1mm 0mm 3mm, clip, width=.33\textwidth]{figs/recall_at_1_GIST1M.pdf}& \includegraphics[trim = 0mm 1mm 0mm 3mm, clip, width=.33\textwidth]{figs/recall_at_1_VLAD500K.pdf}\\ SIFT1M & GIST1M & VLAD500K \end{tabular} \caption{{\bf Comparative CS-aNN performance for different encoding sizes}. Recall@1 on the three datasets for increasing number of encoding bits, comparing PQ and RVQ with \mbox{Q$\alpha$-PQ}~ and \mbox{Q$\alpha$-RVQ}~ respectively. } \label{fig:r@1} \end{figure*} \noindent\textbf{CS-aNN}\quad We compare RVQ to \mbox{Q$\alpha$-RVQ}~ and PQ to \mbox{Q$\alpha$-PQ}~ for different code sizes, from 8 to 24 bytes per vector, on the task of maximum cosine similarity over $\ell^2$-normalized vectors. Corresponding Recall@1 curves are in Fig. \ref{fig:r@1}. \mbox{Q$\alpha$-RVQ}~ clearly outperforms RVQ on all datasets, even with a substantial margin on GIST1M and VLAD500K, \emph{i.e.}, around 30\% relative gain at 24 bytes. The comparison between PQ and \mbox{Q$\alpha$-PQ}~ leads to mixed conclusions: while \mbox{Q$\alpha$-PQ}~is below PQ on SIFT1M, it is slightly above for GIST1M and almost similar for VLAD500K. Note however that, for the same number $M \log_2 K$ of encoding bits, \mbox{Q$\alpha$-PQ}~ uses $M\frac{K}{2}+2^M$ centroids, which is nearly half the number $MK$ of centroids used by PQ in low $M$ regimes (\emph{e.g.}, when $K=256$, 528 vs. 1024 centroids for $M=4$ and 1280 vs. 2048 centroids for $M=8$). Much fewer centroids for equal code size and similar performance yield computational savings in learning and encoding phases. \medskip \noindent\textbf{Euclidean aNN}\quad In order to conduct comparison with other state-of-art methods such as extensions of PQ and of RVQ, we also considered the Euclidean aNN search problem, with no prior normalization of vectors. For this problem, the proposed approach applies similarly since the minimization problem $\arg\!\min_{\mbf{x}\in\mcl{X}} \|\mbf{y} - Q(\mbf{x})\|^2 = \arg\!\max_{\mbf{x}\in\mcl{X}} \trsp{\mbf{y}}Q(\mbf{x}) - \frac{\|Q(\mbf{x})\|^2}{2}$ involves the same quantities as the one in (\ref{eq:cs_ann}). Recall@{\tt R} curves are provided in Fig. \ref{fig:l2_recall} on two of the three datasets, relying on results reported in \cite{NF13} for CKM, RVQ and ERVQ, and \cite{BL14}, \cite{ZDW14} for AQ and CQ respectively. We observe again that $\mbox{Q$\alpha$-PQ}$ is below PQ on SIFT but on par with it on GIST. On SIFT, $\mbox{Q$\alpha$-RVQ}$, ERVQ and CQ perform similarly, while on GIST $\mbox{Q$\alpha$-RVQ}$ outperforms all, including CQ and ERVQ. As discussed in Section \ref{sec:related}, AQ is the most accurate but has very high encoding complexity. CQ also has higher encoding complexity compared to our simple and greedy approach. Table \ref{tab:dist_unnorm} shows reconstruction errors for the same setting as in Fig. \ref{fig:l2_recall}. This is consistent with the results in Fig. \ref{fig:l2_recall}, and shows again that $\mbox{Q$\alpha$-RVQ}$ is the best performer and that $\mbox{Q$\alpha$-PQ}$ does not improve on PQ with the same number of encoding bits. \begin{figure*} \centerline{\scriptsize \begin{tabular}{ccc} \includegraphics[trim = 0mm 1mm 0mm 3mm, clip, width=.25\textwidth]{figs/l2_recall_64_SIFT1M_AQCQ.pdf} \includegraphics[trim = 0mm 1mm 0mm 3mm, clip, width=.25\textwidth]{figs/l2_recall_72_SIFT1M.pdf}& \quad & \includegraphics[trim = 0mm 1mm 0mm 3mm, clip, width=.25\textwidth]{figs/l2_recall_64_GIST1M_CQ.pdf} \includegraphics[trim = 0mm 1mm 0mm 3mm, clip, width=.25\textwidth]{figs/l2_recall_72_GIST1M.pdf}\\ SIFT1M: 64 bits and 72 bits encoding& & GIST1M: 64 bits and 72 bits encoding \end{tabular}} \caption{{\bf Performance comparison for Euclidean-aNN}. Recall@{\tt R} curves on SIFT1M and GIST1M, comparing proposed methods to PQ, RVQ and to some of their extensions, CKM~\cite{NF13}, ERVQ~\cite{AYWHG15}, AQ~\cite{BL14} and CQ~\cite{ZDW14}. } \label{fig:l2_recall} \end{figure*} \begin{table} \centering \begin{tabular}{ccccc} \hline & \multicolumn{2}{c}{SIFT} & \multicolumn{2}{c}{GIST} \\ \hline encoding bits & 64 & 72 & 64 & 72 \\ \hline\hline PQ & 23515 & 20054 & 0.7121 & 0.6733 \\ \hline \mbox{Q$\alpha$-PQ} & 25859 & 22007 & 0.7224 & 0.6868 \\ \hline RVQ & 22170 & 20606 & 0.6986 & 0.6734 \\ \hline \mbox{Q$\alpha$-RVQ} & \textbf{22053}& \textbf{19976}& \textbf{0.6537}& \textbf{0.6174} \\ \hline \end{tabular} \caption{{\bf Comparative distortions in Euclidean aNN setting}. Average squared reconstruction errors on un-normalized SIFT1M and GIST1M.} \label{tab:dist_unnorm} \end{table} Note that the lower performance of $\mbox{Q$\alpha$-PQ}$ compared to PQ is because it uses half the number of codewords to have equal or smaller memory footprint. Relative timings in Tab.~\ref{tab:timings} indicate $\mbox{Q$\alpha$-PQ}$ is substantially faster for learning and encoding in this setting. Our methods are slower in search but this overhead has minimal effect in the applications with very large scale data as we shall see in our billion-scale experiments. \begin{table} \centering \begin{tabular}{llllr} \hline & PQ & $\mbox{Q$\alpha$-PQ}$ & RVQ & $\mbox{Q$\alpha$-RVQ}$ \\ \hline \hline learn & 1 & 0.212 & 1.250 & 0.719 \\ \hline encode & 1 & 0.206 & 1.347 & 0.613 \\ \hline search & 1 & 1.867 & 1.220 & 1.909 \\ \hline \end{tabular}\hfil \caption{{\bf Relative timings}. Learning, encoding and search timings w.r.t PQ on SIFT1M with 64 bits encoding. \mbox{Q$\alpha$-PQ}~and \mbox{Q$\alpha$-RVQ}~ have faster learning/encoding as they use inner product instead of $\ell^2$ distance and have fewer codewords. }\label{tab:timings} \end{table} Table~\ref{tab:pq_methods} provides recall rates for various PQ based methods on SIFT1M with 64 bits encoding. CKM and OPQ are very similar extensions on PQ and thus perform similarly. The improvement provided by CKM/OPQ on PQ is complimentary to $\mbox{Q$\alpha$-PQ}$. By using OPQ instead of PQ within $\mbox{Q$\alpha$-PQ}$, calling it \mbox{Q$\alpha$-OPQ}, we get similar gains as OPQ gives over PQ. This can be seen by comparing the gains of \mbox{Q$\alpha$-OPQ} over \mbox{Q$\alpha$-PQ}~and OPQ over PQ. These results of OPQ and \mbox{Q$\alpha$-OPQ} are not plotted in \ref{fig:l2_recall} to maintain clarity. \begin{table} \centering \begin{tabular}{crrrrr} \hline Recall~ & PQ~ & CKM~ & OPQ~ & \mbox{Q$\alpha$-PQ}~ & \mbox{Q$\alpha$-OPQ} \\ \hline \hline $R@1$ & 0.228 & 0.240 & 0.243 & 0.204 & 0.227 \\ \hline $R@10$ & 0.604 & 0.640 & 0.638 & 0.562 & 0.603 \\ \hline $R@100$ & 0.919 & 0.945 & 0.942 & 0.900 & 0.927 \\ \hline \end{tabular} \caption{{{\bf CKM/OPQ comparison with PQ}. Performance of PQ based methods on SIFT1M with 64 bits encoding. $(M, K) = (8, 256)$ for PQ, CKM and OPQ and $(M, K, P) = (8, 128, 256)$ for our methods.} \label{tab:pq_methods}} \end{table} \noindent\textbf{Very large scale experiments on BIGANN}\quad We validate our approach on large scale experiments carried out on the BIGANN dataset \cite{jegou2011searching}, which contains 1 billion SIFT vectors ($N=1B$, $R=1M$ out of the original 100M training set and $S=10K$ queries). At that scale, an inverted file (IVF) system based on a preliminary coarse quantization of vectors is required. In our experiments, each vector is quantized over $K_c=8192$ centroids, and it is its residual relative to assigned centroid that is fed to the chosen encoder. At search time, the query is multiply assigned to its $W_c=64$ closest centroids and $W_c$ searches are conducted over the corresponding vector lists (each of average size $N/K_c$). Performance is reported in Fig. \ref{fig:bigann_recall} for PQ, RVQ and their proposed extensions. For all of them the setting is $M=8$ and $K=256$, except for PQ-72 bits ($K=512$). All of them use the exact same IVF structure, which occupies approximately 4GB in memory (4B per vector). For RVQ and \mbox{Q$\alpha$-RVQ}, norms of approximated database vectors are quantized over 256 scalar values. The best performance is obtained with the proposed \mbox{Q$\alpha$-RVQ}~approach, which requires 10 bytes per vector, thus a total of 14GB for the whole index. The second best aNN search method is PQ-72 bits, which requires 9 bytes per vector, hence 13GB of index. While both indexes have similar sizes and fit easily in main memory, PQ-72 relies on twice as many vector centroids which makes learning and encoding more expensive. \begin{figure*} \begin{tabular}{c} \raisebox{-0.5\height}{\includegraphics[width=.5\textwidth]{figs/bigann_results.pdf}} \quad\begin{tabular}{llllr} \toprule Method (\textit{b}) & R@1 & R@10 & R@100 & time \\ \toprule PQ-64 (8) & 0.111 & 0.388 & 0.756 & 1.00 \\ \hline PQ-72 (9) & 0.144 & 0.471 & 0.825 & 1.03 \\ \hline RVQ (9) & 0.124 & 0.421 & 0.803 & 1.02 \\ \hline \mbox{Q$\alpha$-PQ} (9) & 0.139 & 0.450 & 0.811 & 1.69 \\ \hline \mbox{Q$\alpha$-RVQ} (10) & 0.160 & 0.514 & 0.868 & 1.72 \\ \hline \mbox{Q$\alpha$-RVQ}$_{128}$ & 0.160 & 0.514 & 0.868 & 0.89 \\ \hline \mbox{Q$\alpha$-RVQ}$_{8}$ & 0.151 & 0.467 & 0.730 & 0.17 \\ \hline \end{tabular} \end{tabular} \caption{{\bf Large scale performance with IVF}. Recall@{\tt R} on the BIGANN 1B-SIFT dataset and 10K queries. For all methods, $M=8$ and $K=256$, except for ``PQ-72" ($K=512$). For quantized sparse coding methods, $P=256$ and norms in residual variant are quantized over 256 scalar values, resulting encoding sizes (\textit{b}) being given in bytes per vector. All methods share the same IVF index with $K_c=2^{13}$ and $W_c=64$. Subscripted \mbox{Q$\alpha$-RVQ}~denotes variants with additional pruning ($W'_c=128$ and $8$ resp.). Search timings are expressed relative to PQ-64.} \label{fig:bigann_recall} \end{figure*} The superior performance of \mbox{Q$\alpha$-RVQ}~ comes at the price of a 70\% increase of search time per query compared to PQ. This can nonetheless be completely compensated for since the hierarchical structure of \mbox{Q$\alpha$-RVQ}~ lends itself to additional pruning after the one with IVF. The $W'_c$ atoms most correlated with the query residual in $C^1$ are determined, and dataset vectors whose first layer encoding uses none of them are ignored. For $W'_c =128$, search time is reduced substantially, making \mbox{Q$\alpha$-RVQ}~10\% faster than PQ, with no performance loss (hence superior to PQ-72). A more drastic pruning ($W'_c=8$) makes performance drop below that of PQ-72, leaving it on par with PQ-64 while being almost 6 times faster. A variant of IVF, called ``inverted multi-index'' (IMI) \cite{BL12} is reported to outperform IVF in speed and accuracy, by using two-fold product quantization instead of vector quantization to produce the first coarse encoding. Using two codebooks of size $K_c$, one for each half of the vectors, IMI produces $K_c^2$ inverted lists. We have run experiments with this alternative inverted file system, using $K_c=2^{14}$ and scanning a list of $T = 100K,~30K$ or $10K$ vectors, as proposed in \cite{BL12}. The comparisons with PQ-64 based on the same IMI are summarized in Tab. \ref{tab:imi_bigann} in terms of recall rates and timings. For all values of $T$, the proposed $\mbox{Q$\alpha$-RVQ}$ and $\mbox{Q$\alpha$-PQ}$ perform the best and with similar search time as RVQ and PQ-64. Also, $\mbox{Q$\alpha$-RVQ}$ with $T=30K$ has the same recall@100 as PQ-64 with $T=100K$ while being twice as fast (14ms vs. 29ms per query). For a fixed $T$, PQ-64 and $\mbox{Q$\alpha$-PQ}$ (resp. RVQ and $\mbox{Q$\alpha$-RVQ}$) have the same search speed, as the overhead of finding the $T$ candidates and computing look-up tables dominates for such relatively short lists. The $T$ candidates for distance computation are very finely and scarcely chosen. Therefore, increasing the size $K$ of dictionaries/codebooks in the encoding method directly affects search time. This advocates for our methods, as for equal $(M,K)$ and an extra byte for encoding coefficients, $\mbox{Q$\alpha$-RVQ}$ and $\mbox{Q$\alpha$-PQ}$ always give better performance. Compared to PQ-72, $\mbox{Q$\alpha$-PQ}$~ is faster (only half the number of codewords is required in the quantization) with slightly lower accuracy. $\mbox{Q$\alpha$-RVQ}$ is more accurate with extra execution time compared to PQ-72. \begin{table*} \centerline{\footnotesize \begin{tabular}{l cccc c cccc c cccc} \toprule & \multicolumn{4}{c}{$T=$100K} & \quad & \multicolumn{4}{c}{$T=$30K} & \quad & \multicolumn{4}{c}{$T=$10K} \\ \cline{2-5}\cline{7-10} \cline{12-15} Method (\textit{b}) & R@1 & R@10 & R@100 & time & \quad & R@1 & R@10 & R@100 & time & \quad & R@1 & R@10 & R@100 & time \\ \hline PQ-64 (8) & 0.170 & 0.535 & 0.869 & 29 & \quad & 0.170 & 0.526 & 0.823 & 11 & \quad & 0.166 & 0.495 & 0.725 & 5 \\ RVQ (9) & 0.181 & 0.553 & 0.877 & 37 & \quad & 0.180 & 0.542 & 0.831 & 14 & \quad & 0.174 & 0.506 & 0.729 & 8 \\ \mbox{Q$\alpha$-PQ} (9) & 0.200 & 0.587 & 0.898 & 30 & \quad & 0.198 & 0.572 & 0.848 & 11 & \quad & 0.193 & 0.533 & 0.740 & 5 \\ \mbox{Q$\alpha$-RVQ}(10) & 0.227 & 0.630 & 0.920 & 37 & \quad & 0.225 & 0.613 & 0.862 & 14 & \quad & 0.217 & 0.566 & 0.747 & 8 \\ PQ-72 (9) & 0.207 & 0.603 & 0.902 & 34 & \quad & 0.205 & 0.586 & 0.849 & 12 & \quad & 0.2 & 0.547 & 0.739 & 6 \\ \bottomrule \end{tabular}} \caption{{\bf Performance and timings with IMI on 1B SIFTs}. Recalls are reported along with search time in milliseconds per query as a function of the length $T$ of candidate list to be exhaustively scanned. For each method, the encoding size (\textit{b}) is given in bytes per vector.} \label{tab:imi_bigann} \end{table*} \section{Discussion and conclusion}\label{sec:conclusion} In this work we present a novel quantized sparse representation that is specially designed for large scale approximate nearest neighbour search. The residual form of this representation, \mbox{Q$\alpha$-RVQ}, clearly outperforms RVQ in all datasets and settings, for equal code size. Within the recursive structure of residual quantization, the introduction of additional coefficients in the representation thus offers accuracy improvements that translate into aNN performance gains, even after drastic vector quantization of these coefficients. Interestingly, the gain is much larger for image level descriptors (GIST and VLAD) which are key to very large visual search. One possible reason for the proposed approach to be especially successful in its residual form lies in the rapid decay of the coefficients that the hierarchical structure induces. This facilitates quantization of coefficient vectors, even with 1 byte only. In its partitioned variant, this property is not true anymore, and the other proposed approach, \mbox{Q$\alpha$-PQ}, brings less gain. It does however improve over PQ for image-level descriptors, especially in small $M$ regimes, while using fewer centroids. As demonstrated on the billion-size BIGANN dataset, the proposed framework can be combined with existing inverted file systems like IVF or IMI to provide highly competitive performance on large scale search problems. In this context, we show in particular that both \mbox{Q$\alpha$-PQ}~and \mbox{Q$\alpha$-RVQ}~offer higher levels of search quality compared to PQ and RVQ for similar speed and that they allow faster search with similar quality. Regarding \mbox{Q$\alpha$-RVQ}, it is also worth noting that its hierarchical structure allows one to prune out most distant vectors based only on truncated descriptors, as demonstrated on BIGANN1B within IVF system. Conversely, this nested structure permits to refine encoding if desired, with no need to retrain and recompute the encoding up to the current layer. On a different note, the successful deployment of the proposed quantized sparse encoding over million to billion-sized vector collections suggests it could help scaling up sparse coding massively in other applications. \section{Introduction}\label{sec:into} Retrieving, from a very large database of high-dimensional vectors, the ones that ``resemble" most a query vector is at the heart of most modern information retrieval systems. Online exploration of very large media repositories, for tasks ranging from copy detection to example-based search and recognition, routinely faces this challenging problem. Vectors of interest are abstract representations of the database documents that permit meaningful comparisons in terms of distance and similarity. Their dimension typically ranges from a few hundreds to tens of thousands. In visual search, these vectors are ad-hoc or learned descriptors that represent image fragments or whole images. Searching efficiently among millions or billions of such high-dimensional vectors requires specific techniques. The classical approach is to re-encode all vectors in a way that allows the design of a compact index and the use of this index to perform fast \textit{approximate search} for each new query. Among the different encoding approaches that have been developed for this purpose, state-of-the-art systems rely on various forms of vector quantization: database vectors are approximated using compact representations that can be stored and searched efficiently, while the query need not be approximated (asymmetric approximate search). In order to get high quality approximation with practical complexities, the encoding is structured, typically expressed as a sum of codewords stemming from suitable codebooks. There are two main classes of such structured quantization techniques: those based on vector partitioning and independent quantization of sub-vectors \cite{GHKS13,JDS11,NF13}; those based on sequential residual encoding \cite{AYWHG15,CGW10,jegou2011searching,MHL14,ZDW14,ZQTW15}. In this work, we show how these approaches can be taken one step further by drawing inspiration from the sparse coding interpretation of these techniques~\cite{VZ12a}. The key idea is to represent input vectors as linear combinations of atoms, instead of sums of codewords. The introduction of scalar weights allows us to extend both residual-based and partitioned-based quantizations such that approximation quality is further improved with modest overhead. For this extension to be compatible with large scale approximate search, the newly introduced scalar weights must be themselves encoded in a compact way. We propose to do so by quantizing the vector they form. The resulting scheme will thus trade part of the original encoding budget for encoding coefficients. As we shall demonstrate on various datasets, the proposed quantized sparse representation (i) competes with partitioned quantization for equal memory footprint and lower learning/coding complexity and (ii) outperforms residual quantization with equal or smaller memory footprint and learning/coding complexity. In the next section, we discuss in more details the problem of approximate vector search with structured quantizers and recall useful concepts from sparse coding. With these tools in hand, we introduce in Section \ref{sec:approach} the proposed structured encoding by quantized sparse representations. The different bricks --learning, encoding and approximate search-- are presented in Sections \ref{sec:sparse} and \ref{sec:search}, both for the most general form of the framework (residual encoding with non-orthogonal dictionaries) and for its partitioned variant. Experiments are described and discussed in Section \ref{sec:experiments}. \section{Related work}\label{sec:related} Approximate vector search is a long-standing research topic across a wide range of domains, from communication and data mining to computer graphics and signal processing, analysis and compression. Important tools have been developed around hashing techniques \cite{IM98}, which turn the original search problem into the one of comparing compact codes, \emph{i.e.}, binary codes~\cite{C02}, see \cite{wangLKC15} for a recent overview on binary hashing techniques. Among other applications, visual search has been addressed by a number of such binary encoding schemes (\emph{e.g.}, \cite{lv2004image,NPF12,torralba2008small,WKC12,XWLZLY11}). An important aspect of hashing and related methods is that their efficiency comes at the price of comparing only codes and not vectors in the original input space. In the present work we focus on another type of approaches that are currently state-of-art in large scale visual search. Sometimes referred to as \textit{vector compression} techniques, they provide for each database vector $\mbf{x}$ an approximation $Q(\mbf{x})\approx \mbf{x}$ such that (i) the Euclidean distance (or other related similarity measure such as inner product or cosine) to any query vector $\mbf{y}$ is well estimated using $Q(\mbf{x})$ instead of $\mbf{x}$ and (ii) these approximate (di)similarity measures can be efficiently computed using the code that defines $Q(\mbf{x})$. A simple way to do that is to rely on vector quantization \cite{gersho2012vector}, which maps $\mbf{x}$ to the closest vector in a codebook learned through $k$-means clustering. In high dimensions though, the complexity of this approach grows to maintain fine grain quantization. A simple and powerful way to circumvent this problem is to partition vectors into smaller dimensional sub-vectors that are then vector quantized. At the heart of product quantization (PQ) \cite{JDS11}, this idea has proved very effective for approximate search within large collections of visual descriptors. Different extensions, such as ``optimized product quantization'' (OPQ) \cite{GHKS13} and ``Cartesian $k$-means" (CKM) \cite{NF13} optimize the chosen partition, possibly after rotation, such that the distortion $\|\mbf{x}-Q(\mbf{x})\|$ is further reduced on average. Additionally, part of the encoding budget can be used to encode this distortion and improve the search among product-quantized vectors \cite{HLY14}. It turns out that this type of partitioned quantization is a special case of \textit{structured} or layered quantization: \begin{equation} Q(\mbf{x}) = \sum_{m=1}^M Q_m(\mbf{x}), \label{eq:ac} \end{equation} where each quantizer $Q_m$ uses a specific codebook. In PQ and its variants, these codebooks are orthogonal, which makes learning, encoding and search especially efficient. Sacrificing part of this efficiency by relaxing the orthogonality constraint can nonetheless provide better approximations. A number of recent works explore this path. ``Additive quantization" (AQ) \cite{BL14} is probably the most general of those, hence the most complex to learn and use. It indeed addresses the combinatorial problem of jointly finding the best set of $M$ codewords in \eqref{eq:ac}. While excellent approximation and search performance is obtained, its high computational cost makes it less scalable \cite{babenko2015tree}. In particular, it is not adapted to the very large scale experiments we report in present work. In ``composite quantization" (CQ) \cite{ZDW14}, the overhead caused at search time by the non-orthogonality of codebooks is alleviated by learning codebooks that ensure $\|Q(\mbf{x})\|= \mathrm{cst}$. This approach can be sped up by enforcing in addition the sparsity of codewords \cite{ZQTW15}. As AQ --though to a lesser extent-- CQ and its sparse variant have high learning and encoding complexities. A less complex way to handle sums of codewords from non-orthogonal codebooks is offered by the greedy approach of ``residual vector quantization" (RVQ) \cite{BRN96,JH82}. The encoding proceeds sequentially such that the $m$-th quantizer encodes the \textit{residual} $\mbf{x}-\sum_{n=1}^{m-1}Q_{n}(\mbf{x})$. Accordingly, codebooks are also learned sequentially, each one based on the previous layer's residuals from the training set. This classic vector quantization approach was recently used for approximate search \cite{AYWHG15,CGW10,MHL14}. ``Enhanced residual vector quantization" (ERVQ) \cite{AYWHG15} improves the performance by jointly refining the codebooks in a final training step, while keeping purely sequential the encoding process. Important to the present work, \textit{sparse coding} is another powerful way to approximate and compress vectors \cite{elad2010sparse}. In this framework, a vector is also approximated as in \eqref{eq:ac}, but with each $Q_m(\mbf{x})$ being of the form $\alpha_m \mbf{c}_{k_m}$, where $\alpha_m$ is a scalar weight and $\mbf{c}_{k_m}$ is a unit norm \textit{atom} from a learned \textit{dictionary}. The number of selected atoms can be pre-defined or not, and these atoms can stem from one or multiple dictionaries. A wealth of techniques exist to learn dictionaries and encode vectors \cite{elad2010sparse,mairal2010online,wright2010sparse}, including ones that use the Cartesian product of sub-vector dictionaries \cite{GHS14} similarly to PQ or residual encodings \cite{zepeda2011jstsp,zepeda2010mmsp} similarly to RQ to reduce encoding complexity. Sparse coding thus offers representations that are related to structured quantization, and somewhat richer. Note however that these representations are not discrete in general, which makes them \textit{a priori} ill-suited to indexing very large vector collections. Scalar quantization of the weights has nonetheless been proposed in the context of audio and image compression \cite{zepeda2011jstsp,frossard2004posteriori,yaghoobi2007quantized}. Our proposal is to import some of the ideas of sparse coding into the realm of approximate search. In particular, we propose to use sparse representations over possibly non-orthogonal dictionaries and with vector-quantized coefficients, which offer interesting extensions of both partitioned and residual quantizations.
{'timestamp': '2016-08-12T02:01:00', 'yymm': '1608', 'arxiv_id': '1608.03308', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03308'}
arxiv
\section{Public Good model} It is generally accepted that random events play a strong role in the evolution of cooperative behavior, which is deterministically selected against~\cite{nowak_2006}. The standard formulation of evolutionary game theory involves setting the problem in terms of a modified Moran model~\cite{nowak_2004,rice_evo_theory}. The Moran model is a population genetic model first developed as an abstract illustration of the effect of genetic drift in a haploid population of two phenotypes; an individual is picked to reproduce with a probability proportional to their fitness, whilst simultaneously a second individual is chosen randomly to die~\cite{crow_kimura_into}. Coupling birth and death events keeps the population size fixed, which increases the tractability of the system. The specification of fixed population size is however restrictive and can be problematic. Most prominently, a phenotype with increased fitness can be no more abundant in isolation than its ailing counterpart. Additional difficulties are encountered if one attempts to use simple game-theoretic models to quantitatively understand more complex experimental data. While, for example, assuming some arbitrary non-linearity in the model's game payoff matrix may enable experimental findings to be elegantly recapitulated, it is more difficult to justify the origin of these assumptions on a mechanistic level~\cite{gore_2009}. In light of such issues, it has been suggested that a more ecologically grounded take on the dynamics of cooperation might be preferable~\cite{hauert_2006,huang_2015}, one in which the population size is not fixed and that is sufficiently detailed that mechanistic (rather than phenomenological) parameters can be inferred experimentally. In the following, we take such an approach. We begin by considering a prototypical model of public good production and consumption. In our model, we consider a phenotype $X$ having the ability to produce a public good $Q$ that catalyzes its growth. We wish to capture the stochastic dynamics of the system. To this end we assume that the system is described by a set of probability transition rates, which describe the probability per unit time of each reaction occurring: \begin{eqnarray} & X \overset{b_{x}}{\underset{\kappa/R^{2}}{ \myrightleftarrows{\rule{0.4cm}{0cm}} } } X + X \,, \quad & X + Q \xrightarrow{ r / R^{2} } X + X + Q \,, \nonumber \\ & X\xrightarrow{ p_{x} } X + Q \,,\quad & Q\xrightarrow{\delta}\varnothing\,. \label{eq_reactions_1} \end{eqnarray} In the absence of the public good, the producer phenotype $X$ reproduces at a baseline birthrate $b_{x}$. The phenotypes encounter each other and the public good at a rate $R^{-2}$; the quantity $R^{2}$ can be interpreted as a measure of the area (or volume) to which the system is confined. Death of the phenotype occurs solely due to crowding effects at rate $\kappa$, multiplied by the encounter rate. Phenotypes encounter and utilize the public good at a rate $r/R^{2}$. We study the case where this reaction is catalytic (i.e. the public good is conserved) and leads to a phenotype reproduction. Examples of catalytic (reusable) public goods are the enzyme invertase produced by the yeast \textit{Saccharomyces cerevisiae}~\cite{koschwanez_2011} or the siderophore pyoverdine produced by the bacterium \textit{Pseudomonas aeruginosa}~\cite{kummerli_2010}. The total rate at which the phenotype reproduces is thus increased in the presence of the public good. The public good itself is produced by the producer phenotype at a rate $p_{x}$ and decays at a rate $\delta$. Note that as well as controlling the spatial scale of the well-mixed system, the magnitude of $R$ will also control the typical number of individuals in the system, since larger $R$ (more space) allows the population to grow to greater numbers. We next introduce a mutant phenotype $Y$ that does not produce the public good; (i.e. $p_{y}=0$) consequently, it has a different baseline birth rate $b_{y}$ which we expect to be at least as high as that of the producer, due to the non-producers' reduced metabolic expenditure. Its interactions with the public good are otherwise similar to those of $X$ (see \eref{eq_reactions_1}). The state of the system is specified by the discrete variables $n_{x}$, $n_{y}$ and $n_{q}$, the number of each phenotype and public good respectively. For the system described, we wish to know the probability of being in any given state at any given time. To answer this, we set up an infinite set of partial difference equations (one for each unique state $(n_x,n_y,n_q)$) that measures the flow of probability between neighboring states (controlled by the transitions \eref{eq_reactions_1}). These equations govern the time-evolution of a probability density function $P(n_{x},n_{y},n_{q},t)$ (see \eref{eq:supmat_meqn_general}). Such a model is sometimes termed a microscopic description~\cite{gardiner_2009}, since it takes account of the dynamics of discrete interactions between the system variables. Although the probabilistic model is straightforward to formalize, it is difficult to solve in its entirety. We apply an approximation that makes the model more tractable, while maintaining the system's probabilistic nature. Such approximations, which assume that the system under consideration has a large but finite number of individuals, are well practiced and understood~\cite{gardiner_2009} and are analogous to the diffusion approximation~\cite{crow_kimura_into} of population genetics. Assuming that $R$ is large, but finite, (which implies a large number of individuals in the system), we transform the system into the approximately continuous variables $(x,y,q)=(n_{x},n_{y},n_{q})/R^{2}$ and expand the partial difference equations in $1/R^{2}$. This allows us to to express the infinite set of partial difference equations as a single partial differential equation in four continuous variables, $(x,y,q,t)$. However, since the PDE results from a Taylor expansion, it has infinite order. Truncating the expression after the first term (at order $R^{-2}$), one obtains a deterministic approximation of the dynamics (valid for $R \rightarrow \infty$, or equivalently for infinite population sizes). Since we aim to make the system tractable but still retain some stochastic element to the dynamics, we truncate the expansion after the second term (at order $R^{-4}$, see \eref{eq:supmat_eq_FPE_general}). The resulting model can be conveniently expressed as a set of It\={o} stochastic differential equations (SDEs): \begin{eqnarray} \dot x &=& x \left[ b_{x} + r q -\kappa (x+y) \right] + R^{-1} \eta_{x}(t)\,, \nonumber \\ \dot y &=& y \left[ b_{y} + r q -\kappa (x+y) \right] + R^{-1} \eta_{y}(t)\,, \label{eq_PG_SDE} \\ \dot q &=& p_{x} x - \delta q + R^{-1} \eta_{q}(t) \,. \nonumber \end{eqnarray} The $\eta_{i}(t)$ represent Gaussian white noise terms whose correlations depend on the state of the system (the noise is multiplicative). Importantly, because \eref{eq_PG_SDE} has been developed as a rigorous approximation of the underlying stochastic model, \eref{eq_reactions_1}, the precise functional form of the noise can be determined explicitly, rather than posited on an ad-hoc basis (see \Aref{sec:supmat_sec_obtain_SDE_system}). Setting $ R \rightarrow \infty $, the population size increases with the interaction scale and one recovers the deterministic limit. Since \eref{eq_PG_SDE} is a course-grained approximation of the underlying microscopic model but retains an inherent stochasticity, it is often referred to as the mesoscopic limit~\cite{mckane_TREE}. First we analyze the dynamics of \eref{eq_PG_SDE} in the deterministic, $ R \rightarrow \infty $ limit. There exist three fixed points, or equilibria. The first, at the origin, is always unstable. The remaining fixed points occur when the system only contains a single phenotype: the producer fixed point, $(x,y,q)=( K_{x} , 0 , p_{x} K_{x}/\delta )$ and the non-producer fixed point, $(x,y,q)=( 0 , K_{y} , 0 )$. Thus $K_{x}$ and $K_{y}$ are measures of the phenotypes' frequency (carrying capacity) in isolation, with precise forms \begin{equation} K_{x}= \frac{ b_{x} \delta }{ \kappa \delta - p_{x} r }\,, \qquad K_{y}= \frac{ b_{y} }{ \kappa }\,. \label{eq_carrying_capacity} \end{equation} If $b_y>b_x$ then the non-producer fixed point is always stable while the producer fixed point is always unstable. However, the non-producer fixed point is only globally attracting if $ \kappa \delta > r p_{x} $. If this condition is not met then there exist initial conditions for which the producers produce and process the public good faster than they die and faster than the public good degrades, resulting in unbounded exponential growth of the system. This biologically unrealistic behavior comes from the fact that we have assumed for simplicity that the public good uptake does not saturate. Since this behavior is unrealistic, we will work in the regime $ \kappa \delta > r p_{x} $ for the remainder of the paper. Finally, we are interested in systems where the size of the producer population in isolation is larger than that of the non-producer, $K_x>K_y$; this is true if the condition $b_{x}>b_{y}(1-r p_x/\delta\kappa)$ holds. Thus, deterministically, a non-producing mutant will always take over a producer population and, due to the absence of the public good, it will yield a smaller population at equilibrium. This deterministic analysis predicts, unsurprisingly, that a population composed entirely of non-producers is the only stable state. We next explore the behavior of the system in \eref{eq_reactions_1} when demographic stochasticity is considered. \subsection{Mesoscopic selection reversal} Due to noise, a stochastic system will not be positioned precisely on deterministic fixed points, but rather it will fluctuate around them. In the above system, these fluctuations will occur along the $y$-axis for the non-producer fixed point while in the absence of non-producers they will occur in the $(x,q)$ plane for the producer fixed point. We can define $N_{x} = R^{2} K_{x}$ and $N_{y} = R^{2} K_{y}$ to be the mean number of the phenotypes $X$ and $Y$ in isolation in the respective stationary states. We assume that the non-producing phenotype has a greater per-capita birth rate than the producer phenotype, i.e. $b_{y} > b_{x}$, and we introduce a single non-producing mutant into a producer population. While the deterministic theory predicts that the non-producer should sweep through the population until it reaches fixation, in the stochastic setting fixation of the non-producer is by no means guaranteed: there is a high probability that the single mutant might be lost due to demographic noise. However, since the non-producer is deterministically selected for, we might expect the probability of a non-producer mutant invading and fixating in a resident producer population to be greater than the probability of a producer mutant invading and fixating in a resident non-producer population. We will explore this question below. In order to make analytic predictions about the stochastic model, we need to reduce the complexity of the system. This can be done if we employ methods based on the elimination of fast variables~\cite{parsons_rogers_2015} to obtain an effective one-dimensional description of the system dynamics. To this end, we begin by assuming that the public good production and decay, $p_{x}$ and $\delta$, and the phenotypes' reproduction and death, $b_{x}$, $b_{y}$, and $\kappa$, occur on a much faster timescale than the rate of change of population composition, which is governed by the difference in birth rates, $b_x - b_y$. Essentially this assumes that the cost of public good production is marginal. In the case of \textit{S. cerevisiae}, this assumption is supported by empirical work (see \tref{tab:supmat_fig_parameter_list_1}). In order to mathematically investigate this timescale-separation we define \begin{equation} b_{x} = b(1-\varepsilon)\,,\quad b_{y} = b \,, \label{eq_def_b} \end{equation} where the parameter $\varepsilon$ represents the metabolic cost that $X$ pays for producing the public good. The parameter $\varepsilon$ now controls the rate of change of population composition, and if $1>>\varepsilon$, we have our desired timescale separation in the deterministic system. Because the parameters $K_{x}$, $K_{y}$, $N_{x}$ and $N_{y}$ depend on $\varepsilon$, we will find it convenient to define their values when $\varepsilon=0$ as $K_{x}^{(0)}$, $K_{y}^{(0)}$, $N_{x}^{(0)}$ and $N_{y}^{(0)}$ respectively. In order to maintain our assumption that the composition of the phenotype population changes slowly in the stochastic system, we additionally require that the noise is small. However this assumption has already been implicitly made in the derivation of \eref{eq_PG_SDE}, where it was assumed that $R$ is large, and thus $R^{-1}$, the prefactor for the noise terms, is small. In order to formalize this, we will find it convenient to assume $R^{-2}\approx \mathcal{O}\left( \varepsilon \right)$. Under the above assumptions, the system features a separation of timescales. Next, we take advantage of this to reduce the complexity of the system. Deterministically, the existence of a set of fast timescales suggests the existence of a lower-dimensional subspace, the slow manifold (SM), shown in \fref{fig_streamplots}(a), to which the system quickly relaxes, and along which it slowly moves, until it reaches the system's stable fixed point. This behavior can be exploited if we assume that the system reaches the SM instantaneously. We can then describe the dynamics of the entire system in this lower dimensional space, and thus reduce the number of variables in our description of the deterministic system. However, we are interested in the stochastic dynamics. \begin{figure}[t] \setlength{\abovecaptionskip}{-2pt plus 3pt minus 2pt} \begin{center} \includegraphics[width=0.5\textwidth]{fig1.pdf} \end{center} \caption{System dynamics in the phenotype plane. Deterministic trajectories shown as gray arrows. Panel (a): Trajectories rapidly collapse to a SM (black dashed line), before slowly moving to the non-producing $Y$ fixed-point. Stochastic trajectories (histogram overlaid in orange) remain in the region of the SM but may fluctuate away from it. Panel (b): Illustration of the origin of noise-induced selection. The orange ellipse depicts the standard deviation of Gaussian fluctuations originating at its center. Fluctuations (black dashed arrows) to points $\alpha$ are equally likely, however when projected back to the CM (black dashed line) to points $\beta$, a bias for producing $X$ phenotype is observed. Parameters used are $p_{x}=9.5\times10^{-4}$, $\varepsilon=0.08$ in panel (a), $\varepsilon=0$ in panel (b) and the remaining parameters are given in \tref{tab:supmat_fig_parameter_list_1}. }\label{fig_streamplots} \end{figure} The stochastic trajectories initially collapse to the region around the SM, about which they are confined, but along which they can move freely until one of the phenotypes fixates (see \fref{fig_streamplots}(a)). Fluctuations that take the system off the SM are quickly quashed back to another point on the SM; however the average position on the SM to which a fluctuation returns is not necessarily the same as that from which the fluctuation originated. A crucial element of the dynamics in this stochastic setting is that the form of the noise, combined with that of the trajectories back to the SM, can induce a bias in the dynamics along the SM (see \fref{fig_streamplots}(b)). This is the origin of the stochastic selection reversal that we will explore. In order to capture this behavior while simultaneously removing the fast timescales in the stochastic system, we map all fluctuations off the SM along deterministic trajectories back to the SM~\cite{parsons_rogers_2015}. This essentially assumes that any noisy event that takes the system off the SM is instantaneously projected back to another point on the SM. For clarity, we briefly describe the dynamics when $\varepsilon=0$. In this case the birth rates of phenotypes $X$ and $Y$ are identical. Instead of the two non-zero fixed points, $K_{x}$ and $K_{y}$, found above, the deterministic system now has a line of fixed points, referred to as a center manifold (CM)~\cite{arnold_2003}. The CM is identical to the SM in the limit $\varepsilon\rightarrow0$. It is given by \begin{equation} y = \frac{ K_{y}^{(0)} }{ K_{x}^{(0)} } \left( K_{x}^{(0)} - x \right) \,, \quad q = \frac{ p_{x} }{ \delta } x \,, \label{eq_CM} \end{equation} and shown graphically in \fref{fig_streamplots}(b). The separation of timescales in the system is now at its most pronounced, since there are strictly no deterministic dynamics along the CM following the fast transient to the CM. However the stochastic system still features dynamics along the CM. Applying the procedure outlined in \cite{parsons_rogers_2015} we arrive at a description of the stochastic dynamics in a single variable, the frequency of producers along the CM; \begin{equation} \dot{x} = \frac{ b }{ R^{2} } x \left( 1 - \frac{ x }{ K_{x}^{(0)} } \right) \,\mathcal{F}(x) + \frac{1}{R} \zeta(t) \,, \label{eq_reduced_PG_SDE_neutral} \end{equation} where \begin{equation} \mathcal{F}(x) = 2 \left( \frac{ K_{x}^{(0)} - K_{y}^{(0)} }{ (K_{x}^{(0)}K_{y}^{(0)})^{2} } \right) \left[ K_{x}^{(0)} K_{y}^{(0)} + \left( K_{x}^{(0)} - K_{y}^{(0)} \right) x \right] \,. \nonumber \end{equation} Here $\zeta(t)$ is a Gaussian white noise term with a correlation structure given in \eref{eq:supmat_eq_PG_clean_Bbar}. Together with \eref{eq_CM}, \eref{eq_reduced_PG_SDE_neutral} approximates the dynamics of the entire system. Note that while \eref{eq_reduced_PG_SDE_neutral} predicts a noise-induced directional drift along the CM (controlled by $\mathcal{F}(x)$), a deterministic analysis predicts no dynamics, since the CM is by definition a line of fixed points. This directional drift along the CM results from the projection bias illustrated in \fref{fig_streamplots}(b). If $p_{x}>0$, then $K_{x}^{(0)}>K_{y}^{(0)}$, and so $\mathcal{F}(x) > 0 $; thus the public good production by phenotype $X$ induces a selective pressure that selects for $X$ along the center manifold. The origin of the term $\mathcal{F}(x)$ in \eref{eq_reduced_PG_SDE_neutral} can be understood more fully by exploring its implications for the invasion probabilities of $X$ and $Y$, denoted $\phi_{x}$ and $\phi_{y}$. These can be straightforwardly calculated since the system is one-dimensional (see \Aref{sec:supmat_sec_fixprob}). We find \begin{equation} \phi_{x} = \frac{1}{N_{y}} \,, \qquad \textrm{and} \qquad \phi_{y} = \frac{1}{N_{x}} \,, \label{eq_phi_quasineutral} \end{equation} where $\phi_{x}>\phi_{y}$ so long as $p_{x} > 0$ (see \eref{eq_carrying_capacity}). The term $\mathcal{F}(x)$ can thus be interpreted as resulting from the stochastic advantage the producers have at the population level from reaching higher carrying capacities in isolation, which makes them more stochastically robust to invasion attempts. This result is independent of the spatial scale $R$ (and therefore population size) so long as $R$ is finite. If $\varepsilon \neq 0 $, the system does not collapse to the CM, but rather to the SM. At leading order in $\varepsilon$, the equation for the SM is given by \eref{eq_CM}. Upon removing the fast dynamics, the effective dynamics of $x$ can now be shown to take the form (see \eref{eq:supmat_eq_PG_maintext_effective}) \begin{equation} \dot{x} = b x \left( 1 - \frac{x}{K_{x}^{(0)}} \right) \left( \frac{ 1 }{ R^{2} } \,\mathcal{F}(x) - \varepsilon \right) + \frac{1}{R} \zeta(t) \,, \label{eq_reduced_PG_SDE} \end{equation} where $\zeta(t)$ and $\mathcal{F}(x)$ are the same as in \eref{eq_reduced_PG_SDE_neutral}. The SDE now consists of two components. The deterministic contribution, governed by $\varepsilon$, exerts a selective pressure against phenotype $X$, due to its reduced birth rate. The stochastic term, $\mathcal{F}(x)$ exerts a pressure in favor of phenotype $X$, resulting, as in the case $\varepsilon = 0$ discussed above, from the producers’ stochastic robustness to invasions. \begin{figure}[t] \setlength{\abovecaptionskip}{-2pt plus 3pt minus 2pt} \begin{center} \includegraphics[width=0.5\textwidth]{fig2.pdf} \end{center} \caption{Stochasticity can render non-producers more susceptible to invasion by producers than vice versa. Plots of the difference in invasion probabilities between producers $X$ and non-producers $Y$ as a function of the cost to birth for production, $\varepsilon$, and good production rate $p_{x}$. The remaining parameters are taken from \tref{tab:supmat_fig_parameter_list_1}. Left: analytic results for a single small patch (see \eref{eq_eps_condition}). The critical cost $\varepsilon$ for selection reversal, \eref{eq_eps_condition}, is shown here as the black dashed line. Right; results from Gillespie simulations~\cite{gillespie_1976} of the stochastic process \eref{eq_reactions_1}, averaged over $2000$ runs.}\label{fig_trade_off} \end{figure} Thus, when $\varepsilon > 0$, a trade-off emerges in the stochastic system between the stochastic advantage to public good production (due to increased population sizes) and the deterministic cost producers pay (in terms of birth rates). If the birth costs are not too high, producers will be selected for, which constitutes a reversal in the direction of selection from the deterministic prediction. Specifically, we can calculate the condition on the metabolic cost that ensures that the producers are fitter than the non-producers (i.e. $\phi_{x}>\phi_{y}$): \begin{equation} \varepsilon < \frac{\kappa}{ b R^{2} } \log \left[ \frac{\delta \kappa }{ \delta \kappa - p_{x} r } \right] \,. \label{eq_eps_condition} \end{equation} Whereas for no metabolic cost producers consistently have a stochastic advantage regardless of typical population size (see \eref{eq_phi_quasineutral}), for non-zero production costs, the population must be sufficiently small that stochastic effects, governed by $R^{-2}$, are dominant. \fref{fig_trade_off} shows that the theory predicts well the trade-off in the underlying stochastic model (\ref{eq_reactions_1}). We have shown that stochastic selection reversal is more prevalent when $R$ is not large. Meanwhile our analytic results results have been obtained under the assumption that $R$ is large, which allowed us to utilize the diffusion approximation leading to \eref{eq_PG_SDE} and aided the timescale elimination procedure that yielded \eref{eq_reduced_PG_SDE}. We therefore expect that although stochastic selection reversal will become more prominent as $R$ is reduced, the quality of our analytic predictions may suffer. Despite this caveat, it is the small $R$ regime that is interesting to us. Small values of $R$ are associated with small population sizes. While it is conceivable that populations of macro-organisms may consist of a small number of individuals, this limit is not so pertinent to the study of micro-organisms. In the next section however, we will show that by incorporating space, the constraint of small population size can be relaxed. \section{Spatial amplification} In this section we consider a metapopulation on a grid: each subpopulation (patch) has a small size so that demographic noise continues to be relevant locally, but the number of subpopulations is large so that the overall population in the system is large. This method of incorporating demographic stochasticity into spatial systems has proved to be successful in the modeling of microbial populations~\cite{hallatschek_2007}. We consider a grid of $C$ patches. The dynamics within each patch are given by the transitions in \eref{eq_reactions_1}, and coupled to the surrounding patches by the movement of the phenotypes and public good. A patch will produce migrants at a rate proportional to its density. Producers $X$ and non-producers $Y$ disperse with a probability rate $m$ to a surrounding region, while the public good diffuses into neighboring regions at a rate $D$. Once again the diffusion approximation can be applied to obtain a set of SDEs approximating the system dynamics; \begin{eqnarray} \frac{\mathrm{d}x_{ij}}{\mathrm{d}\tau} &=& x_{ij} \left( b_{x} + r q_{ij} - \kappa ( x_{ij} + y_{ij} ) \right) + m \left( L \bm{x} \right)_{ij} + \frac{ \eta_{xij}(t) }{ R } \, , \nonumber \\ \frac{\mathrm{d}y_{ij}}{\mathrm{d}\tau} &=& y_{ij} \left( b_{y} + r q_{ij} - \kappa ( x_{ij} + y_{ij} ) \right) + m \left( L \bm{y} \right)_{ij} + \frac{ \eta_{yij}(t) }{ R }\, , \nonumber \\ \frac{\mathrm{d}q_{ij}}{\mathrm{d}\tau} &=& p_{x} x_{ij} - \delta q + D \left( L \bm{q} \right)_{ij} + \frac{ \eta_{qij}(t) }{ R } \,, \label{eq_spatial_ODEs} \end{eqnarray} where $ij$ is the patch on row $i$ and column $j$. The operator $L$ is the discrete Laplacian operator $(L\bm{x})_{ij} = - 4 x_{ij} + x_{(i-1)j} + x_{(i+1)j} + x_{i(j-1)} + x_{i(j+1)} $. If $b_{y}>b_{x}$, the deterministic dynamics predict that the producers will always go extinct. \begin{figure}[t] \setlength{\abovecaptionskip}{-2pt plus 3pt minus 2pt} \begin{center} \includegraphics[width=0.5\textwidth]{fig3.pdf} \end{center} \caption{Left panel: analytic results show that space amplifies stochastic selection reversal in the low dispersal, zero diffusion limit. The critical maximum cost $\varepsilon$ for selection reversal (see \eref{eq_eps_crit_space}) is plotted as black dashed line. Right panel: simulation results are shown for varied $m$ and $D$, averaged over $2000$ runs. Panel (a) gives results which in the low dispersal, zero diffusion limit ($m=3.7\times10^{-8}$, $D=0$), which match our theoretical predictions. Panel (b) gives the result with a set of biologically plausible parameters ($m=3.7\times10^{-7}$ and $D=2.2\times10^{-5}$ derived in \tref{tab:supmat_fig_parameter_list_1}). Panel (c) gives results in a system with high dispersal ($m=3.7\times10^{-5}$, $D=2.2\times10^{-5}$), while panel (d) shows the case of a system with high diffusion ($m=3.7\times10^{-7}$ and $D=2.2\times10^{-3}$). The number of patches is given by $C=16$ and the remaining parameters are listed in \tref{tab:supmat_fig_parameter_list_1}.}\label{fig_trade_off_16_islands} \end{figure} First we will discuss some important limit case behavior for this system. In the limit of large dispersal rate $m$ and diffusion rate $D$, the stochastic system behaves like a well-mixed population with a spatial scale $cR^{2}$ (i.e. the spatial structure is lost). In this case, as the size of the spatial system is increased, the effective population size also increases, and as a consequence selection reversal for producing phenotypes becomes less likely (see \eref{eq_eps_condition}). We next consider the low-dispersal, zero diffusion limit. For sufficiently low dispersal, any incoming mutant will first either fixate or go to extinction locally before any further dispersal event occurs. Since each dispersal/invasion/extinction event resolves quickly, at the population level, the system behaves like a Moran process on a graph~\cite{nowak_2006}, with each node representing a patch. The `fitness' of a patch is the probability that it produces a migrant, and that that migrant successfully invades a homogeneous patch of the opposite type, following the approach used in \cite{houch_2012}. Denoting the `fitness' of producing and non-producing patches by $W_{x}$ and $W_{y}$ respectively, we have \begin{equation} W_{x} = m N_{x} \phi_{x} \,, \qquad W_{y} = m N_{y} \phi_{y} \,, \label{eq_patch_fitness} \end{equation} where $N_{i}$ ($i = x,y$) is the mean carrying capacity of phenotype $i$ in a homogeneous patch, and $\phi_{i}$ are the invasion probabilities of a type $i$ mutant in a type $j\neq i$ patch. The fixation probabilities of a homogeneous patch in a population of the opposite phenotype can now be calculated using standard results~\cite{nowak_2006}. Let $\rho_{i}$ ($i = x,y$) denote the probability that type $i$ takes over the metapopulation when starting from one patch of type $i$ in a population otherwise comprised entirely of patches of the opposite phenotype. Then \begin{equation} \rho_{i} = \frac{1 - r_{i}^{-1} }{ 1 - r_{i}^{-C} } \,, \quad \textrm{for} \quad i = x,y \quad \textrm{and} \quad r_{x} = \frac{W_{x}}{W_{y}} \,, \quad r_{y} = \frac{W_{y}}{W_{x}} \,. \label{eq_regular_graph_fix} \end{equation} If we start from a single invading mutant, the probability that it takes over the entire population (i.e. invasion probability) is the product between the probability that it takes over its home patch $\phi_{i}$, and the probability that the newly invaded home patch fixates into the metapopulation, $\rho_{i}$: \begin{eqnarray} \Pi_{x} = \phi_{x} \rho_{x} \,, \quad \Pi_{y} = \phi_{y} \rho_{y} \,. \label{eq_pi} \end{eqnarray} In the infinite patch limit ($C\rightarrow\infty$), $\rho_{x}$ and $\rho_{y}$ depend on $r_{x}$, the patch fitness ratio defined in \eref{eq_regular_graph_fix}. If $r_{x}>1$, $\rho_{x}\rightarrow1-r_{x}^{-1}$ and $\rho_{y}\rightarrow0$, whereas if $r_{x}<1$ the converse is true. This means that, in the infinite patch, low dispersal, zero diffusion limit, the condition for the stochastic reversal of selection is weakened from $\phi_{x} > \phi_{y}$ to \begin{eqnarray} N_{x} \phi_{x} > N_{y} \phi_{y} \,. \label{eq_weakening_threshold} \end{eqnarray} Spatial structure therefore has the ability to enhance the stochastic reversal observed in the small well-mixed system. An approximate analytic form for the above condition can be obtained in terms of the original parameters; \begin{equation} \varepsilon < 2 \frac{ \kappa }{ b R^{2} } \log \left[ \frac{\delta \kappa }{ \delta \kappa - p_{x} r } \right] \,. \label{eq_eps_crit_space} \end{equation} Once again, our analytical results are well supported by simulations (see \fref{fig_trade_off_16_islands}). The critical production rate for the invasion probability of producers to exceed that of non-producers has been decreased, as predicted by Eqs.~(\ref{eq_eps_condition}) and (\ref{eq_eps_crit_space}). Producers can therefore withstand higher production costs in spatially structured environments. It is important to note that while \eref{eq_weakening_threshold} depends on the mean number of producers and non-producers on a homogeneous patch ($N_x$ and $N_y$), it is independent of the number of individuals in the entire metapopulation in the large $C$ limit. The interaction between these two spatial scales leads to results that can appear counter-intuitive. Demographic noise, as we have discussed, leads to producing patches being `more fit' at the patch level (see \eref{eq_patch_fitness}). However, when a large number of patches is considered, the demographic noise at the metapopulation level is reduced. This leads to the system following trajectories that appear deterministic at the level of the metapopulation, even though the path they follow is entirely the result of demographic stochasticity at the within-patch level (see \fref{fig_10000_islands}). The movie S1 (see \Aref{sec:supmat_sec_movies}) displays the individual dynamics of the patches that comprise the trajectory illustrated in \fref{fig_10000_islands}. \begin{figure}[t] \setlength{\abovecaptionskip}{-2pt plus 3pt minus 2pt} \begin{center} \includegraphics[width=0.5\textwidth]{fig4.pdf} \end{center} \caption{Demographic stochasticity at the local `patch' scale profoundly alters the system dynamics at the population level. Results are obtained from stochastic and deterministic ($R\rightarrow \infty $) simulations of \eref{eq_spatial_ODEs} with a grid of $C=100\times100$ patches, $p_{x}=1\times10^{-4}$, $\varepsilon=0.02$, $m=3.7\times10^{-5}$ and the remaining parameters taken from \tref{tab:supmat_fig_parameter_list_1}. Initial conditions are a single producer and non-producer on each patch. The initial (fast) transient collapse to the SM occurs occurs in the shaded gray region. Following this, the deterministic system slowly moves along the slow manifold until the non-producers fixate, whereas in the stochastic system, the producers experience a selective pressure in their favor. For dynamics at the patch level, see Supplementary Information movie S1.}\label{fig_10000_islands} \end{figure} Away from the small dispersal, zero diffusion limit, the dramatic selection reversal predicted by the analytical results is clearly weakened (see \fref{fig_trade_off_16_islands}). Though selection reversal is still found across a range of $m$ and $D$ values, if either dispersal or diffusion are too high, the selection reversal breaks down. It is therefore important to understand what order of magnitude estimates for the values of $m$ and $D$ may be biologically reasonable. \subsection{Insights from \fontsize{10}{11}{\textit{S.\,cerevisiae}}} In the following section, we will attempt to contextualize our model with reference to a \textit{S. cerevisiae} yeast system, which has been previously identified as a biological example of a population that features public good producers and non-producers. The model we have presented is general and therefore it could not capture the full biological detail of this particular system. For instance, it has been noted that some degree of privatization of the public good occurs in even the well-mixed experimental system~\cite{gore_2009}, a behavior we do not consider in our model. However, setting our model in this context can provide some insight into the scenarios in which we might expect stochastic selection reversal to be a biologically relevant phenomenon. An \textit{S.\,cerevisiae} yeast cell metabolizes simple sugars, such as glucose, in order to function. However, when simple sugars are scarce, the yeast can produce invertase, an enzyme that breaks down complex sugars, such as sucrose, to release glucose~\cite{maclean_2010}. Invertase is produced at a metabolic cost and, since digestion of sucrose occurs extracellularly, most of the benefits of its production are shared by the population. Specifically in the case of S.~cerevisiae, $SUC2$, the wild-type strain, produces invertase, while the lab cultured mutant $suc2$ does not~\cite{maclean_2008}. In terms of our model parameters, the baseline birth rates, $b_{x}$ and $b_{y}$, represent respectively $SUC2$ and $suc2$ reproduction in the absence of invertase. This could be understood as arising from yeast directly metabolizing sucrose (a less energetically beneficial metabolic route~\cite{maclean_2010}) or as the result of some extrinsically imposed low glucose concentration in the system. The rate $r$ would then represent the additional birth rate in the presence of invertase. The form of our specified reactions (see \eref{eq_reactions_1}), assumes that the presence of invertase leads directly to a yeast reproduction event. In reality invertase must break down the sucrose into glucose, and then slowly absorb the glucose. We are therefore essentially assuming that the sucrose is abundant, its breakdown by invertase instantaneous, and the glucose absorption rapid and occurring in discrete packets, with each packet absorbed leading to a reproduction event. In the well-mixed system, our analytic predictions indicate that stochastic selection reversal can occur only if the population is very small. Since this is an unrealistic assumption in the case of yeast cultures, we would predict that non-producers should come to dominate a well-mixed population. In a spatially structured population however, this constraint is relaxed since it only requires small interaction regions. For \textit{S.\,cerevisiae}, we can obtain order of magnitude estimates for the majority of parameters in our model, including public good diffusion (see \Aref{sec:supmat_sec_params}). Using these estimates together with our analytic results for the spatial public goods system, we find that stochastic selection reversal could feasibly be an important phenomenon for promoting the evolution of microbial public goods production in spatial settings (see \fref{fig_trade_off_16_islands}, Panel b). Given this, we now consider the results of a spatial experiment on \textit{S. cerevisiae}, and ask how its results might be interpreted in light of the insights developed with our simple model. \begin{figure}[t] \setlength{\abovecaptionskip}{-2pt plus 3pt minus 2pt} \begin{center} \includegraphics[width=0.5\textwidth]{fig5.pdf} \end{center} \caption{Plots of the pairwise invariability scenarios possible for non-producing, producing and hyper-producing phenotypes. Arrows point away from the dominant phenotype in a pair, which is defined as that with a larger invasion probability (Fig. S3). Non-transitive dynamics are not possible. It is possible however for an optimal intermediate good production rate to emerge (cyan and blue regions), if $a_{p}<a_{b}$. In this scenario the hyper-producer receives diminishing good production as a function of cost to birth rate compared to the producer. Left panels, $a_{b}=1.3$ and $a_{p}=1.5$. Right panels, $a_{b}=3$ and $a_{p}=1.5$. Remaining parameters given in \tref{tab:supmat_fig_parameter_list_1}. }\label{fig_pairwise_invade} \end{figure} In \cite{maclean_2008}, $SUC2$ and $suc2$ were experimentally competed on an agar plate. It was found that non-producing $suc2$ could not invade from rare ($1\%$ of initial yeast population), and in fact decreased in frequency, becoming undetectable at long times (around 800 generations). This suggests that in a spatial setting, invertase producing $SUC2$ yeast are robust to invasions, which is in qualitative agreement with our theoretical predictions. The experiments yielded an additional result, the appearance of a hyper-producing mutant. This hyper-producing phenotype produced invertase at approximately $1.5$ times the rate of standard producers and existed at higher densities. The hyper-producer appeared to evolve naturally and establish robust colonies during the competition experiments between non-producers and producers. However, when separate competition experiments were conducted between the hyper-producers and the producers, the hyper-producers failed to demonstrate any appreciable fitness advantage over the producers. This potentially suggests an optimal invertase production rate, whereby the hyper-producers managed to establish and grow during the $SUC2$-$suc2$ competition experiments by exploiting non-producing regions due to a relative fitness advantage, but could not invade regions of space occupied by producers. Interestingly, our model also predicts that an intermediate optimal production rate may exist, depending on how the cost of production scales with the production rate. Suppose a hyper-producer, $U$, produces at a rate $p_{u}=a_{p}p_{x}$, paying a metabolic cost $a_{b}\varepsilon$ to its birth rate, such that $b_{u}=b(1-a_{b}\varepsilon)$. The pairwise invasion probabilities of each phenotype can then be calculated (see Supplementary Information, \ignore{\sref{Ssec:supMat_sec_pairwise}}Section\,S.4). We define the fitter phenotype in a pair as that with the larger invasion probability. The potential fitness rankings are investigated in \fref{fig_pairwise_invade} as a function of $p_{x}$ and $\varepsilon$, (which we recall also alter $p_{u}$ and $b_{u}$). We draw particular attention to the right panels, in which $a_{b}>a_{p}$. In this scenario, the hyper-producers pay a disproportionate cost for their increased production rate compared to the producers. This can be interpreted as diminishing returns for production. In this case, there exist regions where the producer is the optimal phenotype (regions (a) and (b), in blue and cyan respectively). Specifically, scenario (a) displays a similar behavior to that observed in \cite{maclean_2008}, in which producers win out over both non-producers and hyper-producers, but hyper-producers are more likely to invade non-producing populations. \section{Generality of results} We have shown that demographic stochasticity can reverse the direction of selection in a public good model. In this section we will show that the mechanism responsible for this phenomenon is by no means particular to this model. We consider a general scenario, with a phenotype $X_{1}$, which is at the focus of our study, and a number of discrete ecosystem constituents, $E_{i}$. In the public good model for instance, we would label the public good itself as an ecosystem constituent, however more generally this could be a food source, a predator or anything else that interacts with the phenotypes. The state of the ecosystem influences the birth and death of the phenotype and in turn the presence of the phenotype influences the state of the ecosystem, altering the abundances of the constituents. We assume that the system lies at a unique, stable stationary state, precluding the possibility of periodic behavior. Suppose that a new phenotype, $X_{2}$, arises. We assume that the second phenotype is only slightly better at exploiting the ecosystem than $X_{1}$, though its influence on the ecosystem may be very different. For instance, in the public goods model, non-producers have a small birth-rate advantage over producers, but do not produce the public good. Which phenotype is more likely to invade and fixate in a resident population of the opposite type? The stochastic model for this system can be constructed in a similar manner to the public good model; the dynamics are described by a set of probability transition rates (analogous to \eref{eq_reactions_1}). We restrict the transitions by specifying that although the two phenotypes compete, there is no reaction that instantaneously changes both of their numbers in the population. This final condition simply means that they should not, for instance, be able to mutate from one type to another during their lifetime, or to prey on each other. A parameter $R$ is introduced, to once again govern the typical scale of the system. The model is analyzed in the mesoscopic limit, by introducing $(x_{1},x_{2},\bm{e}) = (n_{x1},n_{x2},\bm{n}_{e})/R^{2}$ and applying the diffusion approximation. For large but finite $R$, the mesoscopic description takes the form \begin{eqnarray} \dot{ x_{1} } &=& x_{1} F^{(0)}(\bm{x},\bm{e}) - \varepsilon x_{1} F^{(\varepsilon)}(\bm{x},\bm{e}) + R^{-1}\eta_{1}(t) \, , \nonumber \\ \dot{ x_{2} } &=& x_{2} F^{(0)}(\bm{x},\bm{e}) + R^{-1} \eta_{2}(t) \, , \label{eq_general_SDEs} \\ \dot{ e_{i} } &=& F_{i}(\bm{x},\bm{e}) + R^{-1} \beta_{i}(t) \,, \quad \forall \, i = 3 , \ldots J \,, \nonumber \end{eqnarray} where $\varepsilon$ is small and governs selective pressure against $X_{1}$. The assumption that there is no reaction that instantaneously changes the number of both phenotypes ensures that the correlation structure of the noise terms takes the form \begin{eqnarray} & \langle \eta_{1}(t) \eta_{1}(t') \rangle = \delta(t-t') x_{1} H^{(0)}(\bm{x},\bm{e}) \,,& \nonumber \\ & \langle \eta_{2}(t) \eta_{2}(t') \rangle = \delta(t-t') x_{2} H^{(0)}(\bm{x},\bm{e}) \,,& \quad \langle \eta_{1}(t) \eta_{2}(t') \rangle = 0 \nonumber \,, \end{eqnarray} with $\varepsilon$ taken to be of order $R^{-2}$. This assumption, made here to isolate the effect of varying carrying capacity from any other intraspecies dynamics, means that while the magnitude of fluctuations in the number of both phenotypes is dependent on the state of the system, $(\bm{x},\bm{e})$, the fluctuations themselves are not correlated with each other. Restrictions on the microscopic model that yield the above SDE description are addressed more thoroughly in \Aref{sec:supmat_sec_general_results}. The form of \eref{eq_general_SDEs} makes the nature of the system we describe more clear; it consists of two competing phenotypes, which reproduce according to replicator dynamics~\cite{hofbauer_1998} with equal fitness at leading order in $\varepsilon$. In the special case $\varepsilon=0$, both phenotypes are equally fit, regardless of their influence on the ecosystem variables $e_{i}$. The degeneracy of the dynamics in $x_{1}$ and $x_{2}$ ensures the existence of a deterministic CM. We assume that the structure of $F^{(0)}(\bm{x})$ and $F_{i}(\bm{x})$ is such that the CM is one-dimensional (there are no further degenerate ecosystem variables) and that it is the only stable state in the interior region $x_{i}>0$. A separation of timescales is present if the system collapses to the CM much faster than the stochastic dynamics. In practical terms, the timescale of collapse can be inferred as the inverse of the non-zero eigenvalues of the system, linearised about the CM~\cite{constable_2013}, while the timescale of fluctuations will be of order $R^{-2}$~\cite{constable_2014_phys}. When $\varepsilon>0$, the timescale elimination procedure can still be applied if $\varepsilon\approx\mathcal{O}\left( R^{-2} \right)$ . The effective one-dimensional description of the system now takes the form \begin{equation} \dot{x_{1}} = - \varepsilon \, \mathcal{D}(x_{1}) + R^{-2} \,\mathcal{S}(x_{1}) + R^{-1} \zeta(t) \,, \label{eq_general_reduced_PG_SDE} \end{equation} where the term $ \mathcal{D}(x_{1})$ is the deterministic contribution to the effective dynamics and $\mathcal{S}(x_{1})$ is the stochastic contribution, while $\zeta(t)$ is an effective noise term. The form these functions take is dependent on $F^{(0)}(\bm{x},\bm{e})$, $F^{(\varepsilon)}(\bm{x},\bm{e})$ and $F_{i}(\bm{x},\bm{e})$, as well as the noise correlation structure, $H^{(0)}(\bm{x},\bm{e})$; however it is independent of the structure of the demographic noise acting on the ecosystem variables (see Eqs.\,(\ref{eq:supmat_eq_general_Abar_det}), (\ref{eq:supmat_eq_Abar_stoch_2}) and (\ref{eq:supmat_eq_general_Bbar})). The core assumption we have made to derive \eref{eq_general_reduced_PG_SDE} is essentially that the system's ecological processes act on a faster timescale than its evolutionary processes. Even in this general setting, insights about the system's stochastic dynamics can still be drawn (see \Aref{sec:supmat_sec_general_results}). If $\varepsilon=0$, the fixation probability of phenotype $X_{1}$ is independent of the initial conditions of the ecosystem variables $\bm{e}$. In fact it is equal to the initial fraction of $X_{1}$ in the population, $ n_{10} / (n_{10} + n_{20} )$. The invasion probability of mutant $X_{1}$ phenotype fixating in a resident $X_{2}$ population however depends on the stationary state of the $X_{2}$ population; this defines the initial invasion conditions (the denominator for the fixation probability of $X_{1}$). Denoting by $N_{1}$ and $N_{2}$ the average numbers of phenotypes $X_{1}$ and $X_{2}$ in their respective stationary states, we find $\phi_{1} = 1/N_{2}$ and $\phi_{2} = 1/N_{1}$, generalizing \eref{eq_phi_quasineutral}. Therefore, for $\varepsilon=0$ the phenotype that exists at higher densities is more likely to invade and fixate than its competitor, a consequence of its robustness to invasions. This result holds for any choice of finite $R$. In an ensemble of disconnected populations subject to repeated invasions, we would observe the emergence of high density phenotypes if this phenotype does not carry a cost. While this seems like a reasonable and indeed natural conclusion, it is one entirely absent from the deterministic analysis. If $\varepsilon>0$, general results for the phenotype fixation probabilities cannot be obtained. However, if $N_{1}>N_{2}$, in the limit $\varepsilon\rightarrow0$ we have shown that $\phi_{1}>\phi_{2}$. From this, it can be inferred that the term $\mathcal{S}(x_{1})$ is positive on average along the slow manifold (see \eref{eq:supmat_integral_S}). Therefore, if phenotype $X_{1}$ exists at higher densities in isolation than phenotype $X_{2}$, there will exist a stochastically-induced pressure favoring the invasion of phenotype $X_{1}$. Meanwhile, by construction we expect the form of $\mathcal{D}(x_{1})$ to be positive, since phenotype $X_{1}$ exploits the ecosystem environment less effectively than phenotype $X_{2}$. There is therefore a trade-off for competing phenotypes between increasing their phenotype population density and increasing their per capita growth rate. Note that the noise-induced selection function $\mathcal{S}(x_{1})$ need not be strictly positive; indeed it may become negative along regions of the SM. This potentially allows for stochastically induced `fixed points' along the SM, around which the system might remain for unusually large periods of time. This may provide a theoretical understanding of the coexistence behavior observed in~\cite{behar_2015}. The term $\mathcal{S}(x_{1})$ is moderated by factor $R^{-2}$ (see \eref{eq_reduced_PG_SDE}), or more physically, the typical size of the population. The stochastically induced selection for the high-density phenotype therefore becomes weaker as typical system sizes increase. The trade-off will be most crucial in small populations, or as illustrated in the public good model, systems with a spatial component. If the phenotypes and ecosystem variables move sufficiently slowly in space, the results of Eqs.~(\ref{eq_pi}) and (\ref{eq_weakening_threshold}) can be imported, with the understanding that $\phi_{1}$ and $\phi_{2}$ must be calculated for the new model under consideration. It is worth noting that the precise functional form of $\phi_{1}$ and $\phi_{2}$ identified in the deterministically neutral case ($\varepsilon=0$) is dependent on the assumption that phenotype noise fluctuations are uncorrelated. While correlated fluctuations (for instance resulting from mutual predation of the phenotypes) can still be addressed with similar methods to those employed here, there is then the potential for the emergence of further noise-induced selection terms (see \Aref{sec:supmat_sec_comp_models}). Careful specification of the phenotype interaction terms is therefore needed to determine to what degree these additional processes might amplify or dampen the induced selection we have identified. \section{Discussion} In this paper, we have shown that stochastic effects can profoundly alter the dynamics of systems of phenotypes that change the carrying capacity of the total population. Most strikingly, selection can act in the opposite direction from that of the deterministic prediction if the phenotype that is deterministically selected for also reduces the carrying capacity of the population. The methods used to analyze the models outlined in the paper are based on the removal of fast degrees of freedom~\cite{parsons_rogers_2015}. The conclusions drawn are therefore expected to remain valid as long as the rate of change of the phenotype population composition occurs on a shorter timescale than the remaining ecological processes. By illustrating this phenomenon in the context of public good production, we have revealed a mechanism by which the dilemma of cooperation can be averted in a very natural way: by removing the unrealistic assumptions of fixed population size inherent in Moran-type game theoretic models. The potential for such behavior has been previously illustrated with the aid of a modified Moran model~\cite{houch_2012} and a single variable Wright-Fisher type model~\cite{houch_2014} that assumes discrete generations. However we have shown that the mechanism can manifest more generally in multivariate continuous time systems. Our analysis may also provide a mathematical insight into the related phenomenon of fluctuation-induced coexistence that has been observed in simulations of a similar public good model featuring exogenous additive noise~\cite{behar_2015}: such coexistence may rely on a similar conflict between noise-induced selection for producing phenotypes and deterministic selection against them. For biologically reasonable public good production costs, selection reversal is only observed in systems that consist of a very small number of individuals. However, by building a metapopulation analogue of the model to account for spatial structure, the range of parameters over which selection reversal is observed can be dramatically increased, so long as public good diffusion and phenotype dispersal between populations are not large. Two distinct mechanisms are responsible for these results. First, including spatial structure allows for small, local effective population sizes, even as the total size of the population increases. This facilitates the stochastic effects that lead to selection reversal. Second, since producer populations tend to exist at greater numbers (or higher local densities) they produce more migrants. The stochastic advantage received by producers is thus amplified, as not only are they more robust stochastically to invasions, but also more likely to produce invaders. Away from the low-dispersal, zero public good diffusion limit, the effect of selection reversal is diminished, but is still present across a range of biologically reasonable parameters. The analytical framework we have outlined may prove insightful for understanding the simulation results observed in \cite{behar_2014}, where a similar metapopulation public good model was considered. In addition to fixation of producers (in the low dispersal-diffusion limit) and fixation of non-producers (in the high dispersal-diffusion limit), \cite{behar_2014} observed an intermediate parameter range in which noise induced coexistence was possible. Though our model does not feature such a regime, extending our mathematical analysis to their model would be an interesting area for future investigations. However it must be noted that coexistence in a stochastic setting is inherently difficult to quantify analytically, as for infinite times some phenotype will always go extinct. That space can aid the maintenance of cooperation is well known~\cite{tarnita_review_2009,wakano_2011}. Generally, however, this is a result of spatial correlations between related phenotypes, so that cooperators are likely to be born neighboring other cooperators (and share the benefits of cooperation) while defectors can only extract benefits at the perimeter of a cooperating cluster. This is not what occurs in the model presented in this paper. Indeed, while we have assumed in our analytic derivation of the invasion probability that dispersal is small enough that each patch essentially contains a single phenotype, we find that the phenomenon of selection reversal manifests outside this limit (see \Aref{sec:supmat_sec_movies}, movie S2 in which a majority of patches contain a mix of producers and non-producers). Instead, producing phenotypes have a selective advantage due to the correlation between the fraction of producers on a patch and the total number of individuals on a patch, which provides both resistance to invasions and an increased dispersal rate. Most commonly in spatial game theoretic models of cooperation-defection, individuals are placed at discrete locations on a graph~\cite{nowak_1992,allen_2013}. In contrast, by using a metapopulation modelling framework we have been able to capture the effect of local variations in phenotype densities across space, which is the driver of selection amplification in our model. Nevertheless, the question that remains is which modelling methodology is more biologically reasonable. This clearly depends on the biological situation. However, in terms of test-ability, our model makes certain distinct predictions. In~\cite{allen_2013}, producers and non-producers were modeled as residing on nodes of a spatial network, with a public good diffusing between them. The investigation concludes that both lower public good diffusion and lower spatial dimensions (e.g. systems on a surface rather than in a volume) should encourage public good production, essentially by limiting the `surface area' of producing clusters. While our investigation certainly predicts that lower public good diffusion is preferable, stochastic selection reversal does not require that the spatial dimension of the system is low. In fact the result utilized in \eref{eq_regular_graph_fix} holds for patches arranged on any regular graph (where each vertex has the same number of neighbors), and thus could be used to describe patches arranged on a cubic, or even hexagonal, lattice. In our final investigation, we have shown that stochastic selection reversal is not an artifact of a specific model choice, but may be expected across a wide range of models. These models consist of two phenotypes, competing under weak deterministic selection strength, reproducing according to replicator dynamics and interacting with their environment. Thus the phenomenon of selection reversal is very general; however, it depends strongly on how one specifies a selective gradient. We take one phenotype to have a stochastic selective advantage over the other if a single mutant is more likely to invade a resident population of the opposite type. Such a definition is also used in standard stochastic game theoretic models~\cite{nowak_2006}. A key difference here however (where the population size is not fixed) is that the invasion probability is not specified by a unique initial condition; we must also specify the size of the resident population. We have assumed that the invading mutant encounters a resident population in its stationary state. This is by no means an unusual assumption; it is the natural analogue of the initial conditions in a fixed population size model. Essentially it assumes a very large time between invasion or mutation events, an approach often taken in adaptive dynamics~\cite{waxman_2005}. If instead we assumed a well-mixed system far from the steady state, our results would differ. For instance, suppose the system initially contains equal numbers of the two phenotypes. For the case when the two phenotypes have equal reproductive rates ($\varepsilon=0$), the phenotypes have equal fixation probability. For $\varepsilon>0$, the phenotype with the higher birth rate has the larger fixation probability, regardless of its influence on the system's carrying capacity. This apparent contradiction with the results we developed in the body of the paper echos the observations of $r-K$ selection theory~\cite{pianka_1970}: selection for higher birth rates ($r$-selection) acts on frequently disturbed systems that lie far from equilibrium, while selection for improved competitive interactions or carrying capacities ($K$-selection) acts on rarely disturbed systems. In addition, $r-K$ selection theory suggests that $K$-selected species are typically larger in size and, as a consequence, consist of a lower number of individuals~\cite{reznick_2002}. This indicates a further parallel with our stochastic model framework, since selection for higher carrying capacities requires that the typical number of individuals (of both the low and high carrying capacity phenotypes) is small. Though the mechanism that leads us to these conclusions is distinct, our stochastic analysis provides a complementary view of $r-K$-selection theory, which may be applicable to simple microorganisms. In exploring this analogous behavior further, future investigations may also benefit from considering the results of~\cite{parsons_quince_2010}, where it was shown that stochastically induced selection can change direction near carrying capacity. Although we have implicitly developed our results in the low mutation limit, including mutation explicitly in the modeling framework is possible. This would be an interesting extension to the framework. In the well-mixed scenario, it is likely that the inclusion of mutation will complicate the intuition developed here: while larger populations are more robust to invasions, they are also more prone to mutations, by virtue of their size. While this may be offset by the additional benefits garnered in the spatial analogue of the model, a complex set of timescale-dependent behaviors is likely to emerge. Finally, we propose a rigorous analytical investigation of existing models that conform to the framework we have outlined; an example is the work conducted in \cite{behar_2014,behar_2015}, which we believe to be mathematically explainable within our formalism. In the context of induced selection, whereby deterministically neutral systems become non-neutral in the stochastic setting, similar ideas have already been extended to disease dynamics \cite{kogan_2014} and the evolution of dispersal \cite{lin_mig_1,lin_mig_2}. The extension of selection reversal to such novel ecological models may provide further insight. Furthermore, this general scheme may be of relevance to many other systems in ecological and biological modeling, such as cancer, for which the evolution of phenotypes that profoundly alter cell carrying capacity can be of primary importance. \begin{acknowledgments} TR acknowledges funding from the Royal Society of London. \end{acknowledgments}
{'timestamp': '2016-08-12T02:07:14', 'yymm': '1608', 'arxiv_id': '1608.03471', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03471'}
arxiv
\section{Introduction} Teasing out signatures of interactions buried in overwhelming volumes of information is one of the most basic challenges in scientific research. Understanding how information is organized can help us discover its fundamental underlying properties. Researchers do this when they investigate the relationships between diseases, cell functions, chemicals, or particles, and we all learn new concepts and solve problems by understanding the relationships between the various entities present in our everyday lives. These entities can be represented as networks, or graphs, in which local behaviors can be easily understood, but whose global view is highly complex. These networks exhibit a long and varied list of global properties, including heavy-tailed degree distributions~\cite{strogatz2001exploring} and interesting growth characteristics~\cite{leskovec2005graphs,LeskovecKleinbergFaloutsos:2007}, among others. Recent work has found that these global properties are merely products of a graph's local properties, in particular, graphlet distributions~\cite{Ugander2013}. These small, local substructures often reveal the degree distributions, diameter and other global properties of a graph~\cite{przulj2007biological, Ugander2013}, and have been shown to be a more complete way to measure the similarity between two or more graphs~\cite{yaverouglu2015proper}. Our overall goal, and the goal of structural inference algorithms in general, is to learn the local structures that, in aggregate, help describe the observed interactions and generalize to explain further phenomena. For example, physicists and chemists have found that many chemical interactions are the result of underlying structural properties of the individual elements. Similarly, biologists have agreed that simple tree structures are useful when organizing the evolutionary history of life, and sociologists find that clique-formation, \eg, triadic closure, underlies community development~\cite{Canestro2007Nature, Sadava:2014, backstrom2006group}. In other instances, the structural organization of the entities may resemble a ring, a clique, a star, or any number of complex configurations. In this work, we describe a general framework that can discover, from any large network, simple structural forms in order to make predictions about the topological properties of a network. In addition, this framework is able to extract mechanisms of network generation from small samples of the graph in order to generate networks that satisfy these properties. Our major insight is that a network's {\em clique tree} encodes simple information about the structure of the network. We use the closely-related formalism of \emph{hyperedge replacement grammars} (HRGs) as a way to describe the organization of real world networks. Unlike previous models that manually define the space of possible structures~\cite{Kemp05082008} or define the grammar by extracting frequent subgraphs~\cite{kukluk2006inference,kukluk2008inference}, our framework can automatically discover the necessary forms and use them to recreate the original graph {\em exactly} as well as infer generalizations of the original network. Our approach can handle any type of graph and does not make any assumption about the topology of the data. After reviewing some of the theoretical foundations of clique trees and HRGs, we show how to extract an HRG from a graph and use it to reconstruct the original graph. We then show how to use the extracted grammar to stochastically generate generalizations of the original graph. Finally, we present experimental results that compare the stochastically generated graphs with the original graphs. We show that these generated graphs exhibit a wide range of properties that are very similar to the properties of the original graphs, and significantly outperform existing graph models at generating subgraph distributions similar to those found in the original~graph. \section{Preliminaries} Before we describe our method, some background definitions are needed. We begin with an arbitrary input {\em hypergraph} $H=(V,E)$, where a {\em hyperedge} $e\in E$ can connect multiple vertices $e_i=\{v_1,v_2,\ldots,v_k\}$. Common {\em graphs} (\eg, social networks, Web graphs, information networks) are a particular case of hypergraphs where each edge connects exactly two vertices. For convenience, all of the graphs in this paper will be {\em simple}, {\em connected} and {\em undirected}, although these restrictions are not vital. In the remainder of this section we refer mainly to previous developments in clique trees and their relationship to hyperedge replacement grammars in order to support the claims made in sections 3 and 4. \subsection{Clique Trees} All graphs can be decomposed (though not uniquely) into a {\em clique tree}, also known as a tree decomposition, junction tree, join tree, intersection tree, or cluster graph. Within the data mining community, clique trees are best known for their role in exact inference in probabilistic graphical models, so we introduce the preliminary work from a graphical modelling perspective; for an expanded introduction, we refer the reader to Chapters 9 and 10 of Koller and Friedman's textbook~\cite{Koller:2009:PGM:1795555}. \begin{definition} \label{defn:cliquetree} A {\em clique tree} of a graph $H=(V,E)$ is a tree $T$, each of whose nodes $\eta$ is labeled with a $V_{\eta}\subseteq V$ and $E_{\eta}\subseteq E$, such that the following properties hold: \begin{enumerate} \item Vertex Cover: For each $v\in V$, there is a vertex $\eta\in T$ such that $v\in V_\eta$. \item Edge Cover: For each hyperedge $e_i=\{v_1,\ldots,v_k\} \in E$ there is exactly one node $\eta\in T$ such that $e\in E_\eta$. Moreover, $v_1,\ldots,v_k\in V_\eta$. \item Running Intersection: For each $v\in V$, the set $\{\eta\in T \mid v\in V_\eta\}$ is connected. \end{enumerate} \end{definition} \begin{definition} The \emph{width} of a clique tree is $\max(|V_{\eta}-1|)$, and the \emph{treewidth} of a graph $H$ is the minimal width of any clique tree of $H$. \end{definition} Unfortunately, finding the optimal elimination ordering and corresponding minimal-width clique tree is NP-complete \cite{Arnborg1987}. Fortunately, many reasonable approximations exist for general graphs: in this paper we employ the commonly used maximum cardinality search (MCS) heuristic introduced by Tarjan and Yannikakis~\cite{TarjanYannakakis1985} in order to compute a clique tree with a reasonably-low, but not necessarily minimal, width. Simply put, a clique tree of any graph (or any hypergraph) is a tree, each of whose nodes is labeled with nodes and edges from the original graph, such that {\em vertex cover}, {\em edge cover} and the {\em running intersection} properties hold, and the ``width'' of the clique tree measures how tree-like the graph is. The reason for the interest in finding the clique tree of a graph is because many computationally difficult problems can be solved efficiently when the data is constrained to be a tree. Figure~\ref{fig:expdtree} shows a graph and a minimal-width clique tree of the same graph (showing $V_\eta$ for each node $\eta$). Nodes are labeled with lowercase Latin letters. We will refer back to this graph and clique tree as a running example throughout this paper. \begin{figure}[t] \centering \includegraphics{./arxiv-figure0} \caption{A graph and one possible minimal-width clique tree for it. Ghosted edges are not part of $E_\eta$; they are shown only for explanatory purposes. } \label{fig:expdtree} \end{figure} \subsection{Hyperedge Replacement Grammar} The key insight for this task is that a network's clique tree encodes robust and precise information about the network. An HRG, which is extracted from the clique tree, contains graphical rewriting rules that can match and replace graph fragments similar to how a Context Free Grammar (CFG) rewrites characters in a string. These graph fragments represent a succinct, yet complete description of the building blocks of the network, and the rewriting rules of the HRG represent the instructions on how the graph is pieced together. For a thorough examination of HRGs, we refer the reader to the survey by Drewes {\em et al.}~\cite{Drewes2002}. \begin{definition} \label{defn:tuple} A {\em hyperedge replacement grammar} is a tuple $G=\langle N,T,S,\mathcal{P}\rangle$, where \begin{enumerate} \item $N$ is a finite set of nonterminal symbols. Each nonterminal $A$ has a nonnegative integer \emph{rank}, which we write $|A|$. \item $T$ is a finite set of terminal symbols. \item $S\in N$ is a distinguished starting nonterminal, and $|S|=0$. \item $\mathcal{P}$ is a finite set of production rules $A\rightarrow R$, where \begin{itemize} \item $A$, the left hand side (LHS), is a nonterminal symbol. \item $R$, the right hand side (RHS), is a hypergraph whose edges are labeled by symbols from $T\cup N$. If an edge $e$ is labeled by a nonterminal $B$, we must have $|e| = |B|$. \item Exactly $|A|$ vertices of $R$ are designated \emph{external vertices}. The other vertices in $R$ are called \emph{internal} vertices. \end{itemize} \end{enumerate} \end{definition} When drawing HRG rules, we draw the LHS $A$ as a hyperedge labeled $A$ with arity $|A|$. We draw the RHS as a hypergraph, with the external vertices drawn as solid black circles and the internal vertices as open white circles. If an HRG rule has no nonterminal symbols in its RHS, we call it a \emph{terminal rule}. \begin{definition} \label{defn:hrg} Let $G$ be an HRG and $P=(A \rightarrow R)$ be a production rule of $G$. We define the relation $H'\Rightarrow H^{*}$ ($H^{*}$ is derived in one step from $H'$) as follows. $H'$ must have a hyperedge $e$ labeled $A$; let $v_1, \ldots, v_k$ be the vertices it connects. Let $u_1, \ldots, u_k$ be the external vertices of $R$. Then $H^*$ is the graph formed by removing $e$ from $H'$, making an isomorphic copy of $R$, and identifying $v_i$ with the copies of $u_i$ for each $i=1,\ldots,k$. Let $\Rightarrow^\ast$ be the reflexive, transitive closure of $\Rightarrow$. Then we say that $G$ generates a graph $H$ if there is a production $S \rightarrow R$ and $R \Rightarrow^\ast H$ and $H$ has no edges labeled with nonterminal symbols. \end{definition} In other words, a derivation starts with the symbol $S$, and we repeatedly choose a nonterminal $A$ and rewrite it using a production $A \rightarrow R$. The replacement hypergraph fragments $R$ can itself have other nonterminal hyperedges, so this process is repeated until there are no more nonterminal hyperedges. These definitions will be clearly illustrated in the following sections. \subsection{The Missing Link} Clique trees and hyperedge replacement graph grammars have been studied for some time in discrete mathematics and graph theory literature. HRGs are conventionally used to generate graphs with very specific structures, \eg, rings, trees, stars. A drawback of many current applications of HRGs is that their production rules must be hand drawn to generate some specific graph or class of graphs. Very recently, Kemp and Tenenbaum developed an inference algorithm that learned probabilities from real world graphs, but still relied on a handful of rather basic hand-drawn production rules (of a related formalism called vertex replacement grammar) to which the learned probabilities were assigned~\cite{Kemp05082008}. The main contribution of this paper is to combine prior theoretical work on clique trees, tree decomposition and treewidth to automatically learn an HRG for real world graphs. Existing graph generators, like exponential random graphs, small world graphs, Kronecker graphs, and so on, learn parameters from some input graph to generate new graphs stochastically. Unlike these previous approaches, our model has the ability to reproduce the exact same graph topology where the new graph is guaranteed to be isomorphic to the original graph. Our model is also able to stochastically generate different-sized graphs that share similar properties to the original graph. \section{Learning Graph Grammars} The first step in learning an HRG from a graph is to compute a clique tree from the original graph. Then, this clique tree induces an HRG in a natural way, which we demonstrate in this section. \subsection{Clique Trees and HRGs} Let $\eta$ be an interior node of the clique tree $T$, let $\eta'$ be its parent, and let $\eta_1, \ldots, \eta_m$ be its children. Node $\eta$ corresponds to an HRG production rule $A \rightarrow R$ as follows. First, $|A| = |V_{\eta'} \cap V_{\eta}|$. Then, $R$ is formed by: \begin{itemize} \item Adding an isomorphic copy of the vertices in $V_\eta$ and the edges in $E_\eta$ \item Marking the (copies of) vertices in $V_{\eta'} \cap V_{\eta}$ as external vertices \item Adding, for each $\eta_i$, a nonterminal hyperedge connecting the (copies of) vertices in $V_\eta \cap V_{\eta_i}$. \end{itemize} \begin{figure}[h] \centering \includegraphics{./arxiv-figure1} \caption{Example of hyperedge replacement grammar rule creation from an interior vertex of the clique tree. Note that lowercase letters inside vertices are for explanatory purposes only; only the numeric labels outside external vertices are actually part of the rule.} \label{fig:creation} \end{figure} Figure~\ref{fig:creation} shows an example of the creation of an HRG rule. In this example, we focus on the middle clique-tree node $V_\eta = \{\text{d},\text{e},\text{f}\}$, outlined in bold. We choose nonterminal symbol N for the LHS, which must have rank~2 because $\eta$ has 2 vertices in common with its parent. The RHS is a graph whose vertices are (copies of) $V_{\eta} = \{\text{d}, \text{e}, \text{f}\}$. Vertices d and e are marked external (and numbered 1 and 2, arbitrarily) because they also appear in the parent node. The terminal edges are $E_{\eta} = \{(\text{d},\text{f}), (\text{e},\text{f})\}$. There is only one child of $\eta$, and the nodes they have in common are e and~f, so there is one nonterminal hyperedge connecting e and~f. Next we deal with the special cases of the root and leaves. \begin{figure}[h] \centering \includegraphics{./arxiv-figure2} \caption{Example of hyperedge replacement grammar rule creation from the root node of the clique tree.} \label{fig:creation_root} \end{figure} \myparagraph{Root Node.} If $\eta$ is the root node, then it does not have any parent cliques, but may still have one or more children. Because $\eta$ has no parent, the corresponding rule has a LHS with rank 0 and a RHS with no external vertices. In this case, we use the start nonterminal $S$ as the LHS, as shown in Figure~\ref{fig:creation_root}. The RHS is computed in the same way as the interior node case. For the example in Fig.~\ref{fig:creation_root}, the RHS has vertices that are copies of c, d, and e. In addition, the RHS has two terminal hyperedges, $E_\eta = \{(\text{c},\text{d}),(\text{c},\text{e})\}$. The root node has two children, so there are two nonterminal hyperedges on the RHS. The right child has two vertices in common with $\eta$, namely, d and e; so the corresponding vertices in the RHS are attached by a 2-ary nonterminal hyperedge. The left child has three vertices in common with $\eta$, namely, c, d, and e, so the corresponding vertices in the RHS are attached by a 3-ary nonterminal hyperedge. \begin{figure}[h] \centering \includegraphics{./arxiv-figure3} \caption{Example of hyperedge replacement grammar rule creation from a leaf vertex of the clique tree.} \label{fig:creation_leaf} \end{figure} \myparagraph{Leaf Node.} If $\eta$ is a leaf node, then the LHS is calculated the same as in the interior node case. Again we return to the running example in Fig.~\ref{fig:creation_leaf} (on the next page). Here, we focus on the leaf node $\{\text{a},\text{b},\text{e}\}$, outlined in bold. The LHS has rank 2, because $\eta$ has two vertices in common with its parent. The RHS is computed in the same way as the interior node case, except no new nonterminal hyperedges are added to the RHS. The vertices of the RHS are (copies of) the nodes in $\eta$, namely, a, b, and e. Vertices b and e are external because they also appear in the parent clique. This RHS has two terminal hyperedges, $E_\eta = \{(\text{a},\text{b}), (\text{a},\text{e})\}$. Because the leaf clique has no children, it cannot produce any nonterminal hyperedges on the RHS; therefore this rule is a terminal rule. \subsection{Top-Down HRG Rule Induction} We induce production rules from the clique tree by applying the above extraction method top down. Because trees are acyclic, the traversal order does not matter, yet there are some interesting observations we can make about traversals of moderately sized graphs. First, exactly one HRG rule will have the special starting nonterminal $S$ on its LHS; no mention of $S$ will ever appear in any RHS. Similarly, the number of terminal rules is equal to the number of leaf nodes in the clique tree. Larger graphs will typically produce larger clique trees, especially sparse graphs because they are more likely to have a larger number of small maximal cliques. These larger clique trees will produce a large number of HRG rules, one for each clique in the clique tree. Although it is possible to keep track of each rule and its traversal order, we find, and will later show in the experiments section, that the same rules are often repeated many times. \renewcommand{\boxed}[1]{\text{\fboxsep=.1em\fbox{$\displaystyle#1$}}} Figure~\ref{fig:production_rules} shows the 6 rules that are induced from the clique trees illustrated in Fig.~\ref{fig:expdtree} and used in the running example throughout this section. \subsection{Complexity Analysis} The HRG rule induction steps described in this section can be broken into two steps: (i) creating a clique tree and (ii) the HRG rule extraction process. Unfortunately, finding a clique tree with minimal width \ie, the treewidth $tw$, is NP-Complete. Let $n$ and $m$ be the number of vertices and edges respectively in $H$. Tarjan and Yannikakis' Maximum Cardinality Search (MCS) algorithm finds a usable clique tree~\cite{TarjanYannakakis1985} in linear time $O(n+m)$, but is not guaranteed to be minimal. The running time of the HRG rule extraction process is determined exclusively by the size of the clique tree as well as the number of vertices in each clique tree node. From Defn.~\ref{defn:cliquetree} we have that the number of nodes in the clique tree is $m$. When minimal, the number of vertices in an the largest clique tree node $\max(|\eta_i|)$ (minus 1) is defined as the treewidth $tw$, however, clique trees generated by MCS have $\max(|\eta_i|)$ bounded by the maximum degree of $H$, denoted as $\Delta$~\cite{geman2002dynamic}. Therefore, given an elimination ordering from MCS, the computational complexity of the extraction process is in $O(m\cdot \Delta)$. \begin{figure}[t] \centering \resizebox{.50\hsize}{!}{% \includegraphics{./arxiv-figure4} } \caption{Complete set of production rules extracted from the example clique tree. Note that lowercase letters inside vertices are for explanatory purposes only; only the numeric labels outside external vertices are actually part of the rule.} \label{fig:production_rules} \end{figure} \section{Graph Generation} In this section we show how to use the HRG extracted from the original graph $H$ (as described in the previous section) to generate a new graph $H^*$. Ideally, $H^*$ will be similar to, or have features that are similar to the original graph $H$. We present two generation algorithms. The first generation algorithm is {\em exact generation}, which, as the name implies, creates an isomorphic copy of the original graph $H^*\equiv H$. The second generation algorithm is a fast {\em stochastic generation} technique that generates random graphs with similar characteristics to the original graph. Each generation algorithm starts with $H^\prime$ containing only the starting nonterminal $S$. \subsection{Exact Generation} Exact generation operates by reversing the HRG extraction process. In order to do this, we must store the HRG rules $\mathcal{P}$ as well as the clique tree $T$ (or at least the order that the rules were created). The first HRG rule considered is always the rule with the nonterminal labelled $S$ as the LHS. This is because the clique tree traversal starts at the root, and because the root is the only case that results in $S$ on the LHS. The previous section defined an HRG $G$ that is constructed from a clique tree $T$ of some given hypergraph $H$, and Defn.~\ref{defn:hrg} defines the application of a production rule $(A\rightarrow R)$ that transforms some hypergraph $H^{\prime}$ into a new hypergraph $H^*$. By applying the rules created from the clique tree in order, we will create an $H^*$ that is isomorphic to the original hypergraph $H$. In the remainder of this section, we provide a more intuitive look at the exact generation property of the HRG by recreating the graph decomposed in the running example. \begin{figure}[h] \centering \includegraphics{./arxiv-figure5} \caption{Application of Rule 1 to replace the starting nonterminal $S$ with the RHS to create a new graph $H^*$.} \label{fig:rule1} \end{figure} Using the running example from the previous section, the application of Rule 1 illustrated in Fig.~\ref{fig:rule1} shows how we transform the starting nonterminal into a new hypergraph, $H^*$. This hypergraph now has two nonterminal hyperedges corresponding to the two children that the root clique had in Fig.~\ref{fig:expdtree}. The next step is to replace $H^\prime$ with $H^*$ and then pick a nonterminal corresponding to the leftmost unvisited node of the clique tree. \begin{figure}[h] \centering \includegraphics{./arxiv-figure6} \caption{Application of Rule 2 to replace a size-3 nonterminal in $H^\prime$ with the RHS to create a new graph $H^*$.} \label{fig:rule2} \end{figure} We proceed down the left hand side of the clique tree, applying Rule 2 to $H^\prime$ as shown in Fig.~\ref{fig:rule2}. The LHS of Rule 2 matches the 3-ary hyperedge and replaces it with the RHS, which introduces a new internal vertex, two new terminal edges and a new nonterminal hyperedge. Again we set $H^\prime$ to be $H^*$ and continue to the leftmost leaf in the example clique tree. \begin{figure}[h] \centering \includegraphics{./arxiv-figure7} \caption{Application of Rule 3 to replace a size-2 nonterminal in $H^\prime$ with the RHS to create a new graph $H^*$.} \label{fig:rule3} \end{figure} The leftmost leaf in Fig.~\ref{fig:expdtree} corresponds to the application of Rule~3; it is the next to be applied to the new nonterminal in $H^*$ and replaced by the RHS as illustrated in Figure~\ref{fig:rule3}. The LHS of Rule 3 matches the 2-ary hyperedge shown and replaces it with the RHS, which creates a new internal vertex along with two terminal edges. Because Rule 3 comes from a leaf node, it is a terminal rule and therefore does not add any nonterminal hyperedges. This concludes the left subtree traversal from Fig.~\ref{fig:expdtree}. \begin{figure}[h] \centering \includegraphics{./arxiv-figure8} \caption{Application of Rules 4, 5 and 6 to create an $H^*$ that is isomorphic to the original graph $H$.} \label{fig:rule456} \end{figure} Continuing the example, the right subtree in the clique tree illustrated in Fig.~\ref{fig:expdtree} has three further applications of the rules in $\mathcal{P}$. As illustrated in Fig.~\ref{fig:rule456}, Rule 4 adds the final vertex, two terminal edges and one nonterminal hyperedge to $H^*$. Rule 5 and Rule 6 do not create any more terminal edges or internal vertices in $H^*$, but are still processed because of the way the clique tree is constructed. After all 6 rules are applied in order, we are guaranteed that $H$ and $H^*$ are isomorphic. \subsection{Stochastic Generation} There are many cases in which we prefer to create very large graphs in an efficient manner that still exhibit the local and global properties of some given example graph {\em without storing the large clique tree} as required in exact graph generation. Here we describe a simple stochastic hypergraph generator that applies rules from the extracted HRG in order to efficiently create graphs of arbitrary size. In larger HRGs we usually find many $A\rightarrow R$ production rules that are identical. We can merge these duplicates by matching rule-signatures in a dictionary, and keep a count of the number of times that each distinct rule has been seen. For example, if there were some additional Rule 7 in Fig.~\ref{fig:production_rules} that was identical to, say, Rule 3, then we would simply note that we saw Rule 3 two times. To generate random graphs from a probabilistic HRG, we start with the special starting nonterminal $H^\prime = S$. From this point, $H^*$ can be generated as follows: (1) Pick any nonterminal $A$ in $H^\prime$; (2) Find the set of rules $(A \rightarrow R)$ associated with LHS $A$; (3) Randomly choose one of these rules with probability proportional to its count; (4) replace $A$ in $H^\prime$ with $R$ to create $H^*$; (5) Replace $H^\prime$ with $H^*$ and repeat until there are no more nonterminal edges. However, we find that although the sampled graphs have the same mean size as the original graph, the variance is much too high to be useful. So we want to sample only graphs whose size is the same as the original graph's, or some other user-specified size. Naively, we can do this using rejection sampling: sample a graph, and if the size is not right, reject the sample and try again. However, this would be quite slow. Our implementation uses a dynamic programming approach to do this exactly while using quadratic time and linear space, or approximately while using linear time and space. We omit the details of this algorithm here, but the source code is available online at \url{https://github.com/nddsg/HRG/}. \section{Experiments} HRGs contain rules that succinctly represent the global and local structure of the original graph. In this section, we compare our approach against some of the state-of-the-art graph generators. We consider the properties that underlie a number of real-world networks and compare the distribution of graphs generated using generators for Kronecker Graphs, the Exponential Random Graph, Chung-Lu Graphs, and the graphs produced by the stochastic hyperedge replacement graph grammar. In a manner similar to HRGs, the Kronecker and Exponential Random Graph Models learn parameters that can be used to approximately recreate the original graph $H$ or a graph of some other size such that the stochastically generated graph holds many of the same properties as the original graph. The Chung-Lu graph model relies on node degree sequences to yield graphs that maintain this distribution. Except in the case of exact HRG generation described above, the stochastically generated graphs are likely not isomorphic to the original graph. We can, however, still judge how closely the stochastically generated graph resembles the original graph by comparing several of their properties. \subsection{Real World Datasets} In order to get a holistic and varied view of the strengths and weaknesses of HRGs in comparison to the other leading graph generation models, we consider real-world networks that exhibit properties that are both common to many networks across different fields, but also have certain distinctive properties. \begin{table}[h] \vspace{-.5cm} \centering \caption{Real networks} \begin{tabular}{r|cc} \textbf{Dataset Name} & \textbf{Nodes} & \textbf{Edges} \\\hlin Enron Emails & 36,692 & 183,831 \\ ArXiv GR-QC & 5,242 & 14,496\\ Internet Routers & 6,474 & 13,895\\ DBLP & 317,080 & 1,049,866\\ \end{tabular} \label{tab:realnets} \vspace{-.2cm} \end{table} The four real world networks considered in this paper are described in Table~\ref{tab:realnets}. The networks vary in their number of vertices and edges as indicated, but also vary in clustering coefficient, diameter, degree distribution and many other graph properties. Specifically, the Enron graph is the email correspondence graph of the now defunct Enron corporation; the ArXiv GR-QC graph is the co-authorship graph extracted from the General Relativity and Quantum Cosmology section of ArXiv; the Internet router graph is created from traffic flows through Internet peers; and, finally, DBLP is the co-authorship graph from the DBLP dataset. Datasets were downloaded from the SNAP and KONECT dataset repositories. \subsection{Methodology} \label{sec:methodology} We compare several different graph properties from the 4 classes of graph generators (HRG, Kronecker, Chung-Lu and exponential random graph (ERGM) models) to the original graph $H$. Other models, such as the Erd\H{o}s-R\'{e}nyi random graph model, the Watts-Strogatz small world model, the Barab\'{a}si-Albert generator, etc. are not compared here due to limited space and because Kronecker, Chung-Lu and ERGM have been shown to outperform these earlier models when matching network properties in empirical networks. Kronecker graphs operate by learning an initiator matrix and then performing a recursive multiplication of that initiator matrix in order to create an adjacency matrix of the approximate graph. In our case, we use KronFit~\cite{Leskovec2010kronecker} with default parameters to learn a $2\times 2$ initiator matrix and then use the recursive Kronecker product to generate the graph. Unfortunately, the Kronecker product only creates graphs where the number of nodes is a power of 2, \ie, $2^x$, where we chose $x=15$, $x=12$, $x=13$, and $x=18$ for Enron, ArXiv, Routers and DBLP graphs respectively to match the number of nodes as closely as possible. The Chung-Lu Graph Model (CL) takes, as input, a degree distribution and generates a new graph of the similar degree distribution and size~\cite{ChungLu2002connected}. Exponential Random Graph Models (ERGMs) are a class of probabilistic models used to directly describe several structural features of a graph~\cite{Robins2007}. We used default parameters in R's ERGM package~\cite{Hunter2008} to generate graph models for comparison. In addition to the problem of model degeneracy, ERGMs do not scale well to large graphs. As a result, DBLP and Enron could not be modelled due to their size, and the ArXiv graph always resulted in a degenerate model. Therefore ERGM results are omitted from this section. The main strength of HRG is to learn the patterns and rules that generate a large graph from only a few small subgraph-samples of the original graph. So, in all experiments, we make $k$ random samples of size $s$ node-induced subgraphs by a breadth first traversal starting from a random node in the graph~\cite{Leskovec2006sampling}. By default we set $k=4$ and $s=500$ empirically. We then compute tree decompositions from the $k$ samples, learn HRGs $G_1, G_2,\ldots, G_{k}$, and combine them to create a single grammar $G = \bigcup_i G_i$. For evaluation purposes, we generate 20 approximate graphs for the HRG, Chung-Lu, and Kronecker models and plot the mean values in the results section. We did compute the confidence internals for each of the models, but omitted them from the graphs for clarity. In general, the confidence intervals were very small for HRG, Kronecker and CL (indicating good consistency), but very big in the few ERGM graphs that we were able to generate because of the model degeneracy problem we encountered. \subsection{Graph Generation Results} Here we compare and contrast the results of approximate graphs generated from HRG, Kronecker product, and Chung-Lu. Before the results are presented, we briefly introduce the graph properties that we use to compare the similarity between the real networks and their approximate counterparts. Although many properties have been discovered and detailed in related literature, we focus on three of the principal properties from which most others can be derived. \begin{figure}[t] \centering \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure9} } \end{minipage}% \begin{minipage}[b]{0.222\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure10} } \end{minipage} \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure11} } \end{minipage}% \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure12} } \end{minipage} \resizebox{.37\linewidth}{!}{ \includegraphics{./arxiv-figure13} } \caption{Degree Distribution. Dataset graphs exhibit a power law degree distribution that is well captured by existing graph generators as well as HRG.} \label{fig:real_degree} \end{figure} \begin{figure}[t] \centering \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure14} } \end{minipage}% \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure15} } \end{minipage} \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure16} } \end{minipage}% \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure17} } \end{minipage} \resizebox{.37\linewidth}{!}{ \includegraphics{./arxiv-figure18} } \caption{Eigenvector Centrality. Nodes are ordered by their eigenvector-values along the x-axis. Cosine distance between the original graph and HRG, Chung-Lu and Kronecker models are shown at the top of each plot where lower is better. In terms of cosine distance, the eigenvector of HRG is consistently closest to that of the original graph.} \label{fig:real_eig} \end{figure} \begin{figure}[t!] \centering \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure19} } \end{minipage}% \begin{minipage}[b]{0.222\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure20} } \end{minipage} \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure21} } \end{minipage}% \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure22} } \end{minipage} \resizebox{.37\linewidth}{!}{ \includegraphics{./arxiv-figure23} } \caption{Hop Plot. Number of vertex pairs that are reachable within $x$-hops. HRG closely and consistently resembles the hop plot curves of the original graph. } \label{fig:real_hopplot} \end{figure} \myparagraph{Degree Distribution.} The degree distribution of a graph is the distribution of the number of edges connecting to a particular vertex. Barab\'{a}si and Albert initially discovered that the degree distribution of many real world graphs follows a power law distribution such that the number of nodes $N_d\propto d^{-\gamma}$ where $\gamma>0$ and $\gamma$ is typically between 2 and 3~\cite{barabasi1999emergence}. Figure~\ref{fig:real_degree} shows the results of the degree distribution property on the four real world graphs ($frequency$ or $count$ as a function of degree $k$). Recall that the graph results plotted here and throughout the results section are the mean averages of 20 generated graphs. Each of the generated graphs is slightly different from the original graphs in their own way. As expected, we find that the power law degree distribution is captured by existing graph generators as well as the HRG model. \myparagraph{Eigenvector Centrality.} The principal eigenvector is often associated with the centrality or ``value'' of each vertex in the network, where high values indicate an important or central vertex and lower values indicate the opposite. A skewed distribution points to a relatively few ``celebrity'' vertices and many common nodes. The principal eigenvector value for each vertex is also closely associated with the PageRank and degree value for each node. Figure~\ref{fig:real_eig} shows the eigenvector scores for each node ranked highest to lowest in each of the four real world graphs. Because the x-axis represents individual nodes, Fig.~\ref{fig:real_eig} also shows the size difference among the generated graphs. HRG performs consistently well across all four types of graphs, but the log scaling on the y-axis makes this plot difficult to discern. To more concretely compare the eigenvectors, the pairwise cosine distance between eigenvector centrality of $H$ and the mean eigenvector centrality of each model's generated graphs appear at the top of each plot in order. HRG consistently has the lowest cosine distance followed by Chung-Lu and Kronecker. \myparagraph{Hop Plot.} The hop plot of a graph shows the number of vertex-pairs that are reachable within $x$ hops. The hop plot, therefore, is another way to view how quickly a vertex's neighborhood grows as the number of hops increases. As in related work~\cite{leskovec2005graphs} we generate a hop plot by picking 50 random nodes and perform a complete breadth first traversal over each graph. Figure~\ref{fig:real_hopplot} demonstrates that HRG graphs produce hop plots that are remarkably similar to the original graph. Chung-Lu performs rather well in most cases; Kronecker has poor performance on Arxiv and DBLP graphs, but still shows the correct hop plot shape. \subsection{Canonical Graph Comparison} The previous network properties primarily focus on statistics of the global network. However, there is mounting evidence which argues that the graphlet comparisons are the most complete way measure the similarity between two graphs~\cite{przulj2007biological,Ugander2013}. The graphlet distribution succinctly describes the number of small, local substructures that compose the overall graph and therefore more completely represents the details of what a graph ``looks like.'' Furthermore, it is possible for two very dissimilar graphs to have the same degree distributions, hop plots, etc., but it is difficult for two dissimilar graphs to fool a comparison with the graphlet distribution. \myparagraph{Graphlet Correlation Distance} Recent work from systems biology has identified a new metric called the Graphlet Correlation Distance (GCD). The GCD computes the distance between two graphlet correlation matrices -- one matrix for each graph~\cite{yaverouglu2015proper}. It measures the frequency of the various graphlets present in each graph, \ie, the number of edges, wedges, triangles, squares, 4-cliques, etc., and compares the graphlet frequencies between two graphs. Because the GCD is a distance metric, lower values are better. The GCD can range from $[0,+\infty]$, where the GCD is 0 if the two graphs are isomorphic. \begin{figure}[t] \centering \resizebox{.64\textwidth}{!}{ \includegraphics{./arxiv-figure24} } \caption{Graphlet Correlation Distance. A measure of the distance between the graphlet counts of both graphs, but also represents a canonical measure of graph similarity. Lower is better. } \label{fig:gcd_real} \end{figure} We computed the GCD between the original graph and each generated graph. Figure~\ref{fig:gcd_real} shows the GCD results. Although they are difficult to see due to their small size, Fig.~\ref{fig:gcd_real} includes error bars for the 95\% confidence interval. The results here are clear: HRG significantly outperforms the Chung-Lu and Kronecker models. The GCD opens a whole new line of network comparison methods that stress the graph generators in various ways. \subsection{Graph Extrapolation} Recall that HRG learns the grammar from $k=4$ subgraph-samples from the original graph. In essence, HRG is extrapolating the learned subgraphs into a full size graph. This raises the question: if we only had access to a small subset of some larger network, could we use our models to infer a larger (or smaller) network with the same local and global properties? For example, given the 34-node Karate Club graph, could we infer what a hypothetical Karate Franchise might look like? Using two smaller graphs, Zachary's Karate Club (34 nodes, 78 edges) and the protein-protein interaction network of \textit{S.~cerevisiae} yeast (1,870 nodes, 2,240 edges), we learned an HRG model with $k=1$ and $s=n$, \ie, no sampling, and generated networks of size-$n^*$ = 2x, 3x, \ldots, 32x. For the protein graph we also sampled down to $n^*=x/8$. Powers of 2 were used because the standard Kronecker model can only generate graphs of that size. The Chung-Lu model requires a size-$n^*$ degree distribution as input. To create the proper degree distribution we fitted a Poisson distribution ($\lambda = 2.43$) and a Geometric Distribution ($p = 0.29$) to Karate and Protein graphs respectively and drew $n^*$ degree-samples from their respective distributions. In all cases, we generated 20 graphs at each size-point. \begin{figure}[t] \centering \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure25} } \end{minipage} \begin{minipage}[b]{0.228\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure26} } \end{minipage} \\ \resizebox{.35\linewidth}{!}{ \includegraphics{./arxiv-figure27} } \caption{GCD of graphs extrapolated in multiples up to 32x from two small graphs. HRG outperforms Chung-Lu and Kronecker models when generating larger graphs. Lower is better. } \label{fig:xtrapol} \end{figure} Rather than comparing raw numbers of graphlets, the GCD metric compares the \textit{correlation} of the resulting graphlet distributions. As a result, GCD is largely immune to changes in graph size. Thus, GCD is a good metric for this extrapolation task. Figure~\ref{fig:xtrapol} shows the mean GCD score and 95\% confidence intervals for each graph model. Not only does HRG generate good results at $n^*=1$x, the GCD scores remain mostly level as $n^*$ grows. \subsection{Sampling and Grammar Complexity} We have shown that HRG can generate graphs that match the original graph from $k=4$ samples of $s=500$-node subgraphs. If we adjust the size of the subgraph, then the size of the clique tree will change causing the grammar to change in size and complexity. A large clique tree ought to create more rules and a more complex grammar, resulting in a larger model size and better performance; while a small clique tree ought to create fewer rules and a less complex grammar, resulting in a smaller model size and a lower performance. \begin{figure}[t] \centering \resizebox{.64\textwidth}{!}{ \includegraphics{./arxiv-figure28} } \caption{HRG model size as the subgraph size $s$ and the number of subgraph samples $k$ varies. The model size grows linearly with $k$ and $s$.} \label{fig:grammarsize} \end{figure} To test this hypothesis we generated graphs by varying the number of subgraph samples $k$ from 1 to 32, while also varying the size of the sampled subgraph $s$ from 100 to 600 nodes. Again, we generated 20 graphs for each parameter setting. Figure~\ref{fig:grammarsize} shows how the model size grows as the sampling procedure changes on the Internet Routers graph. Plots for other graphs show a similar growth rate and shape, but are omitted due to space constraints. To test the statistical correlation we calculated Pearson's correlation coefficient between the model size and sampling parameters. We find that the $k$ is slightly correlated with the model size on Routers ($r=0.31$, $p=0.07$), Enron ($r=0.27, p=0.09$), ArXiv ($r=0.21, p=0.11$), and DBLP ($r=0.29$, $p=0.09$). Furthermore, the choice of $s$ affects the size of the clique tree from which the grammars are inferred. So its not surprising that $s$ is highly correlated with the model size on Routers ($r=0.64), Enron ($r=0.71), ArXiv ($r=0.68$), and DBLP ($r=0.54$) all with $p\ll 0.001$. Because we merge identical rules when possible, we suspect that the overall growth of the HRG model follows Heaps law~\cite{heaps1978information}, \ie, that the model size of a graph can be predicted from its rules; although we save a more thorough examination of the grammar rules as a matter for future work. \subsubsection{Model size and Performance} One of the disadvantages of the HRG model, as indicated in Fig.~\ref{fig:grammarsize}, is that the model size can grow to be very large. But this again begs the question: do larger and more complex HRG models result in improved performance? To answer this question we computed the GCD distance between the original graph and graphs generated by varying $k$ and $s$. Figure~\ref{fig:size_score} illustrates the relationship between model size and the GCD. We use the Router and DBLP graphs to shows the largest and smallest of our dataset; other graphs show similar results, but their plots are omitted due to of space. Surprisingly, we find that the performance of models with only 100 rules is similar to the performance of the largest models. In the Router results, two very small models with poor performance had only 18 and 20 rules each. Best fit lines are drawn to illustrate the axes relationship where negative slope indicates that larger models generally perform better. Outliers can dramatically affect the outcome of best fit lines, so the faint line in the Routers graph shows the best fit line if we remove the two square outlier points. Without removing outliers, we find only a slightly negative slope on the best fit line indicating only a slight performance improvement between HRG models with 100 rules and HRG models with 1,000 rules. Pearson's correlation coefficient comparing GCD and model size similarly show slightly negative correlations on Routers ($r=-0.12$, $p=0.49$), Enron ($r=-0.09, p=0.21$), ArXiv ($r=0.04, p=0.54$), and DBLP ($r=-0.08$, $p=0.62$) \begin{figure}[t] \centering \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure29} } \end{minipage} \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure30} } \end{minipage} \caption{GCD as a function of model size. We find a slightly negative relationship between model size and performance, but with quickly diminishing returns. Best fit lines and their equations are shown; the shorter fit line in the Routers plot ignores the square outlier points. } \label{fig:size_score} \end{figure} \subsubsection{Runtime Analysis Revisited \label{sss:runtime}} The overall execution time of the HRG model is best viewed in two parts: (1) rule extraction, and (2) graph generation. We previously identified the runtime complexity of the rule extraction process to be $O(m\cdot\Delta)$. However, this did not include $k$ samples of size-$s$ subgraphs. So, when sampling with $k$ and $s$, we amend the runtime complexity to be $O(k\cdot m \cdot \Delta)$ where $m$ is bounded by the number of hyperedges in the size-$s$ subgraph sample and $\Delta\le s$. Graph generation requires a straightforward application of rules and is linear in the number of edges in the output graph. \begin{figure}[t] \centering \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure31} } \end{minipage} \begin{minipage}[b]{0.23\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure32} } \end{minipage} \caption{Total inference runtime (\ie, clique tree creation and rule extraction) as a function of model size. Best fit lines on the log-log plot show that the execution time grows linearly with the model size. } \label{fig:size_time} \end{figure} All experiments were performed on a modern consumer-grade laptop in an unoptimized, unthreaded python implementation. We recorded the extraction time while generating graphs for the size-to-GCD comparison in the previous section. Although the runtime analysis gives theoretical upper bounds to the rule extraction process, Fig.~\ref{fig:size_time} shows that the extraction runtime is highly correlated to the size of the model in Routers ($r=0.68$), ArXiv ($r=0.91$), Enron ($r=0.88$), and DBLP ($r=0.94$) all with $p\ll 0.001$. Simply put, more rules require more time, but there are diminishing returns. So it may not be necessary to learn complex models when smaller HRG models tend to perform reasonably well. \subsection{Graph Generation Infinity Mirror} Lastly, we characterize the robustness of graph generators by introducing a new kind of test we call the \textit{infinity mirror}~\cite{aguinaga16infinity}. One of the motivating questions behind this idea was to see if HRG holds sufficient information to be used as a reference itself. In this test, we repeatedly learn a model from a graph generated by the an earlier version of the same model. For HRG, this means that we learn a set of production rules from the original graph $H$ and generate a new graph $H^*$; then we set $H\gets H^*$ and repeat thereby learning a new model from the generated graph recursively. We repeat this process ten times, and compare the output of the tenth recurrence with the original graph using GCD. We expect to see that all models degenerate over 10 recurrences because graph generators, like all machine learning models, are lossy compressors of information. The question is, how quickly do the models degenerate and how bad do the graphs become? \begin{figure}[t] \centering \begin{minipage}[b]{0.235\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure33} } \end{minipage} \begin{minipage}[b]{0.235\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure34} } \end{minipage} \begin{minipage}[b]{0.235\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure35} } \end{minipage} \begin{minipage}[b]{0.235\textwidth} \resizebox{\textwidth}{!}{ \includegraphics{./arxiv-figure36} } \end{minipage} \resizebox{.37\linewidth}{!}{ \includegraphics{./arxiv-figure27} } \caption{Infinity Mirror. Unlike Kronecker and Chung-Lu models, HRG does not degenerate as its model is applied repeatedly. Lower is better.} \label{fig:inf_mir_gcd} \end{figure} Figure~\ref{fig:inf_mir_gcd} shows the GCD scores for the HRG, Chung-Lu and Kronecker models at each recurrence. Surprisingly, we find that HRG stays steady, and even improves its performance while the Kronecker and Chung-Lu models steadily decrease their performance as expected. We do not yet know why HRG improves performance in some cases. Because GCD measures the graphlet correlations between two graphs, the improvement in GCD may be because HRG is implicitly honing in on rules that generate the necessary graph patterns. Yet again, further work is needed to study this important phenomenon. \section{Conclusions and Future Work} In this paper we have shown how to use clique trees (also known as junction trees, tree decomposition, intersection trees) constructed from a simple, general graph to learn a hyperedge replacement grammar (HRG) for the original graph. We have shown that the extracted HRG can be used to reconstruct a new graph that is isomorphic to the original graph if the clique tree is traversed during reconstruction. More practically, we show that a stochastic application of the grammar rules creates new graphs that have very similar properties to the original graph. The results of graphlet correlation distance experiments, extrapolation and the infinity mirror are particularly exciting because our results show a stark improvement in performance over existing graph generators. In the future, we plan to investigate differences between the grammars extracted from different types of graphs; we are also interested in exploring the implications of finding two graphs which have a large overlap in their extracted grammars. Among the many areas for future work that this study opens, we are particularly interested in learning a grammar from the actual growth of some dynamic or evolving graph. Within the computational theory community there has been a renewed interest in quickly finding clique trees of large real world graphs that are closer to optimal. Because of the close relationship of HRG and clique trees shown in this paper, any advancement in clique tree algorithms could directly improve the speed and accuracy of graph generation. Perhaps the most important finding that comes from this work is the ability to interrogate the generation of substructures and subgraphs within the grammar rules that combine to create a holistic graph. Forward applications of the technology described in this work may allow us to identify novel patterns analogous to the previously discovered triadic closure and bridge patterns found in real world social networks. Thus, an investigation in to the nature of the extracted rules and their meaning (if any) is a top priority. We encourage the community to explore further work bringing HRGs to attributed graphs, heterogeneous graphs and developing practical applications of the extracted rules. Given the current limitation related to the growth in the number of extracted rules as well as the encouraging results from small models, we are also looking for sparsification techniques that might limit the model's size while still maintaining performance. \section{Acknowledgements} This work is supported by the Templeton Foundation under grant FP053369-M/O.
{'timestamp': '2016-08-11T02:08:05', 'yymm': '1608', 'arxiv_id': '1608.03192', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03192'}
arxiv
\section{Introduction} \label{sec:intro} \begin{figure}[t] \centering \includegraphics[width=250pt]{Intro_Image1} \caption{Mid-level visual elements: discriminative descriptors of human actions and attributes. Our method discovers visual elements which make discrimination between human body parts or attributes or interacted objects . (a) shows the scores and classification results in the action classification task (b) shows discrimination scores of elements in the attributes classification task by color and shows final results of classification.} \label{fig:1} \end{figure} Mimicking the human capability to understand the actions and attributes of people is very challenging. Lately, deep neural networks have strongly increased the capacity of computers to recognize objects, yet the analysis of human actions and attributes is lagging behind in terms of performance. These are a kind of fine-grained classification problems, where on the one hand possibly small patches that correspond to crucial appearance features of objects interacted with as well as, on the other hand, the global context of the surrounding scene contain crucial cues. The paper presents a newly designed CNN to extract such information by identifying informative image patches. The idea of focusing on patches or parts definitely is not new in computer vision, also not when it comes to human actions or attributes \cite{EPM,Stanford40}. \cite{EPM} show that a good solution to human action classification can be achieved without trying to obtain a perfect pose estimation and without using body part detectors. Indeed, an alternative is to capture discriminative image patches. Mining such patches for the cases of actions and attributes is the very topic of this paper. After deriving some initial discriminative patch clusters for each category of action or attribute, our deep pattern CNN puts them into an iterative process that further optimizes the discriminative power of these clusters. Fig.~\ref{fig:2} sketches our CNN and will be explained further in the upcoming sections. At the end of the training, the CNN has become an expert in detecting those image patches that distinguish human actions and attributes. The CNN comes with the features extracted from those patches. Our experiments show that we obtain better performance for action and attribute recognition than top scoring, patch-based alternatives for object and scene classification~\cite{disc2, MDPM, maxmargin}. The latter do not seem to generalize well to the action and attribute case because these tasks need more fine-grained mid-level visual elements to make discrimination between similar classes. The rest of the paper is organized as follows. Related work is discussed in section \ref{sec:related}. Section~\ref{sec:proposed} describes our framework and new CNN for the mining and detection of discriminative patches for human action and attribute classification. Section~\ref{sec:exps} evaluates our method and compares the results with the state-of-the-art. Section~\ref{sec:conclusion} concludes the paper. \section{Related Work} \label{sec:related} This section first discusses action and attribute recognition in the pre-CNN era. It then continues with a short description of the impact that CNNs have had in the action and attribute recognition domain. Finally, we focus on the mid-level features that this paper shows to further improve performance. \paragraph{Action and Attribute Recognition.} Action and attribute recognition has been approached using generic image classification methods~\cite{rel1,rel2,Spatialpyramid}, but with visual features extracted from human bounding boxes. Context cues are based on the objects and scene visible in the image, e.g. the mutual context model \cite{contextrel4}. The necessary annotation of objects and human parts is substantial. Discriminative part based methods like DPM~\cite{DPM} have been state-of-the-art for quite a while. Inspired by their performance, human poselet methods \cite{poselet1,Berkeley_Attributes} try to capture ensembles of body and object parts in actions and attributes. Maji et al. \cite{Poselets} trained dedicated poselets for each action category. In the domain of attributes the work by Parikh et al.~\cite{parikh2011relative} has become popular. It ranks attributes by learning a function to do so. Berg et al.~\cite{bergAtt} proposed automatic attribute pattern discovery by mining unlabeled text and image data sampled from the web. Thus, also before the advent of CNNs some successes had been scored. \begin{figure*}[ht] \centering \includegraphics[width=500pt]{Method_Pipline} \caption{Full Pipeline of the proposed method for training mid-level deep visual elements in action and attribute. All the modules are explained in Sec.~\ref{sec:proposed}. The first box, which is the baseline of our work, initially cluster patches. The second box propose the introduced iterative process, and contains 3 main blocks. The final block takes trained classifiers and patch features of the second box after convergence, and classify images based on their action or attribute.} \label{fig:2} \end{figure*} \paragraph{CNN powered Approaches.} Convolutional neural networks (CNN) have since defined the state-of-the-art for many tasks, incl. image classification and object detection \cite{alexnet,lecunCNN,RCNN,fastRCNN}. Many researchers proposed new CNN architectures or innovative methods on top of a CNN. Girshick et al.~\cite{RCNN} proposed a novel state-of-the-art object detection scheme (RCNN) by extracting CNN features from object region proposals. Gkioxari et al.~\cite{gkioxari2014r,RCNNstar} used a scheme similar to RCNN for action classification and detection, and for pose estimation. Zhang et al. \cite{PANDA} used HOG-poselets to train a CNN-based part-based model for attribute classification. They achieved a nice gain over previous work. There also is recent work that trains models based on parts and poses \cite{birdCNN, RCNN*}. Zhang et al. \cite{birdCNN} obtained a good performance with a part-based RCNN for bird species classification. The part-based RCNN can discriminate birds by learned models of their parts, by fine-tuning a CNN trained on ImageNet. \cite{deepposelet} trained a deep CNN with prepared HOG poselets as training data and detected humans based on the resulting deep poselets. Recently Gkioxari et al.~\cite{RCNN*} proposed to train human body part detectors, e.g. for the head and torso, based on CNN pool5 feature sliding window search and combined them with the whole body box to train a CNN jointly. They showed that for the task of action and attribute classification, performance can be improved by adding such deep body part detectors to the holistic CNN. This work therefore suggests that adding dedicated patch analysis is beneficial. \paragraph{Discriminative Mid-level feature learning} Mid-level visual learning aims at capturing information at a level of complexity higher than that of typical “visual words”. Mining visual elements in a large number of images is difficult since one needs to find similar discriminate patterns over a very large number of patches. The fine-grained nature of our action and attribute tasks further complicates this search. \cite{disc1,disc2,disc3,disc4} describe methods for extracting clusters of mid-level discriminative patches. Doersch et al.~\cite{disc2} proposed such a scheme for scene classification, through an extension of the mean-shift algorithm to evaluate discriminative patch densities. Naderi et al.~\cite{naderiICLR} introduce a method to learn part-based models for scene classification which a joint training alternates between training part weights and updating parts filter. One of the state-of-the-art contributions in mid-level element mining is \cite{MDPM}, which applies pattern mining to deep CNN patches. We have been inspired by the demonstration that the mining improves results. To the best of our knowledge, the use of CNN mid-level elements for action and attribute classification, as is the case in this paper, is novel. Moreover, given the fine-grained nature of these challenges, we propose a new method to get more discriminative mid-level elements. The result is a performance better than that of competing methods. \section{Method} \label{sec:proposed} In this section, we go through all our new framework for finding discriminative patch clusters and also our convolutional neural network for precise describing of patches. In the first part of this section we talk about the motivation and give an overview of solution. Second part describes our proposed pipeline of mid-level patch mining and its contained blocks. Third part of the section introduces our proposed deep convolutional network for patch learning and the idea behind it. And in the final part we summarize that how we use mid-level visual elements in actions and attributes class-specific classifiers. \subsection{Approach overview} \hamed{ We address an approach using mid-level deep visual patterns for actions and attributes classification which are fine-grained classification tasks. Applying discriminative patches or mid-level pattern mining state-of-the-arts like \cite{disc2,MDPM} to these tasks can not perform very promising as much as in the more generic classification tasks like scenes or object recognition (as we show in the experiments Sec \ref{sec:exps}). The pattern mining algorithm \cite{MDPM} maps all data points to an embedding space to performs the association rule based clustering. For the embedding space, it fine-tunes AlexNet \cite{alexnet} for action or attribute recognition and uses its {\em fc7} layer to extract deep feature embedding. Our main insight in this paper is that a better embedding can improve the quality of clustering algorithm. We design an iterative algorithm where in each iteration, we improve the embedding by training a new CNN to classify cluster labels obtained in the previous iteration. In addition, we believe that aggregating the information and context from whole human body with specific action or attribute label with patches can improve the clusters of mid-level elements. Hence, we modify the architecture of AlexNet to concatenate features from both patch and the whole human bounding box in an intermediate layer (Fig.\ref{fig:3}). We show that learning the embedding using this new architecture outperforms the original AlexNet fine-tuned using patch images alone. Moreover, in each iteration, we purify the clusters by removing the patches that are scored poorly in the clustering. Subsequently, to classify actions and attributes by discriminative patches, we use a similar representation in \cite{MDPM,midObj} which more details about it come in Sec \ref{sec:finalClassify}. In the next part, we reveal more about the components of our pipeline. Finally, we show that the newly learned clusters produce better representations that outperform state-of-the-art when used in human action and attribute recognition. Our contributions are two-fold: (1) designing an iterative algorithm contains an expert patch CNN to improve the embedding, (2) proposing new patch CNN architecture training to use context in clustering the patches. } \subsection{Pipeline Detailes} \label{sec:Blocks} \hamed{ As shown both in Fig.\ref{fig:2} and Algorithm.\ref{alg1}, our iterative algorithm consists of four blocks which are described in more details in this section. } \ignore{ As it can be inferred from the Figure \ref{fig:2} our proposed pipeline consists of four main blocks. In this section we describe each of the blocks of pipeline with more details. } \paragraph{Initial feature extraction and clustering} \hamed{ The first block clusters image patches discriminatively using Mid-Level Deep Pattern Mining (MDPM) algorithm \cite{MDPM}. Given, a set of training images annotated with humans' actions and their bounding boxes, it extracts a set of patches from the person bounding box and learns clusters that can discriminate between actions. The MPDM method, building on the well-known association rule mining which is a popular algorithm in data mining, proposes a pattern mining algorithm, to solve mid-level visual element discovery. This approach in MDPM makes it interesting method because the specific properties of activation extracted from the fully-connected layer of a CNN allow them to be seamlessly integrated with association rule mining, which enables the discovery of category-specific patterns from a large number of image patches . They find that the association rule mining can easily fulfill two requirements of mid-level visual elements, representativeness and discriminativeness. After defining association rule patterns, MDPM creates many mid-level elements cluster based on shared patterns in each category and then applying their re-clustering and merging algorithm to have discriminative patch cluster. We use the MDPM block to have initial mid-level elements clusters to move further on our method. } \ignore{ The first block of the system aims to initially extracting patch features and clustering these initial patches. This block consists of two sub-blocks, the first sub-block is a convolutional neural network which has been trained on cropped images of person in the specific dataset of the task. We densely extract patches of each input image in 3 different scales and use these patches as input of the network to extract feature vector of each patch. The second sub-block is Mid-Level Deep Pattern Mining. The MDPM Block aims to find dense clusters of each class which discriminate their original action or attribute class to other classes. The MPDM method, building on the well-known association rule mining which is a popular algorithm in data mining, proposes a pattern mining algorithm, to solve mid-level visual element discovery. This approach in MDPM makes it interesting method because the specific properties of activation extracted from the fully-connected layer of a CNN allow them to be seamlessly integrated with association rule mining, which enables the discovery of category-specific patterns from a large number of image patches . They find that the association rule mining can easily fulfill two requirements of mid-level visual elements, representativeness and discriminativeness. After defining association rule patterns, MDPM creates many mid-level elements cluster based on shared patterns in each category and then applying their re-clustering and merging algorithm to have discriminative patch cluster. We use the MDPM block to have initial mid-level elements clusters to move further on our method. } \paragraph{Training patch clusters CNN} \hamed{ Our main insight is that the representation of image patches plays an important role in clustering. Assuming that the initial clustering is reasonable, in this block, we train a new CNN to improve the representation. The new CNN is trained so that given patch images, it predicts their cluster label. This is in contrast to the initial CNN that was learned to classify bounding box images to different action categories. We believe learning this fine-grained classification using discriminative patch cluster CNN results in a better representation for clustering. } \newcommand{\nosemic}{\SetEndCharOfAlgoLine{\relax} \newcommand{\dosemic}{\SetEndCharOfAlgoLine{\string;} \newcommand{\pushline}{\Indp \newcommand{\popline}{\Indm\dosemic \begin{algorithm} \caption{Iterative mid-level deep pattern learning.}\label{alg} \nosemic \textbf{Input:} Image set ($\textbf{I}$ , $\textbf{L}$) \; Extract dense patche: $\textbf{P}^i_j$ (jth patch of ith image) \; Extract initial features $\textbf{F}^i_j$ and initial cluster labels $\textbf{C}^i_j$ \; \While{Convergence}{ \textbf{$CNN_{Patch}$} = Train\_CNN($\textbf{P}$,$\textbf{C}$) \; $\textbf{F} \leftarrow$ Extract\_CNN\_Feature($CNN_{Patch}$,$\textbf{P}$) \; $\textbf{C} \leftarrow$ Update\_Cluster($\textbf{F}$,$\textbf{C}$) \; $\textbf{W}$ = Train\_Patch\_Classifier($\textbf{F}$,$\textbf{C}$) \; $\textbf{S}$= Compute\_Score($\textbf{W}$,$\textbf{F}$) \; \For {all patches}{ \If {$S^i_j<th$}{ Eliminate $P^i_j$} } } \textbf{Output:} Mid-Level Pattern Clusters ({$\textbf{C}$}) \label{alg1} \end{algorithm} \ignore{ In this block we train our patch clusters convolutional network, with new inputs and outputs to solve the problem of feature extraction in the initial block. Densely extracted patches from images are inputs of this network, and the outputs are the computed sub-category labels by the initial clustering of MDPM block or the sub-category labels, which computed in the previous step of the iteration. As we propose a new network in this block, more details of this block described in the section \ref{sec:patchCNN}. } \paragraph{Updating clusters} \hamed{ Now that a representation is learned by a newly trained CNN, we can update the clusters again using MDPM to get a better set of clusters that match the new representation. Since populating mid-level clusters in MDPM is time consuming, we freeze the first level of clustering and update the clusters by repeating re-clustering and merging using the new representations. This results in better clusters. Finally, we train new set of LDA classifiers to detect the clusters. The modification to MDPM to do re-clustering is described in Section \ref{ExperimentalSetup}. } \ignore{ The consequence of network training in the previous block is modification of feature space. Therefore we have updated features vectors for all of the instances. Using previous sub-class labels in clustering of these new features reduces the positive effects of training the convolutional network. Wherefore updating clusters is needed. On the other hand if we use a common clustering algorithm it may harm our previous knowledge about sub-clusters, which were based on finding simultaneously dense and discriminative clusters. To solve the issue, we just use cluster updating and merging of MDPM to obtain updated clusters of extracted features or embedding from patches. The changes on MDPM block to do re-clustering described in Experiments section \ref{ExperimentalSetup}. By updating clusters we need a new classifier, therefore we use LDA, same as in MDPM block, to train classifiers on the updated features and clusters. } \paragraph{Harvesting patches} \hamed{ In order to improve the purity of clusters, we clean the clusters by removing patches that do not fit well in any cluster. We do this by thresholding the confidence value that LDA classifiers produce for each cluster assignment. Finally, we pass the new patches with associate cluster labels to learn a new CNN based representation. In the experiments, do cross validation, and stop the iterations when the performance on the validation set stops improving. } \ignore{ We see that the MDPM mid-level patterns do not have enough fine-grained discrimination power, therefor iterating between MDPM block and training patch network by the output of these extracted sub-classes will not have such improvement in discrimination of output clusters to classify action and attribute. We need to harvest the output clusters of MDPM before using them for training network. We do this procedure by adaptive thresholding on classification score of each patch, which computed by the trained LDA classifier on the sub-category classes. } \begin{figure*}[ht] \centering \includegraphics[width=500pt]{Method_Model} \caption{Overview of proposed Mid-level Deep Pattern Network. To train this CNN for mid-level discriminative patches, we concatenate the {\em conv5} layers of patch and the person regions to abstract the visual distinctive information of the patch with holistic clue of the person who is performing an action or has a specific attribute.} \label{fig:3} \end{figure*} \subsection{Mid-level Deep Patterns Network} \label{sec:patchCNN} \hamed{ In updating the representation, we train a CNN to predict the cluster labels for given image patches. This is a challenging task for the network since clusters are defined to be action or attribute specific, so they can discriminate between actions. However, the patch image may not have enough information to discriminate between actions. Hence, to increase the discrimination power of the representation, we modify the network architecture to add the human bounding box image as extra contextual information in the network input (Fig. \ref{fig:3}). Following AlexNet architecture, we pass both patch image and the whole bounding box image to the network and concatenate the activations in {\em conv5} layer to form a larger convolutional layer. To train our mid-level deep patterns CNN, we try fast RCNN \cite{fastRCNN}. In training process of fast RCNN for patch learning, we push two region: patch and the croped image of person. An adaptive max pooling layer takes the output of the last convolutional layer and a list of regions as input. We concatenate the ROI-pooled {\em conv5} features from two regions and then pass this new {\em conv5}(concatenated) through the fully connected layers to make the final prediction. Using fast RCNN helps us to have an efficient, fast and computationally low cost CNN layers calculations, since convolutions are applied at an image-level and are afterward reused by the ROI-specific operations. Our network is using a pre-trained CNN model on ImageNet-1K with Alex-Net\cite{alexnet} architecture, to perform fine-tuning and learn patch network. } \ignore{ Our proposed Convolutional Network for patch feature extraction has been shown in Figure \ref{fig:3}. We propose this architecture instead of the common Alex-Net Architecture \cite{alexnet} to train an effective CNN to obtain more discrimination from extracted features of each patch clusters in the image. Our proposed network extracts Conv5 layer of both patch and the bounding box of person, then by concatenating these two layers and connecting to the fully connected layers, uses the local features beside the global features of the image for a specific patch. The other layers of the network are same as the Alex-Net. To train our mid-level deep parts CNN, we try fast RCNN \cite{girshick15fastrcnn}. In training process of Fast RCNN for patch learning, we push two region: patch and the croped image of person. An adaptive max pooling layer takes the output of the last convolutional layer and a list of regions as input. We concatenate the ROI-pooled features from two regions and then pass this new Conv5(concatenated) through the fully connected layers to make the final prediction. Using Fast RCNN helps us to have an efficient, fast and computationally low cost CNN layers calculations, since convolutions are applied at an image-level and are afterward being reused by the ROI-specific operations. Our network is using a trained CNN model on ImageNet-1K with Alex-Net\cite{alexnet} architecture, to perform fine-tuning and learn patch network. The reason of proposing a new architecture for the network is that we want to train our network on the patches and their correspondence sub-category labels. Convolutional neural networks, in the training phase, try to find convolutional filters and fully connected weights in a way to classify the training images by their ground truth label as accurate as possible. As we mentioned above, our sub-category labels of the patches are not ground truth labels of the data, these labels are extracted from the MDPM block, The only labels which are ground truth and extracted from the annotations are the action or attribute labels of images. So the important point in training this network, which works on the patches, is to classify sub-categories in a way that, they remember they parent category of action or attribute. This goal achieves by adding the whole body image and concatenating conv5 layer of this image with the conv5 layer of the patch. By so doing, the network remembers the original image which the patch extracted from, and the corresponding label of the original image. We can conclude that our proposed network reduces the freedom of network in labeling the patch by each of the sub-categories of all labels, it will more probable to label the patch by one of the sub-categories of the original label of image. } \subsection{Action and attribute classifiers} \label{sec:finalClassify} \hamed{ After learning the mid-level pattern clusters, we use them to classify actions and attributes. Given an image, we extract all patches and find the best scoring one for each cluster. To construct the image representation for action or attribute on each image, we use the idea of mid-level elements for object detection \cite{midObj}, by taking the max score of all patches per mid-level pattern detectors per region encoded in a 2-level (1 * 1 and 2 * 2) spatial pyramid. This feature vector represents occurrence confidence of elements in the image. This results in a rich feature for action and attribute classification since the clusters are learned discriminatively for this task. Finally, we pass the whole bounding box through overall CNN trained on action or attribute labels and append it's {\em fc7} activations to obtained feature. } \ignore{ In the final part of the pipeline we aim to classify action and attribute images by the extracted mid-level pattern clusters which are obtained by previous blocks. We first describe the classifier block of action classification and then specify attribute classification method. \paragraph{Action Classification} After the convergence of the iterative process. Cluster labels of patches and consequently trained LDA patch classifiers of sub-categories can be used to perform action classification. To present the final feature vector of each image, we use the extracted Fc7 feature of each patch from the trained patch network of last iteration. By having these features and mid-level pattern cluster classifiers, we obtain scores of all patches in each image. To construct the image representation for action on each image, we use the idea of mid-level elements for object detection \cite{midObj}, by taking the max score of all patches per detector per region encoded in a 2-level (1 * 1 and 2 * 2) spatial pyramid. This feature vector represents occurrence confidence of elements in the image. At the final stage we concatenate this feature with the CNN fully connected feature of the whole human body in image and train and then test a multi class SVM on these extracted features and the 10 class action label of the Image. \paragraph{Attribute Classification} Attribute classification task needs some modification to the action classification. The main reason of needing them is, in one hand the action classes oppose each other and in the other attribute classes are independent to each other. Needed modifications in the initial patch feature extraction network and MDPM clustering block described in implementation details of section \ref{attr_implement}. Extracting feature representation of attributes is same as the action classification task, the only difference is the final classification implements by separated two class SVMs for each attribute class. } \section{Experiments} \label{sec:exps} We evaluate our algorithm on two tasks: action classification and attribute classification in still images. In both tasks, we are folowing the stantdard PASVAL VOC \cite{pascal} setting that the human bounding box is given in the inference time. The first section of our evaluations are on the PASCAL VOC \cite{pascal} and Stanford 40 \cite{Stanford40} action datasets, and the second part is on the Berkeley attributes of people dataset \cite{Berkeley_Attributes}. \subsection{Experimental Setup} \label{ExperimentalSetup} \paragraph{Common properties of the networks} All of the networks have been trained using the caffe CNN training package \cite{caffe} with back-propagation. We use weights of the trained Network on ImageNet dataset \cite{imagenet} as initial weights and fine-tune our networks on specific datasets and with different properties according to the task. We set the learning rate of CNN training to 0.0001, the batch size to 100. \paragraph{Initial feature extraction network} The fine-tuning of the network is done on the cropped images of each person as input and the Action or Attribute label of images as output of the network. Then we use {\em fc7} feature vector of body image or extracted patches as input of the MDPM (Mid-level Deep Pattern Mining) \cite{MDPM} block. \paragraph{Mid-level deep patterns network} Input images of this network are patches that extracted from cropped body image in 3 different scales (128*128, 160*160, 192*192 patches from a resized image with stride of 16). The output layer of this network is cluster labels that computed by MDPM block. \begin{table*}[t] \centering \resizebox{\textwidth}{!}{ \begin{tabular}{ c | c c c c c c c c c c | c } AP(\%) & Jumping & Phoning & Playing Instrument & Reading & Riding Bike & Riding Horse & Running & Taking Photo & Using Computer & Walking & mAP\\ [0.5ex] \hline CNN & 76.2 &46.7 &75.4 &42.1 &91.4 &93.2 &79.1 &52.3 &65.9 &61.8 & 68.4\\ [0.5ex] CNN+MDPM & 76.8 &47.7 &75.6 &44.1 &90.4 &93.8 &80.1 &53.6 &65.4 &62.7 & 69\\ [0.5ex] Ours\_AlexNet\_iter1 & 76.9 &48.2 &74.9 &46.8 &91.6 &93.9 &82.1 &54.3 &66.4 &63.5 & 69.9\\[0.5ex] Ours\_AlexNet\_iter2 & 78.5 &49.3 &77.9 &50.2 &92.1 &94.2 &82.4 &56.4 &70.1 &64.3 & 71.5\\[0.5ex] Ours\_AlexNet\_iter3 & 78.1 &49.8 &77.8 &51.2 &92.1 &94.6 &82.7 &56.5 &70.3 &64.2 & 71.7\\[0.5ex] \hline Ours\_PatternNet\_iter1 & 80.1 &53.7 &78.3 &55.2 &93.2 &94.8 &84.7 &57 &72.2 &66.2 & 73.5\\ [0.5ex] Ours\_PatternNet\_iter2 & 81.2 &55.4 &80.1 &60.1 &94.3 &95.1 &86.7 &59.1 &73.3 &67.8 & 75.3\\ [0.5ex] \textbf{Ours\_PatternNet\_iter3} & 81.4 &55.3 &80.3 &60.3 &95 &94.8 &86.2 &59.4 &73.6 &68 & \textbf{75.4}\\ [2ex] \end{tabular} } \caption{Average Precision on the PASCAL VOC dataset validation set. The two first rows are baselines of our method, which are results of training CNN on pascal and using MDPM to classify them. The ours\_Alex methods rows are the results of iterating 1,2 and 3 times in the iterative process of pipeline using the Alex-Net architecture as patch CNN training block. The Ours\_PatternNet are same as previous ones by using our proposed mid-level deep patterns network.} \label{tab:1} \end{table*} \begin{table*}[t] \centering \resizebox{\textwidth}{!}{ \begin{tabular}{ c | c c c c c c c c c c | c } AP(\%) & Jumping & Phoning & Playing Instrument & Reading & Riding Bike & Riding Horse & Running & Taking Photo & Using Computer & Walking & mAP\\ [0.5ex] \hline CNN & 77.1 &45.8 &79.4 &42.2 &95.1 &94.1 &87.2 &54.2 &67.5 &68.5 & 71.1\\ [0.5ex] CNN+MDPM & 77.5 &47.2 &78.3 &44.2 &94.2 &95.3 &89.2 &56.4 &68.1 &68.3 & 71.9\\ [0.5ex] Action Poselets & 59.3 & 32.4 & 45.4 & 27.5 & 84.5 & 88.3 & 77.2 & 31.2 & 47.4 & 58.2 & 55.1\\ [0.5ex] Oquab et al & 74.8 & 46.0 & 75.6 & 45.3 & 93.5 & 95.0 & 86.5 & 49.3 & 66.7 & 69.5 & 70.2 \\ [0.5ex] Hoai& 82.3 & 52.9 & 84.3 & 53.6 & 95.6 & 96.1 & 89.7 & 60.4 & 76.0 & 72.9 & 76.3\\ [0.5ex] Gkioxari et al & 77.9 & 54.5 & 79.8 & 48.9 & 95.3 & 95.0 & 86.9 & 61.0 & 68.9 & 67.3 & 73.6\\[0.5ex] \hline Ours\_AlexNet & 79.6 &51.7 &79.7 &50.8 &94.6 &95.8 &88.9 &58.4 &71.1 &68.7 & 73.9\\ [0.5ex] \textbf{Ours\_PatternNet} & 81.4 & 53.8 & 86 & 54.9 & 96.8 & 97.5 & 91.4 & 62.1 & 78.0 & 74.5 & \textbf{77.6}\\ [2ex] \end{tabular} } \caption{Average Precision on the PASCAL VOC dataset test set and comparison with previous methods. The first two rows are our baselines which reported on the test set, the next rows of the above part are previous methods based on 8 layer convolutional network, same as ours. The ours\_Alex and ours\_PatternNet are the results of testing our proposed pipeline with Alex-Net and our Pattern-Net architectures, on the test set of PASCAL VOC, until the convergence of iteration (3 iterations).} \label{tab:2} \end{table*} \paragraph{Mid-level deep pattern mining block.} We use MPDM block with the mentioned properties in \cite{MDPM} for the initial feature extraction and clustering block. While updating clusters in our iterative patch clusters training, we use a part of MPDM algorithm which tries to merge and reconfigure clusters. The new obtained CNN representations for patches help updating clusters to be performed more precise. We apply MDPM patch mining with 50 cluster per each category. \subsection{Action Classification.} For the action Classification task, we evaluate our mid-level pattern mining pipeline and proposed patch CNN network performances on PASCAL VOC and Stanford 40 action datasets. \paragraph{Dataset.} The PASCAL VOC action dataset \cite{pascal} includes 10 different action classes including Jumping, Phoning, Playing Instrument, Reading, Riding Bike, Riding Horse, Running, Taking Photo, Using Computer, Walking, and an Other class consists of images of persons, which has no action label. The dataset has 3 splits of training, validation and test set. ~\\~\\ The Stanford 40 action dataset \cite{Stanford40} contains total of 9532 images and 40 classes of actions, split into train set containing 4000, and test set containing 5532 instances. \paragraph{Implementation detailes.} The training and fine-tuning of the initial CNN and pattern CNN, have been done only on PASCAL VOC dataset. It means to evaluate on Stanford40, we just use convolutional networks of action and patch clusters, which are trained on PASCAL and afterward run the MDPM cluster mining and configure clusters for Stanford40. In the test time we will evaluate the results on both PASCAL VOC and Stanford 40 datasets. The reason of training patch CNN networks on a dataset with less classes than the test dataset is to evaluate discrimination power of our proposed method's extracted patches. In the results section we show that our method achieves state-of-the-art on the both of PASCAL VOC and Stanford 40 dataset, which consequently with results on Stanford40, the discrimination power of extracted patches has been proved. \begin{table} \begin{center} \begin{tabular}{|l|c|} \hline Method & AP(\%) \\ \hline\hline Object bank & 32.5 \\ LLC & 35.2 \\ SPM & 34.9 \\ EPM & 40.7 \\ CNN\_AlexNet & 46\\ CNN+MDPM & 46.8\\ \hline Ours\_AlexNet& 49\\ \textbf{Ours\_PatternNet}& \textbf{52.6}\\ \hline \end{tabular} \end{center} \caption{Average Precision on the Stanford40 action dataset. The used initial CNN and patch CNNs in this section are trained on the PASCAL VOC dataset, and we use these networks to extract patches form Images of Stanford40 dataset.} \label{tab:4} \end{table} \begin{table*}[t] \centering \resizebox{\textwidth}{!}{ \begin{tabular}{ c | c c c c c c c c c | c } AP(\%) & is male & has long hair & has glasses & has hat & has t-shirt & has long sleeves & has shorts & has jeans & has long pants & mAP\\ [0.5ex] \hline CNN$_{att}$ & 88.6 &82.2 &50.1 &83.2 &60.1 &86.2 &88.3 &88.6 &98.2 & 80.6 \\ [0.5ex] CNN$_{att}$+MDPM & 88.8 &84.2 &54.1 &83.4 &64.3 &86.4 &88.5 &88.8 &98.3 & 81.9 \\ [0.5ex] PANDA & 91.7 &82.7 &70 &74.2 &49.8 &86 &79.1 &81 &96.4 & 79 \\ [0.5ex] Gkioxari et al & 91.7 &86.3 &72.5 &89.9 &69 &90.1 &88.5 &88.3 &98.1 & 86\\ [0.5ex] \hline Ours\_AlexNet & 90.8 &84.2 &61.4 &88.9 &67.1 &88.1 &89.2 &89.3 &98.3 & 84.1\\ [0.5ex] \textbf{Ours-PatternNet} & 91.8 &88.4 &71.1 &88.9 &70.7 &91.8 &88.7 &89.3 &98.9 & \textbf{86.6}\\ [2ex] \end{tabular} } \caption{Average Precision on the Berkeley Attributes dataset and comparison with previous methods. The CNN$_{att}$ and CNN$_{att}$+MDPM are the baselines of the work, which their convolutional networks trained on train set of Berkeley attributes dataset. The results of PANDA method with 5 layer network and 8 layer network results of Gkioxari et al is reported in last rows of above part. The bottom of the table shows the results of our proposed pipeline using both Alex-Net and Our Patch-Net until the convergence of the iteration process (3 iterations).} \label{tab:3} \end{table*} \begin{figure*}[ht] \resizebox{18cm}{!}{ \includegraphics[width=500pt]{Fig4} \label{fig:4} } \caption{Explored deep mid-level visual patterns of different categories of actions and samples detected from top scored pattern and aggregated scores over all image from PASCAL VOC 2012 action dataset. In each block of figure, small patches are representatives from most discriminative patches.} \end{figure*} \paragraph{Results.} We report the result of our baseline, and proposed method on the PASCAL VOC validation set in Table \ref{tab:1}. The baseline 'CNN' in the first row of table is AlexNet trained on PASCAL VOC dataset using SVM on the {\em fc7} layer features. The second row which is the output of our initial feature extraction and clustering block, named 'CNN+MDPM' reports the result of SVM training on the concatenated feature vector of convolutional network {\em fc7} and the 2500 dimensional feature vector output of MDPM block (50 cluster * 10 category * 5 spatial pyramid region). The next three rows of the table with names of 'Ours\_AlexNet\_iter1-3' show the result of performing the pipeline using the convolutional neural network architecture of AlexNet and with 1 to 3 iterations. Finally the last three rows are same as previous ones with 1 to 3 iterations applying our proposed pattern CNN architecture. We can conclude from the table that our proposed iterative pipeline and newly proposed CNN architecture can improve the result independently, so the combined method outperform either one alone. The results of our final proposed method in comparison with results of the following methods, Poselets \cite{Poselets} , Oquab et al \cite{oquab2014} ,Hoai \cite{hoai2014} , and Gkioxari et al \cite{RCNN*} on the test set of PASCAL VOC has been shown in Table \ref{tab:2}. As we can see in the table the mean accuracy of our proposed method with the proposed PatternNet outperforms all the previous 8 layer CNN network based methods. The important point in this improvement in result is that most of the mentioned methods were using part detectors based on the part and pose annotations of the datasets which limits the number of annotated training data because of the hardness of pose annotating. In contrast the proposed method does not use any annotation more than action labels and bounding box of person. As we mentioned in the implementation details we evaluate the Stanford40 actions dataset using our final pipeline mid-level patterns CNN - PatternNet\_iter3 - which is trained on PASCAL VOC, and report the results in Table \ref{tab:4}. The result shows that our method improved the results of the previous methods in action classification on this human action dataset. \subsection{Attribute Classification} In this section we report implementation details and results of our method on the Berkeley Attributes of people dataset. We need to train all the networks on the new dataset. \paragraph{Dataset.} The Berkeley attributes of people dataset contains 4013 training and 4022 test examples of people, and 9 Attributes classes, is male, has long hair, has glasses, has hat, has t-shirt, has long sleeves, has shorts, has jeans, has long pants. Each of the classes labeled with 1,-1 or 0, as present, absent and un-specified labels of the attribute. \paragraph{Implementation details.} \label{attr_implement} In contrast to action classification task in attributes classification, more than one label can be true for each instance, it means that classes in attribute classification do not oppose each other. Therefore instead of using the softmax function as the loss function in the last layer of the initial convolutional network, which forces the network to have only a true class for each instance, we use cross entropy function for the task of attributes classification. The other block with the same assumption in opposition of classes is MDPM block which try to find some cluster for each class such that instances of other classes labels as negative to maximize the discrimination of clusters. In the other hand, attribute classes do not oppose each other, so a modification is needed in the MDPM block. We extract discriminative clusters of each class separately, using the positive and negative labels of that class. \paragraph{Results.} We evaluate our method on the Berkeley attributes of people dataset and compare our results on the test set with Gkioxari et al \cite{RCNN*} and PANDA \cite{PANDA} methods in Table \ref{tab:3}. As we show in the table, our baselines, 'CNN$_{att}$' and 'CNN$_{att}$ +MDPM' did not improve the results of previous methods. Even our proposed pipeline with the AlexNet architecture couldn't outperform \cite{RCNN*} which uses trained deep body parts detectors. However, our proposed pipeline with the proposed PatternNet architecture improves the result of attribute classification in comparison with all previous methods. Table \ref{tab:3} shows that although our method have significant improvements in action classification, the method does not have the same margin with the state-of-the-arts in classifying attributes. We believe this is due to the importance of part annotations in training attribute classifier, which is not available in our setting. \section{Conclusion} \label{sec:conclusion} In this work, we have addressed human action and attribute classification using mid-level discriminative visual elements. We proposed a novel framework to learn such elements using a Deep Convolutional Neural Network which also has a new architecture. The algorithm explores a huge number of candidate patches, covering human body parts as well as scene context. We validated our method on the PASCAL VOC 2012 action, the Stanford40 actions, and the Berkeley Attributes of People datasets. The results are good, both qualitatively and quantitatively, reaching the state-of-the-art, but without using any human pose or part annotations. \subsection*{Acknowledgements} This work was supported by DBOF PhD scholarship, KU Leuven CAMETRON project. { \small \bibliographystyle{ieee}
{'timestamp': '2016-08-11T02:08:30', 'yymm': '1608', 'arxiv_id': '1608.03217', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03217'}
arxiv
\section{Introduction} Causality \cite{Lamp:1978,Schw+Matt:1994} is an essential for our perception of the physical world, and of our relations to other entities. If one puts a cup on a table, and looks back at it, one expects it to be there. One also expects to get a reply to one's postcards, \textbf{after} they were sent, and not before. Given the fault-tolerance and high availability expected of internet-based services today, distributed algorithms have become ubiquitous. One duty of these algorithms is to order events totally across multiple replicas of a service. This total order is required to ensure computation determinism; given the requirement of having multiple replicas appear as a single system, each replica must implement a state machine which observes the same events in the same order~\cite{Schn:1990}. However, because of the amount of coordination required, a total order in the entire distributed system is not always feasible while maintaining availability~\cite{Gilb+Lync:2002}. Given the intractability of a total order, techniques that favour a partial order based on causality are explored for they express user's \textbf{intent}. For a key-value store, one's writes may, e.g., be directed to one replica, and, subsequent reads served from a replica which has not yet received those writes. If we consider the canonical example of an access control list for viewing photos~\cite{Lloy+Free+Kami+Ande:2011}, one would expect that a write operation removing Eve from having access to Alice's photos prior to Alice uploading a photo she did not want Eve to see, would be observed in this order by Eve when performing read operations. However, tracking causality can be very expensive in terms of metadata size; more so when interactions amongst many distinct entities are targeted \cite{Char:1991}. Devising scalable solutions to causality tracking is a demanding problem \cite{Lloy+Free+Kami+Ande:2011,Serg+Baqu+Gonc+Preg+Font:2014} to the extent that some solutions even accept to lose causal information by pruning metadata \cite{Deca+Hast+Jamp+Kaku+Laks+Pilc+Siva+Voss+Voge:2007}. Be it because available resources are limited (say to an edge device) or because a replica (say in a data centre) is temporarily out-of-sync, only a partial view of the system causality might be available. There is not much study on dealing with that partiality of knowledge, however. In this paper, we address that problem via a proof-theoretic modelling for partial causality knowledge of distributed systems. Partiality is not a loss in our model: What is not stored might be deducible -- acting in favour of metadata size reduction. Contributions of this paper are as follows: \begin{enumerate} \item We model distributed causality such that the holistic system and the partial causal knowledge of a device are categorically distinct (Definitions~\ref{Defn:WoE} and \ref{Defn:MCosm}). \item We offer rules for deducing causality when a device is online (Definition~\ref{Defn:Micro.Decision}) and prove its computability (Theorem~\ref{Theo:Rules.Comp}) and consistency (Theorem~\ref{Theo:Micro.Rules.Const}). \item We show that deduction of causality with partial knowledge is strictly less accurate than the holistic causal knowledge (Lemma~\ref{Lemm:WoE.More.Accurate.Micro}) and that the deductions of different devices do not conflict (Corollary~\ref{Corr:Mu.Hats}). \item We offer rules for a device to deduce causal information independent of new causal data from outside, e.g., when offline (Definition~\ref{Defn:Offline.Rules}) and prove its consistency with the online rules (Lemmata~\ref{Lemm:Offline.Not.Refute.Online} and \ref{Lemm:Offline.Not.Disagree.Online}). We also prove a related folklore wrong (Lemma~\ref{Lemm:Sample.Refutation.1}) using the latter machinery. \item We craft a notion of bisimilarity (Definition~\ref{Defn:Micro.Analog}) and prove that the order of arrival of new causal data is insignificant for bisimilar devices (Theorem~\ref{Theo:For.Order.Irrelevant}). \item We craft another notion of bisimilarity (Definition~\ref{Defn:Back.Bisimilarity}) to prove that the order of removal of causal data is also insignificant for bisimilar devices (Theorem~\ref{Theo:Back.Order.Irrelevant}). \end{enumerate} Unlike traditional approaches to causality modelling that store a partial order of known causally related events and consider non related events as concurrent events, we explicitly model concurrency information and provide a broader spectrum of relations amongst events. \paragraph*{Real-World Benefits} \label{Sect:Benefits} The technical developments of this paper are beneficial in the following ways: Firstly, whilst being more general, our forward bisimilarity (Definition~\ref{Defn:For.Bisimilarity}) captures replication: like-stated replicas are bisimilar. Replication in distributed systems serves fault-tolerance in that, for example, a like-stated replica will cover for a crashed replica. The idea is that, because the replica providing the cover was like-stated, the crash will go \textbf{unobserved}. Our forward bisimilarity serves that by its formalism for observational equivalence. Secondly, offline decision making (Definition~\ref{Defn:Offline.Rules}) entails that, in presence of network partitions, a device gone offline will still be able to make (useful) new deductions (e.g., Lemma~\ref{Lemm:Sample.Refutation.1}). It only is that the new deductions may not be at the same level of accuracy as those of its bisimilar devices that are still connected or when the device itself retrieves connection (Lemma~\ref{Lemm:WoE.More.Accurate.Micro}). That is the service offline decision making provides to fault-tolerance. Thirdly, Theorems~\ref{Theo:For.Order.Irrelevant} and \ref{Theo:Back.Order.Irrelevant} are formal characterisations for strong eventual consistency---so long as all the correspondences arrive/leave, the replicas are causally consistent, i.e., forward/backward bisimilar---serving key-value stores. \section{Worlds of Events and Microcosms} Call a binary relation $R$ a strict partial order on a set $P$ when $R$ is irreflexive, asymmetric, and transitive. Then, we say that $(P, R)$ is a strict poset. For a strict poset $(T, R)$, when $R$ is also total, call $(T, R)$ a strict chain. Let $R$ be a relation on a set $S$. For a subset $U$ of $S$, the symbol $R_{|U}$ denotes $R$ restricted to $U$. We use ``$\veebar$" for the exclusive or of mathematical logic. For a set $S$, write $|S|$ for the cardinality of $S$. As is common in Set Theory, $\aleph_0$ denotes the cardinality of Natural Numbers ($\mathbb{N}$). Throughout this paper, ``\ensuremath{{}_{\textnormal{\textemdash}}}" is our wild card; its usage expresses our lack of interest in the exact details of what ``\ensuremath{{}_{\textnormal{\textemdash}}}" has replaced. \begin{definition} \label{Defn:WoE} Call $W(<, \parallel)$ a world of events when: \begin{enumerate} \labitem{W1}{Misc:W1} $W$ is an infinitely countable set (i.e., $|W| = \aleph_0$) of events that are ranged over by $e_1, e_2, \dots, e, e', \dots$, \labitem{W2}{Misc:W2} $<$ and $\parallel$ are binary relations defined on $W$ that are ranged over by $r_1, r_2, \dots,$ $r, r', \dots$, \labitem{W3}{Misc:W3} $(W, <)$ is a strict poset, \labitem{W4}{Misc:W4} $\parallel$ is irreflexive and symmetric, and \labitem{W5}{Misc:W5} $e_1 \neq e_2$ iff $e_1 \parallel e_2 \veebar e_1 < e_2 \veebar e_2 < e_1$. \end{enumerate} For $e_1, e_2 \in W$, when $(e_1, e_2) \in r$ for $r \in \{<, \parallel\}$, we write $W \vDash e_1\ r\ e_2$ and say $e_1\ r\ e_2$ holds for $W$.$\Square$ \end{definition} The relations $<$ and $\parallel$ denote the familiar \textsf{happens-before} and \textsf{is-concurrent-with}, respectively \cite{Lamp:1978}. Notice that here we define $\parallel$ explicitly \--- whilst the usual derived definition for non strict posets covers the elements that are not related in the order by stating $e_1 \parallel e_2$ iff $e_1 \not\leq e_2 \wedge e_2 \not\leq e_1$. Notice also that, in line with the traditional understanding about it \cite[Observation 1.3]{Schw+Matt:1994}, (\ref{Misc:W4}) does not define $\parallel$ transitive. For a world of events, we take the relation $<>$ (read \textsf{is-causally-related-to})% \footnote{For a use of $<>$ in reality, see the CISE proof system \cite{Gots+Yang+Ferr+Naja+Shap:2016}. In a valid CISE execution, when a pair of events $e$ and $e'$ possess conflicting tokens, it is required that $e <> e'$.} as a syntactic sugar for $< \cup <^{-1}$, namely, $e_1 <> e_2 \ensuremath{\stackrel{\textnormal{\tiny{def}}}{=}} e_1 < e_2 \vee e_2 < e_1$. Hence, $<>$ is symmetric. We can also observe that every distinct pair of events are attributed to exactly one of the basic relations, and that ``$<$'' $\cap$ ``$<^{-1}$'' $\cap$ ``$=$'' $\cap$ ``$\parallel$'' is always $\emptyset$. Fix the set of \textbf{accurate} relations $R = \{<, \parallel\}$. The relation $<>$ is an \textbf{inaccurate} relation in that it does not expose the exact known direction of $<$. We now extend $\vDash$ to $\vDash^*$ for when the inaccurate relation $<>$ is also needed to be taken into consideration. Write $W \vDash^* e_1\ r\ e_2$ iff: $W \vDash e_1\ r\ e_2$; or, $r =\ <>$ and either $W \vDash e_1 < e_2$ or $W \vDash e_2 < e_1$. Note that, unlike $\vDash$, not every distinct pair of events are attributed to a unique relation by $\vDash^*$. In particular, for every $e_1$ and $e_2$ such that $W \vDash e_1 < e_2$, by definition, it is both the case that $W \vDash^* e_1 < e_2$ and $W \vDash^* e_1 <> e_2$. We call $e_1\ r\ e_2$ a correspondence, ranged over by $c_1, c_2, \dots, c, c', \dots$ For a world of events $W$, we also fix $\mathcal{C}^*_W = \{c \mid W \vDash^* c\}$. For $c = e_1\ r\ e_2$, we say $c$ is an accurate correspondence when $r$ is accurate. We call $c$ inaccurate otherwise. \begin{proposition} \label{Prop:WoE.Const} Every world of events $W$ is consistent: $W \vDash e_1\ r\ e_2$ and $W \vDash e_1\ r'\ e_2$ imply $r = r'$. \end{proposition} \begin{definition} \label{Defn:MCosm} Let $W(<, \parallel)$ be a world of events. Call $M(I, E)$ a microcosm of $W$ (write $M \vartriangleleft W$) when: \begin{enumerate} \labitem{M1}{Misc:M1} $I \subset W$ and $|I| < \aleph_0$, \labitem{M2}{Misc:M2} $(I, <_{|I})$ is a strict chain, \labitem{M3}{Misc:M3} $E \subset \mathcal{C}^*_W$ and $|E| < \aleph_0$, \labitem{M4}{Misc:M4} $e_1\ r\ e_2 \in E$ implies that there is no chain of events $e'_1, \dots, e'_n$ in $M$ such that $e_1 = e'_1 <_{|M} \dots <_{|M} e'_n = e_2$ or $e_2 = e'_1 <_{|M} \dots <_{|M} e'_n = e_1$.% \footnote{More on the motivation behind (\ref{Misc:M4}) to follow.} \end{enumerate} Accordingly, call $W$ the enclosing world of $M$ and let $\mathcal{M}_W = \{M \mid M \vartriangleleft W \}$.$\Square$ \end{definition} The difference between the notation we use for worlds of events and the one we use for microcosms might cause confusion at the first glance. In addition to being the world of events, the $W$ in $W(<, \parallel)$ is a set, $<$ and $\parallel$ are relations on which. To the contrary, the $M$ in $M(I, E)$ is only a name for the pair $(I, E)$. Furthermore, $I$ is a set of events, whilst $E$ is a set of correspondences; they are not of the same sort. For an $M(I, E)$, we refer to $I$ as the \textbf{internal} events of $M$, and, to $E$ as the set of \textbf{external} correspondences known to it. When appropriate, we use the alternative notions $I(M)$ and $E(M)$, respectively. Write $e_1 < e_2 \in I$ when $e_1, e_2 \in I$ and $W \vDash e_1 < e_2$. Besides, write $e_1\ r\ e_2 \in M$, when $e_1\ r\ e_2 \in I$ or $e_1\ r\ e_2 \in E$. Write $e \in E$ when $\exists e' \in W.\ e\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e' \in E \vee e'\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e \in E$. Finally, write $e \in M$ when $e \in I$ or $e \in E$. That is how we formalise the notion of microcosm membership informally used in (\ref{Misc:M4}). A microcosm is our abstraction for a single state -- out of the possibly many states -- of a generic device. The enclosing world of events of a microcosm is the abstraction we use for the ecosystem in which a device lives. Certain events can take place locally for a device; in which case, they are stored in the internal events of the respective microcosm. The correspondence between certain events can also be disclosed to a device by the ecosystem; in which case, they are stored in the external correspondences of the respective microcosm. In our model, devices do not get to communicate directly with one another. The ecosystem sits between devices in that news from other devices in the same ecosystem arrives via the ecosystem (as opposed to the other devices themselves). Note that, unlike a world of events, for a microcosm, the relation $<>$ is not a syntactic sugar. To the latter, an $<>$ instance is all the information that is given for the respective pair of events. In that case, whilst no stronger information about the given pair is provided to the microcosm, the enclosing world of events is aware of the exact $<$ direction between the pair. It, nevertheless, follows from irreflexiveness of $<$ that $<>$ is irreflexive too -- both for worlds of events and their microcosms. \begin{exmp} For a microcosm $M$ such that $I(M) = e_1 < e_2 < e_3$, no correspondence $e_1\ r\ e_2$ can exist in $E(M)$ or (\ref{Misc:M4}) will be violated. There is no need for any ``order" to exist between all the events a microcosm knows of -- be it partial or total. $M' = (\varnothing, \{e_1 <> e_2, e_2 <> e_3\})$ is an entirely fine microcosm (perhaps of the same world of events as $M$), in which there is neither a total order nor a partial order between $e_1$, $e_2$, and $e_3$. $M'' = (M' + e3 < e4)$\footnote{Notation defined at the end of section.} is another permissible microcosm -- regardless of whether $e_3 < e_4 \in I(M'')$ or $e_3 < e_4 \in E(M'')$. Note that $M''$ does contain a partial order but no total one. Finally, $M''' = (I(M), \varnothing)$ is yet another valid microcosm, in which there truly is a total order. \end{exmp} \begin{wrapfigure}{r}{0.39\textwidth} \vspace{-2.5em} \begin{center} \hrule \vspace{-1em} $$ \framebox[1.1\width]{$M \sststile{}{\circ} e_1\ r\ e_2$} \qquad \textnormal{where } r \in R \cup \{<>\} $$ $$ \begin{prooftree} e_1\ r\ e_2 \in M \justifies M \sststile{}{\circ} e_1\ r\ e_2 \using \RuleFont{Init} \end{prooftree} $$ $$ \begin{prooftree} M \sststile{}{\circ} e_1 < e_2 \quad M \sststile{}{\circ} e_2 < e_3 \justifies M \sststile{}{\circ} e_1 < e_3 \using \RuleFont{In-Tr} \end{prooftree} $$ $$ \begin{prooftree} M \sststile{}{\circ} e_1 \parallel e_2 \justifies M \sststile{}{\circ} e_2 \parallel e_1 \using \RuleFont{Co-Sym} \end{prooftree} $$ $$ \begin{prooftree} M \sststile{}{\circ} e_1 <> e_2 \justifies M \sststile{}{\circ} e_2 <> e_1 \using \RuleFont{CR-Sym} \end{prooftree} $$ \vspace{-0.5em} \hrule \end{center} \vspace{-0.5em} \caption{Microcosm Initial Judgements} \label{Fig:Init.Rules} \vspace{-6em} \end{wrapfigure} We now introduce the first sort of deduction for microcosms (Definition~\ref{Defn:Init.Judge}). The idea is that such a deduction is for a microcosm to decree on the correspondences it does know of. Later in Section~\ref{Sect:Online.Decision}, we will generalise deduction for a microcosm to also conclude that it does not know the correspondence between a given pair of events. \begin{definition} \label{Defn:Init.Judge} Let $M$ be a microcosm. Judgements of the form $M \sststile{}{\circ} e_1\ r\ e_2$ are called the initial judgements of $M$ when they are derived using the rules in Fig.~\ref{Fig:Init.Rules}. Write $M \not\sststile{}{\circ} e_1\ r\ e_2$ when $M \sststile{}{\circ} e_1\ r\ e_2$ is not true.$\Square$ \end{definition} Note that with ``\ensuremath{{}_{\textnormal{\textemdash}}}'' being existential in nature, the negation acts universally. In particular, $M \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$ stipulates the lack of \textit{any} initial correspondence between $e_1$ and $e_2$ in $M$. Here is an informal account of the rules in Fig.~\ref{Fig:Init.Rules}: \RuleFont{Init} states that every piece of information that is initially provided to a microcosm is reliable in the initial judgements made inside that microcosm. \RuleFont{In-Tr} legislates transitivity of $<$ for initial judgements (regardless of whether the premises come from internal or external knowledge of a microcosm or a combination of those). \RuleFont{Co-Sym} and \RuleFont{CR-Sym} are routine and legislate symmetry for $\parallel$ and $<>$. There are two possible ways a microcosm can evolve upon receipt of new information: (Section~\ref{Sect:Online.Decision} gives more details about the intuition and the semantics of the two evolution mechanisms.) For a microcosm $M$, when $M \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$, write $(M + e_1\ r\ e_2)$ for the microcosm $M$ with the additional information $e_1\ r\ e_2$. We assume that $e_1\ r\ e_2$ is known to be internal or external to the resulting microcosm. Likewise, when $M \sststile{}{\circ} e_1 <> e_2$ (or $M \sststile{}{\circ} e_2 <> e_1$), define $M[e_1 < e_2]$ for the microcosm $M$ in which $e_1 < e_2$ replaces $e_1 <> e_2$ (or $e_2 <> e_1$). \begin{wrapfigure}{r}{0.56\textwidth} \vspace{-2em} \hrule \vspace{-0.6em} \begin{center} \begin{subfigure}[b]{0.25\columnwidth} \includegraphics[width=\textwidth]{NVC1.pdf} \caption{Addition of $e_1 < e_2$ to $M$ violates (\ref{Misc:M4}).} \label{Fig:NVC1} \end{subfigure} \begin{subfigure}[b]{0.25\columnwidth} \includegraphics[width=\textwidth]{NVC2.pdf} \caption{Updating $M$ with $e_1 < e_2$ violates (\ref{Misc:M4}).} \label{Fig:NVC2} \end{subfigure} \linebreak \underline{Legend}: Arrow from $e_1$ to $e_2$ indicates $e_1 < e_2$. Line labelled with ``$<>$'' between $e_1$ and $e_2$ indicates $e_1 <> e_2$. \end{center} \hrule \caption{Illegal for $e'_1 < e_1 < e_2 < e'_2$ whilst $e'_1 <> e'_2 \in M$} \label{Fig:NVCs} \vspace{-2em} \end{wrapfigure} For both addition -- namely, $(M + e_1\ r\ e_2)$ -- and update -- namely, $M[e_1 < e_2]$ -- we assume that the change will not violate (\ref{Misc:M4}). See Fig.~\ref{Fig:NVC1} and \ref{Fig:NVC2} for when careless addition and update violate (\ref{Misc:M4}). That can be considered a limitation in our model: Once a microcosm reaches either state, further evolution via the given correspondence is banned by (\ref{Misc:M4}) forever. We believe a batch addition (and update) can circumvent that limitation; of course, subject to sanity checks. Take Fig.~\ref{Fig:NVC2} for example: A batch update $M[e_1 < e_2, e'_1 < e'_2]$ is the simultaneous evolution of $M$ with both $e_1 < e_2$ and $e'_1 < e'_2$, in which (\ref{Misc:M4}) is also maintained when $e'_1 < e'_2$ is removed afterwards. In this paper, we disregard batch addition and update and leave them to future. The above discussion gives us context for explaining our design choice on including (\ref{Misc:M4}) in Definition~\ref{Defn:MCosm}. Note that, without (\ref{Misc:M4}) outlawing it, after the addition of $e_1 < e_2$ to $M$ in Fig.~\ref{Fig:NVC1}, for instance, the initial judgements of the resulting microcosm would have become inconsistent: On the one hand, $e'_1 <> e'_2$ would have been given; on the other hand, $e'_1 < e'_2$ would have been deducible by transitivity. \section{Online Decision Making} \label{Sect:Online.Decision} This section provides an algorithm for a microcosm to issue its verdict on the relation it can deduce, to the best of its knowledge, to hold between a queried pair of (distinct) events. This algorithm (manifested in Fig.~\ref{Fig:Rules}) is called the \textbf{online} decision making procedure. The idea is that the decision accuracy keeps improving using this procedure upon the inflow of the new or updated correspondences. In crude terms, this is the situation where the device is connected and thus online. Contrast this with what comes in Section~\ref{Sect:Offline.Decision}. We prove computability (Theorem~\ref{Theo:Rules.Comp}) and consistency (Theorem~\ref{Theo:Micro.Rules.Const}) of the online decision making. We show that the causal knowledge of a microcosm is strictly less than its enclosing world of events (Lemma~\ref{Lemm:WoE.More.Accurate.Micro}), there is no conflict between the verdict of two microcosms of the same world of events -- even when they do not issue the exact same correspondence (Corollary~\ref{Corr:Mu.Hats}). \begin{figure*} \hrule $$ \framebox[1.1\width]{$M \vdash e_1\ r\ e_2$} \qquad \textnormal{ where } r \in R \cup \{<>, ?\} $$ $$ \begin{prooftree} M \sststile{}{\circ} e_1\ r\ e_2 \justifies M \vdash e_1\ r\ e_2 \using \RuleFont{In-OK} \end{prooftree} \qquad \begin{prooftree} M \vdash e_1\ ?\ e_2 \justifies M \vdash e_2\ ?\ e_1 \using \RuleFont{Un-Sym} \end{prooftree} $$ $$ \begin{prooftree} \begin{array}{c@{\quad}c} M \vdash e_1\ r\ e_2 & M \vdash e_2\ r\ e_3\\ r \in \{\parallel, <>, ?\} & M \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_3 \end{array} \justifies M \vdash e_1\ ?\ e_3 \using \RuleFont{Un-1} \end{prooftree} \qquad \begin{prooftree} \begin{array}{c@{\quad}c} M \vdash e_1\ r\ e_2 & M \vdash e_2\ ?\ e_3\\ r \in R \cup \{<>\} & M \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_3 \end{array} \justifies M \vdash e_1\ ?\ e_3 \using \RuleFont{Un-2} \end{prooftree} $$ $$ \begin{prooftree} M \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2 \quad \nexists e' \in M.\ [(M \vdash e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e') \wedge (M \vdash e'\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2)] \justifies M \vdash e_1\ ?\ e_2 \using \RuleFont{Un-3} \end{prooftree} \qquad \begin{prooftree} e \notin M \quad e \neq e' \justifies M \vdash e\ ?\ e' \using \RuleFont{Un-4} \end{prooftree} $$ $$ \begin{prooftree} M \vdash e_1\ ?\ e_2 \quad M \vartriangleleft W \quad W \vDash^* e_1\ r\ e_2 \justifies (M + e_1\ r\ e_2) \vdash e_1\ r\ e_2 \using \RuleFont{Strng} \end{prooftree} \quad \begin{prooftree} M \vdash e_1\ r\ e_2 \quad r \neq\ ? \quad M \vartriangleleft W \quad W \vDash^* e'_1\ r'\ e'_2 \justifies (M + e'_1\ r'\ e'_2) \vdash e_1\ r\ e_2 \using \RuleFont{Weak} \end{prooftree} $$ $$ \begin{prooftree} M \vartriangleleft W \quad M \vdash e_1 <> e_2 \quad W \vDash e_1 < e_2 \justifies M[e_1 < e_2] \vdash e_1 < e_2 \using \RuleFont{Up-S} \end{prooftree} $$ $$ \begin{prooftree} M \vartriangleleft W \quad W \vDash e_1 < e_2 \quad M \vdash e_1 <> e_2 \quad M \vdash e'_1\ r'\ e'_2 \quad r'\ \neq\ ? \justifies M[e_1 < e_2] \vdash e'_1\ r'\ e'_2 \using \RuleFont{Up-W} \end{prooftree} $$ \hrule \caption{Online Decision Making} \vspace{-3em} \label{Fig:Rules} \end{figure*} \begin{definition} \label{Defn:Micro.Decision} Define the online decision making procedure of a microcosm using the rules in Fig.~\ref{Fig:Rules}.$\Square$ \end{definition} In Fig.~\ref{Fig:Rules}, a judgement $M \vdash e_1\ ?\ e_2$ stipulates the lack of knowledge ``in $M$'' about the correspondence between the pair of events $e_1$ and $e_2$. As such, $?$ (read \textsf{is-unknown-to}) is another inaccurate relation. Note that, unlike $<>$, the relation $?$ is only available for microcosms. Recall that, as axiomatised by (\ref{Misc:W5}), the correspondence between every two distinct pair of events is known to their enclosing world of events. Here is an informal account of the rules in Fig.~\ref{Fig:Rules}: \RuleFont{In-OK} says online decision making approves of initial judgements. \RuleFont{Un-Sym} legislates symmetry of $?$. The next two rows concern when a microcosm judges two events as unknown to one another. \RuleFont{Un-1} decrees so when there is an intermediate event $e_2$ that has the same correspondence $r$ with both $e_1$ and $e_3$ (in different orders albeit). Of course, given the transitivity of $<$, in the case of \RuleFont{Un-1}, $r$ cannot be $<$. \RuleFont{Un-2} is similar except that, in the microcosm of discourse, the intermediate event $e_2$ is unknown to $e_3$. Then, \RuleFont{Un-3} decrees for $e_1$ and $e_2$ to be unknown to one another when there is no intermediate event in the microcosm that is in correspondence with both $e_1$ and $e_2$. The last rule of the group, i.e., \RuleFont{Un-4} declares the correspondence between an event that is not in a microcosm to be unknown with any other event. Note that all the \RuleFont{Un-*} rules except \RuleFont{Un-4} assume that the microcosm has no initial judgements between the two events. Next, the rules in the fourth row concern when a microcosm is supplied with new event information. With such a supply, the microcosm of discourse evolves into a new one. To this latter microcosm, one (and only one) more initial correspondence is available than the old microcosm. Evolution happens either by strengthening or weakening. \RuleFont{Strng} states that, when two events are judged to be unknown to one another by a microcosm, the judgement will be changed accordingly when the respective information from the enclosing world of event evolves the microcosm. \RuleFont{Weak} says the supply of new event information from the enclosing world of events preserves every event correspondence decreed earlier not to be unknown. Note that the supply of new information is only possible via the enclosing world of event. Finally, the last two rules are on update of $<>$ instances. \RuleFont{Up-S} (for strengthening) and \RuleFont{Up-W} (for weakening) are the update counterparts \RuleFont{Strng} and \RuleFont{Weak}. The difference is that, for the former pair of rules, the total number of correspondences initially known to the old microcosm and the new one are equal. Yet, in \RuleFont{Up-S} and \RuleFont{Up-W}, one and only one $<>$ in the old microcosm is replaced by exactly one $<$ in the new microcosm. The respective microcosm judgements are updated consequently. The following lemma will later be used in Lemma~\ref{Lemm:Sample.Refutation.1}. \begin{lemma} \label{Lemm:Online.Impl.Init} Suppose that $M \vdash e_1\ r\ e_2$, where $r \in R \cup \{<>\}$. Then, $M \sststile{}{\circ} e_1\ r\ e_2$. \end{lemma} Here are some notational conventions to be used shortly and thereafter: We let $\Pi, \Pi', \dots, \Pi_1, \Pi_2, \dots$ range over derivation trees. For a derivation tree $\Pi$, we write $\LastRuleOf{\Pi}$ for the last rule used in $\Pi$. Additionally, for a derivation $\Pi$ of the form $$ \begin{prooftree} \Pi_1 \quad \Pi_2 \quad \dots \quad \Pi_n \justifies M\ \ensuremath{{}_{\textnormal{\textemdash}}}\ c' \end{prooftree} $$ \noindent we write $c \notin \Pi$ when $c \neq c'$ and $c \notin \Pi_1, c \notin \Pi_2, \ldots, c \notin \Pi_n$. (The ``\ensuremath{{}_{\textnormal{\textemdash}}}'' in ``$M\ \ensuremath{{}_{\textnormal{\textemdash}}}\ c'$'' above can be ``$\sststile{}{\circ}$'', ``$\vdash$'', and ``$\vdash^*$.'' See Definition~\ref{Defn:Offline.Rules} for the latter.) Intuitively, $c \not\in \Pi$ means that `$c$ does not appear in $\Pi$.' \begin{lemma} \label{Lemm:No.Use.Shrink} Let $M \not\sststile{}{\circ} c$ and $\Pi = (M + c) \vdash e_1\ r\ e_2$ but $c \notin \Pi$. Then, $M \vdash e_1\ r\ e_2$. \end{lemma} Informally, the above lemma gives a criterion for shrinking the size of a derivation tree of online decisions. Lemma~\ref{Lemm:No.Use.Shrink} will be used in the proof of Lemma~\ref{Lemm:Analog.No.Use}. Fundamental results about online decision making follow. Theorem~\ref{Theo:Rules.Comp} is on its computability. Then, Theorem~\ref{Theo:Micro.Rules.Const} proves consistency. At last, Lemma~\ref{Lemm:WoE.More.Accurate.Micro} and Corollary~\ref{Corr:Mu.Hats} focus on the relative accuracy of online decision making. \begin{theorem} \label{Theo:Rules.Comp} Online decision making is computable: For every distinct pair of events $e_1$ and $e_2$ and microcosm $M$, in finite number of steps, the relation $r$ for which $M \vdash e_1\ r\ e_2$ can be found, if any. \end{theorem} \begin{proof} Let $p(e_1, e_2) = \exists r \in R \cup \{<>, ?\}.\ M \vdash e_1\ r\ e_2$. The result is trivial when no rule applies because, then, $p(e_1, e_2) = \bot$ in zero steps. Otherwise, we assume availability of a mechanism for preventing infinite trial of the symmetry rules. Similarly, we assume a book-keeping to prevent self-lookup over seeking an intermediate event in the case of \RuleFont{Un-$n$}, where $n \in \{1, 2, 3\}$. The proof is by rule-based induction on $M \vdash e_1\ r\ e_2$. \end{proof} Here is a note on the computational complexity of the online decision making. Let $m$ be the size of a microcosm. Taken na\"{i}vely, the rules in Fig.~\ref{Fig:Rules} give rise to exponential complexity w.r.t. $m$. Using a simple $m \times m$ memoisation matrix, however, one can reduce that complexity to quadratic w.r.t. $m$. Note that, having only a partial knowledge, being quadratic w.r.t. the size of a microcosm is far less than quadratic w.r.t. the size of a world of events as a whole. This proves our model practically more useful than the classical holistic models. In the presence of the above matrix, furthermore, maintaining (\ref{Misc:M4}) upon arrival of new correspondences is DLOG-Complete w.r.t. $m$ \cite[\S5.7]{Yap:1998}. \begin{theorem} \label{Theo:Micro.Rules.Const} Online decision making is consistent: $M \vdash e_1\ r\ e_2$ and $M \vdash e_1\ r'\ e_2$ imply $r = r'$. \end{theorem} \begin{proof} Let $\Pi = M \vdash e_1\ r\ e_2$ and $\Pi' = M \vdash e_1\ r'\ e_2$. The proof is by rule-based induction on $\Pi$, namely, by case analysis of $\LastRuleOf{\Pi}$: \begin{itemize} \item \RuleFont{Un-$n$} for $n \in \{1, 2, 3\}$.\quad In all those cases, as a part of the hypotheses, $M \not\sststile{}{\circ} e_1\ \_\ e_2$. Hence, $\LastRuleOf{\Pi'} \neq \RuleFont{In-OK}$. Furthermore, $\LastRuleOf{\Pi'} \neq \RuleFont{Up-S}$ (because, then, $r' = <$ and $M \sststile{}{\circ} e_1 < e_2$) and $\LastRuleOf{\Pi'} \neq \RuleFont{Up-W}$ (because, then, $r' \neq\ ?$, and, by Lemma~\ref{Lemm:Online.Impl.Init}, $M \sststile{}{\circ} e_1\ r'\ e_2$). Likewise, $\LastRuleOf{\Pi'} \neq \RuleFont{Strng}$ either because, then, $M \sststile{}{\circ} e_1\ r'\ e_2$ for $M = (\ensuremath{{}_{\textnormal{\textemdash}}}\ + e_1\ r'\ e_2)$. We claim that the last rule in $M \vdash e_1\ r'\ e_2$ cannot be \RuleFont{Weak} either, and, the result follows because all the remaining rules imply that $r'\ =\ ?$. We now prove our last claim. If the last rule in $M \vdash e_1\ r'\ e_2$ is to be \RuleFont{Weak}, there exists a microcosm $M'$ such that $M = (M' + e'_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e'_2)$ and $M' \vdash e_1\ r'\ e_2$. Besides, $r'\ \neq\ ?$, which, by Lemma~\ref{Lemm:Online.Impl.Init}, implies $M' \sststile{}{\circ} e_1\ r'\ e_2$. This is, however, a contradiction because, then $M \sststile{}{\circ} e_1\ r'\ e_2$. \item \RuleFont{Un-4}.\quad When $e \notin M$ and $e \neq e'$, there essentially is no other rule that can apply than \RuleFont{Un-4}. That is, the last rule for $M \vdash e_1\ r'\ e_2$ too needs to be \RuleFont{Un-4} and $r'\ =\ ?$. \end{itemize} We drop the remaining cases due to space restrictions. \end{proof} \begin{definition} \label{Defn:More.Accurate} For a pair of relations $r, r' \in R \cup \{<>, ?\}$, write $r \sqsubset r'$ -- for $r$ is at most as accurate as $r'$ -- when: (i) $r'\ \neq\ ?$ and $r\ =\ ?$, (ii) $r'\ =\ <$ and $r\ = <>$, (iii) $r'\ =\ <^{-1}$ and $r\ =\ <>$, (iv) $r\ = r'\ =\ <$, and (v) $r\ = r'\ =\ \parallel$. Write $\sqsubseteq$ for the reflexive closure of $\sqsubset$. \end{definition} The following result states that a microcosm always \textbf{approximate}s its enclosing world of event: For every pair of events, when the relation a microcosm attributes to the pair does not exactly coincide with that of its enclosing world of events, the microcosm is only less accurate. This is the essence of our model being weaker than the mainstream practice where every device is exactly as accurate as its enclosing ecosystem. \begin{lemma} \label{Lemm:WoE.More.Accurate.Micro} Let $M \vartriangleleft W$. Suppose also that $W \vDash e_1\ r_W\ e_2$ and $M \vdash e_1\ r_M\ e_2$. Then, $r_M \sqsubset r_W$. \end{lemma} The next result says: When two microcosms of the same world of events do not agree on a given pair of events, it only is that one of the two is more accurate than the other. In other words, two microcosms of the same world of events will never attribute conflicting relations to any given pair of events. \begin{corollary} \label{Corr:Mu.Hats} Let $M \vartriangleleft W$ and $M' \vartriangleleft W$ with $M \vdash e_1\ r\ e_2$ and $M' \vdash e_1\ r'\ e_2$. Then, $r \sqsubseteq r'$ or $r' \sqsubseteq r$. \end{corollary} \section{Offline Decision Making} \label{Sect:Offline.Decision} The algorithm presented in this section enables a microcosm to make new decisions without depending on new supply from the enclosing world of events. As such, it suits a device required to perform offline computation. Hence, the naming ``offline.'' Unlike our online algorithm that exclusively proves correspondences, our offline algorithm is based on cancelling possibilities. That is, deducing it that certain correspondences cannot possibly hold between the given pair of events. We say that the online decision making \textit{confirm}s, whereas the offline one (mostly) \textit{refute}s. Sometimes, cancelling enough possibilities out will prove the only remaining correspondence (e.g., Fig.~\ref{Fig:WO2}). But, even if that is not quite the case, cancelling one or more correspondences out is still useful (e.g., Fig.~\ref{Fig:WO1}): It conveys the information that the given pair of events are \textbf{not} unknown to one another. (See Lemma~\ref{Lemm:Sample.Refutation.1}.) Most particularly, in such a scenario, it would be wrong to consider the pair concurrent. That is in exact contrast with the common causality folklore that: `when one cannot confirm any correspondence between two events, one can safely [sic] consider them concurrent.' In Fig.~\ref{Fig:WO1}, given that $e_1 \parallel e_2$ and $e_2 < e_3$, it cannot be that $e_3 < e_1$. This is because, then, by transitivity of \textsf{happens-before}, $e_2 < e_3$ and $e_3 < e_1$, imply $e_2 < e_1$, contradicting $e_1 \parallel e_2$. Fig.~\ref{Fig:WO2} rules $e_3 < e_1$ out similarly. But, then, given that $e_1 <> e_3$, the implication is $e_1 < e_3$. Note that the only correspondences that were available prior to concluding $e_3 \not< e_1$ (in Fig.~\ref{Fig:WO1}) and $e_1 < e_3$ (in Fig.~\ref{Fig:WO2}) were the black lines between $e_1$, $e_2$, and $e_3$. No new correspondence was supplied over the arguments either. The important observation to make, hence, is that such arguments do not depend on new supply from the enclosing world of events. Offline decision making (Definition~\ref{Defn:Offline.Rules}) enables such arguments. \begin{figure*} \hrule \centering \begin{subfigure}[b]{0.4\textwidth} \underline{Legend}: Two parallel lines between $e$ and $e'$ depicts $e \parallel e'$. Dotted arrows show hypothesised \textsf{happens-before}. Red lines show what goes wrong as a result of the hypotheses. Green arrow shows \textsf{happens-before} that was proved offline. \end{subfigure} \hfill \vline \hfill \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.59\textwidth]{WO1.pdf} \caption{$[(e_1 \parallel e_2) \wedge (e_2 < e_3)] \Rightarrow e_3 \not< e_1$} \label{Fig:WO1} \end{subfigure} \hfill \vline \hfill \begin{subfigure}[b]{0.29\textwidth} \centering \includegraphics[width=0.55\textwidth]{WO2.pdf} \caption{$[(e_1 \parallel e_2) \wedge (e_2 < e_3) \wedge (e_3 <> e_1)] \Rightarrow e_1 < e_3$} \label{Fig:WO2} \end{subfigure} \hrule \vspace{0.1em} \caption{Two Useful Offline Deductions} \label{Fig:Why.Offline} \vspace{-2em} \end{figure*} Before we can delve into offline decision making itself, we need to introduce a couple of notations. For a microcosm $M$ and a pair of distinct events $e_1$ and $e_2$ such that $M \not\vdash e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$, write $(M \ensuremath{\mathbin{+_?}} e_1\ r\ e_2)$ for a microcosm that is \textit{structurally} the same as $(M + e_1\ r\ e_2)$, namely, contains the exact same correspondences. Despite their same structure, the former is meant to be used only when $e_1\ r\ e_2$ is not supplied by the enclosing world of events; it rather is $M$ with the \textit{hypothesis} that $e_1\ r\ e_2$ was also known by $M$. That is, ``$\ensuremath{\mathbin{+_?}}$'' is like the blue arrow in Fig.~\ref{Fig:WO1}. Note the additional requirement of the former over the latter. The latter only requires that $M \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$. In contrast, the former requires that $M \not\vdash e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$. (By definition, the requirement for $(M \ensuremath{\mathbin{+_?}} e_1\ r\ e_2)$ implies the requirement of $(M + e_1\ r\ e_2)$ too. Hence, $(M \ensuremath{\mathbin{+_?}} e_1\ r\ e_2)$ is well-defined.) Note also that, by Theorem~\ref{Theo:Rules.Comp}, satisfiability of $M \not\vdash e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$ is computable. When $M \not\vdash e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$, define $M\SuppUp{e_1\ r\ e_2}$ similarly for a microcosm that is structurally like $M[e_1\ r\ e_2]$; yet $e_1\ r\ e_2$ is not supplied by the enclosing world of events but is only hypothesised. That is, ``$\SuppUp{.}$'' is like the blue arrow in Fig.~\ref{Fig:WO2}. \begin{figure*} \hrule \vspace{0.1em} \begin{center} \framebox[1.1\width]{$M \vdash^* e_1\ \tilde{r}\ e_2$} where $\tilde{r} ::= r \mid \ensuremath{\not\hspace{-0.1em}r}$ \end{center} $$ \begin{prooftree} M \vdash e_1\ r\ e_2 \justifies M \vdash^* e_1\ r\ e_2 \using \RuleFont{Onl-OK} \end{prooftree}\qquad \begin{prooftree} M \vdash^* e_1 \ensuremath{\not\hspace{-0.1em}r}\ e_2 \quad r \in R \justifies M \vdash^* e_1 \ensuremath{\not\hspace{0.2em}?}\ e_2 \using \RuleFont{Not-R} \end{prooftree} $$ $$ \begin{prooftree} M \vdash^* e_1\ \cancel{<>}\ e_2 \justifies M \vdash^* e_1 \parallel e_2 \using \RuleFont{Not-CR} \end{prooftree}\qquad \begin{prooftree} M \vdash^* e_1\ \ensuremath{\not\hspace{0.1em}\parallel}\ e_2 \justifies M \vdash^* e_1\ <>\ e_2 \using \RuleFont{Not-Co} \end{prooftree} $$ $$ \begin{prooftree} (M \ensuremath{\mathbin{+_?}} e_1\ r\ e_2) \vdash^* e'_1\ r'_1\ e'_2 \quad (M \ensuremath{\mathbin{+_?}} e_1\ r\ e_2) \vdash^* e'_1\ r'_2\ e'_2 \quad r_1 \neq r_2 \justifies M \vdash^* e_1 \ensuremath{\not\hspace{-0.1em}r}\ e_2 \using \RuleFont{Cntrd} \end{prooftree} $$ $$ \begin{prooftree} M\SuppUp{e_1\ r\ e_2} \vdash^* e'_1\ r'_1\ e'_2 \quad M\SuppUp{e_1\ r\ e_2} \vdash^* e'_1\ r'_2\ e'_2 \quad r_1 \neq r_2 \justifies M \vdash^* e_1 \ensuremath{\not\hspace{-0.1em}r}\ e_2 \using \RuleFont{Up-Cntrd} \end{prooftree} $$ $$ \begin{prooftree} M \vdash^* e_1\ <>\ e_2 \quad M \vdash^* e_1\ \not < e_2 \justifies M \vdash^* e_2 < e_1 \using \RuleFont{Not-HB} \end{prooftree}\qquad \begin{prooftree} M \vdash^* e_1 \not < e_2 \quad M \vdash^* e_2 \not < e_1 \justifies M \vdash^* e_1\ \cancel{<>}\ e_2 \using \RuleFont{No-HBs} \end{prooftree} $$ $$ \begin{prooftree} M \vdash^* e_1 \ensuremath{\not\hspace{0.2em}?}\ e_2 \justifies M \vdash^* e_2 \ensuremath{\not\hspace{0.2em}?}\ e_1 \using \RuleFont{NU-Sym} \end{prooftree}\qquad \begin{prooftree} M \vdash^* e_1\ \cancel{<>}\ e_2 \justifies M \vdash^* e_2\ \cancel{<>}\ e_1 \using \RuleFont{NCR-Sym} \end{prooftree}\qquad \begin{prooftree} M \vdash^* e_1 \ensuremath{\not\hspace{0.1em}\parallel} e_2 \justifies M \vdash^* e_2 \ensuremath{\not\hspace{0.1em}\parallel} e_1 \using \RuleFont{NCo-Sym} \end{prooftree} $$ \hrule \caption{Offline Decision Making} \vspace{-3em} \label{Fig:Offline.Rules} \end{figure*} \begin{definition} \label{Defn:Offline.Rules} Define the offline decision making procedure of a microcosm using the rules in Fig.~\ref{Fig:Offline.Rules}, where the judgements take the form $M \vdash^* e_1\ \tilde{r}\ e_2$, and $\tilde{r} ::= r\ \mid \not{r}$. \end{definition} The rules in Fig.~\ref{Fig:Offline.Rules} are fairly self-explanatory and we drop explanation to save space, except for the two key rules: \RuleFont{Cntrd} and \RuleFont{Up-Cntrd}. If a hypothetical correspondence between a pair of events leads to two different conclusions about a single pair of distinct events, we have come to a contradiction, and, conclude the hypothesis to be false. \RuleFont{Cntrd} manifests that for additions whilst \RuleFont{Up-Cntrd} does so for updates. The online and offline decisions on the same pair of events will not conflict. That is, online and offline decision making are consistent: \begin{lemma} \label{Lemm:Offline.Not.Refute.Online} Let $e_1$ and $e_2$ be a pair of distinct events in $M$. Then: (i) $M \vdash e_1\ r\ e_2$ implies $M \not\vdash^* e_1 \ensuremath{\not\hspace{-0.1em}r}\ \ e_2$, and (ii) $M \vdash^* e_1 \ensuremath{\not\hspace{-0.1em}r}\ e_2$ implies $M \not\vdash e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$, in particular, $M \not\vdash e_1\ r\ e_2$. \end{lemma} \begin{lemma} \label{Lemm:Offline.Not.Disagree.Online} If $M \vdash e_1\ r\ e_2$ and $M \vdash^* e_1\ r'\ e_2$, then $r = r'$. \end{lemma} The offline decision making can be used, for example, to mechanically conclude in the case of Fig.~\ref{Fig:WO1} that $M \vdash^* e_3 \ensuremath{\not\hspace{0.2em}?}\ e_1$: \begin{lemma} \label{Lemm:Sample.Refutation.1} Let $M \vdash e_1 \parallel e_2$ and $M \vdash e_2 < e_3$ but $M \not\vdash e_3\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_1$. Then, $M \vdash^* e_3 \ensuremath{\not\hspace{0.2em}?}\ e_1$. \end{lemma} \begin{proof} The mechanical proof comes in Fig.~\ref{Fig:Sample.Refutation}, where the derivation labelled ($*$) is Lemma~\ref{Lemm:Online.Impl.Init}. \end{proof} \begin{figure*} \hrule \vspace{0.1em} \begin{center} \includegraphics[width=\textwidth]{WOProof.pdf} \end{center} \vspace{-0.5em} \hrule \caption{Mechanical Proof of Lemma~\ref{Lemm:Sample.Refutation.1}} \vspace{-2.5em} \label{Fig:Sample.Refutation} \end{figure*} Despite its merits, offline decision making is confronted with two problems: Firstly, getting to refute the right correspondence may only be possible using human intelligence. Although mechanical proofs like Fig.~\ref{Fig:Sample.Refutation} help a human-being legislate informal reasoning such as Fig.~\ref{Fig:Why.Offline}, how likely that is for a machine to produce that is not yet known. Secondly, the search space for getting to a contradiction (and hence a refute) is exponential in the number of events known to a microcosm. We are not aware of any technique for reducing that space. \section{Forward Bisimilarity} \label{Sect:ForBiSim} In this section, we present our first notion of microcosm bisimilarity. We start by defining microcosm analogy (Definition~\ref{Defn:Micro.Analog}), namely, what exactly we mean when we say two microcosms agree on every correspondence. Then, we show that such microcosms will evolve likewise when supplied with the exact same new single correspondence (Theorem~\ref{Theo:Analog.Bisimu}), i.e., they are forward bisimilar (Definition~\ref{Defn:For.Bisimilarity}). The most important result of this section is Theorem~\ref{Theo:For.Order.Irrelevant}, which proves it that the order of arrival of causal information is irrelevant so long as the same correspondences are available to a pair of bisimilar microcosms. Finally, Theorem~\ref{Theo:For.Bisimilarity} establishes the bisimilarity of analogy. We call the bisimilarity of this section forward to contrast it with that of next section (Definition~\ref{Defn:Back.Bisimilarity}), which we call backward. \begin{definition} \label{Defn:Micro.Analog} Call microcosms $M$ and $M'$ analogous -- write $M \approx M'$ -- when: $\forall e_1, e_2.\ M \vdash e_1\ r\ e_2 \Leftrightarrow M' \vdash e_1\ r\ e_2$. \end{definition} In words, two microcosms are analogous when they `agree on the correspondence between every pair of events.' That can, for instance, be two replicas of a single data centre that are in the same state. As another example consider a copy taken from a device before it temporarily dies. As soon as the original device comes back to life, the original device and the copy would be analogous. Interestingly enough, the order of arrival of the causal information to the original device is completely sporadic to the copy. Note that Definition~\ref{Defn:Micro.Analog} has even no explicit mention of the enclosing worlds of events of the two microcosms. \begin{definition} \label{Defn:For.Trans.Sys} Define \ensuremath{\stackrel{c}{\rightarrow}}\ for the transition system $\ensuremath{\mathscr{T}_F(W)} = (\mathcal{M}_W, \mathcal{C}^*_W, \stackrel{.}{\rightarrow})$ such that $M \ensuremath{\stackrel{c}{\rightarrow}} M'$ when $M' = (M + c)$ for some $c \in \mathcal{C}^*_W$. Call \ensuremath{\mathscr{T}_F(W)}\ the forward transition system of $W$. \end{definition} The above definition formalises our understanding of a microcosm evolving \textit{forward} with the arrival of new supply to it. We now present a technical lemma for later use. \begin{lemma} \label{Lemm:Analog.Init.Use} Suppose that $M \approx M'$. Then, $\Pi = (M + c) \sststile{}{\circ} e_1\ r\ e_2$ implies $(M' + c) \sststile{}{\circ} e_1\ r\ e_2$ when $c \in \Pi$. \end{lemma} \begin{proof} By case distinction on $\LastRuleOf{\Pi}$. \end{proof} The following two lemmata explore two different scenarios for forward evolution: when the new supply is not used for deriving the correspondence between a given pair of events (Lemma~\ref{Lemm:Analog.No.Use}) and when it is (Lemma~\ref{Lemm:Analog.Use}). Those two pave the road for Theorem~\ref{Theo:Analog.Bisimu}. \begin{lemma} \label{Lemm:Analog.No.Use} Suppose that $M \approx M'$ and $M \ensuremath{\stackrel{c}{\rightarrow}} (M + c)$. Then, $\Pi = (M + c) \vdash e_1\ r\ e_2$ implies $(M' + c) \vdash e_1\ r\ e_2$ when $c \notin \Pi$. \end{lemma} \begin{proof} By Lemma~\ref{Lemm:No.Use.Shrink}, $(M + c) \vdash e_1\ r\ e_2$ and $c \notin \Pi$ imply $M \vdash e_1\ r\ e_2$. Given that $M \approx M'$, thus, $M' \vdash e_1\ r\ e_2$. Note, then, that $M' \not\vdash e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$ is not true. We claim that the result follows, i.e., $(M' + c) \vdash e_1\ r\ e_2$. Here is the proof of our claim. Suppose otherwise, namely, that $(M' + c) \vdash e_1\ r'\ e_2$ where $r \neq r'$. Then, the only rule that can take $M' \vdash e_1\ r\ e_2$ to $(M' + c) \vdash e_1\ r'\ e_2$ is \RuleFont{Strng}, in which case, $r\ =\ ?$ and $r' \in R \cup \{<>\}$. But, then, $M \vdash e_1\ ?\ e_2$ for $M \approx M'$. It follows by \RuleFont{Strng} that $(M + c) \vdash e_1\ r'\ e_2$. That, however, is a contradiction because, according to Theorem~\ref{Theo:Micro.Rules.Const}, $\vdash$ is consistent. \end{proof} \begin{lemma} \label{Lemm:Analog.Use} Suppose that $M \approx M'$ and $M \ensuremath{\stackrel{c}{\rightarrow}} (M + c)$. Then, $\Pi = (M + c) \vdash e_1\ r\ e_2$ implies $(M' + c) \vdash e_1\ r\ e_2$ when $c \in \Pi$. \end{lemma} \begin{proof} Induction on the size of $\Pi$ by case distinction on \LastRuleOf{\Pi}. \begin{itemize} \item \RuleFont{In-OK}.\quad In this case, $(M + c) \sststile{}{\circ} e_1\ r\ e_2$. By Lemma~\ref{Lemm:Analog.Init.Use}, $(M' + c) \sststile{}{\circ} e_1\ r\ e_2$. Using an application of \RuleFont{In-OK}, one derives the desirable. \item \RuleFont{Un-1}.\quad In this case, $r\ =\ ?$, and, there exist $r' \in R \cup \{<>\}$ and an intermediate event $e$ such that $\Pi_1 = (M + c) \vdash e_1\ r'\ e$ and $\Pi_2 = (M + c) \vdash e\ r'\ e_2$. When $c \notin \Pi_1$, by Lemma~\ref{Lemm:Analog.No.Use}, $(M' + c) \vdash e_1\ r'\ e$. Otherwise, the same result is obtained by the inductive hypothesis. Based on whether $c \in \Pi_2$ or not, one obtains $(M' + c) \vdash e\ r'\ e_2$ similarly. The other hypothesis of this rule is $(M + c) \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$. We claim that $(M' + c) \not\sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_2$. One derives the desirable using an application of \RuleFont{Un-1}. Here is the proof of our claim. Suppose otherwise. Then, $\Pi_\circ = (M' + c) \sststile{}{\circ} e_1\ r_\circ\ e_2$ for some $r_\circ \in R \cup \{<>\}$. When $c \in \Pi_\circ$, by Lemma~\ref{Lemm:Analog.Init.Use}, $(M + c) \sststile{}{\circ} e_1\ r_\circ\ e_2$. When $c \notin \Pi_\circ$, using an application of \RuleFont{In-OK}, one first gets $(M' + c) \vdash e_1\ r_\circ\ e_2$. Next, one uses Lemma~\ref{Lemm:Analog.No.Use} to conclude $(M + c) \vdash e_1\ r_\circ\ e_2$. Both cases, however, contradict consistency of $\vdash$ (c.f., Theorem~\ref{Theo:Micro.Rules.Const}). \item \RuleFont{Un-4}.\quad This case is not applicable. Here is why. Suppose otherwise. Then, $r\ =\ ?$. Furthermore, the only way for $c \in \Pi$ is that $c = e_1\ ?\ e_2$. But, that is not possible because, by Definition~\ref{Defn:For.Trans.Sys}, $M \ensuremath{\stackrel{c}{\rightarrow}} (M + c)$ is only defined when $c \in \mathcal{C}^*_W$. That is, $W \vDash^* e_1\ ?\ e_2$, which cannot be. \item \RuleFont{Strng}.\quad In this case, $M \vdash e_1\ ?\ e_2$. Given that $M \approx M'$, it follows that $M' \vdash e_1\ ?\ e_2$. Using an application of \RuleFont{Strng}, then, $(M' + c) \vdash e_1\ r\ e_2$. \item \RuleFont{Weak}.\quad In this case, $M \vdash e_1\ r\ e_2$. Given that $M \approx M'$, it follows that $M' \vdash e_1\ r\ e_2$. Using an application of \RuleFont{Weak}, then, $(M' + c) \vdash e_1\ r\ e_2$. \end{itemize} We drop the remaining cases due to space restrictions. \end{proof} We next define our notion of forward bisimulation and prove that analogy is a bisimulation. \begin{definition} \label{Defn:For.Bisimilarity} Call a binary relation $\mathpzc{R}$ on $\mathcal{M}_W$ a bisimulation for $\ensuremath{\mathscr{T}_F(W)}$ when for every microcosms $M_1$ and $M_2$ of $W$ such that $M_1\ \mathpzc{R}\ M_2$, the following hold: \begin{itemize} \item $M_1 \ensuremath{\stackrel{c}{\rightarrow}} M'_1 \Rightarrow \exists M'_2 \vartriangleleft W.\ (M_2 \ensuremath{\stackrel{c}{\rightarrow}} M'_2) \wedge (M'_1\ \mathpzc{R}\ M'_2)$, and \item $M_2 \ensuremath{\stackrel{c}{\rightarrow}} M'_2 \Rightarrow \exists M'_1 \vartriangleleft W.\ (M_1 \ensuremath{\stackrel{c}{\rightarrow}} M'_1) \wedge (M'_1\ \mathpzc{R}\ M'_2)$. \end{itemize} Write \ensuremath{\sim_F}\ for the bisimilarity of $\ensuremath{\mathscr{T}_F(W)}$, i.e., the largest bisimulation for $\ensuremath{\mathscr{T}_F(W)}$. \end{definition} \begin{theorem} \label{Theo:Analog.Bisimu} For every $W$, the relation $\approx$ is a bisimulation for $\ensuremath{\mathscr{T}_F(W)}$. \end{theorem} \begin{proof} Let $M, M' \vartriangleleft W$ and $M \approx M'$. Suppose that $M \ensuremath{\stackrel{c}{\rightarrow}} (M + c)$ and $\Pi = (M + c) \vdash e_1\ r\ e_2$. When $c \notin \Pi$, by Lemma~\ref{Lemm:Analog.No.Use}, $(M + c) \vdash e_1\ r\ e_2$. When $c \in \Pi$, by Lemma~\ref{Lemm:Analog.Use}, $(M + c) \vdash e_1\ r\ e_2$. The result follows by symmetry. \end{proof} Now that we are armed with Theorem~\ref{Theo:Analog.Bisimu}, it is easy to prove Theorem~\ref{Theo:For.Order.Irrelevant}. We would like to draw the reader's attention to the small length of the proof and the simple technique used for it. Such a comfort is a consequence of bisimulation being such a strong concept. For a given $n$, write $\overline{c}$ for $c_1, c_2, \dots, c_n$ and $n = |\overline{c}|$. Extend $\stackrel{.}{\rightarrow}$, accordingly, to $\stackrel{.}{\twoheadrightarrow}$ where \ensuremath{\stackrel{\overline{c}}{\twoheadrightarrow}}\ abbreviates $\SingleCNamed{c_1} \circ \SingleCNamed{c_2} \circ \dots \circ \SingleCNamed{c_n}$. Furthermore, write $\overline{c}' = p(\overline{c})$ when $\overline{c}'$ is a permutation of $\overline{c}$. \begin{theorem} \label{Theo:For.Order.Irrelevant} Suppose that $M_0 \approx M'_0$. Suppose also that $M_0 \ensuremath{\stackrel{\overline{c}}{\twoheadrightarrow}} M$ and $M'_0 \ensuremath{\stackrel{\overline{c}'}{\twoheadrightarrow}} M'$, where $\overline{c}' = p(\overline{c})$. Then, $M \approx M'$. \end{theorem} \begin{proof} We proceed by strong induction on $n$, where $n = |\overline{c}|$: \begin{itemize} \item $n = 1$.\quad By Theorem~\ref{Theo:Analog.Bisimu}. \item $n = k$.\quad Suppose that the theorem is correct for every $n < k$. The case when $\overline{c} = \overline{c}'$ is immediate. Otherwise, let $k_0$ be the first position where $\overline{c}$ and $\overline{c}'$ disagree. That is, $M_0 \MultiCsNamed{\overline{c}_l} M_{k_0 - 1} \SingleCNamed{c_{k_0}} M_{k_0} \MultiCsNamed{\overline{c}_r} M$ and $M'_0 \MultiCsNamed{\overline{c}'_l} M'_{k_0 - 1} \SingleCNamed{c'_{k_0}} M'_{k_0} \MultiCsNamed{\overline{c}'_r} M'$ such that $\overline{c}_l = \overline{c}'_l$, $c_{k_0} \neq c'_{k_0}$, and $\overline{c}'_r = p(\overline{c}_r)$. Then, $M_{k_0} \approx M'_{k_0}$ is immediate from Theorem~\ref{Theo:Analog.Bisimu}. And, given that $|c_{k_0}\overline{c}_r| = |c'_{k_0}\overline{c}'_r| < k$, by the inductive hypothesis, $M \approx M'$. \end{itemize} The result follows. \end{proof} \begin{theorem} \label{Theo:For.Bisimilarity} For $W$, the relation $\approx$ is the bisimilarity of $\ensuremath{\mathscr{T}_F(W)}$, i.e., $\approx = \sim_F$. \end{theorem} \begin{proof} Given that $\ensuremath{\sim_F}$ is the largest bisimulation of $\ensuremath{\mathscr{T}_F(W)}$ (c.f., Definition~\ref{Defn:For.Bisimilarity}), it suffices that we show $\ensuremath{\sim_F}\ \subseteq\ \approx$. To that end, suppose that $M \ensuremath{\sim_F} M'$; we will show that $M \approx M'$. Choose an arbitrary pair of events $e_1$ and $e_2$ such that $\Pi = M \vdash e_1\ r\ e_2$ and $\Pi' = M \vdash e_1\ r'\ e_2$. The proof is by parallel induction on $\Pi$ and $\Pi'$ and proceeds by case distinction on $\LastRuleOf{\Pi}$ and $\LastRuleOf{\Pi'}$. The goal is to show that, in all the possible cases, $r = r'$. We only show one case here: \begin{itemize} \item $M \vdash e_1\ r\ e_2$ and $M' \vdash e_1\ r'\ e_2$ but $\{r, r'\} \cap \{?\} = \varnothing$.\quad Note first that, in this case, by Corollary~\ref{Corr:Mu.Hats}, regardless of $M$ and $M'$ being bisimilar, either $r \sqsubseteq r')$ or $r' \sqsubseteq r$. We now show that, in the case of bisimilarity, $r = r'$. Let us assume that $r \sqsubseteq r'$; let us also assume that $r\ =\ <$ and $r'\ =\ <>$; the proof is similar otherwise. When $M \vdash e_1 < e_2$ but $M' \vdash e_1\ <>\ e_2$, by Lemma~\ref{Lemm:Online.Impl.Init}, $M \sststile{}{\circ} e_1 < e_2$ and $M'\sststile{}{\circ} e_1\ <>\ e_2$, respectively. Hence, for an event $e_3$ such that $W \vDash e_2 < e_3$, it follows using an application of \RuleFont{In-Tr} that $M \sststile{}{\circ} e_1 < e_3$. Using an application of \RuleFont{In-OK}, then, $M \vdash e_1 < e_3$. This is whilst, with the given information, $M' \sststile{}{\circ} e_1\ \ensuremath{{}_{\textnormal{\textemdash}}}\ e_3$ is not derivable. Thus, $(M' + e_1 < e_3)$ is defined, but, $(M' + e_1 < e_3)$ is not. Let $c = e_2 < e_3$. Then, $M' \ensuremath{\stackrel{c}{\rightarrow}} (M' + c)$ but $M \ensuremath{\stackrel{c}{\rightarrow}} \ensuremath{{}_{\textnormal{\textemdash}}}$ is not implied, which contradicts $M \ensuremath{\sim_F} M'$. (See Definition~\ref{Defn:For.Bisimilarity}.) \end{itemize} We omit the remaining cases due to space restrictions. \end{proof} A shortcoming of $\ensuremath{\sim_F}$ is that it only studies microcosm evolution via addition. Whereas microcosms can well evolve via update too. We leave the study of $\ensuremath{\sim_F}$ in presence of updates (as well as additions) to future work. The same applies to $\ensuremath{\sim_B}$, which we will consider next. \section{Backward Bisimilarity} Only limited resources are available to devices, especially the edge devices. Emptying the disk or memory of such a device is routine then. To that end, usually, one removes the outdated data to come to a new manageable state. This section deals with when (causal) information is to be removed from devices, say due to resource limitation or outdatedness. That too can be seen as an evolution for a microcosm, albeit \textit{backward} (Definition~\ref{Defn:Back.Trans.Sys}). We show that microcosm analogy (Definition~\ref{Defn:Micro.Analog}) gives rise to a bisimilarity for backward evolution as well (Theorem~\ref{Theo:Back.Bisimilarity}). Besides, this section presents the backward counterpart of Theorem~\ref{Theo:For.Order.Irrelevant} that proves: The order of removal of causal information from bisimilar devices does not matter in that they will again be bisimilar once they are both done with the set of correspondences (Theorem~\ref{Theo:Back.Order.Irrelevant}). \begin{definition} \label{Defn:Back.Trans.Sys} Define \ensuremath{\stackrel{c}{\leftarrow}}\ for the transition system $\ensuremath{\mathscr{T}_B(W)} = (\mathcal{M}_W, \mathcal{C}^*_W, \stackrel{.}{\leftarrow})$ such that $M \ensuremath{\stackrel{c}{\leftarrow}} M'$ when $M = (M' + c)$ for some $c \in \mathcal{C}^*_W$. Call \ensuremath{\mathscr{T}_B(W)}\ the backward transition system of $W$. \end{definition} The notation $M \ensuremath{\stackrel{c}{\leftarrow}}\ M'$ is indeed intended to be read from left to right to denote getting from $M$ to $M'$ by the removal of $c$. \begin{definition} \label{Defn:Back.Bisimilarity} Call a binary relation $\mathpzc{R}$ on $\mathcal{M}_W$ a bisimulation for $\ensuremath{\mathscr{T}_B(W)}$ when for every microcosms $M_1$ and $M_2$ of $W$ such that $M_1\ \mathpzc{R}\ M_2$, the following hold: \begin{itemize} \item $M_1 \ensuremath{\stackrel{c}{\leftarrow}} M'_1 \Rightarrow \exists M'_2 \vartriangleleft W.\ (M_2 \ensuremath{\stackrel{c}{\leftarrow}} M'_2) \wedge (M'_1\ \mathpzc{R}\ M'_2)$, and \item $M_2 \ensuremath{\stackrel{c}{\leftarrow}} M'_2 \Rightarrow \exists M'_1 \vartriangleleft W.\ (M_1 \ensuremath{\stackrel{c}{\leftarrow}} M'_1) \wedge (M'_1\ \mathpzc{R}\ M'_2)$. \end{itemize} Write \ensuremath{\sim_B}\ for the bisimilarity of $\ensuremath{\mathscr{T}_B(W)}$, i.e., the largest bisimulation for $\ensuremath{\mathscr{T}_B(W)}$. \end{definition} \begin{theorem} \label{Theo:Back.Bisimu} For every $W$, the relation $\approx$ is a bisimulation for $\ensuremath{\mathscr{T}_B(W)}$. \end{theorem} We extend $\stackrel{.}{\leftarrow}$, like $\stackrel{.}{\twoheadrightarrow}$ to $\stackrel{.}{\twoheadleftarrow}$ where \ensuremath{\stackrel{\overline{c}}{\twoheadleftarrow}}\ abbreviates $\SingleBCNamed{c_1} \circ \SingleBCNamed{c_2} \circ \dots \circ \SingleBCNamed{c_n}$. In words, the following theorem states that the order of removal is irrelevant so long as the same set of correspondences are removed from analogous microcosms. \begin{theorem} \label{Theo:Back.Order.Irrelevant} Suppose that $M_0 \approx M'_0$. Suppose also that $M_0 \ensuremath{\stackrel{\overline{c}}{\twoheadleftarrow}} M$ and $M'_0 \ensuremath{\stackrel{\overline{c}'}{\twoheadleftarrow}} M'$, where $\overline{c}' = p(\overline{c})$. Then, $M \approx M'$. \end{theorem} \begin{proof} Similar to Theorem~\ref{Theo:For.Order.Irrelevant}. \end{proof} \begin{theorem} \label{Theo:Back.Bisimilarity} For $W$, the relation $\approx$ is the bisimilarity of $\ensuremath{\mathscr{T}_B(W)}$, i.e., $\approx = \sim_B$. \end{theorem} \section{Related Work} \label{Sect:Related} The partial knowledge of a microcosm w.r.t. its enclosing world of events resembles the classical ``knowledge vs common knowledge'' model \cite{Halp+Mose:1990,Fagi+Halp+Mose+Vard:2003}. The latter works, however, take an algorithmic approach. Whereas our work is proof-theoretic. Ben-Zvi and Moses \cite{BenZ+Mose:2010,BenZ:2011} take the same approach to coin the \textit{Syncausality} as an extension to \textsf{happens-before} for synchronised computations. Gonczarowski and Moses \cite{Gonc+Mose:2013} too generalise the classic model to characterise the interactive epistemic state when temporal constraints must be met. The final work in this thread \cite{Abdu:2005} extends the classic model for reasoning about trust in distributed settings. Burckhardt \cite{Burc:2014} takes a novel approach to define causal consistency not just in terms of \textsf{happens-before}, but also w.r.t. arbitration order and visibility order. The gain is a more precise definition of how causality is used to ensure consistency. In addition to being model theoretic, unlike our work, his approach is not based on explicit causality \cite{Bail+Feke+Ghod+Hell+Stoi:2012}. One particular motivation for confining the universal knowledge of a world of events to microcosms is scalability. Systems that reduce the overhead of maintaining scalable causal consistency in wide-area replicated key-value stores include Orbe \cite{Du+Elni+Roy+Zwae:2013}, COPS \cite{Lloy+Free+Kami+Ande:2011}, Eiger \cite{Lloy+Free+Kami+Ande:2013}, and ChainReaction \cite{Alme+Leit+Rodr:2013}. COPS, in particular, defines \textit{causal+ consistency}, which extends causal consistency with convergent conflict handling. This ensures that replicas that see concurrent updates will be updated in a consistent fashion. The systems mentioned above can incur significant overhead (in computation, storage, network load, and latency) to maintain causal consistency in scalable fashion. Du et. al \cite{Du+Iorg+Roy+Zwae:2014} explain the performance overhead of causal consistency vs. eventual consistency. They introduce a protocol to reduce this overhead at the cost of degrading the quality-of-service (offered to the client) by significantly increasing data staleness. \section{Conclusion and Future Work} \label{Sect:Conclusion} To the best of our knowledge, this is the first proof-theoretic modelling of causality in distributed systems, with special emphasis on partiality of causal knowledge. In our model, a device has strictly less causal information than a holistic causality store (Lemma~\ref{Lemm:WoE.More.Accurate.Micro}). We offer rules for deducing causal information both when a device is online and offline (Definitions~\ref{Defn:Micro.Decision} and \ref{Defn:Offline.Rules}). We prove properties of our deductions, which are both theoretically attractive and practically valuable (Theorems~\ref{Theo:Rules.Comp}, \ref{Theo:Micro.Rules.Const}, Corollary~\ref{Corr:Mu.Hats}, and Lemmata~\ref{Lemm:Offline.Not.Refute.Online} and \ref{Lemm:Offline.Not.Disagree.Online}). We refute a causality folklore using a mechanical proof (Lemma~\ref{Lemm:Sample.Refutation.1}). We define two notions of bisimilarity (Definitions~\ref{Defn:For.Bisimilarity} and \ref{Defn:Back.Bisimilarity}) to prove that the order of addition or removal of causal data is irrelevant for bisimilar devices (Theorems~\ref{Theo:For.Order.Irrelevant} and \ref{Theo:Back.Order.Irrelevant}, respectively). There are two immediate improvements to our model that form interesting future work. The first is the study of how to retain (\ref{Misc:M4}) whilst still not disallowing arrival of new information (like Fig.~\ref{Fig:NVCs}). The second is getting forward bisimilarity (and, therefore, backward bisimilarity) to also consider evolution from one microcosm to another by updates (as well as additions). Our modelling does not take it into consideration that information about concurrent events might arrive not at the same time. That lag makes a device observe an internal ordering for concurrent events. The interplay between the concurrency and the internal order becomes more interesting when relaying the concurrency to the next device in the vicinity. Studying that interplay is future work. We anticipate that a new set of proof systems will be required, their status w.r.t. the ones in this paper also requires dedicated study. Another related future work is to take arbitration and visibility into account. The ability to reason about partial causal information suggests positive interaction with causal+ consistency: replicas that are actually causal but for which the causality is not known yet will remain consistently updated as the known causality increases (i.e., updates do not have to be redone as knowledge increases). This is an important property of causal+ consistency that can be a useful model to have together with the deduction systems introduced in this paper. Future work will reveal how the ability to deduce causality can increase the efficiency of COPS (and its counterparts) by reducing the overhead. \paragraph*{\textbf{Acknowledgements}} This work was partially funded by the \href{syncfree.lip6.fr}{SyncFree} project in the European Seventh Framework Programme under Grant Agreement 609551 and by the Erasmus Mundus Joint Doctorate Programme under Grant Agreement 2012-0030. Our special thanks to the \href{syncfree.lip6.fr}{SyncFree} peers for their prolific comments on the early versions of this work. We would like to also thank the anonymous referees for their constructive discussion over the ICE forum. \bibliographystyle{eptcs}
{'timestamp': '2016-08-12T02:01:38', 'yymm': '1608', 'arxiv_id': '1608.03326', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03326'}
arxiv
\section*{Abstract} Encoding brain regions and their connections as a network of nodes and edges captures many of the possible paths along which information can be transmitted as humans process and perform complex behaviors. Because cognitive processes involve large and distributed networks of brain areas, principled examinations of multi-node routes within larger connection patterns can offer fundamental insights into the complexities of brain function. Here, we investigate both densely connected groups of nodes that could perform local computations as well as larger patterns of interactions that would allow for parallel processing. Finding such structures necessitates that we move from considering exclusively pairwise interactions to capturing higher order relations, \new{concepts} naturally expressed in the language of algebraic topology. \new{These tools can be used to study} mesoscale network structures that arise from the arrangement of densely connected substructures called \emph{cliques} in otherwise sparsely connected brain networks. We detect cliques (all-to-all connected sets of brain regions) in the average structural connectomes of 8 healthy adults scanned in triplicate and discover the presence of more large cliques than expected in null networks constructed via wiring minimization, providing architecture through which brain network can perform rapid, local processing. We then locate \emph{topological cavities} of different dimensions, around which information may flow in either diverging or converging patterns. These \new{cavities} exist consistently across subjects, differ from those observed in null model networks, and -- importantly -- link regions of early and late evolutionary origin in long loops, underscoring their unique role in controlling brain function. These results offer a first demonstration that techniques from algebraic topology offer a novel perspective on structural connectomics, highlighting loop-like paths as crucial features in the human brain's structural architecture. \section*{Introduction} Macroscopic computation and cognition in the human brain are affected by an intricately interconnected collection of neurophysical mechanisms \cite{bassett2010efficient,sporns2005human}. Unlike modern parallel computers, which operate through vast numbers of programs running in tandem and in isolation from one another, it is understood that many of these processes are supported on anatomically specialized brain regions that constantly share information among themselves through a network of white matter tracts \cite{hagmann2008mapping}. One approach for understanding the function of such a system begins with studying the organization of this white matter substrate using the language of networks \cite{sporns2015cerebral,bassett2011conserved,sporns2013human}. Collections of regions that are pairwise tightly interconnected by large tracts, variously known as communities \cite{porter2009communities}, modules \cite{meunier2009age}, and rich clubs \cite{van2011rich,senden2014rich}, have been the subject of substantial prior study. Moreover, they have given critical insights into the large-scale structural units of the brain that give rise to many common cognitive functions \cite{chen2008revealing,medaglia2015cognitive}. Such communities easily and rapidly transmit information among their members, facilitating local integration of information \cite{sporns2016modular}. Often left implicit in such investigations of the white matter network is the understanding that just as important as the strong internal connections in communities are the relative \emph{weakness} of connections to external regions. This tendency to focus on strongly connected local regions arises naturally because standard network analyses are based on local properties of the network at individual vertices, where local edge strength is the primary feature \cite{bassett2006small,bullmore2009complex,bullmore2011brain}; the particular choice of quantitative language serves as a filter that diverts attention toward certain facets of the system. However, if one takes a more macro-scale view of the network, the small or absent white matter tracts intuitively serve to isolate processes carried on the strong white matter tracts from one another. Such structure facilitates more traditional conceptual models of parallel processing, wherein data is copied or divided into multiple pieces in order to rapidly perform distinct computations, and then recombined \cite{graham2011packet}. Together, the two notions of dense \new{cliques} and isolating cavities provide a picture of a system that performs complex computations by decomposing information into coherent pieces to be disseminated to local processing centers, and then aggregating the results. In order to quantitatively characterize this macroscale structure, we employ an enrichment of networks that comes from the field of algebraic topology \cite{ghrist2014elementary}, developed precisely to understand the interplay between these weak and strong connections in systems \cite{ghrist2008barcodes}. Beginning with a structural white matter network, we first extract the collection of all-to-all connected subgraphs, called \emph{cliques}, which represent sets of brain regions that may possess a similar function, operate in unison, or share information rapidly \cite{sizemore2016classification}. Attaching these cliques to one another following a map given by the network creates a topological object called a \emph{clique complex} from which we can extract certain patterns of strongly connected regions called \emph{cycles} \cite{giusti2015clique}. \new{Chordless cycles} correspond to extended paths of potential information transmission along which computations can be performed serially to effect cognition in either a divergent or convergent manner\new{, and we refer to these ``enclosed spaces'' as \emph{topological cavities}\footnote{\new{In the mathematical literature, these are called \emph{non-trivial homology classes}. However, due to the extensive and potentially confusing collision with the use of the word ``homology'' in the study of brain function, here we elect to use this new terminology outside of references and necessary mathematical discussion in the Methods and Supplementary Information. Throughout, the word ``homology'' referes to the mathematical, rather than the biological, notion.}} in the network}. We hypothesize that the spatial distributions of cliques and \new{cavities} will differ in their anatomical locations, corresponding to their differential putative roles in neural computations. To address these hypotheses, we construct structural brain networks from diffusion spectrum imaging (DSI) data acquired from eight volunteers in triplicate. We measure node participation in cliques and compare these with a minimally wired null model \cite{betzel2016modular}. We also demonstrate the correspondence between the anatomical location of cliques and the anatomical location of the brain's structural rich club: a group of hubs that are densely connected to one another. Next, we study \new{topological cavities} using a recently developed method from algebraic topology, which detects the presence and robustness \new{, summarized by a quantity called \emph{persistence),} of shell-like motifs of cliques called \emph{cycles}} in the network architecture. Specifically, we recover \new{all minimal length cycles corresponding to four persistent topological cavities} in the consensus structure, and show that these \new{features} are robustly present across subjects through multiple scans. Our results demonstrate that while cliques are observed in the structural core, \new{cycles enclosing topological cavities} are observed to link regions of subcortex, frontal cortex, and parietal cortex in long loops, underscoring their unique role in controlling brain function \cite{gu2015controllability,betzel2016optimally,muldoon2016stimulation}. \section*{Results} To extract relevant architectural features of the human structural connectome, we first encoded diffusion spectrum imaging (DSI) data acquired from eight subjects in triplicate as undirected, weighted networks. In this network, nodes correspond to 83 brain regions defined by the Lausanne parcellation \cite{cammoun2012mapping} and edges correspond to the density of white matter tracts between node pairs (Fig.~\ref{fig:1}a). We initially study a group-averaged network, and then demonstrate that our results are consistently observed across individuals in the group as well as across multiple scans from the same individual. \begin{figure}[h] \centering \includegraphics[width = 3.5in]{Figure1.png} \caption{\textbf{Cliques are features of local neighborhoods in structural brain networks.} \emph{(a)} Diffusion spectrum imaging (DSI) data can be summarized as a network of nodes corresponding to brain regions, and weighted edges corresponding to the density of white matter streamlines reconstructed between them. Here we present a group-averaged network, where each edge corresponds to the mean density of white matter streamlines across eight subjects scanned in triplicate. \new{We show} the network at an edge density $\rho = 0.25$, and display its topology on the brain (\emph{top}), and on a circle plot (\emph{bottom}). \new{This and all brain networks are drawn with BrainNetViewer \cite{xia2013brainnet}.} \emph{(b)} All-to-all connected subgraphs on $k$ nodes are called $k$-cliques. For example, 2-, 3-, and 4-cliques are shown both as schematics and as features of a structural brain network. \emph{(c)} A maximal 4-clique has 3-, 2-, and 1-cliques as faces. \emph{(d)} For statistical validation, we construct a minimally wired null model by linking brain regions by edge weights equal to the inverse of the Euclidean distance between nodes \new{corresponding to brain region centers. Here we show an example of this scheme on 15 randomly chosen brain regions.}} \label{fig:1} \end{figure} \subsection*{\new{Cliques} in the Human Structural Connectome}~ \new{Here, we use the group-averaged network thresholded at an edge density ($\rho$) of 0.25 for computational purposes and for consistency with prior studies \cite{sizemore2016classification}. Results at other densities are similar, and details can be found in the Supplimentary Information. As a null-model, we use minimally wired networks (Fig.~\ref{fig:1}d) created from assigning edge weights to the inverse Euclidean distance between brain region centers (see Methods) observed in each of 24 scans. This model mimics the tendency of the brain to conserve wiring cost by giving edges connecting physically close nodes higher weight than edges between distant nodes.} \new{For each network, we now enumerate all maximal} $k$-cliques. \new{Recall that a $k$-clique is} a set of $k$ nodes having all pairwise connections (see Fig.~\ref{fig:1}b for 2-, 3-, and 4-cliques representing edges, triangles, and tetrahedra, respectively.) By definition, a subgraph of a clique will itself be a clique of lower dimension, called a \emph{face}. A \emph{maximal} clique is one that is not a face of any other (see Fig.~\ref{fig:1}c for a maximal 4-clique, which contains 3-, 2-, and 1-cliques as faces). To understand the anatomical distribution of maximal cliques in both real and null model networks, we count the number of maximal $k$-cliques in which a node is a member, and refer to this value as the node participation, $P_k(v)$ (see Methods). Summing over all $k$ gives the total participation, $P(v)$. We observe that the distribution of maximal clique degrees is unimodal in the minimally wired null model and bimodal in the empirical data (see Fig.~\ref{fig:fig2}a). Anatomically, we observe a general progression of maximal clique participation from anterior to posterior regions of cortex as we detect higher degrees (Fig.~\ref{fig:sfig_corr}). Indeed, maximal cliques of 12--16 nodes contain nearly all of the visual cortex. This spatial distribution suggests that large interacting groups of brain regions are required for early information processing, while areas of frontal cortex driving higher-order cognition utilize smaller working clusters. We also observe that the human brain displays smaller maximal cliques than the minimally wired null model, a fact that might support its distributed processing. \begin{figure*}[h!] \centering \includegraphics[width = \textwidth]{Figure2} \caption{\textbf{Spatial distribution of maximal cliques varies between \new{average} DSI and minimally wired null model.} \emph{(a)} Distribution of maximal cliques in the \new{average} DSI (black) and \new{individual} minimally wired (gray) networks, thresholded at an edge density of $\rho=0.25$. Heat maps of node participation on the brain for a range of clique degrees equal to 4--6 (left), 8--10 (middle), and 12--16 (right). \emph{(b)} Node participation in maximal cliques sorted by the putative cognitive system to which the node is affiliated in functional imaging studies \cite{power2011functional}. We show individual node values (\emph{top}) as well as the difference between real and null model ($P_k^{DSI}-P_k^{MW}$; bottom) according to the colormap (\emph{right}). Individual node labels are listed in Fig. \ref{fig:sfig_table}.} \label{fig:fig2} \end{figure*} The anterior-posterior gradient of maximal clique size can be complemented by additionally analyzing regional variation in the cognitive computations being performed. Specifically, we ask whether node participation in maximal cliques differs in specific cognitive systems \cite{power2011functional} (Fig.~\ref{fig:fig2}b). We observe that the largest maximal cliques are formed by nodes located almost exclusively in the \new{subcortical, dorsal attention, visual, and default mode systems}, suggesting that these systems are tightly interconnected and might utilize robust topologically-local communication. Critically, this spatial distribution of the participation in maximal cliques differs significantly from the minimally wired null model, particularly in the cingulo-opercular and subcortical systems. We hypothesized that these differences may be driven by the excess of maximal 8-cliques in the minimally wired network (Fig.~\ref{fig:fig2}a). Expanding on the difference in node participation ($P_k^{DSI}(v) - P_k^{MW}(v)$), we see indeed that the large discrepancies between empirical and null model networks in cingulo-opercular and subcortical systems are caused by a difference in maximal cliques of approximately eight nodes (Fig.~\ref{fig:fig2}b, bottom). A node with high participation must in turn be well connected locally\footnote{Note the converse is not necessarily true. As an example consider a node that only participates in one maximal 16-clique.}. Therefore we expect the participation of a node to act similarly to other measures of connectivity. To test this expectation, we examine the correlation of node participation with node strength, the summed edge weight of connections emanating from a node, as well as with node communicability, a measure of the strength of long distance walks emanating from a node (Fig.~\ref{fig:fig3}a). We find that both strength and communicability exhibit a strong linear correlation with the participation of a node in maximal cliques (Pearson correlation coefficient $r = 0.957$ and $r = 0.858$, respectively). \begin{figure}[h!] \centering \includegraphics[width = 3.5in]{Figure3} \caption{\textbf{Maximal clique participation tracks with network measures.} \emph{(a)} Scatter plot of node participation and node strength (\emph{top}) or communicability (\emph{bottom}). \emph{(b)} Calculated $k$-core (\emph{top}) and $s$-core decomposition in relation to participation in maximal cliques \new{with rich club nodes (shown $k_{RC}=43$; see Methods and Fig.~\ref{fig:sfig_richclub}) indicated in orange (\emph{bottom})}. Size indicates maximum $k$-core or $s$-core level attained by the node, while color indicates the participation $P(v)$. } \label{fig:fig3} \end{figure} These results indicate that regions that are strongly connected to the rest of the brain by both direct paths and indirect walks also participate in many maximal cliques. Such an observation suggests the possibility that brain hubs -- which are known to be strongly connected with one another in a so-called \emph{rich-club} -- play a key role in maximal cliques. To test this possibility, we measure the association of brain regions to the rich-club using notions of coreness. A $k$-core of a graph $G$ is a maximal connected subgraph of $G$ in which all vertices have degree at least $k$, and an $s$-core is the equivalent notion for weighted graphs (see Methods). Using these notions, we consider how the $k$-core and $s$-core decompositions align with high participation (Fig.~\ref{fig:fig3}b). In both cases, nodes with higher participation often achieve higher levels in the $k$- and $s$-core decomposition. Moreover, we also observe the frequent existence of rich club connections between nodes with high participation (Fig.~\ref{fig:fig3}b, \emph{bottom}). Together, these results suggest that rich-club regions of the human brain tend to participate in local computational units in the form of cliques. \subsection*{Cavities in the Structural Connectome}~ \new{Whereas cliques in the DSI network act as neighborhood-scale building blocks for the computational structure of the brain, the relationships between these blocks can be investigated by studying the unexpected absence of strong connections, which can be detected as topological cavities in the structure of the brain network. Because connections are treated as communication channels along which brain regions can signal one another and participate in shared neural function, the absence of such connections implies a decreased capacity for communication which serves to enhance the segregation of different functions}. \new{To identify topological cavities in a weighted network, we construct a sequence of binary graphs, each included in the next (Fig.~\ref{fig:fig4}a), known as a \emph{filtration}. Beginning with the empty graph we replace unweighted edges one at a time according to order of decreasing edge weight, and we index each graph by its \emph{edge density} $\rho$, given by the number of edges in the graph divided by the number of possible edges. After each edge addition, we \new{extract} ``shell-like'' motifs of $k$-cliques called (non-trivial) \emph{$(k-1)$-cycles}\footnote{\new{This shift in index is due to geometry: a $2$-clique is a 1-dimensional line segment, a $3$-clique is a 2-dimensional triangle, etc.}}, each of which encloses a $k$-dimensional topological cavity in the structure. When $k$ is clear or not pertinent, we will supress it from the notation, and refer simply to ``cycles'' and ``cavities''. While any cavity is surrounded by at least one cycle, often multiple cycles surround the same cavity. However, any two cycles that detect the same cavity will necessarily differ from one another by the boundaries of some collection of $(k+1)$-cliques (see Supporting Information and Fig.~\ref{fig:sfig_ph5}). Any two such cycles are called \emph{topologically equivalent}, so each topological cavity is detected by a non-trivial\footnote{\new{The equivalence class containing the cycle consisting of a single vertex is called \emph{trivial} and bounds the ``empty'' cavity.}} \emph{equivalence class} of cycles. We can represent a topological cavity using any of the cycles within the corresponding equivalence class, but for purposes of studying computational architectures it is reasonable to assume information will travel along paths of minimal length; thus, in this analysis we will consider the collection of cycles in an equivalence class with the minimal number of nodes\footnote{\new{In the absence of a filtration, there are serious computational issues involved in locating minimal-size representatives of equivalence classes. However, in this setting the computation is easily performed using standard algorithms (see Methods).}} and call these the \emph{minimal cycles} representing the cavity.} \new{As we move through the filtration by adding edges, the structure of the cycles, and thus of the cavities they represent, will evolve. We consider an example in Fig.~\ref{fig:fig4}a, showing a green minimal cycle surrounding a 2D cavity which first appears (is \emph{born}) in the graph sequence at $\rho_{birth}$ (cyan). As an edge completing a $3$-clique is added, the minimal cycle representative shrinks to four nodes in size, then finally is tessellated by $3$-cliques (\emph{dies}) at $\rho_{death}$ (orange). We record $\rho_{birth}$ and $\rho_{death}$ for all topological cavities (e.g., non-trivial equivalence classes of cycles) found within the filtration, and display them on a \emph{persistence diagram} (Fig.~\ref{fig:fig4}b). Cavities that survive many edge additions have a long \emph{lifetime}, defined as $\rho_{death} - \rho_{birth}$, or a large death-to-birth ratio, $\rho_{death}/\rho_{birth}$. Such cycles are commonly referred to as \emph{persistent cavities} and in many applications are considered the ``topological features'' of the system.} \begin{figure*}[] \centering \includegraphics[width = \textwidth]{Figure4} \caption{\textbf{Tracking clique patterns through a network filtration reveals \new{key topological cavities in the structural brain network}.} \emph{(a)} Example filtration of a network on 15 nodes shown in the brain across edge density ($\rho$). Blue line on the axis indicates the density of birth ($\rho_{birth}$) of the 2D cavity surrounded by the green minimal cycle. As edges are added, 3-cliques (cyan) form and shrink the cavity and consequentially the minimal green cycle is now four nodes in size. Finally, the orange line marks the time of death ($\rho_{death}$) when the cavity is now filled by 3-cliques. \emph{(b)} Persistence diagram for the cavity surrounded by the green cycle from panel \emph{(a)}. \emph{(c)} Persistence diagrams for the group-averaged DSI (teal) and minimally wired null (gray) networks in dimensions one (left) and two (right). Cavities in the group-averaged DSI network with long lifetime or high death-to-birth ratio are shown in unique colors and will be studied in more detail. \emph{(d)} Box plots of the death-to-birth ratio $\pi$ for cavities of two and three dimensions in the group-averagd DSI and minimally wired null networks. Colored dots correspond to those highlighted in panel \emph{(c)}. \new{The difference between $\pi$ values for \new{3D topological cavities} in the average DSI data versus the minimally wired null model was not found to be significant.} \emph{(e)} Minimal \new{cycles representing each persistent cavity at $\rho_{birth}$} noted in panels \emph{(c)}, \emph{(d)} shown in the brain (\emph{top}) and as a schematic (\emph{bottom}).} \label{fig:fig4} \end{figure*} \new{We investigate the persistence of 2D and 3D cavities (respectively represented by equivalence classes of $1$- and $2$-cycles) in the group-average DSI network and minimally wired null networks (see Fig.~\ref{fig:fig4}c). There are substantially fewer persistent cavities in the group-average DSI network than in the null models. To illustrate the structure of these cavities, we select four representative cavities with exceedingly long lifetimes or a high $\rho_{death}$ to $\rho_{birth}$ ratio (Fig.~\ref{fig:fig4}c,d) in the empirical data, and for each we find the minimal-length representative cycles at $\rho_{birth}$ (Fig.~\ref{fig:fig4}e)\footnote{\new{Such cycles for all of the persistent cavities found in the empircal data are illustrated in Fig.~\ref{fig:allcycles1} and \ref{fig:allcycles2}}}. The first persistent cavity appears as early as $\rho = 0.003$ and is minimally enclosed by the unique blue cycle composed of the thalamus and caudate nucleus of both hemispheres. The green cycle connecting the medial and lateral orbitofrontal, rostaral anterior cingulate, putamen, and superior frontal cortex is the only minimal cycle surrounding a long-lived cavity in the left hemisphere. The final persistent 2D cavity in the average DSI data is found in the right hemisphere between the medial orbitofrontal, accumbens nucleus, any of the subcortical regions hippocampus, caudate nucleus, putamen, thalamus, and amygdala, and any of the rostral middle frontal, lateral orbitofrontal, medial orbitofrontal of the left hemisphere, and rostral anterior cingulate from both hemispheres (see Fig.~\ref{fig:sfig_1cycles}e for all 12 minimal representatives). Finally, the purple octahedral cycle made from 3-cliques contains the inferior and middle temporal, lateral occipital, inferior parietal, supramarginal, superior parietal, and either of the superior temporal and insula of the left hemisphere, and encloses the longest-lived 3D cavity in the structural brain network.} \subsection*{Test-ReTest Reliability and Other Methodological Considerations}~ It is important to ask whether the architectural features that we observe in the group-averaged DSI network can also be consistently observed across multiple individuals, and across multiple scans of the same individual \new{to ensure these cavities are not artifacts driven by a few outliers. Comparison of persistent cavities arising from two different networks is complicated by our notion of equivalence of cavities, and our desire to work with particular representative cycles. To capture the extent to which the cavities and their minimal representatives in the average DSI data are present in the individual scans, we record the collection of cliques that compose each minimal cycle representing the equivalance class (as seen in Fig.~\ref{fig:fig4}e), and check both for the existence of one of those collections of cliques, corresponding to the existence of the same strong fiber tracts, and, more stringently, for the presence of a topological cavity represented by that cycle in each individual's DSI network (see Supporting Information for more details). We observed that the subcortical cycle (Fig.~\ref{fig:fig4}e, blue) exists and these nodes (thalamus and caudate nucleus of both hemispheres) surround an equivalent 2D cavity in at least one scan of all individuals and the late-developing subcortical-frontal cycle (Fig.~\ref{fig:fig4}e, red) surrounds a cavity found in seven of the eight individuals in at least one of three scans (Fig.~\ref{fig:sfig_1cycles}b,f). The earlier arriving subcortical-frontal cycle (Fig.~\ref{fig:fig4}e, green) is present in all individuals and a similar cavity is seen at least once in all individuals (Fig.~\ref{fig:sfig_1cycles}d). Finally, we observe that the octahedral connection pattern in posterior parietal and occipital cortex (Fig.~\ref{fig:fig4}e, purple) is present at least once in seven of eight individuals and these regions enclose a similar cavity at least once in six of these individuals (Fig.~\ref{fig:sfig_1cycles}h). In the opposite hemisphere, the cyclic connection patterns and similar cavities appear though not as regularly (Fig.~\ref{fig:sfig_main4}). Finally we check the existence of similar cavities within the minimally wired null models, and see cavities denoted by the green and purple cycles are never seen (Fig.~\ref{fig:sfig_main4}). However, similar cavities to those represented by the red and blue minimal cycles appear frequently in the null model, though with different birth/death densities and lifetimes. In summary we find topological cavities observed in the group-averaged DSI network appear consistently across individuals, suggesting their potential role as conserved wiring motifs in the human brain.} \begin{figure*}[h!] \centering \includegraphics[width = \textwidth]{Figure5} \caption{\textbf{Cycles \new{and similar cavities in the average DSI network} are consistently seen across individuals.} \new{\emph{(a),(c),(e),(g)} Normalized summed edge weights of the individual scan data connecting nodes seen in minimal cycle(s) recovered from average DSI. \emph{(b),(d),(f),(h)} Connections between indicated cycle nodes in each scan shown thresholded at the minimal weight of expected cycle edges. A gray background indicates a similar cavity found in this scan.}} \label{fig:sfig_1cycles} \end{figure*} In addition to consistency across subjects and scans, it is important to determine whether the known high connectivity from subcortical nodes to the rest of the brain may be artificially \new{obscuring non-trivial} cortico-cortical \new{cavities} important for brain function. To address this question, we examined the 66-node group-average DSI network composed only of cortical regions, after removing subcortical regions, insula, and brainstem. We recovered \new{a long-lived topological cavity surrounded by four cycles of minimal length} composed of nine nodes connecting temporal, parietal, and frontal regions (Fig.~\ref{fig:fig6}). \new{Note in the schematic of Fig.~\ref{fig:fig6}a we see clearly two 2D cavities. The birth edge here was between the lateral orbitofrontal and superior temporal regions, which prevents us from determining whether the exact minimal cycle surrounding this cavity follows the superior frontal (LH)/posterior cingulate or the superior frontal (RH)/caudal middle frontal branch of the top loop. Following either of these two branches (then either of the banks of the superior temporal sulcus or middle temporal route) gives four cycles in which two are equivalent to each other but not to either cycle in the other pair. We will accept all of these four as minimal maroon cycles since any of the four could be minimal representatives}. Moreover, \new{at least one of these minimal cycles and corresponding cavity} was observed in each scan of every individual (Fig.~\ref{fig:sfig_1cyclesub}c), and often in the opposite hemisphere as well (Fig.~\ref{fig:sfig_1cyclesub}d). These results reveal that cortico-cortical cycles are indeed present and suggest their potential utility in segregating function across the brain. \begin{figure*}[h!] \centering \includegraphics[width = \textwidth]{Figure6} \caption{\textbf{Removal of subcortical \new{nodes allows for detection of nine-node cortical cycle enclosing large 2D cavity}.} \emph{(a)} \new{Minimal cycles} shown in the brain (\emph{left}) and as a schematic (\emph{right}). \emph{(b)} Persistence diagram of $DSI^{cort}$ and $MW^{cort}$. \new{Persistent feature corresponding to minimal cycles} in \emph{(a)} \new{indicated with maroon dot}.} \label{fig:fig6} \end{figure*} \section*{Discussion} In this study, we describe a principled examination of multi-node routes within larger connection patterns that are not accessible to network analysis methods that exclusively consider pairwise interactions between nodes. Our approach draws on concepts from a discipline of mathematics known as \emph{algebraic topology} to define sets of all-to-all connected nodes as structural units, called \emph{cliques}, and then to use the clique architecture of the network to detect structural topological cavities, \new{detected by the existence of non-trivial representative} \emph{cycles}. Using this approach, we show that node participation in maximal cliques varies spatially and by cognitive systems, suggesting a global organization of these neighborhood-scale features. These cliques form shell-like patterns of connectivity in the human structural connectome, which separate relatively early-evolving regions of the subcortex with higher-order association areas in frontal, parietal, and temporal cortex that evolved on more recent time scales. We found the recovered \new{topological cavities} exist consistently across individuals and are not expected in a spatially embedded null model, emphasizing their importance in neural wiring and function. These results offer a first demonstration that techniques from algebraic topology offer a novel perspective on structural connectomics, highlighting cavernous spaces as crucial features in the human brain's structural architecture. \subsection*{Algebro-topological Tools for Neural Data Analysis}~ Algebraic topology is a relatively young field of pure mathematics that has only recently been applied to the study of real-world data. However, the power of these techniques to measure structures that are inaccessible to common graph metrics has gained immediate traction in the neuroscience community. Here, we highlight a few notable examples from the growing literature; a more comprehensive recent account can be found in \cite{giusti2016two}. At the neuron level, persistent persistence has been used to detect intrinsic structure in correlations between neural spike trains \cite{giusti2015clique}, expanding our understanding of the formation of spatial maps in the hippocampus \cite{dabaghian2012topological}. Moreover, at the level of large-scale brain regions, these tools have been exercised to characterize the global architecture of fMRI data \cite{stolz2014computational}. Based on their unique sensitivity, we expect these algebric-topological methods to provide novel contributions to our understanding of the structure and function of neural circuitry across all scales at which combinatorial components act together for a common goal: from firing patterns coding for memory \cite{rajan2016recurrent,leen2015simple} to brain regions interacting to enable cognition. \new{Our study uses algebraic topology in the classical form to obtain a global understanding of the structure, and in conjunction, it investigates particular topological features themselves and relates these features to cognitive function. Cycle representatives have previously been considered in biology \cite{chan2013topology,petri2014homological,lord2016insights}, but to our knowledge this is a first attempt to compare topological features in multiple brains.} \subsection*{\new{Cliques} and Cavities for Computations}~ Cliques and \new{minimal cycles representing cavities} are structurally positioned to play distinct roles in neural computations. Cliques represent sets of brain regions that may possess a similar function, operate in unison, or share information rapidly \cite{sizemore2016classification}. Conversely, \new{minimal cycles} correspond to extended paths of potential information transmission along which computations can be performed serially to affect cognition in either a divergent or convergent manner. Indeed, the \new{shell}-like or chain-like nature of cycles is a structural motif that has previously been -- at least qualitatively -- described in neuroanatomical studies of cellular circuitry. In this context, such motifs are known to play a key role in learning \cite{hermundstad2011learning}, memory \cite{rajan2016recurrent}, and behavioral control \cite{levy2001distributed,fiete2010spike}. \new{The presence of minimal cycles suggests a possible role for polysynaptic connections and their importance to neural computations,} consistent with evidence from the field of computational neuroscience highlighting the role of highly structured circuits in sequence generation and memory \cite{rajan2016recurrent,hermundstad2011learning}. Indeed, in computational models at the neuron level, architectures reminiscent of chains \cite{levy2001distributed,fiete2010spike} and rings are particularly conducive to the generation of sequential behavioral responses. It is interesting to speculate that the presence of these \new{structures} at the much larger scale of white matter tracts could support diverse neural dynamics and a broader repertoire of cognitive computations than possible in simpler and more integrated network architectures \cite{tang2016structural}. \new{Another consideration concerns the apparent asymmetry of our results with respect to left and right cerebral hemispheres. While unanticipated, we note that in some cases they have intuitive mathematical underpinnings. For example, in Fig.~\ref{fig:fig3}, we explicitly count maximal cliques, so one edge difference between a region in the left and right hemisphere could result in a large difference in the number of observed maximal cliques. Interestingly, despite this fact we still observe a strong correlation between node strength and $P(v)$, instilling confidence in these results. From a neuroscience point of view, brain asymmetries are not wholly unexpected. There is a storied and ever-growing literature describing the lateralization (i.e., asymmetries) of brain function \cite{galaburda1978right}. While speech generation \cite{rasmussen1977role} and language processing \cite{desmond1995functional,thulborn1999plasticity} are among the most commonly-cited functions to exhibit lateralization \cite{doron2012dynamic,chai2016functional}, such effects have also been linked to a diverse group of other cognitive domains. These include emotion \cite{wager2003valence}, processing of visual input \cite{sandi1993visual}, and even working memory \cite{carpenter2000working}. In addition, a number of studies have also reported the emergence of pathological lateralization or the disruption of asymmetries with neurocognitive disorders including ADHD \cite{oades1998frontal}. Our study does not offer a conclusive demonstration that the observed asymmetries arise from the lateralization of any specific brain function; we merely wish note that there is a precedent for such observations.} \subsection*{Evolutionary and Developmental Drivers}~ Network filtration revealed several persistent \new{cavities} in the macroscale human connectome. While each \new{minimal} cycle \new{surrounding these cavities} involved brain regions interacting in a distinct configuration, we also observed commonalities across these structures. One such commonality was \new{these minimal} cycles tended to link evolutionarily old structures with more recently-developed neo-cortical regions \cite{rakic2009evolution}. For example, the green cycle depicted in Fig.~\ref{fig:fig4}e linked the putamen, an area involved in motor behavior \cite{middleton2000basal}, with \new{the rostral anterior} cingulate cortex, associated with higher-order cognitive functions such as error-monitoring \cite{braver2001anterior} and reward processing \cite{kringelbach2004functional}. This observation led us to speculate that the emergence of these \new{cavities} may reflect the disparate timescales over which brain regions and their circuitry have evolved \cite{gu2015emergence}, through the relative paucity of direct connections between regions that evolved to perform different functions. This hypothesis can be investigated in future work comparing the \new{clique and cavity structure} of the human connectome with that of non-human connectomes from organisms with less developed neocortices. \subsection*{Towards a Global Understanding of Network Organization} Though we highlighted \new{minimal} cycles in the brain, by nature persistence describes the global organization of the network. Often regions in the brain wire minimally to conserve wiring cost \cite{bassett2010efficient,bullmore2012,klimm2014resolving,lohse2014resolving}, though there are exceptions that give the brain its topological properties such as its small-world architecture \cite{bassett2006small,pessoa2014understanding,hilgetag2016brain,muldoon2016small,bassett2016small}. Following this idea, we could interpret the difference in \new{the number of persistent cavities} between the minimally wired and DSI networks as a consequence of the non-minimally wired edges, which \new{tessellate cavities} in the brain itself. Yet when the subcortical regions are removed, the persistent \new{cavities} of the minimally wired and DSI networks are much more similar (Fig.~\ref{fig:sfig_1cyclesub}b). This suggests that the wiring of cortical regions may be more heavily influenced by energy conservation than the wiring of subcortical regions. \new{Additionally the drop in the number and lifetime of persistent cavities when subcortical regions are included indicates that these subcortical regions may prematurely collapse topological cavities. The often high participation of subcortical regions in maximal cliques suggests these well-connected nodes may have hub-like projections to regions involved in cortical cycles, thus tessellating the cortical cavity with higher dimensional cliques.\footnote{Topologically these subcortical nodes are \emph{cone points}.} Previous studies have found that networks with ``star-like'' configurations are optimally efficient in terms of shortest-path efficiency, but also efficient in terms of a random walk-based measure of efficiency \cite{goni2013}. That is, networks optimized to have one or the other type of efficiency tend to have stars. Thus, stars appear to be useful configurations for fast communication, both along shortest paths and also in an unguided sense along random walks. The fact that we see star-like projections to cycles from subcortical regions may suggest that they are useful for efficient communication.} \subsection*{Methodological Considerations} An important consideration relates to the data from which we construct the human structural connectome. DSI and tractography, non-invasive tools for mapping the brain's white-matter connectivity, have some limitations. Tractography algorithms trade off specificity and sensitivity, making it challenging to simultaneously detect true connections while avoiding false connections \cite{thomas2014anatomical}, fail to detect superficial connections (i.e. those that do not pass through deep white matter)\cite{reveley2015superficial}, and have challenges tracking ``crossing fibers'', connections with different orientations that pass through the same voxel \cite{wedeen2008diffusion}. Nonetheless, DSI and tractography represent the only techniques for non-invasive imaging and reconstruction of the human connectome. While such shortcomings limit the applicability of DSI and tractography, they may prove addressable with the development of improved tractography algorithms and imaging techniques \cite{pestilli2014}. \section*{Conclusion} In conclusion, here we offer a unique perspective on the structural substrates of distinct types of neural computations. While traditional notions from graph theory and network science preferentially focus on local properties of the network at individual vertices or edges \cite{bassett2006small,bassett2009human,bullmore2009complex,bullmore2011brain}, here we utilize an enriched network formalism that comes from the field of algebraic topology \cite{ghrist2014elementary}. These tools are tuned to the interplay between weak and strong connections \cite{bassett2012altered}, and therefore reveal architectural features that serve to isolate information transmission processes \cite{giusti2016two}. It will be interesting in future to compare human and non-human connectomes across a range of spatial scales \cite{betzel2016multi} to further elucidate the evolutionary development of these features, and to link them to their functional \cite{hermundstad2013structural} and behavioral \cite{hermundstad2014structurally} consequences. \section*{Materials and Methods} \subsection*{Data Acquisition, Preprocessing, and Network Construction} Diffusion spectrum imaging (DSI) data and T1-weighted anatomical scans were acquired from eight healthy adult volunteers on 3 separate days ($27\pm5$ years old, two female, and two left-handed) \cite{gu2015controllability}. All participants provided informed consent in writing according to the Institutional Review Board at the University of California, Santa Barbara. Whole-brain images were parcellated into 83 regions (network nodes) using the Lausanne atlas \cite{hagmann2008mapping}, and connections between regions (network edges) were weighted by the number of streamlines identified using a determistic fiber tracking algorithm. We represent this network as a graph $G(V,E)$ on $V$ nodes and $E$ edges, corresponding to a weighted symmetric adjacency matrix $\mathbf{A}$. For calculations in the main text, the network was thresholded at $\rho=0.25$ for consistency with previous work \cite{sizemore2016classification}. See Supporting Information and Refs \cite{cieslak2014local,gu2015controllability} for detailed descriptions of acquisition parameters, data preprocessing, and fiber tracking. In the supplement, we provide additional results for the case in which we correct edge weight definitions for the effect of region size \new{Fig.~\ref{fig:sfig_main4}}. \subsection*{Cliques \emph{versus} Cycles} In a graph $G(V,E)$ a $k$-clique is a set of $k$ all-to-all connected nodes. It follows that any subset of a $k$-clique is a clique of smaller degree, called a face. Any clique that is not a face we call maximal. To assess how individual nodes contribute to these structures, we define node participation in maximal $k$-cliques as $P_k(v)$, and we record the total participation of a node as $P(v) = \sum_{k = 1}^{n}P_k(v)$. To detect cycles \new{which enclose topological cavities}, we computed the \emph{persistent homology} for dimensions 1--2 using \cite{henselmannovel}. This process involves first decomposing the weighted network into a sequence of binary graphs beginning with the empty graph and adding one edge at a time in order of decreasing edge weight. Formally, we translate edge weight information into a sequence of binary graphs called a filtration, $$ G_0 \subset G_1 \subset \dots \subset G_{|E|}$$ beginning with the empty graph $G_0$ and adding back one edge at a time following the decreasing edge weight ordering. \new{To ensure all edge weights are unique we added random noise uniformly sampled from $[0,0.0001]$. However, this has essentially no effect on the final results, as stability theorems ensure that small perturbation of the filtration leads to small perturbation of the persistent homology \cite{chowdhury2016persistent,cohen2007stability}.} \new{Within each binary graph of this filtration, we extract the collection of all \emph{$k$-cycles}, families of $(k+1)$-cliques which, when considered as a geometric object, form a closed shell with no boundary. Formally, these are collections of $(k+1)$-cliques $\{\sigma_1, \dots \sigma_n\}$ such that every $k$-subclique of some $\sigma_i$ (called a \emph{boundary}) appears as a subclique in the collection an even number of times. Two $k$-cycles are \emph{equivalent} if they differ by a boundary of $k+1$-cliques.} This relation forms equivalence classes of cycles \new{with each non-trivial equivalence class representing a unique topological cavity}. Constructing the sequence of binary graphs allows us to follow \new{equivalence classes of cycles} as a function of the edge density $\rho$. Important points of interest along this sequence are the edge density associated with the first $G_i$ in which the \new{equivalence class} is found (called the birth \new{density}, $\rho_{birth}$) and the edge density associated with the first $G_i$ in which the enclosed void is triangulated into higher dimensional cliques (called the death \new{density}, $\rho_{death}$). \new{One potential marker of the} relative importance of a \new{persistent cavity} to the weighted network architecture is its \emph{lifetime} ($\rho_{death} - \rho_{birth}$). \new{A large lifetime indicates topological cavities} that persist over many edge additions. \new{An alternative measure is the} death to birth ratio $\pi = \rho_{death}/ \rho_{birth}$ which \new{highlights topological cavities that survive exceptionally long in spite of being born early, a feature that is interesting in geometric random graphs.} (see \cite{bobrowski2015maximally} and Supporting Information). \new{To study the role of each topological cavity in cognitive function, we extract the minimal representatives of each non-trivial equivalence class at the birth density. For unfiltered complexes, the problem of finding a minimal generator for a given homology class is well known to be intractable \cite{chen2011hardness,dey2011optimal}. However, leveraging the filtration, we are able to answer the corresponding question in this context with relative ease. The persistent homology software \cite{henselmannovel} returns the starting edge and birth density of each homology class. To recover the minimal cycle we threshold the network at the density immediately preceding $\rho_{birth}$, then perform a breadth-first search for a path from one vertex to the other, taking all minimum length paths as solutions. If these minimum length paths arise from different equivalence classes (cycles 3, 7, and 10 in Fig.~\ref{fig:allcycles1}) we record and analyze each individually since each could be the generator of the homology class. For higher dimensional cycles we perform a similar process by hand, but we note that they could be algorithmically identified using appropriate generalizations of the graph search method.} \subsection*{Standard Graph Statistics} In addition to the notions of cliques and \new{cavities} from algebraic topology, we also examined corresponding notions from traditional graph theory including communicability and rich-club architecture, which are directly related to node participation in maximal cliques. We first considered nodes that participated in many maximal cliques, and we assessed their putative role in brain communication using the notion of network communicability. \new{The weighted communicability between nodes $i$ and $j$ is $$C_{i,j} = (\exp(D^{-1/2}AD^{-1/2}))_{ij} $$ with $D := \text{diag}(s_i)$ for $s_i$ the strength of node $i$ in the adjacency matrix $\mathbf{A}$, providing a normalization step where each $a_{ij}$ is divided by $\sqrt{d_id_j}$ \cite{crofts2009weighted,estrada2008communicability}}. This statistic accounts for all walks between node pairs and scales the walk contribution according to the product of the component edge weights. The statistic also normalizes node strength to prevent high strength nodes from skewing the walk contributions. We refer to the sum of a node's communicability with all other nodes as node communicability, $C_{i}$. Intuitively, nodes that participate in many maximal cliques may also play a critical role in the well-known rich club organization of the brain, in which highly connected nodes in the network are more connected to each other than expected in a random graph. For each degree $k$ we compute the weighted rich club coefficient $$\phi^w(k) = \frac{W_{>k}}{\sum_{l = 1}^{E_{>k}}w_l^{ranked}}$$ where $W_{>k}$ is the summed weight of edges in the subgraph composed of nodes with degree greater than $k$, $E_{>k}$ is the number of edges in this subgraph, and $w_l^{ranked}$ is the $l$-th greatest edge weight in $\mathbf{A}$. \new{Rich club nodes are those that exist in this subgraph when $\phi^w(k)$ is significantly greater (one sided $t$-test) than $\phi^w_{random}(k)$, the rich club coefficient calculated from 1000 networks constructed by randomly rewiring the graph $\mathbf{A}$ while preserving node strength \cite{rubinov2010complex}}. Furthermore, highly participating nodes may also contribute to a hierarchical organization of the network. To evaluate this contribution, we compute the $k$-core and $s$-core decompositions of the graph \cite{hagmann2008mapping,chatterjee2007understanding}. The $k$-core is the maximally connected component of the subgraph with only nodes having degree greater than $k$. The $s$-core is similarly defined with summed edge weights in the subgraph required to be at least $s$. \subsection*{Null Model Construction} We sought to compare the empirically observed network architecture to that expected in an appropriate null model. Due to the well-known spatial constraints on structural brain \new{connectivity \cite{klimm2014resolving,lohse2014resolving,bullmore2012,betzel2016modular} as well as the similarity in mesoscale homological features to the Random Geometric network \cite{sizemore2016classification}} we considered a minimally wired network in which nodes are placed at the center of mass of anatomical brain regions. Each pair of nodes are then linked by an edge with weight $w_{i,j} = 1/d(i,j)$, where $d(i,j)$ is the Euclidean distance between nodes $i$ and $j$. \new{In each scan, the locations of region centers were collected. Thus, we considered a population of 24 model networks.} This null model allows us to assess what topological properties are driven by the precise spatial locations of brain regions combined with a stringent penalty on wiring length. \section*{Acknowledgments} This work was supported from the John D. and Catherine T. MacArthur Foundation, the Alfred P. Sloan Foundation, the Army Research Laboratory and the Army Research Office through contract numbers W911NF-10-2-0022 and W911NF-14-1-0679, the National Institute of Mental Health (2-R01-DC-009209-11), the National Institute of Child Health and Human Development (1R01HD086888-01), the Office of Naval Research, and the National Science Foundation (CRCNS BCS-1441502 and CAREER PHY-1554488). We thank Scott T. Grafton for access to the DSI data.
{'timestamp': '2016-12-21T02:05:55', 'yymm': '1608', 'arxiv_id': '1608.03520', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03520'}
arxiv
\section{Full results table from Section \ref{sec:emrResults}} \small \begin {longtable}{rccccccc|ccccccc} \rowcolor [rgb]{1,1,1}&\multicolumn{7}{c}{\underline{Training data set, 10-fold cross-validation}}&\multicolumn{7}{c}{\underline{Validation data set}}\\ \rowcolor [rgb]{1,1,1}Outcome&\# Events&CR&RF&MLE&Lasso&Enet&Ridge&\# Events&CR&RF&MLE&Lasso&Enet&Ridge\\\hline \rowcolor [gray]{.9}Death&450&\textbf{0.814}&0.814&0.81&0.791&0.79&0.794&376&\textbf{0.789}&0.784&0.786&0.761&0.761&0.762\\ \rowcolor [gray]{.8}Acute MI&190&\textbf{0.704}&0.658&0.7&0.657&0.673&0.676&197&\textbf{0.699}&0.648&0.699&0.694&0.539&0.697\\ \rowcolor [gray]{.9}Amputation&42&\textbf{0.75}&0.684&0.709&0.443&0.356&0.445&38&\textbf{0.758}&0.605&0.705&0.504&0.504&0.504\\ \rowcolor [gray]{.8}Aneurysm&25&0.676&\textbf{0.737}&0.64&0.355&0.335&0.382&16&\textbf{0.735}&0.582&0.706&0.508&0.508&0.508\\ \rowcolor [gray]{.9}Angioplasty&72&\textbf{0.616}&0.59&0.575&0.39&0.415&0.406&71&\textbf{0.605}&0.544&0.578&0.543&0.543&0.543\\ \rowcolor [gray]{.8}Arterial Cath&82&\textbf{0.759}&0.724&0.737&0.476&0.517&0.568&101&\textbf{0.673}&0.673&0.653&0.543&0.543&0.543\\ \rowcolor [gray]{.9}Atrial Fibrillation&619&0.817&\textbf{0.828}&0.818&0.809&0.814&0.814&593&0.799&\textbf{0.816}&0.798&0.798&0.793&0.793\\ \rowcolor [gray]{.8}Bipolar&199&\textbf{0.702}&0.649&0.694&0.603&0.579&0.617&216&\textbf{0.717}&0.691&0.711&0.548&0.668&0.704\\ \rowcolor [gray]{.9}Cardiac Cath&252&\textbf{0.648}&0.605&0.644&0.477&0.504&0.503&258&\textbf{0.668}&0.619&0.653&0.545&0.545&0.545\\ \rowcolor [gray]{.8}Skin Ulcer&286&0.727&0.692&\textbf{0.733}&0.655&0.629&0.66&338&0.705&0.689&\textbf{0.711}&0.673&0.659&0.664\\ \rowcolor [gray]{.9}COPD&296&0.726&\textbf{0.729}&0.728&0.704&0.689&0.693&294&\textbf{0.721}&0.7&0.718&0.713&0.701&0.712\\ \rowcolor [gray]{.8}Coronary Disease&1439&0.752&\textbf{0.779}&0.752&0.743&0.743&0.743&1406&0.747&\textbf{0.761}&0.747&0.732&0.732&0.736\\ \rowcolor [gray]{.9}Depression&194&0.715&0.693&\textbf{0.718}&0.707&0.67&0.709&176&0.733&0.71&0.737&\textbf{0.748}&0.748&0.746\\ \rowcolor [gray]{.8}Heart Failure&470&\textbf{0.806}&0.801&0.806&0.799&0.798&0.8&556&\textbf{0.785}&0.756&0.785&0.774&0.773&0.773\\ \rowcolor [gray]{.9}Kidney Disease&456&0.781&\textbf{0.807}&0.776&0.768&0.768&0.768&415&0.765&\textbf{0.787}&0.767&0.748&0.743&0.746\\ \rowcolor [gray]{.8}Neurological&636&\textbf{0.751}&0.745&0.75&0.745&0.746&0.747&668&0.734&0.717&\textbf{0.736}&0.73&0.73&0.731\\ \rowcolor [gray]{.9}Obesity&1647&0.676&0.675&\textbf{0.677}&0.664&0.666&0.669&1926&\textbf{0.639}&0.639&0.639&0.625&0.629&0.63\\ \rowcolor [gray]{.8}Opthalmic&491&0.739&\textbf{0.744}&0.738&0.736&0.734&0.733&480&0.737&\textbf{0.741}&0.739&0.724&0.724&0.724\\ \rowcolor [gray]{.9}Arthritis&57&\textbf{0.616}&0.486&0.601&0.362&0.405&0.394&62&0.602&0.598&\textbf{0.604}&0.431&0.431&0.431\\ \rowcolor [gray]{.8}Stroke&344&\textbf{0.741}&0.698&0.737&0.727&0.725&0.725&334&\textbf{0.692}&0.67&0.687&0.68&0.68&0.683\\ \rowcolor [gray]{.9}Unstable Angina&173&\textbf{0.66}&0.616&0.657&0.501&0.484&0.561&125&0.72&0.689&0.712&\textbf{0.729}&0.584&0.726 \end {longtable} \end{sidewaystable} \section{Introduction} Learning hierarchical structures from observed data is a common practice in many knowledge domains. Examples include phylogenies and signaling pathways in biology, language models in linguistics, etc. Agglomerative clustering is still the most popular approach to hierarchical clustering due to its efficiency, ease of implementation and a wide range of possible distance metrics. However, because it is algorithmic in nature, there is no principled way that agglomerative clustering can be used as a building block in more complex models. Bayesian priors for structure learning on the other hand, are perfectly suited to be employed in larger models. Several authors have proposed using hierarchical structure priors to model correlation in factor models \citep{rai08,zhang11a,henao12a,henao13a}. There are many approaches to hierarchical structure learning already proposed in the literature, see for instance \citet{neal03,heller05,teh08,adams10}. The work in this paper focuses on the Bayesian agglomerative clustering model proposed by \citet{teh08}. This allows us to perform model based hierarchical clustering with continuous multivariate non i.i.d.\ data -- by which we mean multivariate observations in which the elements of the vector are not i.i.d.\ . Although the authors introduce priors both for continuous and discrete data, no attention is paid to the non i.i.d.\ case, mainly because their work is focused in proposing different inference alternatives. Kingman's coalescent is a standard model from population genetics perfectly suited for hierarchical clustering since it defines a prior over binary trees \citep{kingman82,kingman82a}. This work advances Bayesian hierarchical clustering in two ways: (i) we extend the original model to handle non i.i.d.\ data and (ii) we propose an efficient sequential Monte Carlo inference procedure for the model which scales quadratically rather than cubically. As a byproduct of our approach we propose as well a small correction to the greedy algorithm of \citet{teh08} that shows gains particularly in small data sets. In addition, we demonstrate a novel application of the Coalescent within a hierarchical regression that gives improved predictive accuracy in the presence of multiple correlated outcomes. There is a separate approach by \citet{gorur08} that also improves the cubic computational cost of Bayesian hierarchical clustering. They introduce an efficient sampler with quadratic cost that although proposed for discrete data can be easily extended to continuous data, however as we will show, our approach is still considerably faster. The remainder of the manuscript is organized as follows, the data model and the use of coalescents as priors for hierarchical clustering are reviewed in Section~\ref{sc:coalescent}. Our approach to inference and relationships to previous approaches are described in Section~\ref{sc:inference}. Section \ref{sec:emrResults} demonstrates the use of the model and algorithm in the context of hierarchical regression with multiple outcomes of unknown correlation. The appendix contains numerical results on both artificial and real data. \section{Coalescents for hierarchical clustering} \label{sc:coalescent} A {\em partition} of a set $A$ is defined to be a collection of subsets $\{a_j\}_{j=1}^J$ such that (1) $a_j\subset A$ for all $j$, (2) $\cup_j a_j = A$ and (3) $a_j \cap a_{j'} = \varnothing$ for all $j\neq j'$. Let $X$ be an $n\times d$ dimensional matrix of $n$ observations in $d$ dimensions with rows ${\bf x}_i$. We will define a binary tree on our set of $n$ observations; define $\pi_0 = \{\{{\bf x}_1\}, \ldots, \{{\bf x}_n\}\}$ to be a partition containing $n$ singletons. We iteratively combine pairs of elements such that $\pi_{i+1}$ is obtained by removing two of the elements from $\pi_i$ and inserting their union. Thus if $\pi_i = \{a_j\}_{j=1}^{n-i}$ then $\pi_{i+1}=(\pi_i \setminus \{a_{j},a_{j'}\}) \cup (a_{j}\cup a_{j'})$ for some $j\neq j'$. For $a_j,a_{j'}\in \pi_i$ define $z_{i+1}^*=a_j \cup a_{j'}$ where $j$ and $j'$ indicate the elements of $\pi_i$ that were merged to obtain $\pi_{i+1}$. A particular sequence of $n$ partitions defines a binary tree. The $n$ leaves of the tree are the elements of $\pi_0$ and the nodes (branching points) of the tree are $\{z_k^*\}_{k=1}^{n-1}$. Defining ${\bf t}=[t_1 \ \ldots \ t_{n-1}]$ to be a vector of branching times, $\bm{\pi}=\{\pi_1,\ldots,\pi_{n-1}\}$ to be the ordered collection of partitions and ${\bf z}=\{{\bf z}_1, \ldots, {\bf z}_{n-1}\}$ to be the latent $d$-dimensional observations at the internal nodes we can write a Bayesian model for hierarchical clustering as \begin{align} \label{eq:model} \begin{aligned} {\bf x}_i|{\bf t},\bm{\pi} \ \sim & \ p({\bf x}_i|{\bf t},\bm{\pi},{\bf z}) \,, \\ {\bf z} \ \sim & \ p({\bf z}) \,, \\ {\bf t},\bm{\pi} \ \sim & \ {\rm Coalescent}(n) \,, \end{aligned} \end{align} $p({\bf x}_i|{\bf t},\bm{\pi},{\bf z})$ is the data likelihood and $p({\bf z})$ is the prior distribution for the internal nodes of the tree and the pair $\{{\bf t},\bm{\pi}\}$ is provided with a prior distribution over binary tree structures known as Kingman's coalescent. \subsection{Kingman's coalescent} The $n$-coalescent is a continuous-time Markov chain originally introduced to describe the common genealogy of a sample of $n$ individuals backwards in time \citep{kingman82,kingman82a}. It defines a prior over binary trees with $n$ leaves, one for each individual. The coalescent assumes a uniform prior over tree structures, $\bm{\pi}$, and exponential priors on the set of $n-1$ merging times, ${\bf t}$. It can be thought of as a generative process on partitions of $\{1,\ldots,n\}$ as follows \begin{itemize} \item Set $k=1$, $t_0=0$, $\pi_0=\{\{1\},\ldots,\{n\}\}$. \item While $k<n$ \begin{itemize} \item Draw $\Delta_k \sim \mathrm{Exponential}(\lambda_k) \mbox{ where } \lambda_k=(n-k+1)(n-k)/2$ is a rate parameter. \item Set $t_k=t_{k-1} + \Delta_k$. \item Merge uniformly two sets of $\pi_{k-1}$ into $\pi_{k}$. \item Set $k=k+1$. \end{itemize} \end{itemize} Because there are $(n-k+1)(n-k)/2$ possible merges at stage $k$, any particular pair in $\pi_i$ merges with prior expected rate 1 for any $i$. We can compute the prior probability of a particular configuration of the pair $\{{\bf t},\bm{\pi}\}$ as \begin{align} \label{eq:prior} p({\bf t},\bm{\pi}) = \prod_{k=1}^{n-1} \exp\left(-\tfrac{(n-k+1)(n-k)}{2}\Delta_k\right) \,, \end{align} this is, the product of merging and coalescing time probabilities. Some properties of the $n$-coalescent include: (i) $\bm{\pi}$ is uniform and independent of ${\bf t}$, (ii) it is independent of the order of sets in partition $\pi_i$ for every $i$ and (iii) the expected value of $t_{n-1}$ (last coalescing time) is $\mathbb{ E}[t_{n-1}]=2(1-n^{-1})$. \subsubsection{Distribution of the latent nodes} Recall that $z_k^*\in \pi_k$ is an internal node in a binary tree with associated latent $d$-dimensional vector ${\bf z}_k$. Let $z^*_{c_1}$ and $z^*_{c_2}$ be the children of $z_k^*$ and define $C=\{c_1, c_2\}$. We designate the leaves of the tree with $x_i^*$. If we define $p({\bf z}_k|{\bf z}_c,{\bf t})$ to be the {\em transition density} between a child node, ${\bf z}_c$, and its parent, ${\bf z}_k$, then we can recursively define $q({\bf z}_k|\bm{\pi},{\bf t})$ to be a distribution of ${\bf z}_k$ as follows: \begin{align*} q({\bf x}_i|\bm{\pi},{\bf t}) = & \ \delta_{{\bf x}_i} \,, \\ q'({\bf z}_k|\bm{\pi},{\bf t}) = & \ \prod_{c\in C}\int p({\bf z}_k|{\bf z}_c,{\bf t})q({\bf z}_c|\bm{\pi},{\bf t})d{\bf z}_c \,, \\ = & \ Z_k({\bf X},\bm{\pi}, {\bf t}) q({\bf z}_k|\bm{\pi},{\bf t}) \,, \end{align*} where $q({\bf z}_k|\bm{\pi},{\bf t})$ is a density (integrating to 1) and $Z_k$ is the appropriate scaling factor. Recently, \citet{teh08} showed that by using an agglomerative approach for constructing $\{{\bf t},\bm{\pi}\}$, the likelihood for the model in equation~\eqref{eq:model} can be recursively written as \begin{align} \label{eq:lik} p({\bf X}|{\bf t},\bm{\pi}) = \prod_{k=1}^{n-1} Z_{k}({\bf X}|\bm{\pi},{\bf t}) \,. \end{align} Because of the tree structure, ${\bf z}_k$ is independent of ${\bf X}$ conditional on the distributions of its two child nodes. This implies that $Z_k({\bf X}|\bm{\pi},{\bf t}) = Z_k({\bf X}|\pi_{1:k},{\bf t}_{1:k})$. Our formulation is equivalent to using \emph{message passing} to marginalize recursively from the leaves to the root of the tree \citep{pearl88}. The message is $q({\bf z}_k|\bm{\pi},{\bf t})$ for node $z^*_k$ and it summarizes the entire subtree below node $z^*_k$. Figure~\ref{fg:stree} illustrates the process for a segment of a tree. The size of partitions $\pi_k$ shrink as $k$ increases, so from the illustration $\pi_0=\{\{1\},\{2\},\ldots,\{n\}\}$, $\pi_1=\{\{1,2\},\ldots,\{n\}\}$, $\pi_{k-1}=\{c_1,c_2,\ldots\}$ and $\pi_k=\{c_1\cup c_2,\ldots\}$. \begin{figure}[!t] \centering \begin{tikzpicture}[ bend angle = 5, >=latex, font = \footnotesize ] % \tikzstyle{lps} = [ circle, thick, draw = black!80, fill = OliveGreen, minimum size = 1mm, inner sep = 2pt ] \tikzstyle{ety} = [ minimum size = 1mm, inner sep = 2pt ] % \begin{scope}[node distance = 1.5cm and 1cm] \node [ety] (t_) [ ] {}; \node [ety] (t0) [ right of = t_, node distance = 2.5cm ] {$t_1=0$}; \node [ety] (t1) [ right of = t0 ] {$t_2$}; \node [ety] (t2) [ right of = t1 ] {$t_{k-1}$}; \node [ety] (t3) [ right of = t2 ] {}; \node [ety] (t4) [ right of = t3 ] {$t_k$}; \node [ety] (t5) [ right of = t4 ] {$t_{k+1}$}; % \node [lps] (lp_1) at (2.5,-0.5) [label = -90:${\bf x}_1$] {}; \node [lps] (lp_2) at (2.5,-1.5) [label = -90:${\bf x}_2$] {}; \node [ety] (lp_3) at (2.5,-2.5) [label = -90:$\vdots$] {}; \node [lps] (lp_4) at (2.5,-4.5) [label = -90:${\bf x}_n$] {}; % \node [lps] (v1) at (4.0,-1.0) [ label = -90:${\bf z}_{c_1}$ ] {} edge [pre, bend right] (lp_1) edge [pre, bend left] (lp_2); \node[ety] (ve1) at (4.0,-3.0) [ label = 180:$\ldots$ ] {}; \node[ety] (ve2) at (4.0,-4.0) [ label = 180:$\ldots$ ] {}; \node [lps] (v2) at (5.5,-3.5) [ label = 90:${\bf z}_{c_2}$ ] {} edge [pre, bend right] (ve1) edge [pre, bend left] (ve2); \node [lps] (v4) at (8.5,-2.5) [ label = -90:${\bf z}_k$ ] {} edge [pre, bend right] (v1) edge [pre, bend left] (v2); \node [ety] (v5) at (10.0,-2.5) [ label = 0:$\ldots$ ] {} edge [pre] (v4); % \node [ety] at (4.9,-0.6) [] {$q({\bf z}_{c_1}|c_1,{\bf t}_{1:2})$}; \node [ety] at (6.6,-3.9) [] {$q({\bf z}_{c_2}|c_2,{\bf t}_{1:k-1})$}; \node [ety] at (9.4,-2.1) [] {$q({\bf z}_k|C,{\bf t}_{1:k})$}; \node [ety] at (7.5,-1.3) [] {$p({\bf z}_k|{\bf z}_{c_1},{\bf t}_{1:k})$}; \node [ety] at (8.2,-3.35) [] {$p({\bf z}_k|{\bf z}_{c_2},{\bf t}_{1:k})$}; \end{scope} \end{tikzpicture} \caption[Segment of the binary tree structure]{Binary tree structure. Latent variable ${\bf t}$ and $\bm{\pi}$ define merging points and merging sets, respectively.} \label{fg:stree} \end{figure} The joint distribution needed to perform inference can be obtained by combining likelihood and prior in equations \eqref{eq:lik} and \eqref{eq:prior} as \begin{align} \label{eq:joint} p({\bf X},{\bf t},\bm{\pi}) = \prod_{k=1}^{n-1} \exp(-\lambda_k\Delta_k) Z_{k}({\bf X}|\pi_{1:k},{\bf t}_{1:k}) \,. \end{align} \subsection{Gaussian transition distributions} A common approach to correlated continuous data is the use of a multivariate Gaussian distribution for the transition density, \begin{align*} p({\bf z}_k|{\bf z}_c,{\bf t}_{1:k}) = \mathcal{N}({\bf z}_k|{\bf z}_c,\Delta_{k,c}\bm{\Phi}) \,, \end{align*} where $\bm{\Phi}$ is a covariance matrix encoding the correlation structure in ${\bf z}_k$ and $\Delta_{k,c}$ is the time elapsed between $t_k$ and $t_c$, not necessarily $t_{k}-t_{k-1}$ as can be seen in Figure~\ref{fg:stree}. We denote the time at which node $z_c^*$ was created as $t_c$. Individual terms of the likelihood in equation~\eqref{eq:lik} can be computed using \begin{align*} q({\bf z}_k|\pi_{1:k},{\bf t}_{1:k}) = & \ \mathcal{N}({\bf z}_k|{\bf m}_{c_1},\tilde{s}_{c_1}\bm{\Phi})\mathcal{N}({\bf z}_k|{\bf m}_{c_2},\tilde{s}_{c_2}\bm{\Phi}) \,, \\ = & \ Z_{k}({\bf X}|\pi_{1:k},{\bf t}_{1:k}) \mathcal{N}({\bf z}_k|s_k(\tilde{s}_{c_1}^{-1}{\bf m}_{c_1}+\tilde{s}_{c_2}^{-1}{\bf m}_{c_2}),s_k\bm{\Phi}) \,, \end{align*} where ${\bf m}_{c_1}$ and $s_{c_1}$ are mean and variance of $q({\bf z}_{c_1}|\bm{\pi},{\bf t})$, respectively. Furthermore, $\tilde{s}_{c_1}=\Delta_{k,c_1}+s_{c_1}$. This leads to $s_k=(\tilde{s}_{c_1}^{-1}+\tilde{s}_{c_2}^{-1})^{-1}$ and the normalization constant is \begin{align} Z_{k}({\bf X}|\pi_{1:k},{\bf t}_{1:k}) = & (2\pi)^{-d/2}|v_k\bm{\Phi}|^{-1/2}\exp\left(-\tfrac{1}{2}({\bf m}_{c_1}-{\bf m}_{c_2})v_k^{-1}\bm{\Phi}^{-1}({\bf m}_{c_1}-{\bf m}_{c_2})^\top\right) \,, \label{eq:ZkNorm} \end{align} where $v_k=\tilde{s}_{c_1}+\tilde{s}_{c_2}=2\Delta_k+r_k$ and $r_k=2t_{k-1}-t_{c_1}-t_{c_2}+s_{c_1}+s_{c_2}$. Note that $\Delta_{c_1}=\Delta_{c_2}$ only if $c_1$ and $c_2$ are singletons. The term $r_k$ can be interpreted as the accumulated variance up to $t_{k-1}$ given partition $\pi_{k-1}$, i.e.\ it summarizes the two subtrees encompassed by sets $c_1$ and $c_2$. \section{Inference} \label{sc:inference} Inference is carried out using a sequential Monte Carlo (SMC) sampling based upon equation~\eqref{eq:joint} \citep[see][]{doucet01}. Define $\mathcal{C}_i$ to be the set of all pairs of elements from the partition $\pi_i$, and for $C\in \mathcal{C}_i$ define $\pi_{i,C}$ to be the partition obtained by merging the two elements in $C$. For a set of $M$ particles, we approximate the posterior of the pair $\{{\bf t},\bm{\pi}\}$ using a weighted sum of point masses obtained iteratively by drawing coalescing times $t_k$ and chain states $\pi_k$ one at a time from their posterior as \begin{align} p(\Delta_k,\pi_{k-1,C}|{\bf t}_{1:k-1},\pi_{1:k-1}) \ = & \ Z^{-1}\exp(-\lambda_k\Delta_k) Z_{k}({\bf X}|\pi_{1:k-1},\pi_{k-1,C},{\bf t}_{1:k-1},\Delta_k) \,, \label{eq:delta_pi_post} \\ Z \ = & \sum_{c \in\mathcal{C}_k} \underbrace{\int \exp(-\lambda_k\Delta_k)Z_k({\bf X}|\pi_{1:k-1},\pi_{k-1,c},{\bf t}_{1:k-1},\Delta_k) d\Delta_k}_{Z_{k,c}} \,, \label{eq:Zkc} \end{align} From equation~\eqref{eq:Zkc} we see that the integral needs to be computed for every pair in $\pi_{k-1}$ at every iteration of the sampler, simply because the rate of the exponential distribution, $\lambda_k$, is a function of $k$. Algorithms introduced by \citet{teh08} try to avoid the computational complexity of using equation \eqref{eq:delta_pi_post} directly by simplifying it or by means of greedy alternatives. They propose for instance to draw $\Delta_k$ from the prior; then computing $Z_{k,C}$ is no longer necessary thus reducing computational cost. We will show that by using some properties of the distributions involved in equation~\eqref{eq:delta_pi_post} we can effectively decrease the computational complexity of the SMC sampler with almost no performance penalty. In particular, we will show that the most expensive parts of equations~\eqref{eq:delta_pi_post} and \eqref{eq:Zkc} need to be computed only once during inference. If we assume a Gaussian transition distribution, we can rewrite and then expand equation~\eqref{eq:delta_pi_post} as \begin{align} p(\Delta_k,\pi_{k-1,C}|{\bf t}_{1:k-1},\pi_{1:k-1}) \ \propto & \ Z_{k}({\bf X}|\pi_{k-1},C,{\bf t}_{1:k})\exp\left(-\frac{\lambda_k}{2}(2\Delta_k+r_k)\right)\exp\left(\frac{\lambda_k}{2}r_k\right) \,, \nonumber \\ \propto & \ \mathrm{tGIG}_{r_k}(2\Delta_k+r_k|\bm{\epsilon}_{k-1,C},\lambda_k)Z_{k,C} \,, \label{eq:delta_pi_modpost} \end{align} where $\bm{\epsilon}_{k-1,C}=({\bf m}_{c_1}-{\bf m}_{c_2})\bm{\Phi}^{-1}({\bf m}_{c_1}-{\bf m}_{c_2})^\top$ and $\mathrm{tGIG}_{r_k}(\lambda_k,\chi,\psi)$ is the generalized inverse Gaussian (GIG) with parameters $\{\lambda_k,\chi,\psi\}$ truncated below $r_k$ \citep{jorgensen82a} and the last term to the right hand side of equation~\eqref{eq:delta_pi_modpost} is used to denote that pair $C$ is selected with probability proportional to $Z_{k,C}$. \begin{align} \label{eq:pi_modpost} Z_{k,C} \ \approx & \ \frac{K_{1-d/2}(\sqrt{\lambda_k\bm{\epsilon}_{k-1,C}})}{(\lambda_k\bm{\epsilon}_{k-1,C}^{-1})^{(1-d/2)/2}}\exp\left(\frac{\lambda_k}{2} r_k\right) \,, \end{align} where $K_{\nu}(z)$, the modified Bessel function of second kind \citep{abramowitz65a}, is the normalizer of the generalized inverse Gaussian distribution. Since the normalization constant of the truncated GIG distribution does not have a closed form and assuming that the posterior distribution of $\Delta_k$ is peaked, we approximate the true normalizer with $K_{\nu}(z)$. Later in the paper we explore empirically the effects of this approximation with some artificially generated data. The details on how to obtain equations~\eqref{eq:delta_pi_modpost} and \eqref{eq:pi_modpost} can be found in Appendix~\ref{eq:delta_pi_details}. From Equation~\eqref{eq:delta_pi_modpost} we have \begin{align} \Delta_k|C,{\bf t}_{1:k-1} \ \sim & \ \mathrm{tGIG}_{r_k}(2\Delta_k+r_k|\bm{\epsilon}_{k,C},\lambda_k) \,, \label{eq:delta_sample} \\ \pi_k|\pi_{k-1},{\bf t}_{1:k-1} \ \sim & \ \mathrm{Discrete}(\pi_{k-1,C}|{\bf w}_{k-1}) \,, \label{eq:pi_sample} \end{align} where ${\bf w}_{k-1}$ is the vector of normalized weights ranging over $\mathcal{C}_{k-1}$, computed using equation~\eqref{eq:pi_modpost}. Sampling from equations~\eqref{eq:pi_modpost}, \eqref{eq:delta_sample} and \eqref{eq:pi_sample} have useful properties, (i) the conditional posterior of $\pi_k$ does not depend on $\Delta_k$. (ii) Sampling from $\Delta_k$ amounts to drawing from a truncated generalized inverse Gaussian distribution. (iii) We do not need to sample $\Delta_k$ for every pair in $\pi_{k-1}$, in fact we only need to do so for the merging pair. (iv) Although $\lambda_k$ in equation~\eqref{eq:pi_modpost} changes with $k$, the most expensive computation, $\bm{\epsilon}_{k-1,C}$, needs to be computed only once. (v) The expression in equation~\eqref{eq:pi_modpost} can be seen as the core of a distribution for ${\bf m}_{c_1}-{\bf m}_{c_2}$ which has heavier tails than a Gaussian distribution, and $Z_{k,C}\to\infty$ as $\bm{\epsilon}_{k-1,C}\to0$ for $d>1$. Furthermore, we can rewrite equation~\eqref{eq:pi_modpost} as \begin{align} Z_{k,C} \ \propto & \ \frac{K_{d/2-1}(\sqrt{\lambda_k\bm{\epsilon}_{k-1,C}})}{(\lambda_k^{-1}\bm{\epsilon}_{k-1,C})^{(d-2)/4}}\exp\left(\frac{\lambda_k}{2} r_k\right) \,, \label{eq:pi_modpost_rep} \\ Z_{k,C} \ \approx & \ \bm{\epsilon}_{k-1,C}^{-(d-1)/4}\exp(-\sqrt{\lambda_k\bm{\epsilon}_{k-1,C}})\exp\left(\frac{\lambda_k}{2} r_k\right) \label{eq:pi_modpost_ne} \,, \end{align} where in equation~\eqref{eq:pi_modpost_rep} we have made a change of variables before marginalizing out $v_k=2\Delta_k+r_k$, and in equation~\eqref{eq:pi_modpost_ne} we have used the limiting form of $K_\nu(z)$ as $z\to\infty$ \citep{abramowitz65a}. \citet{eltoft06a} have called equation~\eqref{eq:pi_modpost_rep} the core of their multivariate Laplace distribution, ${\bf m}_{c_1}-{\bf m}_{c_2}\sim{\rm ML}(\lambda_k,\bm{\Psi})$ with parameters $\lambda_k$ and $\bm{\Psi}$. When $d=1$ equation~\eqref{eq:pi_modpost_ne} is no longer an approximation; it is the core of a univariate Laplace distribution with rate $\sqrt{\lambda_k\bm{\Psi}^{-1}}$. Additionally, equation~\eqref{eq:pi_modpost_ne} can be particularly useful as a cheap numerically stable alternative to $K_\nu(z)$ when $d$ is large. \subsection{Sampling coalescing times} Sampling from a generalized inverse Gaussian distribution is traditionally done using the \emph{ratio-of-uniforms} method of \citet{dagpunar89a}. We observed empirically that a slice sampler within the interval $(r_k/2,\Delta_0r_k/2)$ is considerably faster than the commonly used algorithm. Although we use $\Delta_0=10^2$ in all our experiments, we did try larger values without noticing significant changes in the results. The slice sampler used here is a standard implementation of the algorithm described by \citet{neal03a}. We acknowledge that adaptively selecting $\Delta_0$ at each step could improve the efficiency of the sampler however we did not investigate it. \subsection{Covariance matrix} Until now we assumed the covariance matrix $\bm{\Phi}$ as known, in most cases however the correlation structure of the observed data is unavailable. For unknown $\bm{\Phi}$ we alternate between SMC sampling for the tree structure and drawing $\bm{\Phi}$ from some suitable distribution. We do this by repeating the procedure for a number of iterations ($N_{\rm iter}$) and then dropping a subset of these as burn-in period. Because averaging of tree structures is not a well defined operation, after summarizing the posterior samples of the hyperparameters of the covariance function using medians, we perform a final SMC step to obtain a final tree structure. For cases when observations exhibit additional structure, such as temporal or spatial data, we may assume the latent variable ${\bf z}_k$ is drawn from a Gaussian process. We suppose that elements of $\bm{\Phi}$ are computed using $\phi_{ij}=g(i,j,\bm{\theta})$ for a set of hyperparameters $\bm{\theta}$. For example, we could use a squared exponential covariance function \begin{align} \label{eq:sqexp_noise} g(i,j,\ell,\sigma^2) = \ \exp\left(-\frac{1}{2\ell}d_{ij}^2\right) + \sigma^2\delta_{ij} \,, \end{align} where $\bm{\theta}=\{\ell,\sigma^2\}$, $\delta_{ij}=1$ IFF $i=j$ and $d_{ij}$ is the time between samples $i$ and $j$. The smoothness of the process is controlled by the inverse length scale $\ell$ and the amount of idiosyncratic noise by $\sigma^2$. The elements of $\bm{\theta}$ are sampled by coordinate-wise slice sampling using the following function as proxy for the elements of $\bm{\theta}$, \begin{align*} f(\bm{\theta}|\pi,{\bf t}) = \ \sum_{k=1}^{n-1} Z_{k}({\bf X}|\pi_{1:k},{\bf t}_{1:k}) \,. \end{align*} This approach is generally appropriate for continuous signals where smoothing of the covariance estimates is desirable. For the case when no smoothness is required but correlation structure is expected, conjugate inverse Wishart distributions for $\bm{\Phi}$ can be considered. For i.i.d.\ data, a diagonal/spherical $\bm{\Phi}$ with independent inverse gamma priors is a good choice, as already proposed by \citet{teh08}. \subsection{Greedy implementation} Here we propose a method to draw a single sample with high posterior likelihood from the Coalescent. Such a sample can be built by greedily maximizing equation~\eqref{eq:joint} one step at the time. This requires the computation of the mode of $\Delta_k$ from equation~\eqref{eq:delta_sample} for every pair in $\pi_{k-1}$ and merging the pair with smallest $\Delta_k$. For a given pair, $C$ we have $$\mbox{mode}(\Delta_{k}|C) = \ \frac{1}{2\lambda_k}\left(-d/2+\sqrt{d^2/4+\lambda_k\bm{\epsilon}_{k-1,C}}\right)-\frac{1}{2}r_k $$ and the algorithm selects $C$ such that $$C = \operatornamewithlimits{argmin}_{C'}\{\Delta_{k,C'},C'\in\mathcal{C}_{k-1}\}.$$ Because the posterior of $\Delta_k$ is skewed to the right, a greedy implementation based on the mode of the distribution will on average underestimate coalescing times. If we use the posterior mean this bias can be decreased. We then propose using \begin{align*} \mbox{mean}(\Delta_{k}|C) = \ \frac{1}{2}\underbrace{\sqrt{\frac{\bm{\epsilon}_{k-1,C}}{\lambda_k}}\frac{K_{2-d/2}(\sqrt{\lambda_k\bm{\epsilon}_{k-1,C}})}{K_{1-d/2}(\sqrt{\lambda_k\bm{\epsilon}_{k-1,C}})}}_{\mu_{\Delta_k}} -\frac{1}{2}r_k \,, \end{align*} where $\mu_{\Delta_k}$ is the mean of $\mathrm{GIG}(2\Delta_k+r_k|\bm{\epsilon}_{k,C},\lambda_k)$. We use $\mu_{\Delta_k}$ as an approximation to the mean of the truncated generalized inverse Gaussian distribution because no closed form is available. This means that although our approximation will be also biased to the left of the true coalescing time, it will be considerably less so than the proposal based on the mode of the distribution proposed by \citet{teh08}. We expect significant differences between the two greedy approaches only for low dimensional data sets because as $d$ becomes large, the posterior of $\Delta_k$ will be highly peaked thus making the distance between mean and mode too small to make the proposals distinguishable. Computing two modified Bessel functions by brute force is more expensive and numerically unstable compared to the simple proposal based on the mode of the GIG distribution, however we can recursively compute the ratio of Bessel functions using the identity $K_{v+1}(z) = K_{v-1} + 2vz^{-1} K_{v}(z)$, \citep{abramowitz65a} thus \begin{align*} \frac{K_{v+1}(z)}{K_v} = \frac{K_{v-1}(z)}{K_v} + \frac{2v}{z} \,, \end{align*} starting from the closed forms of $K_{-0.5}$ and $K_{0.5}$ if $d$ is even, or rational approximations (accurate to 19 digits \citep{blair74a}) to $K_{1}$ and $K_{0}$ if $d$ is odd. Incidentally, a similar recursion can be used to compute the variance of the GIG distribution at almost no cost since it is also a function of ratios involving $K_{v+2}(z)$, $K_{v+1}(z)$ and $K_{v}(z)$. The combination of mean and variance estimates can be used to estimate the mass of the distribution that is lost by truncating at $r_k$. \iffalse The greedy algorithm proposed by \citet{teh08} uses instead \begin{align*} \Delta_{k,C}^{\rm prev} = \ \frac{1}{2\lambda_k}\left(-d+\sqrt{d^2+2\lambda_k\bm{\epsilon}_{k-1,C}}\right)-\frac{1}{2}r_k \,. \end{align*} The former proposal uses equation~\eqref{eq:delta_sample} whereas the latter uses equation~\eqref{eq:delta_pi_post} directly without taking into account $Z_{k,C}$. This means that using the properly normalized posterior of $\Delta_k$ leads only to a minor correction of $\Delta_{k,C}$. The following Lemma~\ref{lem:delta_rel} formalizes the relationship between the two proposals. \begin{lemma}\label{lem:delta_rel} If $0<\bm{\epsilon}_{k-1,C}<\infty$, then the following holds % \begin{enumerate} \item $\Delta_{k,C}/\Delta_{k,C}^{\rm prev}\to 1$ as $d\to\infty$. \item $\Delta_{k,C}/\Delta_{k,C}^{\rm prev}>1$ if $\lambda_k\bm{\epsilon}_{k-1,C}>4(d+2)$. \item $\Delta_{k,C}-\Delta_{k,C}^{\rm prev}$ decreases as $2\lambda_k\bm{\epsilon}_{k-1,C}/d^2+{\cal O}(d^{-3})$. \end{enumerate} \end{lemma} \begin{proof} For (1) is enough to take $\lim_{d\to\infty}\Delta_{k,C}/\Delta_{k,C}^{\rm prev}$ by repeatedly applying L'Hospital's rule. (2) is obtained as the solution to the following system of equations % \begin{align*} \widetilde{\Delta}_{k,C}^2+2d\widetilde{\Delta}_{k,C} & = 2\lambda_k\bm{\epsilon}_{k-1,C} \,, \\ \widetilde{\Delta}_{k,C}^2+(d-2)\widetilde{\Delta}_{k,C} & = \lambda_k\bm{\epsilon}_{k-1,C} \,, \end{align*} % with solution $\Delta_{k,C}=2-r_k/2$ and $\lambda_k\bm{\epsilon}_{k-1,C}=4(d+2)$ for $\widetilde{\Delta}_{k,C}=(2\Delta_{k,C}+r_k)$. Lastly, (3) is the result of a Taylor series expansion of $\Delta_{k,C}-\Delta_{k,C}^{\rm prev}$. % \end{proof} Lemma~\ref{lem:delta_rel} implies that $\Delta_{k,C}^{\rm prev}$ only matches the true maximum a-posteriori estimate, $\Delta_{k,C}$, when $\lambda_k\bm{\epsilon}_{k-1,C}=4(d+2)$, thus $\Delta_{k,C}^{\rm prev}$ is a biased estimator of ${\bf t}$ almost everywhere. Besides, for small values of $d$, the difference between $\Delta_{k,C}$ and $\Delta_{k,C}^{\rm prev}$ could be large enough to make the outcome of both algorithms significantly different. \fi \subsection{Computational cost} The computational cost of using equation \eqref{eq:delta_pi_post} directly to sample from ${\bf t}$ and $\bm{\pi}$ for a single particle is ${\cal O}(\kappa_1n^3)$, where $\kappa_1$ is the cost of drawing the merging time of a single candidate pair \citep{teh08}. Using equation \eqref{eq:delta_pi_modpost} costs ${\cal O}(\kappa_2n^3 + \kappa_1n)$, where $\kappa_2$ is the cost of computing $Z_{k,C}$ for a single candidate pair. Since $\kappa_2<<\kappa_1$, using equation \eqref{eq:delta_pi_modpost} is much faster than previous approaches, at least for moderately large $n$. From a closer look at equation~\eqref{eq:pi_modpost} we see that the only variables changing with $k$ are $\lambda_k$ and $r_k$. If we cache $\bm{\epsilon}_{:,C}$, the only costly operation in it is the modified Bessel function. We can approximate equation~\eqref{eq:pi_modpost} by \begin{align} \label{eq:pi_fmodpost} Z_{k,C} \ \propto & \ \frac{K_{1-d/2}(\sqrt{\bm{\epsilon}_{k-1,C}})}{(\bm{\epsilon}_{k-1,C}^{-1})^{(1-d/2)/2}}\exp\left(\frac{\lambda_k}{2} r_k\right) \,, \end{align} where we have dropped $\lambda_k$ from the Bessel function and the divisor in equation~\eqref{eq:pi_modpost}. This is acceptable because (i) $K_{\nu}(z)$ is strictly decreasing for fixed $\nu$ and (ii) the $\lambda_k$ term appearing in the divisor is a constant in $\log Z_{k,C}$. Note that a similar reasoning can be applied to equation~\eqref{eq:pi_modpost_ne}, which is cheaper and numerically more stable. Since equation~\eqref{eq:pi_fmodpost} depends on $k$ only through $\lambda_k r_k$, we have decreased the cost from ${\cal O}(\kappa_2n^3 +\kappa_3n)$ to ${\cal O}(\kappa_2n^2 + \kappa_3n)$, that is, we need to compute equation~\eqref{eq:pi_fmodpost} for every possible pair only once before selecting the merging pair at stage $k$, then we add $\lambda_k r_k/2$ (in log-domain) before sampling its merging time. From now on we use {\sc MPost1} to refer to the algorithm using equation \eqref{eq:pi_modpost} and {\sc MPost2} to the fast approximation in equation~\eqref{eq:pi_fmodpost}. Recently, \citet{gorur08} proposed an efficient SMC sampler ({\sc SMC1}) for hierarchical clustering with coalescents that although was introduced for discrete data can be easily adapted to continuous data. Their approach is based on a regenerative race process in which every possible pair candidate proposes a merging time only once leading to ${\cal O}(\kappa_1n^2)$ computational time. In principle, {\sc SMC1} has quadratic cost as does {\sc MPost2}, however since $\kappa_2<<\kappa_1$ our approximation is considerably faster. In addition, we have observed empirically that at least for $n$ in the lower hundreds, {\sc MPost1} is also faster than {\sc SMC1}. The key difference between our approach and that of \citet{gorur08} is that the latter proposes merging times for every possible pair and selects the pair to merge as the minimum available at a given stage whereas our approach selects the pair to merge and samples the merging time in a separate step. Additionally, they do not sample merging times using $\Delta_{k,c}=t_k-t_c$ but directly $t_k|t_c$, where $t_c$ is the time at which the pair $c$ was created, thus $0\leq t_c < t_k$. For example all pairs of singletons get created at $t_c=0$ regardless of the value of $k$. As $t_c$ occurs generally earlier than $t_{k-1}$, {\sc SMC1} draws $\Delta_{k,c}$ in larger jumps compared to {\sc MPost1/2}. Since the conditioning of $t_k$ is involved in the truncation level of the GIG distribution, time samples from {\sc SMC1} are less constrained. This suggests that our approach will have in general better mixing properties; we compare the speed and accuracy of our approach with previous approaches on both simulated and real data examples in Appendix \ref{sc:results}. \section{Application: Multiple correlated outcomes}\label{sec:emrResults} The broad adoption of electronic medical records has created the possibility of building predictive models for pateint populations at almost any health system. One of the challenges faced when building these predictive models is identifying the appropriate outcome. This is because patients with chronic diseases are typically at risk for many different bad outcomes - often with varying levels of relatedness. In this section we will demostrate the incorporation of the Kingman coalescent in a larger model that allows one to borrow strength across multiple outcomes with unknown levels of relatedness. Suppose we have $Y$, an $N\times P$ dimensional matrix with elements $y_{ij}$ indicating the presence or absence of outcome $j$ for patient $i$. Also, let $X$ be a $N\times K$ dimensional matrix of independent variables. We assume a probit regression model for the outcomes. For $x_i$, the $i^{th}$ row of $X$ we have: \begin{eqnarray*} P(y_{ij}) &=& \Psi(\mu_j + x_i \beta_j) \end{eqnarray*} where the outcome specific intercept $\mu_j$ allows joint modeling of outcomes with different rates, $\beta_j$ is the $K$ dimensional vector of regression coefficients for outcome $j$ and $\Psi$ is the cumulative distribution function for the standard normal distribution. Because all outcomes are at increased risk from the same chronic disease, we suspect that probabilites will be correlated. In order to capture this, we use the coalescent to impose a prior distribution that encourages correlation in the regression coefficients without {\em a priori} knowledge of the strength of relatedness or the values of the regression coefficients. Suppose $\beta_k$ is the parent node for $\beta_j$ and recall that $t_k$ is merging time for node $k$. \begin{eqnarray*} \beta_j|\beta_k, {\bf t}, \bm{\pi} &=& N(\beta_k,(t_k-t_j) \Phi)\\ {\bf t}, \bm{\pi} &\sim & \mbox{Coalescent}(K) \end{eqnarray*} We use an inverse Wishart prior on the covariance matrix $\Phi$. We will test the model in a factor regression context examining models that predict outcomes for $\approx$ 19K diabetic patients using data from an electronic medical record. Diabetic patients are susceptible to many different types of comorbidities - we develop predictive models for the 21 that are listed in Table \ref{tbl:results}. The presence/absence of these comorbidities was ascertained through ICD9 codes; the codes used to identify each are available in supplementary material. We conducted our experiment on data from a large regional health system - Duke University IRB protocol number PRO00060340. The patient pool consisted of all patients with a home address in a particular county and all records collected between 2007 and 2011 (inclusive). {\em Construction of independent variables and outcomes.} For each patient, the data consists of a collection of date-time stamped observations with labels. The labels include medical codes (ICD9, CPT), vitals, medications and laboratory values. For some types of observations (labs and vitals) there are additional continuous values, but these were discarded for this analysis. A high-dimensional sparse vector (3865 independent variables) was constructed for each patient by counting observations for 6 months prior to a specified {\em threshold date} - 1/1/2009 for training and 1/1/2010 for test. We used non-negative matrix factorization \citep{nnmf} on the square root of this matrix to reduce the dimension from 3865 to 25; the 25 factor scores vectors were then used in the regression model above. We recognize the opportunity to incorporate the dimension reduction into a larger model rather than using this two-step process of dimension reduction followed by regression. However, that approach would have complicated the comparison to more standard regression techniques. We also note that the matrix factorization generates collections of observation types with very nice medical interpretations; for example, one factor is heavily weighted with medical codes, meds and labs associated with lung cancer. However, examination of those discovered relationships is outside the scope of this article. \input{bfResults25_limited.tex} Outcomes were constructed by identifying the presence/absence of the relevant comorbidity in the year following the threshold date. Training and test data sets were constructed by thresholding the dataset at Jan 1, 2009 and Jan 1, 2010 respectively. We compare our results to ridge regression, elastic net and maximum likelihood regression. {\em Predictive accuracy.} Predictive accuracy was assessed by area under the ROC curve using 10-fold cross-validation in the training set and directly on the test set after training on the full training set. Table \ref{tbl:results} shows accuracies for each of the outcomes and a number of the modeling methodologies. The model described here, coalescent regression, consistently outperformed other approaches. Elastic net and Ridge were also tested, but performed worse than the others listed. The full table including elastic net and ridge is available in supplemental material. {\em Future costs for diabetic patients.} Identifying high risk patients with the goal of preventing morbidity and mortality is of paramount interest. However, improving the health of the high risk patients can have the additional side effect of lowering their future healthcare costs. In order to assess the future costs of patients with diabetes, we linked the billing codes from the medical records data set with the publicaly available physician fee schedule from the Centers for Medicare and Medicaid \citep{cmsFee}. This allows us to assign a cost to each procedure performed for each patient. We then computed the cumulative cost at each day following the threshold date for each patient. \begin{figure}[!ht] \captionsetup[subfigure]{} \centering \subfloat[]{\includegraphics[width=.45\textwidth]{tree25}}\quad \subfloat[]{\includegraphics[width=.45\textwidth]{cumulativeRVU}} \caption{Future costs for patients with diabetes. Panel (a) shows the tree structure with highest posterior probability; the circled node corresponds to the model that best stratifies patients on future costs in the {\em training} data set. Panel (b) shows future costs of patients in the {\em test} data set stratified by quartile from the risk model identified in panel (a). 90\% confidence bands are computed by bootstrapping with 500 patients.} \label{fig:futureCost} \end{figure} One advantage of the tree model for predicting outcomes is the availability of regression models at each of the parent nodes. Models in these nodes can be loosely interpreted as predictors of the composite outcome composed of outcomes in each of their associated leaf nodes. Each of the leaf and internal node models gives rise to a separate risk stratification. We tested - in the training data set - the ability of all models to stratify patients based on future costs. Figure \ref{fig:futureCost}(a) shows the tree with the highest posterior probability among those sampled; the circled node corresponds to the model that best stratifies patients based on future cost in the {\em training} data set. Costs for each of four quartiles based on risk stratification using this model are shown in the {\em test} data set in Figure \ref{fig:futureCost}(b). Because the outcomes we are predicting with our risk model are typically high cost outcomes, we find the resulting models stratify future costs very well even though future cost was not explicitly included in the model. \section*{Supplementary materials} {\bf Source code:} Matlab/C code required to perform the methods described in the manuscript, including sample scripts and the artificial data generator used throughout the results section (mvbtree\_v0.1.zip, compressed file).
{'timestamp': '2016-08-11T02:08:05', 'yymm': '1608', 'arxiv_id': '1608.03191', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03191'}
arxiv
\section{Introduction} The rise of the Makers Movement is one of the most exciting trends in the past decade~\citep{Martin2015}. In a learning environment, a maker is a true learner that values the process of making as much as the product. Making has the potential to create life-long learners and it is an activity that fits perfectly within Project Based Learning (PBL) curricula~\citep{bender2012PBL}. In this context, hands-on robotics appears as an ideal instructional approach~\citep{Rieber1996,Catlin2012}. The impact of a hands-on robotics program focused on expression and creativity in the service of improving student technological fluency has been recently highlighted~\citep{Hamner_2013_7442}. Firstly, such a program offers (classroom) activities that expose students to valuable concepts from Science, Technology, Engineering and Mathematics (STEM), and it allows to address STEM topics deemed strategic in several national education programs. Secondly, these activities are aligned with core constructionism concepts (e.g. ``think with your hands'') and with current neuroscience research on teaching to the brain’s natural learning system~\citep{given2002}. Finally, activities involving robotics also foster essential skills like problem solving, collaboration and project management. The last two skills are specially relevant when participants work in groups, as done in scientific and engineering work. The natural curiosity in kids and teenagers is particularly strong when it comes to machines. This make robots ideal tools to keep them engaged and motivated during learning. This is specially true when the learning methodology uses unconstrained robotics, i.e. building robots without preassembled kits. Unconstrained robotics truly puts the participant in the role of the maker, bringing them to decision-making situations that accurately simulate working environments. For example, a group must first agree on a robot design; this implies the exchange of explanations to illustrate each member's ideas and decide on the contributions that will be part of the final design. Once a design is in place, the group needs to effectively distribute tasks among its members and make time scheme. Robotics activities are well scaffolded with inquiry project-based learning, which sets up an environment where participants are engaged in open-ended, student-centered, hands-on activities~\citep{Colburn2000}. This involves tackling real-world problems and generating solutions, which can also be relevant for the participants' community~\citep{Bouillion2001}. In this environment, the learning process is shared with the tutors who guide and stimulate participants to question~\citep{freire1989question}. Despite the fact that building a robot is an exiting idea (probably due to its strong presence in popular culture), it might not resonate with the interest of all students. Noteworthy, there are gender issues to be addressed in robotics or more generically in STEM. Worldwide girls are underrepresented in STEM oriented higher education programs and professions~\citep{burke2007}. Among other things, this segregation is troublesome for industries: when women are not involved in the design of their products, needs and desires unique to women may be overlooked~\citep{Hill2010}\footnote{The case of LEGO is analysed in \url{https://youtu.be/CrmRxGLn0Bk}}. The gender difference is dramatic in well developed countries~\citep{Sjoberg2010} and there seems to be a relation with how technology is perceived by girls, which discourages them to pursue activities in the topic. Evidence shows that robots equally attract girls and boys, but each gender might be captivated by different aspects of the technology. A solution is to design robotic activities that are attractive to both genders~\citep{Johnson2003} and this might be catalysed by the inclusion of art. In this paper we discuss a four days long robotics and art activity (ArtBots) organized for a highly heterogeneous group of teenagers. During ArtBots, students were asked to design and build their own robot artist. The activity involved the interaction between participants of different ages, socio-economical backgrounds and cultures. The physical results of the process, the ArtBots, were exposed on the last day during an exhibition at a Belgian contemporary art museum. The goals of the activity were threefold: \begin{enumerate} \item To provide technical skills and robot building experience to high-school students, \item To cause a cross-cultural exchange of knowledge and experiences, \item To train technology ambassadors who stimulate friends and other students to get involved in technology. \end{enumerate} In this article, see Section~\ref{sec:introbotweek}, we document the activity so that it could be reproduced by others. Additionally, we discuss ArtBots as an inquiry project-based learning approach for STEM and we share our insights on how the project affected the way participants perceive STEM (see Section~\ref{sec:discussion}). \section{An international robot week for secondary school students}\label{sec:introbotweek} While the ArtBots event itself spanned only 4 days (from Thursday evening until Monday afternoon), preparation took much longer. It involved a crowdfunding campaign, searching a workspace and sleeping accommodation, acquiring material and tools, informing the participants, their schools and their families, and much more. An overview of the time distribution can be found in Figure~\ref{fig:timeline}. \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{./figs/time_line_011115.png} \caption{Timeline of the organization and execution of ArtBots. The event lasted 4 days while its preparation required the orchestrated actions of volunteers during 7 months: $98\%$ of the time was spent in the preparation of the event.}\label{fig:timeline} \end{figure} In the following sections we focus on the selection of the participants and the execution of the ArtBots event itself. \subsection{Selecting the participants} ArtBots was intended for teenagers (from 12 to 18 years old) with a socio-economically disadvantaged background and a strong interest in science and technology. Additionally, we aimed for gender equality. In order to reach out to this audience, we defined a set of guidelines for the selection of students that were sent to schools and other organisations that we contacted: \begin{itemize} \item Age: students were selected in the age range of 12 to 18 year (high school). \item Gender: we aimed for a healthy collaboration between girls and boys. We suggested schools and organisations to assemble gender-balanced groups and to give preference to lesbian, gay, bisexual, and transgender (LGBT) students. \item Motivation: we asked for students who were fascinated by science and technology, eager to design and build machines or to program applications. \item Social background: different social backgrounds were described. The preference was given to students with no opportunities to travel nor access to other leisure activities (children's camps) during their holidays. Students from economically disadvantaged households should be treated with preference. \item Language: participants had to have basic English understanding (level A1 of the Common European Framework of Reference for Languages~\citep{Europe2004}). \end{itemize} The above criteria served as guidelines only. Figure~\ref{fig:participants} summarizes the characteristics of the participants. Most of them had little experience with both art and robots. We did not survey the actual participants for their social backgrounds. Consequently, we can not give any quantitative results on this matter. However, we observed that we had a good mixture (approx. $50\%$) of underprivileged and privileged teenagers. \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{./figs/Artbots_statsdrawing.png} \caption{Summary of participants' count (51 in total), gender and nationality. Credits: Maps from Wikimedia}\label{fig:participants} \end{figure} \subsection{Art and robots\label{ArtBots}} \begin{figure}[t] \centering \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/robot_sketch_1.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/robot_sketch_2.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/robot_sketch_3.jpg} \end{subfigure} \caption{Some of the participants' robot designs after the brainstorming session with the artists.}\label{fig:robot_sketches} \end{figure} The venue took place at a private art site with a large modern and contemporary art exhibition space. The inspiring and primitive environment immediately put our participants in an artistic mindset. In order to give the participants a better understanding about art, we collaborated with an artist co-creation platform who sent two artists to present their views on art. The artists organised a brainstorm session where participants had to express their views and ideas about artistic robots. The key idea was to give each participant the time to think about their own ArtBot without being constrained by tools, materials or knowledge. During this brainstorm process, all participants expressed their ideas on paper. This is illustrated in Figure~\ref{fig:robot_sketches}. \subsection{Crash course into programming, electronics and mechanics} Robotics emerges from the combination of electronics, mechanics and programming. To build a robot, the designer must get in touch with all these fields. During ArtBots we provided crash courses to all the participants. Each crash course was designed and taught by volunteers with experience in the field. \subsubsection{Programming and algorithmic thinking\label{program}} It is unrealistic to think that we could teach programming in a few hours. However, the materials used for this event, namely the Dwenguino board\footnote{The Dwenguino board is a multi-functional Arduino IDE compatible microcontroller platform (\url{http://www.dwengo.org/tutorials/dwenguino/dwenguino-board}).}, allowed us to focus on a reduced set of programming and algorithmic skills: conditionals, loops and functions. This reduced skill set was sufficient to program robots with complex behaviors. To introduce the participants to conditionals and loops we used the Blockly Game suit\footnote{https://blockly-games.appspot.com}. After a short and playful introduction to the topic and a short icebreaker Q\&A session, we invited the participants to set the interface to the language they felt most comfortable with and then we asked them to solve the ``Maze'' challenges of Google Blockly. In these challenges the user must write instructions for a software agent, such that it moves through a maze from an initial point to a final destination marked with an arrow. Participants with programming experience were invited to opt for harder problems from Google Blockly. The most experienced participants settled into the programming games ``Turtle'' and ``Pond''. We let them play with the game for about 45 minutes. The second part of the crash course focused on the use of the Dwenguino board and took approximately 30 minutes. In this part we also introduced the idea of using functions. We used the integrated LCD screen to show how functions are used. We allowed free exploration of the LCD and the other functions of the Dwenguino. At the same time, small challenges were provided to guide students that might felt lost. For example, we asked them to write code to turn on the backlight of the LCD, to blink a LED, to detect a pressed button, etc. A small sample source code of an easy challenge would look like the one shown in Snippet~\ref{code:example}. \lstset{language=C++, basicstyle=\ttfamily, keywordstyle=\color{blue}\ttfamily, stringstyle=\color{red}\ttfamily, commentstyle=\color{gray}\ttfamily, morecomment=[l][\color{magenta}]{\#} } \begin{lstlisting}[caption={Code used for the LCD programming challenge.},label=code:example] #include <LiquidCrystal.h> #include <Wire.h> #include <Dwenguino.h> void setup() { initDwenguino(); // Use this function to print your name dwenguinoLCD.print("Hello!"); // Can you read it? // How do you turn on the backlight? } void loop() {} \end{lstlisting} Finally, we offered the participants a rather complex source code sample that printed the letter "A" on the LCD and blinked a LED every time a button was pressed. We asked them to discover what part of the code was responsible for the blinking LED and we challenged them to modify the code such that the letter "A" moved one place to the left each time the button was pressed. This {\it find and hack} task was optional and meant to encourage deeper understanding of the code. \subsubsection{Electronics\label{electron}} Similar to the programming course, the electronics crash course was given in a hands-on way. The goal of this course was to provide the basic concepts of electronics with respect to robotics rather than overwhelming the participants with theory. Initially, participants had to figure out what is the use of electronics. For example, if they wanted to make a painting robot, we ask them to think about how would they tackle the challenge by themselves. This guided them to analyse the painting behavior. Afterwards, they had to translate this into a robot and its components. In order words, they had to think about electronic components as equivalents of human senses, brain and muscles. The participants were able to come up with examples such as sound sensors, light sensors, push buttons and ultrasonic sensors. When discussing about the robot's intelligence, participants proposed the analogy between the brain and a programmable computer (or microcontroller). Servomotors and other type of motors would play the role of muscles. After this initiation, the main part of the crash course took place which consisted of solving different challenges in small groups of two or three participants. For example, one of these challenges consisted in controlling the position of a servo with a potentiometer. This is a relatively simple task that covers all the necessary concepts: analog input processed by a microcontroller which controls actuators. We provided all the components (sensors, the Dwenguino board and motors) and an incomplete source code. Participants had to build the electronic circuit and complete the code. Additional information and answers to questions were provided on demand, by the tutoring volunteers. \subsubsection{Mechanics} For the mechanical part of the robot development, we supplied participants with a broad range of materials and tools. We set up a live demonstration and try-out for both hand and power tools available in the workshop. To learn the names of the tools available in the workshop, overcoming the language diversity of the group, we organized games. We did this to avoid giving an extensive enumeration and description of each tool. We also discussed safety measures for correct handling of the tools. Following up to this introduction, we elaborated on appropriate material and tool selection for different applications, as well available materials for joining techniques such as (hot) gluing, bolting, screwing, nailing and interlocking. When prototyping a robot, Computer Aided Design (CAD) can be used for a better 3D visualisation and communication of different concepts and ideas. To introduce the basics of 3D modeling, we gave a short demonstration followed by individual practice in redrawing simple existing objects. We used Autodesk's 123D Design\footnote{A basic and intuitive freeware CAD tool \url{http://www.123dapp.com/design}} for designing some of the more complex robots' parts. The majority of those custom developed parts were later produced through additive manufacturing, also known as 3D printing. To warrant success of the 3D printing process, participants received easy-to-understand guidelines. \subsection{From idea to realisation} \begin{figure}[t] \centering \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/process_1.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/process_2.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/process_3.jpg} \end{subfigure} \caption{Some photographs taken during the building process}\label{fig:robot_building} \end{figure} \begin{figure}[ht] \centering \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/artbot_1.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/artbot_2.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/artbot_3.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/artbot_4.jpg} \end{subfigure} \caption{A selection from the realised ArtBots: a paint shooting robot, a dripping robot, a block collecting robot and a sound registering robot.}\label{fig:robot_selections} \end{figure} During the crash courses, we, the organisers, gathered and clustered the robot designs (i.e. the sketches) based on the concepts within the design. For example, multiple participants wanted to build a robot that integrated some action painting (e.g.~throwing or shooting paint). And thus, we put together all ideas related to action painting. The clustering process was performed without any interference from participants. Consequently, the clustering did not consider age, cultural background or gender of the participants. This resulted in 12 clusters and 12 teams, with ideas varying from action painting to abstract interactive ArtBots. After the crash courses, we asked the participants to find their team mates within the assigned clusters. Next, we asked them to refine their ideas about programming, electronics and mechanics with respect to their robot designs, and start the building process. Mechanical components, motors, microcontroller boards and sensors were provided to the participants as basic building blocks for their robot. Additionally, participants had access to all the necessary tools to build their robot. This included computers, 3D printers, milling machines, soldering stations etc. As the timeline in Figure~\ref{fig:timeline} shows, the building process was spread over three days and took the largest part of the available time frame. Action pictures of the students during the building process are given in the pictures on Figure~\ref{fig:robot_building}. Although some groups had to work until the very last minute, all 12 teams managed to finishing their robot. Most robots could paint by using stamps, brushes, dripping and shooting mechanisms, while some other robots were more abstract, including interactive poetic robots and a block collecting robot. Figure~\ref{fig:robot_selections} gives four examples. \subsection{Social activities} In order to provide some distraction, social activities were organised which varied from short in-between activities such as taking a 3D scan of your face and 3D printing it, and playing sports games. Additionally, we organised some longer activities such as an afternoon visit to the historical town centre of Ghent. \subsection{Exhibition} The last ArtBots day was dedicated to an exhibition, that was held at the Verbeke venue. All 12 robots were presented by their makers to a broad audience of parents, teachers and sponsors. The main event on the exhibition was a live painting session during which all painting robots were put on a huge canvas to co-create a painting. In Figure~\ref{fig:robot_paintings} we show snapshots of the event, as well some of the resulting paintings. \begin{figure*}[t] \centering \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/exhibition_1.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/exhibition_2.jpg} \end{subfigure} \begin{subfigure} \centering \includegraphics[height=1.5in]{./figs/exhibition_3.jpg} \end{subfigure} \caption{The exhibition with an ArtBots fight and some of the resulting paintings.}\label{fig:robot_paintings} \end{figure*} \section{Results and discussion}\label{sec:discussion} As stated in the introduction, the goal of our activity was threefold: (1) provide technical knowledge and robot building experience; (2) cause a cross-intercultural interaction and (3) train technology ambassadors who stimulate friends and other students to get involved in technology. In order to evaluate whether these goals are met or not we observed our participants thoroughly during the activities and conducted a post-survey to question the participants about their experiences. Our survey was completed by 26 out of 51 of the participants. \subsection{Students perspective on difficulty} One of our goals was to provide technical knowledge and robot building experience. While we did not measure the knowledge acquired by the students during our activity, we can say that all students participated in the building process and thus experienced the process of building robots. In order to get acquainted with the students' perceived difficulties we asked them to tell us what they found hard and what easy. The answers are summarized in Figure~\ref{difficulty} which shows that programming was perceived as the hardest to learn, while no student reported mechanics as hard to learn. Electronics appears as a middle ground between these two. \begin{figure*}[hbt] \centering \includegraphics[width=0.9\textwidth]{./figs/difficultyGraph_labels.png} \caption{Difficulty of topics as perceived by the participants. The nodes show the topics that participants reported as easy or hard to learn. The arrows go from ``easy'' to ``hard'', with the width of the arrows indicating the percentage of participants that completed the survey (total number next to the arrow). Most students found programming difficult to learn and no student found mechanics difficult to learn.}\label{difficulty} \end{figure*} Within the group of participants who completed the survey it seems that the more a skill departs from everyday experience, the hardest is to learn it. This observation is anecdotal, as the amount of answers is not representative, and it coincides with the observation made by tutors and with the intuitive idea of learning being bootstrapped by the affordances\footnote{The affordances of an object are the opportunities it offers to interact with it, e.g. a piece of wood can be rotated by hand, texture and shape can be sensed by touch, it can be pushed/pulled/lifted, etc.; cf. the source code of a program.} provided by the objects manipulated~\citep{given2002}. It might also be a consequence of the reduced time dedicated to practise this skill. We read this perceived difficulty as an indication that the tools used in the learning of these skills need to be developed further to offer more affordances: to bring the skills and concepts closer to everyday experience. This is also known as the virtual-to-real problem~\citep{dwengo2015_article}. In the mind of the participant, there are always expectations about what their robot should do (e.g. its behaviour). These expectations can be expressed in natural language quite well, e.g. "When I press this button, my robot should start" or "When the light is too low the robot should turn around". The participant can picture these ideas in their mind's robot simulator. More often than not, these ideas are a simplification of the robot's real behaviour. Consequently, when they need to bring these ideas down to the real hardware, some unforeseen aspects of the hardware will become important, making the translation from virtual to real less direct. We think that by integrating an intermediate learning step which involves adding abstraction layers to hardware and software, this virtual-to-real problem becomes easier to tackle for the participant. For this we could for example include a robot simulator before switching to real robots. This kind of development are now common in physics, geometry and algebra~\footnote{\url{https://phet.colorado.edu/} and \url{https://www.geogebra.org/}}, but they are lacking in the field of robotics despite the huge advances brought by the open hardware community. \subsection{Dealing with dangerous tools during robot construction} Empowering teenagers to work with both hand and power tools requires a thoughtful approach. During the live demonstration and try-out of the available tools, the students were asked to discuss the points of attention and safety rules. Instead of imposing safety measures, it is important to let the students come up with some self-evident measures by themselves, such as wearing safety goggles and ear protection during cutting operations, only using paints, solvents or torches in well-ventilated rooms, etc. Less comprehensible measures, such as not wearing safety gloves while using fast rotating power tools (e.g. miter saws, band sanders), were explained thoroughly. An appropriate supervision of the teenagers is important to prevent injuries~\citep{Peterson1993}, alongside raising awareness of possible safety risks, especially in a mix of teenagers of strongly varying ages. We draw a more general conclusion: giving responsibility to teenagers in handling dangerous situations, preceded by a discussion about safety in which there is room for the teenagers' own input, will have an overall positive effect on safety~\citep{Zaske2015}. This corresponds with the observations we made during the activities. All participants, including the youngest ones, handled the dangerous tools with care as instructed by the tutors. \subsection{Observed social behaviour} On the first day, participants grouped on small groups with people from their school. However, after the brainstorm session the students were put together according the similarity of their ideas. This resulted in groups of mixed nationalities and social backgrounds. The social interaction as perceived by the participants (participants were asked with whom they had interacted) is visualised in Figure~\ref{fig:interaction}. The thicker the arrow, the more students interacted with someone of a different nationality. The size of the arrows were normalised with respect to the amount of students that completed our post-survey. Note that there is no leaving arrow from the Dutch students, although they interacted with other students, simply because none of the Dutch students completed the survey. \begin{figure}[tb] \centering \includegraphics[width=0.45\textwidth]{./figs/interactionGraph.png} \caption{This infographic illustrates the interaction between participants from different countries. The thicker the arrow, the more students interacted with someone of a different nationality. Note that there are no leaving arrows from the Dutch students since they did not complete the surveys.}\label{fig:interaction} \end{figure} By looking at the graph one notices immediately strong cultural differences in openness and willingness to interact with people from other cultures. For example, all Argentine students interacted with students from other nationalities. This was despite their limited English proficiency and the fact that the Argentine students were the farthest from home. On the other hand we noted limited interaction from the Walloon students which is confirmed by our survey. Nevertheless we can say that our activity succeeded in achieving a cross-cultural collaboration between the participating students. This is expressed greatly by the following quote of one of the Irish participants: {\it The most important lesson that I learned is that international barriers should not stop you from making friends. I learned this because I made new friends from Belgium, Netherlands and Argentina.} The observed dynamics in the group brainstorming, or collaboratively generating ideas through idea sharing, supports the results of~\citet{wang2011} that introducing conceptual diversity, such as cultural difference internal to a multicultural group, sparks more ideas and improves creativity. \subsection{Becoming technology ambassadors} An important aspect of the learning process is how enjoyable it is for the students. It has been observed in the past~\citep{wyffels2010} that building robots can be used as a tool to learn how to solve problems which would be otherwise considered too abstract and tedious. This was also confirmed during our activity. The students were so engaged into building ArtBots that it was hard to convince them to go to a closing party with a DJ, drinks and candies (e.g. one of the social activities) on Sunday evening. In our survey the participants graded the ArtBots event with $8.6$ points out of $10$. Additionally, the students' answers in our post-survey reflect their enthusiasm about the activities: \begin{itemize} \item Un nuevo concepto de arte, que inspira para ver mas allá de los estándares propuestos; la creatividad puede llevarnos a construir robots originales y más útiles. {\it (Translation from Spanish) A new art concept that inspires to look beyond the standard; creativity can make us build orginal and more useful robots.} \item I learned that with enthusiasm and compromise I can try to make a better world. The world can be more humane. \item Als je met een groepje samenwerkt je, onder een beetje druk en tijdsgebrek, heel coole dingen kan maken! {\it (Translation from Dutch) When you work together in a team, under a little bit of time pressure, you can create very cool things!} \item Il faut persister dans le travail que nous faisons et trouvé des solutions quand un problème se présente. {\it (Translation from French) By persisting in the work we found solutions whenever a problem occurred} \item To open your eyes, there is more in the world than just internet. \end{itemize} \subsection{Final remarks} The design and construction of a robot are not simple tasks and, unequivocally, the builder will face uncertainty. Under the right conditions this uncertainty provides a healthy amount of frustration and fuels curiosity. The particular way in which the robot building task challenges students keeps them motivated and gives them impetus to overcome frustration. This is the feature that makes robotic activities suited for many audiences and learning objectives. A salient feature of robotic activities such as ArtBots, is that they induce inquisitive attitudes in the participants. This was highlighted during the crash courses, see sections~\ref{program} and~\ref{electron}. Admittedly, the task ``build a robot that makes art'' is vaguely defined. Nevertheless, is this vagueness that gives power to the approach. Granting that motivation is not an issue, when faced with an insurmountable lack of knowledge about something (maybe a tool, a sensor, the use of a device) students naturally engage in inquisitive behavior. Students seek for the missing knowledge on the internet, ask their team mates or the tutors. The benefit of this emergent behavior is twofold. First, students train their abilities to pose question to others, question about extraordinary things, of which they might not know much about. The process of formulating intelligible questions is fundamental in the process of understanding and inherent to the inquiry-based learning process~\citep{Colburn2000}. This also endorses the effectiveness of interactive learning: you learn a lot more, faster and durable by doing it yourself than passively listening to a teacher~\citep{hake1998interactive,crouch2001peer}. Secondly, the tutors receive direct feedback on what topic cause the most problems for a group of students and/or what topic is most interesting for the group. This helps with the steering of the ongoing event and provides extremely useful information for the design of future activities with similar student groups. In terms of scientific literacy, the ArtBots project complies with the recommendations of~\citet{Kesidou2004} of showing relevance in science education and of paying attention to what students are thinking. Another positive aspect of starting from an open problem or context, is that it removes structure from the learning process. It is remarkable how the reduction of structure can spark creativity and inventiveness. Although the reduction of structure can generate unwieldy frustration, it also allows each participant to adapt the learning process to their own pace, needs and curiosity. The hands-on approach makes this possible: using tools as a means to an end, providing emergent learning experiences centered on the participants’ ideas and interests, creating the opportunity to explore one’s own creative potential. Finally, by adopting the maker mindset, participants become producers instead of users, clients or consumers of technology. Art is just one of the many non-technical disciplines that can be combined with engineering and science. Fields related to history (e.g. archeology) could be combined in events when a technology of the past is being reproduced in the present; or when a technology that was crucial for a historical event (e.g. enigma in WWII) is being reproduced. Similarly, literature can be combined with story telling and programming, advertisement and sociological models can be introduced using simulated agents or interactive machines~\citep{Bogost2010}. The combinations are endless, we need only experiment and dare to break the pedagogical conventions. \section{Conclusion}\label{sec:conclusion} Taken as a whole, the underlying framework of this study suggests a fluid interaction among robot, student, and trainer. Trainers facilitate access to robots and mediate related interactions with students, while robots are suitable for manipulations appropriate to the learning tasks. Students engage in flexible, active, and integrated learning, they explore and test designs and solutions. We conclude that by integrating arts and other social fields into STEM, one cannot only establish increased learning but also captivate a broader audience and tackle differences in age, gender and socio-cultural backgrounds. However, one must be aware of the fact that such educational activities might ask of a higher commitment of educators. A solution for this could be involving other actors such as parents with technical or artistic background. Moreover, we also found that the acquisition of skills with fewer affordances (e.g. programming) require developed teaching tools, more time, and guidance. \section*{Acknowledgment} The authors would like to thank all the volunteers and organisations\footnote{Please refer to \url{http://www.dwengo.org/projects/artbots} for a complete overview.} involved in the project. Without their support the ArtBots project would not have been possible. Additionally, we would like to thank all the participants for their enthusiasm and willingness to learn. We would like to thank Cedric Verhelst for providing all the photographs in this paper. The project was part of the Google RISE (Roots in Science and Engineering) 2014 program. \section*{Author contribution} All authors have contributed equally to the writing of this manuscript. The order of the authors list is inverse alphabetical; it is arbitrary and not a hierarchy. \section*{Conflicts of interest} Several authors are active members of the nonprofit organisations {\it Dwengo vzw} and {\it Dwengo Helvetica}. \bibliographystyle{plainnat}
{'timestamp': '2016-08-12T02:05:15', 'yymm': '1608', 'arxiv_id': '1608.03405', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03405'}
arxiv
\section{Introduction} It is well known that in the domain of online algorithms it is often provably necessary to use randomization in order to achieve reasonable approximation (competitive) ratios. It is interesting to ask when can the use of randomization be replaced by extending the online framework. In a more constructive sense, can we de-randomize certain online algorithms by considering more general one pass algorithms? This question has already been answered in a couple of senses. B\"{o}ckenhauer et al \cite{Bock11} show that a substantial class of randomized algorithms can be transformed (albeit {\it non-uniformly} and inefficiently) to an online algorithm with (small) advice. Buchbinder and Feldman \cite{Buchbinder2016} show how to uniformly and efficiently de-randomize the Buchbinder et al \cite{Buchbinder2012} algorithm for the unconstrained non-monotone submodular function maximization (USM) problem. The resulting de-randomized algorithm can be viewed as a parallel algorithm in the form of a ``tree of online algorithms''. We formalize their algorithm as an online restriction of the Alekhnovich et al \cite{Alekhnovich2011a} pBT model. In this paper we consider two classical optimization problems, namely maximum cardinality bipartite matching and the max-sat problem. As an offline problem, it is well known that graph matching and more specifically bipartite matching (in both the unweighted and weighted cases) can be solved optimally in polynomial time. Given its relation to the adwords problem for online advertising, bipartite matching has also been well-studied as a (one-sided) online problem. Max-sat is not usually thought of as an online problem but many of the combinatorial approximation algorithms for max-sat (e.g. Johnson's algorithm \cite{Johnson}, Poloczek and Schnitger \cite{Poloczek2011c}, and Buchbinder et al \cite{Buchbinder2012}) can be viewed as online or more generally one-pass myopic algorithms. To study these types of problems from an online perspective, several precise models of computation have been defined. With respect to these models, we can begin to understand the power and limitations of deterministic and randomized algorithms that in some sense can be viewed as online or one-pass. Our paper will be organized as follows. We will conclude this section with an informal list of our main results. The necessary definitions will be provided in Section \ref{sec:preliminaries}. Section \ref{sec:related} contains a review of the most relevant previous results. Section \ref{sec:max-sat} considers online parallel width results for max-sat. In Section \ref{sec:bipartite} we will consider results for bipartite matching with respect to parallel width, the priority model \cite{Borodin2003}, and the random order model (ROM). We conclude with a number of open problems in Section \ref{sec:conclusions}. \subsection{Our results} \begin{itemize} \item For the max-sat problem, we will show that the Buchbinder and Feldman \cite{Buchbinder2016} de-randomization method can be applied to obtain a deterministic parallel width $2n$ online $\frac{3}{4}$ approximation algorithm. \item We will then show (in a model more general than what is needed for the above $\frac{3}{4}$ approximation), that exponential width is required to improve upon this ratio even for the exact max-2-sat problem for which Johnson's algorithm already achieves a $\frac{3}{4}$ approximation. \item We also offer a plausible width 2 algorithm that might achieve the $\frac{3}{4}$ approximation or at least might improve upon the $\frac{2}{3}$ approximation achieved by Johnson's deterministic algorithm \cite{Johnson} which in some models is provably the best online (i.e. width 1) algorithm. \item For bipartite matching we show that constant width (or even width $\frac{\log n}{\log \log n}$) can cannot asymptotically beat the trivial $\frac{1}{2}$ approximation acheived by any greedy maximal matching algorithm. This implies that more than $\log \log n - \log \log \log n$ advice bits are needed to asymptotically improve upon the $\frac{1}{2}$ approximation achieved by any greedy maximal matching algorithm. \item We offer a plausible candidate for an efficient polynomial width online algorithm for bipartite matching. \item For bipartite matching, we will also show that the ability to sort the input items as in the priority model cannot compensate for absense of randomization. \item We also make some observations about bipartite matching in the random order model. \end{itemize} \section{Preliminaries: definitions, input and algorithmic Models} \label{sec:preliminaries} We will briefly describe the problems of interest in the paper and then proceed to define the algorithmic models and input models relative to which we will present our results. \subsection{The Bipartite Matching and Max-Sat Problems} In the unweighted matching problem, the input is a graph $G=(V,E)$ and the objective is to find the largest subset of edges $S \subseteq E$ that are vertex-disjoint and such that $|S|$ is as large as possible. Bipartite matching is the special case where $V = A \cup B$ and $E \subseteq A \times B$. In the (weighted) max-sat problem, the input is a propositional formula in CNF form. That is, there is a set of clauses $\calc = \{C_1, \ldots, C_n\}$ where each clause is a set of literals and each literal is a propositional variable or its negation. The objective is to find an assignment to the variables that maximizes the number of clauses in $\calc$ that are satisfied. In the weighted case, each clause has an associated weight and the objective is to maximize the sum of weights of clauses that are satisfied. The max-sat problem has been generalized to the submodular max-sat problem where there is a normalized monotone submodular function $f:2^{\calc} \rightarrow \mathbb{R}$ and we wish to assign the variables to maximize $f(\calc')$ where $\calc' \subseteq \calc$ is the subset of satisfied clauses. When a specific problem needs to be solved, there are many possible input instances. An instance is just a specific input for the problem in hand. For example, in bipartite matching, an instance is a bipartite graph. In weighted max-sat, an instance is a set of clauses (including a name, weight, and the literals in each clause). An algorithm will have the goal of obtaining a good solution to the problem for every possible instance (i.e. we are only considering worst case complexity). To establish inapproximation results, we construct an adversarial instance or a family of bad instances for every algorithm (one instance or family of instances per algorithm). We will mainly study deterministic algorithms and their limitations under certain models. We measure the performance of online algorithms by the competitive (or approximation) ratio\footnote{The name competitive ratio is usually used when considering online problems while approximation ratio is used in other settings. We will just use approximation ratio in any model of computation. For the maximization problems we consider, the approximation ratio is typically considered as a fraction less than or equal to 1.}. \begin{defn} Let $\mathbb{A}$ be an algorithm for a problem. Let $\mathbb{{\cal I}}$ be the set of all possible instances for the problem. For $I \in \mathbb{{\cal I}}$, let $v(\mathbb{A}, I)$ be the value obtained by the algorithm $\mathbb{A}$ on instance $I$ and let $v(I)$ be the optimal value for that instance. The approximation ratio of algorithm $\mathbb{A}$ is: \[ \inf_{I \in \mathbb{{\cal I}}} \frac{v(\mathbb{A}, I)}{v(I)}\] Let ${\cal I}_n$ be the set of all instances of size $n$ for the problem. The asymptotic approximation ratio of $\mathbb{A}$ is: \[ \liminf_{n \in \mathbb{N}} \inf_{I \in {\cal I}_n} \frac{v(\mathbb{A}, I)}{v(I)} \] \end{defn} The approximation ratio considers how the algorithm performs in every instance, while the asymptotic approximation ratio considers how the algorithm performs on large instances. Having a small instance where an algorithm performs poorly shows that the algorithm has a low approximation ratio, but says nothing about its asymptotic approximation ratio. \subsection{Algorithmic Models} We define the precise {\it one-pass} algorithmic models that we consider in this paper. For each, the algorithm may receive some limited amount of information in advance. Other than this, an instance is composed of individual {\it data items}. We define the size of an instance as the number of data items it is made of. Data items will be received in a certain order, and how this ordering is chosen depends on the algorithmic model. In addition, when a data item is received, the algorithm must make an irrevocable decision regarding this data item before the next data item is considered. The solution then consists of the decisions that have been made. We do not make any assumptions regarding time or space constraints for our algorithms. In fact, the limitations proven for these algorithmic models are information-theoretic: since the algorithm does not know the whole instance, there are multiple potential instances, and any decision it makes may be bad for some of these. Of course, how each data model is defined will depend on the specific problem (and even for one problem there may be multiple choices for the information contained in data items). Unless otherwise stated, for inapproximations we assume that the algorithm knows the size, and for positive results we assume that it does not know the size. \subsubsection{Online Model} In the online model, the algorithm has no control whatsoever on the order in which the data items are received. That is, data items arrive in any order (in particular, they may arrive in the order decided by an adversary and as each data item arrives, the algorithm has to make its decision. Thus, in this model an adversary chooses an ordering to prevent the algorithm from achieving a good approximation ratio. As long as it remains consistent with previous data items, the data item that an adversary presents to the algorithm may depend on previous data items and the choices that the algorithm has made concerning them. The following presents the structure of an online algorithm. \medskip \noindent\fbox \begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax} \begin{algorithmic}[1] \Statex \textbf{Online Algorithm} \State On an instance $I$, including an ordering of the data items ($d_1, \ldots, d_n$): \State $i:=1$ \State \textbf{While} there are unprocessed data items \State The algorithm receives $d_i$ and makes an irrevocable decision for $d_i$ \Statex (based on $d_i$ and all previously seen data items and decisions). \State $i:= i+1$ \State \textbf{EndWhile} \end{algorithmic} \end{minipage } \medskip In online bipartite matching, it is standard to consider that the algorithm knows in advance the names of the vertices from one of the sides of the graph, which we call the offline side. The other side, which we call the online side, is presented in parts. A data item consists of a single vertex from the online side along with all of its neighbours on the offline side. At each step, an algorithm can match the online vertex to any of its unmatched neighbours, or it can choose to reject the vertex (leave it unmatched). In either case, we say that it processes the vertex. All decisions made by the algorithm are irrevocable. We call this problem online one-sided bipartite matching. A data item consists of a single variable along with some information about the clauses where this variable appears. We consider four models, in increasing order of the amount of knowledge received: \textbf{Model 0:} The data item is a list with the names and weights of the clauses where the variable appears positively and a list of names and weights of the clauses where the variable appears negatively. \textbf{Model 1:} Model 0, plus the length of each clause is also included. \textbf{Model 2:} Model 1, plus for each clause we also include the names of the other variables that occur in this clause. The data item does not include the signs of these variables. \textbf{Model 3:} Model 2, plus for each clause we also include the signs of other variables in the clause. That is, in this model, the data item contains all the information about the clauses in which the variable occurs. For submodular max-sat, in addition to a description of the model for variables and their clauses, we need to state how the submodular function is presented to the algorithm. Since the submodular function has domain exponential in the size of the ground set (in this case the number of clauses), it is usually assumed that the algorithm does not receive the whole description of this function from the start. Instead, there is an oracle which may answer queries that the algorithm makes. A common oracle model is the value oracle, where the algorithm may query $f(S)$ for any subset $S$. In our restricted models of computation, this is further restricted so that the set $S$ can include only elements seen so far, including the current element for which the algorithm is making a decision. For submodular max-sat, this means restricting to sets of clauses each containing at least one seen variable. However, for some algorithms this is too restrictive. In the double-sided myopic model from Huang and Borodin \cite{Huang2014}, the value oracle may also query the complement function $\overline{f}$ defined by $\overline{f}(S) = f(C \setminus S)$ (where $C$ is the ground set). \subsubsection{Width models} We consider a framework which provides a natural way to allow more powerful algorithms, while maintaining in some sense an online setting. The idea is that now, instead of maintaining a single solution, the algorithm keeps multiple possible solutions for the instance. When the whole instance has been processed, the algorithm returns the best among the set of possible solutions that it currently has. The point is to limit the number of possible solutions the algorithm can have at any point in time. The possible solutions can be viewed as a tree with levels. A node in the tree corresponds to a possible solution and an edge means that one solution led to the other one after the algorithm saw the next data item. At the beginning, there is a single empty solution: the algorithm has made no choices yet. This will be the root of the tree and it will be at level 0. Every time a possible solution is split into multiple solutions, the tree branches out. Every time a data item is processed, the level increases by 1. The algorithm may decide to discard some solution. This corresponds to a node with no children and we say that the algorithm cuts the node. The restriction is that the tree can have at most $k$ nodes in each level. Since each level represents a point in time, this means the algorithm can never maintain more than $k$ possible solutions. There are three different models to consider here. In the max-of-$k$ model, the algorithm branches out at the very beginning and does not branch or cut later on. In particular, this model is the same as having $k$ different algorithms and taking the maximum over all of them in the end. In the width-$k$ model, the algorithm can branch out at any time. However, the algorithm cannot cut any possible solution: every node in the tree that does not correspond to a complete solution (obtained after viewing all data items) must have at least one child. Finally, in the width-cut-$k$ model, the algorithm can branch out and disregard a possible solution at any time (so that, at later levels, this possible solution will not contribute to the width count). Although we shall not do so, the width models can also be extended to the priority and ROM settings. For example, we can consider width in the priority model as follows: the algorithm can choose an ordering of the data items as in the fixed priority model (in particular, the arrival order has to be the same for all partial solutions), and once an input item arrives the solutions are updated, branch, or cut as desired. This then is the fixed order pBT model of Alekhnovich et al \cite{Alekhnovich2011a}. It is also possible to allow each branch of the pBT to adaptively choose the ordering of the remaining items and this then is the adaptive pBT model. \subsection{Relation to advice and semi-streaming models} \label{max-of-k-becomes} Most inapproximation results for the online and related models we consider allow the algorithm to know $n$, the size of the input. One would like to allow these algorithms to also know other easily computed information about the input (e.g. maximum or minimum degree of a node, etc.) In keeping with the information theoretic nature of inapproximation results, one way to state this is to allow these algorithms to use any small (e.g. $O(\log n)$) bits of advice and not require that the advice be efficiently computed. The {\it online with advice model} \cite{Bock11, EmekFKR11} that is related to our width models allows the algorithm to access a (say) binary advice string initially given to it by an oracle that knows the whole input and has unlimited computational power. Clearly, the advice string could encode the optimal strategy for the algorithm on the input, so the idea is to understand how the performance of the algorithm changes depending on how many bits of advice it uses. A non-uniform algorithm is a set of algorithms, one for each value of $n$. In particular, a non-uniform algorithm knows $n$, the size of the input. The following simple observation shows that the non-uniform advice and max-of-$k$ models are equivalent. \begin{lemma}\label{WidthAdvice} Suppose that an online algorithm knows $n$, the size of the input. Then there is an algorithm using $b(n)$ advice achieving an approximation ratio of $c$ if and only if there is a max-of-$2^{b(n)}$ algorithm with approximation ratio $c$. \end{lemma} \begin{proof} Let $\mathbb{A}$ be an online advice algorithm using advice of size $t$ and achieving a $c$ approximation ratio. The following max-of-$2^t$ algorithm achieves this ratio: try all possible advice strings of length $t$, and take the best option among these. If $\mathbb{M}$ is a max-of-$2^t$ algorithm with approximation ratio $c$, then there is a $t$ bit advice algorithm that, for each input, encodes the best choice among the $2^t$ that will achieve this approximation ratio. \end{proof} The online advice model and therefore the small width online model also has a weak relation with the graph semi-streaming graph, a model suggested by Muthukrishhan \cite{Muthukrishnan05} and studied futher in Feigenbaum et al \cite{FeigenbaumKMSZ}. In that model, {\it edges} arrive online for a graph optimization problem (e.g. matching). More directly related to our models, Goel et al \cite{GoelKK12} consider the model where vertices arrive online. In either case, letting $n$ be the number of vertice, the algorithm is constrained to use ${\tilde O}(n) = n \log^{O(1)}n$ space which can be substantially less space than the number of edges. The online advice and semi-streaming models are not directly comparable since on the one hand semi-streaming algorithms are not forced to make irrevcable decisions, while online algorithms are not space constrained. In order to relate the online model to the semi-streaming model, we need to restrict the online model to those algorithms in which the computation satisifies the ${\tilde O}(n)$ semi-streaming space bound. In particular, the algorithm cannot store all the information contained in the data items that have been considered in previous iterations. \subsubsection{Priority model} The difference between the priority and online models is that in the priority model the algorithm has some power over the order in which data items arrive. Every time a new data item is about to arrive, an ordering on the universe of potential data items is used to decide which one arrives. This ordering is do not impose any restrictions on how this order is produced (but since it is produced by the algorithm, it cannot depend on data items from the current instance that it has not yet seen). In particular, the ordering need not be computable. In the {\it fixed priority model}, the algorithm only provides one ordering at the beginning. For a given instance, the data items are shown to the algorithm according to this ordering (and as before, when one arrives, the algorithm must make a decision regarding the data item). \medskip \noindent\fbox \begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax} \begin{algorithmic}[1] \Statex \textbf{Fixed Priority Algorithm} \State The algorithm specifies an ordering $\pi: U \rightarrow \mathbb{R}$, where $U$ is the universe of all possible data items. \State On instance $I$, the data items are ordered $d_1, \ldots, d_n$ so that $\pi(d_1) \leq \pi(d_2) \leq \ldots \leq \pi(d_n)$. \State $i:=1$ \State \textbf{While} there are unprocessed data items \State The algorithm receives $d_i$ and makes a decision for $d_i$ \Statex (based on $d_i$ and all previously seen data items and decisions). \State $i:= i+1$ \State \textbf{EndWhile} \end{algorithmic} \end{minipage } \medskip In the {\it adaptive priority model}, the algorithm provides a new ordering every time a data item is about to arrive. Thus, in the fixed order model, the priority of each item is a (say) real valued function of the input item and in the adaptive order model, the priority function can also depend on all previous items and decisions. In the matching problem, an algorithm could for example choose an ordering $\pi$ so that data items corresponding to low degree vertices are preferred. Or it could choose $\pi$ to prefer data items corresponding to vertices that are neighbours of some specific vertex. Unless otherwise stated, when we say priority we mean adaptive priority. The following shows the template for adaptive priority algorithms: \medskip \noindent\fbox \begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax} \begin{algorithmic}[1] \Statex \textbf{Adaptive Priority Algorithm} \State On instance $I$, initialize $D$ as the set of data items corresponding to $I$ and $U$ as the universe of all data items. Let $n := |D|$. \State $i:=1$ \State \textbf{While} there are unprocessed data items \State The algorithm specifies an ordering $\pi: U \rightarrow \mathbb{R}$. \State Let $d_{i} := \operatorname{argmin}_{d \in D}(\pi(d))$. \State The algorithm receives $d_{i}$ and makes a decision about it. \State Update: $D \leftarrow D \setminus \{d_{i}\}$, $U\leftarrow \{\mbox{data items consistent with }d_1, \ldots, d_i\}$. \State $i:= i+1$ \State \textbf{EndWhile} \end{algorithmic} \end{minipage } \medskip Usually, the adversarial argument in this model is as follows: the adversary begins by choosing a subset $S$ from the universe of all data items. This will be the set of potential data items for the problem instance. Now, for every $s_1 \in S$, the algorithm could choose this data item as the first one by using an appropriate ordering $\pi$. After the algorithm chooses $s_1$ and makes its decision for this data item, the adversary further shrinks $S$, thus obtaining a smaller subset of potential data items. The algorithm then proceeds by choosing a second data item $s_2 \in S$ and makes a decision concerning it. After this the adversary further shrinks $S$, and this goes on until $S$ becomes empty. In some adversarial instances, some data items may be indistinguishable to the algorithm. If $d$ and $d'$ are indistinguishable to the algorithm, the algorithm may produce an ordering $\pi$ to try to receive $d$, but the adversary can force $d'$ to be received instead. For instance, in the matching problem, in the beginning data items corresponding to vertices with the same degree will be indistinguishable. If the algorithm tries to produce an ordering $\pi$ to get the data item of a specific vertex, the adversary can rename vertices so that the algorithm receives the data item of some other vertex with the same degree. However, after the first vertex has been seen, the algorithm now does have some limited information about the names of other nodes and can possibly exploit this knowledge as we will see in Section \ref{subsec:randomized-priority}. In the most common model for general graph matching, a data item consists of a vertex name along with its neighbours. Here, every vertex has an associated data item. This contrasts with the common data item for online bipartite matching, where only the online side vertices have associated data items. We call the former model (restricted to instances that are bipartite) two-sided bipartite matching, and the latter one-sided. We shall restrict attention to the one-sided problem. \subsubsection{The random order model} In the random order model, usually abbreviated by ROM, neither the algorithm nor the adversary chooses the order in which the data items are presented. Instead, given an input set chosen by an adversary, a permutation of the data items is chosen uniformly at random and this permutation dictates the order in which data items are presented. Once the random input permutation has been instantiated, the model is the same as the one-sided online model. \begin{defn} Let $\mathbb{A}$ be an online algorithm for a problem whose set of all possible instances is ${\cal I}$. For an instance $I$ of size $n$ and a permutation $\sigma \in S_n$, let $I(\sigma)$ be $I$ with data items presented in the order dictated by $\sigma$. Let $v(\mathbb{A}, I(\sigma))$ be the value achieved by the algorithm on $I(\sigma)$, and let $v(I)$ be the optimal value for $I$. The approximation ratio of $\mathbb{A}$ in ROM is: \[ \inf_{I \in {\cal I}} \frac{\mathbb{E}_{\sigma \in S_n}[v(\mathbb{A},I(\sigma))]}{v(I)}\] Let ${\cal I}_n$ be the set of instances of size $n$. Then the asymptotic approximation ratio of $\mathbb{A}$ in ROM is: \[ \liminf_{n \in \mathbb{N}} \inf_{I \in {\cal I}_n} \frac{\mathbb{E}_{\sigma \in S_n}[v(\mathbb{A},I(\sigma))]}{v(I)} \] \end{defn} \section{Related work} \label{sec:related} The analysis of online algorithms in terms of the competitive ratio was explicitly begun by Sleator and Tarjan \cite{SleatorT85} although there were some previous papers that implictly were doing competitive analysis (e.g. Yao \cite{Yao80}). The max-of-$k$ online width model was introduced in Halld\'orsson et al \cite{Iwama2000} and Iwama and Taketomi \cite{Iwama2002} where they considered the the maximum independent set and knapsack problems. Buchbinder and Feldman showed a deterministic algorithm with approximation ratio $1/2$ for unconstrained submodular maximization which fits the online width model (but not the max-of-$k$ model) \cite{Buchbinder2016}. Their initial approach involved solving an LP at each step. They showed how to simplify the algorithm so that it does not require an LP solver, and the width used is linear. Hopcroft and Karp \cite{HopcroftK73} showed that unweighted bipartite matching can be optimally solved offline in time $O(m \sqrt{n})$. For sparse graphs, the first improvement in 40 years is the ${\tilde O}(m^{\frac{10}{7}})$ time algorithm due to Madry \cite{Madry13}. With regard to the online setting, the seminal paper of Karp, Vazirani and Vazirani \cite{Karp1990a} established a number of surprising results for (one-sided) online bipartite matching. After observing that no online deterministic algorithm can do better than a $\frac{1}{2}$ approximation, they studied randomized algorithms. In particular they showed that the natural randomized algorithm RANDOM (that matches an online vertex uniformly at random to an available offline vertex) only achieved an asymptotic approximation ratio of $\frac{1}{2}$; that is, the same approximation as any greedy maximal matching algorithm. They then showed that their randomized RANKING algorithm achieved \footnote{It was later discoved \cite{GoelM08} (and independently by Krohn and Varadarajan) that there was an error in the KVV analysis. A correct proof was prodvided in \cite{GoelM08} and subsequently alternative proofs \cite{Birnbaum2008,Devanur2013a} have been provided.} ratio $1-\frac{1}{e} \approx .632$. RANKING initially chooses a permutation of the offline vertices and uses that permutation to determine how to match an online vertex upon arrival. By deterministically fixing any permutation of the offline vertices, the Ranking algorithm can be interpreted as a deterministic algorithm in the ROM model. While Ranking is optimal as an online randomized algorithm, it is not known if its interpretation as a deterministic ROM algorithm is optimal for all online deterministic algorithms. Goel and Mehta \cite{GoelM08} show that no deterministic ROM algorithm can achieve an approximation better than $\frac{3}{4}$. The KVV algorithm can also be implemented as a $O(n \log n)$ space randomized semi-streaming algorithm whereas Goel el al \cite{GoelKK12} show that there is a determinstic semi-streaming algorithm using only $O(n)$ space provably establishing the power of the semi-streaming model. In the ROM model, the randomized Ranking algorithm achieves an approximation ratio of at least $0.696 > 1-1/e$ \cite{Karande2011, Mahdian2011a} and at most $0.727$ \cite{Karande2011}. Following the KVV paper there have been a number of extensions of online bipartite matching with more direct application to online advertising (see, for example, \cite{Mehta2005, GoelM08, Aggarwal, Kesselheim2013a}), and has also been studied in various stochastic models where the input graph is generated by sampling i.i.d from a known or unknown distribution of online vertices (see \cite{Feldman2009a, Bahmani2010, Manshadi2011, Jaillet, Karande2011}). Manshadi et al \cite{Manshadi2011} showed that no randomized ROM algorithm can achieve an asymptotic approximation ratio better than $0.823$ by establishing that inapproximation for the stochastic unknown i.i.d model. In the online with advice model for bipartite matching, D{\"{u}}rr et al \cite{Durr2016a} apply the B\"{o}ckenhauer et al de-randomization idea to show that for every $\epsilon >0$, there is an ({\it inefficient}) $O(\log n)$ advice algorithm achieving ratio $(1-\epsilon)(1-\frac{1}{e})$. This is complemented by Mikkleson's \cite{Mikkelsen15} recent result showing that no online (even randomized) algorithm using sublinear $o(n)$ advice can asymptotically improve upon the $1- \frac{1}{e}$ ratio achieved by KVV. Furthermore, D{\"{u}}rr et al show that $O(\frac{1}{\epsilon^5} n) $ advice is sufficient, and $\Omega(\log(\frac{1}{\epsilon}) n$ advice is necessary to achieve a $(1-\epsilon)$ ratio. They show that for a natural but restricted class of algorithms, $\Omega(\log \log \log n)$ advice bits are needed for deterministic algorithms to obtain an approximation ratio asymptotically better than $1/2$. Finally, their Category-Advice algorithm is a deterministic two pass online (i.e. adversarial order) $\frac{3}{5}$ approximation algorithm where the first pass is used to give priority in the second pass to the offline vertices that were unmatched in the first pass. That is, the first pass is efficiently constructing an $n$ bit advice string for the second pass. The priority setting was introduced by Borodin et al \cite{Borodin2003}. It has been studied for problems such as makespan scheduling \cite{Angelopoulos2010a}, and also in several graph optimization problems \cite{Borodin2010a, Davis2009}. In terms of the maximum matching problem, most results are about general graph matching. Here, a data item consists of a vertex (the vertex that needs to be matched) along with a list of its neighbours. Aronson et al \cite{Aronson95} showed that the algorithm which at each step chooses a random vertex and then a random neighbour (to pick an edge to add to the matching) achieves an approximation ratio of $1/2+c$ for some $c>0$. Besser and Poloczek \cite{Besser2015} showed that MinGreedy, the algorithm that at each step picks an edge with a vertex of minimum degree, will not get an approximation ratio better than $1/2$ (even in the bipartite case), but for $d$-regular graphs this approximation ratio improves to $\frac{d-1}{2d-3}$. They showed that no deterministic greedy (adaptive) priority algorithm can beat this ratio for graphs of maximum degree $d$ (which implies that these cannot get an approximation ratio greater than $1/2$), and they showed no deterministic priority algorithm can get an approximation ratio greater than $2/3$ ($5/6$ for ``degree based'' randomized algorithms). It should be noted that these inapproximability results for priority algorithms do not hold for the special bipartite case. H\'astad \cite{Hastad01} showed that it is NP-hard to achieve an approximation ratio of $c$ for the maximum satisfiability problem for any constant $c > 7/8$, and the best known efficient algorithm has an approximation ratio of 0.797 and a conjectured approximation ratio of 0.843 \cite{Avidor2005}. The greedy algorithm that at each step assigns a variable to satisfy the set of clauses with larger weight is an online algorithm achieving an approximation ratio of $1/2$. Azar et al \cite{Azar2011a} observed that this is optimal for deterministic algorithms with input model 0. They showed a randomized greedy algorithm that achieves an approximation ratio of $2/3$ for online submodular max-sat, and they showed that this is optimal for input model 0. In this algorithm, when a variable arrives, the variable is set to true with probability $\frac{w_T}{w_T + w_F}$ and set to false otherwise, where $w_T$ is the weight of clauses satisfied if assigned to true and $w_F$ is the weight of clauses satisfied if assigned to false. For submodular max-sat, the weight is replaced by the marginal gain. Johnson's algorithm \cite{Johnson} is a deterministic greedy algorithm that bases its decisions on the ``measure of clauses'' satisfied instead of the weights of these clauses. Yanakakis \cite{Yann} showed that Johnson's algorithm is the de-randomization (by the method of conditional expectations) of the naive randomized algorithm and also showed that no deterministic algorithm can achieve a better approximation ratio even in input model 3. Chen et al \cite{Chen1999a} showed that Johnson's algorithm achieves this $2/3$ approximation ratio. The analysis was later simplified by Engebretsen \cite{Engebretsen2004a}. Johnson's algorithm can be implemented in input model 1. Costello et al \cite{Costello2011} showed that Johnson's algorithm achieves an approximation ratio of $2/3+c$ for some $c>0$ in ROM. Poloczek and Schnitger gave an online randomized algorithm in input model 1 achieving an approximation ratio of $3/4$ \cite{Poloczek2011c}. They showed that Johnson's algorithm in ROM gets an approximation ratio of at most $2-\sqrt{15} < 3/4$, and they showed that the online randomized version of Johnson's algorithm (which assigns probabilities according to measures, as in the randomized greedy algorithm) achieves an approximation ratio of at most $17/23 < 3/4$. Van Zuylen gave a simpler online randomized algorithm \cite{VanZuylen} with approximation ratio $3/4$. Buchbinder et al \cite{Buchbinder2012} gave a randomized algorithm for unconstrained submodular maximization with approximation ratio $1/2$ and additionally a related randomized algorithm for submodular max-sat achieving an approximation ratio of $3/4$. Poloczek \cite{Poloczek2011b} showed that no deterministic adaptive priority for max-sat can achieve an approximation ratio greater than $\frac{\sqrt{33}+3}{12} < 3/4$ in input model 2. He also showed that, under this input model, no randomized online algorithm can get an approximation ratio better than $3/4$, so several algorithms achieving an approximation ratio of $3/4$ that fit the framework are optimal (up to lower order terms). Yung \cite{YungPMS} showed that no deterministic priority algorithm for max-sat in input model 3 can achieve an approximation ratio better than $5/6$. By extending the online framework, Poloczek et al \cite{Polo2pass} proposed a deterministic algorithm achieving a $3/4$ approximation ratio that makes two passes over the input: in one pass, the algorithm computes some probabilities for each variable, and in the second pass, it uses these probabilities and the method of conditional expectations to assign variables. A model for priority width-and-cut was presented and studied by Alekhnovich et al \cite{Alekhnovich2011a}. In particular, they showed that deterministic fixed priority algorithms require exponential width to achieve an approximation ratio greater than $21/22$ for max-sat in input model 3. \section{Max-sat width results} \label{sec:max-sat} We will first show that the Buchbinder and Feldman \cite{Buchbinder2016} de-randomization approach can be utillizeid to obtain a $\frac{3}{4}$ approximation by a parallel online algorithm of width $2n$. Then we will show that with respect to what we are calling input model 2, that we would need exponential width to improve upon this approximation. Then we will propose a width 2 algotithm as a plausible candidate to exceed Johnson's online $\frac{2}{3}$ approximation. \subsection{Derandomizing the Buchbinder et al submodular max-sat algorithm} Buchbinder et al \cite{Buchbinder2012} presented a randomized algorithm for submodular max-sat with an approximation ratio of $3/4$. They define a \emph{loose assignment} of a set of variables $V$ as a set $A \subseteq V \times \{0,1\}$. Any variable can be assigned one truth value (0 or 1), none, or both. A clause is satisfied by $A$ if $A$ contains at least one of the literals in the clause. For instance, $V \times \{0,1\}$ will satisfy any clause and $\emptyset$ will satisfy no clause. Let $F$ be the normalized monotone submodular function on sets of clauses (this is part of the input to the problem) and let $g: \mathcal P \left( V \times \{0,1\} \right) \rightarrow \mathbb{R}$ be the function defined by $g(A) = F(C)$ where $C$ is the set of clauses satisfied by the loose assignment $A$. It is easy to check that $g$ is also a monotone submodular function. The algorithm keeps track of a pair of loose assignments $(X,Y)$, which change every time a new variable is processed. Let $(X_i,Y_i)$ be the values right after the $i$th variable $v_i$ is processed. Initially the algorithm begins by setting $X_0 = \emptyset$ and $Y_0 = V \times \{0,1\}$. When processing $v_i$, $X_i$ will be $X_{i-1}$ plus an assignment $b$ to $v_i$, while $Y_{i}$ will be $Y_{i-1}$ minus the $1-b$ assignment to $v_i$. We say in this case that $v_i$ is assigned to $b$. Thus $X_i$ and $Y_i$ have the same unique assignment for the first $i$ variables, $X_i$ only contains assignments for the first $i$ variables, and $Y_i$ contains all possible assignments for the variables after $v_i$. If there are $n$ variables, $X_n = Y_n$ is a proper assignment, and this is the output of the algorithm. When processing $v_i$, the algorithm makes a random decision based on the marginal gains of assigning $v_i$ to 0 and of assigning $v_i$ to 1. The value $g(X_{i-1} \cup \{(v_i,0)\}) - g(X_{i-1})$ is how much is gained by assigning $v_i$ to $0$, while $g(Y_{i-1}) - g(Y_{i-1} \setminus \{(v_i,1)\})$ is how much is surely lost by assigning $v_i$ to $0$. Thus, the quantity $f_i := g(X_{i-1} \cup \{(v_i,0)\}) - g(X_{i-1}) + g(Y_{i-1} \setminus \{(v_i,1)\}) - g(Y_{i-1})$ is a value measuring how favourable it is to assign $v_i$ to 0. Similarly, $t_i :=g(X_{i-1} \cup \{(v_i,1)\}) - g(X_{i-1}) + g(Y_{i-1} \setminus \{(v_i,0)\}) - g(Y_{i-1})$ measures how favourable the assignment of $v_i$ to 1 is. In the algorithm presented in \cite{Buchbinder2012}, $v_i$ is assigned to 0 with probability $\frac{f_i}{f_i + t_i}$ and to 1 with probability $\frac{t_i}{f_i + t_i}$ (with some care to avoid negative probabilities). We now de-randomize this algorithm at the cost of having linear width. The de-randomization idea follows along the same lines as that of Buchbinder and Feldman \cite{Buchbinder2016} for a deterministic algorithm for unconstrained submodular maximization with a $1/2$ approximation ratio. The authors present the novel idea of keeping a distribution of polynomial support over the states of the randomized algorithm. Normally, a randomized algorithm has a distribution of exponential support, so the idea is to carefully choose the states that are kept with nonzero probability. Elements of the domain (or in our case, variables) are processed one at a time, and at each iteration a linear program is used to determine the changes to the distribution. They then argue that they can get rid of the LP's to obtain an efficient algorithm, since solving them reduces to a fractional knapsack problem. The same LP format used for unconstrained submodular maximization works for submodular maxsat (the only change in the linear program in our algorithm below are the coefficients), so the idea in \cite{Buchbinder2016} to get rid of the LP solving also works for our algorithm. \begin{theorem}\label{submodularMS} There is a linear-width double-sided online algorithm for submodular max-sat achieving an approximation ratio of $3/4$. The algorithm uses input model 1 of max- sat. \end{theorem} \begin{proof} First, we note that an oracle for $F$ suffices for constructing an oracle for $g$. The algorithm keeps track of a distribution over pairs $(X,Y)$ of loose assignments of variables. A double-sided algorithm is needed to obtain the values of the $g(Y)$'s. The idea is to process the variables online, at each step changing the distribution. The pairs $(X,Y)$ satisfy the same properties as in the Buchbinder et al algorithm. Thus, $X$ corresponds to the assignments made in the partial solution so far, while $Y$ corresponds to this plus the set of potential assignments that the partial solution could still make. When all variables are processed, the support will contain proper assignments of variables, and the algorithm takes the best one. The distribution is constructed by using an LP (without an objective function) to ensure some inequalities hold while not increasing the support by too much. We use the notation $(p,X,Y) \in D$ to say the distribution $D$ assigns $(X,Y)$ probability $p$. Also, if $(X,Y) \in supp(D_{i-1})$, we use the notation $Pr_{D_{i-1}}[X,Y]$ to denote the probability of the pair $(X,Y)$ under distribution $D_{i-1}$. The variables are labelled $V = \{v_1, \ldots, v_n\}$ in the online order. See Algorithm~\ref{Submodular max-sat algorithm}. \begin{algorithm}[!h]\caption{Submodular Max Sat}\label{Submodular max-sat algorithm} \begin{algorithmic}[1] \State Let $D_0 = \{(1, \emptyset, V \times \{0,1\} )\}$ \For{$i=1$ to $n$} \State $\forall (X,Y) \in supp(D_{i-1})$ let \begin{eqnarray*} f_i(X,Y) &=& g(X \cup \{(v_i,0)\}) - g(X) + g(Y \setminus \{(v_i,1)\}) - g(Y)\\ t_i(X,Y) &=& g(X \cup \{(v_i,1)\}) - g(X) + g(Y \setminus \{(v_i,0)\}) - g(Y)\\ \end{eqnarray*} \State Obtain an extreme point solution for: \begin{eqnarray} \label{ineq1}\mathrm{E}_{D_{i-1}}[z(X,Y) f_i(X,Y) + w(X,Y) t_i(X,Y)] &\geq & 2\mathrm{E}_{D_{i-1}}[z(X,Y) t_i(X,Y)]\\ \label{ineq2}\mathrm{E}_{D_{i-1}}[z(X,Y) f_i(X,Y) + w(X,Y) t_i(X,Y)] &\geq & 2\mathrm{E}_{D_{i-1}}[w(X,Y) f_i(X,Y)]\\ z(X,Y) + w(X,Y) &=& 1 \mbox{ }\forall (X,Y) \in supp(D_{i-1})\label{probabilitieseq1}\\ z(X,Y), w(X,Y) & \geq & 0 \mbox{ }\forall (X,Y) \in supp(D_{i-1})\label{ineq3} \end{eqnarray} \State Construct a new distribution: \begin{eqnarray*} D_i =& \{(z(X,Y) Pr_{D_{i-1}}[X,Y], X \cup \{(v_i,0)\}, Y \setminus \{(v_i, 1)\}): (X,Y) \in supp(D_{i-1}) \} \\ & \cup \{(w(X,Y) Pr_{D_{i-1}}[X,Y], X \cup \{(v_i,1)\}, Y \setminus \{(v_i, 0)\}): (X,Y) \in supp(D_{i-1}) \} \end{eqnarray*} \State\label{DelLA} Delete from $D_i$ any pair of loose assignments with zero probability. \EndFor\\ \Return argmax$_{(X,Y) \in supp_{D_n}}\{g(X)\}$ \end{algorithmic} \end{algorithm} As before, $f_i(X,Y)$ is used to determine how profitable it is to assign $v_i$ to 0 in this pair, and similarly $t_i(X,Y)$ measures how profitable it is to assign $v_i$ to 1 in this pair. In normal max-sat, $f_i(X,Y)$ will be the weights of clauses satisfied by assigning $v_i$ to 0 minus the weights of clauses that become unsatisfied by this assignment (a clause becomes unsatisfied when it hasn't been satisfied and all of its variables have been assigned), and $t_i(X,Y)$ is the analogue for the assignment to 1. Each $(X,Y) \in supp(D_{i-1})$ will potentially be split into two in $D_i$: $(X \cup \{(v_i,0)\}, Y \setminus \{(v_i, 1)\})$, corresponding to assigning $v_i$ to 0 in pair $(X,Y)$, and $(X \cup \{(v_i,1)\}, Y \setminus \{(v_i, 0)\})$, corresponding to assigning $v_i$ to 1 in pair $(X,Y)$. $z(X,Y)$ is the probability of assigning $v_i$ to 0, given $(X,Y)$. Similarly, $w(X,Y)$ is the probability of assigning $v_i$ to 1, given $(X,Y)$. Since at each step $D_i$ could grow twice the size, the LP is used to determine values for $z(X,Y)$, $w(X,Y)$ for all $(X,Y) \in supp(D_{i-1})$ such that the resulting distribution still satisfies the properties used to achieve a good assignment in expectation while forcing many of the variables to be 0. In Step~\ref{DelLA}, the pairs with zero probability are trimmed from $D_i$ to keep the distribution size small. First, note that the distributions are well defined by induction and by inequalities~\ref{probabilitieseq1} and \ref{ineq3} of the LP. Also, $D_n$ contains well-defined assignments (instead of loose assignments), so the algorithm returns a valid assignment. Let $|D_i|$ be the size of the support of $D_i$. Excluding inequalities~\ref{ineq3} stating the non-negativity of variables, there are $|D_{i-1}|+2$ inequalities in the LP for step $i$, so an extreme point solution contains at most that many nonzero variables: $|D_i| \leq |D_{i-1}|+2$. Therefore, $|D_n| \leq 2n+1$ and the algorithm does have linear width. Now, let us see that $t_i(X,Y) + f_i(X,Y) \geq 0$ for any $(X,Y) \in supp(D_{i-1})$. It can be proved by induction that for all $1 \leq i \leq n$ and all $(X,Y) \in supp(D_{i-1})$, $X \subseteq Y \setminus \{(v_i,1), (v_i,0)\}$. Then by submodularity, \[g(X \cup \{(v_i,0)\}) - g(X) \geq g(Y) - g(Y \setminus \{(v_i,0)\})\] \[g(X \cup \{(v_i,1)\}) - g(X) \geq g(Y) - g(Y \setminus \{(v_i,1)\})\] Adding both inequalities, moving all terms to the left side and rearranging, we obtain that $t_i(X,Y) + f_i(X,Y) \geq 0$. We now prove that for every $i$ the LP formed is feasible, which is assumed by the algorithm in order to find an extreme point solution. We give an explicit feasible solution: \[ z(X,Y) = \frac{\max\{0, f_i(X,Y)\}}{\max\{0, f_i(X,Y)\} + \max\{0, t_i(X,Y)\}} \hspace{12pt} w(X,Y) = 1 - z(X,Y)\] In case $t_i(X,Y)=f_i(X,Y)=0$, we take $z(X,Y)=1$ and $w(X,Y)=0$. By definition, equalities~\ref{probabilitieseq1} and inequalities~\ref{ineq3} hold. When $t_i(X,Y)=f_i(X,Y)=0$, the corresponding variables will not contribute to either side of inequalities \ref{ineq1} and \ref{ineq2}. Assume either $t_i(X,Y) \neq 0$ or $f_i(X,Y) \neq 0$ and we want to show inequality~\ref{ineq1} (since the other one will be analogous). Let $D:=\max\{0, f_i(X,Y)\} + \max\{0, t_i(X,Y)\}$. Then we want to show: \[ \mathrm{E}\left[ \frac{\max\{0, f_i(X,Y)\}}{D} f_i(X,Y) + \frac{\max\{0, t_i(X,Y)\}}{D} t_i(X,Y)\right] \geq 2\mathrm{E}\left[\frac{\max\{0, f_i(X,Y)\}}{D} t_i(X,Y)\right] \] Because $D>0$ this is equivalent to \[ \mathrm{E}\left[ \max\{0, f_i(X,Y)\} f_i(X,Y) + \max\{0, t_i(X,Y)\} t_i(X,Y)\right] \geq 2\mathrm{E}\left[\max\{0, f_i(X,Y)\}t_i(X,Y)\right]\] where the expectation is over $D_{i-1}$. For $(X,Y)\in supp(D_{i-1}) $ for which $f_i(X,Y)<0$, we have $t_i(X,Y)>0$ and the inequality becomes $t_i(X,Y)^2 \geq 0$, which clearly holds. Similarly, when $t_i(X,Y)<0$ we must have $f_i(X,Y)>0$ and the inequality becomes $f_i(X,Y)^2 \geq 2f_i(X,Y)t_i(X,Y)$ which is true because the right hand side is negative. Finally, when $f_i(X,Y)\geq 0$ and $t_i(X,Y) \geq 0$, the inequality becomes $f_i(X,Y)^2+t_i(X,Y)^2 \geq 2 f_i(X,Y)t_i(X,Y)$, which is true because $(a-b)^2 = a^2+b^2-2ab \geq 0$. Let $OPT$ be an optimal assignment. For any $1\leq i \leq n$ and $(X,Y) \in supp(D_i)$, let $OPT_i(X,Y) := (OPT \cup X) \cap Y$: it is an assignment that coincides with $X$ and $Y$ in the first $i$ variables and coincides with $OPT$ in the rest. We will now prove the following: \begin{lemma} For $1 \leq i \leq n$: \[\mathrm{E}_{D_{i-1}}[g(OPT_{i-1}(X,Y))] - \mathrm{E}_{D_{i}}[g(OPT_i(X,Y))] \leq \frac{1}{2}\left( E_{D_i}[g(X) + g(Y)] - E_{D_{i-1}}[g(X) + g(Y)]\right)\] \end{lemma} \begin{proof} First suppose that in OPT, $v_i$ is assigned 0. In this case: \begin{eqnarray*} \mathrm{E}_{D_{i-1}}[g(OPT_{i-1}(X,Y))] &-& \mathrm{E}_{D_{i}}[g(OPT_i(X,Y))] = \sum_{(X,Y) \in supp(D_{i-1})} [ Pr_{D_{i-1}}[X,Y] g(OPT_{i-1} (X,Y))\\ & - & z_i(X,Y) Pr_{D_{i-1}}[X,Y] g\left(OPT_i(X \cup \{(v_i, 0)\}, Y \setminus \{(v_i,1)\}) \right)\\ & - & w_i(X,Y) Pr_{D_{i-1}}[X,Y] g\left(OPT_i(X \cup \{(v_i, 1)\}, Y \setminus \{(v_i,0)\}) \right) ]\\ & = & \sum_{(X,Y) \in supp(D_{i-1})} w_i(X,Y) Pr_{D_{i-1}}[X,Y] [g(OPT_{i-1}(X,Y))\\ & - & g\left(OPT_i(X \cup \{(v_i, 1)\}, Y \setminus \{(v_i,0)\}) \right) ] \end{eqnarray*} Here, we use $z_i$ and $w_i$ to emphasize that these are the extreme point solutions obtained at the $i$th LP. The first equality holds by construction of $D_i$. The second holds because $z_i(X,Y) = 1 - w_i(X,Y)$ and because for all $(X,Y) \in supp(D_{i-1})$, $OPT_{i-1}(X,Y) = OPT_i(X \cup \{(v_i, 0)\}, Y \setminus \{(v_i,1)\})$ since $(v_i,0) \in OPT$. If $(X,Y) \in supp(D_{i-1})$, then $X \subseteq OPT_{i-1}(X,Y) \setminus \{(v_i,0)\} \subseteq Y \setminus \{(v_i,1)\}$ and by submodularity: \[g(OPT_{i-1}(X,Y)) - g(OPT_{i-1}(X,Y) \setminus \{(v_i,0)\}) \leq g(X \cup \{(v_i,0)\}) - g(X)\] \[g(Y) - g(Y \setminus \{(v_i,1)\}) \leq g(OPT_{i-1}(X,Y) \setminus \{(v_i,0)\} \cup \{(v_i,1)\}) - g(OPT_{i-1}(X,Y) \setminus \{(v_i,0)\})\] Adding these two inequalities, rearranging, and using the fact that $OPT_{i-1}(X,Y) \setminus \{(v_i,0)\} \cup \{(v_i,1)\} = OPT_i(X \cup \{(v_i, 1)\}, Y \setminus \{(v_i,0)\}) $ we obtain: \begin{eqnarray*} g(OPT_{i-1}(X,Y)) & -& g(OPT_i(X \cup \{(v_i, 1)\}, Y \setminus \{(v_i,0)\})) \\ & \leq & g(X \cup \{(v_i,0)\}) - g(X) - g(Y) + g(Y \setminus \{(v_i,1)\})\\ & = & f_i(X,Y) \end{eqnarray*} Thus, we conclude: \begin{eqnarray*} \mathrm{E}_{D_{i-1}}[g(OPT_{i-1}(X,Y)] &-& \mathrm{E}_{D_{i}}[g(OPT_i(X,Y)]\\ & \leq &\sum_{(X,Y) \in supp(D_{i-1})} w_i(X,Y) Pr_{D_{i-1}}[X,Y] f_i(X,Y)\\ & = & \mathrm{E}_{D_{i-1}} [ w_i(X,Y) f_i(X,Y)] \end{eqnarray*} Analoguously, when $(v_i,1) \in OPT$ we obtain: \[ \mathrm{E}_{D_{i-1}}[g(OPT_{i-1}(X,Y)] - \mathrm{E}_{D_{i}}[g(OPT_i(X,Y)] \leq \mathrm{E}_{D_{i-1}} [ z_i(X,Y) t_i(X,Y)]\] On the other hand, we have: \begin{eqnarray*} \frac{1}{2} ( \mathrm{E}_{D_i} [g(X) &+& g(Y)] - \mathrm{E}_{D_{i-1}} [g(X) + g(Y)] ) = \frac{1}{2} ( \mathrm{E}_{D_{i-1}} [z_i(X,Y) g(X \cup \{(v_i,0)\})\\ & +& w_i(X,Y) g(X \cup \{(v_i,1)\}) + z_i(X,Y) g(Y \setminus \{(v_i,1)\}) + w_i(X,Y) g(Y \setminus \{(v_i,0)\})\\ & -& g(X) - g(Y) ] )\\ & = & \frac{1}{2} ( \mathrm{E}_{D_{i-1}}[ z_i(X,Y)(g(X \cup \{(v_i,0)\}) + g(Y \setminus \{(v_i,1)\}) - g(X) - g(Y))\\ & + & w_i(X,Y)(g(X \cup \{(v_i,1)\}) + g(Y \setminus \{(v_i,0)\}) - g(X) - g(Y))])\\ & = & \frac{1}{2}( \mathrm{E}_{D_{i-1}}[z_i(X,Y)f_i(X,Y) + w_i(X,Y)t_i(X,Y)])\\ & \geq & \max\{ \mathrm{E}_{D_{i-1}} [ w_i(X,Y) f_i(X,Y)], \mathrm{E}_{D_{i-1}} [ z_i(X,Y) t_i(X,Y)]\} \end{eqnarray*} where the first equality is by how $D_i$ is constructed and the last inequality is because of inequalities \ref{ineq1} and \ref{ineq2} from the LP. \end{proof} To conclude the proof of the theorem, we add the inequalities given by the lemma for $1 \leq i \leq n$, obtaining: \[ \mathrm{E}_{D_0}[g(OPT_0(X,Y))] - \mathrm{E}_{D_n}[g(OPT_n(X,Y))] \leq \frac{1}{2}\left( E_{D_n}[g(X) + g(Y)] - E_{D_0}[g(X) + g(Y)]\right) \] Notice that $\mathrm{E}_{D_0}[g(OPT_0(X,Y))] = g(OPT)$, $E_{D_0}[g(X)] = g(\emptyset)$, $E_{D_0}[g(Y)] = g(V \times \{0,1\})$, and for all $(X,Y) \in supp(D_n)$, $X = Y = OPT_n(X,Y)$. Therefore the inequality becomes \[ g(OPT) - \mathrm{E}_{D_n}[g(X)] \leq \frac{1}{2} \left( 2E_{D_n}[g(X)] - g(\emptyset) - g(V \times \{0,1\})\right)\] Therefore, after rearranging we get: \[ \mathrm{E}_{D_n}[g(X)] \geq \frac{1}{2} g(OPT) + \frac{1}{4}[ g(\emptyset) + g(V \times \{0,1\}) ] \geq \frac{3}{4} g(OPT)\] The last inequality follows from the fact that $F$ is normalized (so $g(\emptyset) = 0$) and monotone (so $g(V \times \{0,1\}) \geq g(OPT)$). Calling the algorithm's ouput assignment $A$, we conclude that \[F(A) = g\left(\underset{(X,Y) \in supp_{D_n}}{\operatorname{argmax}} \{g(X)\}\right) \geq \mathrm{E}_{D_n}[g(X)] \geq \frac{3}{4} g(OPT) = \frac{3}{4} F(OPT)\] We note that the LP format is the same as that in \cite{Buchbinder2016}. The only difference with their LP is the coefficients. So their argument that this can be solved by viewing it as a fractional knapsack problem still holds. \end{proof} \subsection{Online width inapproximation bounds for max-2-sat} We now present width impossibility results for max-sat with respect to different input models. The best known efficient algorithm for max-sat has an approximation ratio of 0.797 \cite{Avidor2005}. Recall that Johnson's algorithm for max-sat \cite{Johnson} achieves a $2/3$ approximation ratio \cite{Chen1999a} and only requires the algorithm to know the lengths of the clauses; i.e. input model 1. Even for input model 2, we show in Theorem~\ref{maxsat2i} that exponential width-cut is required to improve upon the $3/4$ approximation ratio achieved by Algorithm~\ref{Submodular max-sat algorithm}, which is a linear width algorithm in input model 1. In Theorem~\ref{maxsat0}, we show that constant width algorithms cannot achieve an approximation ratio of 2/3 in input model 0. This shows that constant width is unable to make up for the power lost if the algorithm does not know the lengths of clauses or if the algorithm is required to be deterministic; we note that the randomized algorithm using probabilities proportional to weights achieves an approximation ratio of $2/3$ \cite{Azar2011a}. Finally, in Theorem ~\ref{maxsat3} we show that, in input model 3, exponential width is required to achieve an approximation ratio greater than $5/6$. Our impossibility results hold even in some special cases of max-sat. In max-$q$-sat, the instance is guaranteed to have clauses of length at most $q$. Exact max-$q$-sat is the case where all clauses are of length exactly $q$. In the following theorem, we show that for input model 2, exponential width-cut cannot achieve a better approximation ratio than that achieved in Theorem~\ref{submodularMS}, even for exact max-2-sat. It should be noted that a $3/4$ approximation ratio is already achieved by the naive randomized algorithm (that sets a variable to $0$ (or $1$) with probability $1/2$) and by its de-randomization, Johnson's algorithm, for exact max-2-sat. We say that a max-of-$k$ algorithm \emph{assigns} (or \emph{sets}) $x$ to $(b_1, b_2, \ldots, b_k) \in \{0,1\}^k$ if it assigns $x$ to $b_1$ in its first assignment, it assigns $x$ to $b_2$ in its second assignment, etc. \begin{theorem}\label{maxsat2i} For any $\epsilon > 0$ there exists $\delta > 0$ such that, for $k<e^{\delta n}$, no online width-cut-$k$ algorithm can achieve an asymptotic approximation ratio of $3/4 + \epsilon$ for unweighted exact max-2-sat with input model 2. \end{theorem} \begin{proof} First, we will show a concrete example where any width-2 algorithm achieves an approximation ratio of at most $3/4$. Then we show a way to extend this to a $3/4+\epsilon$ asymptotic inapproximation with respect to the max-of-$k$ model for $k$ that is exponential in the number of variables. Finally, we briefly argue why this impossibility result will also hold in the more general width-cut-$k$ case. Suppose $k=2$. The adversary begins by showing variable $x_1$: it appears positively in one clause and negatively in another clause, both of length 2. The remaining variable in both clauses is $y$. If the algorithm does not branch or sets the variable $x_1$ to $0$ or to $1$ in both assignments, the adversary can force a $3/4$ approximation ratio as follows. Suppose without loss of generality that in both assignments $x_1$ is assigned $1$. Then the adversary presents the instance: $(x_1 \vee \overline{y}) \wedge (\overline{x_1} \vee y) \wedge (\overline{y} \vee z) \wedge (\overline{y} \vee \overline{z})$. No assignment where $x_1$ is set to 1 can satisfy all clauses, but an assignment where $x_1$ and $y$ are set to $0$ satisfies all clauses. Thus, the algorithm achieves an approximation ratio of at most $3/4$. Therefore the algorithm must set one assignment to $1$ and the other to $0$. We assume that the algorithm sets $x_1$ to $(1,0)$. Now the adversary presents a variable $x_2$, where again there is one clause where it appears positively and one where it appears negatively, both of length 2 and where the remaining variable is $y$. Then there are four cases depending on the decision of the algorithm on $x_2$ (in each case, the whole instance consists of four clauses in total): \begin{tabular}{ l | l l l l } Decision on $x_2$ & $(0,0)$ & $(1,0)$ & $(1,1)$ & $(0,1)$ \\ \hline Clause with $x_1$ & $x_1 \vee \overline{y}$ & $x_1 \vee \overline{y}$ & $x_1 \vee \overline{y}$ & $x_1 \vee y$ \\ Clause with $\overline{x_1}$ & $\overline{x_1} \vee \overline{y}$ & $\overline{x_1} \vee y$ & $\overline{x_1} \vee \overline{y}$ & $\overline{x_1} \vee \overline{y}$ \\ Clause with $x_2$ & $x_2 \vee y$ & $x_2 \vee y$ & $x_2 \vee \overline{y}$ & $x_2 \vee y$ \\ Clause with $\overline{x_2}$ & $\overline{x_2} \vee \overline{y}$ & $\overline{x_2} \vee \overline{y}$ & $\overline{x_2} \vee y$ & $\overline{x_2} \vee \overline{y}$ \\ \end{tabular} In all cases, the algorithm will only be able to satisfy 3 out of the 4 clauses in any of its branches, but the instance is satisfiable, so the inapproximation holds. Now let us show how to extend this idea to max-of-$k$. Let $\epsilon > 0$, take $\delta = 7 \epsilon^2$, so that $k < e^{\delta n} = e^{7 \epsilon^2 n}$. The adversary will present variables $x_1, \ldots, x_{n}$, where each $x_i$ appears in two clauses of length 2 and where the remaining variable is $y$: in one $x_i$ appears positively and in the other negatively. In fact, the two clauses will either represent an equivalence to $y$ (given by $x_i \vee \overline{y}$, $\overline{x_i} \vee y$) or an inequivalence to $y$ (given by $x_i \vee y$, $\overline{x_i} \vee \overline{y}$), but the algorithm does not know which is the case. If an assignment does not satisfy the (in)equivalence correctly, it will get only one of the two clauses (ie $1/2$ of the total). Suppose that the algorithm maintains $k$ assignments, and suppose it makes assignments on $x_1, \ldots, x_{n}$. Then the algorithm can only maintain at most $k$ of the possible $2^{n}$ assignments. For a fixed assignment of $x_1, \ldots, x_{n}$, by Chernoff bounds, the probability that a uniformly random assignment agrees with the fixed one on at least $n/2+2\epsilon n$ variables is at most $e^{-8 \epsilon^2 n}$. Similarly, the probability that it agrees with the fixed assignment on at most $n/2 - 2\epsilon n$ variables is at most $e^{-8 \epsilon^2 n}$. Thus, by union bounds, the probability that any of the two possibilities occurs on any of the $k$ assignments maintained by the algorithm is at most $2ke^{-8 \epsilon^2 n}< e^{-\epsilon^2n +ln2}<1$. So there exists an assignment $A$ that agrees with every assignment maintained by the algorithm on more than $n/2-2\epsilon n$ but less than $n/2+2\epsilon n$ of the variables. The adversary uses this assignment $A$ to determine the signs of $y$ in the clauses, which in turn determines for each $i$ whether $x_i$ is equivalent or inequivalent to $y$. If $A$ assigns $x_i$ to 1, then the adversary says $x_i$ is equivalent to $y$. If $A$ assigns $x_i$ to 0, then the adversary says that $x_i$ is inequivalent to $y$. Clearly, the set of clauses constructed is satisfiable. Fix one of the $k$ assignments maintained by the algorithm. If to complete this assignment the algorithm sets $y$ to 1, the number of (in)equivalences satisfied by the assignment is equal to the number of variables where $A$ and this assignment agree, which is less than $n/2+2\epsilon n$. On the other hand, if to complete the assignment the algorithm sets $y$ to 0, then the number of (in)equivalences satisfied is equal to the number of variables where $A$ and this assignment disagree, which again is less than $n/2+2\epsilon n$. Since an assignment that satisfies $q$ (in)equivalences will satisfy a $\frac{n+q}{2n}$ fraction of the clauses, the approximation ratio achieved by the algorithm is less than $3/4 + \epsilon$. It is easy to see why this result will also hold for width-cut: the only decisions of the adversary that depend on the branching are made when the last variable $y$ is being processed (their signs are determined in each clause by assignment $A$). So the adversary can use the strategy that corresponds to the assignments of the algorithm right before $y$ is presented. Any branching or cutting made when deciding the assignments for $y$ are irrelevant: since it's the last variable, the algorithm should just assign $y$ to maximize the number of satisfied clauses in each assignment. \end{proof} \begin{theorem}\label{maxsat0} For any constant $k$, the asymptotic approximation ratio achieved by any online width-$k$ algorithm for unweighted max-sat with input model 0 is strictly less than $2/3$. \end{theorem} \begin{proof} We start by giving a max-of-$k$ inapproximation result, which is then easily extended to width. It should be noted that for this result we need to allow the adversary's final instance to contain repeated equal clauses. First consider the case $k=2$. The adversary presents a variable $x_1$. There are two clauses where it appears positively and two where it appears negatively. Without loss of generality, there are two options: both assignments set $x_1$ to 1 or the first sets $x_1$ to 1 and the second sets $x_1$ to 0. In the former case, the adversary proceeds to say that the clauses containing $\overline{x_1}$ were of length one but the clauses containing $x_1$ had an additional variable $y$, which means both assignments satisfy half of the clauses. In the latter case, the adversary now presents variable $y_1$. It appears positively in one of the clauses where $\overline{x_1}$ appears and it appears negatively in the other clause where $\overline{x_1}$ appears. The value the second assignment gives to this variable is irrelevant since it already satisfied these clauses. Without loss of generality, assume the first assignment sets it to 1. Then the adversary presents a variable $z_1$, which occurs only positively in the clause where $y_1$ appears positively. Thus the values both assignments give to this variable are irrelevant. The first assignment satisfied three of the four clauses while the second only satisfied two of them. There is an optimal solution satisfying all four: set $x_1$ to 1, $y_1$ to 0, $z_1$ to 1. Now, the adversary repeats this process, but reversing the roles of the two assignments so that now the first assignment only gets two out of four clauses and the second gets three. Adding up, both assignments get five out of the eight clauses and the optimal value is 8, so we get a $5/8$ inapproximation. For the general (but constant) $k$ case, we proceed by induction to prove that there is an adversary giving an inapproximation ratio strictly less than $2/3$. Recall that online maxsat ($k=1$) in this model cannot get an approximation ratio better than $1/2$ \cite{Azar2011a} (it is easy to extend this to an asymptotic inapproximation). Suppose there is an adversarial strategy for $i<k$. We now present a strategy for max-of-$k$. The adversary begins by presenting many variables $v_1, v_2, \ldots, v_n$, each of which will have many clauses where it appears positively and the same number of clauses where it appears negatively. For each $1 \leq i \neq j \leq n$, the clauses where $v_i$ and $v_j$ appear are disjoint. These will be all of the clauses of the instance: the adversary will not present any new clauses later on. It will only present additional variables contained within these clauses. After decisions are made there will be $k$ assignments, each assigning a value $0$ or $1$ to each of the variables. For every $S \in \{0,1\}^k$, the adversary will recursively apply its strategies for max-of-$i$ (for values $i<k$) to $V_S$, the set of variables from $v_1, v_2, \ldots, v_n$ assigned to $S$, and to the clauses where variables in $V_S$ appear. More precisely, let $\mathbb{A}_j$ be the adversary for max-of-$j$. Then $\mathbb{A}_k$ will simulate $\mathbb{A}_i$ by ignoring some of the assignments (since now it can only consider $i$ of them). Variables created by $\mathbb{A}_i$ will be new variables. When $\mathbb{A}_i$ creates new clauses, $\mathbb{A}_k$ uses some of the clauses where variables in $V_S$ appear instead of creating new ones. If $S=(1,\ldots,1)$, for these variables the adversary says that the clauses where they appear positively have length two and include a new variable $y$ but the clauses where they appear negatively have length one. Thus the algorithm can only satisfy $1/2$ of these clauses but the set of clauses is satisfiable. The response is analogous if $S=(0,\ldots,0)$. Now suppose that $S = (s_1, \ldots, s_k)$ contains $t$ 1's and $k-t$ 0's, for some for $0<t<k$. Let $S_1 := \{1 \leq j \leq k | s_j = 1\}$ and let $S_0:= \{1 \leq j \leq k | s_j = 0\}$, so $|S_1| = t$ and $|S_2| = k-t$. The adversary will roughly split $V_S$ into two parts, one $V_S^1$ of size $w|V_S|$ and the other $V_S^2$ of size $(1-w)|V_S|$, for a $w$ to be determined. In the first part, the adversary will say that the positive clauses (where variables in $V_S^1$ appear positively) were of length one, and it will simulate $\mathbb{A}_t$ using the negative clauses, so the decisions made on the $k-t$ assignments indexed by $S_0$ don't matter and the adversary only considers the decisions of the algorithm on the $t$ assignments indexed by $S_1$. In the second part, the adversary will say that negative clauses were of length one, and will simulate $\mathbb{A}_{k-t}$ using the positive clauses and considering only the $k-t$ assignments indexed by $S_0$. See Table~\ref{VS12Example} for an example. Let $r_1$ be the inapproximation ratio for max-of-$t$ and let $r_2$ be the inapproximation ratio for max-of-$(k-t)$. Let $a = (1+r_1)/2$ and $b=(1+r_2)/2$. Then the proportion of clauses satisfied by assignments indexed by $S_1$ is at most $aw + 1/2(1-w)$ and the proportion of clauses satisfied by assignments indexed by $S_0$ is at most $1/2w + b(1-w)$. We select $w$ to minimize the maximum between these two amounts, by equating these values: \[aw + \frac{1}{2}(1-w) = \frac{1}{2}w + b(1-w) \] We solve this equation, obtaining \[w = \frac{b-\frac{1}{2}}{a+b-1}\] Plugging back in into the equality and considering there is an optimal assignment satisfying all clauses, we obtain an inapproximation ratio of \[\frac{2ab - \frac{1}{2}}{2(a+b-1)}\] \begin{table}[!h] \begin{tabular}{ l l l | l l l } $V_S^1$ & & & $V_S^2$ & &\\ \hline & $v_1$ & Clause of length 1 & & $v_4$ & Used to simulate $\mathbb{A}_{k-t}$\\ & $v_2$ & Clause of length 1 & & $v_5$ & Used to simulate $\mathbb{A}_{k-t}$\\ & $v_3$ & Clause of length 1 & & $v_6$ & Used to simulate $\mathbb{A}_{k-t}$\\ & $\overline{v_1}$ & Used to simulate $\mathbb{A}_t$ & & $\overline{v_4}$ & Clause of length 1\\ & $\overline{v_2}$ & Used to simulate $\mathbb{A}_t$ & & $\overline{v_5}$ & Clause of length 1\\ & $\overline{v_3}$ & Used to simulate $\mathbb{A}_t$ & & $\overline{v_6}$ & Clause of length 1 \end{tabular} \caption{Example where $V_S$ consists of 6 variables, 3 in $V_S^1$ and 3 in $V_S^2$.} \label{VS12Example} \end{table} Now, recall $r_1$, $r_2$ are inapproximation ratios for max-of-$k'$ for $k'<k$, so by the induction hypothesis $1/2 \leq r_1, r_2 < 2/3$, which implies $3/4 \leq a,b < 5/6$. Given these parameters, it can be shown that the above ratio gets a value strictly less than $2/3$. Since all ratios are less than $2/3$ regardless of $S$, the inapproximation obtained overall is less than $2/3$. Notice that we assume that we can neglect the gain obtained when $|V_S|$ is not large enough to apply the recursive strategy (hence the number of initial variables $n$ has to be large) and in addition we are assuming we can at least approximate $w$ accurately (hence the number of clauses per $v_i$ has to be large). To extend this result to width $k$, we can begin by assuming that $k'=1$ where $k'$ is the maximum number of assignments the algorithm keeps. We start by applying the adversary for max-of-$k'$. If the adversary finishes before the algorithm does any splitting then we are done. Otherwise the algorithm splits to now maintain $k'' > k'$ assignments and we apply the adversary for max-of-$k''$, but using many more clauses so that we ensure that the clauses used by previous adversaries will be negligible when calculating the approximation ratio. \end{proof} \begin{theorem}\label{maxsat3} For any $\epsilon > 0$ there exists $\delta > 0$ such that, for $k<e^{\delta n}$, no online width-cut-$k$ algorithm can achieve an asymptotic approximation ratio of $5/6 + \epsilon$ for unweighted max-2-sat with input model 3. \end{theorem} \begin{proof} We use an argument similar to the one in Theorem~\ref{maxsat2i}, but with a different clause construction. Given $\epsilon >0$, let $\delta = 144 \epsilon^2$ so that $k < e^{\delta n} = e^{144 \epsilon^2 n}$. The instance will contain variables $x_1, \ldots, x_{n/2}$ and $y_1, \ldots, y_{n/2}$. The clauses will be $x_i \vee \overline{y_i}$, $\overline{x_i} \vee y_i$, and either $y_i$ or $\overline{y_i}$. The first two clauses are satisfied if and only if $x_i = y_i$. The last clause determines whether $y_i$ should be assigned to 0 or 1. Any such set of clauses will be satisfiable. The adversary presents the $x_i$'s, and the width-cut algorithm produces at most $k$ assignments of these variables. For a fixed assignment of the $\frac{n}{2}$ $x_i$'s, the probability that a uniformly random assignment agrees with the fixed one on more than $n/4+6\epsilon n$ of the variables is at most $e^{-144 \epsilon^2 n}$. Therefore, there exists an assignment $A$ that agrees with each of the assignments maintained by the algorithm on at most $ n/4+6\epsilon n$ variables. The adversary now presents the $y_i$'s. It chooses to include clause $y_i$ in the instance if $x_i$ is set to 0 in assignment $A$, and it includes $\overline{y_i}$ if $x_i$ is set to 1.. Whenever an assignment does not agree with $A$ on $x_i$, it will satisfy at most two of the three clauses where $y_i$ appears in. Therefore, no assignment can satisfy more than a $\frac{1(1/4 + 6\epsilon) + 2/3(1/2 - (1/4 + 6\epsilon)))}{1/2} = 5/6 + \epsilon$ fraction of the clauses. \end{proof} \subsection{Candidate for a width 2 approximation algorithm} Now we present a max-of-2 algorithm for max-sat. We were unable to prove impossibility results saying max-of-$k$ algorithms for constant $k$ cannot achieve an approximation ratio of $3/4$ in input model 1 or 2. Thus we suggest trying to use Johnson's algorithm in some way. In a max-of-2 algorithm, when processing a variable, we want to have a preference for the case in which the two assignments set a variable differently, since otherwise the $2/3$ inapproximation bound for online algorithms could be applied to the max-of-2 algorithm. In Algorithm~\ref{maxsat2} we present a formal way to do this, where the parameter $p$ controls how much we value different assignments. The variables are $\{x_1, \ldots, x_n\}$ in online order, and the algorithm constructs two assignments $A_1$ and $A_2$. Recall that, at any point in the algorithm, the measure of a clause $C$, $\mu(C)$, is defined by the product of its weight times $2^{-l}$ where $l$ is the number of variables not yet assigned. We call the algorithm Width-2-Johnson's Algorithm. When deciding the assignment for $x_i$, it calculates, for each of the two assignments, the measures of clauses that become satisfied when assigning $x_i$ to 0 or to 1, as in Algorithm~\ref{JohnsonAlg}. For each assignment $D \in \{0,1\}^2$, it adds the measures of satisfied clauses when assigning $x_i$ to $D$. However, instead of double-counting clauses that become satisfied in both assignments, the measures of repeated clauses are multiplied by $p$ instead of added twice for $1 \leq p \leq 2$. \begin{algorithm}\caption{Width-2-Johnson's with parameter $p$}\label{maxsat2} \begin{algorithmic}[1] \State Initialize $A_1$ and $A_2$ to be empty assignments. \For{$i=1$ to $n$} \State The algorithm will calculate a function $f: \{0,1\}^2 \rightarrow \mathbb{R}$ \For{$D = (d_1, d_2) \in \{0,1\}^2$} define \State $C_1:$ the set of clauses that become satisfied by assigning $x_i$ to $d_1$ in $A_1$. \State $C_2:$ the set of clauses that become satisfied by assigning $x_i$ to $d_2$ in $A_2$. \State The algorithm sets $f(D) = \mu(C_1 \setminus C_2) + \mu(C_2 \setminus C_1) + p\mu(C_1 \cap C_2)$. \EndFor \State The algorithm assigns $x_i$ to argmax$_{D \in \{0,1\}^2}\{ f(D) \}$. \EndFor\\ \Return the assignment that satisfies a larger weight of clauses. \end{algorithmic} \end{algorithm} Width-2-Johnson's algorithm is a candidate to achieve a good approximation ratio for max-sat. The following lemma suggests that $p=1.5$ is the right choice. It's unclear whether it could achieve an approximation ratio of $3/4$. It would be interesting to show that it achieves an approximation ratio greater than $2/3$, which would show that, unlike bipartite matching, max-sat is helped by constant width. \begin{lemma} Width-2-Johnson's algorithm cannot achieve an approximation ratio of $3/4$ if $p \neq 1.5$. \end{lemma} \begin{proof} If $p>1.5$, let $w$ be such that $1> w>1/2$ and $p > 1+w$. Consider the max-sat instance consisting of clauses $x_1$ with weight 1, $\overline{x_1} \vee \overline{x_2}$ with weight $w$, and $x_2$ with weight $w$. The algorithm will assign $x_1$ to $(1,1)$ because $p > 1+w$. But then when processing $x_2$ it cannot satisfy both clauses of weight $w$ in any of the two assignments. Thus the approximation ratio achieved is $\frac{1+w}{1+2w}$, which is less than $3/4$ because $w > 1/2$. If $p<1.5$, let $w$ be such that $0 < w < 1/2$ and $p < 1+w$. Consider the instance: $x_1$ with weight 1, $\overline{x_1}$ with weight $w$, $x_2$ with weight 1, $\overline{x_2}$ with weight $w$. The algorithm will assign $x_1$ to either $(1,0)$ or $(0,1)$ because $1+w > p$, so suppose it assigns $x_1$ to $(1,0)$. Then similarly suppose it assigns $x_2$ to $(0,1)$. Then both assignments satisfy clauses with total weight $1+w$, but the optimum assignment satisfies clauses of weight 2, hence the approximation ratio achieved is $\frac{1+w}{2}$, and this is less than $3/4$ because $w<1/2$. \end{proof} \section{Bipartite matching results} \label{sec:bipartite} We will first consider width inapproximation results showing that width $\frac{\log n}{\log \log n}$ online algorithms cannot asymptotically improve upon the $\frac{1}{2}$ approximation given by any maximal matching algorithm. We will then consider bipartite matching in the priority and ROM models. Our priority inapproximation shows that the ROM randomization cannot be replaced by a judicious but deterministic ordering of the online vertices. \subsection{Width inapproximation} We first fix some notation for max-of-$k$ online bipartite matching. The algorithm keeps $k$ distinct matchings $M_1, \ldots, M_k$. Whenever an online vertex $u$ arrives, it can update each of the $M_j$'s by matching to $u$ one of its neighbours that $M_j$ has not yet matched. The size of the matching obtained by the algorithm is the maximum size of the $M_j$'s. We assume that the online vertices are numbered from $1$ to $n$, and the algorithm receives them in that order. The adversary chooses the offline vertices that are the neighbours. We will refer to the time when the algorithm chooses the matchings for the $i$-th online vertex as step $i$. In the usual online bipartite matching problem, we can assume that the algorithm is greedy. This argument clearly still applies when we keep track of multiple matchings at once: we can assume that the algorithm is greedy in each. We begin with a max-of-$n^k$ algorithm and inapproximability result that follows from the relationship between advice and max-of-$k$ algorithms: \begin{theorem}\label{WidthUppLow} For every $\epsilon >0$ there exists a max-of-$n^{O(1)}$ algorithm achieving an approximation ratio of $1-1/e - \epsilon$. Also, no max-of-$2^{o(n)}$ algorithm can achieve an approximation ratio better than $1-1/e+\epsilon$. \end{theorem} \begin{proof} By B\"{o}ckenhauer et al \cite{Bock11}, as observed in \cite{Durr2016a}, for every $\epsilon>0$ there is a $\Theta(\log n)$ advice algorithm achieving an approximation ratio of $1-1/e-\epsilon$. The algorithm is a de-randomization of the Ranking algorithm. Part of the advice string consists of an encoding of $n$. Even without this, the advice is still $\Theta(\log n)$. By Lemma \ref{WidthAdvice} there is a max-of-$2^{O(\log n)} = n^{O(1)}$ algorithm getting the desired approximation ratio. It should be noted that the algorithm uses an information-theoretic approach and is, in fact, extremely inefficient, in addition to requiring heavy pre-processing. For the other part of the theorem, Mikkelsen \cite{Mikkelsen15} showed that, for every $\epsilon$, an advice algorithm with approximation ratio $1-1/e+\epsilon$ requires $\Omega(n)$ advice. If there was a max-of-$2^{o(n)}$ with this ratio, then by Lemma \ref{WidthAdvice} there would be a $o(n)$ advice algorithm achieving that ratio. Note that it can be assumed without loss of generality that any algorithm with $\Omega(\log n)$ advice knows $n$. \end{proof} We now prove some impossibility results concerning algorithms trying to beat the $1/2$ barrier that deterministic online algorithms cannot surmount. The adversarial graphs will be bipartite graphs with perfect matchings. The adversary will not only provide the graph but also construct a perfect matching ``online''. Once an offline vertex has been used in the adversary's perfect match, the adversary will not present it as a neighbour of any of the remaining online vertices. When an online vertex $u$ arrives, the adversary will choose a nonempty subset of offline vertices as its set of neighbours. Then the algorithm (which we assume without loss of generality to be greedy) chooses a match in each of the $k$ matchings. For each matching $M_i$, if there are neighbours of $u$ that have not been used in $M_i$, the algorithm must pick a neighbour $v$ and match $u$ to $v$ in $M_i$. When the algorithm has finished making its choices, the adversary picks one of the neighbours of $u$ and adds the pair of vertices to the perfect matching that it is constructing. The match to online vertex $i$ in this perfect matching is labelled as offline vertex $i$. We say that this offline vertex becomes \emph{unavailable}. An offline vertex is \emph{available} if it is not unavailable. The goal of the adversary is to force the algorithm to make as few matches as possible in the best of its $k$ matchings. At a specific point in time and for any offline vertex $v$, we say $t(v)$ is the number of the algorithm's matchings that have used $v$. Whenever we say that the adversary \emph{gets rid} of an offline vertex $v$ at a given step we mean that, at this step, the only neighbour of the online vertex $u$ is $v$, so the best option of the algorithm is to match $u$ to $v$ in any of the matchings where $v$ has not yet been used. Also, $v$ will not be a neighbour of any of the remaining online vertices (the adversary must add $(u,v)$ to its perfect matching). If the adversary only gets rid of a constant number of offline vertices, the matchings made by the algorithm during these steps are negligible: they do not affect the asymptotic approximation ratio. \begin{lemma}\label{Maxof2bm} Any max-of-2 online bipartite matching algorithm cannot achieve a matching of size greater than $n/2 + 3$ on every input. \end{lemma} \begin{proof} Since the algorithm has only two matchings, at any point in time and for any offline vertex $v$, $0 \leq t(v) \leq 2$. There will be two stages. The first stage consists of steps where, at the beginning of the step, there are more than two available vertices $v$ with $t(v)=0$. The adversary chooses as neighbours all available vertices. Thus, we can guarantee that, after the algorithm has chosen matches for the online vertex of this step, there will still be at least one available vertex $v$ with $t(v)=0$. The adversary will choose one such offline vertex (i.e. one not chosen in any matching) to be added to its perfect matching. If at the beginning of a step, there are less than 3 available offline vertices with $t(v)=0$ (so that we cannot guarantee that there will exist a vertex with $t(v)=0$ after the algorithm does its matches), the adversary concludes stage 1 and gets rid of the at most 2 available offline vertices with $t(v)=0$ before stage 2. Let $p$ be the number of steps that occurred during stage 1. Let $p_1$ and $p_2$ be the number of offline vertices with $t(v) = 1$ and $t(v)=2$ at the end of stage 1, respectively. During stage 1, at each step, $\sum_v t(v)$ is incremented by 2, so $2p = p_1 + 2p_2$. At each step in stage 1 a vertex becomes unavailable, but no vertex with $t(v) \neq 0$ becomes unavailable, so $n \geq p + p_1 + p_2$ (inequality because the adversary may get rid of vertices). Therefore, $p = \frac{p_1}{2} + p_2$ and $\frac{n}{2} \geq \frac{3}{4} p_1 + p_2$. Right before the beginning of stage 2, the size of each matching is at most $p+2$: $p$ from stage 1 and 2 from getting rid of vertices. The second stage consists of steps where at the beginning of the step all the available offline vertices satisfy $t(v) \geq 1$, and there are some available vertices with $t(v)=1$. At this stage, the $p_1$ vertices with $t(v)=1$ are considered. Since the number of vertices matched in $M_1$ and $M_2$ have to be the same during stage one, half of the vertices are used in $M_1$ and half in $M_2$. The steps in this stage will be either $M_1$-steps or $M_2$-steps (the order in which the adversary does them is irrelevant). An $M_1$ step is a step where the neighbours of the online vertex are available vertices that have already been matched in $M_1$, so the algorithm can only do a match in $M_2$. After the algorithm does its match, if there is still an available vertex that has only been matched in $M_1$, the adversary adds it to the perfect matching it is constructing, making it unavailable. At the beginning of stage 2, there are $p_1/2$ vertices with $t(v)=1$ matched in $M_1$. Every $M_1$-step (except possibly the last, where there may be only one available vertex matched in $M_1$ with $t(v)=1$) makes two vertices unusable: one because it is made unavailable and one because $t(v)$ changes from 1 to 2. So there will be $\lceil p_1/4 \rceil$ $M_1$-steps. We define $M_2$-steps analogously, and there will be $\lceil p_1/4 \rceil$ $M_2$-steps. After stage 2, all available vertices have $t(v)=2$ and are unusable, so no more matchings are made by the algorithm. The adversary can finish the construction of the perfect matching by making the remaining online vertices be neighbours of all offline vertices with $t(v)=2$. The size of the matchings produced by the algorithm is at most $p + 2+ \lceil \frac{p_1}{4} \rceil$, since the algorithm can only increase the size of $M_1$ during stage 1, while the adversary gets rid of vertices, and during $M_2$-steps, and similarly for $M_2$. But $p + 2 + \lceil \frac{p_1}{4} \rceil \leq p+3+ \frac{p_1}{4} = \frac{p_1}{2} + p_2 + 3 +\frac{p_1}{4} \leq \frac{n}{2} + 3$. This in particular implies that the asymptotic approximation ratio achieved by any algorithm is at most $\frac{1}{2}$. \end{proof} Clearly, making the width bigger without making $n$ bigger will eventually allow the algorithm to obtain an optimal matching using brute-force. However, it is natural to wonder whether by allowing $n$ to be large the adversary will be able to trick the algorithm into producing a small matching. This question is answered by the following: \begin{theorem}\label{WidthBip1/2} For any constant $k$, any width-$k$ online bipartite matching algorithm cannot achieve an asymptotic approximation ratio greater than $\frac{1}{2}$. \end{theorem} \begin{proof} We will prove the theorem by first considering max-of-$k$ and then extending the result to width. We prove the following statement by induction on $k$: for any max-of-$k$ algorithm there exists a constant $c_k$ (that only depends on $k$) such that for every $n$ there is a graph $G$ of size $n$ ($n$ vertices on each of the two sides) where the algorithm obtains matchings of size at most $n/2 + c_k$. For $k=1$, the problem is the well studied online bipartite matching problem: there are adversarial graphs where we can take $c_1=1$ (needed for odd values of $n$). Lemma~\ref{Maxof2bm} proves the case for $k=2$, taking $c_2=3$. Suppose that the claim is true for max-of-$i$ for all $1 \leq i \leq k$, and we shall prove it for max-of-$(k+1)$. As before, the adversary will decide the neighbours of the incoming online vertex as well as the offline vertex that matches it in the perfect matching it constructs (and this offline vertex will not be a neighbour of any of the remaining online vertices). Let $M_1, \ldots, M_{k+1}$ be the matchings that the algorithm constructs. The adversary will have the same first stage as in the lemma, at each step adding to its perfect matching a vertex with $t(v)=0$. When there are less than $k+2$ available vertices with $t(v)=0$ (so we cannot guarantee that there will be an available vertex with $t(v)=0$ after the algorithm does its matchings), stage 1 ends and then the adversary gets rid of all the available vertices with $t(v)=0$. Let $p$ be the number of steps in the first stage and let $q$ be the number of available offline vertices right after stage 1, ie the number of offline vertices not in the adversary's perfect matching at that time. Then $p + q = n$, and after the adversary gets rid of vertices there are at most $q$ available vertices. Now the adversary proceeds to a second stage. For every $S \subseteq \{1, \ldots, k+1\}$ with $S \neq \emptyset$ and $S \neq \{1, \ldots, k+1\}$, let $V_S$ be the subset of available offline vertices that have been used in $M_i$ for all $i \in S$ and that have not been used in $M_i$ for all $i \notin S$. Let $S^C = \{1, \ldots, k+1\} \setminus S$, and notice that $0 < |S^C| < k+1$. At this point, only $M_i$'s with $i \in S^C$ can match vertices in $V_S$. The idea is that we will recursively apply our adversary for max-of-$|S^C|$ algorithms on a graph with $V_S$ as the set of offline vertices and with $|V_S|$ online vertices. The $M_i$'s with $i \in S$ are ignored: the algorithm cannot add matches in these when the set of neighbours of the online vertex is a subset of $V_S$. By the induction hypothesis, there is an adversarial strategy for max-of-$|S^C|$ such that the size of any of the matchings obtained (on a graph that uses $|V_S|$ online vertices and $V_S$ as the offline vertices) is at most $|V_S|/2 + c_{|S^C|}$. This will be close to 1/2 of the total when $|V_S|$ is large, since $c_{|S^C|}$ is a constant. In the second stage, the adversary executes the max-of-$|S^C|$ strategies described above. For $S_1 \neq S_2$, the strategies will be independent because the set of offline neighbours is disjoint. Thus, the order in which the strategies are executed is irrelevant: they could even be executed in parallel. For concreteness, suppose the adversary first executes the strategies for subsets $S$ of size $k$ in lexicographic order (here it applies max-of-1 strategies), then for subsets $S$ of size $k-1$ in lexicographic order (here it applies max-of-2 strategies), etc. After the strategies for all subsets have been executed, stage 2 is concluded and now we need to show that the adversary's perfect matching is about twice the size as any of the matchings constructed by the algorithm. For simplicity, ignore the adversary getting rid of vertices and suppose that every $V_S$ is large enough. In the end, any fixed matching $M_i$ will use $p$ offline vertices because of stage 1. After applying our recursive adversaries, $M_i$ will use roughly half of the offline vertices that were not used by $M_i$ by the end of stage 1 but were still available at this time. The number of offline vertices that are available by the end of stage 1 is $q$. Thus, in the end, the size of matching $M_i$ is $p + \frac{q - p}{2} = \frac{p + q}{2} = n/2$. Now we make the intuition from the previous paragraph precise. Notice that the size of matching $M_i$ is at most $p+k+1 +\sum_{S: i \notin S} \frac{V_S}{2}+c_{|S^C|}$: $p$ during stage 1, $k+1$ from vertices the adversary gets rid of before stage 2, and the rest during stage 2. The number of available offline vertices that $M_i$ has not used at the beginning of stage 2 is $\sum_{S: i \notin S} V_S \leq q - p = n - 2p$. By the induction hypothesis, $\sum_{S : i \notin S} c_{|S^C|} \leq \sum_{1 \leq j \leq k} \binom{k}{j-1} c_{j}$, since there are $\binom{k}{j-1}$ ways of choosing $S^C$ of size $j$ if we require $i \in S^C$. Therefore, the size of any matching obtained by the algorithm is at most $\frac{n}{2} + c_{k+1}$ where $c_{k+1} = k+1+\sum_{1 \leq j \leq k} \binom{k}{j-1} c_{j}$. This concludes the induction and the proof for max-of-$k$ algorithms. Now we extend the result to width $k$. The idea is that we will slightly modify the adversary so that, given the decisions of the algorithm, for $a>b$, a max-of-$a$ adversary can be viewed as a max-of-$b$ adversary. The width-$k$ adversary will use this fact to change from the max-of-$b$ adversary to the max-of-$a$ adversary, whenever the algorithm branches, without affecting the argument. Let $\mathbb{A}_j$ be the max-of-$j$ adversary, but where the condition to end stage 1 is that there are less than $k+1$ available vertices with $t(v)=0$, instead of $j+1$. Also, we assume that $\mathbb{A}_j$ may perform the independent stage 2 simulations in any order we choose. The width-$k$ adversary $\mathbb{A}$ does the following: begin by assuming $m$, the maximum number of matchings maintained by the algorithm, is 1. When $\mathbb{A}$ needs to tell the algorithm which are the neighbours of the next online vertex, $\mathbb{A}$ does whatever $\mathbb{A}_m$ would do given the matchings the algorithm has made so far. If the algorithm does not branch, $\mathbb{A}$ constructs the perfect match as $\mathbb{A}_m$ would, and this finishes the processing of the online vertex. On the other hand, the algorithm may branch on the decisions of the online vertex, so that now it maintains $m+r$ matchings. Each new matching $M_{new}$ will branch off of some matching $M_{old}$, which in the branching tree means that now $M_{new}$ is a leaf of the subtree rooted at $M_{old}$ (or any of its ancestors). In this case, $\mathbb{A}$ simply increases $m$ by $r$. Then it simulates $\mathbb{A}_m$ ($m$ is the increased value) to obtain the perfect match. And this finishes the processing of the online vertex. At any point in time, there is a max-of-$m$ algorithm that simulates the width-$k$ algorithm up to this point, if it knows the branching tree created up to this point. For each level of the branching tree (each corresponding to an online vertex), the max-of-$m$ algorithm keeps $l$ copies of each node, where $l$ is the number of leaves in the subtree rooted at that node. We claim that all previous decisions made by $\mathbb{A}$ are consistent with $\mathbb{A}_m$, in the following sense: the behaviour of $\mathbb{A}$ on the width-$k$ algorithm (which so far only has $m$ branches) is equivalent to the behaviour of $\mathbb{A}_m$ on the max-of-$m$ algorithm just described. By behaviour of an adversary, we mean the offine neighbours it presents and the perfect matchings it constructs at each step. We can show this by induction. Consider a step where the width-$k$ algorithm branches, and let $m_i$ and $m_f$ be the values of $m$ at the beginning and at the end of the step, respectively. Suppose that $\mathbb{A}$ (on the width-$k$ algorithm) behaves as $\mathbb{A}_{m_i}$ on the max-of-$m_i$ algorithm that simulates the width-$k$ algorithm up until the previous step. We will now show that $\mathbb{A}$ behaves as $\mathbb{A}_{m_f}$ on the max-of-$m_f$ algorithm that simulates the width-$k$ algorithm up until this step. On later steps, as long as the algorithm does not branch, this consistency will still hold. We will see $\mathbb{A}$ as $\mathbb{A}_{m_i}$ (on the max-of-$m_i$ algorithm) up until the end of the previous step, which is valid by our assumption. If the branching occurs during stage 1, then what we claim is true since $\mathbb{A}_{m_i}$ and $\mathbb{A}_{m_f}$ have the same stage 1. Now suppose that the branching occurs during stage 2. We will prove that up until the beginning of the current step we can make the behaviour of $\mathbb{A}_{m_f}$ on the max-of-$m_f$ algorithm be the same as the behaviour of $\mathbb{A}_{m_i}$ on the max-of-$m_i$ algorithm. On a stage 2 step, $\mathbb{A}_{m_i}$ will be simulating $\mathbb{A}_x$ on $V_S$ for some $S \subseteq \{1, \ldots, m_i\}$ and where $x = |S^C|$. Then in $\mathbb{A}_{m_f}$ we choose to simulate a step of $\mathbb{A}_{y}$ on $V_{S'}$, where $S \subseteq S' \subseteq \{1,\ldots,m_f\}$, $S'$ contains all indices of matchings that branched off from matchings indexed in $S$, and $y = |{S'}^C| \geq |S^C|$ (${S'}^C$ contains indices of matchings that branched off from matchings indexed in $S^C$). This is because by definition the max-of-$m_f$ algorithm only keeps copies of the matchings that will later branch off, so $V_S$ = $V_{S'}$: here the left hand side corresponds to the set according to $\mathbb{A}_{m_i}$ and the right hand side is according to $\mathbb{A}_{m_f}$. More generally, there is a mapping $f: \mathcal{P} (\{1, \ldots, m_i\}) \rightarrow \mathcal{P}(\{1, \ldots, m_f\})$ that maps a set of indices $Q$ to the set of indices of matchings that branch off from matchings indexed in $Q$. Because of the behaviour of the algorithms, it holds that $V_Q$ according to $\mathbb{A}_{m_i}$ is equal to $V_{f(Q)}$ according to $\mathbb{A}_{m_f}$, and for any $R \subseteq\{1,\ldots,m_f\}$ that does not have a preimage under $f$, $V_R = \emptyset$. In the step where $m$ changes from $m_i$ to $m_f$, $\mathbb{A}_{m_i}$ simulating $\mathbb{A}_x$ to select a subset of $V_S$ as the set of neighbours is equivalent to $\mathbb{A}_{m_f}$ simulating $\mathbb{A}_y$ to select a subset of $V_{S'}$. After the algorithm does its decision and branching, $m$ is updated and $\mathbb{A}$ actually simulates $\mathbb{A}_{m_f}$, so the behaviour is the same. This concludes the proof of our claim. Thus, in the end, the behaviour of $\mathbb{A}$ on the width-$k$ algorithm is equivalent to the behaviour of $\mathbb{A}_k$ on the max-of-$k$ algorithm. This means that the size of the matching constructed by the width-$k$ algorithm is at most $n/2 + c_k$. Since we changed stage 1 of the adversaries, the $c_k$'s will be slightly larger, but they still only depend on $k$. \end{proof} \begin{corollary} Let $t(n) = \frac{\log n}{\log \log n}$. Any max-of-$t(n)$ online bipartite matching algorithm cannot achieve an asymptotic approximation greater than $\frac{1}{2}$. \end{corollary} \begin{proof} For any $k$, from the proof of Theorem \ref{WidthBip1/2} max-of-$k$ algorithms can achieve matchings of size at most $n/2 + c_k$ on some hard graphs. First, we note that $c_k \leq k^k$. This is true for $k=1$. Assuming this holds for $1 \leq i < k+1$, then $c_{k+1} \leq k+1 + \sum_{1 \leq j \leq k} \binom{k}{j-1} j^j < \sum_{0 \leq j \leq k+1} \binom{k+1}{j} k^j = (k+1)^{k+1}$. In the second inequality we use the fact that $k+1 \leq 1+k^{k+1}$. Now, notice that $t^t < (\log n)^{\frac{\log n}{\log \log n}} = (2^{\log \log n})^{\frac{\log n}{\log \log n}} = n$, where in the first inequality we omit dividing by $(\log \log n)^{\frac{\log n}{\log \log n}}$. This means that $t^t = o(n)$. Thus, max-of-$t$ algorithms achieve matchings of size at most $n/2 + t^t = n/2 + o(n)$. \end{proof} The following corrolary follow immediately from the observations in Section \ref{max-of-k-becomes}. D{\"{u}}rr et al \cite{Durr2016a} proved an $\Omega(\log \log \log n)$ advice lower bound for achieving an approximation ratio greater than $1/2$, and this only applied to a restricted class of online advice algorithms. We improve this result: \begin{corollary} $\Omega(\log \log n)$ advice is required for an online algorithm to achieve an asymptotic approximation ratio greater than $1/2$ for bipartite matching, even when the algorithm is given $n$ in advance. \end{corollary} \begin{proof} No $\log \left(\frac{\log n}{\log \log n}\right) = \log \log n - \log \log \log n$ advice algorithm can achieve an asymptotic approximation ratio better than $1/2$, even knowing $n$. Otherwise Lemma~\ref{WidthAdvice} would give a max-of-$\frac{\log n}{\log \log n}$ online algorithm achieving this ratio, contradicting the previous corollary. \end{proof} \subsection{Candidates for an approximation algorithm with polynomial width} While the bounds for non-uniform max-of-polynomial bipartite matching are tight, we have not provided a simple and efficient constant width algorithm that achieves an approximation ratio better than $1/2$. We present two algorithms which could have an approximation ratio better than 1/2. The first candidate is a simple algorithm for max-of-$k$ bipartite matching that attempts to balance the current usage of offline vertices that are still available. The second attempt tries to de-randomize the Ranking algorithm based on the LP approach of Buchbinder and Feldman. We consider the following simple max-of-$k$ algorithm for bipartite matching, for $k \in n^{O(1)}$. The idea works for max-of-$k$ for any number $k$, but the interesting question is what approximation ratio can we achieve when $k \in n^{O(1)}$. Let $M_1, \ldots, M_k$ be the matchings of the algorithm. Define the load of an offline vertex as the number of matchings in which it has been used. The algorithm does the following: when processing an online vertex, try to balance out the loads of the available offline vertices as much as possible. The intuition behind this is that we want the offline vertex with minimum load to have as high a load as possible, so if the adversary chooses to never show this vertex again, the number of matchings that will not match the vertex is as low as possible. The way of balancing loads can be made more precise or it could be left as an arbitrary choice for the algorithm. Nonetheless, this algorithm is fairly efficient and it would be interesting to see whether an algorithm that maintains polynomially many candidate matchings constructed this way can achieve an approximation ratio greater than $1/2$. We have also considered Algorithm \ref{BipMLP} following the LP approach of Buchbinder and Feldman. Suppose that the online vertices arrive in order $\{v_1, \ldots, v_n\}$. Let $N(v)$ be the set of neighbours of vertex $v$. For a matching $M$ and an online vertex $v$, let $N(M,v)$ be the set of offline vertices that are neighbours of $v$ and have not been used in $M$. Also, let $I(M) = \max\{i \in \{1, \ldots, n\} | v_i \mbox{ is matched in }M\}$, ie $I(M)$ is the maximum index of an online vertex matched in $M$. A permutation of the offline vertices is \emph{consistent} with $M$ if $M$ is the matching that results from performing $I(M)$ steps of Ranking given this permutation. In Algorithm~\ref{BipMLP}, we use an LP-based approach at each step to obtain a polynomial width algorithm for bipartite matching. We will consider distributions of matchings, and say $(p,M) \in D$ whenever the probability of $M$ under $D$ is $p$. For all $M \in D_{i-1}$ and $u \in N(M,v_i)$ let $P_i(u,M)$ be the probability that Ranking, when run with a random permutation consistent with $M$, will choose $(v_i,u)$ in the $i$th step. Let $S_{i-1}$ be the set of matchings $M$ in $D_{i-1}$ such that $|N(M,v_i)|>0$. The variables of the LP for the $i$th step are $x(u,M)$ for $u \in N(M,v_i)$ (when $(v_i,u)$ cannot be added to $M$, it doesn't make sense to have this variable). The intended meaning of $x(u,M)$ is that it is the probability in $D_i$ of matching $v_i$ to $u$, given $M$. Letting the probability of $M$ in $D_{i-1}$ be $Pr_{D_{i-1}}[M]$, then the probability of $M \cup \{(v_i, u)\}$ in $D_i$ will be $Pr_{D_{i-1}}[M] x(u,M)$. \begin{algorithm}\caption{Bipartite Matching LP}\label{BipMLP} \begin{algorithmic}[1] \State Let $D_0 = \{(1,\emptyset)\}$. \For{$i=1$ to $n$} \State Obtain an extreme point solution of the following set of inequalities: \begin{eqnarray} \mathbb{E}_{D_{i-1}}[x(u,M)] & \leq & \mathbb{E}_{D_{i-1}}[P_i(u,M)] \mbox{ }\forall u\in N(v_i) \label{bmlp1}\\ \sum_{u\in N(M,v_i)} x(u,M) & = &1 \mbox{ } \forall M \in S_{i-1} \label{bmlp2}\\ x(u,M) & \geq & 0 \mbox{ } \forall M\in S_{i-1} \mbox{ }\forall u\in N(M,v_i) \label{bmlp3} \end{eqnarray} \State Set $D_i = \{ (Pr_{D_{i-1}}[M]x(u,M), M\cup \{(v_i,u)\}) : M\in S_{i-1} \} \cup \{(Pr_{D_{i-1}}[M], M) : M\in D_{i-1} \setminus S_{i-1}\}$. \State Remove from $D_i$ the matchings with zero probability. \EndFor\\ \Return the largest matching from $D_n$. \end{algorithmic} \end{algorithm} We can talk about applying Ranking given distribution $D_{i-1}$ as follows: this will yield a distribution of matchings. It is built by first taking $M \in D_{i-1}$ with the corresponding probability. Then, a random permutation consistent with $M$ is chosen, and Ranking is applied to the rest of the online vertices using this permutation. The intuition of the algorithm is that Inequality~\ref{bmlp1} ensures that, in $D_i$, the probability of using each offline vertex in the $i$th step will not exceed the probability of using it when applying Ranking to the distribution $D_{i-1}$. Equalities \ref{bmlp2} and \ref{bmlp3} ensure that we will split $Pr_{D_{i-1}}[M]$ into the $x(u,M)$'s so that $D_i$ is a probability distribution. The set of inequalities is feasible because we can set $x(u,M) = P_i(u,M)$ for all $M \in S_{i-1}$ and $u \in N(M,v_i)$. The number of inequalities in the LP, without counting inequalities~\ref{bmlp3} that state variables are non-negative, is at most $|D_{i-1}| + |N(v)|$. Thus, an extreme point solution for the $i$th LP will have at most $|D_{i-1}| + |N(v)|$ nonzero variables, so $|D_n| \leq 1 + \sum_i |N(v_i)|$: this is a $(|E|+1)$-width algorithm, where $E$ is the set of edges of the graph. It should be noted that this algorithm is not efficient. Note that a matching defines a partial ordering on the set of offline vertices in the following way: for every matched online vertex $v$, the offline match $u$ is greater than all the other neighbours $u'$ of $v$ that were available when $u$ is matched. The number of permutations consistent with a matching is equal to the number of linear extensions of this poset: a linear ordering on the set of offline vertices can be viewed as a permutation of this set and vice-versa. Given a poset, it is easy to construct a graph and a matching that corresponds to that poset. Also, $P_i(u,M)$ is the number of linear extensions of $M \cup \{(v_i,u)\}$ divided by the number of linear extensions of $M$. So calculating $P_i(u,M')$ for every $u$ matched in $M$ ($M'$ is the subset of $M$ constructed before matching $u$) will give the number of linear extensions of the poset associated with $M$. Therefore, the $P_i(u,M)$'s calculation is $\#P$-hard (since calculating the number of linear extensions of a poset is \cite{Brightwell}). We have not been able to prove a good guarantee for this algorithm. One reason for this is that the analysis for Ranking usually is inductive but on the offline order (according to the permutation), not the online order, so it is unclear if the inductive invariants used to analyse Ranking will remain true in this LP-based approach. In addition, $P_i(u,M)$ does not seem to be amenable to analysis. Finally, experimental results show that the expected size of matchings in $D_n$ may be worse than the expected performance of Ranking on a graph, so trying to somehow argue that the distribution obtained from the LP algorithm outperforms Ranking will not work. For instance, on the hard instance for Random (see Figure~\ref{RandHard} and its explanation), when $n=10$, the expected ratio for $D_n$ (of size of matching over maximum matching size, in this case 10) is 0.7058 while the expected ratio for Ranking on this same graph is 0.7090. On the complete upper triangular matrix (the hard instance for Ranking in \cite{Karp1990a}), when $n=6$, the expected ratio for $D_n$ is 0.6709 and the one for Ranking is 0.6761. However it should be noted that the results are fairly close and, for this family of examples, it looks like the asymptotic approximation ratio will be at least $1-1/e$. We will first consider the bipartite matching problem in the ROM. We will then show that the use of randomization n the algorithm or the randomization of the inout stream cannot be replaced by a judiciious but deterministic ordering of the online vertices nor can it be replaced by a constant (or even $O(\frac{\log n}{\log \log n})$ width of parallel online algorithms. We will then relate the width inapproximation result to previously known results for the advice and streaming models. \subsection{Priority Inapproximation Bound} We now turn to study unweighted bipartite matching in the priority model. All of our results are for adaptive priority. While there are two related models where priority bipartite matching may be studied: one-sided (where there is one data item per vertex in the online side, and the offline side is known in advance) and two-sided (where there is one data item per vertex in the graph), we shall restrict attention to the one sided model. \subsubsection{The inapproximation for deterministic priority algorithms} The following theorem shows that deterministic priority algorithms cannot achieve a non-trivial asymptotic approximation ratio in the one-sided model. Thus, being able to choose the order in which to process the vertices is not sufficient to overcome the lack of randomness. \begin{theorem}\label{Prio1/2} There does not exist a deterministic priority algorithm that achieves an asymptotic approximation ratio greater than $1/2$ for online one-sided bipartite matching, even if the algorithm knows the size of the graph. \end{theorem} \begin{proof} We describe a game between an algorithm and an adversary that, for any odd integer $n \geq 3$, yields an inapproximation of $\frac{(n+1)/2}{n}$, which can be made arbitrarily close to $1/2$ by making $n$ sufficiently large. The bipartite graph will have two sides, each with $n$ vertices. Let $OFF$ be the set of offline vertices and let $ON$ be the set of online vertices. We restrict our attention to graphs in which all vertices in $ON$ have degree $(n+1)/2$. The idea is that the algorithm does not know, a priori, anything about the degrees of vertices in $OFF$, so we can adjust the neighbours of vertices in $OFF$ to ensure that the algorithm makes mistakes at each step. The adversary will keep track of $M$, $U$, $R$, which are pairwise disjoint subsets of $OFF$ (all initially empty). $M$ will be the set of vertices in $OFF$ matched by the algorithm, $U$ will be the set of vertices that the algorithm cannot possibly match because of the matches it has already done, and $R$ will be the set of vertices that the algorithm cannot match because of the rejections it has made. Note that the algorithm won't be able to match vertices in both $U$ and $R$. The only difference between the sets is the reason for this ``unmatchability''. As the game between the algorithm and adversary progresses, the adversary announces some information about the graph, so that the set of possible instances may be further restricted. The adversary will ensure that $|M| = |U|$ whenever the algorithm has to provide an ordering of data items. The set $P$ of potential data items is defined as the set of vertices of degree $(n+1)/2$ where the set of neighbours $N$ satisfies $M \subseteq N$ and $N \subseteq OFF \setminus (U \cup R)$. In other words, $N$ contains $M$ and is disjoint from $U$ and $R$. Initially $P$ consists of all data items of vertices of degree $(n+1)/2$ with neighbours in $OFF$, and $P$ shrinks every time $M$, $U$, and $R$ are updated. While $|U|+|R| < (n-1)/2$, the algorithm receives the data item of the vertex $v$ from $P$ that comes first in some ordering $\pi$ of data items. Note that the number of neighbours in $OFF \setminus (U \cup R \cup M)$ is at least 2 because $|M| <(n-1)/2 =(n+1)/2-1$. There are two options: the algorithm matches $v$ to a neighbour (in $OFF \setminus (U \cup R \cup M)$, because vertices in $M$ have already been matched by the algorithm), or it rejects $v$. We now show how we maintain our invariant ($|M| = |U|$) in either case. If the algorithm matches $v$ to some vertex $m \in OFF \setminus (U \cup R \cup M)$, the adversary updates $M$ by adding $m$. This means that all the vertices in $ON$ that have not been processed yet will be neighbours of $m$. It picks another neighbour $u$ of $v$ from the set $OFF \setminus (U \cup R \cup M)$ and updates $U$ by adding $u$. This implies that none of the vertices in $ON$ that have not been processed yet will be neighbours of $u$, so it is impossible for the algorithm to match vertex $u$. If the algorithm rejects $v$, the adversary updates $R$ by adding a neighbour $r$ of $v$ from $OFF \setminus (U \cup R \cup M)$. Thus, none of the vertices in $ON$ that have not been processed yet are neighbours of $r$ and $r$ will remain unmatched. Note that, in either case, the condition $|M| = |U|$ is still maintained. Each time a vertex in $ON$ is examined, exactly one of $|U|$ and $|R|$ is increased by 1. Thus, after $(n-1)/2$ vertices in $ON$ have been examined, $|U|+|R|=(n-1)/2$. At this point, $P$ consists of vertices whose set of neighbours is $OFF \setminus (U \cup R)$. This is necessary to guarantee that the potential data items correspond to vertices of degree $(n+1)/2$. The adversary no longer shrinks $P$ while the remaining $(n+1)/2$ vertices are examined. The matching obtained by the algorithm is at most $n - (|U|+|R|) = (n+1)/2$ because it does not match any vertices in $U \cup R$. However, there exists a perfect matching. We construct it by looking back at the game between the algorithm and adversary. We match the first $(n-1)/2$ vertices processed by the algorithm to vertices in $U \cup R$. For each step in which the algorithm rejected a vertex $v$, there was some vertex $r$ added to $R$: we match $v$ to $r$. For each step in which the algorithm matched a vertex $v$, it was matched to a vertex $m$ and there was a $u$ that was added to $U$. We match $v$ to $u$. Thus, after $(n-1)/2$ vertices, we have matched all of $U$ and $R$. We are left with vertices in $OFF \setminus (U \cup R)$, which can be matched in any way to the $(n+1)/2$ remaining vertices in $ON$ because that is precisely their set of neighbours. For an example, take $n=7$. Then the degrees have to be $4$ and the adversary constructs $M$, $U$, and $R$ when the first 3 online vertices are being examined. An example where the algorithm matches the first online vertex, rejects the second, and matches the third is shown in Figure~\ref{7Bip-1}. The online vertices examined after an offline vertex is added to $M$ will be neighbours of this vertex. The online vertices examined after an offline vertex is added to $U \cup R$ will not be neighbours of this vertex. A perfect matching for this example is shown in Figure~\ref{7Bip-2}. \begin{figure}[!ht] \centering \includegraphics[width=0.5\textwidth]{7Bip-1} \caption{Offline vertices are labelled whenever they belong to $M$, $U$, or $R$. Dark lines correspond to matches made by the algorithm. Dotted lines correspond to edges such that, when the online vertex was processed, the adversary added the offline vertex to $U \cup R$. Light lines are all other edges. The algorithm obtains a matching of size 4.} \label{7Bip-1} \end{figure} \begin{figure}[!ht] \centering \includegraphics[width=0.5\textwidth]{7Bip-2} \caption{Same instance as before, now showing only the edges corresponding to a perfect matching obtained by the adversary.} \label{7Bip-2} \end{figure} \end{proof} \subsubsection{Randomized priority algorithms} \label{subsec:randomized-priority} For randomized priority algorithms, we thus far have only a much weaker $\frac{53}{54}$ inapproximation result in Theorem ~\ref{thm:randomized-priority-inapprox}. Algorithm Ranking can obviously be implemented in this model, and this already an approximation ratio of $1-1/e$, which is optimal for online randomized algorithms. This leaves open the question of whether there is a randomized priority algorithm beating the optimal randomized online Ranking algorithm. The following argument emphasizes the difficulty in proving inapproximation results for randomized priority algorithms. Using the Yao minimax lemma, it is sufficient to define a distribution on inputs such that every deterministic algorithm will suffer an inapproximation (in expectation) for that distribution. Consider the graph in Figure~\ref{PrioOneRand} and consider the following reasoning. Given that all online nodes have degree 2, it would seem that if $v$ is the first node being seen (in the random ordering of the online vertices), then it will fail to choose $u$ as its match with probability $\frac{1}{2}$ and hence the probability that the algorithm makes a mistake for the first online vertex it sees is $\frac{1}{6} > \frac{1}{9}$. This would yield the weak but improved bound of $\frac{17}{18}$. This reasoning is correct if the algorithm can only make decisions for an online node based on the degree of the node (and any previously seen information). For the first online node, there is no previous information, so that a {\it degree-based} algorithm would indeed achieve the improved $\frac{17}{18}$ approximation. However, there is a way to order the vertices so that the probability of making a mistake for the first online vertex is less than $\frac{1}{6}$. Let a data item be described by $l_1 : (l_2, l_3)$, meaning that this corresponds to the data item of the online vertex with label $l_1$, having the offline vertices labelled with $l_2$ and $l_3$ as neighbours. Let the priority ordering given by the algorithm begin as follows: $v_1:(u_1,u_2), v_1:(u_1,u_3), v_2:(u_1,u_2), v_2:(u_1,u_3), v_3:(u_1,u_2), v_3:(u_1,u_3)$. At least one of the data items must be in the instance, regardless of how the nodes are permuted. Let us assume that upon receiving its first data item, the algorithm matches the online vertex to $u_1$. We now analyse the probability that $v$ is matched, but not to $u$. If $v$ is not the first online vertex received, it is easy to see that the algorithm can achieve a perfect matching. When $u$ is labelled as $u_1$, then $v$ will be the first online vertex received, but the algorithm will match $v$ to $u$ and achieve a perfect match. So the only case when the algorithm can make a mistake is when $v$'s other neighbour, $u'$, is labelled as $u_1$. Since $u'$ has all online nodes as neighbours, the one labelled $v_1$ will be received first. To make a mistake, then, $u'$ has to be labelled as $u_1$ and $v$ has to be labelled as $v_1$. Thus, the probability that the algorithm makes a mistake is $\frac{1}{9}$, and the algorithm achieves an approximation ratio of $\frac{8}{9} + \frac{1}{9} \times \frac{2}{3} = \frac{26}{27}$. This algorithm shows why the above argument is incorrect: it was able to receive $v$ with probability $4/9$, and conditioned on $v$ being the first vertex, $v$ is matched to $u'$ with probability $1/4$. \begin{figure}[!ht] \centering \includegraphics[width=0.5\textwidth]{PrioOneRand} \caption{A graph showing the difficulty of proving priority randomized inapproximations.} \label{PrioOneRand} \end{figure} We are able to show that randomized priority algorithms cannot achieve optimality \begin{theorem} \label{thm:randomized-priority-inapprox} No randomized priority algorithm can acheive an approximation better than $\frac{53}{54}$. \end{theorem} \begin{proof} Using the names as above, suppose the algorithm first considers $v_i:(v_j,v_k)$ and without loss of generality suppose the algorithm will match $v_i$ to $v_j$. Then with probability $\frac{1}{3}$, $v$ is named $v_1$, and with probability $\frac{1}{6}$, $(u',u)$ is named $(u_j,u_k)$ where $u'$ is the other neighbor of $v$. \end{proof} \subsection{ROM bipartite Matching} Ranking is an online randomized algorithm, but as observed in \cite{Karp1990a}, it also has a well-known interpretation as a ROM algorithm. It is equivalent to the Fixed Ranking algorithm in ROM: performing online Ranking on a graph $G=(V_1,V_2,E)$ (where $V_1$ is the online side and $V_2$ the offline side) is the same as deterministically matching to the first available neighbour in the graph $G'=(V_2,V_1,E)$, in the ROM model (now $V_2$ are the online vertices, and the ordering of $V_1$ used to decide which vertex is ``first'' corresponds to the online order in $G$). This means that deterministic ROM algorithms can achieve an approximation ratio of $1-1/e$. It is known that algorithm Random does not get an approximation ratio better than 1/2 in the online setting \cite{Karp1990a}. Figure~\ref{RandHard} shows the hard instance used for $n=6$. The online vertices are columns, and they arrive from right to left. The offline vertices are rows, and a $0$ entry means there is no edge between the corresponding online and offline vertices, while a $1$ means that there is. This is generalized in an obvious way to an instance of $2k$ vertices. The first $k$ online vertices will have degree $k+1$. They will have $k$ common neighbours (corresponding to the first $k$ rows in the matrix), plus an additional neighbour that has degree 1 (hence, the correct choice is to match the online vertex to this additional neighbour). The last $k$ online vertices will have degree 1, each being matched to one of the first $k$ rows. \begin{figure}[!hb] \caption{Graph that is hard for algorithm Random.} \label{RandHard} $$\begin{pmatrix} 1&0&0&1&1&1\\ 0&1&0&1&1&1\\ 0&0&1&1&1&1\\ 0&0&0&1&0&0\\ 0&0&0&0&1&0\\ 0&0&0&0&0&1\\ \end{pmatrix} $$\end{figure} Random has trouble with this instance because it does not use information from previous online vertices when it has to ``guess'' the correct match of a given online vertex. In contrast, by using a random permutation of the offline vertices, Ranking tends to be biased in favor of vertices that have occurred less in the past. Suppose that several online vertices have been matched. In the permutation used by the algorithm, the remaining offline vertices from among the first $k$ must appear after all the offline vertices that have already been matched. On the other hand, we know nothing about the relative order among the first $k$ offline vertices of the offline vertex $u$ of degree 1 that is neighbour of the next online vertex. Thus, there are more permutations consistent with the choices made so far where $u$ comes first among those available, so $u$ is more likely to be matched. In contrast, in Random, at any point in time, all available vertices are equally likely to be matched. Ranking has been well studied in ROM. It is interesting to note, however, that this is not the case for algorithm Random. Of course, it is very plausible that Random will not beat Ranking in ROM. However, it would be nice to know if it gets an approximation ratio greater than 1/2 in this model. In fact, we do not even know whether Ranking is asymptotically better than Random. It could even be the case that Random is asymptotically better than Ranking. In the analysis of the following theorem we show that the performance of Random in ROM for the instance described above is worse than that of Ranking. \begin{theorem} Algorithm Random achieves an asymptotic approximation ratio of at most $3/4$ in ROM. \end{theorem} \begin{proof} Consider the hard graphs of Figure~\ref{RandHard}. Fix a permutation of online vertices. Ranking will randomly choose a permutation of the offline vertices $\sigma$. Notice that Ranking and Random behave the same on online vertices of degree 1: they will match to its neighbour if it is still available. In particular, the behaviour of Ranking on degree 1 vertices reveals nothing about $\sigma$. We now see what happens to the vertices of degree $k+1$. For the first of these, both algorithms behave the same: the probability of picking any at random is equal to the probability of any being first (among the options) in the ranking. Now, consider any online vertex $u$ of degree $k+1$ and fix the choices of matches of previous vertices. We will analyse the behaviour of Ranking and Random under the assumption that these matches were made previously by both algorithms. Let $A$ be the set of offline vertices of degree $k+1$ that were previously matched to online vertices of degree $k+1$: the mistakes from the past. Let $B$ be the set of offline vertices of degree $k+1$ that are still available currently, when choosing the match of $u$. Notice that all vertices in $B$ must have also been available before. Because Ranking chose matches with vertices in $A$, then all vertices in $A$ go before all vertices in $B$ in $\sigma$. However, consider the unique offline vertex $v$ of degree 1 that is neighbour of $u$: the correct match of $u$. This vertex could appear anywhere in $\sigma$, since it has never been considered before. This means that the probability of this vertex being first in $\sigma$ among the available vertices is greater than that of any vertex in $B$. So the probability that Ranking matches $u$ to $v$ is higher than the probability that it matches $u$ to any vertex in $B$. Thus, for any permutation of online vertices and any fixed choices of matching for previous vertices, the probability that Ranking matches the current online vertex of degree $k+1$ to its neighbour of degree 1 (its correct match) is greater than or equal to the probability that Random does so. The size of the matching is equal to $k$ plus the number of correct matchings: any incorrect match means there will be an online degree 1 vertex that will be unmatched. It is proved in \cite{Karande2011} that the asymptotic approximation ratio of Ranking on these graphs is at most 3/4. Thus, this bound also holds for Random. \end{proof} We now turn our attention to deterministic ROM algorithms. The following shows that in ROM an inapproximation result using a specific small graph will not yield the same inapproximation for arbitrarily large graphs just by taking the union of disjoint copies of the small graph. Consider the bipartite graph with 2 vertices on each side, where one online vertex has degree 2 and the other has degree 1. By carefully choosing the neighbour of the degree 1 vertex, we get that no deterministic algorithm can get an approximation ratio better than 0.75. Now consider a graph with 4 vertices, with 2 components, each with the form of the graph with 2 online vertices (see Figure~\ref{DisjointCopyROM}). \begin{figure}[!htbp] \centering \includegraphics[width=0.4\textwidth]{DisjointCopyROM} \caption{Vertices 2 and 4 have degree one, and the dotted lines show the possible neighbours.} \label{DisjointCopyROM} \end{figure} Consider the following algorithm: match greedily at each step (so that if vertex 2 comes before 1 and 4 before 3, a perfect matching is obtained). Now, if the first vertex received (among 1,2,3,4) is vertex 1 or 3, match it to the leftmost neighbour. Otherwise, whenever there is a choice for vertex 1 because it occurred before vertex 2, choose the rightmost neighbour (analogously for vertex 3). We show that this algorithm achieves an approximation ratio of 0.875 on these graphs. If the graph consists of vertex 2 having the leftmost offline vertex as neighbour, the algorithm will get both vertices matched whenever vertex 1 occurs first in the permutation, and this happens with probability 1/4. The probability that vertex 2 comes before 1 is 1/2. Therefore the algorithm matches $1/2*2+1/4*2+1/4*1 = 1.75$ edges in expectation. If the graph consists of vertex 2 being matched to the option on the right, the algorithm will match both when 1 does not occur first, which happens with probability 3/4. Thus in this case the algorithm matches $3/4*2+1/4*1 = 1.75$ edges in expectation. The analysis for the other component can be done in the same way. That is, the performance of the algorithm on any such graph is $2*1.75 = 3.5$. Thus, the algorithm achieves an approximation ratio of $3.5/4 = 0.875$. To the best of our knowledge, it is not known whether there is any deterministic algorithm that achieves an asymptotic approximation ratio better than $1-1/e$. While we cannot answer this question, we do provide some experimental results suggesting that there may be some better algorithms. As in the online world, it is easy to see that we can assume without loss of generality that the algorithm is greedy: it matches whenever possible. An arbitrary algorithm $ALG$ can be simulated by a greedy algorithm $ALG'$ as follows: if $ALG$ matches online vertex $u$ to $v$ and $v$ is not yet matched in $ALG'$, do that same matching; else match $u$ to any unmatched neighbour in $ALG'$, if there is any. The set of offline vertices matched by $ALG'$ will always contain the set of offline vertices matched by $ALG$, so the approximation ratio of the former is at least as good as that of the latter. Thus the question is, given a vertex, what offline neighbour is chosen as the match, among those available. We define the ranking of an online vertex $v$ as an ordering of offline vertices which determines which one is matched to $v$, among the ones that are available. For instance, in Fixed Ranking, the ranking used is the same for every online vertex. We consider some algorithms which differ from this greedy algorithm with a fixed ranking. In the following, we use the convention that online vertices are labelled $0, 1, \ldots, n-1$ in order of arrival, and offline vertices are somehow labelled also from $0$ to $n-1$. We consider the following algorithms: \begin{algorithm}[!t] \caption{Cyclic Ranking} \begin{algorithmic}[1] \For{$i=0$ to $n-1$} \State Let $v$ be the $i$th online vertex and let $d = \mbox{deg}(v)$ (counting matched offline vertices). \State Let $f = (i+d) \mod (n-1)$. Let $\sigma = (f, (f+1) \mod n, \ldots, (f+n-1) \mod n)$. \State The algorithm matches $v$ using the ranking given by $\sigma$ (first try $f$, if not try $(f+1) \mod n$, etc.). \EndFor \end{algorithmic} \end{algorithm} \begin{algorithm}[!t] \caption{Left-right Ranking} \begin{algorithmic}[1] \For{$i=0$ to $n-1$} \State Let $v$ be the $i$th online vertex and let $d = \mbox{deg}(v)$ (counting matched offline vertices). \State Let $\sigma = \left\{ \begin{array}{ll} (0,1,\ldots,n-1) & \mbox{if } i+d \mod 2 = 0 \\ (n-1,n-2,\ldots,0) & \mbox{otherwise} \end{array} \right.$. \State The algorithm matches $v$ using the ranking given by $\sigma$. \EndFor \end{algorithmic} \end{algorithm} \begin{algorithm}[!t] \caption{Least-seen} \begin{algorithmic}[1] \For{$i=0$ to $n-1$} \State Let $v$ be the $i$th online vertex. \State The algorithm matches $v$ to the neighbour that has occurred the least so far (breaking ties arbitrarily). \EndFor \end{algorithmic} \end{algorithm} For every algorithm $\mathbb{A}$ and every $n$, we consider every possible bipartite graph with $n$ online vertices and $n$ offline vertices. For each graph, we consider all permutations of the online vertices. This yields a ratio $r(\mathbb{A}, n)$: the minimum over all the graphs of the average over all permutations of the performance of the algorithm on the permuted graph, divided by the optimal matching size. Recall that for $n=2$, $0.75$ is optimal for deterministic algorithms. Because the number of bipartite graphs grows exponentially and for each graph all permutations are considered, we limit ourselves to $n \leq 6$ due to the computational resources needed. Table \ref{detROM} contains the results. \begin{table}[h!] \centering \caption{Experimental results for deterministic ROM algorithms} \label{detROM} \begin{tabular}{l|llll} \textbf{n} & \textbf{Fixed Ranking} & \textbf{Cyclic Ranking} & \textbf{Left-right Ranking} & \textbf{Least-seen} \\ \hline \textbf{3} & 0.7222 & 0.7222 & 0.7778 & 0.7222 \\ \textbf{4} & 0.6979 & 0.7292 & 0.7292 & 0.6875 \\ \textbf{5} & 0.6850 & 0.7100 & 0.7267 & 0.6817 \\ \textbf{6} & 0.6762 & 0.7023 & 0.7069 & 0.6722 \end{tabular} \end{table} The table shows how Cyclic Ranking and Left-right Ranking seem to be beating Fixed Ranking for all $n$ (except possibly tying for $n=3$). Despite having lower performance than Fixed Ranking, we decided to include Least-seen because it seemed like a natural candidate, giving priority to offline vertices that have not been seen much, because most likely they have lower degree and thus less chance of being matched and because this somewhat corresponds to our intuition about what gave Ranking an advantage over Random in the online world. However the results seem to indicate it does not do very well against worst-case input. The most interesting question is whether there is an algorithm with asymptotic approximation ratio greater than $1-1/e$, but the fact that Fixed Ranking is not optimal for every $n$ gives hopes for a positive answer. For unweighted matching, without loss of generality we can restrict attention to greedy algorithms, that is those that will always make a match whenever it encounters a data item where the vertex has available neighbours. \section{Conclusion and Open Problems} \label{sec:conclusions} We considered bipartite matching in the width, priority and ROM models. By observing that non-uniform max-of-$k$ and advice results are equivalent, it follows that polynomially many online matchings are enough to achieve an approximation ratio arbitrarily close to $1-1/e$ while exponentially many online matchings are required to achieve an approximation ratio greater than $1-1/e$. We turned to the question as to how large $k$ needs to be so that max-of-$k$ or width-$k$ algorithms can obtain an approximation ratio greater than $1/2$. We showed that if $k$ is constant then width-$k$ algorithms cannot achieve this. By analysing the proof more closely, we noticed that in fact max-of-$\frac{\log n}{\log \log n}$ is not enough. This gave new lower bounds for bipartite matching with advice. However, there is still a gap between our inapproximation bound and the non-uniform max-of-$n^{O(1)}$ algorithm that de-randomizes Ranking (see Theorem~\ref{WidthUppLow}). This algorithm is unsatisfactory because it requires exponential time pre-calculation. The main open problem then is whether or not a uniform and efficient polynomial width online algorithm is possible for online bipartite matching. We offered some possibilitiees in this regard. The study of width bipartite matching in the PBT model \cite{Alekhnovich2011a} is left as future work. With regard to the ROM and priority models, we showed that deterministic priority algorithms cannot improve upon the $\frac{1}{2}$ approximation achieved by any greedy maximal matching algorithm for matching. The situation for randomized priority algorithms remains quite unclear as to whether or not the KVV randomized online Ranking algorithm $1-\frac{1}{e}$ approximation can be improved upon. We give an example showing why the analysis of such algorithms is subtle. It is also the case that biparttite online matching is not completely understood in the ROM model. In particular, what is the precise approximation for the randomized KVV algorithm in the ROM model and is it an optimal algorithm in this regard? And what is the approximation ratio for the Random algorithm in the ROM model? Another problem that has been studied extensively and has important theoretical and practical interest is max-sat. We considered this problem in the width models. The problem itself has multiple possible input models, and it has generalizations such as submodular max-sat. In input model 1, where the algorithm knows the weights and lengths of clauses in which the variable being processed appears (both positively and negatively), we gave an efficient linear width algorithm achieving a $3/4$ approximation ratio by using very similar techniques to those in the deterministic algorithm with approximation ratio $1/2$ for unconstrained submodular maximization \cite{Buchbinder2016}. We showed that, to achieve an approximation ratio greater than $3/4$, exponential width (in the width-cut model) is required, even with input model 2. In input model 0, where the algorithm only knows the weights of clauses in which the variable being processed appears, we showed that deterministic constant width cannot achieve an approximation ratio of $2/3$, so having either the length of clauses or randomization is essential; Johnson's deterministic algorithm and the randomized algorithm that assigns a variable with probabilities proportional to weights both achieve an approximation ratio of 2/3 \cite{Johnson} \cite{Azar2011a}. In the strongest input model, where the algorithm receives a complete description of the clauses in which the variable appears, we showed an exponential lower bound on the width-cut necessary to get an approximation ratio greater than $5/6$. This should be contrasted with the exponential lower bound on the width needed by a pBT algorithm to get an approximation ratio better than $21/22$ \cite{Alekhnovich2011a}. For input model 3, there is clearly a large gap between the online polynomial width $\frac{3}{4}$ approximation and the proven inapproximation for the pBT width model. The question of limitations of randomized priority algorithms has not been studied to the best of our knowledge. Two (and multiple) pass algorithms provide another interesting extension of online (or priority) algorithms. The determinstic two-pass online algorithms for max-sat (\cite{Polo2pass}) and biparitite matching (\cite{Durr2016a}) provably improves upon the known bounds for deterministic one pass algorithms against an adevrsarial input. The ultimate goal is to see to what extent ``simple combinatorial algorithms'' can achieve approximation ratios close to known hardness results and in doing so can come close to or even improve upon the best known offline algorithms. Part of this agenda is to better understand when and how one can de-randomize online algorithms. \bibliographystyle{siam}
{'timestamp': '2016-08-11T02:07:43', 'yymm': '1608', 'arxiv_id': '1608.03182', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03182'}
arxiv
\section{Introduction} The internet has precipitated an explosion of shared user-generated content, with unrestrained access to edit boxes from barely vetted online community members. While this freedom is a boon to many websites, it can lead to abuse if content is inappropriate to the context or viewership. Unfortunately, massive volume makes manual moderation impractical. If inappropriate content is to be flagged or censored automatically, identifying keywords may be insufficient. Neither innuendo, ever changing slang, nor misspellings can be detected by finite lists of words, which themselves may vary in offensiveness depending on context. A further complication is the paucity of {\em annotated} inappropriate data. In this work, we present a large corpus of narrative content published in the online community Wattpad, augmented by crowd-sourced annotations. While those annotations are {\em relatively} sparse, they provide an opportunity to explore this domain using both unsupervised and partially-supervised methods. This paper provides a preliminary exploration of these data using latent Dirichlet allocation (LDA) and an extension, partially-labeled Dirichlet allocation (PLDA), in order to take advantage of the newly acquired labels. Specifically, the texts are classified according to their degree of inappropriateness in three separate categories: sex, violence, and substance abuse. Our goals are to determine a) whether LDA can be adapted for inappropriateness detection on narrative data, and b) whether PLDA can effectively make use of sparse annotations in this domain \section{Background and related work} Little work has been done on automatically detecting inappropriate or offensive content. Thus, major social media websites such as YouTube and Facebook primarily rely on community moderation, in which users ``flag'' inappropriate content which is subsequently dealt with by the organization This approach does not guarantee the timely removal of content Some existing work aimed to detect short offensive or abusive messages called ``flames''. This included the seminal work by \newcite{spertus_smokey:_1997}, who used a 47-element vector of hand-tuned syntactic and semantic features in a decision tree that achieved $\sim{}$65\% flame-detection and 98\% clean-text detection accuracy. \newcite{razavi_offensive_2010} used an adaptive three-tiered classification scheme using a bag-of-words and a dictionary of abusive/insulting words, phrases and expressions. \newcite{mahmud_detecting_2008} also used keywords and shallow syntactic rules. While flames are a subset of inappropriate content, these methods are unable to detect {\em mature} content, which is more related to subject matter and not restricted to short messages. \newcite{chen_detecting_2012} and \newcite{xu_filtering_2010} also use hand-engineered syntactic features and keywords to detect a limited category of \textit{offensive} passages, e.g., by defining offensive text as containing {\em lexical} pejoratives, profanities, or obscenities. Using message-level lexicosyntactic features extracted from relatively short YouTube comments, \newcite{chen_detecting_2012} obtained at most 98.2\% precision and 94.3\% recall, beating $N$-gram models, although this depended on predetermined measures of word-level `offensiveness' and no latent semantics capable of capturing innuendo. While research in this area has been minimal, it falls under the larger umbrella of higher-level unsupervised textual analysis of sentiment, opinion, and subjectivity~\cite{liu_sentiment_2010,razavi_offensive_2010}. Unsupervised methods often rely on word contexts and include methods of determining word embeddings and on topic modelling \cite{blei:latent:2003}. \newcite{xiang_detecting_2012} used a combination of topic modelling and keyword features as input in a few supervised offensiveness classifiers (e.g., SVN, random forest). They `bootstrapped' a set of labelled tweets from known `offensive users' and seed words and found a 5.4\% increase in F1 over the baseline when the number of topics was increased to 50, albeit using only short tweets, and focusing on `bad words' rather than inappropriate {\em content}. \section{Data}\label{sec:Data} Narrative data were shared by Wattpad\footnote{https://www.wattpad.com/}, which is a popular site for social storytelling. These data consist of excerpts from short stories written by members of the community, partitioned into a {\bf Basic} subset from Wattpad's main website ($2,129,156$ excerpts, avg. 931 words/excerpt), and an {\bf AfterDark} subset\footnote{https://www.wattpad.com/afterdark/} intended for ages 17+, and more mature audiences ($47,407$ excerpts, avg. 1597 words/excerpt). For the purposes of this initial analysis, approximately 21,000 excerpts are randomly selected from the former and 10,400 from the latter. These two subsets are then each split equally into training and test sets. Additionally, over 1000 excerpts were each scored by three annotators for mature content using the CrowdFlower crowd-sourcing service\footnote{https://www.crowdflower.com/}. Annotators were asked to identify specific segments within texts which contained ``inappropriate'' or ``mature'' content, along each of three dimensions (sex, substance abuse, and violence) according to the following 4-point scale: \begin{enumerate} \setlength{\itemsep}{-3pt} \item {\bf None}: No inappropriate content. \item {\bf PG}: Mildly suggestive content or language. Not suitable for children or a professional setting. \item {\bf Mature}: Content appropriate only for a mature audience, as in an R-rated movie. \item {\bf Adult/XXX}: Segment contains explicit, graphic, or disturbing content. \end{enumerate} Annotated excerpts were similarly split into training and test sets, with 1/3 of the data comprising the latter. The distribution of ratings in the training and test sets is provided in Table \ref{crowdflower-rating-distribution-table}. Additionally, 289 texts in training and 127 in testing were deemed to be completely appropriate for all audiences. Fleiss' inter-annotator agreement statistic gives $\kappa=0.13,p<0.01$ on sexual content, $\kappa=0.01,p=0.33$ on substance abuse, and $\kappa=0.17,p<0.01$ on violence -- i.e. there was only accidental agreement on the rating of drugs. Pearson's correlation, which is more sensitive to ordinal values than Fleiss, generally agrees, with pairwise annotator agreement $\rho >0.20$ for sex and violence, but $\rho < 0.12$ for substance abuse. \begin{table}[h] \caption{Rating frequencies in annotated data} \label{crowdflower-rating-distribution-table} \centering \small \begin{tabular}{r|rr|rr|rr} \toprule & \multicolumn{2}{c}{Sex}&\multicolumn{2}{c}{Drugs}&\multicolumn{2}{c}{Violence}\\ Rating& Train & Test & Train & Test & Train & Test \\ \midrule 2 & 163& 80 & 56 & 43 & 203 & 131\\ 3& 81& 81& 31& 19& 70 & 57\\ 4 & 12& 9& 3& 8 & 14& 15 \\ \bottomrule \end{tabular} \end{table} \section{Methods} Latent Dirichlet allocation (LDA) is a generative probabilistic model which represents each document as a finite mixture over a set of topics \cite{blei:latent:2003}. The only observed variables in our model are the words, $w_{ij}$, which can be inferred using Gibbs sampling and expectation propagation \cite{blei:latent:2003}, associated with inferred weightings on {\em topics}. The number of topics and smoothing hyper-parameters are empirically selected. Partially-labeled Dirichlet allocation (PLDA) incorporates per-document labels into the topic model of LDA \cite{ramage_partially_2011}. PLDA assumes that each label is associated with some number of topics and that each topic is associated with a single label. Thus, PLDA is appropriate for applications in which labels are comprehensive and indicate distinct content. Like LDA, it associates individual words in a document with topics. While PLDA uses labeled data, topics are still attributed using the same unsupervised approach. It also differs from LDA in that each topic is considered to be an amalgamation of sub-topics. \section{Experiments} First, non-English texts are removed and text is tokenized using the Penn Treebank 3 tokenizer\footnote{http://nlp.stanford.edu/software/tokenizer.shtml}. Punctuation is ignored along with 587 English stop words (e.g., pronouns, conjunctions). Proper names can appear in many of the learned topics, since they are important ``subject'' words. We also discard documents with fewer than 20 words, and consider only tokens which appear in $D$ documents, where $D$ is selected for each experiment empirically. LDA and PLDA were performed using Stanford's topic-modelling toolbox\footnote{http://nlp.stanford.edu/software/tmt/tmt-0.4/}. This implementation does not optimize the term and topic smoothing hyper-parameters, which were both set to 0.01 as suggested by the authors of the toolbox \subsection{LDA on the unannotated corpus} \label{LDA on Wattpad Corpus} In this experiment, LDA is applied to the training sets of {\bf Basic} and {\bf AfterDark} in order to learn a representative set of combined topics. The intention is to determine whether there is a distinction in topics associated with the two categories, and if this distinction is also present in the ``test'' sets. A reasonable way of selecting the number of topics is by using corpus perplexity \cite{blei:latent:2003}. Perplexity is expected to decrease as the number of topics increases. As the model overfits to the training data, the perplexity of the test data is expected to either decrease significantly more slowly or begin to increase; from~\ref{fig:basic-lda-perplexity}, this occurs around $\sim{}$50 topics, so we set $N$ appropriately. Furthermore, the minimum number of documents in which a word may occur is empirically set to 15 in order to reduce proper names from dominating topics in the models with fewer topics. \begin{figure}[h] \centering \includegraphics[width=0.5\textwidth]{lda_perplexity_vs_ntopics.eps} \caption{Perplexity of LDA models on Wattpad training and validation data.} \label{fig:basic-lda-perplexity} \end{figure} Some of the top words associated with each topic are provided in the Supplemental material along with inferred labels. A few observations can be made by `slicing' the output according to the 4-point scale (with the {\bf AfterDark} texts as a fifth point) and considering the per-document topic distribution in each slice. Sixteen topics differ in occurrence by more than 50\% between the topics in the {\bf AfterDark} and {\bf Basic} slices, with six being more prevalent in {\bf AfterDark} including body/sexual (e.g., {\em hips}, {\em hard}), interaction (physical and otherwise, e.g., {\em hands}, {\em feel}), and `crushing' (e.g., {\em moment}, {\em stared}). \subsection{PLDA on the annotated corpus}\label{sec:PLDA} The previous experiment relied on Wattpad's keyword-based rating system, which may not capture latent obscenity. In this section, we provide crowd-sourced annotations to PLDA for each text, consisting of the four labels of degree (see section \ref{sec:Data}) provided by the annotators. Following \newcite{miuraTopic}, the `appropriate' label is added to the set for each unlabeled text since annotators did not label them otherwise. This provides texts with explicit `appropriate' labels, similar to using a single latent topic, which can appear in all documents. Here, we explore the space for the three hyper-parameters using grid-search, specifically the minimum number of documents per allowable token (min-doc) $\in \{1,5,10,15\}$, the number of background topics (n-bg) $\in \{0,1,5,10\}$, and the number of topics per rating category and level (n-label) $\in \{1,5,10\}$. Table \ref{classification-results-table-threshold-05} shows the precision, recall, specificity, and F1 score, averaged over level, for each category, using a threshold of 5\% (there was no significant effect of moving this threshold from 0.1\% to 10\%). Recall is generally in-line with previous work, albeit on a more challenging task of topic modelling, rather than keyword spotting. Across all parameters, precision is <52\%, as labels for inappropriateness tend to be over-applied. This is especially true for the `drugs' category, for which there are the fewest examples. Although not shown, the distribution of error rates over the individual rating levels indicates that errors arise predominantly from level 4 (i.e., highly inappropriate). Since this analysis treats the labels as nominal, interchangeable classes rather than lying on a continuum, we also perform a regression analysis in the next section. \begin{table*}[h!] \centering \caption{PLDA model classification results for aggregated rating levels, threshold=5\%} \label{classification-results-table-threshold-05} \makebox[\linewidth]{ \small \begin{tabular}{llllllllllllll} \toprule & Bg-topics & 0 & & & 1 & & & 5 & & & 10 & & \\ & N-topics & 1 & 5 & 10 & 1 & 5 & 10 & 1 & 5 & 10 & 1 & 5 & 10 \\ \midrule \multirow{ 4}{*}{sex} & Precision & {\textbf{0.36}} & 0.33 & 0.32 & 0.34 & 0.32 & 0.33 & 0.31 & 0.32 & 0.32 & 0.35 & 0.33 & 0.33 \\ & Recall/Sensitivity & 0.75 & 0.89 & {\textbf{0.96}} & 0.71 & 0.88 & 0.91 & 0.5 & 0.8 & 0.9 & 0.56 & 0.81 & 0.88 \\ & Specificity & 0.41 & 0.19 & 0.1 & 0.4 & 0.18 & 0.16 & 0.51 & 0.23 & 0.15 & {\textbf{0.53}} & 0.28 & 0.22 \\ & F1 & 0.48 & 0.48 & 0.48 & 0.46 & 0.47 & 0.48 & 0.38 & 0.43 & 0.47 & 0.43 & 0.47 & {\textbf{0.49}} \\ \midrule \multirow{ 4}{*}{violence} & Precision & 0.5 & 0.5 & 0.48 & {\textbf{0.52}} & 0.49 & 0.48 & 0.5 & 0.48 & 0.48 & 0.49& 0.48 & 0.49 \\ & Recall/Sensitivity & 0.79 & {\textbf{0.94}} & 0.92 & 0.77 & 0.93 & 0.92 & 0.6 & 0.86 & 0.91 & 0.56 & 0.82 & 0.9 \\ & Specificity & 0.31 & 0.18 & 0.13 & 0.37 & 0.15 & 0.13 & 0.49 & 0.18& 0.16 & {\textbf{0.5}} & 0.25 & 0.2 \\ & F1 & 0.61 & {\textbf{0.65}} & 0.63 & 0.62 & 0.64 & 0.63 & 0.55 & 0.61 & 0.63 & 0.52 & 0.61 & 0.63 \\ \midrule \multirow{ 4}{*}{drugs} & Precision & 0.2 & 0.21 & 0.19 & 0.21 & 0.22 & 0.2 & 0.18 & 0.2 & 0.22 & 0.18 & 0.21 & {\textbf{0.23}} \\ & Recall/Sensitivity & {\textbf{0.68}} & 0.57 & 0.46 & {\textbf{0.68}} & 0.6 & 0.43 & 0.52 & 0.48 & 0.44 & 0.43 & 0.49 & 0.43 \\ & Specificity & 0.35 & 0.51 & 0.55 & 0.38 & 0.5 & 0.6 & 0.45 & 0.55 & 0.62 & 0.55 & 0.56 & {\textbf{0.67}} \\ & F1 & 0.31 & 0.31 & 0.27 & {\textbf{0.32}} & {\textbf{0.32}} & 0.27 & 0.27& 0.28 & 0.29 & 0.25& 0.29& 0.3\\ \bottomrule \end{tabular} } \end{table*} \subsection{Regression on ratings} An eventual aim of this work is to automatically provide meaningful ratings for each of sexual, violent, and drug-abuse content, to be used in practice. For this experiment, we trained multilinear regressors for each PLDA model, for each of {\em sex}, {\em drugs}, and {\em violence} separately using support vector machines with stochastic conjugate gradient descent Table \ref{tab:regressResults} shows the absolute distance between inferred and average human ratings, for each category. The weighted average multiplies the contribution of each rating error by the inverse of that rating's prevalence in the data; e.g., `appropriate' texts were weighted lower, since there were more of them in the data. The table also shows a `total' row which selects the best PLDA model by averaging the errors for each rating and the average error across rating levels (i.e., each column in the table) for the sex, drugs, and violence regressors trained on that PLDA model. The classification rates are clearly lowest for the extremes of rating levels 1 and 4. Overall, the regression gives absolute errors $<1$ for each of the three categories of content; while promising, future work with more annotated data and non-linear models is recommended. \begin{table}[h!] \small \begin{tabular}{rc | rrrr | r} \hline & $n_{topics}$ & $1$ & $2$& $3$ &$4$& W.Avg.\\ \hline sex & 9 & 1.74 & 0.69 &0.34 &1.19 &0.77 \\ viol. & 20 & 1.55 & 0.53 &0.47 &0.65 &0.73 \\ drugs & 19 & 1.42 & 0.44 &0.54 &0.91 &0.83 \\ \hline Total & 19 & 1.5 &0.48 &0.55 &1.34 &0.77 \\ \hline \hline \end{tabular} \caption{Lowest absolute error between inferred and average human ratings, for each category, including associated $n_{topics}$. } \label{tab:regressResults} \end{table} \section{Discussion and Conclusion} These pilot studies in topic modelling and regression demonstrate promise in the automatic detection of inappropriateness beyond mere keyword spotting. Using unsupervised LDA, as in section \ref{LDA on Wattpad Corpus}, appears to distinguish subject matter that could easily be related to inappropriate content, as indicated by the identification of latent {\em topics}. The {\em degree} to which a topic-based model identifies inappropriate passages missed by simplistic keyword spotting is the subject of future work. As is typical, topics are open to qualitative interpretation, and additional manual validation is required. To a large extent, this work is incomparable to previous work since it is the first in this space to capture latent semantics. PLDA obviates the need for some manual confirmation, and is largely successful, as it allows for label information to be directly incorporated into the model, which guides topic selection. From the classification results of section \ref{sec:PLDA}, it appears as though models benefit from the ability of PLDA to associate multiple topics with a single label. These models accurately identify inappropriate content in test data for both sex and violence, with some over-estimation. This may partially be due variance in crowd-sourced annotations, as indicated by Fleiss $\kappa$ statistics below 0.2 in all cases (section \ref{sec:Data}). Further exploration in topic modelling of inappropriate content should aim to reduce false positive rates. The PLDA model may also be incorporated into a larger model that incorporates uncertainty into the provided labels. Expanding the set of annotated data may also yield further improvements, and methods of bootstrapping, potentially starting with the LDA results, may be useful in overcoming the lack of such data. Regardless, the LDA-approach provides a reasonable baseline for further explorations and model development for the automatic detection of inappropriate latent topics in narrative content. \bibliographystyle{emnlp2016}
{'timestamp': '2016-08-12T02:06:35', 'yymm': '1608', 'arxiv_id': '1608.03448', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03448'}
arxiv
\section{Introduction} Eye-tracking based research in radiology can be categorized into two main groups. First group of research focuses on psychological viewpoint (e.g. examining attentional behavior) such as the early work of Just et al.~\cite{just1980theory}. Relevant to medical imaging field, most of these studies have been accomplished to understand radiologists' visual search patterns, differences of search patterns, and expert and non-expert visual search discriminations~\cite{mallett2014tracking}. The second group considers eye-tracking as an interaction tool with computers. For instance, Ware et al\cite{ware1987evaluation} used eye-tracker information as an input to perform a predefined task in the computer. In a different study, Sadeghi et al.~\cite{sadeghi2009hands} showed the advantage of using eye-tracking over using mouse clicks as an interaction tool for segmentation task in general. Despite significant advances in human-computer interaction, the use of eye-tracking technology to perform image analysis tasks in radiology remains \textit{largely} untouched. In this study, we propose a pilot system that uses gaze information from the eye-tracker as an input to perform \textit{a fully automatic} image segmentation for radiology scans. To the best of our knowledge, this is the first study integrating biological and computer vision methods synergistically to conduct a quantitative medical image analysis task. The integration of the proposed algorithm, \textit{\textbf{Gaze2Segment}}, into the eye-tracker system is illustrated in Figure~\ref{fig:eyetrackingsystem}. \begin{figure} \centering \includegraphics[scale=0.32]{eyetrackingoverview.pdf} \caption{Overview of the integrated eye-tracking and \textit{\textbf{Gaze2Segment}} system} \label{fig:eyetrackingsystem} \end{figure} Our motivation for the use of eye-tracking in medical image segmentation task lies in the following facts. The segmentation process includes two relevant (and complementary) tasks: \textit{recognition} and \textit{delineation}~\cite{bagci2012hierarchical}. While delineation is the act of defining the spatial extent of the object boundary in the image, recognition (i.e., localization or detection) is the necessary step for determining roughly where the object is. Automatic recognition is a difficult task; hence, manual or semi-automated methods are often devised for this purpose. Available automatic recognition methods usually employ an exhaustive search or optimization. \textit{We postulate herein that eye-tracking can be used as an effective recognition strategy for the medical image segmentation problems.} Towards this aim, we developed the \textit{\textbf{Gaze2Segment}} consisting of the following five major steps, as illustrated in Figure~\ref{fig:overview}: \begin{itemize} \item \textbf{Step 1:} Real-time tracking of radiologists' eye movements for extracting gaze information and mapping them into the CT scans (i.e., converting eye tracker data into image coordinate system). \item \textbf{Step 2:} Jitter Removal for filtering out the unwanted eye movements and stabilization of the gaze information. \item \textbf{Step 3:} Creating visual attention maps from gaze information and locating object of interest from the most important attention regions. \item \textbf{Step 4:} Obtaining computer-derived local saliency and gradient information from gray-scale CT images to identify foreground and background cues for an object of interest. \item \textbf{Step 5:} Segmenting the object of interest (identified in step 3) based on the inferred cues (identified in Step 4). \end{itemize} \begin{figure}[h] \includegraphics[scale=0.27]{overview.png} \caption{\textit{\textbf{Gaze2Segment}} has five steps to perform a segmentation task. Input is inferred from the eye-tracking data (see Figure 1).\label{fig:overview}} \end{figure} \section{Method} \subsection*{Step 1: Eye-Tracking and Extracting Gaze Information} We have used MobileEye XG eye-tracker technology (ASL, Boston, MA) to build our system (Figure~\ref{fig:eyetrackingsystem}). This device has eye and scene cameras that attach to the glasses (or an empty frame in case the participating radiologist already has eye glasses). The two cameras are adjustable to fit different users' settings. While the eye camera records the eye movements, the scene camera (second camera, directed forward) records the monitor being observed by the radiologist at $60$Hz of data rate. The eye camera monitors the pupil orientations and reflective angle using corneal reflection of $3$-infrared dots on the eye from a reflective mirror. These dots are transparent to visible spectrum and nothing obscures the radiologists' field of view. The data from these two cameras were transferred into a workstation through a mobile display/transmit unit using an ethernet cable in real-time. Then, points of gaze were computed on the scene video, which was recorded at 60 frames per second. A calibration needs to be performed by the radiologist before every image reading experiment to match the eye movement data and the $640\times 480$ scene video. The system outputs pupil diameter and gaze coordinates with respect to the scene camera's Field Of View (FOV) on a \textit{.csv} file with timestamps (Figure~\ref{fig:eyetrackingsystem}). Once the calibrated gaze coordinates, scene video, and timestamp were created, gaze coordinates on the scene video ($g^{v}$) were converted onto the gaze coordinates on the stimulus ($g^{s}$). Our pilot study focuses on a realistic scan evaluation by a radiologist without inserting any environmental or psychological constraints. As a part of this realistic experiment in a dark reading room, we have collected chest CTs pertaining to patients diagnosed with lung cancer. Unlike relatively simpler experiments with X-Rays, there are numerous slices to evaluate in 3D CTs. In addition, radiologists may visit the same slice more than once during their reading, including changing the image views into axial, coronal, and sagittal sections. To mitigate these, an image viewer plugin was developed to be integrated into the open source MIPAV image analysis software \cite{mcauliffe2001medical}. The plugin simply records mouse manipulations including scrolling, contrast change, and button clicks with the associated timestamps. \subsection*{Step 2: Jitter Removal and Gaze Stabilization} Eye-tracking data naturally contains jittery noises. While looking at a single object, users normally believe that they look at the object steadily. However, eyes have small jittery movements that causes the gaze location to be unstable. Using such noisy data can create uncertainties in image analysis tasks. In order to remove jitter, while preserving global gaze patterns, a new smoothing operator ($J$) was formulated as follows. Since gaze coordinates on the stimulus ($g^{s}$) included a set of points on $xy$-coordinate system (i.e., planar), Euclidean distance between any consecutive coordinate points could be used for smoothing as values that fall within the small distance neighborhood were eliminated: $$\text{if } || g^{s}(i)-g^{s}(i+1)|| \leq \varepsilon,$$ then, $g^{s}(i)$ is set to $g^{s}(i+1)$, where $i$ indicates the gaze points in an order they have been looked at by the user, and $\varepsilon$ was a pre-defined distance (based on the empirical evaluation of experimental data) and set as 7.5 mm, meaning that all the pixels within $\varepsilon$-neighborhood of $i$ were considered to be pertaining to the same attention regions. \subsection*{Step 3: Visual Attention Maps} There are two major visual search patterns identified so far that radiologists normally follow for reading volumetric radiology scans: \textsl{drilling} and \textsl{scanning}\cite{drew2013scanners}. While \textsl{drillers} spend less time on a single area in an image slice and tend to scroll fast between slices (backward and forward), \textsl{scanners} spend more time on examining a single slice and then move to the next slice. Thus, it's a valid hypothesis that radiologists spend more time on the regions that are more suspicious to them. Hence, the possibility of abnormality presence in those areas is higher compared to the other regions. This fact can be used to perform an image analysis task in suspicious areas of radiology scans. % Considering the above mentioned information, as well as the theory of \textit{Von Helmholtz}, claiming that eye movements reflect the will to inspect interesting objects in fine detail although visual attention can still be consciously directed to peripheral objects\cite{von2005treatise}, we used the time information (from timestamp on the data) to create visual attention map by encoding the regions to which radiologists divert their attention more than other regions. The time spent on a specific area might be different between drillers and scanners but the time that is spent on potentially abnormal areas is still \textit{relatively higher} than other areas for a specific user regardless of the search method. These reasons make the time a reliable factor to derive an attention map. For each gaze point on the stimulus $g^{s}(i)$, an attention value $a(i)\in [0,1]$ was created by mapping the corresponding timestamp $t(i)$ of the gaze coordinate in piece-wise linear form as follows: \begin{equation} a(i)=\left\{\begin{array}{lr} \frac{t(i) - \hat{t} }{t_{max}-\hat{t}}, & t(i) > \hat{t},\\ 0, & \textrm{otherwise,} \end{array} \right. \label{eqn:threshold} \end{equation} where $t_{max}={argmax_i }$ $t(i)$ and $\hat{t}$ can be set into 0 in order to assign an attention value for every gaze coordinate. For practical reasons, since many gaze coordinates may have very small timestamps (i.e., in milliseconds), those gaze coordinates can be removed from the analysis by setting a larger $\hat{t}$. \subsection*{Step 4: Local Saliency Computation for sampling Foreground/Background Cues} In biological vision, humans tend to capture/focus on most salient regions of an image. In computer vision, many algorithms have been developed to \textit{imitate} this biological process by defining a \textit{saliency} concept with different context. The mostly used definition of saliency is based on the distinctiveness of regions with respect to their local and global surroundings. Although this definition is plausible for many computer vision tasks, it alone may not be suitable for defining salient regions in radiology scans where object of interests are not often as distinctive as expected. In addition, radiologists use high level knowledge or contextual information to define regions of interest. Due to all these reasons, we propose to use a \textit{context-aware saliency} definition that aims at detecting the image regions based on contextual features\cite{goferman2012context}. In our implementation, we extracted image context information by predicting which point attracts the most attention. This step combines radiologist's knowledge with image context. The context-aware saliency explains the visual attention with feature-driven four principles, three of which were implemented in our study: (1) local low-level considerations, (2) global considerations, (3) visual organization rules, and (4) high-level factors. (1) For local low-level information, image was divided into local patches ($p_u$) centered at pixel $u$, and for each pair of patches, their distance ($d_{position}$) and normalized intensity difference ($d_{intensity}$) were used to assess saliency of a pixel $u$, as formulated below: \begin{equation} d(p_{u},p_{v})=d_{intensity}/(1+\lambda d_{position}), \label{eqn:saliency} \end{equation} where $\lambda$ is a weight parameter. Pixel $u$ was considered \textit{salient} when it was highly dissimilar to all other image patches, $d(p_{u},p_{v})$ is high $\forall v$. (2) For global considerations, a scale-space approach was utilized to suppress frequently occurring features such as background and maintain features that deviate from the norm. Saliency of any pixel in this configuration was defined as the average of its saliency in $M$ scales $\lbrace (r_{1},r_{2},...,r_{M}), r\in R \rbrace$: \begin{eqnarray} \bar{S_{u}}=(1/M)\sum _{r\in R}S_{u}^{r}\\ S_{u}^{r}=1-exp\lbrace-(1/K)\sum _{k=1}^{K}d(p_{u}^{r},p_{v}^{r})\rbrace & \text{ for} & (r\in R). \end{eqnarray} This scale-based global definition combined $K$ most similar patches for the saliency definition and indicated a more salient pixel $u$ when $S_{u}^{r}$ was large. (3) For visual organization rules, saliency was defined based on the Gestalt laws suggesting areas that were close to the foci of attention should be explored significantly more than far-away regions. Hence, assuming $d_{foci}(u)$ is the Euclidean distance between pixel $u$ and the closest focus of attention pixel, then the saliency of the pixel was defined as $\hat{S_{u}}=\bar{S_{u}}(1-d_{foci}(u))$. A point was considered as a focus of attention if it was salient. (4) High-level factors such as recognized objects can be applied as a post processing step to refine saliency definition. In our current implementation, we did not apply this consideration. Since we inferred \emph{where} information of object of interest from visual attention map (Step 3), we only explored \emph{what} part of object of interest from saliency definition. Once saliency map was created, we confined our analysis into the regions indicated by corresponding visual attention maps ($a(u)$). Since saliency map included object of interest information, we extracted foreground information from this map (called foreground cues/seeds) by simply setting the most salient pixel in this region as a foreground cue. This step helped relocating the attention gaze exactly to the center of the closest most salient object and allowed a perfect seed selection. Furthermore, we defined the background cues for a given local region, indicated by the visual saliency map, as follows. We first computed the gradient information $\nabla I$ from a gray-scale CT image $I$. For a given visual attention map $a(u)$ and saliency map $S(u)$ at the pixel $u$, we employed a search starting from $\nabla I(u)$ and moving into 4 perpendicular directions. Our search was stopped soon after we passed through a high intensity value on the gradient image because object boundaries show high gradient values. Those four pixels found outside the object boundary were considered as background cues. This process is illustrated in Figure~\ref{fig:seed}. \begin{figure} \centering \includegraphics[scale=0.35]{seedsampling.png} \caption{Foreground (FG) regions were obtained from visual attention maps processed from gaze information. After this \textit{recognition} step, we identify most distinct FG seed by using the corresponding regions of saliency map. Once FG seeds are allocated, background (BG) seeds are found by using gradient information of the gray-scale CT image. For each FG seed, four perpendicular directions are searched and edge locations are used to select BG seeds. \label{fig:seed}} \end{figure} \subsection*{Step 5: Lesion Segmentation} After identifying background and foreground seeds, any seed-based segmentation algorithm such as graph-cut, random walk (RW), and fuzzy connectivity, can be used to determine precise spatial extent of the object of interest (i.e., lesion). In our work, we choose to implement RW as it is fast and robust, and offers optimal image segmentation for a given set of seed points. Details of the conventional RW image segmentation algorithm can be found in~\cite{grady2006random}. \section{Results} We tested our system on four chest CT volumes pertaining to patients diagnosed with lung cancer, evaluated by three radiologists having different levels of expertise. In-plane resolution of the images is $512 \times 512$ with a voxel size of $0.58\times0.58\times1.5$ $mm^3$. Imaging data and corresponding lesion labels as well as annotations were obtained from Lung Tissue Research Consortium (LTRC) (\url{https://ltrcpublic.com/}) with an institutional agreement. Blind to diagnostic information of the chest CT scans, the radiologists read the scan once, and interpret the results in routine radiology rooms. Participating radiologists have more than 20, 10, and 3 years of experiences, respectively. This variability in experience levels allowed us to test robustness of our system. As shown by results regardless of user experience and pattern of gaze and attention, our system perfectly captured the attention gaze locations and performed the segmentation successfully. Figure~\ref{fig:qualitative} shows the proposed system's visual attention map, local saliency map, foreground/background seed samples, and segmentation results at different anatomical locations. For quantitative evaluation of segmentation results, we used reference standards from LTRC data set in addition to an independent evaluation by one of the participating radiologists (through manual annotations). We have used dice similarity coefficient (DSC) and Haussdorff Distance (HD) to evaluate accuracy of segmentation results on two reference standards. The average DSC was found to be $86\%$ while average HD was $1.45$ mm. We did not find statistically significant difference between segmentation results when manual seeding and interactive RW were used (t-test, $p>0.05$). \begin{figure} \centering \includegraphics[scale=0.35]{evaluation.pdf} \caption{Qualitative evaluation of medical image segmentation through \textit{\textbf{Gaze2Segment}} system is illustrated. Last column shows the segmentation results zoomed in for better illustration. \label{fig:qualitative}} \end{figure} Figure~\ref{fig:gaze} shows a comparison of gaze and attention maps for two sample slices of the chest CT volume screened by participating radiologists. How the attentional points are distributed over the lung CT volume is arguable based on the experience levels of the radiologists. As Figure~\ref{fig:gaze} illustrates, the less experienced the radiologist is(radiologist 3), the larger the volume of search is compared to the expert radiologists (radiologist 1 and 2). For the selected slices, radiologists' gaze patterns are mapped on the images to compare radiologists' attention patterns in Figure~\ref{fig:pattern}. While attention/search patterns seem to be distinct in the first image, pathological regions (in the second image) have overlapped attentional points among radiologists. \begin{figure} \centering \includegraphics[scale=0.650]{expertvsnave.pdf} \caption{Qualitative comparison of attention and gaze maps is illustrated. \label{fig:gaze}} \end{figure} \begin{figure} \centering \includegraphics[scale=0.65]{pattern.pdf} \caption{Comparisons of gaze patterns pertaining to participating radiologists. Second image has district pathological regions, having overlapped attentional points by all radiologists while first image has distinct attentional patterns. \label{fig:pattern}} \end{figure} \section{Discussion} Since our work is a pilot study, there are several limitations that should be noted. First, we used a limited number of imaging data to test our system. However, it should be noted that gathering a large number of imaging data with corresponding eye-tracking information is a time consuming task. With that said, our team is working on gathering more imaging and eye-tracking data to extend experiments for our future studies. Second, there were several region of interests (non-lesion based) identified and segmented with the proposed system as potential lesion locations. It is because the visual attention information indicated that the radiologists spent several seconds on those regions, and our system naturally considered those regions as potential lesion locations. This can be solved by two ways: allowing the expert to eliminate those false positives interactively, or including a computer-aided detection system helping to remove such objects automatically. Third, although the proposed system is derived from the solid theory of biological and computer vision, there may be additional computational tunings necessary. When different organs and imaging modalities are in consideration for a similar radiology reading experience, methods presented herein should be trained and tuned based on the imaging characteristics and saliency definition. Despite the challenges that might appear due to modality differences, our system has the potential for addressing such difficulties. Fourth, the system parameters such as $\varepsilon$ or $\hat{t}$ are selected empirically. A more reliable and data-driven approach could replace this manual step. Fifth, the segmentation is performed off-line after the data is recorded. Performing the whole process online and during the reading experience in radiology rooms is the future goal. Our initial results on this pilot study add sufficient evidences towards this realistic and innovative goal. \section{Conclusion} In this paper, an automated eye-tracking system was integrated into a medical image segmentation process. For this task, we have successfully combined biological and computer vision techniques for the first time in radiology scan reading setting. We used radiologist's gaze information to extract visual attention map and then complement this information with the computer derived local saliency information from radiology images. By utilizing these two information, we first sampled object and background cues from a region of interest indicated by the eye-tracking and performed a medical image segmentation task. By this way, we proved that gaze information can be used effectively to address the recognition problem of image segmentation, causing a real-time quantification of radiology scans. Our main contribution is to combine biological vision and attention information with image context through saliency map. This has been achieved to perform a quantitative analysis of medical scans during the reading experience and without the need for any further interaction from the user side. \bibliographystyle{unsrt}
{'timestamp': '2016-08-11T02:09:00', 'yymm': '1608', 'arxiv_id': '1608.03235', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03235'}
arxiv
\section{Introduction and Motivation} The \mbox{OpenSHMEM} communications library is designed for computer platforms using Partitioned Global Address Space (PGAS) programming models \cite{Chapman}. Historically, these were large Cray supercomputers, but now the \mbox{OpenSHMEM} interface may also be used on commodity clusters. The Adapteva Epiphany architecture represents a divergence in computer architectures typically used with \mbox{OpenSHMEM} and is just one of many emerging parallel architectures that present a challenge in identifying effective programming models to exploit them. While some researchers may be considering how the \mbox{OpenSHMEM} API may interact with coprocessors, the work presented here leverages the API for device-level operation. In some aspects, the Epiphany architecture resembles a symmetric multiprocessing (SMP) multi-core processor with a shared off-chip global memory pool. However, each core can directly address the private address space of neighboring cores across an on-chip 2D mesh network. Thus, the architecture also has the characteristics of a PGAS platform. Previous proof-of-concepts demonstrated that message passing protocols could achieve good application performance on the Epiphany architecture \cite{Richie2015}, \cite{Implementing2016}. However, it was unclear if the \mbox{OpenSHMEM~1.3} standard could be fully implemented within the platform limitations and achieve high performance using a standard programming model without resorting to non-standard software extensions. Existing open source \mbox{OpenSHMEM} implementations are inadequate within the constraints of the Epiphany architecture, so a new C language implementation named \emph{ARL \mbox{OpenSHMEM} for Epiphany} was developed from scratch. The design emphasizes a reduced memory footprint, high performance, and simplicity, which are often competing goals. This paper discusses the Epiphany architecture in Sect. \ref{ssec:epiphany}, the \mbox{OpenSHMEM} implementation and performance evaluation in Sect. \ref{sec:implementation}, and a discussion of future work and potential standard extensions for embedded architectures in Sect. \ref{sec:future}. \section{Background} \label{sec:background} The 16-core Epiphany-III coprocessor is included within the \$99 ARM-based single-board computer and perhaps represents the low-cost end of programmable hardware suitable for SHMEM research and education. Many universities, students, and researchers have purchased the platform with over 10,000 sales to date. Despite this, programming the platform and achieving high performance or efficiency remain challenging for many users. Like GPUs, the Xeon Phi, and other coprocessors, typical applications comprise host code and device code. Only a minimal set of communication primitives exist within the non-standard Epiphany Hardware Utility Library (eLib) for multi-core barriers, locks, and data transfers \cite{esdkgithub}. The barrier and data transfer routines are not optimized for low latency. Other primitives within eLib use unconventional 2D row and column indexing, which cannot easily address arbitrary numbers of working cores or disabled cores. More complicated collectives, such as those in the \mbox{OpenSHMEM} specification, are left as an exercise for the application developer. Although not discussed in detail in this paper, the CO-PRocessing Threads (COPRTHR) 2.0 SDK \cite{COPRTHR2} further simplifies the execution model to the point where the host code is significantly simplified, supplemental, and even not required depending on the use case \cite{Advances2016}. There are essentially two modes of possible execution. The first mode requires host code with explicit Epiphany coprocessor offload routines. The second mode uses a host-executable coprocessor program with the conventional main routine provided. The program automatically performs the coprocessor offload without host code. Combined with the work presented in this paper, the \mbox{COPRTHR~2.0} SDK enables many \mbox{OpenSHMEM} applications to execute on the Epiphany coprocessor without any source code changes. Execution occurs as if the Epiphany coprocessor is the main processor driving computation. COPRTHR~1.6 was used to present the Threaded MPI model for Epiphany \cite{Richie2015} as well as a number of applications \cite{HPEC2015}, \cite{Ross2016}. \subsection{Epiphany Architecture} \label{ssec:epiphany} Many modern computer architectures address the ``memory wall problem'' by including increasingly complex cache hierarchies and core complexity, wider memory buses, memory stacking, and complex packaging to maintain the SMP hardware and software architecture. The Epiphany architecture unwinds decades of these types of changes -- it is a cache-less, 2D array of RISC cores with a fast network-on-chip (NoC) that can an be simply described as a ``cluster on a chip''. Each core within the Epiphany-III architecture contains 32 KB of SRAM which is shared between instructions and local data. The Epiphany architecture can scale to one megabyte of SRAM per core, but there is a linear design tradeoff between the number of cores and available memory for a fixed die space. The core local memory is memory-mapped, and each core may directly access the local memory of any core within the mesh network. Each core has shared memory access to off-chip global DRAM, although this access is significantly slower than local memory or non-uniform memory access (NUMA) to neighboring core memory. The highest performance and most energy-efficient applications leverage inter-core communication and on-chip data reuse. Like many high performance computing (HPC) clusters, the inter-core communication is generally explicit in order to achieve highest performance. The architecture is also scalable by tiling multiple chips without additional ``glue logic''. The tight coupling between the core logic and the on-chip mesh network enables very low-latency operation of \mbox{OpenSHMEM} routines. An architectural overview appears in Figure~\ref{fig:epiphany}. Unlike most application programming interfaces for communication, there is no additional software layer to handle networking for hardware abstraction. As we will discuss in further detail, the \mbox{OpenSHMEM} implementation for Epiphany performs network operations directly. \begin{figure} \centering \includegraphics[width=1.0\textwidth]{EpiphanyIII.pdf} \caption{The 16-core Epiphany-III architecture is a 2D array of RISC CPU cores. It contains a 64-word register file, sequencer, interrupt handler, integer and floating point units, timers, and DMA engines for the fast network-on-chip} \label{fig:epiphany} \end{figure} \section{Implementation and Performance Evaluation} \label{sec:implementation} Due to the tight memory constraints of the Epiphany memory and availability of specialized hardware features, the \mbox{OpenSHMEM} reference implementation built on GASNet was not suitable for deployment on the Epiphany cores. As a credit to the \mbox{OpenSHMEM} specification and the Adapteva Epiphany architecture documentation, the full \mbox{OpenSHMEM~1.3} implementation was written and optimized over a period of a few weeks. The entire library, including the optional extensions described in detail later, is approximately 1800 lines of code and does not require additional software. The software directly targets the underlying hardware features and was designed to be extremely lightweight in order to compile to small binaries expected with embedded architectures. Linear scaling algorithms were avoided, and many of the collective routines use dissemination or recursive doubling algorithms, optimized for low-latency on the Epiphany network. The remote memory access routines, \texttt{shmem\_\emph{TYPE}\_put} and \texttt{shmem\_\emph{TYPE}\_get}, use hand-tuned memory-mapped load and store primitives with a hardware loop feature specific to the Epiphany architecture. The non-blocking remote memory access routines use the dual-channel Direct Memory Access (DMA) engine on each processor network node. The distributed locking and atomic routines leverage an atomic \texttt{TESTSET} instruction that performs an atomic ``test-if-not-zero'' and conditional write. An optional hardware barrier implementation was also developed for a specialized \texttt{shmem\_barrier\_all} for extremely low-latency global barriers. An optional inter-processor interrupt and corresponding interrupt service routine (ISR) enable faster \texttt{shmem\_\emph{TYPE}\_get} operations by interrupting the remote core to use the optimized \texttt{shmem\_\emph{TYPE}\_put}. Many of the \mbox{OpenSHMEM} routines have some component that is hardware accelerated on the Epiphany architecture such as zero-overhead hardware loops for copying data, memory-mapped loads and stores, the \texttt{TESTSET} instruction for remote locks and atomics, a wait on AND (\texttt{WAND}) instruction for a low-latency \texttt{shmem\_barrier\_all}. The \texttt{MULTICAST} experimental feature would enable energy-efficient, low-latency broadcasts but is presently unused. The point-to-point synchronization routines are among the simplest to implement and do not have a section dedicated to discussion. Generally, they spin-wait on local values until they meet the criteria defined by the routine. The memory ordering routines need only verify that both DMA engines have an idle status by spin-waiting on the relevant special register. There are no intermediate data copies in this implementation. The performance evaluation of the Epiphany \mbox{OpenSHMEM} implementation began with the \mbox{OpenSHMEM} micro-benchmark codes. The timing code had to be modified because the \texttt{gettimeofday} routine is only accurate to a microsecond, and many of the operations operate in the sub-microsecond regime. Many of the communication routines in the performance evaluation include the parameters \(\alpha\) and \(\beta^{-1}\) in the figure subtitle along with their standard deviations. These two parameters are from the ``\(\alpha\)-\(\beta\) model'' for communication in HPC. They neatly summarize the communication time (\(T_c\)) to include the latency (\(\alpha\)) and marginal cost (\(\beta\)) to transfer a message (of size \(L\)) in equation~\ref{eq:comm}. The \(\beta^{-1}\) parameter is the peak effective core bandwidth for the routine. \begin{equation} T_c = \alpha + \beta \cdot L \label{eq:comm} \end{equation} \subsection{Library Setup, Exit, Query Routines} The \texttt{shmem\_init} routine retrieves or calculates the local processing element (PE) number (for \texttt{shmem\_my\_pe}) and number of PEs (for \texttt{shmem\_n\_pes}), configures the optimized hardware barrier or collective dissemination barrier arrays, obtains the SHMEM heap memory offset, and precalculates a few other addresses for improved runtime performance. The \texttt{shmem\_ptr} routine can directly calculate remote memory locations using simple logical shift and bitwise operations. \subsection{Memory Management Routines} \label{ssec:memory} Memory management on the Epiphany processor is atypical. Each Epiphany-III core has a flat 32~KB local memory map from address \texttt{0x0000} to \texttt{0x7fff}. Programs are typically loaded starting at \texttt{0x0100} if extremely constrained for memory, or \texttt{0x0400} if using the COPRTHR~2 interface. The stack pointer typically moves downward from the high address. Data used for the application, including the SHMEM data heap, begins directly after the program space. Figure~\ref{fig:memory} shows the typical memory layout of an Epiphany-III core using the COPRTHR~2 interface as it relates to the PGAS model. The static or global variables that are typically defined within the application appear below the free local memory address within the symmetric heap. They are still symmetrical across all Epiphany cores as the program binary is identical. \begin{figure} \centering \includegraphics[width=1.0\textwidth]{MemoryModel.pdf} \caption{The PGAS memory model (left) and the equivalent typical memory layout on an Epiphany-III core (right)} \label{fig:memory} \end{figure} Due to the tight memory constraints, a more modern memory allocator was not addressed in this work. The basic memory management system calls \texttt{brk} and \texttt{sbrk} are more suited for controlling the amount of memory allocated from the SHMEM data heap for each process element because there is no virtual address abstraction. Instead, there is a local base memory tracking pointer that stores the current free memory base address and incremented with each allocation. The memory management routines build on these calls, but care must be taken to adhere to the following rules: \begin{enumerate} \item \texttt{shmem\_free} must be called in the reverse order of allocation if making subsequent allocations \item \texttt{shmem\_realloc} can only be used on the last (re)allocated pointer \item \texttt{shmem\_align} alignment must be a power of 2 greater than 8 (default is 8) \end{enumerate} This is a pragmatic approach that we feel is reasonable and won't even be noticed on most codes. Calling \texttt{shmem\_free} moves the local base memory tracking pointer to the address in the function argument so most routines only need to call it once for the first allocated buffer in a series if freeing all memory. The \texttt{shmem\_realloc} routine could be designed to copy the contents of the old buffer to the new buffer, however, this would waste the memory space in the original allocation (a precious commodity on the Epiphany architecture). Future developments with COPRTHR~2 may address these deficiencies by exporting the COPRTHR host-side memory management to the coprocessor threads. \subsection{Remote Memory Access Routines} Inter-process memory copying on the Epiphany is trivial, and a simple loop over incrementing source and destination arrays can be done in C code. However, like many optimized \texttt{memcpy} routines, high-performance copies are non-trivial. A high-performance inter-processor memory copy routine does not appear to be in the eLib library. So after quite some time of hand-tuning in assembly, a put-optimized method was written that makes use of a ``zero-overhead'' hardware loop and four-way unrolled staggered double-word loads and (remote) stores. A specialization for the edge case of unaligned memory is also included since the Epiphany architecture requires loads and stores to be memory aligned to the data size. Assuming the fast path is taken, the core can transfer a double-word (8~bytes) per clock cycle. However, since the 8~byte load operation requires an additional cycle, the effective peak network copy is 8~bytes every two clocks. For a clock rate of 600~MHz, peak contiguous network transfers may achieve up to 2.4~GB/sec. Having the NoC and core clocks pinned ensures that application communication performance scales with the chip clock speed. The same put-optimized memory copy subroutine is used for get operations. This is sub-optimal, but remote read operations will never be as high-performance as remote write operations on the Epiphany architecture, so they should generally be avoided. Remote direct read operations are slower than equivalent remote direct write operations because the read request must first traverse the network to the receiving core network interface, then the data must traverse the network back to the requesting core. Unlike a remote direct write operation which can issue store instructions without a response, the read operation stalls the requesting core until the load instruction returns data to a register. Issuing multiple requests does little to mitigate this performance issue, thus, the throughput of the optimized \texttt{shmem\_put} is approximately an order of magnitude greater than \texttt{shmem\_get} as shown in Figure~\ref{fig:put_get}. \begin{figure} \centering \includegraphics[width=0.49\textwidth]{put.pdf} \includegraphics[width=0.49\textwidth]{get.pdf} \includegraphics[width=0.49\textwidth]{speedup.pdf} \includegraphics[width=0.49\textwidth]{get_ipi.pdf} \caption{Performance of optimized \texttt{shmem\_put} (top left) and \texttt{shmem\_get} (top right) for contiguous data exchange operations for 16 processing elements, speedup comparison with eLib (bottom left), and experimental inter-processor user interrupt for high-performance \texttt{shmem\_get} (bottom right).} \label{fig:put_get} \end{figure} In order to address this performance disparity with contiguous remote reads, an inter-processor interrupt is configured and signaled by the receiving core, causing an equivalent fast write to be executed. The receiving core is then signaled to continue upon completion of the inter-processor ISR. This is an experimental feature because it uses the user interrupt and must be enabled with \texttt{SHMEM\_USE\_IPI\_GET} during compilation. It has the greatest performance impact for large transfers. The method has a turnover point for buffers larger than 64 bytes so that smaller transfers are read directly and larger transfers use the inter-processor interrupt. All results for contiguous block transfers and a performance comparison with the equivalent eLib interface in the eSDK are shown in Figure~\ref{fig:put_get}. \subsection{Non-blocking Remote Memory Access Routines} \label{ssec:nonblocking} The set of non-blocking remote memory access routines (\texttt{shmem\_put\_nbi} and \texttt{shmem\_get\_nbi}) makes use of the on-chip DMA engine. The DMA engine has two independent DMA channels per processor node so that two non-blocking transfers may execute concurrently. Each channel has a separate DMA specification of the source and destination address configuration. The configuration is capable of 2D DMA operations with flexible stride sizes. This could support an extension to the \mbox{OpenSHMEM~1.3} standard for non-blocking strided remote memory access routines if needed. The performance results for the non-blocking remote memory access routines appear in Figure~\ref{fig:put_get_nb}. \begin{figure} \centering \includegraphics[width=0.49\textwidth]{put_nb.pdf} \includegraphics[width=0.49\textwidth]{put_nb_dual.pdf} \includegraphics[width=0.49\textwidth]{get_nb.pdf} \includegraphics[width=0.49\textwidth]{get_nb_dual.pdf} \caption{Performance of non-blocking remote memory access routines.} \label{fig:put_get_nb} \end{figure} Application performance improvement may be realized for large non-blocking transfers by splitting transfers into two portions and calling two non-blocking transfers, however, the performance benefit is marginal and often worse. Due to hardware errata in the Epiphany-III, the DMA engine is throttled to less than half of the peak bandwidth of 8 bytes per clock, or 4.8~GB/sec \cite{E16datasheet}. If fully enabled, as expected in future chips, the DMA engine would be used for the blocking remote memory access routines rather than remote load/store instructions. In general, it may be faster to use blocking transfers because the DMA engine setup overhead is relatively high, and there are often bank conflicts with the concurrent computation and DMA engine access, hindering fully overlapped communication and computation. The blocking operation, \texttt{shmem\_quiet}, spin-waits on the DMA status register. Alternatively, a DMA ISR could be used to continue the \texttt{shmem\_quiet} operation, but it is not clear how this could be higher performance. \subsection{Atomic Memory Operations} \label{ssec:atomic} The Epiphany-III ISA does not have support for atomic instructions, but the \texttt{TESTSET} instruction used for remote locks may be used to define other atomic operations in software. With the current code design, it is trivial to extend to other atomic operations with a single line of code if additional atomic operations are defined by the \mbox{OpenSHMEM} specification in the future. At a core level, memory access for both fetch and set operations completes in a single clock cycle and is therefore implicitly atomic. The fetch operation still must traverse the network to the remote core and return the result. Each data type specialization uses a different lock on the remote core as per the specification. The performance results for the 32-bit integer atomic routines appear in Figure~\ref{fig:atomics}. \begin{figure} \centering \includegraphics[width=0.64\textwidth]{atomics.pdf} \caption{Performance of \mbox{OpenSHMEM} atomic operations for 32-bit integers and a variable number of processing elements. Atomic operations are performed in a tight loop on the next neighboring processing element.} \label{fig:atomics} \end{figure} \subsection{Collective Routines} Multi-core barriers are critical to performance for many parallel applications. The Epiphany-III includes hardware support for a fully collective barrier with the \texttt{WAND} instruction and corresponding ISR. This hardware support is included as an experimental feature within the \mbox{OpenSHMEM} library and must be enabled by specifying \texttt{SHMEM\_USE\_WAND\_BARRIER} at compile time. After several implementations of barrier algorithms, it was determined that a dissemination barrier was the highest-performing software barrier method. It is not clear if this algorithm will continue to achieve the highest performance on chip designs with a larger number of cores; alternative tree algorithms may be needed. The eLib interface in the eSDK uses a counter-based collective barrier and requires a linearly increasing amount of memory with the number of cores. The dissemination barrier requires \(8 \cdot log_2(N)\) bytes of memory, where \emph{N} is the number of processing elements within the barrier. The use of this synchronization array mitigates the need for signaling by locks at each stage of the barrier. The collective eLib barrier completes in 2.0~$\mu$sec while the WAND barrier completes in 0.1~$\mu$sec. The performance for group barriers for a subset of the total processing elements is shown in Figure~\ref{fig:barrier_broadcast}. The latency of the dissemination barrier increases logarithmically with the number of cores so that more than eight cores take approximately 0.23~$\mu$sec. \begin{figure} \centering \includegraphics[width=0.49\textwidth]{barrier.pdf} \includegraphics[width=0.49\textwidth]{broadcast64.pdf} \caption{Performance of \texttt{shmem\_barrier} for variable number of processing elements (left) and the performance of \texttt{shmem\_broadcast64} for variable message sizes (right)} \label{fig:barrier_broadcast} \end{figure} Broadcasts are important in the context of the Epiphany application development in order to limit the replication of off-chip memory accesses to common memory. It is faster to retrieve off-chip data once and disseminate it to other processing elements in an algorithmic manner than for each processing element to fetch the same off-chip data. The data are distributed with a logical network tree, moving the data the farthest distance first in order to prevent subsequent stages increasing on-chip network congestion. The broadcast routines use the same high-performance memory copying subroutine as the contiguous data transfers. Effective core bandwidth approaches the theoretical peak performance for this algorithm and is approximately \(2.4 / log_2(N)\) GB/sec. Figure~\ref{fig:barrier_broadcast} shows collective broadcast performance for variable message sizes. The \texttt{shmem\_collect} and \texttt{shmem\_fcollect} routines use ring and recursive doubling algorithms for concatenating blocks of data from multiple processing elements. Each uses the optimized contiguous memory copying routine. There is likely room for improvement with these routines; the measured performance appears in Figure~\ref{fig:collect}. \begin{figure} \centering \includegraphics[width=0.49\textwidth]{collect64.pdf} \includegraphics[width=0.49\textwidth]{fcollect64.pdf} \caption{Performance of linear scaling \texttt{shmem\_collect64} and recursive doubling \texttt{shmem\_fcollect64} for variable message sizes on 16~processing elements} \label{fig:collect} \end{figure} The \texttt{shmem\_\emph{TYPE}\_\emph{OP}\_to\_all} reduction routines are important for many multi-core applications. The routines use different algorithms depending on the number of processing elements. A ring algorithm is used for processing elements that number in non-powers of two and a dissemination algorithm for powers of two. The symmetric work array is used for temporary storage and the symmetric synchronization array is used for multi-core locks and signaling. The performance of \texttt{shmem\_int\_sum\_to\_all} appears in Figure~\ref{fig:reduction}. Other routines vary marginally in performance due to data types and the arithmetic operation used. Reductions that fit within the symmetric work array have improved latency as seen in the figure. \begin{figure} \centering \includegraphics[width=0.67\textwidth]{reduce.pdf} \caption{Reduction performance for \texttt{shmem\_int\_sum\_to\_all} for all 16~processing elements. The latency and the number of collective reductions per second are shown. The effect of the minimum symmetric work array size for reductions, defined as \texttt{SHMEM\_REDUCE\_MIN\_WRKDATA\_SIZE} per the \mbox{OpenSHMEM} specification, is apparent for small reductions} \label{fig:reduction} \end{figure} The performance of the contiguous all-to-all data exchange, \texttt{shmem\_alltoall}, appears in Figure~\ref{fig:alltoall}. This routine has a relatively high overhead latency compared to other collectives. \begin{figure} \centering \includegraphics[width=0.67\textwidth]{alltoall64.pdf} \caption{Performance of the new (to version~1.3) contiguous all-to-all data exchange operation, \texttt{shmem\_alltoall}, for 16~processing elements} \label{fig:alltoall} \end{figure} \subsection{Distributed Locking Routines} The distributed locking routines, \texttt{shmem\_set\_lock} and \texttt{shmem\_test\_lock}, are easily supported by the atomic \texttt{TESTSET} instruction. The actual lock address is defined in the implementation to be on the first processing element. These locking mechanisms are also the basis for the atomic operations detailed in Sect. \ref{ssec:atomic} but for multiple processing elements. The \texttt{shmem\_clear\_lock} routine is a simple remote write to free the lock. Although this scheme works well for the 16 processing elements on the Epiphany-III, the performance bottleneck will likely be a problem scaling to much larger core counts. Application developers should avoid using these global locks. \section{Future Work and Discussion of Extensions for Embedded Architectures} \label{sec:future} It is our intention to release \emph{ARL \mbox{OpenSHMEM} for Epiphany}, as well as the performance evaluation codes and benchmarks used in this paper, as open source software through the U.S. Army Research Laboratory's GitHub account \cite{arlgithub} for Parallella community input and further development. The Epiphany architecture may also be updated in the future to add more hardware support for many of the existing \mbox{OpenSHMEM} routines. Many of the currently proposed \mbox{OpenSHMEM} extensions and updates should be addressable. A non-blocking strided remote memory access routine could be supported with the existing DMA engine as mentioned in Sect. \ref{ssec:nonblocking}. Some other extensions do not make sense for the architecture. For example, Epiphany is not a multithreaded architecture and, although it can be performed via software, is not the ideal mechanism for improving performance. The \mbox{OpenSHMEM} standard should remain sufficiently lightweight to address low-level operations without relying on specific architectural features. One of the more challenging portions of the \mbox{OpenSHMEM} standard for the Epiphany architecture and other embedded architectures are the memory management routines. It makes some sense for some platforms to have a pre-allocated symmetric heap from which memory allocations will be made. Within an Epiphany local core, there is no memory virtualization between the physical address and the memory address returned by the allocation routines as available memory is linearly removed from the symmetric heap. The limitations of the available core space make it challenging to introduce a Linux-like abstract model of virtual memory. As \mbox{OpenSHMEM} is a low-level interface and application developers are already accustomed to explicitly managing memory, it may make some sense to improve memory management interfaces, such as those discussed in Sect. \ref{ssec:memory}, for embedded architectures. \section{Conclusion} \label{sec:conclusion} \mbox{OpenSHMEM} provided an effective and pragmatic programming model for the Epiphany architecture. The header-only implementation enabled compiler optimizations for program size and application performance that is difficult to achieve using a standard pre-compiled library. We demonstrated improved performance and many useful features compared to the current eLib library despite the additional software abstraction with the OpenSHMEM interface. The \emph{ARL \mbox{OpenSHMEM} for Epiphany} demonstrated high-performance execution while approaching hardware theoretical networking limits, and low-latency operation for many of the \mbox{OpenSHMEM} routines.
{'timestamp': '2016-08-12T02:09:33', 'yymm': '1608', 'arxiv_id': '1608.03545', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03545'}
arxiv
\section{Matrix Facts \label{sec:matrix_facts}} \begin{lem} \label{lem:rcdd-inv-monotone} Let $\mm\in\R^{n\times n}$ be an invertible RCDD Z-matrix. Then for any diagonal matrix $\md\in\R_{\geq0}^{n\times n}$ and $\norm{(\md+\mm)^{-1}}_{2}\leq\norm{\mm^{-1}}_{2}$. \end{lem} \begin{proof} For all $\alpha\in\R_{\geq0}$ let $\mm_{\alpha}\defeq\alpha\md+\mm$. Let $\md_{\alpha}=\mdiag(\alpha\md+\mm)$ and let $\ma_{\alpha}=\mdiag(\mm)-\mm$. Note that $\mm_{\alpha}=\md-\ma_{\alpha}$ for all $\alpha\geq0$. Now since $\mm$ is invertible and RCDD we know that $\mm_{\alpha}$ is invertible and RCDD and \[ \mm_{\alpha}^{-1}=(\md_{\alpha}-\ma)^{-1}=\md_{\alpha}^{-1}(\mI-\ma\md_{\alpha}^{-1})=\sum_{i=0}^{\infty}\md_{\alpha}^{-1}(\ma\md_{\alpha}^{-1})^{i}\,. \] Consequently, we see that $\mm_{\alpha}^{-1}$ is a all positive matrix and $(\mm_{\alpha}^{-1})^{\top}\mm_{\alpha}^{-1}$ is a all positive matrix both of which decrease entrywise as $\alpha$ increases. Since the maximum eigenvector of $(\mm_{\alpha}^{-1})^{\top}\mm_{\alpha}^{-1}$ clearly has entries of all the same sign we see that $\norm{\mm_{\alpha}^{-1}}_{2}$ decreases monotonically as $\alpha$ increases. Considering $\alpha\in\{0,1\}$ yields the result. \end{proof} \begin{lem} \label{lem:lap-onenorm-bound} Let $\mm\in\R^{n\times n}$ be either CDD or RDD. Then $\norm{\mm x}_{1}\leq2\cdot\tr(\mm)\cdot\norm x_{\infty}$ for all $x\in\R^{n}$. Consequently, $\norm{\mm}_{2}\leq2\cdot\tr(\mm)$. \end{lem} \begin{proof} Since $\mm$ is CDD or RDD we know $\mm_{ii}\geq0$ for all $i\in[n]$ and $\tr(\mm)\geq\sum_{i\neq j\in[n]}|\mm_{ij}|$. Consequently, \[ \norm{\mm x}_{1}\leq\sum_{i,j\in[n]}|\mm_{ij}|\cdot\norm x_{\infty}=\left(\sum_{i\in[n]}\mm_{ii}+\sum_{i\neq j\in[n]}|\mm_{ij}|\right)\cdot\norm x_{\infty}\leq2\cdot\tr(\mm)\cdot\norm x_{\infty}\,. \] Therefore, $\norm{\mm x}_{2}\leq\norm{\mm x}_{1}\leq2\cdot\tr(\mm)\cdot\norm x_{\infty}\leq2\cdot\tr(\mm)\cdot\norm x_{2}$. \end{proof} \begin{lem} \label{lem:inverse-alphacdd_bound} Let $\mm\in\R^{n\times n}$ be an $\alpha$-CDD Z-matrix. For all $x\in\R_{\geq0}^{n}$ we have $\mdiag(\mm)^{-1}x\leq\mm^{-1}x\leq\mdiag(\mm)^{-1}x+\frac{\norm x_{1}}{\alpha}\mdiag(\mm)^{-1}1$ \end{lem} \begin{proof} Let $\md\defeq\mdiag(\mm)$ and let $\ma\defeq\md-\mm$ so $\mm=\md-\ma$. We see that \[ \mm^{-1}=(\md-\ma)^{-1}=\md^{-1}(\mI-\ma\md^{-1})=\sum_{i=0}^{\infty}\md^{-1}(\ma\md^{-1})^{i} \] Consequently \[ \mm^{-1}x-\md^{-1}x=\md^{-1}\sum_{i=1}^{\infty}(\ma\md^{-1})^{i}x \] Now since $\mm$ is a $\alpha$-CDD Z-matrix we see that $(\ma\md^{-1})x$ is a non-negative vector with $\norm{\ma\md^{-1}x}_{1}\leq\frac{1}{1+\alpha}\norm x_{1}$. Consequently, $\sum_{i=1}^{\infty}(\ma\md^{-1})^{i}x$ is a non-negative vector with $\ellOne$ norm at most \[ \sum_{i=1}^{\infty}\left(\frac{1}{1+\alpha}\right)^{i}=\left(1-\frac{1}{1+\alpha}\right)^{-1}-1=\frac{1+\alpha}{\alpha}-1=\frac{1}{\alpha}\,. \] \end{proof} \begin{lem} \label{lem:cond-num-bd}Let $\mm\in\R^{n\times n}$, and let a diagonal matrix $\md\succeq0$. Then $\norm{(\mm\md^{-1})^{\dagger}}_{2}\leq\norm{\mm^{\dagger}}_{2}\cdot\norm{\md}_{2}$. Furthermore, $\kappa(\mm\md^{-1})=\kappa((\mm\md^{-1})^{\dagger})\leq\kappa(\mm)\kappa(\md)$. \end{lem} \begin{proof} By definition, and using the fact that $\ker((\mm\md^{-1})^{\dagger})=\ker(\md^{-1}\mm^{\top})\perp\im(\mm\md^{-1})$, we have \begin{eqnarray*} \norm{(\mm\md^{-1})^{\dagger}}_{2} & = & \max_{x\perp\ker((\mm\md^{-1})^{\dagger}),x\neq0}\frac{\norm{(\mm\md^{-1})^{\dagger}x}_{2}}{\norm x_{2}}=\max_{y:\mm\md^{-1}y\neq0}\frac{\norm{(\mm\md^{-1})^{\dagger}\mm\md^{-1}y}_{2}}{\norm{\mm\md^{-1}y}_{2}}\\ & = & \max_{z:\mm z\neq0}\frac{\norm{\md z}_{2}}{\norm{\mm z}_{2}}=\max_{z:\mm z\neq0}\left(\frac{\norm z_{2}}{\norm{\mm z}_{2}}\cdot\frac{\norm{\md z}_{2}}{\norm z_{2}}\right)\\ & \leq & \max_{z:\mm z\neq0}\frac{\norm z_{2}}{\norm{\mm z}_{2}}\cdot\max_{z\neq0}\frac{\norm{\md z}_{2}}{\norm z_{2}}=\norm{\mm^{\dagger}}_{2}\cdot\norm{\md}_{2}\,. \end{eqnarray*} Now we can plug in the definition for the condition number: $\kappa(\mm\md^{-1})=\kappa((\mm\md^{-1})^{\dagger})=\norm{(\mm\md^{-1})^{\dagger}}_{2}\norm{\mm\md^{-1}}_{2}$. For the first part we use the upper bound we just proved. For the second one, we bound it by $\norm{\mm\md^{-1}}_{2}\leq\norm{\mm}_{2}\norm{\md^{-1}}_{2}$. Combining these bounds we see that $\kappa(\mm\md^{-1})\leq\norm{\mm^{\dagger}}_{2}\norm{\md}_{2}\cdot\norm{\mm}_{2}\norm{\md^{-1}}_{2}=\kappa(\mm)\kappa(\md)$. \end{proof} \begin{lem} \label{lem:rcdd-to-eulerian-kappa}Let $\mm\in\R^{n\times n}$ be an $\alpha$-RCDD matrix with diagonal $\md$, let $\mU_{\mm}=(\mm+\mm^{\top})/2$, and let the $(n+1)\times n$ matrix $\mc=\begin{pmatrix}\mI_{n}\\ -\vones_{n}^{\top} \end{pmatrix}$. Then the $(n+1)\times(n+1)$ matrix $\mc\mU_{\mm}\mc^{\top}$ satisfies $\kappa(\mc\mU_{\mm}\mc^{\top})\leq2(1+\alpha)/\alpha\cdot n^{3}\cdot\kappa(\md)$. \end{lem} \begin{proof} First, notice that if $\mm$ is $\alpha$-RCDD, then it is also the case that $\mU_{\mm}$ is $\alpha$-RCDD. Then $\frac{\alpha}{1+\alpha}\md\preceq\mU_{\mm}$. Similarly, we have $\mU_{\mm}\preceq2\md$. Therefore $\kappa(\mc\mU_{\mm}\mc^{\top})\leq\kappa(\mc\md\mc^{\top})\cdot2(1+\alpha)/\alpha$. We see that $\mc\md\mc^{\top}$ is an undirected Laplacian with trace at most $2\cdot\vec{1}^{\top}\md\vec{1}\leq2n\max_{i}\md_{i,i}$. Also, its minimum eigenvalue is therefore at least $\min_{i}\md_{i,i}\cdot n^{2}$. Hence $\kappa(\mc\md\mc^{\top})\leq n^{3}\kappa(\md)$, and our result follows. \end{proof} \begin{lem} \label{lem:norm-inverse-perturb}Let $\ma$ and $\ma'=\ma+\Delta\ma$ be matrices with the same null space. Then, if $\norm{\Delta\ma}<\norm{\ma^{\dagger}}^{-1}$, then $\Vert(\ma+\Delta\ma)^{\dagger}\Vert\leq\Vert\ma^{\dagger}\Vert\cdot\frac{1}{1-\norm{\Delta\ma}\norm{\ma^{\dagger}}}$. \end{lem} \begin{proof} Let $x$ be the largest singular vector of $\ma'^{\dagger}$, i.e. it is perpendicular to the kernel, and maximizes $\frac{\norm x}{\norm{\ma'x}}$. Then \begin{align*} \frac{\norm x}{\norm{\ma'x}} & \leq\frac{\norm x}{\abs{\norm{\ma x}-\norm{\Delta\ma x}}}\,. \end{align*} Since $\norm{\Delta\ma}<\norm{\ma^{\dagger}}^{-1}$, we have that $\norm{\Delta\ma x}\leq\norm{\Delta\ma}\norm x<\norm{\ma^{\dagger}}^{-1}\cdot\norm x\leq\norm{\ma x}$. Therefore we can drop the absolute value, and obtain \begin{align*} \frac{\norm x}{\norm{\ma'x}} & \leq\frac{\norm x}{\norm{\ma x}-\norm{\Delta\ma x}}=\frac{\norm x}{\norm{\ma x}}\cdot\frac{\norm{\ma x}}{\norm{\ma x}-\norm{\Delta\ma x}}\\ & =\frac{\norm x}{\norm{\ma x}}\cdot\frac{1}{1-\norm{\Delta\ma x}/\norm{\ma x}}\leq\frac{\norm x}{\norm{\ma x}}\cdot\frac{1}{1-\norm{\Delta\ma}\norm{\ma^{\dagger}}}\,. \end{align*} Since $\frac{\norm x}{\norm{\ma x}}$ is bounded by $\norm{\ma^{\dagger}}$, our inequality follows. \end{proof} \begin{lem} \label{lem:sol-perturb}Let $\ma$ and $\ma'=\ma+\Delta\ma$ be matrices with the same left and right null space, such that $\norm{\Delta\ma}<\norm{\ma^{\dagger}}^{-1}$. Let $b$ be a vector in the image, and let $x=\ma^{\dagger}b$, and $\Delta x$ such that $x+\Delta x=(\ma+\Delta\ma)^{\dagger}b$. Then \[ \frac{\norm{\Delta x}}{\norm x}\leq\frac{\norm{\ma^{\dagger}}\norm{\Delta\ma}}{1-\norm{\ma^{\dagger}}\norm{\Delta\ma}}\,. \] \end{lem} \begin{proof} Since $(\ma+\Delta\ma)(x+\Delta x)=b$, we have $\Delta x=\ma^{\dagger}\left(-\Delta\ma x-\Delta\ma\Delta x\right)$. Applying triangle inequality we see that $\norm{\Delta x}\leq\norm{\ma^{\dagger}}\norm{\Delta\ma}\left(\norm x+\norm{\Delta x}\right)$. Therefore, after rearranging terms we obtain \begin{eqnarray*} \norm{\Delta x}\left(1-\norm{\ma^{\dagger}}\norm{\Delta\ma}\right) & \leq & \norm x\cdot\norm{\ma^{\dagger}}\norm{\Delta\ma}\,. \end{eqnarray*} Finally, since $\norm{\ma^{\dagger}}\norm{\Delta\ma}<1$, we get \[ \frac{\norm{\Delta x}}{\norm x}\leq\frac{\norm{\ma^{\dagger}}\norm{\Delta\ma}}{1-\norm{\ma^{\dagger}}\norm{\Delta\ma}}\,. \] \end{proof} \section{\label{sec:applications}Applications} In this section, we use the algorithms from the previous sections\textemdash in particular the stationary computation algorithm described in Theorem~\ref{thm:stat-from-dd} and the solver for RCDD-linear systems from Corollary~\ref{cor:alpha-rcdd-solver}\textemdash to efficiently solve several of problems of interest. Most of these problems are related to computing random walk-related quantities of directed graphs. We emphasize that unlike all prior work for directed graphs, our results have only a polylogarithmic dependence on the condition number\textemdash or equivalently\textemdash the mixing time. We show how to efficiently compute \begin{itemize} \item $\ma^{\dagger}b$ where $\ma$ is any row- or column-diagonally dominant matrix and $b$ is orthogonal to the null space of $\ma$, without any requirement that $\ma$ being strictly row-column-diagonally-dominant or a $\mz$-matrix (\ref{subsec:app-solvers}) \item $\mlap^{\dagger}b$ where $\mlap$ is a directed Laplacian matrix and $b$ is any vector in $\R^{n}$, including those not in the image of $\mlap$ (\ref{subsec:app-solvers}) \item personalized PageRank (\ref{subsec:app-pagerank}) \item the mixing time of a directed graph\textemdash up to various polynomial factors\textemdash and its stationary distribution (\ref{subsec:app-cond-est}) \item hitting times for any particular pair of vertices (\ref{subsec:app-commute}) \item escape probabilities for any particular triple of vertices (\ref{subsec:Escape-probabilities}) \item commute times between all pairs of vertices using Johnson-Lindenstrauss sketching (\ref{subsec:app-commute}) \end{itemize} As with Theorem~\ref{thm:stat-from-dd}, all of our routines will utilize a solver for a RCDD linear system in a black-box manner. Therefore, the running time bounds will also involve black-box bounds on the costs of such a solver. \input{applications_ppr.tex}\input{applications_condition_estimation.tex}\input{applications_solvers.tex}\input{applications_hitting.tex}\input{applications_escape.tex}\input{applications_commute.tex} \subsection{\label{subsec:Sketching-Commute-Times}Sketching Commute Times} In this section, we show that we can efficiently compute an $O\left(\epsilon^{-2}\log n\right)\times n$ matrix that allows us to compute a $(1+\epsilon)$ multiplicative approximation to the commute time between any two vertices in $O\left(\epsilon^{-2}\log n\right)$ time. This data structure is the natural generalization of a powerful result for undirected graphs: with $O(\epsilon^{-2}\log n)$ undirected Laplacian solves one can build an $O\left(\epsilon^{-2}\log n\right)\times n$ sized matrix that allows one to compute the effective resistance between any pair of vertices in $O(\epsilon^{-2}\log n)$ time \cite{SpielmanS08}. This follows from applying the technique used in \cite{SpielmanS08} for sketching effective resistances. \begin{lem} \label{prop:commute-time}Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix corresponding to an irreducible Markov chain with stationary distribution $s$. Then the commute time $C_{uv}$ satisfies the following three identities: \begin{eqnarray*} C_{uv} & = & \left(\vec{1}_{u}-\vec{1}_{v}\right)^{\top}\left(\left(\mI-\mw\right)\ms\right)^{\dagger}\left(\vec{1}_{u}-\vec{1}_{v}\right)\\ & = & \left(\vec{1}_{u}-\vec{1}_{v}\right)^{\top}\ms^{-1}\left(\mI-\mw\right)^{\dagger}\left(\vec{1}_{u}-\vec{1}_{v}\right)\\ & = & \left(\vec{1}_{u}-\vec{1}_{v}\right)^{\top}\left(\mlap_{b}^{\dagger}\right)^{\top}\mU_{b}\mlap_{b}^{\dagger}\left(\vec{1}_{u}-\vec{1}_{v}\right)\,, \end{eqnarray*} where $\mlap_{b}:=(\mI-\mw)\ms$ is the Laplacian rescaled to an Eulerian graph using the stationary $s$, and $\mU_{b}=\frac{1}{2}\left(\mlap_{b}+\mlap_{b}^{\top}\right)$. \end{lem} We defer the proof to Section~\ref{subsec:commute-formula} of the Appendix. The connection to effective resistances is more apparent by noticing that for undirected graphs\textemdash where $s=\md/2m$, and $\mlap=(\mI-\mw)\md$\textemdash one obtains $C_{uv}=(\vec{1_{u}}-\vec{1}_{v})^{\top}((\mI-\mw)\md\cdot\frac{1}{2m})^{\dagger}(\vec{1}_{u}-\vec{1}_{v})=2m\cdot(\vec{1}_{u}-\vec{1}_{v})^{\top}((\mI-\mw)\md)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})=2m\cdot\reff{uv}$, which matches a well known identity. Having shown that $C_{uv}$ can be defined as a quadratic form involving a symmetric positive semi-definite matrix, we can sketch the quadratic form using the technique from \cite{SpielmanS11}. In the remainder of this section we show how to carry out this approach. One should note that applying the operators $\mlap_{b}$ and $\mU_{b}$ appearing in the symmetric formula requires knowing the stationary distribution. Since our solver provides an approximation $s'$ to the stationary, the scaling $\mlap_{b}'=(\mI-\mw)\ms'$ will not be Eulerian in general, and therefore its corresponding symmetrization may not even be positive semi-definite. This is addressed by adding extra arcs to $\mlap_{b}$ so that it becomes Eulerian. If the stationary is computed to high enough accuracy, the additional arcs will not change the commute time by more than a factor of $1+\epsilon/2$, and the result follows. For completeness, we first state the Johnson-Lindenstrauss lemma: \begin{lem} (Johnson-Lindenstrauss) Let $v_{1,}\dots,v_{m}\in\R^{n}$, $\epsilon>0$ and $\mq$ a random $k\times n$ matrix where each entry is random $\pm1/\sqrt{k}$, with $k\geq24\log m/\epsilon^{2}$. Then with high probability, $(1-\epsilon)\left\Vert v_{i}\right\Vert _{2}^{2}\leq\left\Vert \mq v_{i}\right\Vert _{2}^{2}\leq(1+\epsilon)\left\Vert v_{i}\right\Vert _{2}^{2}$, for all $i\in\left\{ 1,\dots,m\right\} $. \end{lem} Then we proceed with describing the implementation of the sketch for walk matrices with known stationary distribution. Extending it to the case where the stationary is not known a priori will be done later, by rescaling with an approximate stationary distribution obtained via Theorem~\ref{thm:cond_and_stationary_est}, and perturbing the problem so that the rescaled matrix becomes exactly balanced. \begin{algorithm2e} \caption{Commute Time Sketch Computation with Known Stationary}\label{alg:commute-time-sketch} \SetAlgoLined \textbf{Input: }Random walk matrix $\mw\in\R_{\geq0}^{n\times n}$ with stationary distribution $s$, accuracy $\epsilon\in(0,1)$ Let $\mlap=(\mI-\mw)\ms$ be the Eulerian directed Laplacian corresponding to $\mw$; factor its symmetrization $\mU=\mb^{\top}\mc\mb$ where $\mb$ is the edge-vertex incidence matrix, and $\mc$ is a diagonal matrix. Let $k=2400\cdot\log m/\epsilon^{2}$, and let $\mq$ be a random $k\times n$ matrix, where each entry is random $\pm1/\sqrt{k}$. For $i\in\left\{ 1,\dots,k\right\} $ call Lemma~\ref{lem:weirdnormsolver} on $\mlap$ with $b=\mb^{\top}\mc^{1/2}\left(\mq^{\top}\right)_{:,i}$ and $\epsilon'\leq\frac{\epsilon^{2}s_{\textnormal{min}}^{3}w_{\textnormal{min}}^{3}}{50n^{4}}$. Let $\tilde{\my}$ be the $k\times n$ matrix where $\tilde{\my}_{i,:}$ is the approximation to $\mlap^{\dagger}\mb^{\top}\mc^{1/2}\left(\mq^{\top}\right)_{:,i}$ that resulted from invoking Lemma~\ref{lem:weirdnormsolver}. \textbf{Output}: $\tilde{\my}$. \end{algorithm2e} Obtaining an approximation to the commute time $C_{uv}$ is done simply by computing $\Vert\tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}^{2}$, as can be seen from the following lemma. \begin{lem} \label{lem:sketch-exact-stationary} Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix with $m$ non-zero entries and a given stationary distribution $s$, i.e. $(\mI-\mw)\ms$ is an Eulerian directed Laplacian. Let $s_{\textnormal{min}}$ and $w_{\textnormal{min}}$ be the minimum stationary probability and the smallest transition probability, respectively. Then, for any $\epsilon\in(0,1)$, Algorithm~\ref{alg:commute-time-sketch} computes in time $O(\tsolve\cdot\log(\frac{n}{\epsilon\cdot s_{\textnormal{min}}w_{\textnormal{min}}})\cdot\frac{1}{\epsilon^{2}})$ a $O(\log n/\epsilon^{2})\times n$ matrix $\tilde{\my}$ such that, $(1-\epsilon)C_{uv}\leq\left\Vert \tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\right\Vert _{2}^{2}\leq(1+\epsilon)C_{uv}$, with high probability in $n$. \end{lem} \begin{proof} The proof involves carefully analyzing the composition of errors. Let $\mx=\mlap^{\top}\mU^{\dagger}\mlap$, $\my=\mq\mc^{1/2}\mb\left(\mlap^{\top}\right)^{\dagger}$ and recall that, by Lemma~\ref{lem:weirdnormsolver}, $\tilde{\my}$ is an approximation to $\my$ in the sense that $\Vert\tilde{\my}_{i,:}-\my_{i,:}\Vert_{\mx}\leq\epsilon'\cdot\Vert\mb^{\top}\mc^{1/2}\left(\mq^{\top}\right)_{:,i}\Vert_{\mU^{\dagger}}$. Using the fact that the commute time $C_{uv}$ can be written as $C_{uv}=\Vert\mc^{1/2}\mb\left(\mlap^{\top}\right)^{\dagger}\left(\vec{1}_{u}-\vec{1}_{v}\right)\Vert^{2}$ (since $\vec{1}_{u}-\vec{1}_{v}\perp\vec{1}$), and applying the JL lemma, we have that \[ (1-\epsilon/10)C_{uv}\leq\Vert\mq\mc^{1/2}\mb\left(\mlap^{\top}\right)^{\dagger}\left(\vec{1}_{u}-\vec{1}_{v}\right)\Vert^{2}=\norm{\my(\vec{1}_{u}-\vec{1}_{v})}_{2}^{2}\leq(1+\epsilon/10)C_{uv}\,. \] We can bound the error introduced by the Laplacian solver using triangle inequality as follows: \begin{eqnarray*} \abs{\Vert\tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}-\Vert\my(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}} & \leq & \Vert(\tilde{\my}-\my)(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}=\sqrt{\sum_{i=1}^{k}\left(\left(\tilde{\my}_{i,:}-\my_{i,:}\right)(\vec{1}_{u}-\vec{1}_{v})\right)^{2}}\,. \end{eqnarray*} Next, let $\Pi=\mI-\frac{1}{n}\vec{1}\vec{1}^{\top}$ be the projection onto the space perpendicular to $\vec{1}$. Using the fact that both $\vec{1}_{u}-\vec{1}_{v}$ and $\left(\tilde{\my}_{i,:}-\my_{i,:}\right)\Pi$ are orthogonal to $\ker(\mx)=\vec{1}$ (this identity is immediate, since $\mx$ corresponds to a doubly stochastic random walk matrix), we can write: \begin{align*} \left(\tilde{\my}_{i,:}-\my_{i,:}\right)(\vec{1}_{u}-\vec{1}_{v})=\left(\tilde{\my}_{i,:}-\my_{i,:}\right)\Pi(\vec{1}_{u}-\vec{1}_{v}) & =\left(\tilde{\my}_{i,:}-\my_{i,:}\right)\Pi\mx^{1/2}\cdot\left(\mx^{\dagger}\right)^{1/2}\Pi(\vec{1}_{u}-\vec{1}_{v})\,, \end{align*} then apply the Cauchy-Schwarz inequality: \begin{align*} \left(\tilde{\my}_{i,:}-\my_{i,:}\right)\Pi\mx^{1/2}\cdot\left(\mx^{\dagger}\right)^{1/2}\Pi(\vec{1}_{u}-\vec{1}_{v}) & \leq\norm{\left(\tilde{\my}_{i,:}-\my_{i,:}\right)\Pi}_{\mx}\cdot\norm{\Pi\left(\vec{1}_{u}-\vec{1}_{v}\right)}_{\mx^{\dagger}}\\ & =\norm{\tilde{\my}_{i,:}-\my_{i,:}}_{\mx}\cdot\norm{\vec{1}_{u}-\vec{1}_{v}}_{\mx^{\dagger}}\,. \end{align*} Combining this with the solver guarantee we obtain \begin{eqnarray*} \abs{\Vert\tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}-\Vert\my(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}} & \leq & \sqrt{\sum_{i=1}^{k}\epsilon'\cdot\Vert\mb^{\top}\mc^{1/2}\left(\mq^{\top}\right)_{:,i}\Vert_{\mU^{\dagger}}^{2}\cdot\norm{\vec{1}_{u}-\vec{1}_{v}}_{\mx^{\dagger}}^{2}}\\ & = & \norm{\vec{1}_{u}-\vec{1}_{v}}_{\mx^{\dagger}}\cdot\sqrt{\epsilon'}\cdot\sqrt{\sum_{i=1}^{k}\Vert\mc^{1/2}\mb\mU^{\dagger}\mb^{\top}\mc^{1/2}\left(\mq^{\top}\right)_{:,i}\Vert^{2}}\\ & = & C_{uv}\cdot\sqrt{\epsilon'}\cdot\sqrt{\sum_{i=1}^{k}\Vert\mc^{1/2}\mb\mU^{\dagger}\mb^{\top}\mc^{1/2}\left(\mq^{\top}\right)_{:,i}\Vert^{2}}\,. \end{eqnarray*} The factor containing the square root is equal to the Frobenius norm $\Vert\mc^{1/2}\mb\mU^{\dagger}\mb^{\top}\mc^{1/2}\mq^{\top}\Vert_{F}$, which can be upper bounded by \begin{eqnarray*} \Vert\mc^{1/2}\mb\mU^{\dagger}\mb^{\top}\mc^{1/2}\mq^{\top}\Vert_{F} & \leq & \norm{\mc^{1/2}\mb}_{F}\cdot\norm{\mU^{\dagger}\mb^{\top}\mc^{1/2}}_{F}\cdot\norm{\mq^{\top}}_{F}\\ & = & \sqrt{\tr\left(\mU\right)\cdot\tr\left(\mU^{\dagger}\right)\cdot\tr\left(\mq^{\top}\mq\right)}\\ & \leq & \sqrt{n\cdot\left(n/\lambda_{\textnormal{min}}\left(\mU\right)\right)\cdot\tr\left(\mq^{\top}\mq\right)}\\ & = & \sqrt{n^{3}/\lambda_{\textnormal{min}}\left(\mU\right)}\,. \end{eqnarray*} Then, we obtain that \begin{align*} \abs{\Vert\tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}-\Vert\my(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}} & \leq C_{uv}\cdot\sqrt{\epsilon'}\cdot\sqrt{n^{3}/\lambda_{\textnormal{min}}\left(\mU\right)}\\ & =C_{uv}\cdot\sqrt{\frac{\epsilon^{2}}{100n^{3}}\cdot2s_{\textnormal{min}}^{2}w_{\textnormal{min}}^{2}\cdot\frac{s_{\textnormal{min}}w_{\textnormal{min}}}{n}\cdot\frac{n^{3}}{\lambda_{\textnormal{min}}\left(\mU\right)}}\leq\sqrt{C_{uv}}\cdot\epsilon/10\,. \end{align*} For the last part we used Cheeger's inequality to bound $\lambda_{\textnormal{min}}\left(\mU\right)\geq2(s_{\textnormal{min}}w_{\textnormal{min}})^{2}$, and Lemma~\ref{prop:(Bounding-commute-times)} to bound $C_{uv}\leq n/(s_{\textnormal{min}}w_{\textnormal{min}})$. Therefore \begin{align*} \abs{\left\Vert \tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\right\Vert _{2}^{2}-C_{uv}} & \leq\abs{\left(\norm{\my(\vec{1}_{u}-\vec{1}_{v})}_{2}+\Vert\tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}-\Vert\my(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}^{2}-C_{uv}\right)}\\ & =\left(\norm{\my(\vec{1}_{u}-\vec{1}_{v})}_{2}^{2}-C_{uv}\right)+\left(\Vert\tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}-\Vert\my(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}\right)^{2}\\ & +2\cdot\sqrt{C_{uv}}\cdot\left(\Vert\tilde{\my}(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}-\Vert\my(\vec{1}_{u}-\vec{1}_{v})\Vert_{2}\right)\\ & \leq C_{uv}\cdot\epsilon/10+C_{uv}\cdot\epsilon^{2}/100+2\cdot C_{uv}\cdot\epsilon/10\\ & \leq C_{uv}\cdot\epsilon\,, \end{align*} and our desired guarantee follows. The running time is dominated by the $k$ calls to Lemma~\ref{lem:weirdnormsolver}, each of them requiring time $O(\tsolve\log(1/\epsilon'))=O(\tsolve\log\frac{n}{\epsilon\cdot s_{\textnormal{min}}w_{\textnormal{min}}})$. Hence the bound on running time. \end{proof} Next we show how to extend this sketching technique to general walk matrices. The difficulty lies in the fact that Algorithm~\ref{alg:commute-time-sketch} requires knowing the exact stationary distribution of $\mw$. However, our solver produces only an approximate solution. In order to alleviate this issue, we use the approximate stationary to rescale the Laplacian, then patch the graph by adding extra arcs in order to make it Eulerian. The small error in the stationary approximation guarantees that patching does not significantly change the commute times or the mixing time of the walk matrix. Therefore we can use the patched Laplacian inside Algorithm~\ref{alg:commute-time-sketch} to produce a sketch. The method is underlined in the algorithm described below. \begin{algorithm2e} \caption{Walk Matrix with Exact Stationary}\label{alg:commute-time-approx} \SetAlgoLined \textbf{Input: }Random walk matrix $\mw\in\R_{\geq0}^{n\times n}$, upper bound $M\geq t_{\textnormal{mix}}$, lower bound $\sigma\leq s_{\textnormal{min}}$, accuracy $\epsilon\in(0,1)$. Call Theorem \ref{thm:cond_and_stationary_est} to compute the stationary of $\mw$ with additive error $\epsilon'=\frac{\epsilon\sigma}{4n}$. Let $s'$ be the approximate stationary obtained from invoking Theorem \ref{thm:cond_and_stationary_est}, and set $s''=s'+\epsilon'\cdot\vec{1}$. Let $d=\left(\mw-\mI\right)s''$. Compute a matching $\mm$ routing demand $d$. Let $\tilde{s}=\left(s''+d_{>0}\right)/\norm{s''+d_{>0}}_{1}$. Let $\tilde{\mw}=\left(\mw\ms''+\mm\right)\tilde{\ms}^{-1}$ \textbf{Output}: $\left(\tilde{\mw},\tilde{s}\right)$ \end{algorithm2e} \begin{lem} \label{prop:produce-exact-stationary}Let $\mw\in\R_{\geq0}^{n\times n}$ be the random walk matrix of a Markov chain associated with a strongly connected graph. Let $M\geq t_{\textnormal{mix}}$ and $\sigma\leq s_{\textnormal{min}}$. Then Algorithm~\ref{alg:commute-time-approx} produces a walk matrix $\tilde{\mw}$ such that $\abs{\mw_{ij}-\tilde{\mw}_{ij}}\leq\epsilon$ for all $i,j$, along with its exact stationary distribution $\tilde{s}$ in time $O\left(\tsolve\left(\log\frac{nM}{\epsilon\sigma}\right)^{2}\right)$. Furthermore, $s_{i}+\epsilon\sigma/2\geq\tilde{s}_{i}\geq s_{i}/(1+\epsilon\sigma)$ for all $i$. \end{lem} \begin{proof} We start by bounding the $\ell_{1}$ norm of the routed demand $d$. By construction we have $\norm d_{1}=\norm{(\mI-\mw)s''}_{1}=\norm{(\mI-\mw)(s+s''-s)}_{1}=\norm{(\mI-\mw)(s''-s)}_{1}$. Since applying $\mw$ does not increase the $\ell_{1}$ norm of the vector it is applied to, we see that the previous quantity can be bounded by $2\norm{s''-s}_{1}=2\norm{\epsilon'\vec{1}+s'-s}_{1}\leq2n\epsilon'+2\norm{s'-s}_{1}$. Plugging in the error guarantee $\norm{s'-s}_{2}\leq\epsilon'$ we obtain $\norm{s'-s}_{1}\leq\epsilon'\sqrt{n}$. Hence, putting everything together we get $\norm d_{1}\leq2n\epsilon'+2\epsilon'\sqrt{n}\leq4n\epsilon'$. Also note that $s_{i}''\tilde{s}_{i}^{-1}=\norm{s''+d_{>0}}_{1}\cdot\frac{s_{i}''}{s_{i}''+(d_{>0})_{i}}$. Since by construction $s''\geq s$, we obtain \begin{eqnarray*} \frac{s''_{i}}{s''_{i}+\norm d_{1}/2} & \leq & s_{i}''\tilde{s}_{i}^{-1}\leq\norm{s+(s''-s)+d_{>0}}_{1}\,. \end{eqnarray*} Using the bound on $\norm d_{1}$ for the first inequality, plus the triangle inequality for the second, we get \begin{equation} \frac{s''_{i}}{s''_{i}+2n\epsilon'}\leq s_{i}''\tilde{s}_{i}^{-1}\leq1+4n\epsilon'\,,\label{eq:commute_bd1} \end{equation} for all $i$. Plugging in $\epsilon'=\frac{\epsilon\sigma}{4n}$ we obtain \begin{equation} 1-\epsilon\leq s_{i}''\tilde{s}_{i}^{-1}\leq1+\epsilon/2\,.\label{eq:commute_bd2} \end{equation} Also, note that \begin{eqnarray} (\mm\tilde{\ms}^{-1})_{ij} & \leq & \norm{d_{>0}}_{1}\cdot\max_{k}\left(\norm{s''+d_{>0}}_{1}\cdot\frac{1}{s_{k}''+(d_{>0})_{k}}\right)\label{eq:commute_bd3}\\ & \leq & 2n\epsilon'\cdot\left(\left(1+4n\epsilon'\right)\cdot\frac{1}{s_{\textnormal{min}}}\right)\leq\epsilon/2\,.\label{eq:eq:commute_bd4} \end{eqnarray} Combining Equations~\ref{eq:commute_bd2} and \ref{eq:commute_bd3}, we obtain that $(1-\epsilon)\mw_{ij}\leq\tilde{\mw}_{ij}\leq(1+\epsilon/2)\mw_{ij}+\epsilon/2$, and the desired bound on $\tilde{\mw}_{ij}$ follows. Also, by construction, we notice that $\tilde{s}_{i}\geq s''_{i}/\norm{s''+d_{>0}}_{1}\geq s_{i}/(1+4n\epsilon')=s_{i}/(1+\epsilon\sigma)$. Similarly, since $s''\geq s$, and therefore $\tilde{s}_{i}\leq s_{i}+\norm{d_{>0}}_{1}$, we have $\tilde{s_{i}}\leq s_{i}+2n\epsilon'\leq s_{i}+\epsilon\sigma/2$. \begin{sloppypar}The running time is dominated by the invocation of Theorem \ref{thm:cond_and_stationary_est}, which requires time $O\left(\tsolve\left(\log\frac{nM}{\epsilon'}\right)^{2}\right)=O\left(\tsolve\left(\log\frac{nM}{\epsilon\sigma}\right)^{2}\right)$.\end{sloppypar} \end{proof} The lemma below shows a sufficient accuracy to which we need to invoke Algorithm~\ref{alg:commute-time-approx} in order to approximately preserve commute times. \begin{lem} \label{prop:approx-commute}Let $\mw,\tilde{\mw}\in\R_{\geq0}^{n\times n}$ be random walk matrices of Markov chains associated with strongly connected graphs, having stationaries $s$ and $\tilde{s}$, respectively. Let $C$ and $\tilde{C}$, respectively, denote commute times for the two walk matrices. Let $s_{\textnormal{min}}$ represent the minimum stationary probability of $\mw$, and let $\epsilon_{0}\leq\epsilon\cdot s_{\textnormal{min}}^{2}/(256\cdot n^{3}\log^{2}n\cdot t_{\textnormal{mix}}^{2})$. If $\abs{\mw_{ij}-\tilde{\mw}_{ij}}\leq\epsilon_{0}$ for all $i,j$, and $\norm{s-\tilde{s}}_{\infty}\leq\epsilon_{0}$, then $\abs{\tilde{C}_{uv}-C_{uv}}\leq\epsilon$, for all $u,v$. \end{lem} \begin{proof} Recall that, by Lemma~\ref{prop:commute-time}, we can write $C_{uv}=(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})$, and similarly for $\tilde{C}_{uv}$. We proceed to bounding the difference between them as follows: \begin{align} \abs{C_{uv}-\tilde{C}_{uv}} & =\abs{(\vec{1}_{u}-\vec{1}_{v})^{\top}(((\mI-\mw)\ms)^{\dagger}-((\mI-\tilde{\mw})\tilde{\ms})^{\dagger})(\vec{1}_{u}-\vec{1}_{v})}\nonumber \\ & \leq\norm{\vec{1}_{u}-\vec{1}_{v}}\norm{(((\mI-\mw)\ms)^{\dagger}-((\mI-\tilde{\mw})\tilde{\ms})^{\dagger})(\vec{1}_{u}-\vec{1}_{v})}\,.\label{eq:commute-difference} \end{align} Our goal will be to apply Lemma~\ref{lem:sol-perturb} with $\ma=(\mI-\mw)\ms$, $\Delta\ma=(\mI-\tilde{\mw})\tilde{\ms}-(\mI-\mw)\ms$, $b=e_{u}-e_{v}$. First let us bound $\norm{\ma^{\dagger}}$ and $\norm{\Delta\ma}$. First, we bound \begin{eqnarray*} \norm{\ma^{\dagger}} & = & \norm{((\mI-\mw)\ms)^{\dagger}}=\max_{x:(\mI-\mw)\ms x\neq0}\frac{\norm x}{\norm{(\mI-\mw)\ms x}}\\ & \leq & \max_{x:(\mI-\mw)\ms x\neq0}\frac{\norm{\ms^{-1}}\norm{\ms x}}{\norm{(\mI-\mw)\ms x}}=\norm{\ms^{-1}}\norm{(\mI-\mw)^{\dagger}}\\ & \leq & 4\cdot n\log n\cdot t_{\textnormal{mix}}/s_{\textnormal{min}}\,. \end{eqnarray*} For the last inequality, we used the bound on $\norm{(\mI-\mw)^{\dagger}}$ from Theorem~\ref{thm:mixingTimesSingular}. Second, we bound $\norm{\Delta\ma}$. Applying triangle inequality, we obtain \begin{eqnarray*} \norm{\Delta\ma} & \leq & \norm{((\mI-\tilde{\mw})-(\mI-\mw))\tilde{\ms}}+\norm{(\mI-\mw)(\tilde{\ms}-\ms)}\\ & \leq & \norm{\tilde{\mw}-\mw}\norm{\tilde{\ms}}+\norm{\mI-\mw}\norm{\tilde{\ms}-\ms}\,. \end{eqnarray*} Since we have an entry-wise bound on the difference between $\tilde{\mw}$ and $\mw$, we can upper bound $\norm{\tilde{\mw}-\mw}$ with the Frobenius norm $\norm{\tilde{\mw}-\mw}_{F}\leq n\epsilon_{0}$. Also $\tilde{\ms}$ is a stationary, so $\norm{\tilde{\ms}}\leq1$. Additionally, the additive error on $\tilde{s}$, bounds $\norm{\tilde{\ms}-\ms}\leq\epsilon_{0}$. Also $\norm{\mI-\mw}_{2}\leq\sqrt{\norm{\mI-\mw}_{1}\cdot\norm{\mI-\mw}_{\infty}}\leq\sqrt{2\cdot n}$. Combining these, we obtain \[ \norm{\Delta\ma}\leq n\epsilon_{0}+\sqrt{2n}\cdot\epsilon_{0}\leq\frac{1}{2\norm{\ma^{\dagger}}}\,. \] Therefore we can plug our bounds into in our bounds into Lemma~\ref{lem:sol-perturb}, and obtain $\frac{\norm{(\ma'^{\dagger}-\ma^{\dagger})b}}{\norm{\ma^{\dagger}b}}\leq\frac{\norm{\ma^{\dagger}}\norm{\Delta\ma}}{1-\norm{\ma^{\dagger}}\norm{\Delta\ma}}\leq2\norm{\ma^{\dagger}}\norm{\Delta\ma}$, and equivalently $\norm{(\ma'^{\dagger}-\ma^{\dagger})b}\leq2\norm{\ma^{\dagger}}^{2}\norm{\Delta\ma}\norm b$. Finally, combining with Equation~\ref{eq:commute-difference}, we obtain $\abs{\tilde{C}_{uv}-C_{uv}}\leq\sqrt{2}\cdot2\norm{\ma^{\dagger}}^{2}\norm{\Delta\ma}\norm b\leq4\cdot\left(\frac{4n\log n\cdot t_{\textnormal{mix}}}{s_{\textnormal{min}}}\right)^{2}\cdot\left(n\epsilon_{0}+\sqrt{2n}\cdot\epsilon_{0}\right)\leq\epsilon$. \end{proof} \begin{lem} \label{prop:(Bounding-commute-times)}(Bounding commute times) Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix corresponding to an irreducible Markov chain, and let $s_{\textnormal{min}}$ and $w_{\textnormal{min}}$ be its smallest stationary probability, and smallest transition probability, respectively. Then any commute time $C_{uv}$ satisfies $C_{uv}\leq n/(s_{\textnormal{min}}w_{\textnormal{min}})$. \end{lem} \begin{proof} We will use the fact that commute times form a metric. Then any commute time $C_{uv}$ is upper bounded by the sum of commute times over arcs in $\mw$ with nonzero probability. Using Lemma~\ref{prop:commute-time}, we can therefore bound \begin{eqnarray*} C_{uv} & \leq & \sum_{i\neq j:\mw_{ij}>0}(\vec{1}_{i}-\vec{1}_{j})^{\top}\left(\mlap_{b}\mU_{b}^{\dagger}\mlap_{b}^{\top}\right)^{\dagger}(\vec{1}_{i}-\vec{1}_{j})\\ & \leq & \frac{1}{\min_{i\neq j:\mw_{ij}>0}\abs{\mU_{b}}_{ij}}\cdot\sum_{i\neq j:\mw_{ij}>0}\left(\mlap_{b}\mU_{b}^{\dagger}\mlap_{b}^{\top}\right)^{\dagger}\bullet\left((\vec{1}_{i}-\vec{1}_{j})(\vec{1}_{i}-\vec{1}_{j})^{\top}\cdot\abs{\mU_{b}}_{ij}\right)\\ & \leq & \frac{1}{\min_{i\neq j:\mw_{ij}>0}\abs{\mU_{b}}_{ij}}\cdot\tr\left(\left(\mlap_{b}\mU_{b}^{\dagger}\mlap_{b}^{\top}\right)^{\dagger}\mU_{b}\right)\,. \end{eqnarray*} From Lemma~\ref{lem:lapbounds} we have that $\mlap_{b}\mU_{b}^{\dagger}\mlap_{b}^{\top}\succeq\mU_{b}$, and therefore $\left(\mlap_{b}\mU_{b}^{\dagger}\mlap_{b}^{\top}\right)^{\dagger}\preceq\mU_{b}^{\dagger}$. Hence $\tr\left(\left(\mlap_{b}\mU_{b}^{\dagger}\mlap_{b}^{\top}\right)^{\dagger}\mU_{b}\right)\leq\tr\left(\mU_{b}^{\dagger}\mU_{b}\right)=n-1$. So \[ C_{uv}\leq\frac{n-1}{\min_{i\neq j:\mw_{ij}>0}\abs{\mU_{b}}_{ij}}\,. \] Finally, since $\left(\mU_{b}\right)_{ij}\geq\left(\mlap_{b}\right)_{ij}=\left(\left(\mI-\mw^{\top}\right)\ms\right)_{ij}$, we have that \begin{eqnarray*} \min_{i\neq j:\mw_{ij}>0}\abs{\mU_{b}}_{ij} & \geq & \min_{i\neq j:\mw_{ij}>0}\left(\mw^{\top}\ms\right)_{ij}\geq s_{\textnormal{\ensuremath{\min}}}w_{\textnormal{min}}\,. \end{eqnarray*} Therefore \[ C_{uv}\leq\frac{n-1}{s_{\textnormal{min}}w_{\textnormal{min}}}\,. \] \end{proof} Finally, we can combine Lemmas~\ref{lem:sketch-exact-stationary}, \ref{prop:produce-exact-stationary}, and \ref{prop:approx-commute} in order to obtain the following result: \begin{thm} Let $\mw\in\R_{\geq0}^{n\times n}$ be the random walk matrix of a Markov chain associated with a strongly connected graph. Let $M\geq t_{\textnormal{mix}}$, $\sigma\leq s_{\textnormal{min}}$, where $s_{\textnormal{min}}$ represents the smallest stationary probability, and let $w_{\textnormal{min}}$ be the smallest transition probability. Then Algorithm~\ref{alg:commute-time-final} computes in time $O(\tsolve((\log\frac{nM}{\epsilon\sigma})^{2}+\frac{1}{\epsilon^{2}}\log\frac{n}{\epsilon\sigma w_{\textnormal{min}}}))$ an $O(\log n/\epsilon^{2})\times n$ matrix $\tilde{\my}$ such that, $(1-\epsilon)C_{uv}\leq\left\Vert \tilde{\my}(e_{u}-e_{v})\right\Vert _{2}^{2}\leq(1+\epsilon)C_{uv}$, with high probability in $n$. \end{thm} \begin{proof} We start by proving correctness. First, we see that the commute times in $\tilde{\mw}$ approximate the original ones within $1+\epsilon/2$. Indeed, as seen in Lemma~\ref{prop:produce-exact-stationary}, running Algorithm~\ref{alg:commute-time-approx} on $\mw$ with accuracy $\epsilon_{0}=\frac{\sigma^{2}}{256\cdot n^{3}\log^{2}n\cdot M^{2}}\cdot\frac{\epsilon}{2}$ produces a walk matrix $\tilde{\mw}$ with stationary $\tilde{s}$, whose entries approximate those of $\mw$ within additive error $\epsilon_{0}$. Furthermore $s_{i}+\epsilon_{0}\sigma/2\geq\tilde{s}_{i}\geq s_{i}/(1+\epsilon_{0}\sigma)$, which immediately implies $\norm{\tilde{s}-s}_{\infty}\leq\epsilon_{0}$. Hence, by Lemma~\ref{prop:approx-commute}, $\abs{\tilde{C}_{uv}-C_{uv}}\leq\epsilon/2$ for all $u,v$. Then, running Algorithm~\ref{alg:commute-time-sketch} on $(\tilde{\mw},\tilde{s})$ we obtain a matrix $\tilde{\my}$, which we can use to sketch all commute times in $\tilde{\mw}$ with multiplicative error $1+\epsilon/3$. Therefore $\tilde{\my}$ sketches commute times in $\mw$ with multiplicative error $1+\epsilon$. Next, we bound the total running time. The call to Algorithm~\ref{alg:commute-time-approx} requires time $O(\tsolve(\log\frac{nM}{\epsilon_{0}\sigma})^{2})=O(\tsolve(\log\frac{nM}{\epsilon\sigma})^{2})$. The running time of the call to Algorithm~\ref{alg:commute-time-sketch} depends on the minimum stationary probability, and the smallest transition probability of $\tilde{\mw}$:$\tilde{s}_{\textnormal{min}}$ and $\tilde{w}_{\textnormal{min}}$, respectively. From Lemma~\ref{prop:produce-exact-stationary}, we see that these are within constant factors from the originals. Therefore, the running time of this call is $O(\tsolve\cdot\log\frac{n}{\epsilon\sigma w_{\textnormal{min}}}\cdot\frac{1}{\epsilon^{2}})$. Putting these bounds together, we obtain our bound. \end{proof} \begin{algorithm2e}[H] \caption{Commute Time Sketch Computation}\label{alg:commute-time-final} \SetAlgoLined \textbf{Input: }Random walk matrix $\mw\in\R_{\geq0}^{n\times n}$, upper bound $M\geq t_{\textnormal{mix}}$, lower bound $\sigma\leq s_{\textnormal{min}}$, accuracy $\epsilon\in(0,1)$. Run Algorithm~\ref{alg:commute-time-approx} on input $\mw$, $M$, $\sigma$, $\epsilon_{0}=\frac{\sigma^{2}}{256\cdot n^{3}\log^{2}n\cdot M^{2}}\cdot\frac{\epsilon}{2}$ Let $(\tilde{\mw},\tilde{s})$ be the output produced by Algorithm~\ref{alg:commute-time-approx}. Run Algorithm~\ref{alg:commute-time-sketch} on input $\tilde{\mw}$, $\tilde{s}$, $\epsilon/3$ Let $\tilde{\my}$ be the matrix produced by Algorithm~\ref{alg:commute-time-sketch}. \textbf{Output}: $\tilde{\my}$ \end{algorithm2e} \subsection{Condition Number and Stationary Distribution Estimation \label{subsec:app-cond-est}} Here we show how to use the PageRank computation algorithm from Section~\ref{subsec:app-pagerank} to estimate various ``condition number'' like quantities associated with a directed Laplacian or a random walk matrix. We use these quantities to parameterize the running times of the algorithms presented throughout the remainder of Section~\ref{sec:applications}. In particular, we use the relationships between the smallest singular value of $\mlap$, the mixing time, and the personalized PageRank mixing time proved in Section~\ref{sec:application_quantities} to estimate each up to polynomial factors in the quantities and $n$. Furthermore, we use the bounds of Section~\ref{sec:application_quantities} to obtain precise estimates to the stationary distribution. The key results of this section are summarized in the following theorem, whose proof we defer to the end of this Section~\ref{subsec:app-cond-est}. \begin{thm} \label{thm:cond_and_stationary_est} Let $\mlap=\mI-\mw\in\R^{n\times n}$ be directed Laplacian associated with a strongly connected graph. Let $\kappa$ be any of the mixing time of $\mw$, $t_{mix}$, the personalized PageRank mixing time of $\mw$, and $\kappa(\mlap)$. Then in time $O(\tsolve\cdot\log^{2}(n\cdot\kappa))$ with high probability in $n$ we can compute $\tilde{\kappa}$ such that \[ t_{pp}\leq\tilde{\kappa}\leq400n^{2}\norm{\mlap^{\dagger}}_{1}\enspace\textnormal{\textit{and}}\enspace n^{-1/2}\log_{2}^{-1/2}(n)\norm{\mlap^{\dagger}}_{1}\leq\tilde{\kappa}\leq400n^{2}\norm{\mlap^{\dagger}}_{1}, \] and \[ t_{pp}\leq\tilde{\kappa}\leq6400n^{2.5}\log_{2}(n)\cdot t_{pp}\,\enspace\text{\textit{and}}\enspace\frac{1}{16}n^{-1/2}\log_{2}^{-1/2}(n)\sqrt{t_{\text{mix}}}\leq\tilde{\kappa}\leq1600n^{2.5}\log_{2}(n)t_{\text{mix}}\,. \] Furthermore, for any $\epsilon\in(0,1)$ in time $O(\tsolve\cdot\log^{2}(n\cdot\epsilon^{-1})$ we can compute $s'$ that approximates the stationary distribution $s$ of $\mw$, in the sense that $\norm{s'-s}_{2}\leq\epsilon\cdot\norm{\mlap^{\dagger}}_{1}$. Consequently, if instead we spend time $O(\tsolve\cdot\log^{2}(n\cdot\kappa\cdot\epsilon^{-1})$ we can obtain $\norm{s'-s}_{2}\leq\epsilon$ and if we spend time $O(\tsolve\cdot\log^{2}(n\cdot\kappa\cdot\kappa(\ms)\cdot\epsilon^{-1}))$ we can obtain $(1-\epsilon)\ms\preceq\ms'\preceq(1+\epsilon)\ms$. \end{thm} Note that we believe that significantly better estimates of the condition number quantities are possible. However, as our algorithms depend logarithmically on these quantities, the estimates that this theorem provides are more than sufficient to achieve our running time bounds. Our primary tools for proving Theorem~\ref{thm:cond_and_stationary_est} are the PageRank computation algorithm from Section~\ref{subsec:app-pagerank}. Lemma~\ref{lem:pers-page-rank}, and the structural results of Section~\ref{sec:application_quantities} allow us to relate the personalized PageRank mixing time to the quantities we wish to compute. Recall from Section~\ref{sec:application_quantities} that for a random walk matrix $\mw\in\R^{n\times n}$ associated with a strongly connected graph, the personalized PageRank mixing time, $t_{pp}$ is the smallest $k$ such that for all probability vectors $x\in\simplex^{n}$, \[ \norm{\mm_{pp(1/k)}x-s}_{1}\leq\frac{1}{2}\enspace\text{ where }\enspace\mm_{pp(1/k)}\defeq(1/k)(\mI-(1-(1/k))\mw)^{-1}\,. \] Our approach is to roughly estimate this quantity and use it to compute approximations to the other condition number quantities. Unfortunately computing this quantity directly requires knowing $s$. We circumvent this using the linearity of the PageRank matrix, specifically we use that \[ dist(\beta)\defeq\max_{x\in\R^{n}\,:\,x\perp\vec{1},\norm x_{1}\leq1}\norm{\mm_{pp(\beta)}x}_{1} \] is a constant factor approximation as shown in the following lemma. \begin{lem} \label{lem:simplerOperator} For any $\beta\in(0,1)$, \[ dist(\beta)\leq\max_{x\in\simplex^{n}}\norm{\mm_{pp(\beta)}x-s}_{1}\leq2\cdot dist(\beta). \] \end{lem} \begin{proof} Note that by Lemma~\ref{lem:equiv_helper_lemma} we have that \[ \max_{x\in\simplex}\norm{\mm_{pp(\beta)}x-s}_{1}=\norm{\mm_{pp(\beta)}x-s\vec{1}^{\top}x}_{1}=\max_{x\in\R^{n}:\,\norm x_{1}\leq1}\norm{\mm_{pp(\beta)}x-s\vec{1}^{\top}x}_{1}. \] This maximization can then be restricted to the set of vectors $x\perp1$, giving (again by by Lemma~\ref{lem:equiv_helper_lemma}): \[ \leq\max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm_{pp(\beta)}x-s\vec{1}^{\top}x}_{1}=\max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm_{pp(\beta)}x}_{1}=dist(\beta). \] To show the other direction, let $x\in\simplex^{n}$ be a maximizer of $\norm{\mm_{pp(\beta)}x-s}_{1}$. Let $y=\frac{1}{2}(x-s)$. We know that \[ \mm_{pp(\beta)}s=\beta\left(\mI-(1-\beta)\mw\right)^{-1}s=\beta\sum_{i=0}^{\infty}(1-\beta)^{i}\mw^{i}s=s \] and therefore $\norm{\mm_{pp(\beta)}y}_{1}=\norm{\mm_{pp(\beta)}x-s}_{1}$. Furthermore, $\vec{1}^{\top}y=0$ and by triangle inequality $\norm y_{1}\leq1$. Consequently, $y$ can be used in the maximization problem for $dist(\beta)$ and we have $dist(\beta)\geq\frac{1}{2}\norm{\mm_{pp(\beta)}x-s}_{1}$. \end{proof} Therefore the key to estimating $t_{pp}$ becomes estimating the $\ell_{1}$ operator norm of $\mm_{pp(1/k)}$ in the space orthogonal to $\vec{1}$. In the following lemma we show how to do this through random projections. \begin{lem} \label{lem:randomProjection} Given a matrix $\mm\in\R^{n\times n}$, we can determine w.h.p. in $n$ whether \[ \max_{x\in\R^{n}:x\perp1\,\norm x_{1}\leq1}\norm{\mm x}_{1}\geq\frac{1}{2}\enspace\text{ or }\enspace\max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm x}_{1}<\frac{1}{2n^{2}} \] by: \end{lem} \begin{enumerate} \item Evaluating $\norm{\mm x}_{2}$ to additive error $\frac{1}{4n}$ for $O(\log n)$ random unit vectors $x$ projected to be orthogonal to the all 1-s vector, and \item Return with the first case ($M$ having large $1\rightarrow1$ norm) if the result is at least $\frac{1}{4n}$ for any of the vectors and the second otherwise. \end{enumerate} \begin{proof} The fact that $\norm y_{2}\leq\norm y_{1}\leq n^{1/2}\norm y_{2}$ means we have: \[ \max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm x}_{1}\leq n^{1/2}\max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm x}_{2}\leq n^{1/2}\max_{x\in\R^{n}:\,x\perp1\,\norm x_{2}\leq1}\norm{\mm x}_{2}, \] and \[ \max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm x}_{1}\geq\max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm x}_{2}\geq n^{-1/2}\max_{x\in\R^{n}:\,x\perp1\,\norm x_{1}\leq1}\norm{\mm x}_{2} \] Consequently, approximating the $\ell_{2}$-matrix norm gives an $n$-approximation to the desired quantity. Furthermore, we have that for a random unit vector $x$ orthogonal to the all-1s vector, with constant probability its mass in the top eigenspace is at least $1/\mathrm{rank}(\mm)\geq1/n$ (see e.g. the proof of Theorem~7.2. of \cite{SpielmanTengSolver:journal}) and $\norm{\mm x}_{2}$ is at least $1/\sqrt{n}$ of the maximum. So taking $O(\log n)$ such vectors $x$ randomly and evaluating $\norm{\mm x}_{2}$ to additive error $1/4n$, and checking if $\norm{\mm x}_{2}\geq\frac{1}{4n}$ for any yields the result. \end{proof} Combining this estimation routine with a binary-search-like routine leads to an estimation routine whose pseudocode is shown in Algorithm~\ref{alg:approx_tpp}. \begin{algorithm2e} \caption{Approximating Page Rank Mixing Time}\label{alg:approx_tpp} \SetAlgoLined \textbf{Input: }Random walk matrix $\mw\in\R_{\geq0}^{n\times n}$ Initialize $k$ = 1 \Repeat{$\widetilde{dist}\leq\frac{1}{10}n^{-3/2}$}{ Initialize estimate $\widetilde{dist}=0$. \For{$O(\log n)$ steps}{ Pick a random unit vector $g$ orthogonal to the all-1's vector. Use Lemma~\ref{lem:pers-page-rank} with $\epsilon=\frac{1}{100}n^{-3/2}$ to compute approximation $\widetilde{z}$ to $\mm_{pp(1/k)}g$. Update estimate, $\widetilde{dist}=\max\{\widetilde{dist},\norm{\widetilde{z}}_{2}\}.$ } } \textbf{Output}: k \end{algorithm2e} Note that since mixing is not monotonic in $k$, this is not binary search in the strictest sense. However, the relatively large multiplicative error that we allow means we can still invoke Theorem~\ref{lem:superMixing} to provide guarantees for this process. \begin{lem} \label{lem:conditionNumberEstimate} In $O(\tsolve\cdot\log^{2}(n\cdot\norm{\mlap^{\dagger}}_{1}))$ time Algorithm~\ref{alg:approx_tpp} computes a quantity $\tilde{\kappa}$ such that \[ t_{pp}\leq\tilde{\kappa}\leq400n^{2}\norm{\mlap^{\dagger}}_{1}. \] \end{lem} \begin{proof} Since $\norm g_{2}\leq1,$ the errors from the approximate personalized PageRank calls to Lemma~\ref{lem:pers-page-rank} affect the results by at most an additive $\frac{1}{100}n^{-3/2}$. Lemma~\ref{lem:randomProjection} gives that if $\widetilde{dist}\leq\frac{1}{10}n^{-3/2}$, we have with high probability \[ \max_{x\in\R^{n}\,:\,x\perp\vec{1},\norm x_{1}\leq1}\norm{\mm_{pp(1/k)}x}_{1}\leq\frac{1}{4}, \] which by Lemma~\ref{lem:simplerOperator} implies $\max_{x\in\simplex^{n}}\norm{\mm_{pp(\beta)}x-s}_{1}\leq1/2$ with high probability, and therefore $k\geq t_{pp}$. On the other hand, Lemma~\ref{lem:ppLeft} gives that for any $k\geq400n^{2}\norm{\mlap^{\dagger}}_{1}$, we have for all $x\in\Delta^{n}$, \[ \norm{\mm_{pp(1/k)}x-s}_{1}\leq\frac{4}{k}\norm{\mlap^{\dagger}}_{1}\leq\frac{1}{100}n^{-2}. \] which by Lemma~\ref{lem:simplerOperator} implies $dist\leq\frac{1}{50}n^{-2}.$ \ref{lem:randomProjection} then gives that we will have $\widetilde{dist}\leq\frac{1}{10}n^{-2}$with probability. This gives the desired approximation ratio of the output $\tilde{k}$. Also, the fact that we only run the approximate Personalized PageRank algorithm from Lemma~\ref{lem:pers-page-rank} with $k\leq O(n^{2}\norm{\mlap^{\dagger}}_{1})$ gives the running time bound. \end{proof} We now have everything we need to prove Theorem~\ref{thm:cond_and_stationary_est}. Our bounds on the other condition number quantities come from Theorem~\ref{thm:mixingTimesSingular} and by applying Lemma~\ref{lem:pers-page-rank} and Lemma~\ref{lem:ppLeft} we obtain our stationary distribution estimation bounds. More precisely we compute a personalized PageRank vector on the uniform distribution with the restart probability small enough so that we can use Lemma~\ref{lem:ppLeft} to reason about the error in this computation. \begin{proof}[Proof of Theorem~\ref{thm:cond_and_stationary_est}] Computing the condition number estimate, $\tilde{\kappa}$, using Lemma~\ref{lem:conditionNumberEstimate} and then applying Theorem~\ref{thm:mixingTimesSingular} yields our bounds on $\tilde{\kappa}$. The form of the running time follows again from the equivalence of condition numbers from Lemma~\ref{lem:conditionNumberEstimate} and the fact that $\norm{\mlap^{\dagger}}_{1}=O(\mathrm{poly}(n,\kappa(\mlap))$. (See Section~\ref{sec:application_quantities}). All that remains is to compute the estimates $s'$ to the stationary distribution. To prove the results on stationary computation, we simply compute $y\approx\mm_{pp(\epsilon)}(\frac{1}{n}\vec{1})$ to $\epsilon$ accuracy using Lemma~\ref{lem:pers-page-rank}. Since $\norm{\frac{1}{n}\vec{1}}_{2}=1/\sqrt{n}$, Lemma~\ref{lem:pers-page-rank} yields that $\norm{y-\mm_{pp(\epsilon)}(\frac{1}{n}\vec{1})}_{2}\leq\epsilon/\sqrt{n}$ and computes this in time $O(\tsolve\cdot\log^{2}(\frac{n}{\epsilon})$. However, by Lemma~\ref{lem:ppLeft} we have $\norm{\mm_{pp(\epsilon)}(\frac{1}{n}\vec{1})-s}_{1}\leq4\epsilon\norm{\mlap^{\dagger}}_{1}$ and consequently \[ \norm{y-s}_{2}\leq\normFull{y-\mm_{pp(\epsilon)}(\frac{1}{n}\vec{1})}_{2}+\normFull{\mm_{pp(\epsilon)}(\frac{1}{n}\vec{1})-s}_{2}\leq\epsilon\left(1+4\norm{\mlap^{\dagger}}_{1}\right). \] Since $\norm{\mlap^{\dagger}}_{1}$ is larger than some absolute constant we see that by scaling down $\epsilon$ by a constant we obtain our first result on computing an approximation to $s$. The second follows from estimating $\norm{\mlap^{\dagger}}_{1}$ from the first part of the theorem and scaling down $\epsilon$ by that. The third follows from the fact that if we have $\norm{y-s}_{\infty}\leq\epsilon\cdot\min_{i\in[n]}s_{i}$ then $(1-\epsilon)\ms\preceq\my\preceq(1+\epsilon)\ms$ and noting that we can make sure this hold by seeing if $\norm{y-s}_{2}\leq\frac{\epsilon}{2}\cdot\min_{i\in[y]}y_{i}$ which must happen when $\norm{y-s}_{2}\leq\frac{\epsilon}{8}\cdot\min_{i\in[n]}s_{i}.$ The form of the running time follows from the fact that $\max_{i\in[n]}s_{i}\geq\frac{1}{n}$ and thus $1/\min_{i\in[n]}s_{ii}\leq n\cdot\kappa(\ms)$. \end{proof} \subsection{Escape probabilities\label{subsec:Escape-probabilities}} In this section we derive a simple formula for escape probabilities in a Markov chain, and show how to compute them using our directed Laplacian solver. We first define escape probabilities, then we show how they can be computed using our directed Laplacian solver. \begin{defn} \label{def:escape-prob}Let $u$ and $v$ be two different vertices in a Markov chain. The \textit{escape probability} $p_{w}$ denotes the probability that starting at vertex $w$, a random walk reaches $u$ before first reaching $v$.\footnote{One should note that escape probabilities can similarly be defined with respect to sets of vertices, not just singleton vertices. In particular, one can define escape probabilities just like above with respect to two disjoint sets $S$ and $T$. However, this instance reduces to the one above simply by contracting the sets into single vertices.} \end{defn} \begin{lem} \label{prop:escape-prob}Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix associated with a strongly connected graph. Let $s$ be its stationary distribution, and let $u,v$ be two of its vertices. Let $p$ be the vector of escape probabilities, where $p_{w}$ represents the probability that a random walk starting at $w$ reaches $u$ before $v$. Then \[ p=\beta\left(\alpha s+(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})\right)\,, \] where $\alpha=-e_{v}^{\top}\ms^{-1}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})$ and $\beta=\frac{1}{s_{u}(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}$. Furthermore, \[ \abs{\alpha}\leq\frac{t_{\textnormal{mix}}}{s_{\textnormal{min}}}\cdot8\sqrt{n}\log n \] and \[ \frac{1}{t_{\textnormal{mix}}\cdot8\sqrt{n}\log n}\leq\beta\leq\frac{1}{s_{\textnormal{min}}}\,. \] \end{lem} The proof can be found in Section~\ref{subsec:Escape-Probabilities}. Using it, we can compute escape probabilities in time $\tilde{O}(\tsolve)$ using the algorithm described below. \begin{algorithm2e} \caption{Escape Probability Computation}\label{alg:escape-prob-1} \SetAlgoLined \textbf{Input: }Random walk matrix $\mw\in\R_{\geq0}^{n\times n}$, lower bound $\sigma\leq s_{\textnormal{min}}$, upper bound $M\geq t_{\textnormal{mix}}$, vertices $u,v\in V$, accuracy $\epsilon\in(0,1)$. Let $\tilde{\epsilon}=\epsilon\sigma^{3}/\left(2000\cdot M^{2}\cdot n\log^{2}n\right)$. Call Theorem~\ref{thm:lap-pinv-solver} with $\mlap=\mI-\mw$, $b=\vec{1}_{u}-\vec{1}_{v}$, and $\epsilon'=\tilde{\epsilon}/(4\sqrt{2}\cdot n\log n\cdot M)$. Let $\tilde{z}$ be the approximation to $\mlap^{\dagger}b$ that resulted from invoking Theorem~\ref{thm:lap-pinv-solver}. Call Theorem~\ref{thm:cond_and_stationary_est} to compute the stationary of $\mw$ with additive error $\epsilon''=\sigma\tilde{\epsilon}$. Let $\tilde{s}$ be the approximate stationary resulting from invoking Theorem~\ref{thm:cond_and_stationary_est}. Let $\tilde{\alpha}=-\tilde{z}_{v}/\tilde{s}_{v}$, $\tilde{\beta}=\frac{1}{\tilde{s}_{u}(\vec{1}_{u}-\vec{1}_{v})^{\top}\tilde{\ms}^{-1}\tilde{z}}$, $\tilde{p}=\tilde{\alpha}\tilde{\beta}\tilde{s}+\tilde{\beta}\tilde{z}$. \textbf{Output}: $\tilde{p}$ \end{algorithm2e} \begin{thm} (Escape Probability Computation) Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix with $m$ non-zero entries, i.e. $\mI-\mw$ is a directed Laplacian, let $\sigma\leq s_{\textnormal{min}}$ be a lower bound on the minimum stationary probability, $M\geq t_{\textnormal{mix}}$ an upper bound on the mixing time, and let $u,v\in\left\{ 1,\dots,n\right\} $. Then for any $\epsilon\in(0,1)$, Algorithm~\ref{alg:escape-prob-1} computes a vector $\tilde{p}$ such that $\abs{\tilde{p}_{i}-p_{i}}\leq\epsilon$ for all $i$ with high probability in $n$ in time $O(\tsolve\log^{2}(\frac{nM}{\epsilon\sigma}))$, where $p$ is the vector of escape probabilities as defined in Definition~\ref{def:escape-prob}. \end{thm} \begin{proof} First we analyze the running time. From the description of the algorithm, we see that the running time is dominated by the calls to Theorem~\ref{thm:lap-pinv-solver}, respectively Theorem~\ref{thm:cond_and_stationary_est}. The first one computes $\tilde{z}$ in time time $O(\tsolve\log^{2}(\frac{n\cdot\kappa(s)\cdot\kappa(\mI-\mw)}{\epsilon'}))=O(\tsolve\log^{2}(\frac{nM}{\epsilon\sigma}))$. The second one computes $\tilde{s}$ in time $O(\tsolve\log^{2}(\frac{nM}{\epsilon''}))=O(\tsolve\log^{2}(\frac{nM}{\epsilon\sigma}))$. Hence the bound on running time. Next, we analyze the error. As seen in Lemma \ref{prop:escape-prob}, we can write the true escape probability vector as $p=\beta\left(\alpha s+z\right)$, where $z=\left(\mI-\mw\right)^{\dagger}(e_{u}-e_{v})$. Our algorithm uses the approximations to $s$ and $z$ that it has access to in order to obtain $\tilde{\alpha}$ and $\tilde{\beta}$. We will show that these approximate the original values sufficiently well to provide additive guarantees on each element of $\tilde{p}$. By definition, $\tilde{\epsilon}\leq\epsilon s_{\textnormal{min}}^{3}/\left(2000\cdot t_{\textnormal{mix}}^{2}\cdot n\log^{2}n\right)$. In order to provide bounds on the error of the approximation, we will prove that: \begin{enumerate} \item $\norm{\tilde{z}-z}_{\infty}\leq\tilde{\epsilon}$ \item $\abs{\tilde{s}_{i}-s_{i}}\leq\tilde{\epsilon}s_{i}$ for all $i$ \item $\abs{\alpha-\tilde{\alpha}}\leq\tilde{\epsilon}\cdot20\frac{t_{\textnormal{mix}}}{s_{\textnormal{min}}}\cdot\sqrt{n}\log n=\tilde{\epsilon}_{\alpha}$ \item $\abs{\tilde{\beta}-\beta}\leq\frac{18}{s_{\textnormal{min}}}\tilde{\epsilon}\cdot\beta=\tilde{\epsilon}_{\beta}\cdot\beta\,.$ \end{enumerate} Indeed, combining them we obtain \begin{align*} \norm{\tilde{p}-p}_{\infty} & =\norm{\tilde{\alpha}\tilde{\beta}\tilde{s}+\tilde{\beta}\tilde{z}-(\alpha\beta s+\beta z)}_{\infty}\\ & \leq\norm{\tilde{\alpha}\tilde{\beta}\tilde{s}-\alpha\beta s}_{\infty}+\norm{\tilde{\beta}\tilde{z}-\beta z}_{\infty}\\ & \leq\norm{\tilde{\beta}\tilde{s}(\tilde{\alpha}-\alpha)}_{\infty}+\norm{(\tilde{\beta}\tilde{s}-\beta s)\alpha}_{\infty}+\norm{\tilde{\beta}(\tilde{z}-z)}_{\infty}+\norm{(\tilde{\beta}-\beta)z}_{\infty}\\ & \leq\abs{\tilde{\beta}}\abs{\tilde{\alpha}-\alpha}\norm{\tilde{s}}_{\infty}+\abs{\alpha}\norm{\tilde{\beta}\tilde{s}-\beta s}_{\infty}+\abs{\tilde{\beta}}\norm{\tilde{z}-z}_{\infty}+(\tilde{\beta}-\beta)\norm z_{\infty}\\ & \leq(1+\tilde{\epsilon}_{\beta})\beta\cdot\tilde{\epsilon}_{\alpha}\cdot(1+\tilde{\epsilon})+\abs{\alpha}\cdot2(\tilde{\epsilon}+\tilde{\epsilon}_{\beta})\norm{\beta s}_{\infty}+(1+\tilde{\epsilon}_{\beta})\beta\tilde{\epsilon}+\tilde{\epsilon}_{\beta}\beta\norm z_{\infty}\,. \end{align*} Next, we use the fact that $z=\frac{1}{\beta}p-\alpha s$, hence $\norm z_{\infty}\leq\frac{1}{\beta}\norm p_{\infty}+\abs{\alpha}\norm s_{\infty}\leq\frac{1}{\beta}+\abs{\alpha}$. Combining with the previous bound we obtain \begin{align*} \norm{\tilde{p}-p}_{\infty} & \leq\tilde{\epsilon}_{\alpha}(1+\tilde{\epsilon})(1+\tilde{\epsilon}_{\beta})\beta+2(\tilde{\epsilon}+\tilde{\epsilon}_{\beta})\abs{\alpha}\beta+\tilde{\epsilon}(1+\tilde{\epsilon}_{\beta})\beta+\tilde{\epsilon}_{\beta}\beta\left(\frac{1}{\beta}+\abs{\alpha}\right)\\ & \leq\tilde{\epsilon}_{\alpha}\cdot12\abs{\alpha}\beta\\ & \leq\tilde{\epsilon}_{\alpha}\cdot12\cdot\left(\frac{t_{\textnormal{mix}}}{s_{\textnormal{min}}}\cdot8\sqrt{n}\log_{2}n\right)\cdot\frac{1}{s_{\textnormal{min}}}\\ & \leq\epsilon\,. \end{align*} Therefore it suffices to prove statements 1\textendash 4 from before. \begin{enumerate} \item Theorem~\ref{thm:lap-pinv-solver} gives us that $\norm{\tilde{z}-(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}_{2}\leq\epsilon'\norm x_{2}\leq\epsilon'\cdot\frac{1}{4\sqrt{2}\cdot n\log_{2}(n)\cdot M}\cdot\norm x_{2}$. Therefore $\norm{\tilde{z}-z}_{2}\leq\tilde{\epsilon}$. \item Theorem~\ref{thm:cond_and_stationary_est} gives us that $\norm{\tilde{s}-s}_{\infty}\leq\norm{\tilde{s}-s}_{2}\leq\epsilon''$. Hence $\abs{\tilde{s}_{i}-s_{i}}\leq\frac{\epsilon''}{s_{\textnormal{min}}}\cdot s_{i}\leq\tilde{\epsilon}s_{i}$ for all $i$. \item We write $\abs{\tilde{\alpha}-\alpha}=\abs{\frac{\tilde{z}_{v}}{\tilde{s}_{v}}-\frac{z_{v}}{s_{v}}}=\abs{\frac{s_{v}}{\tilde{s}_{v}}\cdot\frac{\tilde{z}_{v}}{s_{v}}-\frac{z_{v}}{s_{v}}}\leq\abs{\frac{\tilde{z}_{v}}{s_{v}}-\frac{z_{v}}{s_{v}}}+\abs{\left(\frac{s_{v}}{\tilde{s}_{v}}-1\right)\cdot\frac{\tilde{z}_{v}}{s_{v}}}$. Next, using the additive bound on $\tilde{z}$, respectively the multiplicative bound on $\tilde{s}_{v}$ we see that this is further upper bounded by $\frac{1}{s_{v}}\abs{\tilde{z}_{v}-z_{v}}+\abs{2\tilde{\epsilon}s_{v}\cdot\frac{\tilde{z}_{v}}{s_{v}}}\leq\frac{1}{s_{\textnormal{min}}}\cdot\abs{\tilde{z}_{v}-z_{v}}+2\tilde{\epsilon}\cdot\tilde{z}_{v}$. Applying triangle inequality, we see that this is at most $\abs{\tilde{z}_{v}-z_{v}}\cdot\left(\frac{1}{s_{\textnormal{min}}}+2\tilde{\epsilon}\right)+2\tilde{\epsilon}\cdot z_{v}.$ Similarly to the proof of Lemma~\ref{prop:escape-prob}, we bound $z_{v}\leq\norm{(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}_{1}\leq t_{\textnormal{mix}}\cdot8\sqrt{n}\log n$. Therefore $\abs{\tilde{\alpha}-\alpha}\leq\tilde{\epsilon}\cdot\frac{3}{s_{\textnormal{min}}}+\tilde{\epsilon}\cdot t_{\textnormal{mix}}\cdot16\sqrt{n}\log n$, which gives our bound. \item We have $\abs{\tilde{\beta}-\beta}=\abs{\frac{1}{\tilde{s}_{u}(\vec{1}_{u}-\vec{1}_{v})^{\top}\tilde{\ms}^{-1}\tilde{z}}-\frac{1}{s_{u}(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}}$. By triangle inequality, we see that this is at most $\abs{\left(\frac{1}{\tilde{s}_{u}}-\frac{1}{s_{u}}\right)\cdot\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}}+\abs{\frac{1}{\tilde{s}_{u}}\cdot\left(\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\tilde{\ms}^{-1}\tilde{z}}\right)}$. Using the multiplicative bound on $\tilde{s}$ we bound it with \[ \frac{2\tilde{\epsilon}}{s_{u}}\cdot\abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}}+\frac{1}{(1-\tilde{\epsilon})s_{u}}\cdot\abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\tilde{\ms}^{-1}\tilde{z}}}\,. \] Now let us bound $\abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\tilde{\ms}^{-1}\tilde{z}}}$. By triangle inequality, it is at most \[ \abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\tilde{z}}}+\abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\tilde{z}}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\tilde{\ms}^{-1}\tilde{z}}}\,. \] Using the multiplicative bound on $\tilde{s}$ we see that this is at most \[ \abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\tilde{z}}}+\abs{\frac{2\tilde{\epsilon}}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\tilde{z}}}\,, \] which, again, by triangle inequality we bound with \[ \abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\tilde{z}}}+2\tilde{\epsilon}\left(\abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}}+\abs{\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}-\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\tilde{z}}}\right)\,. \] Using $\abs{\frac{1}{a}-\frac{1}{a+b}}=\abs{\frac{b}{a(a+b)}}\leq2\abs{\frac{b}{a}}$, if $a+b\geq1$, with $a=(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z$ and $b=(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\tilde{z}-z)$ (which satisfies the conditions since $a\geq1$ and $\abs b\leq\norm{\ms^{-1}(\vec{1}_{u}-\vec{1}_{v})}_{2}\norm{\tilde{z}-z}_{2}\leq\frac{\sqrt{2}}{s_{\textnormal{min}}}\cdot\tilde{\epsilon}\leq\frac{1}{2}$) we obtain that the quantity above is at most \begin{align*} 2\abs{\frac{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\tilde{z}-z)}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}}(1+2\tilde{\epsilon})+\abs{\frac{2\tilde{\epsilon}}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}}\\ =\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}\cdot\left(2\abs{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\tilde{z}-z)}(1+2\tilde{\epsilon})+2\tilde{\epsilon}\right)\,. \end{align*} Applying the Cauchy-Schwarz inequality: $\abs{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\tilde{z}-z)}\leq\norm{\ms^{-1}(\vec{1}_{u}-\vec{1}_{v})^{\top}}_{2}\norm{\tilde{z}-z}_{2}$, we see that the quantity is at most \begin{align*} \frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}\left(2\norm{\ms^{-1}(\vec{1}_{u}-\vec{1}_{v})^{\top}}_{2}\norm{\tilde{z}-z}_{2}\cdot(1+2\tilde{\epsilon})+2\tilde{\epsilon}\right) & \leq\\ \frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}\left(\frac{2\sqrt{2}}{s_{\textnormal{min}}}\cdot\tilde{\epsilon}(1+2\tilde{\epsilon})+2\tilde{\epsilon}\right) & \leq\frac{1}{(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}\cdot\frac{8}{s_{\textnormal{min}}}\tilde{\epsilon}\,. \end{align*} Plugging back into the bound for $\abs{\tilde{\beta}-\beta}$ we obtain that \[ \abs{\tilde{\beta}-\beta}\leq\frac{1}{s_{u}(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}z}\left(2\tilde{\epsilon}+\frac{1}{(1-\tilde{\epsilon})}\cdot\frac{8}{s_{\textnormal{min}}}\tilde{\epsilon}\right)\leq\beta\cdot\frac{18}{s_{\textnormal{min}}}\tilde{\epsilon}\,. \] \end{enumerate} \end{proof} \subsection{\label{subsec:app-commute}Hitting and Commute Times} In this section we show how to compute hitting times and commute times for a random walk on a directed graph by solving only $O(1)$ linear systems involving the associated directed Laplacian. We first formally define hitting and commute times and then we provide Lemma~\ref{prop:hitting-time-rank-1} which yields a short formula of these quantities in terms of the directed Laplacian pseudoinverse. This suggests a natural algorithm which formally analyze in the main result of this section, Theorem~\ref{thm:(Hitting-Time-Computation)} to compute them, and then formally analyze the error required by this Laplacian solve. \begin{defn} \label{def:hitting-time}The \textit{hitting time} $H_{uv}$ denotes the expected number of steps a random walk starting at $u$ takes until first reaching $v$. \end{defn} \begin{defn} \label{def:commute-time}The \textit{commute time} $C_{uv}$ denotes the expected number of steps for a random walk starting at $u$ to reach $v$, then return to $u$. In other words, $C_{uv}=H_{uv}+H_{vu}$. \end{defn} These quantities can each be computed using the below identities, which hold for Markov chains whose associated graph is strongly connected. \begin{lem} \label{prop:hitting-time-rank-1} \label{prop:hitting-time-inner-prod} Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix associated to a strongly connected graph. Let $s$ be its stationary distribution. The hitting time $H_{uv}$ satisfies \[ H_{uv}=\left(\vec{1}-\vec{1}_{v}\cdot\frac{1}{s_{v}}\right)^{\top}(\mI-\mw)^{\dagger}\left(\vec{1}_{u}-\vec{1}_{v}\right)\,. \] \end{lem} We prove this identity in Section~\ref{subsec:Hitting-Time-Formula}. It suggests the following natural algorithm for computing hitting times. \begin{algorithm2e} \caption{Hitting Time Computation}\label{alg:hitting-time} \SetAlgoLined \textbf{Input: }Random walk matrix $\mw\in\R_{\geq0}^{n\times n}$, lower bound $\sigma\leq s_{\textnormal{min}}$, upper bound $M\geq t_{\textnormal{mix}}$, vertices $u,v\in V$, accuracy $\epsilon\in(0,1)$. Call Theorem~\ref{thm:lap-pinv-solver} with $\mlap=\mI-\mw$, $b=\vec{1}_{u}-\vec{1}_{v}$, and $\epsilon'=\epsilon\cdot\frac{\sigma}{16\sqrt{2}Mn^{1.5}\log n}$. Let $x'$ be the approximation to $\mlap^{\dagger}b$ that resulted from invoking Theorem~\ref{thm:lap-pinv-solver}. Call Theorem~\ref{thm:cond_and_stationary_est} to compute the stationary of $\mw$ with multiplicative error $\epsilon''=\epsilon\cdot\frac{\sigma}{16\sqrt{2}Mn\log n}$. Let $s'$ be the approximate stationary resulting from invoking Theorem~\ref{thm:cond_and_stationary_est}. \textbf{Output}: $\tilde{H}_{uv}=\left\langle x',\vec{1}-e_{v}\cdot\frac{1}{s'_{v}}\right\rangle $ . \end{algorithm2e} \begin{thm} \label{thm:(Hitting-Time-Computation)} (Hitting Time Computation) Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix with $m$ nonzero entries, associated with a strongly connected graph. Let $\sigma\leq s_{\textnormal{min}}$ be a lower bound on its minimum stationary probability, let $M\geq t_{\textnormal{mix}}$ be an upper bound on its mixing time, and let $u,v\in\left\{ 1,\dots,n\right\} $. Then for any $\epsilon\in(0,1)$, Algorithm~\ref{alg:hitting-time} computes $\tilde{H}_{uv}$ such that $\abs{\tilde{H}_{uv}-H_{uv}}\leq\epsilon$ in time $O(\tsolve\log^{2}(\frac{Mn}{\epsilon\sigma}))$, with high probability in $n$. \end{thm} \begin{proof} First we bound the running time. Theorem~\ref{thm:lap-pinv-solver} gives that approximates $\mlap^{\dagger}b$ takes time $O(\tsolve\log^{2}(\frac{n\kappa(\ms)\kappa(\mI-\mw)}{\epsilon'}))=O(\tsolve\log^{2}(\frac{Mn}{\epsilon\sigma}))$. The call to Theorem~\ref{thm:cond_and_stationary_est} produces an approximate stationary in time $O(\tsolve\log^{2}(\frac{nM\kappa(\ms)}{\epsilon''}))=O(\tsolve\log^{2}(\frac{nM}{\epsilon\sigma}))$. The desired bound then follows from all the other operations taking$O(n)$ time, which is sublinear in $\tsolve$. We write the approximation error $\abs{\tilde{H}_{uv}-H_{uv}}$ explicitly, and expand it by applying the triangle inequality. Letting $x=(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})$ we obtain: \begin{align*} \abs{\tilde{H}_{uv}-H_{uv}}=\abs{\langle x',\vec{1}-\vec{1}_{v}\cdot\frac{1}{s'_{v}}\rangle-\langle x,\vec{1}-\vec{1}_{v}\cdot\frac{1}{s_{v}}\rangle}\leq\left(\sum_{i}\abs{x'_{i}-x_{i}}\right)+\abs{\frac{x'_{v}}{s'_{v}}-\frac{x_{v}}{s_{v}}}\\ \leq\norm{x'-x}_{1}+\abs{\frac{x'_{v}-x_{v}}{s_{v}'}}+\abs{\frac{x_{v}}{s_{v}'}-\frac{x_{v}}{s_{v}}}\leq\norm{x'-x}_{2}\sqrt{n}\cdot\left(1+\frac{1}{s_{v}'}\right)+\abs{x_{v}}\left(\frac{1}{s_{v}'}-\frac{1}{s_{v}}\right)\,. \end{align*} The call to Theorem~\ref{thm:lap-pinv-solver} returns $x'$ satisfying $\Vert x-x'\Vert_{2}\leq\epsilon'\norm x_{2}$. Also, the call to Theorem~\ref{thm:cond_and_stationary_est} returns $s'$ satisfying $\abs{s'_{v}-s_{v}}\leq\epsilon''\cdot s_{v}$, so $\abs{\frac{1}{s_{v}'}-\frac{1}{s_{v}}}\leq\frac{2\epsilon}{s_{v}}$. Therefore, since $\abs{x_{v}}\leq\norm x_{2}$, \begin{align*} \abs{\tilde{H}_{uv}-H_{uv}}\leq\norm x_{2}\cdot\left(\epsilon'\sqrt{n}\cdot\left(1+\frac{1}{\sigma}\right)+\frac{2\epsilon''}{\sigma}\right)\,. \end{align*} Plugging in $\norm x_{2}\leq\norm{(\mI-\mw)^{\dagger}}_{2}\norm{\vec{1}_{u}-\vec{1}_{v}}_{2}$, we see that error satisfies \begin{align*} \abs{\tilde{H}_{uv}-H_{uv}} & \leq\norm{(\mI-\mw)^{\dagger}}_{2}\sqrt{2}\cdot\left(\epsilon'\sqrt{n}\cdot\left(1+\frac{1}{\sigma}\right)+\frac{2\epsilon''}{\sigma}\right)\\ & \leq M\cdot4n\log n\cdot\sqrt{2}\cdot\left(\epsilon'\sqrt{n}\cdot\left(1+\frac{1}{\sigma}\right)+\epsilon''\frac{2}{\sigma}\right)\,, \end{align*} where, for the last inequality, we used the bound on $\norm{(\mI-\mw)^{\dagger}}_{2}$ from Theorem~\ref{thm:mixingTimesSingular}. Plugging in the values for $\epsilon'$ and $\epsilon''$ yields the result. \end{proof} Combining the formulas for hitting times also leads to an expression for commute time, $C_{uv}=H_{uv}+H_{vu}$. It can be computed by simply invoking Theorem~\ref{thm:(Hitting-Time-Computation)} twice. \subsection{\label{subsec:app-pagerank}Computing Personalized PageRank Vectors} Here we show how to apply our RCDD solver to compute personalized PageRank vectors. The algorithm we provide and analyze in this section serves as the basis for many of the applications we provide throughout Section~\ref{sec:applications}. Recall that given a restart probability $\beta>0$ and a vector of teleportation probabilities $p$, the personalized PageRank vector of a Markov chain is defined as the vector $x$ satisfying \[ \beta\cdot p+(1-\beta)\mw x=x\,. \] Rearranging terms we have that this condition is equivalent to finding the $x$ such that \[ \mm_{\beta}x=p_{\beta}\enspace\text{ where }\enspace\mm_{\beta}=\frac{\beta}{1-\beta}\mI+\left(\mI-\mw\right)\enspace\text{ and }\enspace p_{\beta}=\frac{\beta}{1-\beta}\cdot p\,. \] Consequently it suffices to solve this linear system $\mm_{\beta}x=p_{\beta}$. We solve this system in three steps. First we use Theorem~\ref{thm:stat-from-dd} with Corollary~\ref{cor:alpha-rcdd-solver} to compute an approximate Eulerian scaling of $\mI-\mw$, which we denote $s$. Under this scaling we show that that $\mm_{\beta}\ms$ is $\alpha$-RCDD for a sufficiently small $\alpha$. Since $\mm_{\beta}\ms$ is $\alpha$-RCDD we can solve linear systems in it, i.e. compute a $y\approx y_{*}$where $\mm_{\beta}\ms y_{*}=p_{\beta}$, by Corollary~\ref{cor:alpha-rcdd-solver}. Final, we output $x=\ms y$ as our approximate personalized PageRank vector. This algorithm is stated formally in Algorithm~\ref{alg:stationary_ppr} and in Lemma~\ref{lem:pers-page-rank} we bound the running time of this algorithm and the quality of $x$ as an approximation personal PageRank vector. \begin{algorithm2e} \caption{Personalized PageRank Computation}\label{alg:stationary_ppr} \SetAlgoLined \textbf{Input: }Random walk matrix $\mw\in\R_{\geq0}^{n\times n}$, teleportation probability $\beta\in(0,1)$, accuracy $\epsilon\in(0,1)$ \textbf{Notation}: Let $\mm_{\beta}=\frac{\beta}{1-\beta}\mI+\left(\mI-\mw\right)$ and let $p_{\beta}=\frac{\beta}{1-\beta}\cdot p$. Call Theorem~\ref{thm:stat-from-dd} with $\alpha=\frac{\beta}{1-\beta}\cdot\frac{1}{3n}$ on $\mlap=\mI-\mw$ with Corollary~\ref{cor:alpha-rcdd-solver} as the $\alpha$-RCDD Z-matrix solver. Let $s\in\simplex^{n}$ be the approximate Eulerian scaling resulting from invoking Theorem~\ref{thm:stat-from-dd}. Call Corollary~\ref{cor:alpha-rcdd-solver} with $\ma=\mm_{\beta}\ms$, $b=p_{\beta}$, and $\epsilon'=\frac{\epsilon\beta}{45\sqrt{n}}$. Let $y$ be the approximation to $\ma^{-1}b$ that resulted from invoking Corollary~\ref{cor:alpha-rcdd-solver} \textbf{Output}: $x=\ms y$ \end{algorithm2e} \begin{lem} \label{lem:pers-page-rank} (Personalized PageRank Computation) Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix with $m$ non-zero entries, let $\beta\in(0,1)$ be a restart probability, let $p\in\R_{\geq0}^{n}$ be teleportation constants, and let $x_{*}$ be the corresponding personalized PageRank vector. Then for any $\epsilon\in(0,1)$, Algorithm~\ref{alg:stationary_ppr} computes a vector $x$ such that $\norm{x-x_{*}}_{2}\leq\epsilon\norm p_{2}$ with high probability in $n$ in time $O(\tsolve\cdot(\log^{2}\frac{n}{\beta}+\log\frac{1}{\epsilon}))$. \end{lem} \begin{proof} Here we analyze Algorithm~\ref{alg:stationary_ppr} step by step. First, consider the invocation Theorem~\ref{thm:stat-from-dd} with $\alpha=\frac{\beta}{1-\beta}\cdot\frac{1}{3n}$ on matrix $\mI-\mw$. By Theorem~\ref{thm:stat-from-dd} we know that the approximate Eulerian scaling $s\in\simplex^{n}$ is such that $\left(3\alpha n\cdot\mI+\left(\mI-\mw\right)\right)\ms$ is $\alpha$-RCDD and $\kappa(\ms)\leq\frac{20}{\alpha^{2}}n$. Furthermore, since we invoke Theorem~\ref{thm:stat-from-dd} using Corollary~\ref{cor:alpha-rcdd-solver} as the $\alpha$-RCDD Z-matrix solve we know that $\runtime$ in Theorem~\ref{thm:stat-from-dd} is $O(\tsolve\log(\frac{n}{\alpha}))$. Since $\tsolve=\Omega(m)$ invoking Theorem~\ref{thm:stat-from-dd} takes time $O((m+\tsolve\log(\frac{n}{\alpha}))\log\alpha^{-1})=O(\tsolve\log^{2}(\frac{n}{\beta}))$. Next, consider the invocation of Corollary~\ref{cor:alpha-rcdd-solver} on an $\ma$ and $b$. Note that $\alpha$ was chosen precisely so that $\left(3\alpha n\cdot\mI+\left(\mI-\mw\right)\right)\ms=\mm_{\beta}\ms$ and therefore by the reasoning in the preceding paragraph we know that $\mm_{\beta}\ms$ is $\alpha$-RCDD and therefore we can invoke Corollary~\ref{cor:alpha-rcdd-solver}. By Corollary~\ref{cor:alpha-rcdd-solver} we know that $\norm{y-y_{*}}_{\md}\leq\frac{\epsilon'}{\alpha}\norm{p_{\beta}}_{\md^{-1}}$ where $y_{*}=\ma^{-1}b=\ms^{-1}\mm_{\beta}^{-1}p_{\beta}$ and $\md=(\frac{\beta}{1-\beta}\mI+\mI)\ms=\frac{1}{1-\beta}\ms$. Moreover, we compute this approximation in time $O(\tsolve\log(1/\epsilon'))=O(\tsolve\log(\frac{n}{\epsilon\beta}))$ giving the overall running time. Finally, consider the vector $x=\ms y$ returned by the algorithm. Since $x_{*}=\ms y_{*}$we have \begin{align*} \norm{x-x_{*}}_{2} & =\norm{\ms y-\ms y_{*}}_{2}\leq\sqrt{\max_{i\in[n]}\ms_{ii}}\cdot\norm{y-y_{*}}_{\ms}=\sqrt{(1-\beta)\cdot\max_{i\in[n]}\ms_{ii}}\cdot\norm{y-y_{*}}_{\md}\\ & =\frac{\epsilon'}{\alpha}\sqrt{(1-\beta)\cdot\max_{i\in[n]}\ms_{ii}}\cdot\norm{p_{\beta}}_{\md^{-1}}\leq\frac{\epsilon'}{\alpha}(1-\beta)\sqrt{\kappa(\ms)}\norm{p_{\beta}}_{2}=\frac{\epsilon'}{\alpha}\beta\sqrt{\kappa(\ms)}\norm p_{2}\,. \end{align*} Now, using that $\alpha\geq\frac{\beta}{3n}$, $\kappa(\ms)\leq\frac{20}{\alpha^{2}}n$, and our choice of $\epsilon'$ the result follows. \end{proof} With this routine, we can also compute a good approximation of the stationary distribution via a sufficiently large $\beta$. \section{\label{sec:application_quantities}Condition Number Bounds} For the various applications of this paper (Section~\ref{sec:applications}) we use three quantities to measure the degeneracy or condition number of the matrices involved. Here we define these quantities and prove that they are equivalent up to polynomial factors. Since the running times for all algorithms provided in this paper depend on these quantities only poly-logarithmically, this allows us to use whichever quantity simplifies the analysis while only mildly affecting performance. We define these quantities for a directed Laplacian, $\mlap=\mI-\mw\in\R^{n\times n}$, where $\mw\in\R_{\geq0}^{n\times n}$ is the random walk matrix associated with a strongly connected graph. Note that for any Laplacian, $\mlap=\md-\ma^{\top}$, we have $\mlap\md^{-1}=\mI-\mw$; thus it is easy to relate these quantities to those of an arbitrary Laplacian, since $\kappa(\md-\ma)\leq\kappa(\mI-\ma\md^{-1})\cdot\kappa(\md)$.\\ \\ \textbf{Inverse of Second Smallest Singular Value}: This quantity is $\norm{\mlap^{\dagger}}_{2}$. Note that since $\norm{\mlap}_{2}\leq2n$, by Lemma~\ref{lem:lap-onenorm-bound} we have $\kappa(\mlap)\leq2n\norm{\mlap^{\dagger}}_{2}$. Thus, up to a polynomial dependence on $n$, this quantity bounds the condition number of $\mlap$.\\ \\ \textbf{(Lazy) Mixing Time}: This quantity is denoted $t_{mix}$. It is defined as the smallest $k$ such that $\norm{\lazywalk^{k}p-s}_{1}\leq\frac{1}{2}$, for all $p\in\simplex^{n}$, where $\lazywalk\defeq\frac{1}{2}(\mI+\mw)$ is the lazy random walk matrix associated with $\mw$, and $s\in\simplex^{n}$ is the stationary distribution associated with $\mw$.\\ \\ \textbf{Personalized PageRank Mixing Time}: This quantity is denoted $t_{pp}$. It is defined as the smallest $k\geq0$ such that, setting $\beta=\frac{1}{k}$, one has $\norm{\mm_{pp(\beta)}p-s}_{1}\leq\frac{1}{2}$, for all $p\in\simplex^{n}$; the matrix $\mm_{pp(\beta)}=\beta\left(\mI-(1-\beta)\mw\right)^{-1}$ is the personalized PageRank matrix with restart probability $\beta$ (See Section~\ref{sec:prelim}), and $s$ is the stationary distribution associated with $\mw$. Note that $\mm_{pp(\beta)}p$ is the personalized PageRank vector with restart probability $\beta$ and vector $p$.\\ \\ Each of these quantities is required for our applications, and they are involved in the running time guarantees we provide. The inverse of the second smallest singular value is related to the condition number of $\mlap$, and is used to bound the accuracy to which we need to solve various linear systems. The mixing time is related to many applications involving directed Markov chains. In order to obtain bounds on these quantities, we use the personalized PageRank mixing time, which can be computed accurately enough for our purposes (See Section~\ref{subsec:app-cond-est}). The main result of this section is to prove the following theorem showing how these different quantities are related. Rather than relating many of the quantities to $\norm{\mlap^{\dagger}}_{2}$ directly, we instead obtain cleaner bounds by relating them to the maximum column norm of $\mlap$, i.e. $\norm{\mlap^{\dagger}}_{1}$. Since for $x\in\R^{n}$ we have $\frac{1}{\sqrt{n}}\norm x_{1}\leq\norm x_{2}\leq\norm x_{1}$, it is easy to see that $\frac{1}{\sqrt{n}}\norm{\mlap^{\dagger}}_{1}\leq\norm{\mlap^{\dagger}}_{2}\leq\sqrt{n}\norm{\mlap^{\dagger}}_{1}$. \begin{thm} \label{thm:mixingTimesSingular} Let $\mlap=\mI-\mw\in\R^{n\times n}$ be a directed Laplacian, where $\mw\in\R_{\geq0}^{n\times n}$ is a random walk matrix associated with a strongly connected graph. The inverse of the second smallest singular value of $\mlap$, $\norm{\mlap^{\dagger}}_{2}$, the mixing time, $t_{mix}$, the personalized PageRank mixing time, $t_{pp}$, and the largest column norm of $\mlap^{\dagger},$ $\norm{\mlap^{\dagger}}_{1},$ obey the following: \begin{itemize} \item \textbf{Mixing Time vs. Column Norm}: $\frac{1}{16}\sqrt{t_{mix}}\leq\norm{\mlap^{\dagger}}_{1}\leq t_{mix}\cdot4\sqrt{n}\log_{2}n$ \item \textbf{Personalized PageRank Mixing vs. Singular Values}: $\frac{1}{8}t_{pp}\leq\norm{\mlap^{\dagger}}_{1}\leq t_{pp}\cdot16\sqrt{n}\log_{2}n$ \item \textbf{Mixing Time vs. Personalized PageRank Mixing} Time: $t_{pp}\leq36\cdot t_{mix}$ \item \textbf{Column Norm vs. Singular Values}: $\frac{1}{\sqrt{n}}\norm{\mlap^{\dagger}}_{1}\leq\norm{\mlap^{\dagger}}_{2}\leq\sqrt{n}\norm{\mlap^{\dagger}}_{1}$ \end{itemize} \end{thm} Note that the analysis of our applications only rely on the relationship between $t_{pp}$ and $\norm{\mlap^{\dagger}}_{1}$ that we provide in this section. However, we provide this full set of relationships both for completeness and to admit clean and more easily understood running times. Our proof of this theorem is split into several parts. First, in Section~\ref{subsec:Bounds-Between-Mixing} we provide an operator view of mixing times, and use this to prove the relationship between personalized PageRank mixing time and mixing time. Then in Section~\ref{subsec:Singular-Value-Lower} we prove upper bounds on $\norm{\mlap^{\dagger}}_{1}$, and in Section~\ref{subsec:Condition-Number-Upper} we prove lower bounds on $\norm{\mlap^{\dagger}}_{1}$. Along the way we provide a more fine grained understanding of personalized PageRank mixing time (Lemma~\ref{lem:ppLeft} and Lemma~\ref{lem:cond_to_tppr}) that may be of further use. \subsection{Bounds Between Mixing Times\label{subsec:Bounds-Between-Mixing}} Here we provide bounds between different possible notions of mixing times. First we provide Lemma~\ref{lem:equiv_helper_lemma}, a general mathematical lemma which implies that mixing time conditions are equivalent to certain operator norm statements on matrices, e.g. $\norm{\mw^{k}p-s}_{1}\leq\frac{1}{2}$ for all $p\in\simplex$ implies $\norm{\mw-s\vec{1}^{\top}}_{1}\leq\frac{1}{2}$. Using this we prove Lemma~\ref{lem:mix-c} which shows how the mixing amount of a random walk can be amplified, e.g. given $t_{mix}$ we can compute bounds on the smallest $k$ for which $\norm{\mw^{k}p-s}_{1}\leq\epsilon$, for any small enough $\epsilon$. Finally, we conclude this section with Lemma~\ref{lem:superMixing}, which relates $t_{mix}$ to $t_{pp}$. \begin{lem} \label{lem:equiv_helper_lemma} For all $\ma\in\R^{m\times n}$, $b\in\R^{n}$, and $\alpha\geq0$, one has that \[ \norm{\ma p-b}_{1}\leq\alpha,\textnormal{ for all }p\in\Delta^{n}, \] if and only if \[ \norm{\ma-b\vec{1}^{\top}}_{1}\leq\alpha\,. \] \end{lem} \begin{proof} Suppose $\norm{\ma-b\vec{1}^{\top}}_{1}\leq\alpha$. Then, for all $p\in\simplex^{n}$, \[ \norm{\ma p-b}_{1}=\normFull{(\ma-b\vec{1}^{\top})p}_{1}\leq\alpha\norm p_{1}=\alpha \] yielding one direction of the claim. On the other hand, suppose $\norm{\ma p-b}_{1}\leq\alpha$ for all $p\in\simplex^{n}$. Let $x\in\R^{n}$ be arbitrary. Decompose $x$ into its positive and negative coordinates, i.e. define $x_{+},x_{-}\in\R_{\geq0}^{n}$ as the unique vectors such that $x=x_{+}-x_{-}$, and at most one of $x_{+}$ and $x_{-}$ is non-zero in a coordinate. Now, if $\norm{x_{+}}_{1}=0$ or $\norm{x_{-}}_{1}=0$ then for some $s\in\{-1,1\}$ we have $s\cdot x/\norm x_{1}\in\simplex^{n}$ and \[ \normFull{\left(\ma-b\vec{1}^{\top}\right)x}_{1}=\norm x_{1}\cdot\normFull{\ma\frac{x}{\norm x_{1}}-b}_{1}\leq\norm x_{1}\cdot\alpha\,. \] Otherwise, by triangle inequality \begin{align*} \normFull{\left(\ma-b\vec{1}^{\top}\right)x}_{1} & \leq\normFull{\left(\ma-b\vec{1}^{\top}\right)x_{+}}_{1}+\normFull{\left(\ma-b\vec{1}^{\top}\right)x_{-}}_{1}\\ & =\norm{x_{+}}_{1}\cdot\normFull{\ma\frac{x_{+}}{\norm{x_{+}}}-b}_{1}+\norm{x_{-}}_{1}\cdot\normFull{\ma\frac{x_{-}}{\norm{x_{-}}}-b}_{1}\,. \end{align*} Since $\frac{x_{+}}{\norm{x_{+}}}\in\simplex^{n}$ and $\frac{x_{-}}{\norm{x_{-}}}\in\simplex^{n}$, we have $\normFull{\ma\frac{x_{+}}{\norm{x_{+}}}-b}_{1}\leq\alpha$ and $\normFull{\ma\frac{x_{-}}{\norm{x_{-}}}-b}_{1}\leq\alpha$. Furthermore, since $\norm x_{1}=\norm{x_{+}}_{1}+\norm{x_{-}}_{1}$ we have that $\normFull{\left(\ma-b\vec{1}^{\top}\right)x}_{1}\leq\norm x_{1}\cdot\alpha$. In either case, the claim holds. \end{proof} \begin{lem} \label{lem:mix-c} Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix associated with a strongly connected graph. Let $s$ be its stationary distribution, and let $t_{mix}$ be its mixing time. Then for all $k\geq t_{mix}$ and $x\perp s$ we have \[ \norm{\mw^{k}x-s}_{1}\leq\left(\frac{1}{2}\right)^{\left\lfloor \frac{k}{t_{mix}}\right\rfloor }\enspace\text{ and }\enspace\norm{\mw^{k}-s\vec{1}^{\top}}_{1}\leq\left(\frac{1}{2}\right)^{\left\lfloor \frac{k}{t_{mix}}\right\rfloor }\,. \] \end{lem} \begin{proof} First note that, since $\mw s=s$, it is the case that $\mw^{k}x-s=\mw^{k}(x-s)$. Furthermore, since $\norm{\mw}_{1}=1$, we have that \[ \norm{\mw^{k+1}x-s}_{1}=\norm{\mw(\mw^{k}x-s)}_{1}\leq\norm{\mw^{k}x-s}_{1}\,. \] Consequently, $\norm{\mw^{k}x-s}_{1}$ decreases monotonically with $k$ and by Lemma~\ref{lem:equiv_helper_lemma} it therefore suffices to prove the claim for $k=c\cdot t_{mix}$ for positive integers. Next, by the definition of $t_{mix}$ and Lemma~\ref{lem:equiv_helper_lemma} we know that $\norm{\mw-s\vec{1}^{\top}}_{1}\leq\frac{1}{2}$. Furthermore, since $\vec{1}^{\top}\mw=\vec{1}^{\top}$ and since $\mw s=s$, for all non-negative integers $\alpha$, we have that \[ (\mw^{\alpha}-s\vec{1}^{\top})(\mw-s\vec{1})=\mw^{\alpha+1}-s\vec{1}^{\top}\mw-\mw^{\alpha}s\vec{1}+s\vec{1}^{\top}s\vec{1}=\mw^{\alpha+1}-s\vec{1}^{\top}\,. \] By induction, we know that for all non-negative integers $c$ it is the case that \[ \norm{\mw^{c\cdot t_{mix}}-s\vec{1}^{\top}}_{1}=\normFull{\left(\mw^{t_{mix}}-s\vec{1}^{\top}\right)^{c}}_{1}\leq\left(\frac{1}{2}\right)^{c}\,. \] Applying Lemma~\ref{lem:equiv_helper_lemma} again yields the result. \end{proof} We also show the following bound based on amplifying mixed walks: \begin{lem} \label{lem:superMixing} Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix associated with a strongly connected graph, and let $s$ and be its stationary distribution, and let $t_{mix}$ be its mixing time. Let $\mm_{pp(\beta)}$ be the personalized PageRank matrix with restart probability $\beta$ associated with $\mw$. For all $k\geq1$, $\beta\leq(k\cdot t_{mix})^{-1}$, $x\in\simplex^{n}$, we have $\norm{\mm_{pp(\beta)}x-s}_{1}\leq3k^{-1/2}$. Consequently, the personalized PageRank mixing time $t_{pp}$ obeys $t_{pp}\leq36\cdot t_{mix}$. \end{lem} \begin{proof} First, a little algebraic manipulation reveals that for $\gamma=\frac{\beta}{2-\beta}$, \[ \mI-(1-\beta)\mw=(2-\beta)\mI-2(1-\beta)\lazywalk=(2-\beta)\cdot\left(\mI-2\left(\frac{1-\beta}{2-\beta}\right)\lazywalk\right)=\frac{\beta}{\gamma}\left(\mI-(1-\gamma)\lazywalk\right)\,. \] Consequently, since $(\mI-(1-\gamma)\lazywalk)\frac{1}{\gamma}s=s$ we have \begin{align*} \mm_{pp(\beta)}x-s & =\mbox{\ensuremath{\gamma\left(\mI-(1-\gamma)\lazywalk\right)}}^{-1}(x-s)=\gamma\sum_{i=0}^{\infty}(1-\gamma)^{i}\lazywalk^{i}(x-s)\,. \end{align*} Now, by triangle inequality, we know that \[ \norm{\mm_{pp(\beta)}x-s}_{1}\leq\gamma\sum_{i=0}^{\infty}(1-\gamma)^{i}\norm{\mw^{i}(x-s)}_{1}\,. \] Since, $\norm{\mw^{i}}_{1}\leq1$ and $\norm{x-s}_{1}\leq2$, we have that the first $\lfloor\sqrt{k}t_{mix}\rfloor$ terms sum to at most $2\gamma\sqrt{k}t_{mix}\leq2k^{-1/2}$. Furthermore, Lemma~\ref{lem:mix-c} implies that for all $i>\lceil\sqrt{k}t_{mix}\rceil$ we have \begin{eqnarray*} \norm{\mw^{k}x-s}_{1} & \leq & \left(\frac{1}{2}\right)^{\lfloor\frac{i}{t_{mix}}\rfloor}\leq2^{-\lfloor\sqrt{k}\rfloor}\leq\frac{1}{\sqrt{k}} \end{eqnarray*} for $k\geq1$, and therefore the remaining terms sum to at most $k^{-1/2}$. \end{proof} \subsection{Singular Value Lower Bounds \label{subsec:Singular-Value-Lower}} Here we show how to lower bound $\norm{\mlap^{\dagger}}_{1}$ in terms of the mixing time and personalized PageRank mixing time. First we provide a small technical lemma, Lemma~\ref{lem:tech-large-simplex-diff}, that will be used to reason about vectors orthogonal to stationary distribution. Then, using this result, in Lemma~\ref{lem:mixLeft} we lower bound $\norm{\mlap^{\dagger}}_{1}$ by the mixing time, and in Lemma~\ref{lem:ppLeft} we lower bound $\norm{\mlap^{\dagger}}_{1}$ by the personalized PageRank mixing time. \begin{lem} \label{lem:tech-large-simplex-diff} For all $a,b\in\simplex^{n}$ and $\alpha\in\R$, we have that \[ \norm{a-\alpha b}_{1}\geq\frac{1}{2}\norm{a-b}_{1}\,. \] \end{lem} \begin{proof} If $\left|1-\alpha\right|\geq\frac{1}{2}\norm{a-b}_{1}$ then \[ \norm{a-\alpha b}_{1}\geq\left|\sum_{i\in[n]}a_{i}-\alpha b_{i}\right|=\left|1-\alpha\right|\geq\frac{1}{2}\norm{a-b}_{1}\,. \] On the other hand if $\left|1-\alpha\right|\leq\frac{1}{2}\norm{a-b}_{1}$ then by reverse triangle inequality we have \[ \norm{a-\alpha b}_{1}\geq\norm{a-b}_{1}-\norm{(\alpha-1)b}_{1}\geq\norm{a-b}_{1}-\left|1-\alpha\right|\geq\frac{1}{2}\norm{a-b}_{1}\,. \] \end{proof} \begin{lem} \label{lem:mixLeft} For a directed Laplacian $\mlap=\mI-\mw$ associated with a strongly connected graph, the mixing time of the random walk matrix $\mw$ satisfies \[ \sqrt{t_{mix}}\leq16\norm{\mlap^{\dagger}}_{1}\,. \] \end{lem} \begin{proof} Consider some vector $x\in\simplex^{n}$ that has not mixed at step $k=t_{mix}-1$, i.e. $\norm{\mw^{k}x-s}_{1}>\frac{1}{2}$. Let \[ y\defeq\mw^{k}x-s\cdot\frac{s^{\top}\mw^{k}x}{\norm s_{2}^{2}}\,. \] By construction, we have that $s^{\top}y=0$ and therefore \begin{equation} \frac{\norm y_{1}}{\norm{\mlap y}_{1}}\leq\max_{z\perp s\,:\,z\neq\vec{0}}\frac{\norm z_{1}}{\norm{\mlap z}_{1}}=\max_{z\neq\vec{0}}\frac{\norm{\mlap^{\dagger}z}_{1}}{\norm z_{1}}=\norm{\mlap^{\dagger}}_{1}\,.\label{eq:tmix_upbound_1} \end{equation} Now by Lemma~\ref{lem:tech-large-simplex-diff} and our assumption on $x$, we know that $\norm y_{1}\geq\frac{1}{4}$, so all that remains is to upper bound $\norm{\mlap y}_{1}$. However, since $\mlap s=\vec{0}$ we have \begin{align*} \norm{\mlap y}_{1} & =\norm{(\mI-\mw)\lazywalk x}_{1}=\normFull{(\mI-\mw)\left(\frac{\mI+\mw}{2}\right)^{k}x}_{1}=\normFull{\frac{\mI-\mw}{2^{k}}\sum_{i=0}^{k}{k \choose i}\mw^{i}x}_{1}\\ & =\frac{1}{2^{k}}\normFull{\left(\mI-\mw^{k+1}+\sum_{i=1}^{k}\left({k \choose i-1}-{k \choose i}\right)\mw^{i}\right)x}_{1}\\ & \leq\frac{1}{2^{k}}\left(2+\sum_{i=1}^{k}\left|{k \choose i-1}-{k \choose i}\right|\right)\,. \end{align*} In the last line we used the fact that $\norm{\mw}_{1}=1$, and thus $\norm{\mw^{i}x}_{1}\leq1$ for all $i\geq0$. Now, consider the function $f(i)\defeq{k \choose i}$. Clearly $f(i)\geq1$, and for all $1\leq i\leq$k, $f(i)$ increases monotonically with $i$ until it achieves its maximum value and then decreases monotonically, and $f(i)=f(k-i)$. Consequently, \[ \sum_{i=1}^{k}\left|{k \choose i-1}-{k \choose i}\right|=-2+2\cdot\max_{1\leq i\leq k}\frac{k!}{i!(k-i)!}=-2+2\frac{k!}{\lfloor\frac{k}{2}\rfloor!\lceil\frac{k}{2}\rceil!}\,. \] Using Stirling's approximation $\sqrt{2\pi}\cdot n^{n+\frac{1}{2}}e^{-n}\leq n!\leq e\cdot n^{n+\frac{1}{2}}e^{-n}$ we have that if $k$ is even then \begin{align*} \frac{k!}{\lfloor\frac{k}{2}\rfloor!\lceil\frac{k}{2}\rceil!} & \leq\frac{e\cdot k^{k+\frac{1}{2}}e^{-k}}{2\pi\cdot\left(\frac{k}{2}\right)^{k+1}e^{-k}}=\frac{e\cdot2^{k+1}}{2\pi\sqrt{k}}\,. \end{align*} Since this maximum binomial coefficient increases as $k$ increases, we have that this inequality holds for all $k$ if we replace $k$ in the right hand side with $k+1$, and we have \[ \norm{\mlap y}_{1}\leq\frac{1}{2^{k}}\left(2\cdot\frac{e\cdot2^{k+2}}{2\pi\sqrt{k+1}}\right)=\frac{4e}{\pi}\cdot\frac{1}{\sqrt{k+1}}\leq\frac{4}{\sqrt{k+1}}\,. \] Combining this with (\ref{eq:tmix_upbound_1}) and the facts that $\norm y_{1}\geq\frac{1}{4}$ and $k=t_{mix}-1$ yields the result. \end{proof} \begin{lem} \label{lem:ppLeft} Let $\mlap=\mI-\mw$ be a directed Laplacian associated with a strongly connected graph, and let $\mm_{pp(\beta)}$ denote the personalized PageRank matrix with restart probability $\beta\in[0,1]$ associated with $\mw$. For all $x\in\simplex^{n}$ we have \[ \frac{1}{4\beta}\norm{\mm_{pp(\beta)}x-s}_{1}\leq\norm{\mlap^{\dagger}}_{1} \] and consequently the personalized PageRank mixing time for $\mw$, denoted $t_{pp}$, satisfies. \[ \frac{t_{pp}}{8}<\norm{\mlap^{\dagger}}_{1}\enspace\text{ and }\enspace\frac{1}{4\beta}\norm{\mm_{pp(\beta)}-s\vec{1}^{\top}}_{1}\leq\norm{\mlap^{\dagger}}_{1}\,. \] \end{lem} \begin{proof} Let $y=\mm_{pp(\beta)}x$. Recall that this implies $y=\beta(\mI-(1-\beta)\mw)^{-1}x=\beta\sum_{i=0}^{\infty}(1-\beta)^{i}\mw^{i}x$, and since $x\in\simplex^{n}$ clearly $y\in\simplex^{n}$. Now let $z=y-\alpha s$ where $\alpha=s^{\top}y/\norm s_{2}^{2}$ so that $s^{\top}z=0$.. Since $\norm{y-s}_{1}>\epsilon$ by Lemma~\ref{lem:tech-large-simplex-diff}, we have that $\norm z_{1}>\frac{\epsilon}{2}$. Furthermore, since $(\mI-(1-\beta)\mw)y=\beta x$, we have $\mlap y=\beta(x-y)$. Also, since $\mlap s=0$ we have \[ \norm{\mlap z}_{1}=\norm{\mlap y}_{1}=\beta\norm{x-y}_{1}\leq\beta\cdot(\norm x_{1}+\norm y_{1})=2\beta. \] Consequently, \[ \norm{\mlap^{\dagger}}_{1}=\max_{x\neq0}\frac{\norm{\mlap^{\dagger}x}_{1}}{\norm x_{1}}=\max_{x\perp s,x\neq0}\frac{\norm x_{1}}{\norm{\mlap x}_{1}}\geq\frac{\norm z_{1}}{\norm{\mlap z}_{1}}>\frac{\epsilon}{4\beta}\,. \] Using the definition of $t_{pp}$ and applying Lemma~\ref{lem:equiv_helper_lemma} completes the results. \end{proof} \subsection{Condition Number Upper Bounds \label{subsec:Condition-Number-Upper}} Here we provide various upper bounds on $\norm{\mlap^{\dagger}}_{1}$ for a directed Laplacian $\mlap=\mI-\mw$ associated with a strongly connected directed graph. In particular we show how to upper bound $\norm{\mlap^{\dagger}}_{1}$in terms of $t_{mix}$ and $t_{pp}$. We achieve this by providing an even stronger lower bound on the mixing time of random walks. First, in Lemma~\ref{lem:condition-num-upp-bound} we show how to lower bound how well any distribution of random walk matrices of bounded length mixes. We then show how to amplify this bound in Lemma~\ref{lem:upper_bound_helper}, providing stronger lower bounds. As a near immediate corollary of this lemma we upper bound $\norm{\mlap^{\dagger}}_{1}$ in terms of the lazy random walk mixing time (Lemma~\ref{lem:cond_to_tmix}) and the personalized page rank mixing time (Lemma~\ref{lem:cond_to_tppr}). \begin{lem} \label{lem:condition-num-upp-bound} Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix associated with a strongly connected graph, and let $\mm$ be a distribution of the walks of $\mw$ of length at most $k$, i.e. $\mm=\sum_{i=0}^{k}\alpha_{i}\mw^{k}$ where $\alpha_{i}\geq0$, $\sum_{i=0}^{k}\alpha_{i}=1$. If $k<\frac{\norm{\mlap^{\dagger}}}{2\sqrt{n}}$, then$\norm{\mm-s\vec{1}^{\top}}_{1}>\frac{1}{2\sqrt{n}}$. \end{lem} \begin{proof} Recall that \[ \norm{\mlap^{\dagger}}_{1}=\max_{x\neq0}\frac{\norm{\mlap x}_{1}}{\norm x_{1}}=\max_{x\perp s,x\neq0}\frac{\norm x_{1}}{\norm{\mlap x}_{1}}=\max_{\norm x_{1}=1,x\perp s}\norm{\mlap x}_{1}^{-1}\,. \] Consequently, we let $x$ be such that $\norm x_{1}=1$, $x\perp s$, and $\norm{\mlap x}_{1}^{-1}=\norm{\mlap^{\dagger}}_{1}$. Now, by reverse triangle inequality and the definition of operator norm we have \[ \norm{\mm-s\vec{1}{}^{\top}}_{1}\geq\norm{(\mm-s\vec{1}{}^{\top})x}_{1}\geq\norm{x-s\vec{1}^{\top}x}_{1}-\norm{\mm x-x}_{1}\,. \] However, since $\norm x_{1}=\norm s_{1}=1$ we know that \[ \norm{x-s\vec{1}^{\top}x}_{1}\geq\norm{x-s\vec{1}^{\top}x}_{2}\geq\norm x_{2}\geq\frac{1}{\sqrt{n}}\norm x_{1}=\frac{1}{\sqrt{n}}. \] Furthermore we have that \[ \norm{\mm x-x}_{1}=\normFull{\sum_{i=0}^{k}\alpha_{i}(\mw^{i}x-x)}_{1}\leq\sum_{i=0}^{k}\alpha_{i}\norm{\mw^{i}x-x}_{1}\leq\max_{i\in[k]}\norm{\mw^{i}-x}_{1} \] and by triangle inequality and the fact that $\norm{\mw}_{1}=1$ we have that \[ \|\mw^{i}x-x\|_{1}\leq\|\mw x-x\|_{1}+\|\mw^{2}x-\mw x\|_{1}+\cdots+\|\mw^{k}x-\mw^{k-1}x\|_{1}\leq k\|\mw x-x\|_{1}=k\|\mlap x\|_{1}\,. \] Using, that $k<\frac{\norm{\mlap^{\dagger}}_{1}}{2\sqrt{n}}$ and $\norm{\mlap x}_{1}=\norm{\mlap^{\dagger}}_{1}^{-1}$ we have \[ \norm{\mm-s\vec{1}{}^{\top}}_{1}\geq\frac{1}{\sqrt{n}}-k\|\mlap x\|_{1}\geq\frac{1}{\sqrt{n}}-\frac{1}{2\sqrt{n}}=\frac{1}{2\sqrt{n}}\,. \] \end{proof} \begin{lem} \label{lem:upper_bound_helper} Let $\mw\in\R_{\geq0}^{n\times n}$ be a random walk matrix associated with a strongly connected graph, and let $\mm$ be a distribution of the walks of $\mw$, i.e. $\mm=\sum_{i=0}^{\infty}\alpha_{i}\mw^{i}$ where $\alpha_{i}\geq0$ and $\sum_{i=0}^{\infty}\alpha_{i}=1$. If $\norm{\mm-s\vec{1}^{\top}}_{1}\leq\epsilon<1$, then $\alpha_{i}>0$ for some $i\geq k$ where \[ k=\frac{\norm{\mlap^{\dagger}}_{1}}{\log_{\epsilon}\left(\frac{1}{2\sqrt{n}}\right)\cdot2\sqrt{n}}\,. \] \end{lem} \begin{proof} Proceed by contradiction, and suppose that $\alpha_{i}=0$ for all $i\geq k$. Then we have that $\mm=\sum_{i=0}^{k'}\alpha_{i}\mw^{i}$, where $\sum_{i=0}^{k'}\alpha_{i}=1$ and $k'<k$. Now clearly for all integers $a>0$, since $\mm s=s$, we have $\norm{\mm^{a}-s\vec{1}^{\top}}_{1}=\norm{(\mm-s\vec{1}^{\top})^{a}}_{1}\leq\epsilon^{a}$. Furthermore, picking $a=\log_{\epsilon}(1/(2\sqrt{n}))$ we have that $\norm{\mm^{a}-s\vec{1}^{\top}}\leq\frac{1}{2\sqrt{n}}$. However, we also have $\mm^{a}=\sum_{i=0}^{ak'}\beta_{i}\mm^{i}$, where $\beta_{i}\geq0$ and $\sum_{i=0}^{ak'}\beta_{i}=1$. Consequently, by Lemma~\ref{lem:condition-num-upp-bound} we have $ak'\geq\norm{\mlap^{\dagger}}_{1}/2\sqrt{n}$ . Since $k=\norm{\mlap^{\dagger}}_{1}/(a2\sqrt{n})$ we obtain $k'\geq k$, contradicting $k'<k$. \end{proof} \begin{lem} \label{lem:cond_to_tmix} Let $\mlap=\mI-\mw\in\R^{n\times n}$ be a directed Laplacian associated with a strongly connected graph and let $t_{mix}$ be its mixing time, then $\norm{\mlap^{\dagger}}_{1}\leq t_{mix}\cdot4\sqrt{n}\log_{2}n$. \end{lem} \begin{proof} By Lemma~\ref{lem:equiv_helper_lemma} we know $\norm{\lazywalk^{t_{mix}}-s\vec{1}^{\top}}_{1}\leq\frac{1}{2}$. Since $\lazywalk^{t_{mix}}$ is a distribution of the walks of $\mw$ of length at most $k$, by Lemma~\ref{lem:upper_bound_helper} we know that $t_{mix}\geq k$ where \[ k=\frac{\norm{\mlap^{\dagger}}_{1}}{\log_{1/2}\left(\frac{1}{2\sqrt{n}}\right)\cdot2\sqrt{n}}=\frac{\norm{\mlap^{\dagger}}_{1}}{(1+\log_{2}\sqrt{n})\cdot2\sqrt{n}}\,. \] Since when $n=1$ we have $\mlap=0$ and $\mw-s\vec{1}^{\top}=0$ making the lemma trivially true and when $n\geq2$ we have that $1+\log_{2}(\sqrt{n})\leq2\log_{2}n$ the result follows. \end{proof} \begin{lem} \label{lem:cond_to_tppr} Let $\mlap=\mI-\mw\in\R^{n\times n}$ be a directed Laplacian associated with a strongly connected graph, and let $\mm_{pp(\beta)}$ be the personalized PageRank matrix with restart probability $\beta$ associated with $\mw$. If $\norm{\mm_{pp(\beta)}x-s}_{1}\leq\frac{1}{2}$ for all $x\in\simplex$, then $\norm{\mlap^{\dagger}}_{1}\leq\frac{16\sqrt{n}\log_{2}n}{\beta}$; consequently, $\norm{\mlap^{\dagger}}_{1}\leq t_{pp}\cdot16\sqrt{n}\log_{2}n$. \end{lem} \begin{proof} By Lemma~\ref{lem:equiv_helper_lemma} we know that $\norm{\mm_{pp(\beta)}x-s\vec{1}^{\top}}_{1}\leq\frac{1}{2}$. Now since $\mw^{k}-s\vec{1}^{\top}=(\mw-s\vec{1}^{\top})^{k}$ as $\mw s=s$, we have \[ \mm_{pp(\beta)}-s\vec{1}^{\top}=\beta\left(\mI-(1-\beta)\mw\right)^{-1}-s\vec{1}^{\top}=\beta\sum_{i=0}^{\infty}(1-\beta)^{i}\left(\mw-s\vec{1}^{\top}\right)^{i} \] and, for all $k$ and $x$, we have \[ \norm{(\mm_{pp(\beta)}-s\vec{1}^{\top})x}_{1}\geq\normFull{\sum_{i=0}^{k}\beta(1-\beta)^{i}\left(\mw-s\vec{1}^{\top}\right)^{i}x}_{1}-\normFull{\sum_{i=k+1}^{\infty}\beta(1-\beta)^{i}\left(\mw-s\vec{1}^{\top}\right)^{i}x}_{1} \] Since $\norm{\mw}_{1}=1$, we have \[ \normFull{\sum_{i=k+1}^{\infty}\beta(1-\beta)^{i}\left(\mw-s\vec{1}^{\top}\right)^{i}x}_{1}\leq(1-\beta)^{k+1}\normFull{(\mm_{pp(\beta)}-s\vec{1}^{\top})x}_{1} \] and, since $\norm{\mm_{pp(\beta)}x-s\vec{1}^{\top}}_{1}\leq\frac{1}{2}$, we have \[ \normFull{\sum_{i=0}^{k}\beta(1-\beta)^{i}\left(\mw-s\vec{1}^{\top}\right)^{i}x}_{1}\leq\left(1+(1-\beta)^{k+1}\right)\frac{1}{2} \] Since the geometric sum satisfies the identity, $\sum_{i=0}^{k}(1-\beta)^{i}=\frac{1-(1-\beta)^{k+1}}{\beta}$. We have that $\mm=\frac{1}{1-(1-\beta)^{k+1}}\sum_{i=0}^{k}\beta(1-\beta)^{i}\mw^{i}$ is a distribution of walks of $\mw$ of length at most $k$ with \[ \norm{\mm x-s\vec{1}^{\top}}_{1}\leq\frac{1+(1-\beta)^{k+1}}{1-(1-\beta)^{k+1}}\cdot\frac{1}{2}\leq\frac{1+e^{-\beta k}}{1-e^{-\beta k}}\cdot\frac{1}{2}\,. \] If we pick$k=\frac{1}{\beta}\ln5$ we have that $\norm{\mm-s\vec{1}^{\top}}_{1}\leq\frac{3}{4}$ and therefore, by Lemma~\ref{lem:upper_bound_helper}: \[ \frac{1}{\beta}\ln5=k\geq\frac{\norm{\mlap^{\dagger}}_{1}}{\log_{\frac{3}{4}}\left(\frac{1}{2\sqrt{n}}\right)\cdot2\sqrt{n}}=\frac{\log_{2}\left(\frac{4}{3}\right)\norm{\mlap^{\dagger}}_{1}}{(1+\log_{2}(2\sqrt{n}))\cdot\sqrt{n}}\,. \] Since when $n=1$, we have $\mlap=0$ and $\mw-s\vec{1}^{\top}=0$, making the lemma trivially true. When $n\geq2$ we have that $1+\log_{2}\sqrt{n}\leq2\log_{2}n$; combining this with $\log_{2}\frac{4}{3}/\ln5\geq\frac{1}{4}$ completes the result. \end{proof} \subsection{\label{subsec:app-solvers}Solving More General Linear Systems} Corollary~\ref{cor:alpha-rcdd-solver} allows one to solve linear systems involving RCDD matrices, but requires the matrix to be strictly RCDD and have non-positive off-diagonals. Furthermore, it may return solutions with components in the null space of the matrix, while several of our subsequent applications rely on matrix-vector multiplications involving the pseudoinverse, specifically, computing vectors of the form $\mlap^{\dagger}b$. In this section we give removes these restrictions, at the cost of introducing a dependence on the condition number of the matrix. These proofs can be viewed as more involved analogs of the double-cover reduction from solving SDDM matrices to M matrices, and projecting away against the null space. The main complications are the much more complicated error propagation behaviors in directed settings. The following two Lemmas are crucial for handling these errors. \begin{lem} \label{lem:breakup-ineq} Let $u,v$ be any vectors and $\alpha,\beta$ any scalars. Then $\norm{\alpha u-\beta v}_{2}\leq|\alpha-\beta|\cdot\norm u_{2}+\norm{u-v}_{2}\cdot|\beta|$. \end{lem} \begin{proof} We have $\norm{\alpha u-\beta v}_{2}=\norm{(\alpha-\beta)u+(u-v)\beta}_{2}\leq|\alpha-\beta|\cdot\norm u_{2}+\norm{u-v}_{2}\cdot|\beta|$ \end{proof} \begin{lem} \label{lem:comboUpper} Let $\mm=\alpha\mb+\ma$ be an invertible matrix with $\mm y=b$ and $x=\ma^{\dagger}b$. Suppose $b\in\im(\ma)$. Then, $\norm{y-x}_{2}\leq\alpha\cdot\|\mm^{-1}\|_{2}\cdot\|\mb\|_{2}\cdot\|x\|_{2}$. In particular, this implies $\|y\|_{2}\leq(1+\alpha\cdot\|\mm^{-1}\|_{2}\cdot\|\mb\|_{2})\cdot\|x\|_{2}\leq(1+\alpha\cdot\|\mm^{-1}\|_{2}\cdot\|\mb\|_{2})\cdot\norm{\ma^{\dagger}}_{2}\cdot\|b\|_{2}$. \end{lem} \begin{proof} Expanding yields that \[ \norm{y-x}_{2}=\norm{\mm^{-1}b-\ma^{\dagger}b}_{2}=\norm{\mm^{-1}(\mI-\mm\ma^{\dagger})b}_{2}=\alpha\norm{\mm^{-1}\mb\ma^{\dagger}b}_{2}=\alpha\norm{\mm^{-1}\mb x}_{2} \] where in the second-to-last step, we used that $\mm=\alpha\mb+\ma$ and $\ma\ma^{\dagger}b=b$ for $b\in\im(\ma)$ . \end{proof} \begin{thm} (Arbitrary RCDD system solver)\label{thm:0-rcdd-solver} Let $\ma$ be an invertible $n\times n$ RCDD matrix. Let $b$ be an $n$-dimensional vector, and $x$ the solution to $\ma x=b$. Let $r,u$ be the smallest and largest entries, respectively, on the diagonal of $\ma$ so $\kappa(\md)=u/r$. Then for any $\epsilon>0$, one can compute, with high probability and in $O\left(\tsolve\log\left(\frac{\kappa(\ma)\cdot\kappa(\md)}{\epsilon}\right)\right)$ time, a vector $x'$ satisfying $\|x'-x\|_{2}\leq\epsilon\|x\|_{2}$. \end{thm} \begin{proof} We first handle the case where the off-diagonal entries can be positive. For an $\alpha$-RCDD matrix $\mm$, let $\mm_{+}$ denote the matrix of positive off-diagonal entries of $\mm$, with zeros elsewhere. Let $\mm_{-}$ be the matrix of negative off-diagonals. Consider the matrix \[ \mz=\left[\begin{array}{cc} \mdiag(\mm)+\mm_{-} & -\mm_{+}\\ -\mm_{+} & \mdiag(\mm)+\mm_{-} \end{array}\right] \] and the system \[ \mz\left[\begin{array}{c} x_{1}\\ x_{2} \end{array}\right]=\left[\begin{array}{c} b\\ -b \end{array}\right]. \] Note that $\mz$ is RCDD and a Z-matrix. Let $y$ be the solution to $\mm y=b$. Then the solution $x_{1}=-x_{2}=x$ satisfies this new system. Similarly, let $(x_{1};x_{2})$ be a solution to this new system, where the semicolon denotes vertical concatenation. Then $x=(x_{1}-x_{2})/2$ is a solution to the original system. Now, suppose we have an approximate solution $(x'_{1};x'_{2})$ to the new system in the sense of Corollary~\ref{cor:alpha-rcdd-solver}. Define $(e_{1};e_{2})=(x'_{1}-x_{1};x'_{2}-x_{2})$. Let $\md=\mdiag(\mm)/(1+\alpha)$. Note that \[ 2\mdiag(\mz)-\left[\begin{array}{c} \mI\\ -\mI \end{array}\right]\md\left[\begin{array}{cc} \mI & -\mI\end{array}\right]=\left[\begin{array}{c} \mI\\ \mI \end{array}\right]\md\left[\begin{array}{cc} \mI & \mI\end{array}\right]\succeq\mzero \] and consequently, the approximate solution $x'=\frac{x'_{1}-x'_{2}}{2}$ to $\ma x=b$ satisfies \begin{align*} \|x'-x\|_{\md} & =\frac{1}{2}\cdot\left[\begin{array}{cc} e_{1}^{\top} & e_{2}^{\top}\end{array}\right]\left[\begin{array}{c} \mI\\ -\mI \end{array}\right]\md\left[\begin{array}{cc} \mI & -\mI\end{array}\right]\left[\begin{array}{c} e_{1}\\ e_{2} \end{array}\right]\leq\left[\begin{array}{cc} e_{1}^{\top} & e_{2}^{\top}\end{array}\right]\mdiag(\mz)\left[\begin{array}{c} e_{1}\\ e_{2} \end{array}\right]\\ & =\|(e_{1};\,e_{2})\|_{\mdiag(\mz)}\leq\|(b;\,-b)\|_{\mdiag(\mz)^{-1}}=\|b\|_{\md^{-1},}. \end{align*} which is, up to a constant factor, exactly the error guarantee of Corollary~\ref{cor:alpha-rcdd-solver}. With the reduction now complete, let $\md=\mdiag(\ma)$. Set $\mm=\alpha\md+\ma$ for $\alpha=\frac{\epsilon r}{4\cdot\|\ma^{-1}\|_{2}^{2}\cdot u^{2}}$. Note that $\mm$ is $\alpha$-RCDD. Since $\mm$ is strictly RCDD, it is invertible by Lemma~\ref{lem:invertible_B}. Thus, let $y$ be the vector satisfying $\mm y=b$. By Corollary~\ref{cor:alpha-rcdd-solver}, we can compute, with high probability and in $O\left(\tsolve\log\frac{1}{\alpha\epsilon r}\right)=O\left(\tsolve\log\left(\frac{\epsilon^{2}r^{2}}{\|\ma^{-1}\|_{2}^{2}\cdot u^{2}}\right)^{-1}\right)$ time, a vector $x'$ satisfying \[ \|x'-y\|_{2}\|x'-y\|_{\md}\leq\frac{\alpha\epsilon r}{2\alpha}\|b\|_{\md^{-1}}\implies\|x'-y\|_{2}\leq\frac{\epsilon}{2}\|b\|_{2}. \] Let $x$ be the solution to $\ma x=b$. Then we have \[ \|\ma x-\ma y\|_{2}=\|b-(b-\alpha\md y)\|_{2}=\alpha\|\md y\|_{2}\leq\alpha\cdot u\cdot\|y\|_{2}=\alpha\cdot u\cdot\|\mm^{-1}b\|_{2}\leq\alpha\cdot u\cdot\|\mm^{-1}\|_{2}\cdot\|b\|_{2}. \] We can bound $\|\mm^{-1}\|_{2}$ by \begin{align*} \|\mm^{-1}\|_{2} & =\left(\min_{v}\frac{\|\mm v\|_{2}}{\|v\|_{2}}\right)^{-1}=\left(\min_{v}\frac{\|v\|_{2}\cdot\|\mm v\|_{2}}{\|v\|_{2}^{2}}\right)^{-1}\\ & \leq\left(\min_{v}\frac{v^{\top}[\alpha\md+\ma]v}{\|v\|_{2}^{2}}\right)^{-1}\leq\left(\alpha r+\lambda_{\text{min}}(\ma+\ma^{\top})\right)^{-1}\leq1/(\alpha r). \end{align*} Substituting this into Lemma~\ref{lem:comboUpper}, we get a bound that doesn't depend on $\alpha$. \[ \|\mm^{-1}\|_{2}\leq(1+\alpha\cdot\|\mm^{-1}\|_{2}\cdot\|\md\|_{2})\cdot\|\ma^{-1}\|_{2}\leq(1+\|\md\|_{2}/r)\cdot\|\ma^{-1}\|_{2}\leq2(u/r)\cdot\|\ma^{-1}\|_{2} \] Thus, by Lemma~\ref{lem:rcdd-inv-monotone}, \[ \|x-y\|_{2}\leq\alpha\cdot\|\ma^{-1}\|_{2}\cdot u\cdot\|\mm^{-1}\|_{2}\cdot\|b\|_{2}\leq\alpha\cdot\|\ma^{-1}\|_{2}^{2}\cdot(u^{2}/r)\cdot\|b\|_{2}=\frac{\epsilon}{2}\|b\|_{2}. \] By the triangle inequality, $\|x'-x\|_{2}\leq\epsilon\|b\|_{2}$. Replacing $\epsilon$ with $\epsilon/\norm{\ma}_{2}$ completes the proof. \end{proof} We now show that we can approximate $\mlap^{\dagger}b$ efficiently, even when $b$ is not in the image of $\mlap$. \begin{thm} (Laplacian pseudoinverse solver)\label{thm:lap-pinv-solver}Let $\mlap=\md-\ma^{\top}$ be an $n\times n$ directed Laplacian matrix of the directed, strongly connected graph $G$. Let $x=\mlap^{\dagger}b$ where $b\in\R^{n}$. Then for any $0<\epsilon\leq1$, one can compute, with high probability and in time \[ O\left(\tsolve\log^{2}\left(\frac{n\cdot\kappa(\md)\cdot\kappa(\mlap)}{\epsilon}\right)\right) \] a vector $x'$ satisfying $\|x'-x\|_{2}\leq\epsilon\norm x_{2}$. \end{thm} In order to prove this, we prove Theorem~\ref{thm:cond-lap-pinv-solver} which says that one can do this if one has a reasonable upper bound on $\kappa(\mlap)$ (or equivalently, $t_{\text{mix}}$). Theorem~\ref{thm:lap-pinv-solver} then immediately follows from the fact that we can, in fact, compute good upper bounds quickly via Theorem~\ref{thm:cond_and_stationary_est}. \begin{thm} (Conditional Laplacian solver)\label{thm:cond-lap-pinv-solver} Let $\mlap=\md-\ma^{\top}$ be an $n\times n$ directed Laplacian associated with a strongly connected directed graph $G$. Let \[ \mathcal{R}(\epsilon)\leq O\left(\tsolve\log^{2}\left(\frac{n\cdot M}{\epsilon}\right)\right) \] be the cost of computing an $\epsilon$-approximation to the stationary distribution of $\mlap$ in the sense of Theorem~\ref{thm:cond_and_stationary_est}, where $M$ is a known upper bound on $\norm{\left(\mI-\mw\right)^{\dagger}}_{2}$, where $\mw=\ma^{\top}\md^{-1}$ is the associated random walk matrix. Let $x=\mlap^{\dagger}b$, where $b\in\R^{n}$. Then for any $0<\epsilon\leq1$, one can compute, with high probability and in time \[ O\left(\tsolve\log^{2}\left(\frac{n\cdot\kappa(\md)\cdot M}{\epsilon}\right)+\mathcal{R}\left(\frac{\epsilon}{n\cdot\kappa(\md)}\right)\right)\leq O\left(\tsolve\log^{2}\left(\frac{n\cdot\kappa(\md)\cdot M}{\epsilon}\right)\right) \] a vector $x'$ satisfying $\|x'-x\|_{2}\leq\epsilon\norm x_{2}$. Furthermore, all the intermediate Eulerian Laplacian solves required to produce the approximate solution involve only $\mr$ for which $\kappa(\mr+\mr^{\top}),\,\kappa(\mdiag(\mr))\leq(n\kappa(\md)M/\epsilon)^{O(1)}$. \end{thm} \begin{proof} Note that since we wish to compute $x=\mlap^{\dagger}b$, we can initially project $b$ onto $\im(\mlap)=\sspan(\vones)^{\perp}$. Thus, we will assume for the rest of the proof that $b$ is in the image of $\mlap$. We solve the equivalent linear system $(\mI-\mw)z=b$, where $\mI-\mw=\mlap\md^{-1}$, to within accuracy $\epsilon'=\epsilon/\kappa(\md)$, in the sense that the solution $z'$ we obtain satisfies $\norm{z'-z}_{2}\leq\epsilon'\cdot\norm z_{2}$. At the end, we return the solution $x'=\md^{-1}z'$. The guarantee we provide on $z'$ is equivalent to $\norm{\md^{-1}x'-\md^{-1}x}_{2}\leq\epsilon'\cdot\norm{\md^{-1}x}_{2}$, and thus $\norm{\md^{-1}(x'-x)}_{2}\leq\epsilon'\cdot\norm{\md^{-1}}_{2}\norm x_{2}$. We then know that $\norm{x'-x}_{2}\leq(\epsilon/\kappa(\md))\cdot\kappa(\md)\cdot\norm x_{2}\le\epsilon\norm x_{2}$. In order to solve the system in $\mI-\mw$, we set $\mm=\alpha\mI+(\mI-\mw)$, for $\alpha=\epsilon'/(6M\sqrt{n})$, and find an approximate solution to the system involving $\mm$. First we show that, having set $\alpha$ sufficiently small, the solution to the system in $\mm$ is not very far from the true solution $z$. Letting $\Pi$ denote the projection onto the subspace orthogonal to the kernel of $\mI-\mw$, we upper bound $\norm{\Pi(z-\mm^{-1}b)}_{2}$. First, using the fact that $\mm$ is invertible, we notice that $\norm{\mm^{-1}}_{2}\leq\max_{x:\norm x_{2}=1}\frac{1}{\norm{\mm x}_{2}}\leq\max_{x:\norm x_{2}=1}\frac{\sqrt{n}}{\norm{\mm x}_{1}}$. Since $\mm$ is $\alpha$-RCDD we have $\norm{\mm x}_{1}\geq\alpha\norm x_{1}$. Therefore $\norm{\mm^{-1}}_{2}\leq\max_{x:\norm x_{2}=1}\frac{\sqrt{n}}{\alpha\norm x_{1}}\leq\sqrt{n}/\alpha$. By Lemma~\ref{lem:comboUpper}, we have $\|\mm^{-1}b\|_{2}\leq(1+\alpha\|\mm^{-1}\|_{2})\cdot\|(\mI-\mw)^{\dagger}b\|_{2}$, and therefore \begin{eqnarray} \norm{\mm^{-1}b}_{2} & \leq & 2\sqrt{n}\norm z_{2}\,.\label{eq:minvbd} \end{eqnarray} Thus we can bound \begin{align*} \norm{\Pi(z-\mm^{-1}b)}_{2} & =\norm{(\mI-\mw)^{\dagger}(\mI-\mw)(z-\mm^{-1}b)}_{2}\leq\norm{(\mI-\mw)^{\dagger}}_{2}\norm{b-(\mm-\alpha\mI)\mm^{-1}b}_{2}\\ & =\norm{(\mI-\mw)^{\dagger}}_{2}\cdot\alpha\norm{\mm^{-1}b}_{2}\leq\norm{(\mI-\mw)^{\dagger}}\alpha\cdot2\sqrt{n}\cdot\norm z_{2}\leq\frac{\epsilon'}{3}\norm z_{2}\,. \end{align*} Next, we provide a bound on the required accuracy for solving $\mm^{-1}b$. Using Theorem~\ref{thm:stat-from-dd}, we compute in time $O\left(\left(m+\tsolve\log\frac{n}{\alpha}\right)\cdot\log\frac{n}{\alpha}\right)=O\left(\tsolve\log^{2}\frac{nM\kappa(\md)}{\epsilon}\right)$, a diagonal matrix $\ms\succeq\mzero$ such that $\tr(\ms)=1$, $\mm\ms$ is $\frac{\alpha}{3n}$-RCDD, and $\kappa(\ms)\leq\frac{60n^{3}}{\alpha^{2}}$. Letting $\epsilon''=\epsilon'\cdot\alpha^{3}/(120n^{3.5})$ , and using Corollary~\ref{cor:alpha-rcdd-solver}, we can compute, with high probability and in $O\left(\tsolve\log\frac{1}{\epsilon''}\right)=O\left(\tsolve\log\frac{\kappa(\md)}{\epsilon}\right)$ time, a vector $x'$ satisfying \begin{eqnarray*} \norm{x'-(\mm\ms)^{-1}b}_{(1+\alpha)\ms} & \leq & \frac{\epsilon''}{\alpha}\Vert b\Vert_{(1+\alpha)^{-1}\ms^{-1}} \end{eqnarray*} with high probability, and equivalently: \begin{eqnarray*} (1+\alpha)^{1/2}\norm{\ms x'-\mm^{-1}b}_{\ms^{-1}} & \leq & \frac{\epsilon''}{\alpha(1+\alpha)^{1/2}}\Vert b\Vert_{\ms^{-1}}\,. \end{eqnarray*} Plugging the bound on $\kappa(\ms)$, this yields: \begin{eqnarray*} \norm{\ms x'-\mm^{-1}b}_{2} & \leq & \frac{\epsilon''\kappa(\ms)}{\alpha(1+\alpha)}\Vert b\Vert_{2}\leq\frac{60n^{3}\epsilon''}{\alpha^{3}(1+\alpha)}\norm b_{2}\,. \end{eqnarray*} Since $b$ is in the image of $\mlap$, therefore in the image of $\mI-\mw$, and using $\norm{\mI-\mw}_{2}\leq2\sqrt{n}$, we obtain: \begin{eqnarray} \norm{\ms x'-\mm^{-1}b}_{2} & \leq & \frac{60n^{3}\epsilon''}{\alpha^{3}(1+\alpha)}\norm{(\mI-\mw)(\mI-\mw)^{\dagger}b}_{2}\leq\frac{120n^{3.5}\epsilon''}{\alpha^{3}(1+\alpha)}\norm{(\mI-\mw)^{\dagger}b}_{2}\leq\frac{\epsilon'}{3}\norm z_{2}\,.\label{eq:firstbd} \end{eqnarray} Using triangle inequality we then obtain that \begin{equation} \norm{\Pi(\ms x'-z)}_{2}\leq\norm{\Pi(\ms x'-\mm^{-1}b)}_{2}+\norm{\Pi(z-\mm^{-1}b)}_{2}\leq\frac{2\epsilon'}{3}\norm z_{2}\,.\label{eq:goodbd} \end{equation} So, if we ignore the kernel of $\mI-\mw$, our solution $\ms x'$ is close to $z$. The rest of the proof is devoted to showing how to project off something approximating the kernel of $\mI-\mw$ in order to obtain a vector that unconditionally approximates $z=(\mI-\mw)^{\dagger}b$. Using Theorem~\ref{thm:cond_and_stationary_est}, we compute in time $\mathcal{R}\left(\epsilon'/(32n)\right)=\mathcal{R}\left(\epsilon/(32n\cdot\kappa(\md))\right)$, an approximate stationary vector $s'$ satisfying $\|s'-s^{*}\|_{2}\leq\frac{\epsilon'}{32n}$, where $s^{*}$ is the true stationary. We will prove that if we approximate the true stationary sufficiently well, then the approximate projection $\Pi'\ms x'$, where $\Pi'=\mI-\frac{s'}{\norm{s'}_{2}}\left(\frac{s'}{\norm{s'}_{2}}\right){}^{\top}$, is unconditionally close to $z$. First we bound \begin{align*} \norm{\Pi-\Pi'}_{2} & =\normFull{\left(\mI-\frac{s^{*}}{\norm{s^{*}}_{2}}\left(\frac{s^{*}}{\norm{s^{*}}_{2}}\right)^{\top}\right)-\left(\mI-\frac{s'}{\norm{s'}_{2}}\left(\frac{s'}{\norm{s'}_{2}}\right)^{\top}\right)}_{2}\\ & =\normFull{\frac{s^{*}}{\norm{s^{*}}_{2}}\left(\frac{s^{*}}{\norm{s^{*}}_{2}}\right)^{\top}-\frac{s'}{\norm{s'}_{2}}\left(\frac{s'}{\norm{s'}_{2}}\right)^{\top}}_{2}\,. \end{align*} Using Lemma~\ref{lem:breakup-ineq}, we see that $\left\Vert \frac{s^{*}}{\norm{s^{*}}_{2}}-\frac{s'}{\norm{s'}_{2}}\right\Vert _{2}\leq2\cdot\frac{\norm{s'-s^{*}}_{2}}{\norm{s^{*}}_{2}}\leq\frac{\epsilon'}{16n}\cdot\sqrt{n}$. Therefore we can use this, together with triangle inequality, to prove that for any vector $y$: \begin{align*} \norm{(\Pi-\Pi')y}_{2} & =\normFull{\frac{s^{*}}{\norm{s^{*}}_{2}}\cdot\frac{\left(s^{*}\right)^{\top}y}{\norm{s^{*}}_{2}}-\frac{s'}{\norm{s'}_{2}}\cdot\frac{\left(s'\right)^{\top}y}{\norm{s'}_{2}}}_{2}\\ & \leq\normFull{\frac{s'}{\norm{s'}_{2}}\cdot\left(\frac{s'^{\top}y}{\|s'\|_{2}}-\frac{\left(s^{*}\right)^{\top}y}{\|s^{*}\|_{2}}\right)}_{2}+\normFull{\left(\frac{s'}{\norm{s'}_{2}}-\frac{s^{*}}{\norm{s^{*}}_{2}}\right)\cdot\frac{\left(s^{*}\right)^{\top}y}{\norm{s^{*}}_{2}}}_{2}\\ & \leq2\left\Vert \frac{s^{*}}{\norm{s^{*}}_{2}}-\frac{s'}{\norm{s'}_{2}}\right\Vert _{2}\norm y_{2}\leq\frac{\epsilon'}{8\sqrt{n}}\norm y_{2}\,. \end{align*} Therefore, using this together with (\ref{eq:firstbd}) and (\ref{eq:minvbd}), we obtain \begin{align*} \norm{\Pi'\ms x'-\Pi\ms x'}_{2} & \leq\frac{\epsilon'}{8\sqrt{n}}\norm{\ms x'}_{2}\leq\frac{\epsilon'}{8\sqrt{n}}\left(\norm{\ms x'-\mm^{-1}b}_{2}+\norm{\mm^{-1}b}_{2}\right)\\ & \leq\frac{\epsilon'}{8\sqrt{n}}\cdot\left(\frac{\epsilon'}{3}\norm z_{2}+2\sqrt{n}\norm z_{2}\right)\leq\frac{\epsilon'}{3}\norm z_{2}\,. \end{align*} Using this together with (\ref{eq:goodbd}), and applying the triangle inequality, we obtain that $\norm{\Pi'\ms x'-z}_{2}\leq\epsilon'\norm z_{2}$. Finally, as we can see from Theorem~\ref{thm:stat-from-dd}, all the intermediate solves involve $(\alpha/3n)$-RCDD matrices for which the condition number of their diagonals is bounded by $(n/\alpha)^{O(1)}$. Using Lemma~\ref{lem:rcdd-to-eulerian-kappa}, we see that applying the reduction from Theorem~\ref{thm:basic-rcdd} to these matrices only outputs matrices whose symmetrizations have condition number bounded by $4n^{3}\cdot3n/\alpha\cdot(n/\alpha)^{O(1)}=(n\kappa(\md)M/\epsilon)^{O(1)}$. \end{proof} We also note that the first part of the proof of Theorem~\ref{thm:cond-lap-pinv-solver} also gives a solver for a more general class of linear systems\textendash arbitrary row- or column-diagonally dominant systems. This includes directed Laplacians for graphs that are not strongly connected. As the null space of such matrices are more intricate, we give the following guarantee in terms of the $\ell_{2}$ norm of the matrix-vector product. \begin{thm} (Diagonally dominant solver)\label{thm:dd-solver}Let $\mm$ be an arbitrary $n\times n$ column-diagonally-dominant or row-diagonally-dominant matrix with diagonal $\md$. Let $b\in\im(\mm)$. Then for any $0<\epsilon\leq1$, one can compute, with high probability and in time \[ O\left(\tsolve\log^{2}\left(\frac{n\cdot\kappa(\md)\cdot\kappa(\mm)}{\epsilon}\right)\right) \] a vector $x'$ satisfying $\|\mm x'-b\|_{2}\leq\epsilon\norm b_{2}$. Furthermore, all the intermediate Eulerian Laplacian solves required to produce the approximate solution involve only matrices $\mr$ for which $\kappa(\mr+\mr^{\top}),\:\kappa(\mdiag(\mr))\leq(n\kappa(\md)\kappa(\mm)/\epsilon)^{O(1)}$. \end{thm} \begin{proof} The algorithm and proof are essentially the same as the first part of that of Theorem~\ref{thm:cond-lap-pinv-solver}. First, let us analyze the CDD case. Suppose $K$ is a known upper bound on $\kappa(\mm)$. We rescale $\mm$ by the diagonal, and solve for $\widehat{\mm}=\mm\md^{-1}$ to within accuracy $\epsilon/\kappa(\md)$. In order to do so, we consider the matrix $\tilde{\mm}$ with a slightly increased diagonal \[ \tilde{\mm}=\frac{1}{\alpha}\mI+\widehat{\mm}, \] where $\alpha=\epsilon'/(6\kappa(\md)Kn)\leq\epsilon/(6\kappa^{2}(\md)Kn)$. We notice that $\norm{(\mm\md^{-1})^{\dagger}}_{2}=\kappa(\mm\md^{-1})/\norm{\mm\md^{-1}}_{2}$, and the term in the denominator can be lower bounded by $\norm{\mm\md^{-1}}_{1}/\sqrt{n}$. But by definition the corresponding norm of the rescaled matrix is at least $1$; thus $\norm{(\mm\md^{-1})^{\dagger}}_{2}\leq\kappa(\mm\md^{-1})\cdot\sqrt{n}\leq\kappa(\md)\kappa(\mm)\sqrt{n}\leq\kappa(\md)K\sqrt{n}$, where for the last inequality we used Lemma~\ref{lem:cond-num-bd}. So our setting of $\alpha$ corresponds to the what is required for the analysis we have seen in Theorem~\ref{thm:cond-lap-pinv-solver}. An approximate rescaling of it to the RCDD case is obtained by considering the diagonal scaling $\ms$ of the matrix $\tilde{\mm}_{-}$, which has all the off-diagonal entries replaced by negative entries with the same magnitude. With this rescaling, solutions to the system $\tilde{\mm}x=b$ can be approximated to high accuracy using Theorem~\ref{thm:0-rcdd-solver}. The $\ell_{2}$ norm error guarantees of the solution to $\tilde{\mm}^{\dagger}b$ follows via the exact same sequence of inequalities, namely Equations~\ref{eq:minvbd}~and~\ref{eq:firstbd}. The second part involving the projections from the kernel is not necessary since we measure only $\|\mm x'-b\|_{2}$. Finally, in order to eliminate the assumption on $K$, we can simply run the algorithm with $K=2^{2^{0}},2^{2^{1}},\dots$ and test if the returned solution satisfies the required bound. This adds at most a constant overhead, since the running time of the algorithm doubles between iterations, therefore it is dominated by the one involving a value of $K$ that is within a polynomial factor from the true $\kappa(\mm)$. The RDD case is treated similarly. The difference is that the initial rescaling is done in order to produce $\widehat{\mm}=\md^{-1}\mm$, and that the rescaling is computed with respect to $\tilde{\mm}^{\top}$. Again, as seen in the statement of Theorem~\ref{thm:stat-from-dd}, all the intermediate solves involve $(\alpha/3n)$-RCDD matrices for which the condition number of their diagonals is bounded by $(n/\alpha)^{O(1)}$. Just like before, we see that by Lemma~\ref{lem:rcdd-to-eulerian-kappa}, plugging these into the reduction from Theorem~\ref{thm:basic-rcdd} produces matrices with condition number bounded by $(n/\alpha)^{O(1)}=(n\kappa(\md)\kappa(\mm)/\epsilon)^{O(1)}$. \end{proof} We believe a guarantee more similar to Theorem~\ref{thm:cond-lap-pinv-solver} can be obtained, but would require methods that better take the null space of these matrices into account. One plausible approach for directed Laplacians is to topologically sort the strongly connected components, and then perform back-substitutions. \section{Eulerian Laplacian Solver \label{sec:eulerian_solver}} Throughout this section, let $\mlap$ denote an Eulerian directed Laplacian with $n$ vertices and $m$ edges, and let $\mU$ denote the associated undirected Laplacian: $\mU\defeq\frac{1}{2}(\mlap+\mlap^{\top})$. Let $\mb$ denote a weighted edge-vertex incidence matrix for $\mU$, so that $\mU=\mb^{\top}\mb$. We define $\tsolve\defeq(nm^{3/4}+n^{2/3}m)(\log n)^{3}$ to simplify the statements of our runtime bounds. The goal of this section is to prove the following, Theorem~\ref{thm:euleriansolver}, showing that we can efficiently solve linear systems in $\mlap$. Note that we make no attempt to minimize the number of logarithmic factors in this presentation (including e.g. in parameter balancing); however, we suspect that with careful use of the recent results \cite{LeeS15} and \cite{LeePS15} the $\log n$ factors can all be eliminated. \begin{thm} \label{thm:euleriansolver}Let $b$ be an $n$-dimensional vector in the image of $\mlap$, and let $x$ be the solution to $\mlap x=b$ . Then for any $0<\epsilon\leq\frac{1}{2}$, one can compute in $O(\tsolve\log(1/\epsilon))$ time, a vector $x'$ which with high probability is an approximate solution to the linear system in that $\|x'-x\|_{\mU}\leq\epsilon\|b\|_{\mU^{\dagger}}$. \end{thm} Our proof of Theorem~\ref{thm:euleriansolver} is crucially based on the symmetric matrix $\mx\defeq\mlap^{\top}\mU^{\dagger}\mlap$. We begin by noting that $\mx$ is somewhat well approximated by $\mU$: \begin{lem} \label{lem:lapbounds}$\mx\succeq\mU$, while $\tr(\mx\mU^{\dagger})=\tr(\mlap^{\top}\mU^{\dagger}\mlap\mU^{\dagger})\leq2(n-1)^{2}$. \end{lem} \begin{proof} We first show that $\mU\preceq\mx$. Let $\mv$ denote the antisymmetric matrix $\frac{1}{2}(\mlap-\mlap^{\top})$ so that $\mlap=\mU+V$. With this notation we have \begin{align*} \mx & =(\mU+\mv)^{\top}\mU^{\dagger}(\mU+\mv)=(\mU-\mv)\mU^{\dagger}(\mU+\mv)\\ & =\mU-\mv+\mv-\mv\mU^{\dagger}\mv=\mU+\mv^{\top}\mU^{\dagger}\mv\succeq\mU\,. \end{align*} Next, for the trace bound, we first note as $\mlap$ is an Eulerian Laplacian it can be decomposed as a sum over simple cycles (multiplied by a scalar weight) $\mlap_{i}$, i.e. \[ \mlap=\sum_{i}\mlap_{i}\enspace\text{ and }\enspace\mU=\sum_{i}\mU_{i} \] where $\mU_{i}\defeq\frac{1}{2}(\mlap_{i}+\mlap_{i}^{\top})$. Now we claim $\mx\preceq\sum_{i}\mlap_{i}^{\top}\mU_{i}^{\dagger}\mlap_{i}.$This can be shown by simply directly bounding the quadratic form for each input, showing that \[ v^{\top}\mx v\leq\sum_{i}(\mlap_{i}v)^{\top}\mU_{i}^{\dagger}(\mlap_{i}v). \] This in turn follows from the general statement that for any two vectors $u$ and $v$, and positive definite matrices $\ma$ and $\mb$, \[ (u+v)^{\top}(\ma+\mb)^{-1}(u+v)\leq u^{\top}\ma^{-1}u+v^{\top}\mb^{-1}v\,. \] Consequently, our claim $\mx\preceq\sum_{i}\mlap_{i}^{\top}\mU_{i}^{\dagger}\mlap_{i}$ holds and therefore $\tr(\mx\mU^{\dagger})\leq\sum_{i}\tr(\mlap_{i}^{\top}\mU_{i}^{\dagger}\mlap_{i}\mU^{\dagger})$. Next, we note that if $\mlap_{i}$ is a simple cycle of length $k_{i}$ and weight $w_{i}$ through the vertices $V_{i}\subseteq V$, then $\mlap_{i}^{\top}\mU_{i}^{\dagger}\mlap_{i}$ is precisely the clique on those $k_{i}$ vertices, multiplied by $\frac{2w_{i}}{k_{i}}$. This can be verified, for instance, using an eigenvector decomposition (the Fourier vectors simultaneously diagonalize $\mlap_{i}$, $\mlap_{i}^{\top}$, and $\mU_{i}$). We then can express $\tr(\mlap_{i}^{\top}\mU_{i}^{\dagger}\mlap_{i}\mU^{\dagger})$ as $\frac{2w_{i}}{k_{i}}$ times the sum over all pairs of vertices $u,v\in V_{i}$ of the effective resistance between $u$ and $v$ in $\mU$. Effective resistances form a metric; since any two vertices in $V_{i}$ are connected by some path through the cycle, their effective resistance must always be at most the sum of the effective resistances between the edges in the cycle, which in turn is $\frac{2}{w_{i}}\tr(\mU_{i}\mU^{\dagger})$. With $\frac{k_{i}(k_{i}-1)}{2}$ pairs of vertices, we have \[ \tr(\mlap_{i}^{\top}\mU_{i}^{\dagger}\mlap_{i}\mU^{\dagger})\leq2(k_{i}-1)\tr(\mU_{i}\mU^{\dagger})\leq2(n-1)\tr(\mU_{i}\mU^{\dagger}) \] and \[ \sum_{i}\tr(\mlap_{i}^{\top}\mU_{i}^{\dagger}\mlap_{i}\mU^{\dagger})\leq2(n-1)\sum_{i}\tr(\mU_{i}\mU^{\dagger})\leq2(n-1)\tr(\mU\mU^{\dagger})=2(n-1)^{2}\,. \] \end{proof} Lemma~\ref{lem:lapbounds} immediately suggests our approach: we essentially solve systems in $\mlap$ by solving systems in $\mx$ (technically, we use a slightly different matrix $\widetilde{\mx}$ which we define later), and use preconditioning schemes for symmetric positive definite matrices based on the structure of $\mx$ and $\mU$. A simple preconditioning strategy would be to directly use $\mU$ as a preconditioner for $\mx$ in an algorithm like preconditioned Chebyshev iteration. This depends on the \emph{relative condition number} of $\mU$ and $\mx$; the relative condition number of two symmetric positive semidefinite matrices $\ma$ and $\mb$ is defined to be infinite if they don't have the same null space, and otherwise to be $\frac{\lambda_{max}(\ma\mb^{\dagger})}{\lambda_{min}(\ma\mb^{\dagger})}.$ Since the relative condition number of $\mx$ and $\mU$ is at most $O(n^{2})$ by Lemma~\ref{lem:lapbounds} and iterative algorithms like preconditioned Chebyshev iteration have an iteration count proportional to the square root of the relative condition number, this would require about $n$ iterations for a total runtime of about $nm$ (using fast Laplacian solvers to solve systems in $\mU$). One might hope to improve this by plugging the \emph{trace} bound into a result from \cite{SpielmanW09}, which says that if one uses preconditioned \emph{conjugate gradient} in exact arithmetic, the iteration count scales only with the cube root of the trace. That would give a runtime of about $n^{2/3}m$. However, it is unknown how to obtain this result without using exact arithmetic (or a polynomial number of bits of precision). Since we are aiming for algorithms which only need a logarithmic number of bits of precision (see Appendix~\ref{sec:numerical_stability}) it is unclear how to leverage preconditioned conjugate gradient directly to improve the running time and this remains an interesting open question. Instead use a technique similar to the method of transmogrification used in Laplacian solvers, in particular \cite{KoutisMP11}. However, our method deviates from much of this previous work in that it is non-recursive and uses only the Woodbury matrix identity (instead of partial Cholesky factorization) to solve the preconditioner. This allows us to obtain a preconditioner with a better relative condition number than $\mU$ itself, which can still be applied nearly as efficiently. First, we state the ``matrix Chernoff bound'' that we will use to construct the preconditioner: \begin{lem} \label{lem:matrixchernoff}Let $\epsilon,\delta\in(0,1/2)$. Let $\mm=\sum_{i}\mm_{i}$ be the sum of independent random symmetric $n$-dimensional matrices $\mm_{i}$, where each $\mm_{i}$ is positive definite and satisfies $\|\mm_{i}\|_{2}\leq\frac{\epsilon^{2}}{3\log(2n/\delta)}$ with probability 1. Furthermore, let $\mathrm{E}[\mm]\preceq\mI$. Then $\|\mm-\mathrm{E}[\mm]\|\leq\epsilon$ with probability at least $1-\delta$. \end{lem} \begin{proof} Apply Theorem 1.4 (``matrix Bernstein'') from \cite{Tropp12} to $\sum_{i}(\mm_{i}-\mathrm{E}[\mm_{i}])$, and let $R'=\frac{\epsilon^{2}}{3\log(2n/\delta)}$. We have unconditionally, for all $i$, $\|\mm_{i}-\mathrm{E}[\mm_{i}]\|\leq\|\mm_{i}\|+\|\mathrm{E}[\mm_{i}]\|\leq2R'$. Furthermore, we have \begin{align*} \sum_{i}\mathrm{E}[(\mm_{i}-\mathrm{E}[\mm_{i}])^{2}] & =\sum_{i}(\mathrm{E}[\mm_{i}^{2}]-(\mathrm{E}[\mm_{i}])^{2})\preceq\sum_{i}\mathrm{E}[\mm_{i}^{2}]\preceq R'\sum_{i}\mathrm{E}[\mm_{i}]\preceq R'\mI\,. \end{align*} We thus have $R=2R'$ and $\sigma^{2}\leq R'$ in that theorem statement. The probability that the max eigenvalue of $\mm-\mathrm{E}[\mm]$ is greater than $\epsilon$ is then at most \begin{align*} n\exp\left(-\frac{\epsilon^{2}/2}{R'+2R'\epsilon/3}\right) & =n\exp\left(-\frac{\epsilon^{2}}{2R'(1+2\epsilon/3)}\right)\leq n\exp\left(-\frac{\epsilon^{2}}{3R'}\right)\\ & \leq n\exp(-\log(2n/\delta))=\frac{\delta}{2}\,. \end{align*} Applying the same argument to the negation $\mathrm{E}[\mm]-\mm$ and union bounding gives the result. \end{proof} For notational convenience (to deal with inexact Laplacian system solvers), for the next statements, we let $\widetilde{\mU}$ be any symmetric matrix satisfying $\frac{1}{2}\mU\preceq\widetilde{\mU}\preceq\mU,$ and let $\widetilde{\mx}\defeq\mlap^{\top}\widetilde{\mU}^{\dagger}\mlap$. The next statement gives us a method to construct preconditioners for $\mx$; it is inspired by the ``ultrasparsifiers'' or ``incremental sparsifiers'' from \cite{KoutisMP11}. \begin{lem} \label{lem:ultrasparsify} For any $k\in[0,n^{2}]$, there exists a set of nonnegative weights $w_{i}$, with at most $O(\frac{n^{2}\log n}{k})$ of them nonzero, such that \[ \frac{1}{2}\left(\widetilde{\mU}+\frac{1}{k}\widetilde{\mx}\right)\preceq\widetilde{\mU}+\mlap^{\top}\widetilde{\mU}^{\dagger}\mb^{\top}\mw\mb\widetilde{\mU}^{\dagger}\mlap\preceq2\left(\widetilde{\mU}+\frac{1}{k}\widetilde{\mx}\right). \] Furthermore, if $\widetilde{\mU}^{\dagger}$can be applied to a vector in $O(m\log n)$ time, such weights can be computed in time $O(m(\log n)^{2})$ with high probability. Note that no access to $\widetilde{\mU}$ itself is needed; only its pseudoinverse. \end{lem} \begin{proof} Define $l_{i}\defeq\|\mlap^{\top}\widetilde{\mU}^{\dagger}b_{i}\|_{\widetilde{\mU}^{\dagger}}$ where $b_{i}$ is the $i$th row of $\mb$ for all $i\in[n]$. Then there exists some universal constant $C$ (depending on the exponent in the ``high probability'') such that if $p_{i}\geq Cl_{i}\log n$, we can independently pick $\frac{\sum_{i}p_{i}}{k}$ rows of $\mb$, with replacement, with probability of picking row $i$ each time being $\frac{p_{i}}{\sum_{i}p_{i}}$, then add $\frac{1}{p_{i}}$ to $w_{i}$ each time $i$ is picked. Here, we define $\mv=\widetilde{\mU}+\frac{1}{k}\widetilde{\mx}$ and $\widetilde{\mv}=\widetilde{\mU}+\mlap^{\top}\widetilde{\mU}^{\dagger}\mb^{\top}\mw\mb\widetilde{\mU}^{\dagger}\mlap$. Then we apply Lemma~\ref{lem:matrixchernoff} to $\mv^{-\frac{1}{2}}(\widetilde{\mv}-\widetilde{\mU})\mv^{-\frac{1}{2}}$, which is a sum of independent random matrices, with expectation$\preceq\mI$, with each term having spectral norm at most $\frac{1}{C\log n}$. If $C$ is set sufficiently large this guarantees the desired result. We have \begin{align*} \sum_{i\in[n]}l_{i} & =\sum_{i\in[n]}b_{i}^{\top}\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger}\mlap^{\top}\widetilde{\mU}^{\dagger}b_{i}=\sum_{i\in[n]}\tr(\mlap^{\top}\widetilde{\mU}^{\dagger}b_{i}b_{i}^{\top}\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger})\leq\tr(\mlap^{\top}(4\mU^{\dagger})\mlap(2\mU^{\dagger}))\\ & =8\tr(\mx\mU^{\dagger})=O(n^{2})\,. \end{align*} where the last line used Lemma~\ref{lem:lapbounds}. Thus, if we can compute a constant-factor approximation to the $l_{i}$, we can obtain $p_{i}\geq Cl_{i}\log(n)$ with $\sum_{i}p_{i}=O(n^{2}\log n)$, and the random sample will be of size $O(k^{-1}n^{2}\log n)$ as desired. Next, we note that $l_{i}$ is within a factor of 2 of $\|\mb\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger}b_{i}\|_{2}$, since $\widetilde{\mU}^{\dagger}\mb^{\top}\mb\widetilde{\mU}^{\dagger}=\mU^{\dagger}\mU\mU^{\dagger}$ is within a factor of two of $\widetilde{\mU}^{\dagger}=\widetilde{\mU}^{\dagger}\widetilde{\mU}\widetilde{\mU}^{\dagger}$. Thus a constant factor approximation to the latter expression is sufficient. Finally, we note that we can compute all of these constant factor approximations using Johnson-Lindenstrauss (analogous to the construction in \cite{SpielmanS08}). In particular, we may let $\mpi$ be a Gaussian random matrix with $r=O(\log n)$ rows and $m$ columns, rescaled by $\frac{1}{\sqrt{r}}$. Then the Johnson-Lindenstrauss lemma implies that with high probability, $\|\mpi\mb\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger}b_{i}\|_{2}$ will be within a constant factor of $\|\mb\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger}b_{i}\|_{2}$ for all $i$. We may compute each row of $\mpi\mb\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger}$ in $O(m\log n)$ time by successively multiplying the rows of $\mpi$ by $m$-sparse matrices and $\widetilde{\mU}^{\dagger},$ each of which can be done in $O(m\log n)$ time. Thus computing it for all rows takes time $O(m(\log n)^{2}).$ Finally, since $\mpi\mb\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger}$ has $O(\log n)$ rows and $b_{i}$ is 2-sparse, we can compute each $\mpi\mb\widetilde{\mU}^{\dagger}\mlap\widetilde{\mU}^{\dagger}b_{i}$ in $O(\log n)$ time, taking $O(m\log n)$ time in total. \end{proof} Lemma~\ref{lem:ultrasparsify} says that for large $k$, we can approximate $\widetilde{U}+\frac{1}{k}\widetilde{X}$ with a low-rank update to $\widetilde{\mU}$, i.e. rank $O(k^{-1}n^{2}\log n)$ to be precise. In the next lemma we show that with a little precomputation, we can apply the pseudoinverse of this approximation efficiently. \begin{lem} \label{lem:ShermanMorrison} Consider the matrix $\mz=\widetilde{\mU}+\mlap^{\top}\widetilde{\mU}^{\dagger}\mb^{\top}\mw\mb\widetilde{\mU}^{\dagger}\mlap$. If $\widetilde{\mU}^{\dagger}$ can be applied to a vector in time $T$, and $\mw$ has $r$ non-zero entries, then after precomputation taking $O((m+T)r+r^{3})$ time, we can apply $\mathbf{Z}^{\dagger}$ to a vector in $O(m+T+r^{2})$ time. \end{lem} \begin{proof} We define $\mr$ to be the restriction of $\mb\widetilde{\mU}^{\dagger}\mlap$ to the rows where $\mw$ is nonzero, so that $\mz=\widetilde{\mU}+\mr^{\top}\mw_{S}\mr$ (where $\mw_{S}$ is $\mw$ similarly restricted). Then we can apply the Woodbury matrix identity to get that \[ \mz^{\dagger}=\widetilde{\mU}^{\dagger}-\widetilde{\mU}^{\dagger}\mr^{\top}(\mw_{S}^{-1}+\mr\widetilde{\mU}^{\dagger}\mr^{\top})^{-1}\mr\widetilde{\mU}^{\dagger}. \] First, we define the precomputation stage, which computes the entries of the matrix $\mm=(\mw_{S}^{-1}+\mr\widetilde{\mU}^{\dagger}\mr^{\top})^{-1}$. This has two logical steps: computing the entries of $\mr\widetilde{\mU}^{\dagger}\mr^{\top}$ and then computing the matrix inverse. We compute $\mr\widetilde{\mU}^{\dagger}\mr^{\top}$column by column, simply applying $\mr^{\top}$, $\widetilde{\mU}^{\dagger}$, and $\mr$ in succession to each of the standard basis vectors. The applications of $\mr$ and $\mr^{\top}$ are done by successively applying $\mb$, $\widetilde{\mU}^{\dagger}$,$\mlap$, and their transposes; each of these is either an $O(m)$-sparse matrix or one which we are promised can be applied in time $T$. Thus, each of these columns can be computed in time at most $O(m+T)$; getting all $r$ columns then takes $O((m+T)r)$ time. Adding this to $\mw_{S}^{-1}$ (which is diagonal) and then inverting the $r\times r$ matrix takes time at most $O(r^{3})$ even using a naive algorithm such as Gaussian elimination (which already suffices to achieve our desired result). Now, once this $\mm$ has been precomputed, we can apply the operator $\mz^{\dagger}$ to a vector just by applying $\widetilde{\mU}^{\dagger}$ and applying $\widetilde{\mU}^{\dagger}\mr^{\top}\mm\mr\widetilde{\mU}^{\dagger}$ by applying the individual factors successively. Applying $\mm$ costs at most $O(r^{2})$ since that is the size of the matrix, while the other applications take $O(m+T);$ thus the total time to apply is $O(m+T+r^{2}).$ \end{proof} \begin{lem} \label{lem:complicated-matrix-solver}If $\widetilde{\mU}^{\dagger}$ can be applied to a vector in $O(m\log n)$ time, we can, with high probability, apply a linear operator $\my^{\dagger}$ satisfying $(1-\epsilon)\widetilde{\mx}^{\dagger}\preceq\my^{\dagger}\preceq(1+\epsilon)\widetilde{\mx}^{\dagger}$ in $O((nm^{3/4}+n^{2/3}m)(\log n)^{3}\log(1/\epsilon))=O(\tsolve\log(1/\epsilon))$ time. \end{lem} \begin{proof} Invoke \ref{lem:ultrasparsify} for $k=\max(n^{2}/\sqrt{m},n^{4/3})$, and define $\mz=\widetilde{\mU}+\mlap^{\top}\widetilde{\mU}^{\dagger}\mb^{\top}\mw\mb\widetilde{\mU}^{\dagger}\mlap$. The number of nonzero entries in $\mw$ will then be at most $O(\min(\sqrt{m},n^{2/3})\log n)$. Now, apply \ref{lem:ShermanMorrison}. The precomputation takes time $O((m\log n)r+r^{3})\leq O(n^{2/3}m(\log n)^{2}+\min(m^{3/2},n^{2})(\log n)^{3}).$ Since $\min(m^{3/2},n^{2})\leq nm^{3/4}+n^{2/3}m$, this is $O((nm^{3/4}+n^{2/3}m)(\log n)^{3}$. The time per application is at most $O(m+m\log n+(\sqrt{m}\log n)^{2})=O(m(\log n)^{2}).$ Now, we use $\mz^{+}$ as a preconditioner in an iterative method: preconditioned Chebyshev iteration. Because the relative condition number between $\mz$ and $\widetilde{\mx}$ is $O(k)$, the number of iterations required is $O(\sqrt{k}\log(1/\epsilon))=O((n/m^{1/4}+n^{2/3})\log(1/\epsilon))$. Each iteration requires one application of $\widetilde{\mx}$ and one application of $\mz^{\dagger}$ to vectors, each of which takes $O(m(\log n)^{2})$ time. The total running time of this solve phase is then at most $O((nm^{3/4}+n^{2/3}m)(\log n)^{2}\log(1/\epsilon))$. \end{proof} Now, we turn Lemma~\ref{lem:complicated-matrix-solver} into a solver for $\mlap$. \begin{lem} \label{lem:weirdnormsolver} Let $b$ be an $n$-dimensional vector in the image of $\mlap$, and let $x$ be the solution to $\mlap x=b$. Then for any $0<\epsilon\leq\frac{1}{2}$, one can compute in $O(\tsolve\log(1/\epsilon))$ time a vector $x'$ which with high probability is an approximate solution to the linear system in that $\|x'-x\|_{\mx}\leq\epsilon\|b\|_{\mU^{\dagger}}$. Furthermore, a given choice of random bits produces a correct result for all $b$ simultaneously, and makes $x'$ linear in $b$. \end{lem} \begin{proof} First note that we can actually choose a $\widetilde{\mU}^{\dagger}$ satisfying the needed properties: a linear-operator based graph Laplacian solver, such as \cite{KoutisMP11}. With this $\widetilde{\mU}^{\dagger}$, we apply Lemma~\ref{lem:complicated-matrix-solver}, which produces a linear operator $\my^{\dagger}.$ We simply return $x'=\my^{\dagger}\mlap^{\top}\widetilde{\mU}^{\dagger}b$\textendash corresponding to approximately solving the linear system $\mlap^{\top}\widetilde{\mU}^{\dagger}\mlap x=\mlap^{\top}\widetilde{\mU}^{\dagger}b$. The error bound follows from \begin{align*} \|x'-x\|_{\mx} & \leq\|x'-x\|_{\widetilde{\mx}}=\|(\my^{\dagger}-\widetilde{\mx}^{\dagger})\mlap^{\top}\widetilde{\mU}^{\dagger}b\|_{\widetilde{X}}=\|\mlap^{\top}\widetilde{\mU}^{\dagger}b\|_{(\my^{\dagger}-\widetilde{\mx}^{\dagger})\widetilde{\mx}(\my^{\dagger}-\widetilde{\mx}^{\dagger})}\\ & \leq\epsilon\|\mlap^{\top}\widetilde{\mU}^{\dagger}b\|_{\widetilde{\mx}^{\dagger}}=\epsilon\|\widetilde{\mU}^{\dagger}b\|_{\mlap\widetilde{\mx}^{\dagger}\mlap^{\top}}=\epsilon\|\widetilde{\mU}^{\dagger}b\|_{\widetilde{\mU}}\\ & =\epsilon\|b\|_{\widetilde{\mU}^{\dagger}}\leq\epsilon\|b\|_{\mU^{\dagger}}. \end{align*} \end{proof} Theorem~\ref{thm:euleriansolver} follows as an immediate corollary: \begin{proof}[Proof of Theorem \ref{thm:euleriansolver}] Apply Lemma \ref{lem:weirdnormsolver} and use the fact (from Lemma \ref{lem:lapbounds}) that $\mU\preceq\mx$: \begin{align*} \|x'-x\|_{\mU} & \leq\|x'-x\|_{\mx}\leq\epsilon\|b\|_{\mU^{\dagger}}. \end{align*} \end{proof} \section{\label{sec:Deriving-the-Identities}Deriving the Identities from Section \ref{subsec:app-commute}} \subsection{\label{subsec:Hitting-Time-Formula}Formula for Hitting Times (Proof of Lemma \ref{prop:hitting-time-rank-1})} We derive the formula for $H_{uv}$ from first principles. Let $h^{v}$ be a vector where $h_{u}^{v}=H_{uv}$. Then, applying the definition we have that \begin{eqnarray*} h_{u}^{v} & = & \begin{cases} 0, & \mbox{if }u=v\\ 1+\sum_{w}\mbox{\ensuremath{\mw}}_{wu}\cdot h_{w}^{v}, & \mbox{if }u\neq v \end{cases}=\begin{cases} 0, & \mbox{if }u=v\\ 1+\left(\mbox{\ensuremath{\mw}}^{\top}h^{v}\right)_{u}, & \mbox{if }u\neq v \end{cases}\,. \end{eqnarray*} Rearranging terms, we see that $h^{v}$ is a solution to the linear system \[ \left[\begin{array}{cc} \left[\mI-\mw^{\top}\right]_{B,B} & \left[\mI-\mw^{\top}\right]_{B,v}\\ \vzero & 1 \end{array}\right]\left[\begin{array}{c} h_{B}^{v}\\ h_{v}^{v} \end{array}\right]=\left[\begin{array}{c} \vec{1}\\ 0 \end{array}\right]\,, \] where $B=V\setminus\left\{ v\right\} $. Since every row is diagonally dominant, with the last row being strictly so, we see that a solution to this system of equation is unique. Consequently, it suffices to find a solution to this system of equations. Now, let $x$ be any solution to $(\mI-\mw)^{\top}x=d$ where $d_{u}=1$ for $u\neq v$ and $d_{v}=1-\frac{1}{s_{v}}$. Since the graph associated to $\mw$ is strongly connected, and $d\perp s$, there exists such an $x$ which is unique up to adding multiples of $\vec{1}$. Consequently, if we let $y=x-x_{v}\vec{1}$ then we see that $[(\mI-\mw^{\top})y]_{u}=[(\mI-\mw^{\top})x]_{u}=d_{u}=1$ for $u\neq v$, and $y_{v}=0$. Therefore, $y=h^{v}$ and \[ H_{uv}=y_{u}=\vec{1}_{u}^{\top}(\mI-\mw^{\top})^{\dagger}d-\vec{1}_{v}^{\top}(\mI-\mw^{\top})^{\dagger}d=(\vec{1}_{u}-\vec{1}_{v})^{\top}(\mI-\mw^{\top})^{\dagger}d\,. \] Plugging in $d=\vec{1}-\vec{1}_{v}\cdot\frac{1}{s_{v}}$, we obtain \[ H_{uv}=(\vec{1}-\vec{1}_{v}\cdot\frac{1}{s_{v}})^{\top}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})\,. \] \subsection{\label{subsec:commute-formula}Formula for Commute Times (Proof of Lemma \ref{prop:commute-time})} Using the identity from Lemma \ref{prop:hitting-time-rank-1}, we can prove a nice formula for commute times. \begin{align*} C_{uv} & =H_{uv}+H_{vu}\\ & =(\vec{1}-\vec{1}_{v}\cdot\frac{1}{s_{v}})^{\top}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})+(\vec{1}-\vec{1}_{u}\cdot\frac{1}{s_{u}})^{\top}(\mI-\mw)^{\dagger}(\vec{1}_{v}-\vec{1}_{u})\\ & =(\vec{1}-\vec{1}_{v}\cdot\frac{1}{s_{v}})^{\top}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})-(\vec{1}-\vec{1}_{u}\cdot\frac{1}{s_{u}})^{\top}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})\\ & =(\vec{1}_{u}\cdot\frac{1}{s_{u}}-\vec{1}_{v}\cdot\frac{1}{s_{v}})^{\top}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})\\ & =(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})\,. \end{align*} Furthermore, this also gives \begin{eqnarray*} C_{uv} & = & (\vec{1}_{u}-\vec{1}_{v})((\mI-\mw)\ms)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})\,. \end{eqnarray*} While in general $((\mI-\mw)\ms)^{\dagger}\neq\ms^{-1}(\mI-\mw)^{\dagger},$ in this case we notice that \[ (\vec{1}_{u}-\vec{1}_{v})^{\top}\left(\ms^{-1}(\mI-\mw)^{\dagger}-((\mI-\mw)\ms)^{\dagger}\right)(\vec{1}_{u}-\vec{1}_{v})=0\,, \] and the result follows. \begin{sloppypar}Indeed, we can immediately see that $\left((\mI-\mw)^{\dagger}-\ms((\mI-\mw)\ms)^{\dagger}\right)(\vec{1}_{u}-\vec{1}_{v})\in\ker(\mI-\mw)$: using the fact that $\vec{1}_{u}-\vec{1}_{v}\perp\ker(\mI-\mw^{\top})$, so $\vec{1}_{u}-\vec{1}_{v}\in Im(\mI-\mw)$, we obtain $(\mI-\mw)\left((\mI-\mw)^{\dagger}-\ms((\mI-\mw)\ms)^{\dagger}\right)(\vec{1}_{u}-\vec{1}_{v})=(\mI_{Im(\mI-\mw)}-\mI_{Im((\mI-\mw)\ms)})(\vec{1}_{u}-\vec{1}_{v})=0$. Therefore, $(\vec{1}_{u}-\vec{1}_{v})^{\top}\left(\ms^{-1}(\mI-\mw)^{\dagger}-((\mI-\mw)\ms)^{\dagger}\right)(\vec{1}_{u}-\vec{1}_{v})=(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\cdot k$ where $k\in\ker(\mI-\mw)$. Hence, writing $k=\alpha s$ for some constant $\alpha$, we have $(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}k=(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}\cdot\alpha s=(\vec{1}_{u}-\vec{1}_{v})^{\top}\cdot\alpha\vec{1}=0$, which yields the desired result.\end{sloppypar} Finally, for the third identity, since the vectors on both sides are symmetric, we can write \[ C_{uv}=\left(\vec{1}_{u}-\vec{1}_{v}\right)^{\top}\mlap_{b}^{\dagger}\left(\vec{1}_{u}-\vec{1}_{v}\right)=\frac{1}{2}\left(\vec{1}_{u}-\vec{1}_{v}\right)^{\top}\left(\mlap_{b}^{\dagger}+\left(\mlap_{b}^{\dagger}\right)^{\top}\right)\left(\vec{1}_{u}-\vec{1}_{v}\right). \] We will show that the matrix that appears in the middle is, as a matter of fact, symmetric positive semi-definite. In order to do so, we first use the fact that \[ \mlap_{b}^{\dagger}+\left(\mlap_{b}^{\dagger}\right)^{\top}=\mlap_{b}^{\dagger}\left(\mlap_{b}+\mlap_{b}^{\top}\right)\left(\mlap_{b}^{\dagger}\right)^{\top}\,, \] which follows immediately by expanding the right hand side. This identity critically uses the fact that $\mlap_{b}$ is Eulerian, and therefore the right and left null spaces coincide. Plugging this into the previous formula for commute times yields our desired identity. \subsection{\label{subsec:Escape-Probabilities}Formula for Escape Probabilities (Proof of Lemma \ref{prop:escape-prob})} Just like we did for hitting times, we can derive the formula for escape probabilities from first principles. In particular, the definition gives us \begin{eqnarray*} p_{i} & = & \begin{cases} 1, & \mbox{if }i=u\\ 0, & \mbox{if }i=v\\ \sum_{j}\mw_{ij}\cdot p_{j}, & \mbox{otherwise} \end{cases}=\begin{cases} 1, & \mbox{if }i=u\\ 0, & \mbox{if }i=v\\ \mw\cdot p, & \mbox{otherwise} \end{cases}\,. \end{eqnarray*} Equivalently, this yields the linear system: \[ \left[\begin{array}{ccc} [\mI-\mw]_{B,B} & [\mI-\mw]_{B,s} & [\mI-\mw]_{B,t}\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array}\right]\left[\begin{array}{c} p_{B}\\ p_{u}\\ p_{v} \end{array}\right]=\left[\begin{array}{c} \vec{0}\\ 1\\ 0 \end{array}\right]\,, \] where $B=V\setminus\left\{ u,v\right\} $. Again, since every row is diagonally dominant, and the last two are strictly so, we see that a solution to this system is unique. So we only need to find a solution to this system. Now let $x$ be a solution to $(\mI-\mw)x=\vec{1}_{u}-\vec{1}_{v}$. Since $\vec{1}_{u}-\vec{1}_{v}\perp\vec{1}$, the solution exists. Also, since the graph associated to $\mw$ is strongly connected, it is unique up to adding multiples of the stationary. Therefore letting $y=x-s\cdot\frac{x_{v}}{s_{v}}$ all the constraints of the system are satisfied, except $y_{u}=1$. Setting $y'=\frac{1}{y_{u}}\cdot y=\left(x_{u}-s_{u}\cdot\frac{x_{v}}{s_{v}}\right)^{-1}\left(x-s\cdot\frac{x_{v}}{s_{v}}\right)=\left(s_{u}\left(\frac{x_{u}}{s_{u}}-\frac{x_{v}}{s_{v}}\right)\right)^{-1}\cdot\left(x-s\cdot\frac{x_{v}}{s_{v}}\right)$ yields a solution to the system. Consequently, $p=y'$ and the result follows. Next, we bound the coefficients. We have $\abs{\alpha}=\abs{\frac{x_{v}}{s_{v}}}\leq\frac{1}{s_{\textnormal{min}}}\cdot\norm{(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}_{\infty}\leq\frac{1}{s_{\textnormal{min}}}\cdot\norm{(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}_{\infty}\leq\frac{1}{s_{\textnormal{min}}}\cdot\norm{(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}_{1}\leq\frac{1}{s_{\textnormal{min}}}\cdot\norm{(\mI-\mw)^{\dagger}}_{1}\norm{\vec{1}_{u}-\vec{1}_{v}}_{1}$. Plugging in Theorem \ref{thm:mixingTimesSingular}, we obtain that $\abs{\alpha}\leq\frac{t_{\textnormal{mix}}}{s_{\textnormal{min}}}\cdot8\sqrt{n}\log_{2}n$. Also, $\beta=\frac{1}{s_{u}\left(\frac{x_{u}}{s_{u}}-\frac{x_{v}}{s_{v}}\right)}=\frac{1}{s_{u}(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}$. As seen from Lemma \ref{prop:commute-time}, the term $(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})$ is precisely the commute time $C_{uv}$ which satisfies $1\leq C_{uv}$ by definition. Also, we have that $C_{uv}=(\vec{1}_{u}-\vec{1}_{v})^{\top}\ms^{-1}(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})\leq\norm{\ms^{-1}(\vec{1}_{u}-\vec{1}_{v})}_{\infty}\cdot\norm{(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}_{1}\leq\frac{1}{s_{\textnormal{min}}}\cdot\norm{(\mI-\mw)^{\dagger}(\vec{1}_{u}-\vec{1}_{v})}_{1}\leq\frac{t_{\textnormal{mix}}}{s_{\textnormal{min}}}\cdot8\sqrt{n}\log_{2}n$ . Therefore $\frac{1}{t_{\textnormal{mix}}\cdot8\sqrt{n}\log_{2}n}\leq\beta\leq\frac{1}{s_{\textnormal{\ensuremath{\min}}}}$. \section{Introduction} The application and development of spectral graph theory has been one of the great algorithmic success stories of the past three decades. By exploiting the relationship between the combinatorial properties of a graph, the linear algebraic properties of its Laplacian, and the probabilistic behavior of the random walks they induce, researchers have obtained landmark results ranging across multiple areas in the theory of algorithms, including Markov chain Monte Carlo techniques for counting \cite{DBLP:journals/iandc/SinclairJ89,karp1989monte,jerrum2004polynomial} and volume estimation \cite{lovasz1990mixing,dyer1991random,vempala2005geometric,lovasz2006fast,lovasz2006hit,lee2016geodesic}, approximation algorithms for clustering and graph partitioning problems \cite{alon1985lambda1,SpielmanTengSolver:journal,kannan2004clusterings,AndersenCL06,orecchia2012approximating}, derandomization \cite{hoory2006expander,reingold2008undirected}, error correcting codes \cite{spielman1995linear,sipser1996expander}, and the analysis of random processes \cite{lovasz1993random}, among others. In addition to their theoretical impact, spectral techniques have found broad applications in practice, forming the core of Google's PageRank algorithm, playing a ubiquitous role in practical codes for machine learning, computer vision, clustering, and graph visualization. Furthermore they have enabled the computation of fundamental properties of various Markov chains, such as stationary distributions, escape probabilities, hitting times, mixing times, and commute times. More recently, spectral graph theory has been driving an emerging confluence of algorithmic graph theory, numerical scientific computing, and convex optimization. This recent line of work began with a sequence of papers that used combinatorial techniques to accelerate the solution of linear systems in undirected graph Laplacians, eventually leading to algorithms that solve these systems in nearly-linear time \cite{SpielmanTengSolver:journal,KoutisMP10:journal,KoutisMP10,KoutisMP11,KelnerOSZ13,lee2013efficient,Cohen:2014:SSL:2591796.2591833,PengS14,LeePS15,KyngLPSS15:arxiv}. This was followed by an array of papers in the so-called ``Laplacian Paradigm'' \cite{Teng10}, which either used this nearly-linear-time algorithm as a primitive or built on the structural properties underlying it to obtain faster algorithms for problems at the core of algorithmic graph theory, including finding maximum flows and minimum cuts \cite{christiano2011electrical,lee2013new,sherman2013nearly,kelner2014almost,peng2016approximate}, solving traveling salesman problems \cite{asadpour2010log,anari2015effective}, sampling random trees \cite{kelner2009faster,madry2015fast}, sparsifying graphs \cite{SpielmanS08,SpielmanS11,allen2015spectral,LeeS15}, computing multicommodity flows \cite{kelner2012faster,kelner2014almost}, and approximately solving a wide range of general clustering and partitioning problems \cite{alon1985lambda1,kannan2004clusterings,AndersenCL06,orecchia2012approximating}. While these recent algorithmic approaches have been very successful at obtaining algorithms running in close to linear time for undirected graphs, the directed case has conspicuously lagged its undirected counterpart. With a small number of exceptions involving graphs with particularly nice properties and a line of research in using Laplacian system solvers inside interior point methods for linear programming \cite{DBLP:conf/focs/Madry13,LeeS14,DBLP:journals/corr/CohenMSV16}, the results in this line of research have centered almost entirely on the spectral theory of undirected graphs. While there have been interesting results in candidate directed spectral graph theory \cite{ref1,AndersenCL06,GuoM15:arxiv}, their algorithmic ramifications have been less clear. One problem that particularly well illustrates the discrepancy between the directed and undirected settings is the computation of the stationary distribution of a random walk. Computing this is a primary goal in the analysis of Markov chains, constitutes the main step in the PageRank algorithm, remains the missing piece in derandomizing randomized log space computations \cite{4262767}, and is necessary to obtain the appropriate normalization for any of the theoretical or algorithmic results in one of the few instantiations of directed spectral graph theory \cite{ref1,AndersenCL06}. In the undirected setting, the stationary distribution is proportional to the degree of a vertex, so it can be computed trivially. However, despite extensive study in the mathematics, computer science, operations research, and numerical scientific computing communities, the best previously known asymptotic guarantees for this problem are essentially what one gets by applying general-purpose linear algebra routines. Given a directed graph with $n$ vertices and $m$ edges these previous algorithms fall into two broad classes: \begin{itemize} \item \textbf{Iterative Methods:} These aim to compute the stationary distribution by either simulating the random walk directly or casting it as a linear system or eigenvector computation and applying either a global or coordinate-wise iterative method to find it. The running times of these methods either depend polynomially on the relevant numerical conditioning property of the instance, which in this case is, up to polynomial factors, the mixing time of the random process; or they only compute a distribution that only approximately satisfies the defining equations of the stationary distribution, with a running time that is polynomial in $1/\epsilon$. There has been extensive work on tuning and specializing these methods to efficiently compute the stationary distribution, particularly in the special case of PageRank. However, all such methods that we are aware of retain a polynomial dependence on either the mixing time, which can be arbitrary large as a function of the number of edges of the graph, or on $1/\epsilon$.\footnote{A possibleexception, is the algorithm that invokes conjugate gradient in a blackbox manner to solve the requisite linear system to compute the stationary distribution. At best this analysis would suggest an $O(mn)$ running time. However, it is not known how to realize even this running time in the standard word-RAM model of computation.} \item \textbf{Fast Matrix Multiplication}: By using a direct method based on fast matrix multiplication, one can find the stationary distribution in time in time $n^{\omega}$, where $\omega<2.3729$ \cite{DBLP:conf/stoc/Williams12} is the matrix multiplication exponent. These methods neglect the graph structure and cannot exploit sparsity. As such, even if one found a matrix multiplication algorithm matching the lower bound of $\omega=2$, this cannot give a running time lower than $\Omega(n^{2})$, even when the graph is sparse. \end{itemize} Another problem which well demonstrates the gap between directed and undirected graph problems is that of solving linear systems involving graph Laplacians. For undirected graphs, as we have discussed there are multiple algorithms to solve associated Laplacian systems in nearly time. However, in the case of directed graphs natural extensions of solving Laplacian systems are closely related to computing the stationary distribution, and thus all known algorithms either depend polynomially on the condition number of the matrix or the desired accuracy or they require time $\Omega(n^{2})$. Moreover, many of the techniques, constructions, and properties used to solve undirected Laplacian systems either have no known analogues for directed graphs or can be explicitly shown to not exist. This gap in our ability to solve Laplacian systems is one of the the primary reasons (perhaps \emph{the} primary reason) that the recent wave of graph algorithms based on the ``Laplacian Paradigm'' have not produced directed results to match the undirected ones. Given the fact that, despite several decades of work on designing specialized methods for this problem, there are no methods known that asymptotically improve upon general linear algebra routines, along with the structural problems in translating the techniques from the undirected case, it would not be unreasonable to expect that the best one can hope for is heuristic improvements in special cases, and that the worst-case asymptotics for graph Laplacians are no better than the $\min{O(n^{\omega},nm)}\geq\Omega(n^{2})$ that is known for general matrices. In this paper, we show that this is not the case by providing an algorithm that solves directed graph Laplacian systems\textemdash a natural generalization of undirected graph Laplacian systems\textemdash in time $\tilde{O}(nm^{3/4}+n^{2/3}m)$ where here and throughout the paper the $\otilde(\cdot)$ notation hides polylogarithmic factors in $n$, the desired accuracy, and the natural condition numbers associated with the problem. Consequently, we obtain the first asymptotic improvement for these systems over solving general linear systems.\footnote{In follow up work, the authors of this paper in collaboration with Anup Rao have improved the running time to almost linear in the number of edges in the graph, meaning the running time is linear if we ignore contributions to the running time that are smaller than any polynomial. This paper will be made available online as soon as possible.} In particular, when the graph is sparse, i.e. $m=O(n)$, our algorithm runs in time $\otilde(n^{7/4})$, breaking the barrier of $O(n^{2})$ that would be achieved by algorithms based on fast matrix multiplication if $\omega=2$. We then leverage this result to obtain improved running times for a host of problems in algorithmic graph theory, scientific computing, and numerical linear algebra, including: \begin{itemize} \item \textbf{Computing the Stationary Distribution}: We compute a vector within $\ell_{2}$ distance $\epsilon$ of the stationary distribution of a random walk on a strongly connected directed graph in time $\otilde(nm^{3/4}+n^{2/3}m)$, where the natural condition number of this problem is the mixing time. (See Section~\ref{subsec:app-cond-est}.) \item \textbf{Solving Large Classes of Linear Systems}: We provide algorithms that solve a large class of well-studied linear systems. Compared with prior algorithms capable of solving this class, ours are the first that are asymptotically faster than solving general linear systems, and the first that break the $O(n^{2})$ barrier for sufficiently sparse instances. Our methods solve directed Laplacian systems and systems where the matrix is row- or column-diagonally dominant. The running time is $\tilde{O}\left(nm^{3/4}+n^{2/3}m\right)$. (See Section~\ref{subsec:app-solvers}.) \item \textbf{Computing Personalized PageRank}: We compute a vector within $\ell_{2}$ distance $\epsilon$ of the personalized PageRank vector, for a directed graph with with restart probability $\beta$, in time $\tilde{O}\left(nm^{3/4}+n^{2/3}m\right)$. Here the natural condition number is $1/\beta$. In the case of small $\beta$ and $\epsilon$, this improves upon local methods that take $O(m\beta^{-1}\epsilon^{-1})$ time \cite{PageBMW99,jeh2003scaling,fogaras2004towards,AndersenCL06,andersen2007local,lofgren2014fast}. (See Section~\ref{subsec:app-pagerank}). \item \textbf{Simulating Random Walks}: We show how to compute a wide range of properties of random walks on directed graphs including escape probabilities, commute times, and hitting times. (See Section~\ref{subsec:app-commute} and Section~\ref{subsec:Escape-probabilities}.) We also show how to efficiently estimate the mixing time of a lazy random walk on a directed graph up to polynomial factors in $n$ and the mixing time. (See Section~\ref{subsec:app-cond-est}.) The runtime for all these algorithms is $\tilde{O}\left(nm^{3/4}+n^{2/3}m\right)$. \item \textbf{Estimating All Commute Times}: We show how to build a $\otilde(n\epsilon^{-2}\log n)$ size data structure in time $\otilde(nm^{3/4}+n^{2/3}m)$ that, when queried with any two vertices $a$ and $b$, outputs a $1\pm\epsilon$ multiplicative approximation to the expected commute time between $a$ and $b$, i.e. the expected amount of time for a random walk starting at $a$ to reach $b$ and return to $a$. Our data structure is similar to the data structure known for computing all-pairs effective resistances in undirected graphs \cite{SpielmanS08,SpielmanS11}. (See Section~\ref{subsec:Sketching-Commute-Times}.) \end{itemize} It is important to note that the $\tilde{O}$-notation hides factors that are polylogarithmic in both the condition number (equivalently, mixing time) and the ratio of maximum to minimum stationary probability. As such, the natural parameter regime for our algorithms is when these quantities are subexponential or polynomial. For all the above problems, the best prior algorithms had worst case runtimes no better than $O(\min\{n^{\omega},nm\})\geq\Omega(n^{2})$ in this regime. We hope that our results open the door for further research into directed spectral graph theory, and serve as foundation for the development of faster algorithms for directed graphs. \subsection{Approach} Our approach for solving these problems centers around solving linear systems in a class of matrices we refer to as \emph{directed (graph) Laplacians}, a natural generalization of undirected graph Laplacians. A directed Laplacian, $\mlap\in\R^{n\times n},$ is simply a matrix with non-positive off-diagonal entries such that each diagonal entry is equal to the sum of the absolute value of the other off-diagonal entries in that column, i.e. $\mlap_{ij}\leq0$ for $i\neq j$ and $\mlap_{ii}=-\sum_{j\neq i}\mlap_{ji}$ (equivalently $\vec{1}^{\top}\mlap=\vec{0}$). As with undirected Laplacians, every directed Laplacian there is naturally associated with a directed graph $G=(V,E,w)$, where the vertices $V$ correspond to the columns of $\mlap$ and there is an edge from vertex $i$ to vertex $j$ of weight $\alpha$ if and only if $\mlap_{ji}=-\alpha$. Another close feature of directed and undirected Laplacians is the close connection between random walks on the associated graph $G$ and solutions to linear systems in $\mlap$. We ultimately show that solving a small number of directed Laplacian systems suffices to obtain all of our desired applications (See Section~\ref{sec:solving_strictly_rcdd} and Section~\ref{sec:applications}). Unfortunately, solving linear systems in $\mlap$ directly is quite challenging. Particularly troubling is the fact that we while we know $\mlap$ has a non-trivial kernel (since $\vec{1}^{\top}\mlap=\vec{0}^{\top})$, we do not have a simple method to compute it efficiently. Moreover, $\mlap$ is not symmetric, complicating the analysis of standard iterative algorithms.Furthermore, the standard approach of multiplying on the left by the transpose, so that we are solving linear systems in $\mlap^{\top}\mlap$, would destroy the combinatorial structure of the problem and cause an intolerably large condition number. A natural idea is to try to work with a symmetrization of this matrix, $\frac{1}{2}(\mlap+\mlap^{\top})$, but it turns out that this may not even be positive semidefinite (PSD).\footnote{Consider the directed edge Laplacian $\mlap=\left[\begin{array}{cc} 1 & 0\\ -1 & 0 \end{array}\right]$. Then, $\mlap+\mlap^{\dagger}=\left[\begin{array}{cc} 2 & -1\\ -1 & 0 \end{array}\right]$ has an eigenvector $(\sqrt{2}-1,1)$ with a corresponding eigenvalue of $(1-\sqrt{2})$.} Consequently, it is not clear a priori how to define an efficient iterative method for computing the stationary $\mlap$ or solve systems in it without depending polynomially on the condition number of $\mlap$. Fortunately, we do know how to characterize the kernel of $\mlap$, even if computing it is difficult \emph{a priori}. If we let $\md\in\R^{n\times n}$ denote the diagonal matrix consistent with $\mlap$, i.e., $\md_{ii}=\mlap_{ii}$, then we see that $\mlap\md^{-1}=\mI-\mw$ where $\mI$ is the identity matrix and $\mw$ is the random walk matrix associated with $G$. In other words, for any distribution $p$, we have that $\mw p$ is the resulting distribution of one step of the random walk where, at a vertex $i\in[n]$, we pick a random outgoing edge with probability proportional to its weight and follow that edge. The Perron-Frobenius Theorem implies that as long as the graph is strongly connected there is some stationary distribution $s\in\R_{>0}$ such that $\mw s=s$. Consequently, the kernel of $\mlap$ is simply the stationary distribution of the natural random walk on $G$ multiplied by $\md$. Consequently, we can show that for every directed Laplacian $\mlap$ that corresponds to a strongly connected graph, there is always a vector $x\in\R_{>0}^{n}$ such that $\mlap x=0$ (See Lemma~\ref{lem:stationary-equivalence}). In other words, letting $\mx$ denote the diagonal matrix associated with $x$ the directed Laplacian $\mlap'=\mlap\mx$ satisfies $\mlap'\mx1=0$. This says that the total weight of incoming edges to a vertex is the same as the total weight of outgoing edges from that vertex, i.e., that $\mlap'$ corresponds to the Laplacian of an Eulerian graph. We call such a vector an\emph{ Eulerian scaling} of $\mlap$. Now, solving systems in an Eulerian Laplacian $\mlap$ (i.e., a Laplacian corresponding to an Eulerian graph) seems easier than solving an arbitrary directed Laplacian. In particular, we know the kernel of a $\mlap$, since it is just the all ones vector. In addition, we have that $\frac{1}{2}(\mlap+\mlap^{\top})$ is symmetric and PSD\textemdash in fact it is just the Laplacian of an undirected graph! Unfortunately, this does not immediately yield an algorithm, as it is not known how to use the ability to solve systems in such a symmetrization to solve systems in the original matrix. Ultimately, this line of reasoning leaves us with two fundamental questions: \begin{enumerate} \item Can we solve Eulerian Laplacian systems in time $o(n^{\omega},nm)?$ \item Can we use an Eulerian Laplacian system solver for more than solving Eulerian Laplacian systems? \end{enumerate} The major contribution of this paper is answering both of these questions in the affirmative. We show the following: \begin{itemize} \item We show that we can solve Eulerian Laplacian systems in time $\tilde{O}\left(nm^{3/4}+n^{2/3}m\right)$. \item We show that using Eulerian Laplacian systems we can solve broader classes of matrices we refer to as RCDD Z-matrices, and $\alpha$ RCDD Z-matrices. \item We show that using solvers for $\alpha$ RCDD Z-matrices, we can estimate an Eulerian scaling of a directed Laplacian. \item Putting these components together we achieve our desired applications. Some of these are applications are straightforward, whereas others require some significant work. \end{itemize} A serious question that arises throughout these results is the degree of precision do we need to carry out our arithmetic operations. This arrises both in using undirected Laplacian system solvers to solving Eulerian Laplacian systems, and then again in using Eulerian Laplacian system solvers to derive the rest of our results. These numerical issues are not merely technicalities\textemdash they crucially affect the algorithms we can use to solve our problem. In fact, we will see in Section~\ref{sec:eulerian_solver} that, if we disregarded the numerics and relied on frequently-quoted assertions relating the behavior of conjugate gradient to the existence of polynomials with certain properties, we would actually obtain a better running time, but that these assertions do not carry over to reasonable finite-precision setting. Given these subtleties, we discuss numerical issues throughout the paper, and in Appendix~\ref{sec:numerical_stability} we cover particular details of the stability of our algorithms and the precision they require, showing that we can achieve all our results in the standard unit cost RAM model (or any other reasonable model of computation). In the remainder of this overview we briefly comment on the key technical ingredients of each of these results. \subsubsection{Solving Eulerian Laplacian Systems} To solve a Eulerian Laplacian system $\mlap x=b$, we first precondition, multiplying both sides by $\mlap^{\top}\mU^{\dagger}$, where $\mU\defeq\frac{1}{2}(\mlap^{\top}+\mlap)$ is a Laplacian of an undirected graph corresponding to $\mlap$, and $\mU^{\dagger}$ is its Moore-Penrose pseudoinverse. This shows that it suffices to instead solve, $\mlap^{\top}\mU^{\dagger}\mlap x=\mlap^{\top}\mU^{\dagger}x$. Now using a nearly-linear-time Laplacian system solver, we can apply $\mU^{\dagger}$ to a vector efficiently. As such, we simply need to show that we can efficiently solve systems in the symmetric matrix $\mlap^{\top}\mU^{\dagger}\mlap$. Next, we show that the matrix $\mlap^{\top}\mU^{\dagger}\mlap$ is, in an appropriate sense, approximable by $\mU$. Formally we show that $\mU$ is smaller in the sense that $\mU\preceq\mlap^{\top}\mU^{\dagger}\mlap$, and that it is not too much larger in the sense that $\tr(\mU^{\dagger/2}\mlap^{\top}\mU^{\dagger}\mlap\mU^{\dagger/2})=O(n^{2})$. While the first proof is holds for a broad class of asymmetric matrices, to prove the second fact we exploit structure of Eulerian Laplacians, particularly the fact that an Eulerian graph has a decomposition into simple cycles. Unfortunately, this property doesn't immediately yield an algorithm for solving Laplacian systems. The natural approach would be to use preconditioned Krylov methods, such as the Chebyshev method or conjugate gradient. These essentially apply a polynomial of $\mU^{\dagger}\mlap^{\top}\mU^{\dagger}\mlap$ to the right hand side. Unfortunately, Chebyshev iterations only yield a $\Omega(mn)$ time algorithm with this approach. For conjugate gradient, it can be shown that the trace bound leads to $o(mn)$ time algorithm in exact arithmetic, but, unfortunately, this analysis does not appear to be numerically stable, and we do not know how to show it yields this running time in our computational model. Instead we implement an approach based on preconditioning and subsampling. We precondition with $\mlap^{\top}\mU^{\dagger}\mlap+\alpha\mU$ for a value of $\alpha$ we tune. This reduces the problem to only solving $\otilde(\sqrt{\alpha})$ linear systems in $\mlap^{\top}\mU^{\dagger}\mlap+\alpha\mU$. To solve these systems we note that we can write this equivalently as $\mlap^{\top}\mU^{\dagger}\mU\mU^{\dagger}\mlap+\alpha\mU$ and using the factorization of $\mU$ into its edges we can subsample the inner $\mU$ while preserving the matrix. Ultimately, this means we only need to solve systems in $\alpha\mU$ plus a low rank matrix which we can do efficiently using the fact that there is an explicitly formula for low rank updates (i.e. Sherman-Morrison-Woodbury Matrix Identity). Trading between the number of such systems to solve, the preprocessing to solve these systems, and the time to solve them gives us our desired running time for solving such linear systems. We show in the appendix that we can, with some care, stably implement a preconditioned Chebyshev method and low rank update formulas. This allows us to circumvent the issues in using conjugate gradient and achieve our running time in the desired computational model. \subsubsection{Solving RCDD Z-matrices} A row column diagonal dominant (RCDD) matrix is simply a matrix $\mm$ where $\mm_{ii}\geq\sum_{j\neq i}|\mm_{ij}|$ and $\mm_{ii}\geq\sum_{j\neq i}|\mm_{ji}|$ and a Z-matrix is a matrix $\mm$ where the off-diagonal entries are negative. We show how to solve such matrices by directly reducing them to solving Eulerian Laplacian systems. Given a RCDD Z-matrix $\mm$, we add an additional row and column, filling in the entries in the natural way so that the resulting matrix is an Eulerian Laplacian. We show that, from the solution to such a linear system, we can immediately glean the solution to systems in $\mm$. This reduction is analogous to the reduction from solving symmetric diagonally dominant (SDD) systems to solving undirected Laplacian systems. In the appendix we show that this method is stable. \subsubsection{Computing the Stationary} Given a RCDD Z-matrix solver we use it to compute the scaling that makes a directed Laplacian $\mlap$ Eulerian, i.e., we compute the stationary distribution. To do this, we pick an initial non-negative diagonal scaling $\mx$ and a initial non-negative diagonal matrix $\mE$ such that $(\mE+\mlap)\mx$ is $\alpha$-RCDD, that is each diagonal entry is a $1+\alpha$ larger in absolute value than the sum of the off-diagonal entries in both the corresponding row and column. We then iteratively decrease $\mE$ and update $\mx$ while maintaining that the matrix is $\alpha$-RCDD. The key to this reduction is the fact that there is a natural way to perform a rank 1 update of $(\mE+\mlap)\mx$ to obtain an Eulerian Laplacian, and that the stationary distribution of this Laplacian can be obtained by solving a single system in $(\mE+\mlap)\mx$. Ultimately, this method yields a sequence of stationary distributions that, when multiplied together entrywise, yield a good approximate stationary distribution for $\mlap$. For a more detailed over this approach and this intuition underlying it, see Section~\ref{sec:computing_stationary:approach}. \subsubsection{Additional Applications} Our algorithms for computing personalized page rank vectors, solving linear systems in arbitrary RCDD matrices, and solving directed Laplacian linear systems are all proven in a similar fashion. We obtain an approximate stationary distribution, rescale the system to make it strictly RCDD, then solve it\textemdash all using algorithms from the previous sections in a black box fashion. Therefore, the running times for these applications\textemdash and in fact all our applications\textemdash depend solely (up to polylogarithmic factors) on the black-box costs of computing the stationary distribution and solving RCDD matrices. However, our algorithms must determine how much accuracy to request when they invoke these two black-box routines. For computing personalized PageRank, one can determine the accuracy to request based solely on the restart probability. However, for our other applications, the accuracy our algorithms request has a dependence on the condition number $\kappa(\mlap)$ of $\mlap$ and the ratio $\kappa(\ms^{*})$ of max over min stationary probability. In order to get an unconditional running time\textemdash and out of intrinsic interest\textendash -we show how to efficiently compute reasonable upper bounds on these quantities. We use an approach motivated by the close relationship of $\kappa(\mlap)$ and mixing time. Specifically, we formulate a notion of personalized PageRank mixing time, then get a polynomially good estimate of this quantity using our ability to solve personalized PageRank. Finally, we show that $\kappa(\mlap)$ and personalized pagerank mixing time are equivalent up to factors that are good enough\footnote{They are equivalent up to factors polynomial in $n$ and themselves. Since these quantities appear only in logs in our runtimes and these logs already have factors of $n$ in them, this polynomial equivalence only changes runtimes by a constant factor compared to if we had exact estimates. A similar relationship also holds between $\kappa(\mlap)$ and the mixing time of lazy random walks on the graph. (See Section \ref{sec:application_quantities} for details.)} for our purposes. With a reasonable bound on $\kappa(\mlap)$, we are then able to choose a restart probability that is small enough in order to guarantee that personalized solving PageRank gives a good approximation of the stationary distribution. Our algorithms for computing hitting times, escape probabilities, and all pairs commute times all start by taking a natural definition for the quantity of interest and massaging it into an explicit formula that has an $\mlap^{\dagger}$ in it. Then, they use various methods to approximately evaluate the formula. In the case of hitting times, we simply plug everything into the formula and invoke our approximate solver for $\mlap^{\dagger}$ with appropriately small error. Escape probabilities are handled similarly, except that there are also two unknown parameters which we show we can estimate to reasonable accuracy and plug in. Perhaps the most sophisticated application is computing all pairs commute times. We show that the commute time from $u$ to $v$ is given by the simple formula $(\vec{1}_{u}-\vec{1}_{v})^{\intercal}(\mlap_{b}^{\top}\mU_{b}^{\dagger}\mlap_{b})^{\dagger}(\vec{1}_{u}-\vec{1}_{v})$ where $\mlap_{b}$ is the matrix obtained by performing the diagonal rescaling of $\mlap$ that turns its diagonal into the stationary distribution, which also makes the graph Eulerian. An interesting feature of this formula is that it involves applying the pseudo-inverse of a matrix of the very same form as the preconditioned system $\mlap^{\top}\mU^{\dagger}\mlap$ that our Eulerian Laplacian solver uses. Another interesting feature is that when $\mlap$ is symmetric, this formula simplifies to $(\vec{1}_{u}-\vec{1}_{v})^{\intercal}\mU_{b}^{\dagger}(\vec{1}_{u}-\vec{1}_{v})=2m\cdot(\vec{1}_{u}-\vec{1}_{v})^{\intercal}\mU^{\dagger}(\vec{1}_{u}-\vec{1}_{v})$. Thus, it is a generalization of the well-known characterization of commute times in terms of effective resistance from undirected graphs. In undirected graphs, all pairs commute times can be computed efficiently via Johnson-Lindenstrauss sketching \cite{SpielmanS08}. We show that a similar approach extends to directed Laplacians as well. While the general approach is similar, the error analysis is complicated by the fact that we only have access to an approximate stationary distribution. If this were used naively, one would have to deal with an approximate version of $\mlap_{b}$ that, importantly, is only approximately Eulerian. We bypass this issue by showing how to construct an Eulerian graph whose stationary is exactly known and whose commute times approximate the commute times of the original graph. This may be of independent interest. The fact that a matrix of the form $\mlap^{\top}\mU^{\dagger}\mlap$ comes up both in solving Eulerian Laplacians and in sketching commute times indicates that it is an even more natural object than it might appear at first. \subsection{Paper Organization} The rest of our paper is organized as follows: \begin{itemize} \item \textbf{Section~\ref{sec:prelim}} - we cover preliminary information \item \textbf{Section~\ref{sec:computing_stationary}} - we show how to compute the stationary distribution \item \textbf{Section~\ref{sec:eulerian_solver}} - we provide our fast Eulerian Laplacian system solver \item \textbf{Section~\ref{sec:solving_strictly_rcdd}} - we reduce strict RCDD linear systems to solving Eulerian systems \item \textbf{Section}~\ref{sec:application_quantities} - we provide condition number quantities for applications and prove equivalences \item \textbf{Section~\ref{sec:applications}} - we provide our applications \item \textbf{Appendix~\ref{sec:numerical_stability}} - we discuss numerical stability of our solvers \item \textbf{Appendix~\ref{sec:matrix_facts}} - we provide facts about matrices we use throughout \item \textbf{Appendix~}\ref{sec:Deriving-the-Identities} - we derive identities for hitting times, commute times, and escape probabilities \end{itemize} \section{Preliminaries \label{sec:prelim}} In this section we introduce notation and provide basic machinery we use throughout this paper. \subsection{Notation \label{sec:prelim:notation}} \textbf{Matrices: }We use bold to denote matrices and let $\mI_{n},\mzero_{n}\in\R^{n\times n}$ denote the identity matrix and zero matrix respectively. For symmetric matrices $\ma,\mb\in\R^{n\times n}$ we use $\ma\preceq\mb$ to denote the condition that $x^{\top}\ma x\leq x^{\top}\mb x$ and we define $\succeq$, $\prec$, and $\succ$ analogously. We call a symmetric matrix $\ma\in\R^{n\times n}$ positive semidefinite if $\ma\succeq\mzero_{n}$ and we let $\norm x_{\ma}\defeq\sqrt{x^{\top}\ma x}$. For any norm $\norm{\cdot}$ define on vectors in $\R^{n}$ we define the \emph{operator norm} it induces on $\R^{n\times n}$ by $\norm{\ma}=\max_{x\neq0}\frac{\norm{\ma x}}{\norm x}$ for all $\ma\in\R^{n\times n}$.\\ \\ \textbf{Diagonals}: For $x\in\R^{n}$ we let $\mdiag(x)\in\R^{n\times n}$ denote the diagonal matrix with $\mdiag(x)_{ii}=x_{i}$ and when it is clear from context we more simply write $\mx\defeq\mdiag(x)$. For $\ma\in\R^{n\times n}$ we let $\diag(\ma)$ denote the vector corresponding to the diagonal of $\ma$ and we let $\mdiag(\ma)\defeq\mdiag(\diag(\ma))$, i.e. $\ma$ with the off-diagonal set to $0$.\\ \\ \textbf{Vectors}: We let $\vec{0}_{n},\vec{1}_{n}\in\R^{n}$ denote the all zeros and ones vectors respectively. We use $\vec{1}_{i}\in\R^{n}$ to denote the indicator vector for coordinate $i\in[n]$, i.e. $[\vec{1_{i}}]_{j}=0$ for $j\neq i$ and $[\vec{1}_{i}]_{i}=1$. Occasionally we apply scalar operations to vectors with the interpretation that they should be applied coordinate-wise, e.g. for $x,y\in\R^{n}$ we let $\max\{x,y\}$ denote the vector $z\in\R^{n}$ with $z_{i}=\max\{x_{i},y_{i}\}$ and we use $x\geq y$ to denote the condition that $x_{i}\geq y_{i}$ for all $i\in[n]$.\\ \\ \textbf{Condition Numbers}: Given a invertible matrix $\ma\in\R^{n\times n}$ we let $\kappa(\ma)\defeq\norm{\ma}_{2}\cdot\norm{\ma^{\dagger}}_{2}$ denote the condition number of $\ma$. Note that if $\mx\in\R^{n\times n}$ is a nonzero diagonal matrix then $\kappa(\mx)=\frac{\max_{i\in[n]}|\mx_{ii}|}{\min_{i\in[n]}|\mx_{ii}|}$.\\ \\ \textbf{Sets}: We let $[n]\defeq\{1,...,n\}$ and $\simplex^{n}\defeq\{x\in\R_{\geq0}^{n}\,|\,\vec{1}_{n}^{\top}x=1\}$, i.e. the $n$-dimensional simplex. \subsection{Matrix Classes \label{sec:prelim:matrices}} \textbf{Diagonal Dominance: }We call a possibly asymmetric matrix $\ma\in\R^{n\times n}$ \emph{$\alpha$-row diagonally dominant (RDD) }if $\ma_{ii}\geq(1+\alpha)\sum_{j\neq i}|\ma_{ij}|$ for all $i\in[n]$, \emph{$\alpha$-column diagonally dominant (CDD) }if $\ma_{ii}\geq(1+\alpha)\sum_{j\neq i}\left|\ma_{ji}\right|$, and \emph{$\alpha$-RCDD} if it is both $\alpha$-RDD and $\alpha$-CDD. For brevity, we call $\ma$ RCDD if it is $0$-RCDD and strictly RCDD if it is $\alpha$-RCDD for $\alpha>0$.\\ \\ \textbf{Z-matrix}: A matrix $\mm\in\R^{n\times n}$ is called a Z-matrix if $\mm_{ij}\leq0$ for all $i\neq j$, i.e. every off-diagonal entry is non-positive.\\ \\ \textbf{Directed Laplacian}: A matrix $\mlap\in\R^{n\times n}$ is called a \emph{directed Laplacian }if it a Z-matrix with $\vec{1}_{n}^{\top}\mlap=\vec{0}_{n}$, that is $\mlap_{ij}\leq0$ for all $i\neq j$ and $\mlap_{ii}=-\sum_{j\neq i}\mlap_{ji}$ for all $i$. To every directed Laplacian $\mlap$ we associate a graph $G_{\mlap}=(V,E,w)$ with vertices $V=[n]$ and an edge $(i,j)$ of weight $w_{ij}=-\mlap_{ji}$ for all $i\neq j\in[n]$ with $\mlap_{ji}\neq0$. Occasionally we write $\mlap=\md-\ma^{\top}$ to denote that we decompose $\mlap$ into the diagonal matrix $\md$ where $\md_{ii}=\mlap_{ii}$ is the out degree of vertex $i$ in $G_{\mlap}$ and $\ma$ is weighted adjacency matrix of $G_{\mlap}$ with $\ma_{ij}=w_{ij}$ if $(i,j)\in E$ and $\ma_{ij}=0$ otherwise. We call $\mw=\ma^{\top}\md^{-1}$ the random walk matrix associated with $G_{\mlap}$. We call $\mlap$ Eulerian if additionally $\mlap\vec{1}_{n}=\vec{0}_{n}$ as in this case the \emph{associated graph }$G_{\mlap}$ is Eulerian.\\ \\ \textbf{(Symmetric) Laplacian}: A matrix $\mU\in\R^{n\times n}$ is called a \emph{Symmetric Laplacian }or just a \emph{Laplacian} if it is symmetric and a Laplacian. This coincides with the standard definition of Laplacian and in this case note that the associated graph $G_{\mU}=(V,E,w)$ is symmetric. For a Laplacian we also associate a matrix $\mb\in\R^{E\times V}$ known as the weighted incidence matrix. Each row $b^{(i)}$ of $\mb$ corresponds to an edge $\{j,k\}\in E$ and for a canonical orientation ordering of $\{j,k\}$ we have $b_{j}^{(i)}=\sqrt{w_{\{j,k\}}}$, $b_{k}^{(i)}=-\sqrt{w_{\{j,k\}}}$, and $b_{l}^{(i)}=0$ if $l\notin\{j,k\}$. Note that $\mU=\mb^{\top}\mb$ and thus $\mlap$ is always PSD.\\ \\ \textbf{Random Walk Matrix}: A matrix $\mw\in\R^{n\times n}$ is called a \emph{random walk matrix }if $\mw_{ij}\geq0$ for all $i,j\in[n]$ and $\vec{1}_{n}^{\top}\mw=\vec{1}_{n}$. To every random walk matrix $\mw$ we associated a directed graph $G_{\mw}=(V,E,w)$ with vertices $V=[n]$ and an edge from $i$ to $j$ of weight $w_{ij}=\mw_{ij}$ for all $i,j\in[n]$ with $\mw_{ij}\neq0$. Note if we say that $\mlap=\mI-\mw$ is a directed Laplacian, then $\mw$ is a random walk matrix and the directed graphs associated with $\mlap$ and $\mw$ are identical.\\ \\ \textbf{Lazy Random Walk Matrix: }Given a random walk matrix $\mw\in\R^{n\times n}$ the $\alpha$-lazy random walk matrix associated with $\mw$ for $\alpha\in[0,1]$ is given by $\alpha\mI+(1-\alpha)\mw$. When $\alpha=\frac{1}{2}$ we call this a lazy random walk matrix for short and typically denote it $\lazywalk$.\\ \\ \textbf{Personalized PageRank Matrix}: Given a random walk matrix $\mw\in\R^{n\times n}$ the personalized PageRank matrix with restart probability $\beta\in[0,1]$ is given by $\mm_{pp(\beta)}=\beta(\mI-(1-\beta)\mw)^{-1}$. Given any probability vector $p\in\simplex^{n}$ the personalized PageRank vector with restart probability $\beta$ and vector $p$ is the vector $x$ which satisfies $\beta p+(1-\beta)\mw x=x$. Rearranging terms we see that $x=\mm_{\beta}p$ hence justifying our naming of $\mm_{pp(\beta)}$ as the personalized PageRank matrix. \subsection{Directed Laplacians of Strongly Connected Graphs \label{sec:prelim:stationary}} Here we give properties of a directed Laplacian, $\mlap\in\R^{n\times n}$, whose associated graph, $G_{\mlap}$, is strongly connected that we use throughout the paper. Formally, we provide Lemma~\ref{lem:stationary-equivalence} which shows that $\mlap$ always has a positive Eulerian scaling, that is a $x\in\R_{>0}$ with $\mlap\mx$ Eulerian, and that this is given by the stationary distribution of the associated random walk matrix. Using this we completely characterize the kernel of $\mlap$ and $\mlap^{\top}$. \begin{lem} \label{lem:stationary-equivalence} For directed Laplacian $\mlap=\md-\ma^{\top}\in\R^{n\times n}$ whose associated graph is strongly connected there exists a positive vector $s\in\R_{>0}^{n}$ (unique up to scaling) such that the following equivalent conditions hold. \begin{itemize} \item $\mw s=s$ for the random walk matrix $\mw=\ma^{\top}\md^{-1}$ associated with $\mlap$. \item $\mlap\md^{-1}s=0$ \item $\mlap\md^{-1}\ms$ for $\ms=\mdiag(s)$ is an Eulerian Laplacian. \end{itemize} If we scale $s$ so that $\norm s_{1}=1$ then we call $s$ the stationary distribution associated with the random walk on the associated graph $G_{\mlap}$. We call any vector $x\in\R_{>0}^{n}$ such that $\mlap\mx$ is an Eulerian Laplacian an eulerian scaling for $\mlap$. Furthermore, $\ker(\mlap)=\mathrm{span}(\md^{-1}s)$ and $\ker(\mlap^{\top})=\mathrm{span}(\vec{1}_{n})$. \end{lem} \begin{proof} Since the graph associated with $\mlap$ is strongly connected we have that for any $\alpha>0$ note that $\alpha\mI+\mw$ is positive irreducible and aperiodic with all columns having $\ellOne$ norm of $1+\alpha$. Therefore, by the Perron-Frobenius Theorem we know and therefore therefore there exists a positive vector $s\in\R_{>0}^{n}$ unique up to scaling such that that $(\alpha\mI+\mw)s=(\alpha+1)s$ or equivalently $\mw s=s$. Therefore, by definition $\ma^{\top}\md^{-1}s=s$ and $\mlap\md^{-1}s=(\md-\ma^{\top})\md^{-1}s=0$. Furthermore this implies that for $\mlap'$=$\mlap$$\md^{-1}\ms$ we have $\mlap'\vec{1}_{n}=\vec{0}_{n}$ and as $\mlap$ is Z-matrix so is $\mlap'$ and therefore $\mlap'$ is a Z-matrix. Furthermore clearly $\mlap^{\top}\md^{-1}\ms$ being a Eulerian Laplacian implies $\mw s=s$ and therefore we see that the conditions are all equivalent. Lastly, we know that $\frac{1}{2}(\mlap'+[\mlap']^{\top})$ is a symmetric Laplacian associated with an connected graph. Therefore it is PSD having only $\vec{1}_{n}$ in there kernel yielding our characterization of the kernel of $\mlap$ and $\mlap^{\top}$. \end{proof} Note that Lemma~\ref{lem:stationary-equivalence} immediately implies that any random walk matrix $\mw$ associated with a strongly connected graph has a unique stationary distribution $s$, i.e. $s\in\simplex^{n}$ and $\mw s=s$. Furthermore, we see that all $\alpha$-lazy random walks for $\alpha\in[0,1)$ associated with $\mw$ have the same stationary distribution. \section{Solving Strictly RCDD Systems \label{sec:solving_strictly_rcdd}} Here we show how to reduce solving strictly RCDD systems using an Eulerian Laplacian solver. First we provide an prove Theorem~\ref{thm:basic-rcdd} which achieves precisely this goal by using the Eulerian Laplacian system solver presented in Section~\ref{sec:solving_strictly_rcdd}. Then we provide Corollary~\ref{cor:alpha-rcdd-solver} which specializes this result to the case of solving $\alpha$-RCDD systems. We make extensive use of this corollary to compute the the Eulerian scaling of a directed Laplacian in Section~\ref{sec:computing_stationary}. \begin{thm} \label{thm:basic-rcdd} Let $\ma\in\R^{n\times n}$ be a strictly RCDD $Z$-matrix, let $b\in\R^{n}$, let $x$ be the solution to $\ma x=b$, and let $0<\epsilon\leq\frac{1}{2}$. Then in $O(\tsolve\log(1/\epsilon))$ time we can compute a vector $x'$ that satisfies $\|x'-x\|_{\frac{1}{2}(\ma+\ma^{\top})}\leq\epsilon\|b\|_{(\frac{1}{2}(\ma+\ma^{\top}))^{-1}}$ with high probability. \end{thm} \begin{proof} Define the $(n+1)\times n$ matrix $\mc=$$\begin{pmatrix}\mI_{n}\\ -\vones_{n}^{\top} \end{pmatrix}$. Now define a $(n+1)\times(n+1)$ matrix $\mlap=\mc\ma\mc^{\top}$. The top left $n\times n$ entries of $\mlap$ are a copy of $\ma$, and its rows and columns sum to 0 since the columns of $\mc$ sum to 0. Since $\ma$ is a diagonally dominant Z-matrix, the new off-diagonal entries are negative and the new diagonal entry is then positive. Thus $\mlap$ is a Z-matrix for which all rows and columns sum to to 0, so it is an Eulerian Laplacian. Now, if $\ma x=b$, we must have $\mlap\begin{pmatrix}x\\ 0 \end{pmatrix}=\begin{pmatrix}b\\ y \end{pmatrix}$ for some scalar $y$, since the upper left block is $\ma$. Furthermore, this must satisfy $\vones_{n}^{\top}b+y=0$, since the image of a Laplacian is orthogonal to the all-ones vector. Consequently, $\begin{pmatrix}b\\ y \end{pmatrix}=\mc x$. Now, for a connected Eulerian Laplacian, the null space is precisely the all-ones vector. Furthermore, $\mlap$ is clearly connected as the $n+1$ row must be non-zero by the fact that $\ma$ is strictly RCDD. Consequently, any solution to $\mlap z=\begin{pmatrix}b\\ y \end{pmatrix}$ must be off by only by a shift of the all-ones vector from $\begin{pmatrix}x\\ 0 \end{pmatrix}$. In particular, this implies that $x=\mc^{\top}\mlap^{\dagger}\mc b$ since the $\mc^{\top}$ adds the shift of the all-ones vector to zero out the auxiliary variable. This means that $\ma^{-1}=\mc^{\top}\mlap^{\dagger}\mc$, and by the same argument, $(\frac{1}{2}(\ma+\ma^{\top}))^{-1}=\mc^{\top}(\frac{1}{2}(\mlap+\mlap^{\top}))^{\dagger}\mc=\mc^{\top}\mU^{\dagger}\mc$. This effectively reduces solving RCDD systems to solving Eulerian Laplacian systems. Specifically, we obtain $x'$ by calling Theorem~\ref{thm:euleriansolver} on $\mc b$ with $\mlap$ and $\epsilon$ to get a vector $z'$ (with $z$ referring to $\mlap^{\dagger}\mc b$), then returning $\mc^{\top}z'$. The desired error follows from \begin{align*} \|x'-x\|_{\frac{1}{2}(\ma+\ma^{\top})} & =\|\mc^{\top}(z'-z)\|_{\frac{1}{2}(\ma+\ma^{\top})}=\|z'-z\|_{\frac{1}{2}\mc(\ma+\ma^{\top})\mc^{\top}}=\|z'-z\|_{\mU}\\ & \leq\epsilon\|\mc b\|_{\mU^{\dagger}}=\epsilon\|b\|_{\mc^{\top}\mU^{\dagger}\mc}=\epsilon\|b\|_{(\frac{1}{2}(\ma+\ma^{\top}))^{-1}}. \end{align*} \end{proof} \begin{cor} \label{cor:alpha-rcdd-solver} Let $\ma\in\R^{n\times n}$ be a $\alpha$-RCDD $Z$-matrix, let $\md$ represent the matrix with $\md_{ij}=0$ for $i\neq j$ and $\md_{ii}=\frac{A_{ii}}{1+\alpha}$, let $x$ be the solution to $\ma x=b$ for $b\in\R^{n},$ and let $0<\epsilon\leq\frac{1}{2}$. Then in $O(\tsolve\log(1/\epsilon))$ time we can compute a vector $x'$ satisfying $\|x'-x\|_{\md}\leq\frac{\epsilon}{\alpha}\|b\|_{\md^{-1}}$ with high probability. \end{cor} \begin{proof} We apply Theorem~\ref{thm:basic-rcdd} to our input. We can express $\frac{1}{2}(\ma+\ma^{\top})$ as $\alpha\md+\mm$, where $\mm$ is a symmetric diagonally dominant, and thus positive definite, matrix. In other words we have \[ \frac{1}{2}(\ma+\ma^{\top})\succeq\alpha\md \] meaning that the $\frac{1}{2}(\ma+\ma^{\top})$ norm dominates the $\alpha\md$ norm while the $(\frac{1}{2}(\ma+\ma^{\top}))^{-1}$ norm is dominated by the $\alpha^{-1}\md^{-1}$ norm. Thus we have \begin{align*} \|x'-x\|_{\md} & =\alpha^{-\frac{1}{2}}\|x'-x\|_{\alpha\md}\leq\alpha^{-\frac{1}{2}}\|x'-x\|_{\frac{1}{2}(\ma+\ma^{\top})}\leq\alpha^{-\frac{1}{2}}\epsilon\|b\|_{(\frac{1}{2}(\ma+\ma^{\top}))^{-1}}\\ & \leq\alpha^{-\frac{1}{2}}\epsilon\|b\|_{\alpha^{-1}\md^{-1}}=\frac{\epsilon}{\alpha}\|b\|_{\md^{-1}}. \end{align*} \end{proof} \section{Computing the Stationary Distribution \label{sec:computing_stationary}} Here we show to compute the stationary distribution given an $\alpha$-RCDD Z-matrix linear system solver. Throughout this section, we let $\mlap=\md-\ma^{\top}\in\R^{n\times n}$ denote a directed Laplacian and our primary goal in this section is to compute an approximate stationary vector $s\in\R_{>0}^{V}$ such that $\mlap\md^{-1}\ms$ is approximately Eulerian. The main result of this section is the following: \begin{thm}[Stationary Computation Using a RCDD Solver] \label{thm:stat-from-dd} Given $\alpha\in(0,\frac{1}{2})$ and $\mlap\in\R^{n\times n}$, a directed Laplacian with $m$ nonzero-entries, in time $O((m+\runtime)\cdot\log\alpha^{-1})$ Algorithm~\ref{alg:stationary_computation} computes an approximate stationary distribution $s\in\simplex^{n}$ such that $(3\alpha n\cdot\md+\mlap)\md^{-1}\ms$ is $\alpha$-RCDD where $\md=\mdiag(\mlap)$, $\ms=\mdiag(s)$, and $\runtime$ is the cost of computing an $\epsilon$-approximate solution to a $n\times n$ $\alpha$-RCDD Z-matrix linear system with $m$-nonzero entries, i.e. computing $x$ such that $\norm{x-\mm^{-1}b}_{\mdiag(\mm)}\leq\frac{\epsilon}{\alpha}\norm b_{\mdiag(\mm)^{-1}}$ for $\alpha$-RCDD Z-matrix $\mm\in\R^{n\times n}$ with $O(m)$ non-zero entries, $\epsilon=O(\poly(n/\alpha))$. Furthermore, $\kappa(\ms)\leq\frac{20}{\alpha^{2}}n$, where $\kappa(\ms)$ is the ratio between the largest and smallest elements of $s$, and the diagonals of all intermediate RCDD systems also have condition number \textup{$O(\poly(n/\alpha))$}. \end{thm} The remainder of this section is divided as follows: \begin{itemize} \item \textbf{Section~\ref{sec:computing_stationary:approach}}: we provide an overview of our approach to computing the stationary distribution \item \textbf{Section~\ref{sec:computing_stationary:algorithm}}: we provide the details of our algorithm \item \textbf{Section~\ref{sec:computing_stationary:analysis}}:\textbf{ }we analyze this algorithm proving Theorem~\ref{thm:stat-from-dd}. \end{itemize} \subsection{The Approach\label{sec:computing_stationary:approach}} Our approach to computing the stationary distribution is broadly related to the work of Daitch and Spielman \cite{DaitchS08} for computing the diagonal scaling makes a symmetric $M$-matrix diagonally dominant. However, the final rescaling that we're trying to calculate is given by the uniqueness of the stationary distribution, which in turn follows from the Perron-Frobenius theorem. The fact that we're rescaling and computing on the same objective leads a more direct iterative process. As in \cite{DaitchS08} we use an iterative that brings a matrix increasingly close to being RCDD. However, Our convergence process is through potential functions instead of through combinatorial entry count; instead of making parts of $\mlap$ RCDD incrementally we instead start with a relaxation of $\mlap$ that is RCDD and iteratively bring this matrix closer to $\mlap$ while maintaining that it is RCDD. We remark that this scheme can also be adapted to find rescalings of symmetric M-matrices. Our algorithm hinges on two key insights. The first is that if we have positive vectors $e,x\in\R_{>0}^{n}$ so that $\mm\defeq(\mE+\mlap)\mx$ is $\alpha$-RCDD, then for any vector $g\in\R_{>0}^{n}$ with $\norm g_{1}=1$ we can compute the stationary distribution of the directed Laplacian $\mlap'=\mE-ge^{\top}+\mlap$ by solving a single linear system in $\mm$. Note that $\mm$ is clearly invertible (Lemma~\ref{lem:invertible_B}) whereas $\mlap'$ has a kernel (Lemma~\ref{lem:stationary-equivalence}). Furthermore, $\mlap'\mx$ is simply a rank-1 update of $\mm$ and consequently there kernel $\mlap'$ has a closed form, namely $\mx\mlap^{-1}f$ (Lemma~\ref{lem:ker_under_update}). Since the stationary distribution of $\mlap'$ is given by its kernel (Lemma~\ref{lem:stationary-equivalence}) we obtain the result. This first insight implies that if we have a RCDD Z-matrix we can compute the stationary of a related matrix, however a priori it is unclear how this allows to compute the stationary of $\mlap$. The second insight is that if we compute the stationary of $\mlap'$, e.g. we compute some $y\in\R_{>0}^{n}$ such that $\mlap'\my$ is an Eulerian Laplacian, then $(\mE+\mlap)\my$ is strictly RCDD. Since $\mlap'\my$ is Eulerian, $(\mE-\mlap-\mlap')\my=ge^{\top}\my$ is an all positive matrix which is entrywise less than $\mlap'$ in absolute value. In other words, removing $ge^{\top}\my$ from $\mlap'\my$ strictly decreases the absolute value of the off diagonal entries and increases the value of the diagonal entries causing $(\mE+\mlap)\my$ to be strictly RCDD. Consequently, given $y$ we can hope to decrease $e$ to achieve $e'$ to obtain an $\alpha$-RCDD Z-matrix $\mm'=(\mE'+\mlap)\my$ where $e'\leq e$. Combining these insights naturally yields our algorithm. We compute an initial$\alpha$-RCDD Z-matrix $\mm=(\mE+\mlap)\mx$ and compute $x'=\mx\mm^{-1}g$ for $g\in\R_{>0}^{n}$ with $\norm g_{1}=1$ so that $\mlap'=(\mE-ge^{\top}+\mlap)\mx'$ is Eulerian. We then compute the smallest $e'\in\R_{>0}^{n}$ so that $(\mE'+\mlap)\mx'$ is again $\alpha$-RCDD and repeat. What remains to show is that for proper choice of initial $x$ and $e$ as well as proper choice of $g$ in each iteration, this algorithm converges quickly provided we use a sufficiently accurate RCDD linear system solver. The only missing ingredient for such analysis, is how to measure progress of the algorithm. Note that $(\mE+\mlap)\mx$ is $\alpha$-CDD if and only if $e\geq\alpha d$ (Lemma~\ref{lem:column-alphadd-condtions}) and consequently the smallest $\alpha d$ is the smallest value of $e$ we can hope for to keep $(\mE+\mlap)\mx$ $\alpha$-RCDD. We show the each iteration of the procedure outlined above brings $e$ rapidly closer to $\alpha$d. In particular we show that in each iteration we can ensure that $\norm{\md^{-1}(e-\alpha d)}_{1}$ decreases by a multiplicative constant up to a small additive factor depending only on $\alpha$ (Lemma~\ref{lem:e-progress}). Putting this all together we achieve an algorithm (See Section~\ref{sec:computing_stationary:algorithm}) that in $O(\ln(\frac{1}{\alpha}))$ iterations finds the desired $x,e$. \subsection{The Algorithm\label{sec:computing_stationary:algorithm}} Following the approach outlined in the previous section, our iterative algorithm for computing the stationary is given by Algorithm~\ref{alg:stationary_computation}. First, we compute positive vectors $e^{(0)},x^{(0)}\in\R_{>0}^{V}$ such that and $\mm^{(0)}\defeq(\mE^{(0)}+\mlap)\mx^{(0)}$ is $\alpha$-DD. In particular, we let $x^{(0)}\defeq\md^{-1}1$ and we let $e^{(0)}\in\R_{\geq0}^{V}$ be the entry-wise minimal non-negative vector such that $\mm^{(0)}$ is $\alpha$-RCDD. This choice of $x^{(0)}$ allows us to reason about the size of $e^{(0)}$ easily (See Lemma~\ref{lem:bound-on-e0}). \begin{algorithm2e} \caption{Stationary Computation Algorithm}\label{alg:stationary_computation} \SetAlgoLined \textbf{Input: }Directed Laplacian $\mlap\in\R^{n\times n}$ with diagonal $d\defeq\mdiag(\mlap)$ \textbf{Input: }Restart parameter $\alpha\in[0,\frac{1}{2}]$ Set $x^{(0)}:=\md^{-1}1$ Set $e^{(0)}\in\R^{V}$ to the entry-wise minimal with $\mm^{(0)}\defeq(\mE^{(0)}+\mlap)\mx^{(0)}$ $\alpha$-RCDD \For{$t=0$ to $k=3\ln\alpha^{-1}$}{ Set $g^{(t)}=\frac{1}{\norm{\md^{-1}e^{(t)}}_{1}}\md^{-1}e^{(t)}$ and let $\mlap^{(t)}\defeq\mE^{(t)}-g^{(t)}(e^{(t)})^{\top}+\mlap$ Let $z_{*}^{(t+1)}=[\mm^{(t)}]^{-1}g^{(t)}$, let $x_{*}^{(t+1)}=\mx^{(t)}[\mm^{(t)}]^{-1}g^{(t)}$, and let $\epsilon=O(\poly(\frac{\alpha}{n}))$ Compute $z^{(t+1)}\approx z_{*}^{(t+1)}$ such that $\norm{z^{(t+1)}-z_{*}^{(t+1)}}_{\mdiag(\mm^{(t)})}\leq\frac{\epsilon}{\alpha}\norm{g^{(t)}}_{\mdiag(\mm^{(t)})^{-1}}$ Compute $x^{(t+1)}\approx x_{*}^{(t+1)}$ such that $\norm{\md(x^{(t+1)}-\mx^{(t)}z^{(t+1)})}_{\infty}\leq\epsilon$ Set $e^{(t+1)}\in\R^{n}$ to be entry-wise minimal with $\mm^{(t+1)}\defeq(\mE^{(t+1)}+\mlap)\mx^{(t+1)}$ $\alpha$-RCDD } \textbf{Output}: Approximate stationary $s=\frac{\md x^{(k+1)}}{\norm{\md x^{(k+1)}}_{1}}$ such that $\left(3\alpha n\cdot\md+\mlap\right)\md^{-1}\ms$ is $\alpha$-RCDD \end{algorithm2e} Next, we iterate, computing $e^{(t)},x^{(t)}\in\R_{\geq0}^{V}$ such that $\mm^{(t)}=(\mE^{(t)}+\mlap)\mx^{(t)}$ is $\alpha$-RCDD. We pick the $g^{(t)}$ discussed in the previous section to be $g^{(t)}=\norm{\md^{-1}e^{(t)}}_{1}^{-1}\md^{-1}e^{(t)}$ as this naturally corresponds to the relative amount of each $e^{(t)}$ we want to remove. We then let $x^{(t+1)}\approx\mx^{(t)}[\mm^{(t)}]^{-1}g^{(t)}$ so that $\mlap^{(t)}\defeq\mE^{(t)}-g^{(t)}[e^{(t)}]^{\top}+\mlap$ is a directed Laplacian where $\mlap^{(t+1)}\mx^{(t+1)}$ is nearly Eulerian. We let $e^{(t+1)}\in\R_{\geq0}^{V}$ be the entry-wise minimal vector such that $\mm^{(t+1)}$ is $\alpha$-RCDD and then we repeat. Outputting the final $x^{(t)}$ computed completes the result. To complete the specification of the algorithm all that remains is discuss the precision with which we need to carry out the operations of the algorithm. There are two places in particular where we might worry that error in inexact arithmetic could hinder the progress of the algorithm. The first is the degree of precision to which we solve the linear system in $\mm^{(t)}$, i.e. compute $z_{*}^{(t+1)}\defeq[\mm^{(t)}]^{-1}g^{(t)}$. We show that computing instead an approximate $z^{(t+1)}$ such that $\norm{z^{(t+1)}-z_{*}}_{\mdiag(\mm^{(t)})}\leq\frac{\epsilon}{\alpha}\norm{g^{(t+1)}}_{\mdiag(\mm^{(t)})^{-1}}$ for $\epsilon=O(\poly(\frac{\alpha}{n}))$ suffices. The second is in computing $x^{(t+1)}=\mx^{(t)}z^{(t+1)}$. Unrolling the iterations of the algorithm we see that $x^{(t+1)}$ is the entry-wise product of all previous vectors $[\mm^{(t')}]^{-1}g^{(t')}$ with $t'\leq t$. Consequently, one might worry that since that errors could accumulate. We show that computing a bounded precision $x^{(t+1)}$ such that $\norm{\md(x^{(t+1)}-\mx^{(t)}z^{(t+1)})}_{\infty}\leq\epsilon$ for $\epsilon=O(\poly(\frac{\alpha}{n}))$ suffices. \subsection{The Analysis \label{sec:computing_stationary:analysis}} Here we prove Theorem~\ref{thm:stat-from-dd} by showing the correctness of our algorithm for computing the stationary distribution, Algorithm~\ref{alg:stationary_computation}. We split our proof into multiple parts: \begin{itemize} \item \textbf{Section~\ref{sec:computing_stationary:analysis:prop_x}}: we show that $x_{*}^{(t+1)}$ is indeed a positive vector that makes $\mlap^{(t)}\mx_{*}^{(t+1)}$ Eulerian \item \textbf{Section~\ref{sec:computing_stationary:analysis:prop_e}}: we provide bounds on $e^{(t)}$ \item \textbf{Section~\ref{sec:computing_stationary:analysis:progress:e}}: we show how much $\norm{\md^{-1}(e^{(t)}-\alpha d)}_{1}$ decreases between iterations \item \textbf{Section~\ref{sec:computing_stationary:analysis:linear_system_accuracy}}: we bound the error induced by solving linear systems approximately \item \textbf{Section~\ref{sec:computing_stationary:analysis:progress:e}}: we put everything together to prove Theorem~\ref{thm:stat-from-dd}. \end{itemize} Note that much of the analysis is done in slightly greater generality then required. In particular, much of our analysis works so long as $\alpha\geq0$ however we constrain $\alpha\in(0,\frac{1}{2})$ so we can easily reason about the stability of the procedure, measure of the quality of the output stationary distribution, and simplify our analysis. Also note that minimal effort was taken to control the actual value of $\epsilon$ beyond to simplify the proof that $\epsilon=O(\poly(\frac{\alpha}{n}))$ suffices. \subsubsection{Properties of $x$ \label{sec:computing_stationary:analysis:prop_x}} Here we prove that $x_{*}^{(t+1)}$ is indeed a positive vector such that $\mlap^{(t)}\mx_{*}^{(t+1)}$ is Eulerian. First we provide two general lemmas about the kernel of a matrix after a rank one update, Lemma~\ref{lem:ker_under_update}, and the invertibility of $\alpha$-DD matrices Lemma~\ref{lem:invertible_B}. Then, using these lemmas we prove the main result of this subsection, Lemma~\ref{lem:exact_xt}, which yields our desired properties of $x_{*}^{(t+1)}$. \begin{lem} \label{lem:ker_under_update}$\ker\left(\mm+uv^{\top}\right)\subseteq\mathrm{span}\left(\mm^{-1}u\right)$ for all invertible $\mm\in\R^{n\times n}$ and $u,v\in\R^{n}$. \end{lem} \begin{proof} If $\ker(\mm+uv^{\top})=\emptyset$ the claim follows trivially. Otherwise, there is $x\in\R^{n}$ with $x\neq0$ such that $(\mm+uv^{\top})x=0$. Since $\mm$ is invertible it follows that $x=-\mm^{-1}u(v^{\top}x)\in\mathrm{span}(\mm^{-1}u)$. \end{proof} \begin{lem} \label{lem:invertible_B} Every strictly RCDD matrix is invertible. \end{lem} \begin{proof} Let $\mm$ be an arbitrary strictly RCDD matrix. By definition, $\mm$ is $\alpha$-RCDD for some$\alpha>0$. Consequently, there exists $\epsilon>0$ such that $\mn=\mm-\epsilon\mI$ is $\beta$-RCDD for some $\beta>0$. Now, \[ \mm^{\top}\mm=(\epsilon\mI+\mn)^{\top}(\epsilon\mI+\mn)=\epsilon^{2}\mI+\epsilon(\mn+\mn^{\top})+\mn^{\top}\mn \] However, $\mn+\mn^{\top}$ is clearly a $\beta$-RCDD symmetric matrix and therefore is PSD. Consequently $\mm^{\top}\mm\succeq\epsilon^{2}\mI$ and therefore $\mm$ doesn't have a non-trivial kernel and is invertible. \end{proof} \begin{lem} \label{lem:exact_xt} Let $x,e\in\R_{>0}^{n}$ be such that $\mm=(\mE+\mlap)\mx$ is strictly RCDD and let $g\in\R_{>0}^{n}$ with $\norm g_{1}=1$. Then $x_{*}\defeq\mx\mm^{-1}g$ is all positive and $(\mE-ge^{\top}+\mlap)\mx_{*}$ is an Eulerian Laplacian. \end{lem} \begin{proof} Since $\mm$ is strictly RCDD by Lemma~\ref{lem:invertible_B} it is invertible. Furthermore, since $x,e,g\geq0$ by Lemma~\ref{lem:inverse-alphacdd_bound} we know that $\mm^{-1}g>0$ and $x_{*}>0$. Now $\mlap'=(\mE-ge^{\top}+\mlap)\mx$ is a directed Laplacian and therefore has a non-trivial right kernel. Consequently, by Lemma~\ref{lem:ker_under_update} and the fact that $\mlap'-\mm=-ge^{\top}\mx$ we know that $\mm^{-1}g$ is in the kernel of $\mlap^{'}$. Consequently, $(\mE-ge^{\top}+\mlap)\mx\mm^{-1}\mg1=0$ yielding the result. \end{proof} \subsubsection{Properties of $e$ \label{sec:computing_stationary:analysis:prop_e}} Here we provide bounds on what $e^{(t)}$ needs to be for $\mm^{(t)}$ to be $\alpha$-RCDD. First in Lemma~\ref{lem:column-alphadd-condtions} we give necessary and sufficient conditions for $(\mE+\mlap)\mx$ to be $\alpha$-CDD. This provides a lower bound on all the $e^{(t)}$. Then in Lemma~\ref{lem:bound-on-e0} we upper bound $e^{(0)}$. We conclude with Lemma~\ref{lem:formula_for_ei}, which yields a closed formula for the $e^{(t)}$. \begin{lem}[Conditions for $\alpha$-CDD] \label{lem:column-alphadd-condtions} For all vectors $x,e\in\R_{>0}^{n}$ and directed Laplacian $\mlap\in\R^{n\times n}$ the matrix $(\mE+\mlap)\mx$ is $\alpha$-CDD if and only if $e\geq\alpha d$. \end{lem} \begin{proof} By definition of $\mlap=\md-\ma$ we have that $(\mE+\mlap)\mx$ is column $\alpha$-CDD if and only if entrywise \[ 1^{\top}(\mE+\md)\mx\geq(1+\alpha)1^{\top}\ma^{\top}\mx=(1+\alpha)d^{\top}\mx. \] Applying $\mx^{-1}$ to each side and then subtracting $d^{\top}$ from each side yields the result. \end{proof} \begin{lem}[Bound on $e^{(0)}$] \label{lem:bound-on-e0} $\norm{\md^{-1}e^{(0)}}_{1}\leq(1+2\alpha)n$ \end{lem} \begin{proof} Since $e^{(0)}$ is the entry-wise minimal vector such that $\mm^{(0)}=(\mE^{(0)}+\mlap)\mx^{(0)}$ is $\alpha$-RCDD and since $\mx^{(0)}=\md^{-1}$ we have \[ \md^{-1}(e^{(0)}+d)=(1+\alpha)\max\left\{ \ma^{\top}\md^{-1}1\,,\,\md^{-1}\ma1\right\} \leq(1+\alpha)[\ma^{\top}\md^{-1}1+\md^{-1}\ma1]. \] However, since $\ma1=d$ we have that \begin{align*} \norm{\md^{-1}e^{(0)}}_{1} & \leq\norm{(1+\alpha)\ma^{\top}\md^{-1}1+(1+\alpha)\md^{-1}d-\md^{-1}d}_{1}\\ & \leq(1+\alpha)\norm{\ma^{\top}\md^{-1}1}_{1}+\alpha\norm 1_{1}\leq(1+2\alpha)|V|. \end{align*} Where we used that $\norm{\ma^{\top}\md^{-1}1}_{1}=1^{\top}\ma^{\top}\md^{-1}1=d^{\top}\md^{-1}1=n$. \end{proof} \begin{lem}[Formula for $e$] \label{lem:formula_for_ei} For $e,x\in\R_{>0}^{n}$ and $g\in\simplex^{n}$ let $v\defeq(\mE-ge^{\top}+\mlap)\mx1$ for directed Laplacian $\mlap=\md-\ma^{\top}$. Then, $f\in\R^{n}$, the entry-wise minimal vector such that $(\mf+\mlap)\mx$ is $\alpha$-RCDD is given by \[ f=\alpha d+(1+\alpha)\max\left\{ e-\mx^{-1}v-(e^{\top}x)\mx^{-1}g\,,\,0\right\} \,. \] \end{lem} \begin{proof} By Lemma~\ref{lem:column-alphadd-condtions} we know that $(\mf+\mlap)\mx$ is $\alpha$-CDD if and only if $f\geq\alpha d$. Furthermore, $(\mf+\mlap)\mx$ is $\alpha$-RDD if and only if $(\mf+\md)\mx1\geq(1+\alpha)\ma^{\top}\mx1$ which happens if and only if \begin{align*} f & \geq-d+(1+\alpha)\mx^{-1}\ma^{\top}\mx1\\ & \geq-d+(1+\alpha)\mx^{-1}[-v+\left(\mE-ge^{\top}+\md\right)\mx1]\\ & =\alpha d+(1+\alpha)[-\mx^{-1}v+e-(e^{\top}x)\mx^{-1}g]. \end{align*} Taking the maximum of the two lower bounds on $f$ yields the result. \end{proof} \subsubsection{Progress from Updating $e$ \label{sec:computing_stationary:analysis:progress:e}} Here we bound how much progress we make by updating $e$. We first give a general technical lemma, Lemma~\ref{lem:gen_progress}, and then in Lemma~\ref{lem:e-progress} we bound how $\norm{\md^{-1}(e^{(t)}-\alpha d)}_{1}$ decreases in each iteration. \begin{lem} \label{lem:gen_progress} For $a,b\in\R_{\geq0}^{n}$ and $z\in\R_{>0}^{n}$ with $b_{i}=\max\left\{ a_{i}-\frac{a^{\top}z}{\norm a_{1}}\cdot\frac{a_{i}}{z_{i}}\,,\,0\right\} $ we have $\norm b_{1}\leq\frac{1}{2}\norm a_{1}$. \end{lem} \begin{proof} Let $T\defeq\left\{ i\in[n]\,:\,\frac{a^{\top}z}{\norm a_{1}}\cdot\frac{a_{i}}{z_{i}}\leq a_{i}\right\} $. Then we have that \begin{equation} \norm a_{1}-\norm b_{1}=\sum_{i\in[n]}(a_{i}-b_{i})=\sum_{i\in T}\frac{a^{\top}z}{\norm a_{1}}\cdot\frac{a_{i}}{z_{i}}+\sum_{i\in[n]\setminus T}a_{i}\,.\label{eq:scale_bound_1} \end{equation} We can bound $\norm a_{1}^{2}$ trivially by \begin{align} \norm a_{1}^{2} & =\left(\sum_{i\in T}a_{i}+\sum_{i\in[n]\setminus T}a_{i}\right)^{2}\leq2\left(\sum_{i\in T}a_{i}\right)^{2}+2\left(\sum_{i\in[n]\setminus T}a_{i}\right)^{2}\,.\label{eq:scale_bound_2} \end{align} We can bound the first term by Cauchy-Schwarz \begin{equation} \left(\sum_{i\in T}a_{i}\right)^{2}=\left(\sum_{i\in T}\frac{\sqrt{a_{i}}}{\sqrt{z_{i}}}\cdot\sqrt{z_{i}a_{i}}\right)^{2}\leq\sum_{i\in T}\frac{a_{i}}{z_{i}}\sum_{i\in T}a_{i}z_{i}\leq\sum_{i\in T}\frac{a_{i}}{z_{i}}(a^{\top}z)\,.\label{eq:scale_bound_3} \end{equation} and the second term trivially by \begin{equation} \left(\sum_{i\in[n]\setminus T}a_{i}\right)^{2}\leq\left(\sum_{i\in[n]\setminus T}a_{i}\right)\sum_{i\in[n]}a_{i}\leq\sum_{i\in[n]\setminus T}a_{i}\norm a_{1}\,.\label{eq:scale_bound_4} \end{equation} Combining (\ref{eq:scale_bound_1}), (\ref{eq:scale_bound_2}), (\ref{eq:scale_bound_3}), and (\ref{eq:scale_bound_4}) yields the result \[ \frac{1}{2}\norm a_{1}\leq\sum_{i\in T}\frac{a^{\top}z}{\norm a_{1}}\cdot\frac{a_{i}}{z_{i}}+\sum_{i\in[n]\setminus T}a_{i}=\norm a_{1}-\norm b_{1}\,. \] \end{proof} \begin{lem}[Formula for $e_{i}^{(t)}$] \label{lem:e-progress} For $e,x\in\R_{>0}^{n}$ and $g\defeq\norm{\md^{-1}e}_{1}^{-1}\md^{-1}e$ let $v\defeq(\mE-ge^{\top}+\mlap)\mx1$. Then setting $f\in\R^{n}$ to the entry-wise minimal vector such that $(\mf+\mlap)\mx$ is $\alpha$-RCDD gives: \[ \norm{\md^{-1}(f-\alpha d)}_{1}\leq\frac{1+\alpha}{2}\norm{\md^{-1}(e-\alpha d)}_{1}+(1+\alpha)\norm{\md^{-1}\mx^{-1}v}_{1}+\left(\frac{1+\alpha}{2}\right)\frac{\alpha}{2}n\,. \] \end{lem} \begin{proof} By Lemma~\ref{lem:formula_for_ei} we know $f=\alpha d+(1+\alpha)\max\left\{ e-\mx^{-1}v-(e^{\top}x)\mx^{-1}g\,,\,0\right\} $. Consequently \begin{align*} \norm{\md^{-1}(f-\alpha d)}_{1} & =(1+\alpha)\norm{\max\{\md^{-1}e-\md^{-1}\mx^{-1}v-(e^{\top}x)\md^{-1}\mx^{-1}g\,,\,0\}}_{1}\\ & \leq(1+\alpha)\norm{\md^{-1}\mx^{-1}v}_{1}+(1+\alpha)\norm{\max\{\md^{-1}e-(e^{\top}x)\md^{-1}\mx^{-1}g\,,\,0\}}_{1}\,. \end{align*} Applying Lemma~\ref{lem:gen_progress} with $a=\md^{-1}e$ and $z=\md x$ we see that \begin{align*} \normFull{\max\left\{ \md^{-1}e-(e^{\top}x)\md^{-1}\mx^{-1}g\,,\,0\right\} }_{1} & =\normFull{\max\left\{ a-\frac{a^{\top}z}{\norm a_{1}}\mz^{-1}a\,,\,0\right\} }_{1}\leq\frac{1}{2}\norm a_{1}\\ & =\frac{1}{2}\norm{\md^{-1}e}_{1}\leq\frac{1}{2}\norm{\md^{-1}(e-\alpha d)}_{1}+\frac{\alpha}{2}n\,. \end{align*} Combining yields the result. \end{proof} \subsubsection{Linear System Solving Accuracy \label{sec:computing_stationary:analysis:linear_system_accuracy}} Here we show how to deal with approximate computation. \begin{lem} \label{lem:stationary_stable_compute} Let $\mlap=\md-\ma\in\R^{n\times n}$ be a directed Laplacian and let $e,x\in\R_{>0}^{n}$ be such that $\mm=(\mE+\mlap)\mx$ is $\alpha$-RCDD for $\alpha\in(0,\frac{1}{2})$. Let $g\defeq\norm{\md^{-1}e}_{1}^{-1}\md^{-1}e$ and let $z\in\R^{n}$ be an approximate solution to $\mm z=g$ in the sense that for $z_{*}\defeq\mm^{-1}g$ we have \begin{equation} \norm{z-z_{*}}_{\mdiag(\mm)}\leq\frac{\epsilon}{\alpha}\norm g_{\mdiag(\mm)^{-1}}\,.\label{eq:lem:stationary_stable_compute:1} \end{equation} Furthermore, let $y$ be approximately $\mx z$ in the sense that $\norm{\md(y-\mx z)}_{\infty}\leq\epsilon\norm{\md^{-1}e}_{\infty}$. Then if \[ \epsilon\leq\epsilon'\cdot\frac{\alpha^{2}}{100}\cdot\frac{1}{\norm{\md^{-1}e}_{1}}\cdot\frac{1}{(n+\norm{\md^{-1}e}_{1})}\cdot\frac{1}{\sqrt{n\cdot(1+\norm{\md^{-1}e}_{\infty})\kappa(\md\mx)}} \] for $\epsilon'\in(0,1)$ we have that $y>0$ and $\norm{(\my_{*})^{-1}(y-y_{*})}_{\infty}\leq\epsilon'$ where $y_{*}=\mx\mm^{-1}\md^{-1}e$. Consequently, for $\mlap'=\mE-ge^{\top}+\mlap$ we have $\norm{\my^{-1}\md^{-1}\mlap'y}_{1}\leq\epsilon'$ and $\kappa(\md\my)\leq\frac{10}{\alpha^{2}}\norm{\md^{-1}e}_{1}$. \end{lem} \begin{proof} By Lemma~\ref{lem:inverse-alphacdd_bound} and the fact that $\norm g_{1}=1$ by construction we have \begin{equation} \mdiag(\mm)^{-1}g\leq z_{*}\leq\mdiag(\mm)^{-1}g+\frac{1}{\alpha}\mdiag(\mm)^{-1}1\,.\label{eq:lem:stationary_stable_compute:2} \end{equation} Consequently, by (\ref{eq:lem:stationary_stable_compute:1}) \begin{align*} \norm{\mz_{*}^{-1}(z-z_{*})}_{\infty} & \leq\norm{\mdiag(\mm)\mg^{-1}(z-z_{*})}_{2}\leq\norm{\mg^{-1}}_{2}\cdot\sqrt{\norm{\mdiag(\mm)}_{2}}\cdot\norm{z-z_{*}}_{\mdiag(\mm)}\\ & \leq\norm{\mg^{-1}}_{2}\cdot\sqrt{\norm{\mdiag(\mm)}_{2}}\cdot\frac{\epsilon}{\alpha}\norm g_{\mdiag(\mm)^{-1}}\\ & \leq\frac{\epsilon}{\alpha}\norm{\mg^{-1}}_{2}\cdot\sqrt{\norm{\mdiag(\mm)}_{2}\cdot\norm{\mdiag(\mm)^{-1}}_{2}}\cdot\norm g_{2}\\ & \leq\frac{\epsilon}{\alpha}\norm{\mg^{-1}}_{2}\cdot\sqrt{\kappa(\mdiag(\mm))}\cdot\sqrt{n}\norm g_{\infty}\\ & \leq\frac{\epsilon}{\alpha}\kappa(\mg)\sqrt{n\kappa(\mdiag(\mm))} \end{align*} Now, $\kappa(\mdiag(\mm))\leq(1+\norm{\md^{-1}e}_{\infty})\kappa(\md\mx)$ and $\norm{\mg}_{2}\leq1$. Furthermore, $\norm{\mg^{-1}}_{2}\leq\frac{1}{\alpha}\norm{\md^{-1}e}_{1}$ since $\mE\succeq\alpha\md$ by Lemma~\ref{lem:column-alphadd-condtions} and the fact that $\mm$ is $\alpha$-RCDD. Consequently, $\kappa(\mg)\leq\frac{1}{\alpha}\norm{\md^{-1}e}_{1}$ and by our choice of $\epsilon$ we have \[ \norm{\mz_{*}^{-1}(z-z_{*})}_{\infty}\leq\frac{\epsilon}{\alpha^{2}}\norm{\md^{-1}e}_{1}\sqrt{n\cdot(1+\norm{\md^{-1}e}_{\infty})\kappa(\md\mx)}\defeq c_{1} \] This in turn implies that \begin{align*} \norm{\my_{*}^{-1}(y-y_{*})}_{\infty} & =\norm{\mz_{*}^{-1}\mx^{-1}(y-\mx z_{*})}_{\infty}\leq\norm{\mz_{*}^{-1}\mx^{-1}(y-\mx z)}_{\infty}+\norm{\mz_{*}^{-1}\mx^{-1}(\mx z_{*}-\mx z)}_{\infty}\\ & \leq\norm{\mdiag(\mm)\mg^{-1}\mx^{-1}(y-\mx z_{*})}_{\infty}+c_{1}\\ & \leq\norm{\mdiag(\mm)\mg^{-1}\mx^{-1}\md^{-1}}_{2}\cdot\norm{\md(y-\mx z_{*})}_{\infty}+c_{1}\\ & =\norm{\md^{-1}e}_{1}\cdot\norm{\mI+\md\mE^{-1}}_{2}\cdot\frac{\epsilon}{\alpha}+c_{1}\leq\frac{2}{\alpha}\norm{\md^{-1}e}_{1}\cdot\frac{\epsilon}{\alpha}+c_{1}\\ & \leq\frac{3\epsilon}{\alpha^{2}}\norm{\md^{-1}e}_{1}\sqrt{n\cdot(1+\norm{\md^{-1}e}_{\infty})\kappa(\md\mx)}\defeq c_{2} \end{align*} where we used that $\norm{\md\mE^{-1}}_{2}\leq\frac{1}{\alpha}$ by Lemma~\ref{lem:column-alphadd-condtions} and that $1\leq\frac{1}{\alpha}$ by assumption that $\alpha<\frac{1}{2}$. Consequently, we see that $y$ is within a small multiplicative constant of $y_{*}$, i.e. $\frac{1}{2}y_{*}\leq(1-c_{2})y_{*}\leq y\leq(1+c_{2})y_{*}\leq1y_{*}$ since by our choice of $\epsilon$ $c_{2}\leq\frac{1}{2}$. Therefore, applying Lemma~\ref{lem:exact_xt} we know that $\mlap'y_{*}=0$ and \begin{align*} \norm{\my^{-1}\md^{-1}\mlap'y}_{1} & =\norm{\my^{-1}\md^{-1}\mlap'(y-y_{*})}_{1}\leq2\norm{\my_{*}^{-1}\md^{-1}\mlap'\my_{*}\my_{*}^{-1}(y-y_{*})}_{1}\\ & \leq4\norm{\diag(\my_{*}^{-1}\md^{-1}\mlap'\my_{*})}_{1}\norm{\my_{*}^{-1}(y-y_{*})}_{\infty}\\ & \leq4\norm{\diag(\mI+\md^{-1}\mE)}_{1}\cdot c_{2}\leq4(n+\norm{\md^{-1}e}_{1})\cdot c_{2}\\ & \leq\frac{12\epsilon}{\alpha^{2}}\norm{\md^{-1}e}_{1}(n+\norm{\md^{-1}e}_{1})\sqrt{n\cdot(1+\norm{\md^{-1}e}_{\infty})\kappa(\md\mx)}\,. \end{align*} Where we used that $\mlap'\my_{*}$ is a Eulerian Laplacian so $\my_{*}^{-1}\md^{-1}\mlap'\my_{*}$is RDD and we can apply Lemma~\ref{lem:lap-onenorm-bound}. Finally, we note that by (\ref{eq:lem:stationary_stable_compute:2}) \begin{align*} \kappa(\md\my_{*}) & =\norm{\md\mz_{*}\mx}_{2}\cdot\norm{\md^{-1}\mz_{*}^{-1}\mx^{-1}}_{2}\\ & \leq\norm{(\mdiag(\mm)^{-1}\mg+\frac{1}{\alpha}\mdiag(\mm)^{-1})\md\mx}_{2}\cdot\norm{\md^{-1}\mx^{-1}\mdiag(\mm)\mg^{-1}}_{2}\\ & \leq\norm{(\md^{-1}\mE+\mI)^{-1}(\mg+\alpha^{-1}\mI)}_{2}\cdot\norm{(\md^{-1}\mE+\mI)\mg^{-1}}_{2}\\ & \leq\frac{2}{\alpha}\cdot\norm{\md^{-1}e}_{1}\norm{(\mI+\md\mE^{-1})}_{2}\leq\frac{4}{\alpha^{2}}\norm{\md^{-1}e}_{1} \end{align*} Where we used $\mg\preceq\mI\preceq\frac{1}{\alpha}\mI$ and $\md^{-1}\mE\succeq\alpha\mI$. Our bound on $\norm{\my_{*}^{-1}(y-y_{*})}$ completes the result. \end{proof} \subsubsection{Putting it All Together\label{sec:computing_stationary:analysis:main_theorem}} Here we show how to put together the results of the previous subsections to prove Theorem~\ref{thm:stat-from-dd}. \begin{proof}[Proof of Theorem~\ref{thm:stat-from-dd}] The running time is immediate from the definition of the algorithm and the fact that for exact $x^{(t)}$ computation it is the case that $v^{(t)}=0$ by Lemma~\ref{lem:exact_xt}. What remains is to prove that $\left(3\alpha|V|\cdot\md+\mlap\right)\md^{-1}\ms$ is an $\alpha$-RCDD. Now, by Lemma~\ref{lem:column-alphadd-condtions} and Lemma~\ref{lem:bound-on-e0} we know that \[ \norm{\md^{-1}(e^{(0)}-\alpha d)}_{1}\leq\norm{\md^{-1}e^{(0)}}_{1}-\alpha\norm{\md^{-1}d}_{1}\leq(1+\alpha)\cdot n\leq2n \] and clearly $\kappa(\md\mx^{(0)})=1$. Now suppose that for some $t\geq0$ we have that \[ \norm{\md^{-1}(e^{(t)}-\alpha d)}_{1}\leq\max\left\{ \left(\frac{7}{8}\right)^{t}2n\,,\,2\alpha n\right\} \] and $\kappa(\md\mx^{(t)})\leq\frac{20}{\alpha^{2}}n$. Then since this implies $\norm{\md^{-1}e^{(t)}}_{1}\leq2n$ by Lemma~\ref{lem:stationary_stable_compute} we have that for any absolute constant $\epsilon'$ it is the case that $x^{(t+1)}>0$ and $\norm{[\mx^{(t+1)}]^{-1}\md^{-1}\mlap^{(t)}x^{(t+1)}}_{1}\leq\epsilon'$ and $\kappa(\md\mx^{(t+1)})\leq\frac{10}{\alpha^{2}}\norm{\md^{-1}e^{(t)}}_{1}\leq\frac{20}{\alpha^{2}}n$. Furthermore, this implies by Lemma~\ref{lem:e-progress} that for $\epsilon'\leq\frac{1}{24}$ \begin{align*} \norm{\md^{-1}(e^{(t+1)}-\alpha d)}_{1} & \leq\frac{1+\alpha}{2}\norm{\md^{-1}(e^{(t)}-\alpha d)}_{1}+(1+\alpha)\epsilon'+\left(\frac{1+\alpha}{2}\right)\frac{\alpha}{2}n\\ & \leq\frac{3}{4}\norm{\md^{-1}(e^{(t)}-\alpha d)}_{1}+\frac{1}{4}\alpha n\leq\max\left\{ \left(\frac{7}{8}\right)^{t+1}2n\,,\,2\alpha n\right\} \,, \end{align*} where in the last line we used that if $\norm{\md^{-1}(e^{(t)}-\alpha d)}_{1}\geq2\alpha n$, then decreasing it by $\frac{3}{4}=(1-\frac{1}{4})$ is the same as decreasing by $\frac{7}{8}=(1-\frac{1}{8})$ and then subtracting $\frac{1}{8}$ fraction is subtracting at least $\frac{1}{4}\alpha n$, which cancels the additive term. Consequently, by induction we have that $\norm{\md^{-1}(e^{(t)}-\alpha d)}_{1}\leq\max\left\{ \left(\frac{7}{8}\right)^{t}2n\,,\,2\alpha n\right\} $ for all $t$. Therefore, for $k=8\ln\alpha^{-1}$ we have \[ \left(\frac{7}{8}\right)^{t}2n=\left(1-\frac{1}{8}\right)^{t}2n\leq e^{-\frac{t}{8}}2n\leq2n\alpha \] and $\norm{\md^{-1}(e^{(k+1)}-\alpha d)}_{\infty}\leq\norm{\md^{-1}(e^{(k+1)}-\alpha d)}_{1}\leq2n\alpha$; therefore $e^{(t)}\leq3\alpha n\cdot d$. Furthermore, since $(\mE^{(k+1)}+\mlap)\mx^{(k+1)}$ is $\alpha$-RCDD by construction this implies that $(3n\alpha\md+\mlap)\mx^{(k)}$ is $\alpha$-RCDD, yielding the result. \end{proof} \section{Numerical Stability \label{sec:numerical_stability}} In this section we give brief justifications of the numerical stability of our routine. For simplicity we will use fixed point arithmetic, and show that $O(1)$ words are sufficient when the input fits in word size. However, we do assume the numerical errors are adversarial: specifically we assume that at each step, any value can be perturbed adversarially by machine epsilon ($\epsilon_{mac})$. Formally our assumptions include: \begin{enumerate} \item The numerical stability of Gaussian elimination / LU factorization. Specifically given a matrix $M$ with condition number $\kappa$, we can access its inverse $M^{-1}$ with additive error $\epsilon$ in $O(n^{3}\log^{O(1)}(\kappa\epsilon^{-1}))$ time by manipulating words of length $O(\log(\kappa\epsilon^{-1}))$: see i.e. \cite{higham02}, Chapters 9 and 10, in particular Theorems 9.5. and 10.8. \item \begin{sloppypar}Numerically stable solvers for undirected Laplacians: given a graph Laplacian where all weights are in the range $[1,$U{]}, solves in it can be made to $\epsilon$ additive error in time $O(m\log^{O(1)}(n)\log(U\epsilon^{-1}))$ by manipulating words of length $O(\log(U\epsilon^{-1}))$. \end{sloppypar} \item The stability of iterative refinement: once we obtain a constant factor approximation, we can obtain an $\epsilon$-approximation in a numerically stable manner by working with words of the same length. \end{enumerate} Our analyses center around bounding the condition numbers of the matrices involved. This is because our algorithm makes crucial use of the Woodbury formula, which preserves condition number bounds, but may severely change the matrix entry-wise. Recall that $\kappa(\cdot)$ denotes the condition number of a matrix, which in case of symmetric matrices/operators is the maximum over minimum eigenvalue. \subsection{Reduction to Eulerian Case} Here it suffices to check that the iterative process outlined in Theorem \ref{thm:stat-from-dd} can tolerate perturbations to its intermediate vectors. Its proof relies on showing the 1-norm of a vector, $\norm{\md^{-1}(e^{(t-1)}-\alpha d)}_{1}$ is geometrically decreasing until up to $32\cdot\alpha\cdot|V|$. Such a bound is friendly to perturbations by vectors that are entrywise less than $\alpha$. Furthermore, if the entries of $D$ are at least $U^{-1},$ perturbations less than $U^{-1}\alpha$ are sufficient. The most important condition is that the intermediate matrices generated by this reduction do not become ill-conditioned. \begin{lem} \label{lem:reductionCondNice}If Algorithm \ref{alg:stationary_computation} takes a directed Laplacian $\mlap\in\R^{n\times n}$ where all non-zero entries are within a factor of $\kappa$ of each other, and restart parameter $\alpha$, then all intermediate matrices ($\mm^{(t)}$) that it performs linear-system solve on satisfy $\kappa(\frac{1}{2}(\mm+\mm^{\top}))\leq O(\kappa^{2}\alpha^{-2}n^{5})$. \end{lem} \begin{proof} The proof of Theorem~\ref{thm:stat-from-dd} in Section \ref{sec:computing_stationary:analysis:main_theorem} gives that all entries in $\mathbf{DX}^{(t)}$ are within a ratio of $20\alpha^{-2}n$ of each other. As $\mathbf{D}$ is the diagonal of $\mathcal{\mlap}$, all entries in $\md$ are within a factor of $\kappa n$ of each other, and therefore all entries of $\mx^{(t)}$are within a factor of $20\kappa\alpha^{-2}n$ of each other. Therefore all non-zero entries in the matrix $\mathcal{\mlap}\mx^{(t)}$ are within a factor of $20\kappa^{2}\alpha^{-2}n$ of each other. Since the matrix $\mE^{(t)}$ is chosen so that $\mE^{(t)}\mx^{(t)}+\mathcal{\mlap}\mx^{(t)}$ is $\alpha$-RCDD and $\alpha\leq\frac{1}{2}$, the additional entries can equal to at most the row/column sums of $\mathcal{\mlap}\mx^{(t)}$. Therefore all non-zero entries in $\mathbf{M}$ are within a factor of $20\kappa^{2}\alpha^{-2}n^{2}$ of each other, and the choice of $\mU=\frac{1}{2}(\mm+\mm^{\top})$ means all non-zero entries of the SDD matrix $\mU$ are within a factor of $40\kappa^{2}\alpha^{-2}n^{2}$ of each other. As condition numbers are invariant under scaling, we may assume without loss of generality that they're in the range $[1,$$40\kappa^{2}\alpha^{-2}n^{2}]$ by rescaling. The assumption of $\mlap$ being strongly connected means $\mU$ is connected. Therefore the minimum non-zero eigenvalue of $\mU$ is at least $0.1n^{-2}$, which occurs when $\mU$ is a path, and the diagonal is either exactly equal to row / column sums, or larger by $1$ on a single coordinate. The maximum on the other hand is bounded by $Trace(\mU)\leq40\kappa^{2}\alpha^{-2}n^{3}$ , which gives that the condition number of $\mU$ is bounded by $O(\kappa^{2}\alpha^{-2}n^{5})$. \end{proof} \subsection{Solving Eulerian Systems} Lemma~\ref{lem:reductionCondNice} implies that the condition number of $\mathbf{U}$ is polynomially bounded. Lemma~\ref{lem:lapbounds} then implies that the condition number of $\mx$ is also bounded by $O(\kappa^{2}\alpha^{-2}n^{5})$. Therefore, the routines in this section are performing one-step preconditioning operations on polynomially conditioned matrices, and intuitively are stable. Formally, there are three main sources of numerical errors in this process: \begin{enumerate} \item The Woodbury matrix identity from Lemma \ref{lem:ShermanMorrison}. \item Gaussian elimination involving the matrix $\mw_{S}^{-1}+\mr\widetilde{\mU}^{\dagger}\mr^{\top}$. This matrix is polynomially conditioned, so LU/Cholesky factorizations on it are stable by assumption. \item The calls to preconditioned iterative methods through Lemma \ref{lem:complicated-matrix-solver}. Since the relative condition number is bounded by $O(n^{2})$, this is stable by stability results of Chebyshev iterations. \end{enumerate} To show these bounds we need to bound the condition numbers of the input matrices. \begin{lem} When Theorem \ref{thm:euleriansolver} takes a matrix with condition number $\kappa$ and entries between $[U^{-1},U]$ as input, all the intermediate matrices generated have condition number $\leq\kappa n^{10}$, and entries bounded by \textup{$[U^{-1}\kappa^{-1}n^{-10},U\kappa n^{10}]$} \end{lem} \begin{proof} These distortions happen in several places where we manipulate the matrices: \end{proof} \begin{enumerate} \item Lemma \ref{lem:ultrasparsify}: here weights can be restricted to the range $[1,m]$ by lower bounding the probabilities at $1/m$. \item The Sherman-Morrison formula: \begin{enumerate} \item $\mathbf{W_{S}}$ has condition number $O(n^{2})$ as above \item Entries of $\mathbf{U^{\dagger}}$are pairwise effective resistances, and therefore bounded between $[U^{-1}n^{-2},Un^{2}]$, so the matrix $\mr\widetilde{\mU}^{+}\mr^{\top}$ is well conditioned, and have bounded entries. \item Compounding this with multiplying by $\mr\widetilde{\mU}^{+}$gives the bound on overall condition number and entry values \end{enumerate} \end{enumerate} This allows us to control the overall accumulation of error through direct propagation of vector error bounds. \begin{lem} If all the routines invoked in Theorem \ref{thm:euleriansolver} are run to precision $U^{-1}\kappa^{-1}n^{-10}$, then the guarantees of Theorem \ref{thm:euleriansolver} holds with $2\epsilon$. \end{lem} \begin{proof} The overall proof scheme is to view all numerical errors as perturbations with small $\ell_{2}$-norms after each step. Then the fact that the matrix are well conditioned means constant number of these steps can only increase error by a factor of $\mathrm{poly}(U,\kappa,n)$. There are two main numerical routines invoked in the course of the algorithm.: 1. All the calls to $\mathbf{U^{\dagger}}$ are stable by the stability analyses of operator based solvers, since $\mathbf{U}$ is well-conditioned. 2. The calls to Chebyshev iteration invoked in Lemma\ref{lem:complicated-matrix-solver} has a condition number of $O(n^{2})$, so all the operators are polynomially conditioned from the condition number bound on $\mathbf{Z}$. Therefore we can invoke known analyses of stability of Chebyshev iteration, such as Lemma 2.6.3. of \cite{Peng13:thesis}. Aside from that, the only other operations are matrix-vector multiplications. \end{proof}
{'timestamp': '2016-11-03T01:08:21', 'yymm': '1608', 'arxiv_id': '1608.03270', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03270'}
arxiv
\section{#1} } \def\hskip 1pt\vrule width1pt\hskip 1pt{\hskip 1pt\vrule width1pt\hskip 1pt} \def{\mathsf b}{{\mathsf b}} \def\mathsf P{\mathsf P} \def{\mathbb H}{{\mathbb H}} \def{\mathbb N}{{\mathbb N}} \def{\mathbb R}{{\mathbb R}} \def{\mathbb C}{{\mathbb C}} \def{\mathbb Z}{{\mathbb Z}} \def{\mathbb P}{{\mathbb P}} \def{{\rm I}\kern-1pt\Pi}{{{\rm I}\kern-1pt\Pi}} \def{\mathbb S}{{\mathbb S}} \def\mathfrak{S}{\mathfrak{S}} \def\mathbb T{\mathbb T} \def\mathcal{T}{\mathcal{T}} \def\alpha{\alpha} \def\b #1;{{\bf #1}} \def{\bf x}{{\bf x}} \def{\bf k}{{\bf k}} \def{\bf y}{{\bf y}} \def\mathbf{u}{\mathbf{u}} \def{\bf w}{{\bf w}} \def{\bf z}{{\bf z}} \def{\bf h}{{\bf h}} \def\mathbf{v}{\mathbf{v}} \def\mathfrak{m}{\mathfrak{m}} \def\mathbf{j}{\mathbf{j}} \def\mathbf{r}^*{\mathbf{r}^*} \def{\mathbf 0}{{\mathbf 0}} \def\epsilon{\epsilon} \def\lambda{\lambda} \def\phi{\phi} \def\varphi{\varphi} \def\sigma{\sigma} \def\mathbf{t}{\mathbf{t}} \def\Delta{\Delta} \def\delta{\delta} \def{\cal F}{{\cal F}} \def{\cal O}{{\cal O}} \def{\cal P}{{\cal P}} \def{\mathcal M}{{\mathcal M}} \def{\mathcal C}{{\mathcal C}} \def\CR{{\mathcal C}} \def{\mathcal N}{{\mathcal N}} \def{\cal Z}{{\cal Z}} \def{\cal A}{{\cal A}} \def{\cal V}{{\cal V}} \def{\cal E}{{\cal E}} \def{\mathcal H}{{\mathcal H}} \def{\bf W}{{\bf W}} \def{\mathbb W}{{\mathbb W}} \def\mathbb{Y}{\mathbb{Y}} \def{\bf Y}{{\bf Y}} \def{\widetilde\epsilon}{{\widetilde\epsilon}} \def{\widetilde E}{{\widetilde E}} \def{\overline{B}}{{\overline{B}}} \def\ip#1#2{{\langle {#1}, {#2}\rangle}} \def\derf#1#2{{#1}^{(#2)}} \def\node#1#2{x_{{#1},{#2}}} \def\mathop{\hbox{{\rm ess sup}}}{\mathop{\hbox{{\rm ess sup}}}} \def{{\bf e}_{q+1}}{{{\bf e}_{q+1}}} \def\begin{equation}{\begin{equation}} \def\end{equation}{\end{equation}} \def\begin{eqnarray}{\begin{eqnarray}} \def\end{eqnarray}{\end{eqnarray}} \def\eref#1{(\ref{#1})} \def\displaystyle{\displaystyle} \def\cfn#1{\chi_{{}_{ #1}}} \def\varrho{\varrho} \def\intpart#1{{\lfloor{#1}\rfloor}} \def\largeint#1{{\lceil{#1}\rceil}} \def\mathbf{ \hat I}{\mathbf{ \hat I}} \def\mbox{{\rm dist }}{\mbox{{\rm dist }}} \def\mbox{{\rm Prob }}{\mbox{{\rm Prob }}} \def\binom#1#2{\small{\left(\!\!\begin{array}{c}{#1}\\{#2} \end{array}\!\!\right)}} \def\donchitre#1#2{\vskip 6.5cm\noindent \parbox[t]{1in}{\special{eps:#1.eps x=6.5cm y=5.5cm}} \hbox to 7cm{}\parbox[t]{0.0cm}{\special{eps:#2.eps x=6.5cm y=5.5cm}}} \def\chitra#1{\vskip 9.5cm\noindent \hskip2in{\special{eps:#1.eps x=8.5cm y=8.5cm}} } \defFrom\ {From\ } \def|\!|\!|{|\!|\!|} \def{\mathbb X}{{\mathbb X}} \def{\mathbb B}{{\mathbb B}} \def\mbox{\mathsf{span }}{\mbox{\mathsf{span }}} \def\bs#1{{\boldsymbol{#1}}} \def\bs{\omega}{\bs{\omega}} \def\bs{\theta}{\bs{\theta}} \def\mathbf{t}^*{\mathbf{t}^*} \def\mathbf{x}^*{\mathbf{x}^*} \def\mathsf{dist }{\mathsf{dist }} \def\mathsf{supp\ }{\mathsf{supp\ }} \def\corr#1{#1} \def\sahi{\noindent With best regards,\\ \textit{ Hrushikesh}} \setlength{\parskip}{1.3em} \renewcommand{\baselinestretch}{1} \setlength{\parindent}{0pt} \newcommand*{\fbox{$\mathcal{PL}$}}{\fbox{$\mathcal{PL}$}} \setlength{\parindent}{0pt} \newcommand*{\titleAT}{\begingroup \newlength{\drop} \drop=0.05\textheight \begin{center} \includegraphics[scale=0.4]{cbmm.png} \end{center} \vspace{2pt}\vspace{-\baselineskip} \vspace{\drop} \textbf{\large{CBMM Memo No. 054}} \hfill \textbf{\large{\today}} \vspace{\drop} \begin{center} \textbf{\huge{Deep vs. Shallow Networks: an Approximation Theory Perspective}}\\ \vspace{0.4\drop} \textbf{\Large{by}}\\ \vspace{0.4\drop} \large{\memoauthors} \end{center} \vspace{\drop} \textbf{\large{\noindent Abstract}:} {\memoabstract} \vspace{\fill} \rule{\textwidth}{0.4pt}\par \begin{minipage}{.15\linewidth} \includegraphics[scale=0.1]{nsf1.pdf} \end{minipage} \begin{minipage}{.84\linewidth} \textbf{\large{This work was supported by the Center for Brains, Minds and Machines (CBMM), funded by NSF STC award CCF - 1231216. H.M. is supported in part by ARO Grant W911NF-15-1-0385.}} \end{minipage} \endgroup} \begin{document} \def054{054} \def\today{\today} \defDeep vs. Shallow Networks: an Approximation Theory Perspective{Deep vs. Shallow Networks: an Approximation Theory Perspective} \def\memoauthors{ \textbf{ Hrushikesh N. Mhaskar$^1$ and Tomaso Poggio$^2$ \\ \small 1. Department of Mathematics, California Institute of Technology, Pasadena, CA 91125 \\ Institute of Mathematical Sciences, Claremont Graduate University, Claremont, CA 91711. \\ \textsf{[email protected]} \\ 2. Center for Brains, Minds, and Machines, McGovern Institute for Brain Research, \\ Massachusetts Institute of Technology, Cambridge, MA, 02139. \\ \textsf{[email protected]} \\ } } \normalsize \def\memoabstract{ The paper briefly reviews several recent results on hierarchical architectures for learning from examples, that may formally explain the conditions under which Deep Convolutional Neural Networks perform much better in function approximation problems than shallow, one-hidden layer architectures. The paper announces new results for a non-smooth activation function -- the ReLU function -- used in present-day neural networks, as well as for the Gaussian networks. We propose a new definition of {\it relative dimension} to encapsulate different notions of sparsity of a function class that can possibly be exploited by deep networks but not by shallow ones to drastically reduce the complexity required for approximation and learning.} \titleAT \newpage \bhag{Introduction}\label{intsect} Deep Neural Networks especially of the convolutional type (DCNNs) have started a revolution in the field of artificial intelligence and machine learning, triggering a large number of commercial ventures and practical applications. Most deep learning references these days start with Hinton's backpropagation and with Lecun's convolutional networks (see for a nice review \cite{lecun2015deep}). Of course, multilayer convolutional networks have been around at least as far back as the optical processing era of the 70s. Fukushima's Neocognitron \cite{fukushima1980} was a convolutional neural network that was trained to recognize characters. The HMAX model of visual cortex \cite{Riesenhuber1999} was described as a series of AND and OR layers to represent hierarchies of disjunctions of conjunctions. A version of the questions about the importance of hierarchies was asked in \cite{poggio03mathematics} as follows: ``\textit{A comparison with real brains offers another, and probably related, challenge to learning theory. The ``learning algorithms'' we have described in this paper correspond to one-layer architectures. Are hierarchical architectures with more layers justifiable in terms of learning theory? It seems that the learning theory of the type we have outlined does not offer any general argument in favor of hierarchical learning machines for regression or classification. This is somewhat of a puzzle since the organization of cortex -- for instance visual cortex -- is strongly hierarchical. At the same time, hierarchical learning systems show superior performance in several engineering applications.}'' Ironically a mathematical theory characterizing the properties of DCNN's and even simply why they work so well is still missing. Two of the basic theoretical questions about Deep Convolutional Neural Networks (DCNNs) are: \begin{itemize} \item which classes of functions can they approximate well? \item why is stochastic gradient descent (SGD) so unreasonably efficient? \end{itemize} In this paper we review and extend a theoretical framework that we have introduced very recently to address the first question \cite{mhaskar_poggio_uai_2016}. The theoretical results include answers to why and when deep networks are better than shallow by using the idealized model of a deep network as a directed acyclic graph (DAG), which we have shown to capture the properties a range of convolutional architectures recently used, such as the very deep convolutional networks of the ResNet type \cite{EXTREMELYDEEP_MS_2015}. For compositional functions conforming to a DAG structure with a small maximal indegree of the nodes, such as a binary tree structure, one can bypass the curse of dimensionality with the help of the blessings of compositionality (cf. \cite{donoho2000high} for a motivation for this terminology). We demonstrate this fact using three examples : traditional sigmoidal networks, the ReLU networks commonly used in DCNN's, and Gaussian networks. The results announced for the ReLU and Gaussian networks are new. We then give examples of different notions of sparsity for which we expect better performance of DCNN's over shallow networks, and propose a quantitative measurement, called relative dimension, encapsulating each of these notions, independently of the different roles the various parameters play in each case. In Section~\ref{compfuncsect}, we explain the motivation for considering compositional functions, and demonstrate how some older results on sigmoidal networks apply for approximation of these functions. In Section~\ref{shallowsect}, we announce our new results in the case of shallow networks implementing the ReLU and Gaussian activation functions. The notion of a compositional function conforming to a DAG structure is explained in Section~\ref{deepsect}, in which we also demonstrate how the results in Section~\ref{shallowsect} lead to better approximation bounds for such functions. The ideas behind the proofs of these new theorems are sketched in Section~\ref{ideasect}. Finally, we make some concluding remarks in Section~\ref{sparssect}, pointing out a quantitative measurement for three notions of sparsity which we feel may be underlying the superior performance of deep networks. \bhag{Compositional functions}\label{compfuncsect} The purpose of this section is to introduce the concept of compositional functions, and illustrate by an example how this leads to a better approximation power for deep networks. In Sub-section~\ref{motivsect}, we explain how such functions arise in image processing and vision. In Sub-section~\ref{reviewsect}, we review some older results for approximation by shallow networks implementing a sigmoidal activation function, and explain how a ``good error propagation'' helps to generalize these results for deep networks. \subsection{Motivation}\label{motivsect} Many of the computations performed on images should reflect the symmetries in the physical world that manifest themselves through the image statistics. Assume for instance that a computational hierarchy such as \begin{equation}\label{compositionfigure} h_l(\cdots h_3(h_{21} (h_{11}(x_1, x_2), h_{12}(x_3, x_4)),\\ h_{22}(h_{13}(x_5, x_6), h_{14}(x_7, x_8))\cdots))) \end{equation} is given. Then shift invariance of the image statistics is reflected in the following property: the local node ``processors'' satisfy $h_{21}=h_{22}$ and $h_{11}=h_{12}=h_{13}=h_{14}$ since there is no reason for them to be different across an image. Similar invariances of image statistics -- for instance to scale rotation -- can be similarly used to constrain visual algorithms and their parts such as the local processes $h$. It is natural to ask whether the hierarchy itself -- for simplicity the idealized binary tree of the Figure \ref{example_binary} -- follows from a specific symmetry in the world and which one. A possible answer to this question follows from the fact that in natural images the target object is usually among several other objects at a range of scales and position. From the physical point of view, this is equivalent to the observation that there are several localized clusters of surfaces with similar properties (object parts, objects, scenes, etc). These basic aspects of the physical world are reflected in properties of the statistics of images: {\it locality, shift invariance and scale invariance}. In particular, locality reflects clustering of similar surfaces in the world -- the closer to each other pixels are in the image, the more likely they are to be correlated. Thus nearby patches are likely to be correlated (because of locality), at all scales. Ruderman's pioneering work \cite{Ruderman1997} concludes that this set of properties is {\it equivalent to the statement that natural images consist of many object patches that may partly occlude each other} (object patches are image patches which have similar properties because they are induced by local groups of surfaces with similar properties). We argue that Ruderman's conclusion reflects the compositionality of objects and parts: parts are themselves objects, that is self-similar clusters of similar surfaces in the physical world. The property of {\it compositionality} was in fact a main motivation for hierarchical architectures such as Fukushima's and later imitations of it such as HMAX which was described as a pyramid of AND and OR layers \cite{Riesenhuber1999}, that is a sequence of conjunctions and disjunctions. According to these arguments, compositional functions should be important for vision tasks because they reflect constraints on visual algorithms. The following argument shows that compositionality of visual computations is a basic property that follows from the simple requirement of {\it scalability} of visual algorithms: an algorithm should not change if the size of the image (in pixels) changes. In other words, it should be possible to add or subtract simple reusable parts to the algorithm to adapt it to increased or decreased size of the image without changing its basic core. A way to formalize the argument is the following. Consider the class of nonlinear functions, mapping vectors from ${\mathbb R}^n$ into ${\mathbb R}^d$ (for simplicity we put in the following $d=1$). Informally we call an algorithm $K_n: {\mathbb R}^n \mapsto {\mathbb R}$ {\it scalable} if it maintains the same ``form'' when the input vectors increase in dimensionality; that is, the same kind of computation takes place when the size of the input vector changes. Specific definitions of scalability and shift invariance for any (one-dimensional) image size lead to the following characterization of scalable, shift-invariant functions or algorithms: \textit{ Scalable, shift-invariant functions $K: {\mathbb R}^{2m} \mapsto {\mathbb R}$ have the structure $K = H_2 \circ H_4 \circ H_6 \cdots \circ H_{2m}$, with $H_4=\tilde{H}_2 \oplus \tilde{H}_2$, $H_6=H^*_2 \oplus H^*_2 \oplus H^*_2$, etc., \corr{where $\tilde{H}_2$ and $H^*_2$ are suitable functions}}. Thus the structure of {\it shift-invariant, scalable functions} consists of several layers; each layer consists of identical blocks; each block is a function $H: {\mathbb R}^2 \mapsto {\mathbb R}$: see Figure~\ref{ScalableOperator}. Obviously, shift-invariant scalable functions are equivalent to shift-invariant compositional functions. The definition can be changed easily in several of its specifics. For instance for two-dimensional images the blocks could be operators $H: {\mathbb R}^5 \rightarrow {\mathbb R}$ mapping a neighborhood around each pixel into a real number. The final step in the argument uses the universal approximation property to claim that a nonlinear node with two inputs and enough units (that is, channels) can approximate arbitrarily well each of the $H_2$ blocks. This leads to conclude that deep convolutional neural networks are natural approximators of {\it scalable, shift-invariant functions}. \begin{figure}\centering \includegraphics[width=0.5\textwidth]{ScalableOperator.pdf} \caption{\it A scalable function. Each layer consists of identical blocks; each block is a function $H_{2}: {\mathbb R}^2 \mapsto {\mathbb R}$. The overall function shown in the figure is $ \R^{32} \mapsto {\mathbb R}$ } \label{ScalableOperator} \end{figure} \subsection{An example}\label{reviewsect} In this section, we illustrate the advantage of approximating a compositional function using deep networks corresponding to the compositional structure rather than a shallow network that does not take into account this structure. In the sequel, for any integer $q\ge 1$, ${\bf x}=(x_1,\cdots,x_q)\in{\mathbb R}^q$, $|{\bf x}|$ denotes the Euclidean $\ell^2$ norm of ${\bf x}$, and ${\bf x}\cdot{\bf y}$ denotes the usual inner product between ${\bf x},{\bf y}\in{\mathbb R}^q$. In general, we will not complicate the notation by mentioning the dependence on the dimension in these notations unless this might lead to confusion. Let $I^q=[-1,1]^q$, ${\mathbb X}=C(I^q)$ be the space of all continuous functions on $I^q$, with $\|f\|=\max_{{\bf x}\in I^q}|f({\bf x})|$. If $\mathbb{V}\subset{\mathbb X}$, we define $\mathsf{dist}(f,\mathbb{V})=\inf_{P\in\mathbb{V}}\|f-P\|$. Let $\mathcal{S}_n$ denote the class of all shallow networks with $n$ units of the form $$ {\bf x}\mapsto\sum_{k=1}^n a_k\sigma(\mathbf{w}_k\cdot{\bf x}+b_k), $$ where $\mathbf{w}_k\in{\mathbb R}^q$, $b_k, a_k\in{\mathbb R}$. The number of trainable parameters here is $(q+2)n\sim n$. Let $r\ge 1$ be an integer, and $W_{r,q}^{\mbox{NN}}$ be the set of all functions with continuous partial derivatives of orders up to $r$ such that $\|f\|+\sum_{1\le |{\bf k}|_1\le r} \|D^{\bf k} f\| \le 1$, where $D^{\bf k}$ denotes the partial derivative indicated by the multi--integer ${\bf k}\ge 1$, and $|{\bf k}|_1$ is the sum of the components of ${\bf k}$. For explaining our ideas for the deep network, we consider compositional functions conforming to a binary tree. For example, we consider functions of the form (cf. Figure~\ref{example_binary}) \begin{equation}\label{l-variables} f(x_1, \cdots, x_8) = h_3(h_{21}(h_{11} (x_1, x_2), h_{12}(x_3, x_4)), h_{22}(h_{13}(x_5, x_6), h_{14}(x_7, x_8))). \end{equation} \begin{figure}[h] \centering \includegraphics[width=0.45\textwidth, height=0.3\textwidth]{Fig1a.pdf} \caption{\it A shallow universal network in 8 variables and $N$ units which can approximate a generic function $f(x_1, \cdots, x_8)$. The top node consists of $n$ units and computes the ridge function $\sum_{i=1}^n a_i\sigma(\ip{\mathbf{v}_i}{\mathbf{x}}+t_i)$, with $\mathbf{v}_i, \mathbf{x} \in {\mathbb R}^2$, $a_i, t_i\in{\mathbb R}$.} \label{example_shallow} \end{figure} \begin{figure}[h] \centering \includegraphics[width=0.9\textwidth]{Fig1b.pdf} \caption{\it A binary tree hierarchical network in 8 variables, which approximates well functions of the form \eref{l-variables}. Each of the nodes consists of $n$ units and computes the ridge function $\sum_{i=1}^n a_i\sigma(\ip{\mathbf{v}_i}{\mathbf{x}}+t_i)$, with $\mathbf{v}_i, \mathbf{x} \in {\mathbb R}^2$, $a_i, t_i\in{\mathbb R}$. Similar to the shallow network such a hierarchical network can approximate any continuous function; the text proves how it approximates compositional functions better than a shallow network. Shift invariance may additionally hold implying that the weights in each layer are the same. The inset at the top right shows a network similar to ResNets: our results on binary trees apply to this case as well with obvious changes in the constants} \label{example_binary} \end{figure} For the hierarchical binary tree network, the spaces analogous to $W_{r,q}^{\mbox{NN}}$ are $W_{H,r,2}^{\mbox{NN}}$, defined to be the class of all functions $f$ which have the same structure (e.g., (\ref{l-variables})), where each of the constituent functions $h$ is in $W_{r,2}^{\mbox{NN}}$ (applied with only $2$ variables). We define the corresponding class of deep networks $\mathcal{D}_n$ to be set of all functions with the same structure, where each of the constituent functions is in $\mathcal{S}_n$. We note that in the case when $q$ is an integer power of $2$, the number of parameters involved in an element of $\mathcal{D}_{n}$ -- that is, weights and biases, in a node of the binary tree is $(q-1)(q+2)n$. The following theorem (cf. \cite{optneur}) estimates the degree of approximation for shallow and deep networks. We remark that the assumptions on $\sigma$ in the theorem below are not satisfied by the ReLU function $x\mapsto |x|$, but they are satisfied by smoothing the function in an arbitrarily small interval around the origin. \begin{theorem} \label{optneurtheo} Let $\sigma :{\mathbb R}\to {\mathbb R}$ be infinitely differentiable, and not a polynomial on any subinterval of ${\mathbb R}$. \\ {\rm (a)} For $f\in W_{r,q}^{\mbox{NN}}$ \begin{equation}\label{optneurest} \mathsf{dist}(f,\mathcal{S}_n)= {\cal O}(n^{-r/q}). \end{equation} {\rm (b)} For $f\in W_{H,r,2}^{\mbox{NN}}$ \begin{equation} \mathsf{dist}(f,\mathcal{D}_n) =\mathcal{O}(n^{-r/2}). \label{deepnetapprox} \end{equation} \end{theorem} \noindent\textit{Proof.} Theorem~\ref{optneurtheo}(a) was proved by \cite{optneur}. To prove Theorem~\ref{optneurtheo}(b), we observe that each of the constituent functions being in $W_{r,2}^{\mbox{NN}}$, (\ref{optneurest}) applied with $q=2$ implies that each of these functions can be approximated from $\mathcal{S}_n$ up to accuracy $n^{-r/2}$. Our assumption that $f\in W_{H,r,2}^{\mbox{NN}}$ implies that each of these constituent functions is Lipschitz continuous. Hence, it is easy to deduce that, for example, if $P$, $P_1$, $P_2$ are approximations to the constituent functions $h$, $h_1$, $h_2$, respectively within an accuracy of $\epsilon$, then \begin{eqnarray*} \|h(h_1,h_2)-P(P_1,P_2)\| &\le& \|h(h_1,h_2)-h(P_1,P_2)\|+\|h(P_1,P_2)-P(P_1,P_2)\|\\ & \le& c\left\{\|h_1-P_1\|+\|h_2-P_2\|+\|h-P\|\right\}\le 3c\epsilon, \end{eqnarray*} for some constant $c>0$ independent of $\epsilon$. This leads to (\ref{deepnetapprox}). $\square$ The constants involved in ${\cal O}$ in (\ref{optneurest}) will depend upon the norms of the derivatives of $f$ as well as $\sigma$. Thus, when the only a priori assumption on the target function is about the number of derivatives, then to \textbf{guarantee} an accuracy of $\epsilon$, we need a shallow network with ${\cal O}(\epsilon^{-q/r})$ trainable parameters. If we assume a hierarchical structure on the target function as in Theorem~\ref{optneurtheo}, then the corresponding deep network yields a guaranteed accuracy of $\epsilon$ only with ${\cal O}(\epsilon^{-2/r})$ trainable parameters. Is this the best? To investigate this question, we digress and recall the notion of non--linear widths \cite{devore1989optimal}. If ${\mathbb X}$ is a normed linear space, $W\subset {\mathbb X}$ be compact, $M_n :W\to \mathbb R^n$ be a continuous mapping (parameter selection), and $A_n :\mathbb R^n\to {\mathbb X}$ be any mapping (recovery algorithm). Then an approximation to $f$ is given by $A_n(M_n(f))$, where the continuity of $M_n$ means that the selection of parameters is robust with respect to perturbations in $f$. The nonlinear $n$--width of the compact set $W$ is defined by \begin{equation}\label{nwidthdef} d_n(W)=\inf_{M_n, A_n}\sup_{f\in W}\| f, A_n(M_n(f))\|_{\mathbb X}. \end{equation} We note that the $n$--width depends only on the compact set $W$ and the space ${\mathbb X}$, and represents the best that can be achieved by \textbf{any} continuous parameter selection and recovery processes. It is shown in \cite{devore1989optimal} that $d_n(W_{r,q}^{\mbox{NN}})\ge cn^{-r/q}$ for some constant $c>0$ depending only on $q$ and $r$. So, the estimate implied by (\ref{optneurest}) is {\it the best possible} among \textbf{all} reasonable methods of approximating arbitrary functions in $W_{r,q}^{\mbox{NN}}$, although by itself, the estimate (\ref{optneurest}) is blind to the process by which the approximation is accomplished; in particular, this process is not required to be robust. Similar considerations apply to the estimate (\ref{deepnetapprox}). \bhag{Shallow networks}\label{shallowsect} In this section, we announce our results in the context of shallow networks in two settings. One is the setting of neural networks using the ReLU function $x\mapsto |x|\corr{=x_++(-x)_+}$ (Sub-section~\ref{relusect}), and the other is the setting of Gaussian networks using an activation function of the form ${\bf x}\mapsto\exp(-|{\bf x}-{\bf w}|^2)$ (Sub-section~\ref{gausssect}). It is our objective to generalize these results to the case of deep networks in Section~\ref{deepsect}. \corr{Before starting with the mathematical details, we would like to make some remarks regarding the results in this section and in Section~\ref{deepsect}. \begin{enumerate} \item It seems unnatural to restrict the range of the constituent functions. Therefore, we are interested in approximating functions on the entire Euclidean space. \item If one is interested only in error estimates analogous to those in Theorem~\ref{optneurtheo}, then our results need to be applied to functions supported on the unit cube. One way to ensure that that the smoothness is preserved is to consider a smooth extension of the function on the unit cube to the Euclidean space \cite[Chapter~VI]{stein2016singular}, and then multiply this extension by a $C^\infty$ function supported on $[-2,2]^q$, equal to $1$ on the unit cube. However, this destroys the constructive nature of our theorems. \item A problem of central importance in approximation theory is to determine what constitutes the right smoothness and the right measurement of complexity. The number of parameters or the number of non--linear units is not necessarily the right measurement for complexity. Likewise, the number of derivatives is not necessarily the right measure for smoothness for every approximation process. In this paper, we illustrate this by showing that different smoothness classes and notions of complexity lead to satisfactory approximation theorems. \end{enumerate}} \subsection{ReLU networks}\label{relusect} In this section, we are interested in approximating functions on ${\mathbb R}^q$ by networks of the form ${\bf x}\mapsto\sum_{k=1}^n a_k|{\bf x}\cdot\mathbf{v}_k+b_k|$, $a_k, b_k\in{\mathbb R}$, ${\bf x}, \mathbf{v}_k\in{\mathbb R}^q$. The set of all such functions will be denoted by $\mathcal{R}_{n,q}$. Obviously, these networks are not bounded on the whole Euclidean space. Therefore, we will study the approximation in weighted spaces, where the norm is defined by $$ \|f\|_{w,q} =\mathop{\hbox{{\rm ess sup}}}_{{\bf x}\in{\mathbb R}^q} \frac{|f({\bf x})|}{\sqrt{|{\bf x}|^2+1}}. $$ The symbol $X_{w,q}$ will denote the set of all continuous functions $f :{\mathbb R}^q\to {\mathbb R}$ for which $(|{\bf x}|^2+1)^{-1/2}f({\bf x})\to 0$ as ${\bf x}\to\infty$. We will define a ``differential operator'' $\mathcal{D}$ and smoothness classes $W_{w, \gamma,q}$ in terms of this operator in Section~\ref{relupfsect}. In the sequel, we will adopt the following convention. The notation $A\lesssim B$ means $A\le cB$ for some generic positive constant $c$ that may depend upon fixed parameters in the discussion, such as $\gamma$, $q$, but independent of the target function and the number of parameters in the approximating network. By $A\sim B$, we mean $A \lesssim B$ and $B \lesssim A$. Our first main theorem is the following Theorem~\ref{relutheo}. We note two technical novelties here. One is that the activation function $|\cdot|$ does not satisfy the conditions of Theorem~\ref{optneurtheo}. Second is that the approximation is taking place on the whole Euclidean space rather than on a cube as in Theorem~\ref{optneurtheo}. \begin{theorem}\label{relutheo} Let $\gamma>0$, $n\ge 1$ be an integer, $f\in W_{w,\gamma,q}$. Then there exists $P\in\mathcal{R}_{n,q}$ such that \begin{equation}\label{reluapproxbd} \|f-P\|_{w,q}\lesssim n^{-\gamma/q}\|f\|_{w,\gamma,q}. \end{equation} \end{theorem} \subsection{Gaussian networks}\label{gausssect} We wish to consider shallow networks where each channel evaluates a Gaussian non--linearity; i.e., Gaussian networks of the form \begin{equation}\label{gaussnetworkdef} G({\bf x})=\sum_{k=1}^n a_k\exp(-|{\bf x}-{\bf x}_k|^2),\qquad {\bf x}\in\mathbb R^q. \end{equation} It is natural to consider the number of trainable parameters $(q+1)n$ as a measurement of the complexity of $G$. However, it is known (\cite{convtheo}) that an even more important quantity that determines the approximation power of Gaussian networks is the minimal separation among the centers. For any subset ${\mathcal C}$ of $\mathbb R^q$, the minimal separation of ${\mathcal C}$ is defined by \begin{equation}\label{minsepdef} \eta({\mathcal C})=\inf_{{\bf x},{\bf y}\in{\mathcal C}, {\bf x}\not={\bf y}}|{\bf x}-{\bf y}|. \end{equation} For $n, m>0$, the symbol $\mathcal{N}_{n,m}(\mathbb R^q)$ denotes the set of all Gaussian networks of the form (\ref {gaussnetworkdef}), with $\eta(\{{\bf x}_1,\cdots,{\bf x}_n\})\ge 1/m$. Let ${\mathbb X}_q$ be the space of continuous functions on ${\mathbb R}^q$ vanishing at infinity, equipped with the norm $\|f\|_q=\max_{{\bf x}\in{\mathbb R}^q}|f({\bf x})|$. In order to measure the smoothness of the target function, we need to put conditions not just on the number of derivatives but also on the rate at which these derivatives tend to $0$ at infinity. Generalizing an idea from \cite{freud1972direct,tenswt}, we define first the space $W_{r,q}$ for integer $r\ge 1$ as the set of all functions $f$ which are $r$ times iterated integrals of functions in ${\mathbb X}$, satisfying $$ \|f\|_{r,q}=\|f\|_{q}+\sum_{1\le|{\bf k}|_1\le r}\|\exp(-|\cdot|^2)D^{\bf k}(\exp(|\cdot|^2)f)\|_{q} <\infty. $$ Since one of our goals is to show that our results on the upper bounds for the accuracy of approximation are the best possible for individual functions, the class $W_{r,q}$ needs to be refined somewhat. Toward that goal, we define next a regularization expression, known in approximation theory parlance as a $K$--functional, by $$ K_{r,q}(f,\delta)=\inf_{g\in W_{r,q}}\{\|f-g\|_{q}+\delta^r(\|g\|_{q}+\|g\|_{r,q})\}. $$ We note that the infimum above is over \textbf{all} $g$ in the class $W_{r, q}$ rather than just the class of all networks. The class $\mathcal{W}_{\gamma,q}$ of functions which we are interested in is then defined for $\gamma>0$ as the set of all $f\in {\mathbb X}_q$ for which $$ \|f\|_{\gamma,q}=\|f\|_{q}+\sup_{\delta\in (0,1]}\frac{K_{r,q}(f,\delta)}{\delta^\gamma}<\infty, $$ for some integer $r\ge \gamma$. It turns out that different choices of $r$ yield equivalent norms, without changing the class itself. The following theorem gives a bound on approximation of $f\in {\mathbb X}_q$ from $\mathcal{N}_{N,m}({\mathbb R}^q)$. The following theorem is proved in \cite{convtheo}. \begin{theorem}\label{unidegapptheo} Let $\{{\mathcal C}_m\}$ be a sequence of finite subsets with ${\mathcal C}_m\subset [-cm,cm]^q$, with \begin{equation}\label{uniformity} 1/m \lesssim\max_{{\bf y}\in [-cm,cm]^q}\min_{{\bf x}\in {\mathcal C}}|{\bf x}-{\bf y}| \lesssim \eta({\mathcal C}_m), \qquad m=1,2,\cdots. \end{equation} Let $1\le p\le\infty$, $\gamma>0$, and $f\in \mathcal{W}_{\gamma,q}$. Then for integer $m\ge 1$, there exists $G\in \mathcal{N}_{|{\mathcal C}_m|,m}({\mathbb R}^q)$ with centers at points in ${\mathcal C}_m$ such that \begin{equation}\label{unidirect} \|f-G\|_{q} \lesssim \frac{1}{m^\gamma}\|f\|_{\gamma,q}. \end{equation} Moreover, the coefficients of $G$ can be chosen as linear combinations of the data $\{f({\bf x}) :{\bf x}\in{\mathcal C}_m\}$. \end{theorem} We note that the set of centers ${\mathcal C}_m$ can be chosen arbitrarily subject to the conditions stated in the theorem; \textbf{there is no training necessary to determine these parameters}. Therefore, there are only ${\cal O}(m^{2q})$ coefficients to be found by training. This means that if we assume a priori that $f\in \mathcal{W}_{\gamma,q}$, then the number of trainable parameters to theoretically guarantee an accuracy of $\epsilon>0$ is ${\cal O}(\epsilon^{-2q/\gamma})$. For the unit ball $\mathcal{B}_{\gamma, q}$ of the class $\mathcal{W}_{\gamma,q}$ as defined in Section~\ref{gausssect}, the Bernstein inequality proved in \cite{mohapatrapap} leads to $d_n(\mathcal{B}_{\gamma,q})\sim n^{-\gamma/(2q)}$. Thus, the estimate \eref{unidirect} is the best possible in terms of widths. This implies in particular that when the networks are computed using samples of $f$ to obtain an accuracy of $\epsilon$ in the approximation, one needs $\sim \epsilon^{-2q/\gamma}$ samples. \corr{When $f$ is compactly supported, $\|f\|_{\gamma,q}$ is of the same order of magnitude as the norm of $f$ corresponding to the $K$-functional based on the smoothness class $W_r^{\mbox{NN}}$ in Section~\ref{reviewsect}. However, the number of parameters is then not commesurate with the results in that section.} We observe that the width estimate holds for the approximation of the entire class, and hence, an agreement with such width estimate implies only that there exists a possibly pathological function for which the approximation estimate cannot be improved. How good is the estimate in Theorem~\ref{unidegapptheo} for individual functions? If we know that some oracle can give us Gaussian networks that achieve a given accuracy with a given complexity, does it necessarily imply that the target function is smooth as indicated by the above theorems? The following is a converse to Theorem~\ref{unidegapptheo} demonstrating that the accuracy asserted by these theorems is possible if and only if the target function is in the smoothness class required in these theorems. It demonstrates also that rather than the number of nonlinearities in the Gaussian network, it is the minimal separation among the centers that is the ``right'' measurement for the complexity of the networks. Theorem~\ref{convtheo} below is a refinement of the corresponding result in \cite{convtheo}. \begin{theorem} \label{convtheo} Let $\{{\mathcal C}_m\}$ be a sequence of finite subsets of $\mathbb R^q$, such that for each integer $m\ge 1$, ${\mathcal C}_m\subseteq {\mathcal C}_{m+1}$, $|{\mathcal C}_m|\le c\exp(c_1m^2)$, and $\eta({\mathcal C}_m)\ge 1/m$. Further, let $f\in {\mathbb X}_q$, and for each $m\ge 1$, let $G_m$ be a Gaussian network with centers among points in ${\mathcal C}_m$, such that \begin{equation}\label{uniconv_degapprox} \sup_{m\ge 1}m^\gamma\|f-G_m\|_q <\infty. \end{equation} Then $f\in \mathcal{W}_{\gamma,q}$. \end{theorem} \corr{We observe that Theorem~\ref{unidegapptheo} can be interpreted to give estimates on the degree of approximation by Gaussian networks either in terms of the number of non--linear units, or the number of trainable parameters, or the minimal separation among the centers, or the number of samples of the target function. Theorem~\ref{convtheo} shows that the right model of complexity among these is the minimal separation among the centers. Using this measurement for complexity yields ``matching'' direct and converse theorems. Based on the results in \cite{eignet}, we expect that a similar theorem should be true also for ReLU networks.} \bhag{Deep networks}\label{deepsect} The purpose of this section is to generalize the results in Section~\ref{shallowsect} to the case of deep networks. In Sub-section~\ref{dagsect}, we will formulate the concept of compositional functions in terms of a DAG, and introduce the related mathematical concepts for measuring the degree of approximation and smoothness. The approximation theory results in this context will be described in Sub-section~\ref{deepapproxsect}. \subsection{General DAG functions}\label{dagsect} Let $\mathcal{G}$ be a directed acyclic graph (DAG), with the set of nodes $V$. A $\mathcal{G}$--function is defined as follows. The in-edges to each node of $\mathcal{G}$ represents an input real variable. The node itself represents the evaluation of a real valued function of the inputs. The out-edges fan out the result of this evaluation. Each of the source node obtains an input from some Euclidean space. Other nodes can also obtain such an input. We assume that there is only one sink node, whose output is the $\mathcal{G}$-function. For example, the DAG in Figure~\ref{graphpict} represents the $\mathcal{G}$--function \begin{eqnarray}\label{gfuncexample} \lefteqn{f^*(x_1,\cdots, x_9)=}\nonumber\\ &&h_{19}(h_{17}(h_{13}(h_{10}(x_1,x_2,x_3, h_{16}(h_{12}(x_6,x_7,x_8,x_9))), h_{11}(x_4,x_5)), h_{14}(h_{10},h_{11}), h_{16}), h_{18}(h_{15}(h_{11},h_{12}),h_{16}))\nonumber\\ \end{eqnarray} \begin{figure}[h] \begin{center} \includegraphics[scale=0.3]{poggiographrefined.pdf} \end{center} \caption{\it An example of a $\mathcal{G}$--function ($f^*$ given in \eref{gfuncexample}). The vertices of the DAG $\mathcal{G}$ are denoted by red dots. The black dots represent the input to the various nodes as indicated by the in--edges of the red nodes, and the blue dot indicates the output value of the $\mathcal{G}$--function, $f^*$ in this example.} \label{graphpict} \end{figure} We note that if $q$ is the number of source nodes in $\mathcal{G}$, a $\mathcal{G}$--function is a function on ${\mathbb R}^q$. Viewed only as a function on ${\mathbb R}^q$, it is not clear whether two different DAG structures can give rise to the same function. Even if we assume a certain DAG, it is not clear that the choice of the constituent functions is uniquely determined for a given function on ${\mathbb R}^q$. For our mathematical analysis, we therefore find it convenient to think of a $\mathcal{G}$--function as a set of functions $f=\{f_v :{\mathbb R}^{d(v)}\to{\mathbb R}\}_{v\in V}$, rather than a single function on ${\mathbb R}^q$. The individual functions $f_v$ will be called \textit{constituent functions}. We adopt the convention that for any function class ${\mathbb X}({\mathbb R}^d)$, the class $\mathcal{G}{\mathbb X}$ denotes the set of $\mathcal{G}$ functions $f=\{f_v\}_{v\in V}$, where each constituent function $f_v\in {\mathbb X}({\mathbb R}^{d(v)})$. We define \begin{equation}\label{gengfuncnormdef} \|f\|_{\mathcal{G},{\mathbb X}}=\sum_{v\in V}\|f_v\|_{{\mathbb X}({\mathbb R}^{d(v)})}. \end{equation} \subsection{Approximation using deep networks}\label{deepapproxsect} First, we discuss the analogue of Theorem~\ref{relutheo} in Section~\ref{relusect} for deep networks conforming to the DAG $\mathcal{G}$. We define the classes $\mathcal{G}X_w$ and $\mathcal{G}W_{w,\gamma}$ in accordance with the notation introduced in Section~\ref{dagsect}, and denote the norm on $\mathcal{G}X_w$ (respectively, $\mathcal{G}W_{w,\gamma}$) by $\|\cdot\|_{\mathcal{G},w}$ (respectively, $\|\cdot\|_{\mathcal{G}, w,\gamma}$). The symbol $\mathcal{G}\mathcal{R}_n$ denotes the family of networks $\{P_v\in \mathcal{R}_{n,d(v)}\}_{v\in V}$. The analogue of Theorem~\ref{relutheo} is the following. \begin{theorem} \label{deeprelutheo} Let $1\le \gamma\le 2$, $n\ge 1$ be an integer, $f\in \mathcal{G}W_{w,\gamma}$, $d=\max_{v\in V}d(v)$. Then there exists $P\in\mathcal{G}\mathcal{R}_n$ such that \begin{equation}\label{deepreluapproxbd} \|f-P\|_{\mathcal{G},w}\lesssim n^{-\gamma/d}\|f\|_{\mathcal{G},w,\gamma}. \end{equation} \end{theorem} We observe that if $P=\{P_v\}\in \mathcal{G}\mathcal{R}_n$ the number of trainable parameters in each constituent network $P_v$ is ${\cal O}(n)$. Therefore, the total number of trainable parameters in $P$ is ${\cal O}(|V|n)$. Equivalently, when the target function is in $\mathcal{G}W_{w,\gamma}$, one needs ${\cal O}((\epsilon/|V|)^{-d/\gamma})$ units in a deep network to achieve an accuracy of at most $\epsilon$. If one ignores the compositional structure of the target function, \eref{reluapproxbd} shows that one needs $O(\epsilon^{-q/\gamma})$ units in a shallow network. Thus, a deep network conforming to the structure of the target function yields a substantial improvement over a shallow network if $d\ll q$. Next, we discuss deep Gaussian networks. As before, the spaces $\mathcal{G}{\mathbb X}$ and $\mathcal{G}W_{\gamma}$ are as described in Section~\ref{dagsect}, and denote the corresponding norms $\|\cdot\|_{\mathcal{G}{\mathbb X}}$ (respectively, $\|\cdot\|_{\mathcal{G}W_{\gamma}}$) by $\|\cdot\|_{\mathcal{G}}$ (respectively, $\|\cdot\|_{\mathcal{G},\gamma}$). The analogue of Theorem~\ref{unidegapptheo} and Theorem~\ref{convtheo} are parts (a) and (b) respectively of the following Theorem~\ref{deepgausstheo}. \begin{theorem} \label{deepgausstheo} {\rm (a)} For each $v\in V$, let $\{{\mathcal C}_{m,v}\}$ be a sequence of finite subsets as described in Theorem~\ref{unidegapptheo}. Let $\gamma\ge 1$ and $f\in\mathcal{G}\mathcal{W}_{\gamma}$. Then for integer $m\ge 1$, there exists $G\in \mathcal{G}\mathcal{N}_{\max|{\mathcal C}_{m,v}|,m}$ with centers of the constituent network $G_v$ at vertex $v$ at points in ${\mathcal C}_{m,v}$ such that \begin{equation}\label{deepgfuncdirect} \|f-G\|_{\mathcal{G}} \lesssim \frac{1}{m^\gamma}\|f\|_{\mathcal{G},\gamma}. \end{equation} Moreover, the coefficients of each constituent $G_v$ can be chosen as linear combinations of the data $\{f_v({\bf x}) :{\bf x}\in{\mathcal C}_{m,v}\}$.\\ {\rm (b)} For each $v\in V$, let $\{{\mathcal C}_{m,v}\}$ be a sequence of finite subsets of $\mathbb R^{d(v)}$, satisfying the conditions as described in part (a) above. Let $f\in\mathcal{G}{\mathbb X}$, $\gamma>0$, and $\{G_m\in \mathcal{G}\mathcal{N}_{n,m}$\} be a sequence where, for each $v\in V$, the centers of the constitutent networks $G_{m,v}$ are among points in ${\mathcal C}_{m,v}$, and such that \begin{equation}\label{gfuncconv_degapprox} \sup_{m\ge 1}m^\gamma\|f-G_m\|_{\mathcal{G}} <\infty. \end{equation} Then $f\in \mathcal{G}\mathcal{W}_{\gamma}$. \end{theorem} \vskip -0.5cm \bhag{Ideas behind the proofs}\label{ideasect} \subsection{Theorem~\ref{relutheo}.}\label{relupfsect} The proof of this theorem has two major steps. One is a reproduction formula (\eref{repkern} below), and the other is the definition of smoothness. Both are based on ``wrapping'' the target function from ${\mathbb R}^q$ to a function $\mathcal{S}(f)$ (cf. \eref{rqtosqtrans} below) on the unit Euclidean sphere ${\mathbb S}^q$, defined by $$ {\mathbb S}^q=\{\mathbf{u}\in{\mathbb R}^{q+1} : |\mathbf{u}|=1\}. $$ A parametrization of the upper hemisphere ${\mathbb S}^q_+=\{\mathbf{u}\in{\mathbb S}^q : u_{q+1}>0\}$ of ${\mathbb S}^q$ is given by \begin{equation}\label{basicparam} u_j=\frac{x_j}{\sqrt{|{\bf x}|^2+1}}, \quad j=1,\cdots, q, \quad u_{q+1}=(|{\bf x}|^2+1)^{-1/2},\quad \mathbf{u}\in{\mathbb S}^q_+, \ {\bf x}\in {\mathbb R}^q, \end{equation} with the inverse mapping \begin{equation}\label{inverseparam} x_j=\frac{u_j}{u_{q+1}}, \qquad j=1,\cdots, q, \qquad \mathbf{u}\in{\mathbb S}^q_+,\ {\bf x}\in{\mathbb R}^q. \end{equation} Next, we define an operator $\mathcal{S}$ on $X_{w,q}$ by \begin{equation}\label{rqtosqtrans} \mathcal{S}(f)(\mathbf{u})= |u_{q+1}|f\left(\frac{u_1}{u_{q+1}}, \cdots, \frac{u_q}{u_{q+1}}\right), \qquad f\in X_{w,q}. \end{equation} We note that if $f\in X_{w,q}$, then $(|{\bf x}|^2+1)^{-1/2}f({\bf x})\to 0$ as $|{\bf x}|\to\infty$. Therefore, $\mathcal{S}(f)$ is well defined, and defines an even, continuous function on ${\mathbb S}^q$, equal to $0$ on the ``equator'' $u_{q+1}=0$. Next, let $\mu^*$ be the Riemannian volume measure on ${\mathbb S}^q$, with $\mu^*({\mathbb S}^q)=\omega_q$. In this subsection, we denote the dimension of the space of all homogeneous spherical polynomials of degree $\ell$ by $d_\ell$, $\ell=0,1,\cdots$, and the set of orthonormalized spherical harmonics on ${\mathbb S}^q$ by $\{Y_{\ell,k}\}_{k=1}^{d_\ell}$. If $F\in L^1({\mathbb S}^q)$, then \begin{equation}\label{fourcoeff} \hat{F}(\ell, k)=\int_{{\mathbb S}^q} F(\mathbf{u})Y_{\ell,k}(\mathbf{u})d\mu^*(\mathbf{u}). \end{equation} We note that if $F$ is an even function, then $\hat{F}(2\ell+1, k)=0$ for $\ell=0,1,\cdots$. Next, we recall the addition formula \begin{equation}\label{additionformula} \sum_{k=1}^{d_\ell}Y_{\ell,k}(\mathbf{u})\overline{Y_{\ell, k}(\mathbf{v})}=\omega_{q-1}^{-1}p_\ell(1)p_\ell(\mathbf{u}\cdot\mathbf{v}), \end{equation} where $p_\ell$ is the degree $\ell$ ultraspherical polynomial with positive leading coefficient, with the set $\{p_\ell\}$ satisfying \begin{equation}\label{orthonormal} \int_{-1}^1 p_\ell(t)p_j(t)(1-t^2)^{q/2-1}dt =\delta_{j,\ell}, \qquad j, \ell =0, 1,\cdots. \end{equation} The function $t\to |t|$ can be expressed in an expansion \begin{equation}\label{absseries} |t|\sim p_0-\sum_{\ell=1}^\infty \frac{\ell-1}{\ell(2\ell-1)(\ell+q/2)}p_{2\ell}(0)p_{2\ell}(t), \qquad t\in [-1,1], \end{equation} with the series converging on compact subsets of $(-1,1)$. We define the $\phi$--derivative of $F$ formally by \begin{equation}\label{formderdef} \widehat{\mathcal{D}_\phi F}(2\ell,k)=\left\{\begin{array}{ll} \hat{F}(0,0), & \mbox{if $\ell=0$},\\[1ex] \displaystyle -\frac{\ell(2\ell-1)(\ell+q/2)p_{2\ell}(1)}{\omega_{q-1}(\ell-1)p_{2\ell}(0)}\hat{F}(2\ell, k), &\mbox{ if $\ell=1,2,\cdots$,} \end{array}\right. \end{equation} and $\widehat{\mathcal{D}_\phi F}(2\ell+1,k)=0$ otherwise. Then for an even function $F \in L^1({\mathbb S}^q)$ for which $\mathcal{D}_\phi F\in L^1({\mathbb S}^q)$, we deduce the reproducing kernel property: \begin{equation}\label{repkern} F(\mathbf{u})=\int_{{\mathbb S}^q}|\mathbf{u}\cdot\mathbf{v}|\mathcal{D}_\phi F(\mathbf{v})d\mu^*(\mathbf{v}). \end{equation} A careful discretization of this formula using polynomial approximations of both the terms in the integrand as in \cite{zfquadpap, eignet} leads to a zonal function network of the form $\mathbf{u}\mapsto\sum_{k=0}^n a_k|\mathbf{u}\cdot\mathbf{v}_k|$, $a_k\in{\mathbb R}$, $\mathbf{v}_k\in{\mathbb S}^q$, satisfying \begin{equation}\label{relufavard} \left|F(\mathbf{u})-\sum_{k=0}^n a_k|\mathbf{u}\cdot\mathbf{v}_k|\right|\lesssim n^{-1/q}\mathop{\hbox{{\rm ess sup}}}_{\mathbf{v}\in{\mathbb S}^q}|\mathcal{D}_\phi F(\mathbf{v})|, \qquad \mathbf{u}\in{\mathbb S}^q. \end{equation} Next, we define formally \begin{equation}\label{reluderdef} \mathcal{D}(f)({\bf x})=(|{\bf x}|^2+1)^{1/2}\mathcal{D}_\phi (\mathcal{S}(f))\left(\frac{x_1}{\sqrt{|{\bf x}|^2+1}},\cdots,\frac{x_q}{\sqrt{|{\bf x}|^2+1}}, \frac{1}{\sqrt{|{\bf x}|^2+1}}\right). \end{equation} The estimate \eref{relufavard} now leads easily for all $f\in X_{w,q}$ for which $\mathcal{D}(f)\in X_{w,q}$ to \begin{equation}\label{relufavardeuclid} \left|f({\bf x})-\sum_{k=1}^n \frac{a_k}{\sqrt{|{\bf x}_k|^2+1}}|{\bf x}\cdot {\bf x}_k+1|\right|\lesssim n^{-1/q}\|\mathcal{D} (f)\|_{w,q}, \end{equation} where ${\bf x}_k$ is defined by $({\bf x}_k)_j=(\mathbf{v}_k)_j/(\mathbf{v}_k)_{q+1}$, $j=1,\cdots,q$. In order to define the smoothness class $W_{w,\gamma,q}$, we first define the $K$--functional \begin{equation}\label{relukfunc} K_w(f,\delta)=\inf\left\{\|f-g\|_{w,q}+\delta\|\mathcal{D}(g)\|_{w,q}\right\}, \end{equation} where the infimum is taken over all $g$ for which $\mathcal{D}g\in X_{w,q}$. Finally, the smoothness class $W_{w,\gamma,q}$ is defined to be the set of all $f\in X_{w,q}$ such that $$ \|f\|_{w,\gamma,q}=\|f\|_{w,q}+\sup_{0<\delta<1}\frac{K_w(f,\delta)}{\delta^\gamma}\corr{<\infty.} $$ The estimate \eref{relufavardeuclid} then leads to \eref{reluapproxbd} in a standard manner. \corr{We remark here that the unit cube $[-1,1]^q$ is mapped to some compact subset of ${\mathbb S}^q_+$. However, the operator $\mathcal{D}$ does not have an obvious interpretation in terms of ordinary derivatives on the cube.} \subsection{Theorems~\ref{unidegapptheo} and \ref{convtheo}.}\label{gausspfsect} In this section, let $\{\psi_j\}$ denote the sequence of orthonormalized Hermite functions; i.e., \cite[Formulas~(5.5.3), (5.5.1)]{szego} \begin{equation}\label{hermitedef} \psi_j(x)= \frac{(-1)^j}{\pi^{1/4}2^{j/2}\sqrt{j!}}\exp(x^2/2)\left(\frac{d}{dx}\right)^j (\exp(-x^2)), \qquad x\in{\mathbb R}, \ j=0,1,\cdots. \end{equation} The multivariate Hermite functions are defined by \begin{equation}\label{multihermitedef} \psi_\mathbf{j}({\bf x})=\prod_{\ell=1}\psi_{j_\ell}(x_\ell). \end{equation} We note that \begin{equation}\label{hermiteortho} \int_{{\mathbb R}^q} \psi_\mathbf{j}({\bf z})\psi_{\bf k}({\bf z})d{\bf z} =\delta_{\mathbf{j},{\bf k}},\qquad \mathbf{j},{\bf k}\in {\mathbb Z}_+^q. \end{equation} Using the Mehler formula \cite[Formula~(6.1.13)]{andrews_askey_roy}, it can be shown that \begin{equation}\label{hermite_recovery} \psi_\mathbf{j}({\bf y})=\frac{3^{|\mathbf{j}|/2}}{(2\pi)^{q/2}}\int_{{\mathbb R}^q} \exp(-|{\bf y}-{\bf w}|^2)\exp(-|{\bf w}|^2/3)\psi_\mathbf{j}(2{\bf w}/\sqrt{3})d{\bf w}. \end{equation} We combine the results on function approximation and quadrature formulas developed in \cite{mohapatrapap} to complete the proof of Theorem~\ref{unidegapptheo}. To prove Theorem~\ref{convtheo}, we modify the ideas in \cite{gaussbern} to obtain a Berstein--type inequality for Gaussian networks of the form \begin{equation}\label{gaussbernineq} \|g\|_{r,q}\lesssim m^r\|g\|_q, \qquad g\in N_{N,m}, \quad N\lesssim \exp(cm^2). \end{equation} The proof of Theorem~\ref{convtheo} then follows standard arguments in approximation theory. \subsection{Results in Section~\ref{deepapproxsect}. }\label{deeppfsect} Theorems~\ref{deeprelutheo} and \ref{deepgausstheo}(a) follow from Theorems~\ref{relutheo} and \ref{unidegapptheo} respectively by the ``good error propagation property'' as in the proof of Theorem~\ref{optneurtheo}(b) from Theorem~\ref{optneurtheo}(a). Our definitions of the norms for function spaces associated with deep networks ensure that a bound of the form \eref{gfuncconv_degapprox} implies a bound of the form \eref{uniconv_degapprox} for each of the constituent functions. Therefore, Theorem~\ref{convtheo} leads to Theorem~\ref{deepgausstheo}(b). \bhag{Blessed representations}\label{sparssect} As pointed out in Sections~\ref{reviewsect} and \ref{deepsect}, \textit{there are deep networks -- for instance of the convolutional type -- that can bypass the curse of dimensionality when learning functions blessed with compositionality.} In this section, we explore possible definitions of blessed function representations that can be exploited by deep but not by shallow networks to reduce the complexity of learning. We list three examples, each of a different type. \begin{itemize} \item The main example consists of the compositional functions defined in this paper in terms of DAGs (Figure \ref{graphpict}). The simplest DAG is a binary tree (see Figure \ref{example_binary} ) corresponding to compositional functions of the type $$ f(x_1, \cdots, x_8) = h_3(h_{21}(h_{11} (x_1, x_2), h_{12}(x_3, x_4)), h_{22}(h_{13}(x_5, x_6), h_{14}(x_7, x_8))). $$ As explained in previous sections, such compositional functions can be approximated well by deep networks. In particular, if the function form above has shift symmetry, it takes the form $$ f(x_1, \cdots, x_8) = h_3(h_2(h_1 (x_1, x_2), h_1(x_3, x_4)), h_2(h_1(x_5, x_6), h_1(x_7, x_8))). $$ that can be approximated well by a Deep Convolutional Network (that is with ``weight sharing'') but not by a shallow one. This first example is important because compositionality seems a common feature of algorithms applied to signals originating from our physical world, such as images. Not surprisingly, binary-like tree structures (the term binary-like covers obvious extensions to two-dimensional inputs such as images) represemt well the architecture of the most successful DCNN. \item Consider that the proof of Theorem~\ref{optneurtheo} relies upon the fact that when $\sigma$ satisfies the conditions of that theorem, the algebraic polynomials in $q$ variables of (total or coordinatewise) degree $<n$ are in the uniform closure of the span of ${\cal O}(n^q)$ functions of the form ${\bf x}\mapsto\sigma({\bf w}\cdot{\bf x}+b)$. The advantage of deep nets is due to the fact that polynomials of smaller number of variables lead to a nominally high degree polynomial through repeated composition. As a simple example, we consider the polynomial \begin{eqnarray*} Q(x_1,x_2,x_3,x_4)=(Q_1(Q_2(x_1,x_2), Q_3(x_3,x_4)))^{1024}, \end{eqnarray*} where $Q_1$, $Q_2$, $Q_3$ are bivariate polynomials of total degree $\le 2$. Nominally, $Q$ is a polynomial of total degree $4096$ in $4$ variables, and hence, requires $\binom{4100}{4} \approx (1.17)*10^{13}$ parameters without any prior knowledge of the compositional structure. However, the compositional structure implies that each of these coefficients is a function of only $18$ parameters. In this case, the representation which makes deep networks approximate the function with a smaller number of parameters than shallow networks is based on polynomial approximation of functions of the type $g(g(g()))$. \item As a different example, we consider a function which is a linear combination of $n$ tensor product Chui--Wang spline wavelets \cite{chuiwaveletbk}, where each wavelet is a tensor product cubic spline. It is shown in \cite{chui1994neural, chui1996limitations} that is impossible to implement such a function using a shallow neural network with a sigmoidal activation function using ${\cal O}(n)$ neurons, but a deep network with the activation function $(x_+)^2$ can do so. This case is even less general than the previous one but it is interesting because shallow networks are provably unable to implement these splines using a fixed number of units. In general, this does not avoid the curse of dimensionality, but it shows that deep networks provide, unlike shallow networks, local and multi--scale approximation since the spline wavelets are compactly supported with shrinking supports. \item \corr{Examples of functions that cannot be represented efficiently by shallow networks have been given very recently by \cite{Telgarsky2015}. The results in \cite{eldan2015power} illustrate the power of deep networks compared to shallow ones, similar in spirit to \cite{chui1994neural, chui1996limitations}.} \end{itemize} The previous examples show three different kinds of ``sparsity'' that allow a blessed representation by deep networks with a much smaller number of parameters than by shallow networks. This state of affairs motivates the following general definition of {\it relative dimension}. Let $d_n(W)$ be the non--linear $n$-width of a function class $W$. For the unit ball $\mathcal{B}_{\gamma, q}$ of the class $\mathcal{W}_{\gamma,q}$ as defined in Section~\ref{gausssect}, the Bernstein inequality proved in \cite{mohapatrapap} leads to $d_n(\mathcal{B}_{\gamma,q})\sim n^{-\gamma/(2q)}$. In contrast, for the unit ball $\mathcal{G}\mathcal{B}_\gamma$ of the class we have shown that $d_n(\mathcal{G}\mathcal{B}_{\gamma})\le cn^{-\gamma/(2d)}$, where $d=\max_{v\in V}d(v)$. Generalizing, let $\mathbb{V}$, $\mathbb{W}$ be compact subsets of a metric space ${\mathbb X}$, and $d_n(\mathbb{V})$ (respectively, $d_n(\mathbb{W})$) be their $n$--widths. We define the \textit{relative dimension} of $d_n(\mathbb{V})$ with respect to $d_n(\mathbb{W})$ by \begin{equation}\label{reldimdef} D(\mathbb{V}, \mathbb{W})=\limsup_{n\to\infty}\frac{\log d_n(\mathbb{W})}{\log d_n(\mathbb{V})}. \end{equation} Thus, $D(\mathcal{G}\mathcal{B}_{\gamma},\mathcal{B}_{\gamma, q})\le d/q$. This leads us to say that $\mathbb{V}$ is \textit{parsimonious} with respect to $\mathbb{W}$ if $D(\mathbb{V}, \mathbb{W})\ll 1$. As we mentioned in previous papers \cite{poggio2015December, mhaskar_poggio_uai_2016} this definition, and in fact most of the previous results, can be specialized to the class of Boolean functions which map the Boolean cube into reals, yielding a number of known \corr{\cite{Hastad1987}} and new results. This application will be described in a forthcoming paper. \corr{ \bhag{Conclusion}\label{conclusionsect} } \corr{ A central problem of approximation theory is to determine the correct notions of smoothness classes of target functions and the correct measurement of complexity for the approximation spaces. This definition is dictated by having ``matching'' direct and converse theorems. In this paper, we have demonstrated how different smoothness classes lead to satisfactory results for approximation by ReLU networks and Gaussian networks on the entire Euclidean space. Converse theorem is proved for Gaussian networks, and results in \cite{eignet} suggest that a similar statement ought to be true for ReLU networks as well. These results indicate that the correct measurement of network complexity is not necessarily the number of parameters. We have initiated a discussion of notions of sparsity which we hope would add deeper insights into this area.}
{'timestamp': '2016-08-12T02:00:23', 'yymm': '1608', 'arxiv_id': '1608.03287', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03287'}
arxiv
\subsection{Neurological Noise Research: Background and Motivation}\label{subsec:Introduction} \IEEEPARstart{S}{ignals} recorded from living neurological tissue are extremely noisy at all scales from individual ion channels \cite{hill-chen-IV-1972} through collections of one or more neurons \cite{manwani-koch-I-1999,hille-book-2001,diba-lester-koch-2004} up to scalp-recorded EEGs \cite{nunez-srin-book-2006} (\myfig{fig:RawEEG28Hz}). As a result, the theory of neurological noise continues to be a thriving area for research \cite{dest-book-2012}, with theoretical and practical implications for neurological signal processing and neurology. In this paper we examine the statistical characteristics of EEG periodograms \cite{oppen-schafer-book-1975,brockwell-davis-book-1991}. Specifically, we present a new model for the statistical properties of EEG background processes which, for the purpose of many applications, may be regarded as ``brain noise''. To the best of our knowledge, it is the first simple and general noise model in the EEG literature which closely matches recorded EEG periodograms from near 0 Hz to over 30 Hz. We then validate this new model using three different and complementary approaches. Our research on neurological noise is inspired by three main goals: $\bullet$ \emph{To improve the performance of real-time neurological algorithms:} Certain neurological signal processing tasks, such as extracting event-related potentials (ERPs), increase signal-to-noise ratios (SNRs) by averaging many epochs of data recorded over long experimental periods \cite{luck-book-2014}. However, time-frequency algorithms, which assume high levels of nonstationarity \cite{rankin-etal-2007}, and BCIs \cite{wangs-hong-gaos-2006,allison-et-al-2008}, which are meant to provide disabled patients with a sense of real-time control, must work with much shorter, single-trial epochs. Ordinary linear filtering of such short epochs is problematic, since there is evidence that the brain's responses are highly nonlinear \cite{tetz-etal-2006}, and because the target signals can be nearly indistinguishable from the background (cf. \myfig{fig:RawEEG28Hz}). Moreover, poorly-fitting models of the detailed statistical characteristics of brain processes reduces the precision of detection/estimation procedures and makes model validation uncertain. We are particularly interested in developing real-time SSVEP BCI algorithms which are accurate into the $\gamma$-band, a region of the EEG spectrum which is dominated by noise. $\bullet$ \emph{To create statistically-realistic simulations of neurological signals:} The common practice is to add artificial noise sources to neurological simulations in order to increase their realism and to measure the performance of models and algorithms \cite{diba-lester-koch-2004}. Good simulations of neurological signals are essential for development and testing of medical and BCI algorithms. This is especially true for critical applications to human neurology \cite{tetz-etal-2006,rankin-etal-2007} for which experimentation is highly restricted. $\bullet$ \emph{To create new insight into the underlying neurological processes:} Statistical models of neurological noise have had remarkable success in providing indirect tests of neuroscience hypotheses. This was spectacularly true for the elucidation of the acetycholine neurotransmission mechanisms in the 1970's by Katz \& Miledi \cite{katz-miledi-1972}. But noise models continue to enhance our understanding of neurological illness \cite{diez-etal-2013, vysata-etal-2014}, cognitive processes \cite{legenstein-maass-2014}, and may even explain brain nonlinearity \cite{miller-troyer-2002}. We believe that the theory of neurological noise processes will play an increasingly important role in interpreting the behavior of the billions of neurons and trillions of ion channels in large-scale, biological brain networks. \subsection{Steady-State Visual Evoked Potential BCIs}\label{subsec:SSVEP_def} Sudden stimuli such as a touch, a sound, or a bright flash will elicit a detectable brain reaction called an \myemph{event-related potential} \cite{luck-book-2014} or \myemph{evoked potential} (EP). Such EPs typically last on the order of 500 ms before disappearing, and usually may be reinvoked after a short refractory period. However, if the stimuli are repeated at a regular rate faster than about 2Hz, the EPs will not have time to decay and the brain's reaction will be a periodic signal called a \myemph{steady-state evoked potential} whose fundamental frequency is the same as the stimulus'. In particular, periodic visual stimuli will cause an SSVEP \cite{vialatte-maurice-dauwels-cichocki-2010}. These stimulus-dependent brain frequencies can be used to control BCIs \cite{allison-et-al-2008}, by flashing lights at various distinct frequencies simultaneously in different locations on a computer screen or LED device. The strongest SSVEP response peak detected corresponds to the location on which the subject's attention was most focused and usually represents the selection. Low frequency visual stimuli also induce harmonics \cite{herrmann-2001} (cf. \myfig{fig:chi2_8Hz}) which also may be used for BCI detection \cite{SSVEP-BCI-harmonics-2005}. Thus the corresponding subject selections can be identified by simple algorithms. It is worth remarking that such harmonic responses prove conclusively that the brain is a nonlinear system since pure linear systems cannot generate harmonics. On the other hand, higher frequencies, especially those which approach the gamma-band above 30 Hz, are much more difficult to detect, because their response power is close to that of the background and all harmonics (if they exist at all) and are lost in the gamma-band noise. This is seen most clearly in \myfig{fig:RawEEG28Hz}, which shows a 28 Hz brain response almost indistinguishable from background noise. (However, note that our new GVZM-based algorithms in \mysec{sec:SSVEP} detect the 28 Hz peak even in this difficult data set.) \subsection{Modeling EEG Noise and Noise Power Spectral Densities}\label{subsec:SSVEP_SFT} EEG noise has often been modeled using PSDs \cite{oppen-schafer-book-1975,brockwell-davis-book-1991} that are power law functions \cite{mandelbrot-book-1999a,miller-troyer-2002} of the form $S(f) \propto 1/f^\theta$ for some $0 \leqslant \theta < 2$. Neurological noise PSDs at all scales have long been claimed \cite{hill-chen-IV-1972,linkenhaer-hansen-etal-2001,diba-lester-koch-2004} to have the general characteristics of such ``$1/f$--type noise'' \cite{mandelbrot-book-1999a} even though this claim implies the obvious paradox of infinite total power in a biological system. Also, autoregressive (AR) \cite{allison-et-al-2008} and autoregressive-moving average (ARMA) models of \cite{brockwell-davis-book-1991} of EEG recordings are very commonly used, in particular to simulate noise for the SSVEP detection algorithm \cite{liavas-moustakides-1998}. Such models are useful approximations but yield PSDs which are rational functions and are more appropriate to stationary, linear systems. However, brain signals are known to be neither stationary \cite{rankin-etal-2007} nor linear \cite{miller-troyer-2002}. A useful approach has been to model the statistical variations of noise periodograms around their mean PSD. In many cases, the periodogram values $S_x\Paren{k}$ of a discrete-time random process $x\Paren{n}$ are independent, scaled $\chi^2\Paren{2}$ random variables \cite{mood-graybill-boes-book-1974}, whose expected value $\mathsf{E}\Brack{S_x\Paren{k}}$ gives the mean spectral power at the frequency index $k$ \cite{brockwell-davis-book-1991}. This result holds exactly for many important special cases, such as white Gaussian noise and causal periodic ARMA processes. (See Appendix A for the definition.) In more general situations, the $\chi^2\Paren{2}$ distribution is approached only asymptotically as the data length increases, however the result still has very broad applicability \cite{brockwell-davis-book-1991}. The idea of detecting SSVEP responses for BCI applications by performing statistical testing of the periodogram (often called the Spectral \textit{F}-Test (SFT)) was developed by several research groups in the mid-90's \cite{sa-infantosi-lazarev-2007} and is based on ``hidden periodicity'' methods dating back to the 40's \cite{brockwell-davis-book-1991}. The idea has been used regularly, most notably in \cite{liavas-moustakides-1998,baka-tana-cich-neuro-let-2010} which enhanced the flexibility of the original SFT procedure. \subsection{Contributions and Paper Organization}\label{subsec:Contributions} The central innovation of this article is a new statistical model of the discrete Fourier transform (DFT) periodograms \cite{oppen-schafer-book-1975} of EEG noise processes, the so-called GVZM noise model. We validate this model via three distinct approaches: (i) developing a neurological noise model based on quantum mechanical ion channel kinetics, (ii) linking autoregressive time series to the GVZM noise model and EEG noise, (iii) and designing and evaluating two real-time SSVEP BCI estimation algorithms, based on the new GVZM noise model. Our contributions can be summarized as the following $\bullet$ We introduce a novel, five-parameter GVZM PSD function, and we show that this function accurately matches the PSD function of recorded EEG noise, from near 0 Hz to 30 Hz. Also, we show that this function is approximately of the form $1/f^\theta$ in the mid-frequencies but has finite total power and finite amplitude as $f \to 0$. We provide a biophysical meaning of the function parameters and indicate how the function can be derived from a theory of ion channel noise. $\bullet$ We use the GVZM PSD function to define a new statistical model of the DFT periodgrams of EEG noise processes, which we call the GVZM noise model. We show that this model successfully captures the statistics of EEG periodograms, allows rigorous statistical testing, detection, and estimation, and enables statistically accurate simulations of EEG noise periodograms. $\bullet$ We define a class of mixed autoregressive (AR) time series, which we call AR-GVZM processes, containing accurate simulations of EEG noise time series, and whose PSD functions converge asymptotically to the GVZM PSD function (GVZM noise model). We show also that, if recorded EEG noise is assumed to be Gaussian and satisfies the GVZM noise model, it can be approximated arbitrarily closely by AR-GVZM processes. $\bullet$ We define two new SSVEP frequency estimation algorithms based on the GVZM noise model: a simple $\chi^2$-distribution detection algorithm for frequency spikes and a more sophisticated, $F$-distribution estimator based on the well-known algorithm in \cite{liavas-moustakides-1998}. We demonstrate statistically that these algorithms outperform two well-known rivals \cite{vialatte-maurice-dauwels-cichocki-2010,wei-xiao-lu-2011,kus-dusyk-etal-2013}, thus providing evidence for the truth of our noise model. The practical success of the GVZM noise model provides indirect validation of the underlying ion channel noise model from which it was developed. The remainder of this paper is organized as follows: \mysec{sec:GVZM} introduces the GVZM PSD function, defines the GVZM noise model, and discusses the behavior of the GVZM PSD function. \mysec{sec:Channels} briefly summarizes the results of the theory of quantum-controlled ion channels. \mysec{sec:ARGVZM} introduces AR-GVZM processes and discusses their link to GVZM noise model and EEG noise. \mysec{sec:SSVEP} describes and compares statistically two GVZM-based SSVEP algorithms and two rival SSVEP estimators. \mysec{sec:Summary} presents our conclusions. \section{Introduction}\label{sec:Overview} \input{1_Intro/1_Introduction} \input{1_Intro/2_SSVEP_BCI} \input{1_Intro/3_SSVEP_SFT} \input{1_Intro/4_ContributionsOutline} \subsection{Defining the Periodogram}\label{subsec:Periodograms} \mybegdef{def:periodogram} For the purpose of this article, the single-epoch \myemph{periodogram} of a discrete-time signal $x\Paren{n}$, $0 \leqslant n \leqslant N-1$, is defined as \[ S_x\Paren{k} \overset {\mathrm{def}} = \frac{2\pi}{N} \Abs{X\Paren{k}}^2, \;\; 0 \leqslant k \leqslant N-1, \] \noindent where $X\Paren{k} \overset {\mathrm{def}} = \sum_{n = 0}^{N-1} {x\Paren{n} \; \Exp{-i \Paren{2\pi/N}kn } } $ is the DFT of $x\Paren{n}$ \cite{oppen-schafer-book-1975}. The factor $2\pi$ is present to convert $S_x\Paren{k}$ to dimension amplitude$^2$/frequency, where frequency has dimension 1/time, not angle/time; i.e., units of Hz rather than radians/sec. \end{definition} \subsection{Defining the GVZM PSD Function}\label{subsec:GVZM_def} \mybegdef{def:GVZM_atan} The \myemph{GVZM PSD} $S_\mathrm{GVZM}\Paren{f}$ is the family of functions with five parameters $0 < \theta < 2$, $0 < \upsilon_1 < \upsilon_2$, $P_0 \geqslant 0$, $P_\mathrm{s} \geqslant 0$ and defined by \begin{align}\label{eq:SVZM_def} S_\mathrm{GVZM}\Paren{f} \overset {\mathrm{def}} = P_0 \Abs{f}^{-\theta} &\Paren{\mathrm{tan}^{-1}_\theta\Paren{2\pi \upsilon_2 \Abs{f}} \right. \nonumber\\ &\quad\left. - \mathrm{tan}^{-1}_\theta\Paren{2\pi \upsilon_1 \Abs{f}} } + P_\mathrm{s}, \end{align} where \mybegeq{eq:atan_def} \mathrm{tan}^{-1}_\theta\Paren{x} \overset {\mathrm{def}} = \mathrm{sgn}\Paren{x} \int\limits_0^{\Abs{x}} { \frac{u^{\theta-1}}{1+u^2} du}. \end{equation} \end{definition} Note that for $\theta = 1$, Eq. \myeq{eq:atan_def} is the ordinary $\mathrm{arctan}\Paren{x}$ (cf. \myfig{fig:atan}). The dimension of $\upsilon_1$, $\upsilon_2$ is time while that of $P_0$, $P_\mathrm{s}$ is amplitude$^2$/frequency (i.e., noise power). The spectral exponent $\theta$ is dimensionless. The biophysical meaning of these parameters is described in \mysec{subsec:QuantumChannels}. The importance of this definition is that, so far as the authors are aware, this is the first simple model of the average EEG background noise spectrum proposed in the literature which can match recorded EEG periodograms from near 0 Hz to over 30 Hz, with a fixed number of parameters. Moreover, the GVZM PSD function approximates a power law $1/f^\theta$ in the mid-frequencies without requiring infinite power. In fact, $S_\mathrm{GVZM}\Paren{f}$ always has finite amplitude and finite total power. In the next section, the GVZM PSD will be used to define a statistical model of EEG periodograms, the core of our work and the basis of the new SSVEP algorithms in \mysec{sec:SSVEP}. \subsection{The GVZM Noise Model}\label{subsec:GVZM_model} \mybegdef{def:GVZM_model} Let $x\Paren{n}$, $0 \leqslant n \leqslant N-1$ be samples of an EEG electrode, taken at sampling frequency $f_\mathrm{samp}$, which measures a naturally-occuring, stationary ensemble of brain background processes for a single individual. Then the \textbf{GVZM noise model} of the periodogram values $S_x\Paren{k}$, $0 \leqslant k \leqslant N-1$ is the random process \mybegeq{eq:GVZM_process} S_x\Paren{k} = S_\mathrm{GVZM}\Paren{ k \Delta f} \cdot \Paren{1/2} \, \Xi\Paren{k}, \end{equation} \noindent where $\Xi\Paren{k}$ is a sequence of $\chi^2\Paren{2}$ distributed \cite{mood-graybill-boes-book-1974} random variables, which are independent for $0 \leqslant k, l < N/2$ when $k \ne l$, $\Delta f \overset {\mathrm{def}} = f_\mathrm{samp} / N$, and $S_\mathrm{GVZM}\Paren{f}$ is an appropriate GVZM PSD defined by \myeq{eq:SVZM_def}. \end{definition} Note that the reason for the restriction of independence to $0 \leqslant k, l < N/2$ is that, since $x\Paren{\, \cdot \,}$ is real, we have $S_x\Paren{N-k} = S_x\Paren{k}$. Also note that the half-interval definition $0 \leqslant k, l < N/2$ applies whether $N$ is even or odd. We can write \myeq{eq:GVZM_process} informally as \[ S_x\Paren{k} \sim S_\mathrm{GVZM}\Paren{ k \Delta f} \cdot \Paren{1/2} \, \chi^2\Paren{2}, \] where $\sim$ denotes ``is distributed as.'' The $\Paren{1/2} \, \chi^2\Paren{2}$ periodogram distribution holds exactly for special processes such as $N$-periodic ARMA described in Appendix A. When conditions for the Central Limit Theorem hold, the $\Paren{1/2} \, \chi^2\Paren{2}$ distribution holds asymptotically as the data length $N \to \infty$ \cite{brockwell-davis-book-1991}. Both $N$-periodic ARMA and the large-$N$ approximations are appropriate for EEG noise. Note that Eq. \myeq{eq:GVZM_process} implies that the expected values $\mathsf{E} \Brack{S_x\Paren{k}}$ are equal to $S_\mathrm{GVZM}\Paren{ k \Delta f}$. Using general results presented in \cite{brockwell-davis-book-1991}, the converse holds asymptotically; that is, the process $S_x\Paren{k}$ converges uniformly in distribution to $S_\mathrm{GVZM}\Paren{ k \Delta f} \cdot \Paren{1/2} \, \Xi\Paren{k}$ as $N \rightarrow \infty$, at least when conditions for Central Limit Theorem hold. (cf. \cite{brockwell-davis-book-1991}, Chapter 10 for details.) \mydef{def:GVZM_model} is consistent with the single-epoch approach of \cite{brockwell-davis-book-1991,liavas-moustakides-1998} but multi-epoch averages of such single-epoch spectra can be used as well. Our methods will apply to such general periodograms merely by replacing ``$\chi^2\Paren{2}$'' with ``$1/M \; \chi^2\Paren{2M}$,'' where $M$ is the number of (statistically independent) epochs. \subsection{The Behavior of the GVZM PSD Function}\label{subsec:GVZM_behavior} The properties of $\mathrm{tan}^{-1}_\theta\Paren{x}$ show that once the noise floor $P_\mathrm{s}$ is subtracted we have the approximate proportionalities $S_\mathrm{GVZM}\Paren{f} \propto1/f^0$ (i.e., a constant) for $f < 1/\Paren{2\pi \upsilon_2}$, $S_\mathrm{GVZM}\Paren{f} \propto 1/f^\theta$ for $1/\Paren{2\pi \upsilon_2} < f < 1/\Paren{2\pi \upsilon_1}$, and $S_\mathrm{GVZM}\Paren{f} \propto 1/f^2$ for $f > 1/\Paren{2\pi \upsilon_1}$. Thus its roll-off transitions smoothly through the $1/f^\theta$ regime, without any of the so-called ``catastrophes'' \cite{mandelbrot-book-1999a} of apparent infinite power when $f \to 0$ and infinite integrals as $f \rightarrow \infty$ which plague true $1/f$--type noises. In particular, $S_\mathrm{GVZM}\Paren{f}$ approaches a (calculable) limiting value as $f \rightarrow 0$. \myfig{fig:GVZMfit} shows a GVZM PSD function fitted to the periodogram of recorded EEG data from an SSVEP session. The GVZM curve follows the periodogram closely except for the alpha-band power \cite{nunez-srin-book-2006} and the SSVEP response spike. \myfig{fig:GVZMfit} should be compared closely to \myfig{fig:chi2_simulation} which shows a \myemph{simulated} periodogram based on the fitted GVZM PSD function and \myeq{eq:GVZM_process}; that is, samples of an independent and identically distributed (iid) $\chi^2\Paren{2}$ pseudo--random process $\Xi\Paren{k}$, $0 \leqslant k \leqslant N-1$ were generated and each sample was multiplied by the factor $\Paren{1/2}\cdot \, S_\mathrm{GVZM}\Paren{ k \Delta f}$. The results were then plotted against frequency on a log-linear scale. We observe that the simulated periodogram of \myfig{fig:chi2_simulation} is visually indistinguishable from the background periodogram of \myfig{fig:GVZMfit}. Eq. \myeq{eq:SVZM_def} has it origin in investigations dating to the 1930's \cite{bernamont-1937} on apparent $1/f$-type noise in vacuum tubes and semiconductors. In 1957, A.L. McWhorter proposed\cite{mcwh-1957} a simple explanation for $1/f$--type semiconductor noise at thermal equilibrium, based on the assumption that the logarithm of the rate at which electrons drop from an activated state was proportional to the energy of that state. Subsequently A. van der Ziel and others \cite{vdziel-1978} abstracted the McWhorter mechanism to general noise processes. Our formula \myeq{eq:SVZM_def} reduces to the original van der Ziel-McWhorter PSD function for $\theta = 1$. \section{The GVZM EEG Periodogram Model}\label{sec:GVZM} In this section, we first specify the notion of periodogram we are using and then define the GVZM PSD function. We then present the GVZM EEG periodogram model. \input{2_GVZM/1_Periodogram} \input{2_GVZM/2_GVZM_def} \input{2_GVZM/3_GVZM_model} \input{2_GVZM/4_GVZM_misc} \subsection{Are Ion Channels the Source of \textit{1}$/f$--type Noise?}\label{subsec:NoisyChannels} Ion channels are protein-based micromachines densely embedded in all neuron membranes, which create and control the transmission of information by regulating the passage of ions in response to neurotransmitters, local voltages, or external stimuli such as temperature, pressure, or photon reception \cite{hille-book-2001}. Soon after Hodgkin \& Huxley decoded the generation of action potentials by the ${\textrm{K}^+}$/${\textrm{Na}^+}$ channel system \cite{hodgkin-huxley-1952}, researchers began to model ion conductance variations in membranes as resulting from simple Markov processes governing the open/close kinetics of the embedded ion channels \cite{hill-chen-IV-1972}. These conductance variations were recognized quickly as a potential source of neurological noise, at least at the neuron level \cite{hille-book-2001}. In a series of articles \cite{hill-chen-IV-1972} in the early 1970's, Hill \& Chen examined several versions of Markov models, including one which was claimed to test the original van der Ziel-McWhorter paradigm (\mysec{sec:GVZM}), with the stated goal of \myemph{excluding} ion channels as sources of the $1/f$--type noise component seen in neuron-level recordings. The limited computational resources available at that time prevented detailed simulations, and they eventually rejected ion channel kinetics as the source of the $1/f$--type noise, thus leaving its origin unexplained. Since then there have been attempts to explain this neurological noise by various other mechanisms \cite{diba-lester-koch-2004}, however, none of these explanations have been completely successful. \subsection{Maximum Entropy in Populations of Quantum Ion Channels and GVZM Noise}\label{subsec:QuantumChannels} We have revisited the conclusion of of Hill \& Chen in \cite{paris-atia-vosoughi-berman-2015a} by considering network-level behavior of large populations of ion channels in statistical equilibrium. Specifically, we have returned to McWhorter's original model (\mysec{sec:GVZM}) of noise generation in semiconductors and identified channel analogies to McWhorter's energy-dependent rate constants and maximum entropy distributions. We have applied McWhorter's abstract maximum entropy paradigm by creating a new quantum mechanical model of ion channel kinetics, which we call \myemph{activated measurement processes}. In the following, we recall a special case of our work in \cite{paris-atia-vosoughi-berman-2015a}: \mybegthm{thm:ionR} \input{3_Channels/R_thm} \end{theorem} (The ``conditions'' mentioned in \mythm{thm:ionR} are technical and are omitted.) Note that the Fourier transform of \myeq{eq:R_GVZM} is easily seen to be the GVZM PSD function in \mydef{def:GVZM_atan}. While these results have immediate relevance only for populations of ion channels, we have argued in \cite{paris-atia-vosoughi-berman-2015a} that the presence of GVZM noise in large-scale EEG recordings ultimately derives from the collective behavior of billions of ion channels balanced in statistical equilibrium. A rough idea of the biophysical meaning of the parameters can be given. The values $\upsilon\Paren{x}$ represents the range of possible reciprocal eigenvalues (``modes'') of the kinetic rate matrices \cite{hille-book-2001} of all possible ion channels in a large network while $X$ is an index set for these modes. The $P_\mathrm{s} \cdot \delta\Paren{\tau}$ term represents ``sputter'' in the channels: the possibility that a channel's state is not quite open or closed completely. The $1/\upsilon\Paren{x}$ prefactor in the integrand derives from the proportionality between activation energy and $\mathrm{log}\Paren{\upsilon}$, a feature common to both the McWhorter paradigm as well as an alternative ion channel mechanism called Eyring rate theory \cite{woodbury-1969}. Most importantly, the exponent $\theta$ is the normalization parameter for a standard thermodynamic partition function \[ Z\Paren{\theta} = \int\limits_X {\Exp{-\theta E\Paren{\upsilon}} \, d\upsilon}, \] where, as previously mentioned, the activation energy of mode $\upsilon$ is $E\Paren{\upsilon} \propto \textrm{log}\Paren{\upsilon}$. This latter point is very significant. Many attempts have been made to explain irrational exponents in $1/f^\theta$--type spectra by means of purported power laws, ``scaling'', or ``self-similarity'' phenomena in neural tissue \cite{mandelbrot-book-1999a}. We consider our interpretation of spectral exponents as normalizing constants for logarithmically-determined energy levels to represent a needed influx of reality into the field of neurological noise. \section{Neurological Noise Theory and Quantum Mechanical Ion Channel Kinetics}\label{sec:Channels} In this section we briefly discuss the theoretical foundation of our GVZM PSD function in \mydef{def:GVZM_atan}, using a new model of \myemph{ion channel quantum stochastic processes} we have developed, and whose details are presented in the supplementary document \cite{paris-atia-vosoughi-berman-2015a}. For the present paper we extract a simplified form of one type of potential autocorrelation function in \cite{paris-atia-vosoughi-berman-2015a} and provide the biophysical interpretation of its parameters. \input{3_Channels/1_NoisyChannels} \input{3_Channels/2_QuantumChannels} \input{\LocalIncludesDir/Figs/04_ARGVZM} \subsection{The Convergence of AR-GVZM, Processes to the GVZM Noise Model}\label{subsec:ARConvergence} We choose some $0 \leqslant k \leqslant K-1$ and let $\upsilon =\upsilon_1 + k\Delta\upsilon$ in \myeq{eq:ARcoeffs}. For small $\Delta t$, we find $a_k = 1-\Delta t / \upsilon$ and $b_k = \sqrt{2\Delta t / \upsilon}$, where we have ignored terms of order higher than $\Delta t$. Defining $\Delta x_k\Paren{n} \overset {\mathrm{def}} = x_k\Paren{n}-x_k\Paren{n-1}$, we easily calculate \mybegeq{eq:dx-dt} \frac{\Delta x_k\Paren{n}}{\Delta t} + \frac{1}{\upsilon}\cdot x_k\Paren{n-1} = \sqrt{\frac{2 P_0}{\upsilon \Delta t}}\cdot e_k\Paren{n}. \end{equation} Let $y_k\Paren{n} \overset {\mathrm{def}} = w_k\cdot x_k\Paren{n}$. Using the definition of $w_k$ in \myeq{eq:ARcoeffs}, \myeq{eq:dx-dt} becomes \[ \frac{\Delta y_k\Paren{n}}{\Delta t} + \frac{1}{\upsilon}\cdot y_k\Paren{n-1} = \sqrt{\frac{2P_0}{\upsilon\cdot\upsilon^{2-\theta}}\Delta\upsilon}\cdot e_k\Paren{n}. \] Now suppose the values $e_k\Paren{n}$ are samples $e_k\Paren{n\Delta t}$ of a continuous-time, iid $N\Paren{0,1}$ process $e_k\Paren{t}$. Then, as $\Delta t \to 0$, $y_k\Paren{n}$ will approach a continuous-time, stationary, Gaussian AR process $y_k\Paren{t}$ satisfying the stochastic differential equation \mybegeq{eq:AR_ODE} \frac{dy_k}{dt} + \frac{1}{\upsilon}\cdot y_k\Paren{t} = \sqrt{\frac{2P_0}{\upsilon\cdot\upsilon^{2-\theta}}\Delta\upsilon}\cdot e_k\Paren{t}. \end{equation} It is well-known \cite{dest-book-2012} that the autocorrelation function of $y_k\Paren{t}$ satisfying \myeq{eq:AR_ODE} is \[ R_k\Paren{\tau} = P_0\,\frac{1}{\upsilon^{2-\theta}}\Exp{-\Abs{\tau}/\upsilon} \Delta\upsilon. \] Using \myeq{eq:ARGVZM}, suppose the values $f_\mathrm{s}\Paren{n}$ are also samples $f_\mathrm{s}\Paren{n\Delta t}$ of a continuous-time, iid $N\Paren{0,1}$ process $f_\mathrm{s}\Paren{t}$ which is independent of all the $e_k\Paren{t}$'s. We observe that the AR-GVZM, processes $x_K\Paren{n}$ in \myeq{eq:ARGVZM} approach a continuous-time, stationary, Gaussian, mixed AR process with autocorrelation function \[ \begin{aligned} R_K\Paren{\tau} = P_0\,\sum\limits_{k=0}^{K-1} \frac{1}{\upsilon^{2-\theta}}\Exp{-\Abs{\tau}/\upsilon}\Delta\upsilon + P_\mathrm{s} \cdot \delta\Paren{t}. \end{aligned} \] Therefore, as $K \to \infty$, the $x_K\Paren{t}$'s themselves will approach a Gaussian process $x_\ast\Paren{t}$ with autocorrelation \mybegeq{eq:R_ARGVZM} R_\ast\Paren{\tau} = P_0 \int\limits_{\upsilon_1}^{\upsilon_2}{\frac{1}{\upsilon^{2-\theta}} \Exp{-\Abs{\tau}/\upsilon} d\upsilon} + P_\mathrm{s} \cdot \delta\Paren{\tau}. \end{equation} It is now easy to check that the PSD function of $x_\ast\Paren{t}$, which is the Fourier transform of $R_\ast\Paren{\tau}$ \cite{oppen-schafer-book-1975}, is given precisely by the formula of Eq. \myeq{eq:SVZM_def}; i.e., the GVZM PSD function. This is a significant result since zero-mean, Gaussian processes are uniquely defined by their autocorrelation function \cite{brockwell-davis-book-1991}. Noting that the GVZM periodogram model implies the autocorrelation must be given by \myeq{eq:R_ARGVZM}, if we make the additional assumption that the EEG noise time series is zero-mean, Gaussian, then that time series \myemph{must} be $x_\ast\Paren{t}$. This means that the AR-GVZM, simulations can be made to approximate EEG background noise with arbitrary precision by means of the double limiting process $\Delta t, \Delta\upsilon \to 0$ described above. Note also that the converse can be proven using methods of \cite{brockwell-davis-book-1991}; that is, if the EEG noise time series is given by limits of AR-GVZM, processes, then the GVZM periodogram model must be valid. This is important for practical applications because it defines the correct statistical model of the periodogram if AR-GVZM, approximations are used to simulate EEG noise. \section{Autoregressive GVZM Simulations of EEG Noise}\label{sec:ARGVZM} The GVZM noise model in \mydef{def:GVZM_model} concerns periodograms and makes no claims about the underlying time domain signal from which they were calculated. In this section, we define a class of mixed autoregressive time series called \textbf{autoregressive GVZM (AR-GVZM) processes}, which are useful simulations of EEG noise and are closely associated with GVZM periodograms. In \mysec{subsec:ARGVZMdef}, we define AR-GVZM processes and show an example based on the parameters derived from recorded data (\myfig{fig:ARGVZM}), in \mysec{subsec:ARConvergence} we connect the asymptotic properties of AR-GVZM, periodograms to the GVZM noise model. \input{4_ARGVZM/1_Def} \input{4_ARGVZM/2_Convergence} \subsection{Set-up and Preprocessing}\label{subsec:Methods} As our data, we used the publicly-available EEG recordings \cite{baka-tana-cich-neuro-let-2010} of four subjects undergoing a series of SSVEP experiments, using a 128-channel Biosemi active-electrode EEG system (\url{http://www.biosemi.com}) sampled at 256 Hz. Each subject experienced 15 25-second trials divided into five trials each of approximately 8 Hz, 16 Hz, and 28 Hz stimulation frequencies. Each 25-second trial consisted of a 5-second pre-stimulation epoch, a 15-second visual stimulation epoch, and a 5-second post-stimulation epoch. Further experimental conditions are presented in \cite{baka-tana-cich-neuro-let-2010}. We preprocessed each epoch separately. Using standard treatments for Biosemi recordings \cite{baka-tana-cich-neuro-let-2010}, quadratic trends in each channel were removed and the central Cz channel (in 10/20-nomenclature was subtracted from all other electrodes. A virtual electrode over the visual cortex was created by averaging the Biosemi-nomenclature electrodes A14, A15, A16, A21, A22, A23, A25, A27, A28, and A29. A virtual electrode close to the eye muscles was created by averaging the frontal 10/20 Fp2, Fpz, and Fp1 electrodes.The visual electrode was linearly regressed onto the eye electrode and the residual was used as the SSVEP response signal. This simple method of removing eyeblink artifacts worked well for our subjects. We excluded the mid-alpha (9.5 Hz--13.5 Hz) and high beta (23.5 Hz--26.5 Hz) non-stationary bands \cite{liavas-moustakides-1998} from all PSD functions, as well as frequencies below 6 Hz and above 50 Hz. This left 614 frequencies per periodogram for testing against the known stimuli. The cumulative distribution functions (CDFs) of the BCI-SNR statistic, required in \mysec{subsec:SNR}, were calculated by bootstrap resampling \cite{efron-tibshirani-1993}. Specifically, for every one of the four subjects, each of their 15 pre-stimulation epochs was independently concatenated to their 15 post-stimulation epochs, yielding 225 sample baseline datasets which were then multiplied by a Tukey window with parameter 0.1 (using the window of \cite{kus-dusyk-etal-2013}). For each baseline, the BCI-SNR statistic was computed using equation Eq. \myeq{eq:SNR} at each of the 614 test frequencies resulting in 614 ``urns'', each urn containing the approximately 225 distinct SNR values which occured at that frequency. For each test frequency, 1000 samples (with replacement) of size 225 were then selected from its urn. Each of these 1000 samples generated its own CDF. Then these 1000 CDFs were averaged to obtain a representative CDF at that frequency. Repeating this procedure at every one of the 614 test frequencies yielded 614 empirical CDFs for each of the four subjects. The smoothed-\textit{F} algorithm \cite{liavas-moustakides-1998} of \mysec{subsec:LM_etal} estimated the expected PSD of the pre-stimulation epoch $x_\mathrm{pre}\Paren{n}$ by the smoothed periodogram approach of \cite{ljung-book-1987}. The circular autocorrelation \cite{oppen-schafer-book-1975} $R_\mathrm{pre}\Paren{m}$ of $x_\mathrm{pre}\Paren{n}$ was computed and then the DFT $S_\mathrm{pre}\Paren{k}$ of the windowed autocorrelation $h\Paren{m} \cdot R_\mathrm{pre}\Paren{m}$ was regarded as the expected PSD. The window $h\Paren{m}$ was a symmetric Hamming window of length $2M+1$, where $M$ is approximately 10\% of the data length of $x_\mathrm{pre}\Paren{n}$. In \cite{liavas-moustakides-1998}, the pre-stimulation data length was specifically chosen to be same as the stimulated epoch $x_\mathrm{stim}\Paren{n}$ so that their respective DFTs $S_\mathrm{pre}\Paren{k}$ and $S_\mathrm{stim}\Paren{k}$ could be compared easily at equal frequency indices $k$. Since our pre-stimulation epochs are shorter than the stimulation epochs, spline interperpolation of $S_\mathrm{pre}\Paren{k}$ was performed to resample it to the larger length. We found that the 10\% smoothed periodogram was sufficiently smooth that such resampling was very accurate. The authors of \cite{liavas-moustakides-1998} time-averaged multiple epochs to improve the SNR prior to detection. This required about 2 minutes of trial data, a very long duration for a practical real-time BCI. For example, the longest epoch used by the well-known and successful SSVEP BCI of \cite{wangs-hong-gaos-2006} was 8 seconds, which was then continuously processed to yield average inter-selection intervals between 3.40 and 5.68 seconds. We therefore tested the GVZM-\textit{F} and smoothed-\textit{F} algorithms on the single-trial, unaveraged epochs of 15 seconds. We performed the paired algorithm comparisons of GVZM-$\chi^2$ vs. BCI-SNR in \mysec{subsec:SNR} and GVZM-\textit{F} vs. smoothed-\textit{F} in \mysec{subsec:LM_etal} by procedures outlined in Appendix B. (See \myfig{fig:SNRTab_ROC}, \myfig{fig:LM_ROC}, \mytable{tab:SNR_vs_GVZM_summary}, and \mytable{tab:LM_vs_GVZM_summary}.) All fits of GVZM PSDs in \mydef{def:GVZM_atan} to actual EEG periodograms, used by both the GVZM-$\chi^2$ and GVZM-\textit{F} algorithms, were obtained by weighted least-squares optimization. We used weights proportional to $f^\beta$, for $\beta \approx 1.5$, where the $f$ are the frequencies over which we are optimizing. We observed that weighting increases the accuracy in the higher frequencies where the signal power is inherently small. Figures displaying spectra and the results of spectral tests show power density $S$ in dB relative to 1; that is $10 \, \mathrm{log}_{10}\Paren{S/1}$. However, all actual critical values have been determined and hypothesis tests were performed in the original units of (amplitude unit)$^2$/Hz. \subsection{Real-time Estimation of SSVEP Responses using the GVZM-$\boldsymbol{\chi^2}$ Algorithm}\label{subsec:GVZM-Chi2} The most direct way to utilize the GVZM noise model in an estimation algorithm is by optimally fitting a GVZM PSD to recorded periodogram and calculating $\Paren{1/2} \, \chi^2\Paren{2}$ critical levels parallel to it. Recall that a GVZM-$\chi^2$-critical level at particular $P$-value is a curve parallel to $S_\mathrm{GVZM}(f)$, showing the power below which periodogram values are confined with probability $1-P$, assuming the GVZM noise model to be correct. The frequencies of any spikes which extend above a pre-assigned $P$-value then are regarded as \myemph{positives}: frequencies at which the GVZM-$\chi^2$ algorithm will report the EEG as having true power, not merely random noise. All others are reported as negatives. In this way, stimulus frequency estimation is implemented by a sequence of hypothesis tests \cite{mood-graybill-boes-book-1974,benjamini-krieger-yekutieli-2006}, one at every frequency we intend to examine. \myfig{fig:chi2_8Hz} and \myfig{fig:chi2_28Hz} show the results of the GVZM-$\chi^2$ algorithm for SSVEP experiments at 8 Hz and 28 Hz respectively (subject 3, trial 2). In particular, according to the GVZM noise model, it is 99.5\% probable that a spectral spike will lie below the upper dashed critical level. These critical levels also display how accurately the GVZM noise model fits the spectra of recorded EEG background processes. It is clear from \myfig{fig:chi2_8Hz} that the GVZM-$\chi^2$ algorithm accurately estimated the 8Hz fundamental SSVEP response and its two harmonics at significance level $P = 0.005$, thus generating no false negatives (also called) Type II errors\cite{mood-graybill-boes-book-1974}). Moreover, it has correctly excluded all other spikes as simply random noise and thus avoided all false positives. (Also called Type I errors \cite{mood-graybill-boes-book-1974} or false discoveries \cite{benjamini-krieger-yekutieli-2006}). In \myfig{fig:chi2_28Hz} the 28 Hz response was estimated accurately however there are several false positives arising, because of non-stationary power in the alpha- and beta-bands (approximately 25 Hz). As discussed in \mysec{subsec:Methods}, such bands need to be pre-excluded from the frequencies to be tested. \subsection{SSVEP Frequency Estimation Using the GVZM-$\chi^2$ and BCI-SNR Algorithms}\label{subsec:SNR} In this section, we describe the BCI-SNR algorithm and compare it to the GVZM-$\chi^2$ algorithm. The BCI-SNR statistic for SSVEP procedures was first defined in \cite{wangs-hong-gaos-2006}, where it was used as a simple measure of signal strength for determining optimal stimulus frequencies. It subsequently became a popular frequency estimator for SSVEP BCIs \cite{kus-dusyk-etal-2013} and more general applications \cite{vialatte-maurice-dauwels-cichocki-2010}. The phrase ``power spectral density analysis'' (PSDA) also has been used \cite{wei-xiao-lu-2011} for methods based on the BCI-SNR. \mybegdef{def:SNR} The BCI-SNR statistic \cite{wangs-hong-gaos-2006} of a signal $x$ at the $k^\mathrm{th}$ test frequency $f_k$ is the ratio \mybegeq{eq:SNR} SNR_x\Paren{f_k} = \frac{n \cdot \hat{S}_x\Paren{f_k}}{\sum\limits_{\substack{j = -n/2 \\ j\ne0}}^{n/2} { \hat{S}_x\Paren{f_k+j\cdot\Delta f} } }, \end{equation} \noindent where $\hat{S}_x$ is an estimator of the sample spectrum, $\Delta f$ is the spectral resolution of the estimated frequency domain, and $n$ is a small integer. To be consistent with \cite{kus-dusyk-etal-2013}, we use $n = 6$. \end{definition} The BCI-SNR statistic is sometimes used as a non-blind detector for a short list $f_1,\ldots, f_K$ of known SSVEP BCI selection frequencies. The subject's selection is considered to be that frequency $f_k$ which has the largest $SNR_x$ value; i.e., $f_{\mathrm{selected}} = \mathrm{argmax}_{f_k} \; SNR_x\Paren{f_k}$. (For example, \cite{wei-xiao-lu-2011,kus-dusyk-etal-2013}.) To use the BCI-SNR algorithm as a blind SSVEP frequency estimator, as described by Appendix B, we require each individual probability distribution function of $SNR_x\Paren{f_k}$ for every test frequency $f_k$. These were estimated by bootstrap resampling as described in \mysec{subsec:Methods}. \input{\LocalIncludesDir/Figs/06_SNRTab_ROC} \myfig{fig:SNRTab_ROC} shows an example of a minimum-variance, unbiased, single-trial estimate of the comparison \myemph{receiver operating characteristics (ROC)} graph \cite{fawcett-2006} as described in Appendix B. The dataset is that of \myfig{fig:RawEEG28Hz} (subject 3, trial 1, 28 Hz stimulus). In \myfig{fig:SNRTab_ROC}, TPR and FPR denote the true and false positive rates, calculated at 256 operating points as detailed in the Appendix. Confusion measures the fractional distance of an operating point from ideal performance TPR = 1, FPR = 0 while the truth rate is a weighted average of the TPR and the true negative rate TNR = (1 - FPR) intended as a measure of accuracy \[\left\{ \begin{aligned} \mathrm{Confusion} &= \sqrt{\Paren{1-\mathrm{TPR}}^2 + \mathrm{FPR}^2} / \sqrt 2 \\ \mathrm{Truth \; Rate} &= \Paren{1-p_0}\cdot\mathrm{TPR} + p_0\cdot\Paren{1-\mathrm{FPR}}, \end{aligned} \right.\] where $0 \leqslant p_0 \leqslant 1$. In a Bayesian situation, with $p_0$ the probability of the null hypothesis \cite{mood-graybill-boes-book-1974}, the truth rate is the probability of a true decision. We assume $p_0 = 1/2$. We observe that the GVZM-$\chi^2$ algorithm outperforms the BCI-SNR algorithm at nearly every operating point. Moreover, even on this very difficult 28Hz stimulus, the optimal operating point for GVZM-$\chi^2$ identifies the true stimulus frequency with probability above 90\% with FPR below 20\%. \input{\LocalIncludesDir/Tables/SNR_vs_GVZM_summary} \mytable{tab:SNR_vs_GVZM_summary} summarizes the pooled ROC results for $N = 34$ trials, in which at least one of the algorithms had confusion below 35\% (``unconfused'' trials by definition). Pooled SE denotes the standard error \[ \mathrm{Pooled \; SE} =\sqrt{\Paren{\sigma_\mathrm{GVZM}^2 + \sigma_\mathrm{SNR}^2} / N} \] appropriate to the \textit{t}-test for the difference of means. \mytable{tab:SNR_vs_GVZM_summary} shows that the GVZM-$\chi^2$ algorithm outperforms the BCI-SNR algorithm on both the confusion and truth rate measures with statistical significance above 99\%. \subsection{SSVEP Frequency Estimation Using the GVZM-\textit{F} and Smoothed-\textit{F} Algorithms}\label{subsec:LM_etal} In \cite{liavas-moustakides-1998}, the authors assume, based on the theory of periodograms developed in detail in \cite{brockwell-davis-book-1991}, that the periodogram random process $S_x\Paren{k}$, $0 \leqslant k \leqslant N-1$ of the EEG background time series $x\Paren{n}$ is given asymptotically by \mybegeq{eq:Liavas_etal} S_x\Paren{k} = \mathsf{E}\Brack{S_x\Paren{k}} \cdot \Paren{1/2} \, \Xi \Paren{k}, \end{equation} where $\Xi\Paren{k}$, $0 \leqslant k \leqslant N-1$ is a process with $\Xi\Paren{k} \sim \chi^2\Paren{2}$ and which are independent for $0 \leqslant k, l < N/2$ with $k \ne l$. If the function $\mathsf{E}\Brack{S_x\Paren{k}}$ were known, then \myeq{eq:Liavas_etal} implies that the test statistics \[ s_x\Paren{k} \overset {\mathrm{def}} = 2 \cdot S_x\Paren{k} / \,\mathsf{E}\Brack{S_x\Paren{k}} \] for $0 \leqslant k \leqslant N-1$ would be iid $\chi^2\Paren{2}$ random variables. A fixed set of indices $\Omega \subseteq \Curly{0,1,\cdots,N-1}$ is selected to represent what we regard as stationary frequencies; e.g., alpha-band frequencies are excluded (cf. \mysec{subsec:Methods}). Then, under the null hypothesis that there is no SSVEP spike at frequency index $k_\mathrm{test}$ we have \begin{align}\label{eq:F-stat} &\frac {\sum_{k \in \Omega_\mathrm{test}} {\! s_x\Paren{k}} \;/\; N_\mathrm{test}} { \sum_{k' \in \Omega \setminus \Omega_\mathrm{test}} {\! s_x\Paren{k'}} \;/ \Paren{N_\Omega - N_\mathrm{test}}} \\ &\qquad\qquad\qquad\qquad \sim F\Paren{N_\mathrm{test}, N_\Omega - N_\mathrm{test}}\nonumber, \end{align} where $\Omega_\mathrm{test}$ is the set of indices $k_\mathrm{test}$ and its harmonics in $\Omega$, $N_\mathrm{test}$ is the size of $\Omega_\mathrm{test}$, $N_\Omega$ the size of $\Omega$, and $F\Paren{d_1,d_2}$ is the $F$--distribution with degrees of freedom $d_1, \, d_2$ \cite{mood-graybill-boes-book-1974}. The key issue is how to obtain the function $\mathsf{E}\Brack{S_x\Paren{k}}$. In \cite{liavas-moustakides-1998}, the authors estimated this function by computing a ``smoothed periodogram'' $S_\textrm{smooth}\Paren{k}$ of a pre-stimulation epoch as described in \mysec{subsec:Methods} and used $S_\textrm{smooth}\Paren{k}$ as a substitute for $\mathsf{E}\Brack{S_x\Paren{k}}$. This constituted their smoothed-\textit{F} algorithm. However, by using the GVZM noise model, we expect to obtain a more accurate baseline estimate by using the GVZM PSD which optimally fits the same pre-stimulus epoch as a substitute for $\mathsf{E}\Brack{S_x\Paren{k}}$. This is our GZVM-\textit{F} algorithm. \myfig{fig:baseline_28Hz} shows the periodogram from the pre-stimulus epoch of the data of \myfig{fig:RawEEG28Hz} (subject 3, trial 1, 28Hz stimulus) with both the smoothed periodogram and the fitted GVZM PSD displayed. The two algorithms are compared as described in Appendix B. \myfig{fig:LM_ROC} shows an example of a minimum-variance, unbiased, single-trial estimate of the comparison ROC graph. \input{\LocalIncludesDir/Figs/07_baseline_28Hz} The dataset is that of \myfig{fig:RawEEG28Hz} (subject 3, trial 1, 28 Hz stimulus). As in \mysec{subsec:SNR}, the GVZM-\textit{F} algorithm outperforms the smoothed-\textit{F} algorithm at nearly every operating point, achieving an optimal performance of over 95\% probability of true identification with just above 20\% FPR. \input{\LocalIncludesDir/Tables/LM_vs_GVZM_summary} \mytable{tab:LM_vs_GVZM_summary} summarizes the pooled ROC results as described in Appendix B for the 56 trials in which at least one of the algorithms had confusion below 35\%. The large number of unconfused trials of these algorithms is a result of the inherent stability of the carefully-designed underlying statistic \myeq{eq:F-stat}. \mytable{tab:LM_vs_GVZM_summary} shows that GVZM-\textit{F} algorithm outperforms the smoothed-\textit{F} algorithm on both the confusion and accuracy measures with statistical significance above 99\%. \input{\LocalIncludesDir/Figs/08_LM_ROC} \section{Real-time BCI Algorithms and EEG Noise}\label{sec:SSVEP} In this section, we explore two new SSVEP frequency estimation algorithms we have designed, based on the GVZM noise model, which we refer to as \textbf{GVZM-}$\boldsymbol{\chi^2}$ and the \textbf{GVZM-}$\boldsymbol{F}$. We evaluate the performance of the new algorithms by comparing each with an existing, commonly-used procedure (to be be described later). Our statistical analysis demonstates that the GVZM-based algorithms outperform both their rivals. In \mysec{subsec:GVZM-Chi2} we examine the GVZM-$\chi^2$ algorithm, which is based on GVZM-$\chi^2$\textbf{-critical levels} for the EEG periodogram. These critical levels are curves drawn on the graph of the periodogram, which are parallel to the GVZM spectrum $S_\mathrm{GVZM}\Paren{f}$ defined in \mysec{subsec:GVZM_def}. Each represents the PSD level beneath which a random $S_\mathrm{GVZM}\Paren{f}\cdot\Paren{1/2}\chi^2\Paren{2}$ variable should remain, with specified probability (see \myfig{fig:chi2_8Hz} and \myfig{fig:chi2_28Hz} for examples of GVZM-$\chi^2$-critical levels.) In \mysec{subsec:SNR}, we perform a statistical performance comparison of GVZM-$\chi^2$ against a commonly-used BCI algorithm \cite{wangs-hong-gaos-2006,wei-xiao-lu-2011,kus-dusyk-etal-2013} we refer to as \textbf{BCI-SNR}. Note that BCI-SNR is based on forming certain ratios of periodogram values around the frequencies that are being tested as SSVEP stimuli (see \mydef{def:SNR} in \mysec{subsec:SNR}). \mysec{subsec:LM_etal} implements two versions of the well-known periodogram $F$-test frequency estimation method used in \cite{liavas-moustakides-1998,baka-tana-cich-neuro-let-2010}. The first version, which we call the \textbf{smoothed-\textit{F}} algorithm, is a direct implementation of \cite{liavas-moustakides-1998}. The second version, which we call the \textbf{GVZM-\textit{F}} algorithm, replaces a key data-estimated periodogram with the optimally-fitting GVZM PSD and making no other alterations. We compare the performance of the GVZM-\textit{F} and the smoothed-\textit{F} algorithms statistically. All four algorithms are used as SSVEP frequency estimators according to the protocol described in Appendix B. This Appendix also describes the procedures we used to generate the summary data statistics in \mytable{tab:SNR_vs_GVZM_summary} and \mytable{tab:LM_vs_GVZM_summary}. \input{5_SSVEP/1_Methods} \input{5_SSVEP/2_GVZMChi2} \input{5_SSVEP/3_SNR} \input{5_SSVEP/4_LM_etal} \section{Conclusions}\label{sec:Summary} In this paper, we showed the necessity of accurate statistical models of EEG background noise for applications to neuroscience, neurology, and real-time BCIs. Based on our analysis and numerical experiments, we proposed a specific, five-parameter statistical family of EEG background periodograms using the GVZM PSD function. To the best of our knowledge, the GVZM PSD function is the only EEG noise PSD model with a fixed number of parameters, matches recorded EEG PSD's with high accuracy over the full spectrum from 0 Hz to 30 Hz, and has approximately $1/f^\theta$ behavior in the mid-frequencies without infinities. We validated this model using three complementary approaches. First, we briefly discussed our theoretical work \cite{paris-atia-vosoughi-berman-2015a} on neurological ion channels and quantum stochastic processes and noted that this theory implies the applicability of the GVZM PSD function to large networks of ion channels in maximum entropy statistical equilibrium. Second, we presented a class of time series we call AR-GVZM, processes which simulate EEG background noise. We showed that the periodograms of AR-GVZM, processes approach the GVZM PSD function as the number of subprocesses becomes large. Third, we designed two algorithms to estimate SSVEP frequencies for real-time BCI applications and applied them to a public set of SSVEP recorded data. We showed statistically that both GVZM-based algorithms were more accurate than two commonly used alternatives, even on difficult data. We conclude that the GVZM noise model accurately characterizes the statistics of EEG background periodograms and, therefore, is a very suitable model for algorithm design, brain signal simulation, and neuroscience investigations. In addition, we believe our applied results indirectly validate quantum ion channel maximum entropy analysis, which is the theoretical foundation of the GVZM noise model. \subsection{The Periodogram Distribution of Periodic ARMA Processes}\label{sec:ARMA_N} \mybegdef{def:N_ARMA} A periodic Gaussian $\boldsymbol{ARMA\Paren{P,Q,N}}$ \myemph{process} is a zero-mean, stationary random process $\Curly{x\Paren{n}}_{n = -\infty}^\infty$ satisfying \mybegeq{eq:ARMA_N} \sum_{p = 0}^P{a_p \, x\Paren{n-p}} = \sum_{q = 0}^Q{b_q \, \nu\Paren{n-q}}, \end{equation} \noindent where $a_0 = b_0 = 1$ and $\Curly{\nu\Paren{n}}_{n = -\infty}^\infty$ is an iid, zero-mean, Gaussian process which is $N$-periodic: $\nu\Paren{n+N} = \nu\Paren{n}$, for all $n$, and the polynomials $A\Paren{z} = \sum_{p=0}^P{a_p z^p}$ and $B\Paren{z} = \sum_{q=0}^Q{b_q z^q}$ have no common zeros. The equality in the periodicity condition is meant to be exact; i.e., there are really only $N$ distinct random processes $\nu\Paren{0}, \ldots, \nu\Paren{N-1}$. \end{definition} \mybegdef{} An $ARMA\Paren{P,Q,N}$ system is \myemph{causal} \cite{brockwell-davis-book-1991} if the polynomial $A\Paren{z}$ defined above has no zeros on or inside the unit circle. \end{definition} \mybegthm{thm:ChiTwo} Let $x\Paren{0}, \ldots, x\Paren{N-1}$ be one period of a causal Gaussian $ARMA\Paren{P,Q,N}$ process and let $S_x\Paren{k}$, $0 \leqslant k \leqslant N-1$, be its periodogram (\mydef{def:periodogram}). Then \[ S_x\Paren{k} = 2\pi \sigma_\nu^2 \cdot \frac{\Abs{B\Paren{\Exp{-i\Paren{2\pi k/N}}}}^2}{\Abs{A\Paren{\Exp{-i\Paren{2\pi k/N}}}}^2} \cdot \Paren{1/2} \, \Xi\Paren{k}, \] \noindent where $\Xi\Paren{k}$, $0 \leqslant k \leqslant N-1$, is a sequence of $\chi^2\Paren{2}$ distributed \cite{mood-graybill-boes-book-1974} random variables which are independent for $0 \leqslant k, l < N/2$ when $k \ne l$ and $\sigma_\nu^2$ is the variance of $\nu\Paren{n}$ . \end{theorem} Because of space limitations, we omit the proof of this result, which is a simple application of the techniques of \cite{brockwell-davis-book-1991}. \subsection{Comparison and Validation Metrics for SSVEP Algorithms}\label{subsec:ROC} The following section presents a preview of an innovative, statististically sound, and extremely flexible methodology we developed specifically for the comparison and validation of SSVEP algorithms. It forms the foundation for the single-trial receiver operating characterstics (ROC) graph of \myfig{fig:SNRTab_ROC} and \myfig{fig:LM_ROC} and the summary statistics of \mytable{tab:SNR_vs_GVZM_summary} and \mytable{tab:LM_vs_GVZM_summary}. The details will be published separately. } \subsection{Comparison Protocols for SSVEP Estimation Algorithms}\label{subsec:Protocols} To simplify analysis of the algorithms of \mysec{sec:SSVEP}, all four were reduced to a common $m$-ary test \cite{benjamini-krieger-yekutieli-2006} protocol, outlined by the flow chart \myfig{fig:CTchart}. Every $f \in F_\mathrm{test}$ in a given set of \myemph{test frequencies} is to be independently judged by the algorithm for its presence or absence as an SSVEP stimulus in the experimental periodogram $S$. No constraint is placed on the number of test frequencies $f \in F_\mathrm{test}$ the algorithm may report as present (positives, P), absent (negatives, N), or undetermined (u). Both pairs in a comparison (GVZM-$\chi^2$ vs. BCI-SNR and GVZM-$F$ vs. smoothed-$F$) are tested against the same \myemph{ground truth}, which has access to the true SSVEP stimulus frequencies and possible harmonics for this experiment. Each algorithm is characterized by a \myemph{test statistic} $X\Paren{\boldsymbol{\mathrm{S}},f}$ with CDFs \[ P_X\Paren{x,f} \overset {\mathrm{def}} = \mathsf{Prob}\Brack{X\Paren{\boldsymbol{\mathrm{S}},f} \leqslant x}, \] where $\boldsymbol{\mathrm{S}}$ is a random variable varying over all possible periodograms that $X\Paren{\, \cdot \,,f}$ could receive ($S$ is a particular value of $\boldsymbol{\mathrm{S}}$). We assume that the larger the value of $X\Paren{\boldsymbol{\mathrm{S}},f}$, the more likely $f$ is a stimulus frequency. \textbf{GVZM-$\boldsymbol{\chi^2}$}: $X\Paren{\boldsymbol{\mathrm{S}},f} = \boldsymbol{\mathrm{S}}\Paren{f}/S_\mathrm{GVZM}\Paren{f}$ and $P_X\Paren{x,f}$ is given by the inverse $\Paren{1/2}\cdot\chi^2\Paren{2}$ distribution (see Eq. \myeq{eq:GVZM_process}). \textbf{BCI-SNR}: $X\Paren{\boldsymbol{\mathrm{S}},f}$ is given by Eq. \myeq{eq:SNR} and the CDFs are obtained empirically by bootstrap resampling as described in \mysec{subsec:Methods}. \textbf{GVZM-\textit{F}}: $X\Paren{\boldsymbol{\mathrm{S}},f}$ is the ratio Eq. \myeq{eq:F-stat}, with $\mathsf{E}\Brack{S_x\Paren{k}}$ the GVZM fit to the baseline data. The CDFs are the inverse \textit{F} distribution with appropriate degrees of freedom. \textbf{smoothed-\textit{F}}: $X\Paren{\boldsymbol{\mathrm{S}},f}$ is the ratio Eq. \myeq{eq:F-stat}, with $\mathsf{E}\Brack{S_x\Paren{k}}$ the smoothed periodogram of \cite{ljung-book-1987}.The CDFs are the inverse \textit{F} distribution with appropriate degrees of freedom. Let $0 \leqslant \alpha \leqslant 1$ be the \myemph{1-ary significance level}. The $\boldsymbol{\alpha^p}$\myemph{-urn} for $X\Paren{\boldsymbol{\mathrm{S}},f}$ is a conceptual container of paired values $x_0 \leqslant x_1$ whose likelihood of occurrence is determined by $P_X\Paren{x,f}$. The $\boldsymbol{\alpha^p}$\myemph{-urn test} is the following randomized procedure: Calculate $X\Paren{\boldsymbol{\mathrm{S}},f}$ and independently select a pair $x_0, x_1$ from the $\alpha^p$-urn. Then $f$ is adjudged present in $\boldsymbol{\mathrm{S}}$ if $X\Paren{\boldsymbol{\mathrm{S}},f} \geqslant x_1$, absent if $X\Paren{\boldsymbol{\mathrm{S}},f} < x_0$, and undetermined otherwise. Ground truth answers questions about binary hypotheses $H_0\Paren{f},H_\mathrm{a}\Paren{f}$, where the null hypothsis $H_0\Paren{f}$ is: frequency $f$ is not an SSVEP stimulus. It may fail to answer, which we symbololize in \myfig{fig:CTchart} by ``$h\Paren{f}$''. Since no estimation algorithm can be 100\% accurate, ground truth must contain a parameter $\delta f$ which determines how much error $\Abs{f - f_\mathrm{ssvep}}$ it will tolerate between a test frequency $f$ and a known stimulus or harmonic frequency $ f_\mathrm{ssvep}$. We have found SSVEP estimation to be very sensitive to $\delta f$ and its optimal value must be determined for each subject during pre-test training. With these definitions, the \myemph{single-trial contingency table} $CT\Paren{\boldsymbol{\mathrm{S}}}$ can be calculated as shown in \myfig{fig:CTchart}. Note that multiple true positives are possible, even with a single stimulus frequency $f_\mathrm{ssvep}$, both because ground truth may report harmonics of $f_\mathrm{ssvep}$ and because the resolution $\delta f > 0$ must report test frequencies in an interval around $f_\mathrm{ssvep}$. When a particular periodogram $\boldsymbol{\mathrm{S}} = S$ is analyzed, the conditional expectation $\overline{CT}\Paren{S} \overset {\mathrm{def}} = \mathsf{E}\Brack{CT\Paren{\, \cdot \,} \; | \; S}$, which is known to be the minimum variance unbiased estimator of $CT\Paren{\, \cdot \,}$ \cite{mood-graybill-boes-book-1974}, can be calculated. From the cells of $\overline{CT}\Paren{S}$ , we can derive the TPR and FPR (\mysec{subsec:SNR}) as $\mathrm{TPR} \overset {\mathrm{def}} = \mathrm{TP} / N_\mathrm{a}$, $\mathrm{FPR} \overset {\mathrm{def}} = \mathrm{FP} / N_0$, where TP, FP are the number of true and false positives and $N_\mathrm{a}$,$N_0$ are the number of true hypotheses $H_\mathrm{a}$,$H_0$ respectively. As seen in \myfig{fig:CTchart}, the estimator $\overline{CT}\Paren{\alpha,\delta f; S}$ depends on the parameters $\alpha,\delta f$. By varying these, we can plot the resulting operating points $\Paren{\mathrm{FPR}\Paren{\alpha,\delta f},\mathrm{TPR}\Paren{\alpha,\delta f}}$ on a \myemph{single-trial ROC} graph \cite{fawcett-2006}. The ROC determines the optimal values of $\alpha,\delta f$ for the periodogram $S$. \myfig{fig:SNRTab_ROC} and \myfig{fig:LM_ROC} show the operating points of 256 choices of $\alpha,\delta f$ for the various algorithms, on the \myfig{fig:RawEEG28Hz} periodogram, as well as the optimal operating points according to the two accuracy measures described in \mysec{subsec:SNR}. By creating single-trial ROCs for all periodograms $S$ in an experiment, the statistical distribution of optimal accuracy measures can be inferred. \mytable{tab:SNR_vs_GVZM_summary} and \mytable{tab:LM_vs_GVZM_summary} show the analysis of $N = 12$ optimal operating point measures corresponding to the three subjects and four possible stimulus frequencies, each of which were tested in five trials (\mysec{subsec:Methods}). \section{Appendices}\label{sec:Appendices} Appendix A presents the background for a useful class of random processes we call $ARMA(P,Q,N)$ processes which provide motivation for the GVZM model of \mysec{sec:GVZM}. Appendix B is an overview of the statistical methodology used for the algorithm comparisons of \mysec{sec:SSVEP}. \input{\LocalIncludesDir/Figs/09_CTchart} \input{7_Appendix/A_ARMA_N} \input{7_Appendix/B_Protocols} \subsection{Neurological Noise Research: Background and Motivation}\label{subsec:Introduction} \IEEEPARstart{S}{ignals} recorded from living neurological tissue are extremely noisy at all scales from individual ion channels \cite{hill-chen-IV-1972} through collections of one or more neurons \cite{manwani-koch-I-1999,hille-book-2001,diba-lester-koch-2004} up to scalp-recorded EEGs \cite{nunez-srin-book-2006} (\myfig{fig:RawEEG28Hz}). As a result, the theory of neurological noise continues to be a thriving area for research \cite{dest-book-2012}, with theoretical and practical implications for neurological signal processing and neurology. In this paper we examine the statistical characteristics of EEG periodograms \cite{oppen-schafer-book-1975,brockwell-davis-book-1991}. Specifically, we present a new model for the statistical properties of EEG background processes which, for the purpose of many applications, may be regarded as ``brain noise''. To the best of our knowledge, it is the first simple and general noise model in the EEG literature which closely matches recorded EEG periodograms from near 0 Hz to over 30 Hz. We then validate this new model using three different and complementary approaches. Our research on neurological noise is inspired by three main goals: $\bullet$ \emph{To improve the performance of real-time neurological algorithms:} Certain neurological signal processing tasks, such as extracting event-related potentials (ERPs), increase signal-to-noise ratios (SNRs) by averaging many epochs of data recorded over long experimental periods \cite{luck-book-2014}. However, time-frequency algorithms, which assume high levels of nonstationarity \cite{rankin-etal-2007}, and BCIs \cite{wangs-hong-gaos-2006,allison-et-al-2008}, which are meant to provide disabled patients with a sense of real-time control, must work with much shorter, single-trial epochs. Ordinary linear filtering of such short epochs is problematic, since there is evidence that the brain's responses are highly nonlinear \cite{tetz-etal-2006}, and because the target signals can be nearly indistinguishable from the background (cf. \myfig{fig:RawEEG28Hz}). Moreover, poorly-fitting models of the detailed statistical characteristics of brain processes reduces the precision of detection/estimation procedures and makes model validation uncertain. We are particularly interested in developing real-time SSVEP BCI algorithms which are accurate into the $\gamma$-band, a region of the EEG spectrum which is dominated by noise. $\bullet$ \emph{To create statistically-realistic simulations of neurological signals:} The common practice is to add artificial noise sources to neurological simulations in order to increase their realism and to measure the performance of models and algorithms \cite{diba-lester-koch-2004}. Good simulations of neurological signals are essential for development and testing of medical and BCI algorithms. This is especially true for critical applications to human neurology \cite{tetz-etal-2006,rankin-etal-2007} for which experimentation is highly restricted. $\bullet$ \emph{To create new insight into the underlying neurological processes:} Statistical models of neurological noise have had remarkable success in providing indirect tests of neuroscience hypotheses. This was spectacularly true for the elucidation of the acetycholine neurotransmission mechanisms in the 1970's by Katz \& Miledi \cite{katz-miledi-1972}. But noise models continue to enhance our understanding of neurological illness \cite{diez-etal-2013, vysata-etal-2014}, cognitive processes \cite{legenstein-maass-2014}, and may even explain brain nonlinearity \cite{miller-troyer-2002}. We believe that the theory of neurological noise processes will play an increasingly important role in interpreting the behavior of the billions of neurons and trillions of ion channels in large-scale, biological brain networks. \subsection{Steady-State Visual Evoked Potential BCIs}\label{subsec:SSVEP_def} Sudden stimuli such as a touch, a sound, or a bright flash will elicit a detectable brain reaction called an \myemph{event-related potential} \cite{luck-book-2014} or \myemph{evoked potential} (EP). Such EPs typically last on the order of 500 ms before disappearing, and usually may be reinvoked after a short refractory period. However, if the stimuli are repeated at a regular rate faster than about 2Hz, the EPs will not have time to decay and the brain's reaction will be a periodic signal called a \myemph{steady-state evoked potential} whose fundamental frequency is the same as the stimulus'. In particular, periodic visual stimuli will cause an SSVEP \cite{vialatte-maurice-dauwels-cichocki-2010}. These stimulus-dependent brain frequencies can be used to control BCIs \cite{allison-et-al-2008}, by flashing lights at various distinct frequencies simultaneously in different locations on a computer screen or LED device. The strongest SSVEP response peak detected corresponds to the location on which the subject's attention was most focused and usually represents the selection. Low frequency visual stimuli also induce harmonics \cite{herrmann-2001} (cf. \myfig{fig:chi2_8Hz}) which also may be used for BCI detection \cite{SSVEP-BCI-harmonics-2005}. Thus the corresponding subject selections can be identified by simple algorithms. It is worth remarking that such harmonic responses prove conclusively that the brain is a nonlinear system since pure linear systems cannot generate harmonics. On the other hand, higher frequencies, especially those which approach the gamma-band above 30 Hz, are much more difficult to detect, because their response power is close to that of the background and all harmonics (if they exist at all) and are lost in the gamma-band noise. This is seen most clearly in \myfig{fig:RawEEG28Hz}, which shows a 28 Hz brain response almost indistinguishable from background noise. (However, note that our new GVZM-based algorithms in \mysec{sec:SSVEP} detect the 28 Hz peak even in this difficult data set.) \subsection{Modeling EEG Noise and Noise Power Spectral Densities}\label{subsec:SSVEP_SFT} EEG noise has often been modeled using PSDs \cite{oppen-schafer-book-1975,brockwell-davis-book-1991} that are power law functions \cite{mandelbrot-book-1999a,miller-troyer-2002} of the form $S(f) \propto 1/f^\theta$ for some $0 \leqslant \theta < 2$. Neurological noise PSDs at all scales have long been claimed \cite{hill-chen-IV-1972,linkenhaer-hansen-etal-2001,diba-lester-koch-2004} to have the general characteristics of such ``$1/f$--type noise'' \cite{mandelbrot-book-1999a} even though this claim implies the obvious paradox of infinite total power in a biological system. Also, autoregressive (AR) \cite{allison-et-al-2008} and autoregressive-moving average (ARMA) models of \cite{brockwell-davis-book-1991} of EEG recordings are very commonly used, in particular to simulate noise for the SSVEP detection algorithm \cite{liavas-moustakides-1998}. Such models are useful approximations but yield PSDs which are rational functions and are more appropriate to stationary, linear systems. However, brain signals are known to be neither stationary \cite{rankin-etal-2007} nor linear \cite{miller-troyer-2002}. A useful approach has been to model the statistical variations of noise periodograms around their mean PSD. In many cases, the periodogram values $S_x\Paren{k}$ of a discrete-time random process $x\Paren{n}$ are independent, scaled $\chi^2\Paren{2}$ random variables \cite{mood-graybill-boes-book-1974}, whose expected value $\mathsf{E}\Brack{S_x\Paren{k}}$ gives the mean spectral power at the frequency index $k$ \cite{brockwell-davis-book-1991}. This result holds exactly for many important special cases, such as white Gaussian noise and causal periodic ARMA processes. (See Appendix A for the definition.) In more general situations, the $\chi^2\Paren{2}$ distribution is approached only asymptotically as the data length increases, however the result still has very broad applicability \cite{brockwell-davis-book-1991}. The idea of detecting SSVEP responses for BCI applications by performing statistical testing of the periodogram (often called the Spectral \textit{F}-Test (SFT)) was developed by several research groups in the mid-90's \cite{sa-infantosi-lazarev-2007} and is based on ``hidden periodicity'' methods dating back to the 40's \cite{brockwell-davis-book-1991}. The idea has been used regularly, most notably in \cite{liavas-moustakides-1998,baka-tana-cich-neuro-let-2010} which enhanced the flexibility of the original SFT procedure. \subsection{Contributions and Paper Organization}\label{subsec:Contributions} The central innovation of this article is a new statistical model of the discrete Fourier transform (DFT) periodograms \cite{oppen-schafer-book-1975} of EEG noise processes, the so-called GVZM noise model. We validate this model via three distinct approaches: (i) developing a neurological noise model based on quantum mechanical ion channel kinetics, (ii) linking autoregressive time series to the GVZM noise model and EEG noise, (iii) and designing and evaluating two real-time SSVEP BCI estimation algorithms, based on the new GVZM noise model. Our contributions can be summarized as the following $\bullet$ We introduce a novel, five-parameter GVZM PSD function, and we show that this function accurately matches the PSD function of recorded EEG noise, from near 0 Hz to 30 Hz. Also, we show that this function is approximately of the form $1/f^\theta$ in the mid-frequencies but has finite total power and finite amplitude as $f \to 0$. We provide a biophysical meaning of the function parameters and indicate how the function can be derived from a theory of ion channel noise. $\bullet$ We use the GVZM PSD function to define a new statistical model of the DFT periodgrams of EEG noise processes, which we call the GVZM noise model. We show that this model successfully captures the statistics of EEG periodograms, allows rigorous statistical testing, detection, and estimation, and enables statistically accurate simulations of EEG noise periodograms. $\bullet$ We define a class of mixed autoregressive (AR) time series, which we call AR-GVZM processes, containing accurate simulations of EEG noise time series, and whose PSD functions converge asymptotically to the GVZM PSD function (GVZM noise model). We show also that, if recorded EEG noise is assumed to be Gaussian and satisfies the GVZM noise model, it can be approximated arbitrarily closely by AR-GVZM processes. $\bullet$ We define two new SSVEP frequency estimation algorithms based on the GVZM noise model: a simple $\chi^2$-distribution detection algorithm for frequency spikes and a more sophisticated, $F$-distribution estimator based on the well-known algorithm in \cite{liavas-moustakides-1998}. We demonstrate statistically that these algorithms outperform two well-known rivals \cite{vialatte-maurice-dauwels-cichocki-2010,wei-xiao-lu-2011,kus-dusyk-etal-2013}, thus providing evidence for the truth of our noise model. The practical success of the GVZM noise model provides indirect validation of the underlying ion channel noise model from which it was developed. The remainder of this paper is organized as follows: \mysec{sec:GVZM} introduces the GVZM PSD function, defines the GVZM noise model, and discusses the behavior of the GVZM PSD function. \mysec{sec:Channels} briefly summarizes the results of the theory of quantum-controlled ion channels. \mysec{sec:ARGVZM} introduces AR-GVZM processes and discusses their link to GVZM noise model and EEG noise. \mysec{sec:SSVEP} describes and compares statistically two GVZM-based SSVEP algorithms and two rival SSVEP estimators. \mysec{sec:Summary} presents our conclusions. \section{Introduction}\label{sec:Overview} \input{1_Intro/1_Introduction} \input{1_Intro/2_SSVEP_BCI} \input{1_Intro/3_SSVEP_SFT} \input{1_Intro/4_ContributionsOutline} \subsection{Defining the Periodogram}\label{subsec:Periodograms} \mybegdef{def:periodogram} For the purpose of this article, the single-epoch \myemph{periodogram} of a discrete-time signal $x\Paren{n}$, $0 \leqslant n \leqslant N-1$, is defined as \[ S_x\Paren{k} \overset {\mathrm{def}} = \frac{2\pi}{N} \Abs{X\Paren{k}}^2, \;\; 0 \leqslant k \leqslant N-1, \] \noindent where $X\Paren{k} \overset {\mathrm{def}} = \sum_{n = 0}^{N-1} {x\Paren{n} \; \Exp{-i \Paren{2\pi/N}kn } } $ is the DFT of $x\Paren{n}$ \cite{oppen-schafer-book-1975}. The factor $2\pi$ is present to convert $S_x\Paren{k}$ to dimension amplitude$^2$/frequency, where frequency has dimension 1/time, not angle/time; i.e., units of Hz rather than radians/sec. \end{definition} \subsection{Defining the GVZM PSD Function}\label{subsec:GVZM_def} \mybegdef{def:GVZM_atan} The \myemph{GVZM PSD} $S_\mathrm{GVZM}\Paren{f}$ is the family of functions with five parameters $0 < \theta < 2$, $0 < \upsilon_1 < \upsilon_2$, $P_0 \geqslant 0$, $P_\mathrm{s} \geqslant 0$ and defined by \begin{align}\label{eq:SVZM_def} S_\mathrm{GVZM}\Paren{f} \overset {\mathrm{def}} = P_0 \Abs{f}^{-\theta} &\Paren{\mathrm{tan}^{-1}_\theta\Paren{2\pi \upsilon_2 \Abs{f}} \right. \nonumber\\ &\quad\left. - \mathrm{tan}^{-1}_\theta\Paren{2\pi \upsilon_1 \Abs{f}} } + P_\mathrm{s}, \end{align} where \mybegeq{eq:atan_def} \mathrm{tan}^{-1}_\theta\Paren{x} \overset {\mathrm{def}} = \mathrm{sgn}\Paren{x} \int\limits_0^{\Abs{x}} { \frac{u^{\theta-1}}{1+u^2} du}. \end{equation} \end{definition} Note that for $\theta = 1$, Eq. \myeq{eq:atan_def} is the ordinary $\mathrm{arctan}\Paren{x}$ (cf. \myfig{fig:atan}). The dimension of $\upsilon_1$, $\upsilon_2$ is time while that of $P_0$, $P_\mathrm{s}$ is amplitude$^2$/frequency (i.e., noise power). The spectral exponent $\theta$ is dimensionless. The biophysical meaning of these parameters is described in \mysec{subsec:QuantumChannels}. The importance of this definition is that, so far as the authors are aware, this is the first simple model of the average EEG background noise spectrum proposed in the literature which can match recorded EEG periodograms from near 0 Hz to over 30 Hz, with a fixed number of parameters. Moreover, the GVZM PSD function approximates a power law $1/f^\theta$ in the mid-frequencies without requiring infinite power. In fact, $S_\mathrm{GVZM}\Paren{f}$ always has finite amplitude and finite total power. In the next section, the GVZM PSD will be used to define a statistical model of EEG periodograms, the core of our work and the basis of the new SSVEP algorithms in \mysec{sec:SSVEP}. \subsection{The GVZM Noise Model}\label{subsec:GVZM_model} \mybegdef{def:GVZM_model} Let $x\Paren{n}$, $0 \leqslant n \leqslant N-1$ be samples of an EEG electrode, taken at sampling frequency $f_\mathrm{samp}$, which measures a naturally-occuring, stationary ensemble of brain background processes for a single individual. Then the \textbf{GVZM noise model} of the periodogram values $S_x\Paren{k}$, $0 \leqslant k \leqslant N-1$ is the random process \mybegeq{eq:GVZM_process} S_x\Paren{k} = S_\mathrm{GVZM}\Paren{ k \Delta f} \cdot \Paren{1/2} \, \Xi\Paren{k}, \end{equation} \noindent where $\Xi\Paren{k}$ is a sequence of $\chi^2\Paren{2}$ distributed \cite{mood-graybill-boes-book-1974} random variables, which are independent for $0 \leqslant k, l < N/2$ when $k \ne l$, $\Delta f \overset {\mathrm{def}} = f_\mathrm{samp} / N$, and $S_\mathrm{GVZM}\Paren{f}$ is an appropriate GVZM PSD defined by \myeq{eq:SVZM_def}. \end{definition} Note that the reason for the restriction of independence to $0 \leqslant k, l < N/2$ is that, since $x\Paren{\, \cdot \,}$ is real, we have $S_x\Paren{N-k} = S_x\Paren{k}$. Also note that the half-interval definition $0 \leqslant k, l < N/2$ applies whether $N$ is even or odd. We can write \myeq{eq:GVZM_process} informally as \[ S_x\Paren{k} \sim S_\mathrm{GVZM}\Paren{ k \Delta f} \cdot \Paren{1/2} \, \chi^2\Paren{2}, \] where $\sim$ denotes ``is distributed as.'' The $\Paren{1/2} \, \chi^2\Paren{2}$ periodogram distribution holds exactly for special processes such as $N$-periodic ARMA described in Appendix A. When conditions for the Central Limit Theorem hold, the $\Paren{1/2} \, \chi^2\Paren{2}$ distribution holds asymptotically as the data length $N \to \infty$ \cite{brockwell-davis-book-1991}. Both $N$-periodic ARMA and the large-$N$ approximations are appropriate for EEG noise. Note that Eq. \myeq{eq:GVZM_process} implies that the expected values $\mathsf{E} \Brack{S_x\Paren{k}}$ are equal to $S_\mathrm{GVZM}\Paren{ k \Delta f}$. Using general results presented in \cite{brockwell-davis-book-1991}, the converse holds asymptotically; that is, the process $S_x\Paren{k}$ converges uniformly in distribution to $S_\mathrm{GVZM}\Paren{ k \Delta f} \cdot \Paren{1/2} \, \Xi\Paren{k}$ as $N \rightarrow \infty$, at least when conditions for Central Limit Theorem hold. (cf. \cite{brockwell-davis-book-1991}, Chapter 10 for details.) \mydef{def:GVZM_model} is consistent with the single-epoch approach of \cite{brockwell-davis-book-1991,liavas-moustakides-1998} but multi-epoch averages of such single-epoch spectra can be used as well. Our methods will apply to such general periodograms merely by replacing ``$\chi^2\Paren{2}$'' with ``$1/M \; \chi^2\Paren{2M}$,'' where $M$ is the number of (statistically independent) epochs. \subsection{The Behavior of the GVZM PSD Function}\label{subsec:GVZM_behavior} The properties of $\mathrm{tan}^{-1}_\theta\Paren{x}$ show that once the noise floor $P_\mathrm{s}$ is subtracted we have the approximate proportionalities $S_\mathrm{GVZM}\Paren{f} \propto1/f^0$ (i.e., a constant) for $f < 1/\Paren{2\pi \upsilon_2}$, $S_\mathrm{GVZM}\Paren{f} \propto 1/f^\theta$ for $1/\Paren{2\pi \upsilon_2} < f < 1/\Paren{2\pi \upsilon_1}$, and $S_\mathrm{GVZM}\Paren{f} \propto 1/f^2$ for $f > 1/\Paren{2\pi \upsilon_1}$. Thus its roll-off transitions smoothly through the $1/f^\theta$ regime, without any of the so-called ``catastrophes'' \cite{mandelbrot-book-1999a} of apparent infinite power when $f \to 0$ and infinite integrals as $f \rightarrow \infty$ which plague true $1/f$--type noises. In particular, $S_\mathrm{GVZM}\Paren{f}$ approaches a (calculable) limiting value as $f \rightarrow 0$. \myfig{fig:GVZMfit} shows a GVZM PSD function fitted to the periodogram of recorded EEG data from an SSVEP session. The GVZM curve follows the periodogram closely except for the alpha-band power \cite{nunez-srin-book-2006} and the SSVEP response spike. \myfig{fig:GVZMfit} should be compared closely to \myfig{fig:chi2_simulation} which shows a \myemph{simulated} periodogram based on the fitted GVZM PSD function and \myeq{eq:GVZM_process}; that is, samples of an independent and identically distributed (iid) $\chi^2\Paren{2}$ pseudo--random process $\Xi\Paren{k}$, $0 \leqslant k \leqslant N-1$ were generated and each sample was multiplied by the factor $\Paren{1/2}\cdot \, S_\mathrm{GVZM}\Paren{ k \Delta f}$. The results were then plotted against frequency on a log-linear scale. We observe that the simulated periodogram of \myfig{fig:chi2_simulation} is visually indistinguishable from the background periodogram of \myfig{fig:GVZMfit}. Eq. \myeq{eq:SVZM_def} has it origin in investigations dating to the 1930's \cite{bernamont-1937} on apparent $1/f$-type noise in vacuum tubes and semiconductors. In 1957, A.L. McWhorter proposed\cite{mcwh-1957} a simple explanation for $1/f$--type semiconductor noise at thermal equilibrium, based on the assumption that the logarithm of the rate at which electrons drop from an activated state was proportional to the energy of that state. Subsequently A. van der Ziel and others \cite{vdziel-1978} abstracted the McWhorter mechanism to general noise processes. Our formula \myeq{eq:SVZM_def} reduces to the original van der Ziel-McWhorter PSD function for $\theta = 1$. \section{The GVZM EEG Periodogram Model}\label{sec:GVZM} In this section, we first specify the notion of periodogram we are using and then define the GVZM PSD function. We then present the GVZM EEG periodogram model. \input{2_GVZM/1_Periodogram} \input{2_GVZM/2_GVZM_def} \input{2_GVZM/3_GVZM_model} \input{2_GVZM/4_GVZM_misc} \subsection{Are Ion Channels the Source of \textit{1}$/f$--type Noise?}\label{subsec:NoisyChannels} Ion channels are protein-based micromachines densely embedded in all neuron membranes, which create and control the transmission of information by regulating the passage of ions in response to neurotransmitters, local voltages, or external stimuli such as temperature, pressure, or photon reception \cite{hille-book-2001}. Soon after Hodgkin \& Huxley decoded the generation of action potentials by the ${\textrm{K}^+}$/${\textrm{Na}^+}$ channel system \cite{hodgkin-huxley-1952}, researchers began to model ion conductance variations in membranes as resulting from simple Markov processes governing the open/close kinetics of the embedded ion channels \cite{hill-chen-IV-1972}. These conductance variations were recognized quickly as a potential source of neurological noise, at least at the neuron level \cite{hille-book-2001}. In a series of articles \cite{hill-chen-IV-1972} in the early 1970's, Hill \& Chen examined several versions of Markov models, including one which was claimed to test the original van der Ziel-McWhorter paradigm (\mysec{sec:GVZM}), with the stated goal of \myemph{excluding} ion channels as sources of the $1/f$--type noise component seen in neuron-level recordings. The limited computational resources available at that time prevented detailed simulations, and they eventually rejected ion channel kinetics as the source of the $1/f$--type noise, thus leaving its origin unexplained. Since then there have been attempts to explain this neurological noise by various other mechanisms \cite{diba-lester-koch-2004}, however, none of these explanations have been completely successful. \subsection{Maximum Entropy in Populations of Quantum Ion Channels and GVZM Noise}\label{subsec:QuantumChannels} We have revisited the conclusion of of Hill \& Chen in \cite{paris-atia-vosoughi-berman-2015a} by considering network-level behavior of large populations of ion channels in statistical equilibrium. Specifically, we have returned to McWhorter's original model (\mysec{sec:GVZM}) of noise generation in semiconductors and identified channel analogies to McWhorter's energy-dependent rate constants and maximum entropy distributions. We have applied McWhorter's abstract maximum entropy paradigm by creating a new quantum mechanical model of ion channel kinetics, which we call \myemph{activated measurement processes}. In the following, we recall a special case of our work in \cite{paris-atia-vosoughi-berman-2015a}: \mybegthm{thm:ionR} \input{3_Channels/R_thm} \end{theorem} (The ``conditions'' mentioned in \mythm{thm:ionR} are technical and are omitted.) Note that the Fourier transform of \myeq{eq:R_GVZM} is easily seen to be the GVZM PSD function in \mydef{def:GVZM_atan}. While these results have immediate relevance only for populations of ion channels, we have argued in \cite{paris-atia-vosoughi-berman-2015a} that the presence of GVZM noise in large-scale EEG recordings ultimately derives from the collective behavior of billions of ion channels balanced in statistical equilibrium. A rough idea of the biophysical meaning of the parameters can be given. The values $\upsilon\Paren{x}$ represents the range of possible reciprocal eigenvalues (``modes'') of the kinetic rate matrices \cite{hille-book-2001} of all possible ion channels in a large network while $X$ is an index set for these modes. The $P_\mathrm{s} \cdot \delta\Paren{\tau}$ term represents ``sputter'' in the channels: the possibility that a channel's state is not quite open or closed completely. The $1/\upsilon\Paren{x}$ prefactor in the integrand derives from the proportionality between activation energy and $\mathrm{log}\Paren{\upsilon}$, a feature common to both the McWhorter paradigm as well as an alternative ion channel mechanism called Eyring rate theory \cite{woodbury-1969}. Most importantly, the exponent $\theta$ is the normalization parameter for a standard thermodynamic partition function \[ Z\Paren{\theta} = \int\limits_X {\Exp{-\theta E\Paren{\upsilon}} \, d\upsilon}, \] where, as previously mentioned, the activation energy of mode $\upsilon$ is $E\Paren{\upsilon} \propto \textrm{log}\Paren{\upsilon}$. This latter point is very significant. Many attempts have been made to explain irrational exponents in $1/f^\theta$--type spectra by means of purported power laws, ``scaling'', or ``self-similarity'' phenomena in neural tissue \cite{mandelbrot-book-1999a}. We consider our interpretation of spectral exponents as normalizing constants for logarithmically-determined energy levels to represent a needed influx of reality into the field of neurological noise. \section{Neurological Noise Theory and Quantum Mechanical Ion Channel Kinetics}\label{sec:Channels} In this section we briefly discuss the theoretical foundation of our GVZM PSD function in \mydef{def:GVZM_atan}, using a new model of \myemph{ion channel quantum stochastic processes} we have developed, and whose details are presented in the supplementary document \cite{paris-atia-vosoughi-berman-2015a}. For the present paper we extract a simplified form of one type of potential autocorrelation function in \cite{paris-atia-vosoughi-berman-2015a} and provide the biophysical interpretation of its parameters. \input{3_Channels/1_NoisyChannels} \input{3_Channels/2_QuantumChannels} \input{\LocalIncludesDir/Figs/04_ARGVZM} \subsection{The Convergence of AR-GVZM, Processes to the GVZM Noise Model}\label{subsec:ARConvergence} We choose some $0 \leqslant k \leqslant K-1$ and let $\upsilon =\upsilon_1 + k\Delta\upsilon$ in \myeq{eq:ARcoeffs}. For small $\Delta t$, we find $a_k = 1-\Delta t / \upsilon$ and $b_k = \sqrt{2\Delta t / \upsilon}$, where we have ignored terms of order higher than $\Delta t$. Defining $\Delta x_k\Paren{n} \overset {\mathrm{def}} = x_k\Paren{n}-x_k\Paren{n-1}$, we easily calculate \mybegeq{eq:dx-dt} \frac{\Delta x_k\Paren{n}}{\Delta t} + \frac{1}{\upsilon}\cdot x_k\Paren{n-1} = \sqrt{\frac{2 P_0}{\upsilon \Delta t}}\cdot e_k\Paren{n}. \end{equation} Let $y_k\Paren{n} \overset {\mathrm{def}} = w_k\cdot x_k\Paren{n}$. Using the definition of $w_k$ in \myeq{eq:ARcoeffs}, \myeq{eq:dx-dt} becomes \[ \frac{\Delta y_k\Paren{n}}{\Delta t} + \frac{1}{\upsilon}\cdot y_k\Paren{n-1} = \sqrt{\frac{2P_0}{\upsilon\cdot\upsilon^{2-\theta}}\Delta\upsilon}\cdot e_k\Paren{n}. \] Now suppose the values $e_k\Paren{n}$ are samples $e_k\Paren{n\Delta t}$ of a continuous-time, iid $N\Paren{0,1}$ process $e_k\Paren{t}$. Then, as $\Delta t \to 0$, $y_k\Paren{n}$ will approach a continuous-time, stationary, Gaussian AR process $y_k\Paren{t}$ satisfying the stochastic differential equation \mybegeq{eq:AR_ODE} \frac{dy_k}{dt} + \frac{1}{\upsilon}\cdot y_k\Paren{t} = \sqrt{\frac{2P_0}{\upsilon\cdot\upsilon^{2-\theta}}\Delta\upsilon}\cdot e_k\Paren{t}. \end{equation} It is well-known \cite{dest-book-2012} that the autocorrelation function of $y_k\Paren{t}$ satisfying \myeq{eq:AR_ODE} is \[ R_k\Paren{\tau} = P_0\,\frac{1}{\upsilon^{2-\theta}}\Exp{-\Abs{\tau}/\upsilon} \Delta\upsilon. \] Using \myeq{eq:ARGVZM}, suppose the values $f_\mathrm{s}\Paren{n}$ are also samples $f_\mathrm{s}\Paren{n\Delta t}$ of a continuous-time, iid $N\Paren{0,1}$ process $f_\mathrm{s}\Paren{t}$ which is independent of all the $e_k\Paren{t}$'s. We observe that the AR-GVZM, processes $x_K\Paren{n}$ in \myeq{eq:ARGVZM} approach a continuous-time, stationary, Gaussian, mixed AR process with autocorrelation function \[ \begin{aligned} R_K\Paren{\tau} = P_0\,\sum\limits_{k=0}^{K-1} \frac{1}{\upsilon^{2-\theta}}\Exp{-\Abs{\tau}/\upsilon}\Delta\upsilon + P_\mathrm{s} \cdot \delta\Paren{t}. \end{aligned} \] Therefore, as $K \to \infty$, the $x_K\Paren{t}$'s themselves will approach a Gaussian process $x_\ast\Paren{t}$ with autocorrelation \mybegeq{eq:R_ARGVZM} R_\ast\Paren{\tau} = P_0 \int\limits_{\upsilon_1}^{\upsilon_2}{\frac{1}{\upsilon^{2-\theta}} \Exp{-\Abs{\tau}/\upsilon} d\upsilon} + P_\mathrm{s} \cdot \delta\Paren{\tau}. \end{equation} It is now easy to check that the PSD function of $x_\ast\Paren{t}$, which is the Fourier transform of $R_\ast\Paren{\tau}$ \cite{oppen-schafer-book-1975}, is given precisely by the formula of Eq. \myeq{eq:SVZM_def}; i.e., the GVZM PSD function. This is a significant result since zero-mean, Gaussian processes are uniquely defined by their autocorrelation function \cite{brockwell-davis-book-1991}. Noting that the GVZM periodogram model implies the autocorrelation must be given by \myeq{eq:R_ARGVZM}, if we make the additional assumption that the EEG noise time series is zero-mean, Gaussian, then that time series \myemph{must} be $x_\ast\Paren{t}$. This means that the AR-GVZM, simulations can be made to approximate EEG background noise with arbitrary precision by means of the double limiting process $\Delta t, \Delta\upsilon \to 0$ described above. Note also that the converse can be proven using methods of \cite{brockwell-davis-book-1991}; that is, if the EEG noise time series is given by limits of AR-GVZM, processes, then the GVZM periodogram model must be valid. This is important for practical applications because it defines the correct statistical model of the periodogram if AR-GVZM, approximations are used to simulate EEG noise. \section{Autoregressive GVZM Simulations of EEG Noise}\label{sec:ARGVZM} The GVZM noise model in \mydef{def:GVZM_model} concerns periodograms and makes no claims about the underlying time domain signal from which they were calculated. In this section, we define a class of mixed autoregressive time series called \textbf{autoregressive GVZM (AR-GVZM) processes}, which are useful simulations of EEG noise and are closely associated with GVZM periodograms. In \mysec{subsec:ARGVZMdef}, we define AR-GVZM processes and show an example based on the parameters derived from recorded data (\myfig{fig:ARGVZM}), in \mysec{subsec:ARConvergence} we connect the asymptotic properties of AR-GVZM, periodograms to the GVZM noise model. \input{4_ARGVZM/1_Def} \input{4_ARGVZM/2_Convergence} \subsection{Set-up and Preprocessing}\label{subsec:Methods} As our data, we used the publicly-available EEG recordings \cite{baka-tana-cich-neuro-let-2010} of four subjects undergoing a series of SSVEP experiments, using a 128-channel Biosemi active-electrode EEG system (\url{http://www.biosemi.com}) sampled at 256 Hz. Each subject experienced 15 25-second trials divided into five trials each of approximately 8 Hz, 16 Hz, and 28 Hz stimulation frequencies. Each 25-second trial consisted of a 5-second pre-stimulation epoch, a 15-second visual stimulation epoch, and a 5-second post-stimulation epoch. Further experimental conditions are presented in \cite{baka-tana-cich-neuro-let-2010}. We preprocessed each epoch separately. Using standard treatments for Biosemi recordings \cite{baka-tana-cich-neuro-let-2010}, quadratic trends in each channel were removed and the central Cz channel (in 10/20-nomenclature was subtracted from all other electrodes. A virtual electrode over the visual cortex was created by averaging the Biosemi-nomenclature electrodes A14, A15, A16, A21, A22, A23, A25, A27, A28, and A29. A virtual electrode close to the eye muscles was created by averaging the frontal 10/20 Fp2, Fpz, and Fp1 electrodes.The visual electrode was linearly regressed onto the eye electrode and the residual was used as the SSVEP response signal. This simple method of removing eyeblink artifacts worked well for our subjects. We excluded the mid-alpha (9.5 Hz--13.5 Hz) and high beta (23.5 Hz--26.5 Hz) non-stationary bands \cite{liavas-moustakides-1998} from all PSD functions, as well as frequencies below 6 Hz and above 50 Hz. This left 614 frequencies per periodogram for testing against the known stimuli. The cumulative distribution functions (CDFs) of the BCI-SNR statistic, required in \mysec{subsec:SNR}, were calculated by bootstrap resampling \cite{efron-tibshirani-1993}. Specifically, for every one of the four subjects, each of their 15 pre-stimulation epochs was independently concatenated to their 15 post-stimulation epochs, yielding 225 sample baseline datasets which were then multiplied by a Tukey window with parameter 0.1 (using the window of \cite{kus-dusyk-etal-2013}). For each baseline, the BCI-SNR statistic was computed using equation Eq. \myeq{eq:SNR} at each of the 614 test frequencies resulting in 614 ``urns'', each urn containing the approximately 225 distinct SNR values which occured at that frequency. For each test frequency, 1000 samples (with replacement) of size 225 were then selected from its urn. Each of these 1000 samples generated its own CDF. Then these 1000 CDFs were averaged to obtain a representative CDF at that frequency. Repeating this procedure at every one of the 614 test frequencies yielded 614 empirical CDFs for each of the four subjects. The smoothed-\textit{F} algorithm \cite{liavas-moustakides-1998} of \mysec{subsec:LM_etal} estimated the expected PSD of the pre-stimulation epoch $x_\mathrm{pre}\Paren{n}$ by the smoothed periodogram approach of \cite{ljung-book-1987}. The circular autocorrelation \cite{oppen-schafer-book-1975} $R_\mathrm{pre}\Paren{m}$ of $x_\mathrm{pre}\Paren{n}$ was computed and then the DFT $S_\mathrm{pre}\Paren{k}$ of the windowed autocorrelation $h\Paren{m} \cdot R_\mathrm{pre}\Paren{m}$ was regarded as the expected PSD. The window $h\Paren{m}$ was a symmetric Hamming window of length $2M+1$, where $M$ is approximately 10\% of the data length of $x_\mathrm{pre}\Paren{n}$. In \cite{liavas-moustakides-1998}, the pre-stimulation data length was specifically chosen to be same as the stimulated epoch $x_\mathrm{stim}\Paren{n}$ so that their respective DFTs $S_\mathrm{pre}\Paren{k}$ and $S_\mathrm{stim}\Paren{k}$ could be compared easily at equal frequency indices $k$. Since our pre-stimulation epochs are shorter than the stimulation epochs, spline interperpolation of $S_\mathrm{pre}\Paren{k}$ was performed to resample it to the larger length. We found that the 10\% smoothed periodogram was sufficiently smooth that such resampling was very accurate. The authors of \cite{liavas-moustakides-1998} time-averaged multiple epochs to improve the SNR prior to detection. This required about 2 minutes of trial data, a very long duration for a practical real-time BCI. For example, the longest epoch used by the well-known and successful SSVEP BCI of \cite{wangs-hong-gaos-2006} was 8 seconds, which was then continuously processed to yield average inter-selection intervals between 3.40 and 5.68 seconds. We therefore tested the GVZM-\textit{F} and smoothed-\textit{F} algorithms on the single-trial, unaveraged epochs of 15 seconds. We performed the paired algorithm comparisons of GVZM-$\chi^2$ vs. BCI-SNR in \mysec{subsec:SNR} and GVZM-\textit{F} vs. smoothed-\textit{F} in \mysec{subsec:LM_etal} by procedures outlined in Appendix B. (See \myfig{fig:SNRTab_ROC}, \myfig{fig:LM_ROC}, \mytable{tab:SNR_vs_GVZM_summary}, and \mytable{tab:LM_vs_GVZM_summary}.) All fits of GVZM PSDs in \mydef{def:GVZM_atan} to actual EEG periodograms, used by both the GVZM-$\chi^2$ and GVZM-\textit{F} algorithms, were obtained by weighted least-squares optimization. We used weights proportional to $f^\beta$, for $\beta \approx 1.5$, where the $f$ are the frequencies over which we are optimizing. We observed that weighting increases the accuracy in the higher frequencies where the signal power is inherently small. Figures displaying spectra and the results of spectral tests show power density $S$ in dB relative to 1; that is $10 \, \mathrm{log}_{10}\Paren{S/1}$. However, all actual critical values have been determined and hypothesis tests were performed in the original units of (amplitude unit)$^2$/Hz. \subsection{Real-time Estimation of SSVEP Responses using the GVZM-$\boldsymbol{\chi^2}$ Algorithm}\label{subsec:GVZM-Chi2} The most direct way to utilize the GVZM noise model in an estimation algorithm is by optimally fitting a GVZM PSD to recorded periodogram and calculating $\Paren{1/2} \, \chi^2\Paren{2}$ critical levels parallel to it. Recall that a GVZM-$\chi^2$-critical level at particular $P$-value is a curve parallel to $S_\mathrm{GVZM}(f)$, showing the power below which periodogram values are confined with probability $1-P$, assuming the GVZM noise model to be correct. The frequencies of any spikes which extend above a pre-assigned $P$-value then are regarded as \myemph{positives}: frequencies at which the GVZM-$\chi^2$ algorithm will report the EEG as having true power, not merely random noise. All others are reported as negatives. In this way, stimulus frequency estimation is implemented by a sequence of hypothesis tests \cite{mood-graybill-boes-book-1974,benjamini-krieger-yekutieli-2006}, one at every frequency we intend to examine. \myfig{fig:chi2_8Hz} and \myfig{fig:chi2_28Hz} show the results of the GVZM-$\chi^2$ algorithm for SSVEP experiments at 8 Hz and 28 Hz respectively (subject 3, trial 2). In particular, according to the GVZM noise model, it is 99.5\% probable that a spectral spike will lie below the upper dashed critical level. These critical levels also display how accurately the GVZM noise model fits the spectra of recorded EEG background processes. It is clear from \myfig{fig:chi2_8Hz} that the GVZM-$\chi^2$ algorithm accurately estimated the 8Hz fundamental SSVEP response and its two harmonics at significance level $P = 0.005$, thus generating no false negatives (also called) Type II errors\cite{mood-graybill-boes-book-1974}). Moreover, it has correctly excluded all other spikes as simply random noise and thus avoided all false positives. (Also called Type I errors \cite{mood-graybill-boes-book-1974} or false discoveries \cite{benjamini-krieger-yekutieli-2006}). In \myfig{fig:chi2_28Hz} the 28 Hz response was estimated accurately however there are several false positives arising, because of non-stationary power in the alpha- and beta-bands (approximately 25 Hz). As discussed in \mysec{subsec:Methods}, such bands need to be pre-excluded from the frequencies to be tested. \subsection{SSVEP Frequency Estimation Using the GVZM-$\chi^2$ and BCI-SNR Algorithms}\label{subsec:SNR} In this section, we describe the BCI-SNR algorithm and compare it to the GVZM-$\chi^2$ algorithm. The BCI-SNR statistic for SSVEP procedures was first defined in \cite{wangs-hong-gaos-2006}, where it was used as a simple measure of signal strength for determining optimal stimulus frequencies. It subsequently became a popular frequency estimator for SSVEP BCIs \cite{kus-dusyk-etal-2013} and more general applications \cite{vialatte-maurice-dauwels-cichocki-2010}. The phrase ``power spectral density analysis'' (PSDA) also has been used \cite{wei-xiao-lu-2011} for methods based on the BCI-SNR. \mybegdef{def:SNR} The BCI-SNR statistic \cite{wangs-hong-gaos-2006} of a signal $x$ at the $k^\mathrm{th}$ test frequency $f_k$ is the ratio \mybegeq{eq:SNR} SNR_x\Paren{f_k} = \frac{n \cdot \hat{S}_x\Paren{f_k}}{\sum\limits_{\substack{j = -n/2 \\ j\ne0}}^{n/2} { \hat{S}_x\Paren{f_k+j\cdot\Delta f} } }, \end{equation} \noindent where $\hat{S}_x$ is an estimator of the sample spectrum, $\Delta f$ is the spectral resolution of the estimated frequency domain, and $n$ is a small integer. To be consistent with \cite{kus-dusyk-etal-2013}, we use $n = 6$. \end{definition} The BCI-SNR statistic is sometimes used as a non-blind detector for a short list $f_1,\ldots, f_K$ of known SSVEP BCI selection frequencies. The subject's selection is considered to be that frequency $f_k$ which has the largest $SNR_x$ value; i.e., $f_{\mathrm{selected}} = \mathrm{argmax}_{f_k} \; SNR_x\Paren{f_k}$. (For example, \cite{wei-xiao-lu-2011,kus-dusyk-etal-2013}.) To use the BCI-SNR algorithm as a blind SSVEP frequency estimator, as described by Appendix B, we require each individual probability distribution function of $SNR_x\Paren{f_k}$ for every test frequency $f_k$. These were estimated by bootstrap resampling as described in \mysec{subsec:Methods}. \input{\LocalIncludesDir/Figs/06_SNRTab_ROC} \myfig{fig:SNRTab_ROC} shows an example of a minimum-variance, unbiased, single-trial estimate of the comparison \myemph{receiver operating characteristics (ROC)} graph \cite{fawcett-2006} as described in Appendix B. The dataset is that of \myfig{fig:RawEEG28Hz} (subject 3, trial 1, 28 Hz stimulus). In \myfig{fig:SNRTab_ROC}, TPR and FPR denote the true and false positive rates, calculated at 256 operating points as detailed in the Appendix. Confusion measures the fractional distance of an operating point from ideal performance TPR = 1, FPR = 0 while the truth rate is a weighted average of the TPR and the true negative rate TNR = (1 - FPR) intended as a measure of accuracy \[\left\{ \begin{aligned} \mathrm{Confusion} &= \sqrt{\Paren{1-\mathrm{TPR}}^2 + \mathrm{FPR}^2} / \sqrt 2 \\ \mathrm{Truth \; Rate} &= \Paren{1-p_0}\cdot\mathrm{TPR} + p_0\cdot\Paren{1-\mathrm{FPR}}, \end{aligned} \right.\] where $0 \leqslant p_0 \leqslant 1$. In a Bayesian situation, with $p_0$ the probability of the null hypothesis \cite{mood-graybill-boes-book-1974}, the truth rate is the probability of a true decision. We assume $p_0 = 1/2$. We observe that the GVZM-$\chi^2$ algorithm outperforms the BCI-SNR algorithm at nearly every operating point. Moreover, even on this very difficult 28Hz stimulus, the optimal operating point for GVZM-$\chi^2$ identifies the true stimulus frequency with probability above 90\% with FPR below 20\%. \input{\LocalIncludesDir/Tables/SNR_vs_GVZM_summary} \mytable{tab:SNR_vs_GVZM_summary} summarizes the pooled ROC results for $N = 34$ trials, in which at least one of the algorithms had confusion below 35\% (``unconfused'' trials by definition). Pooled SE denotes the standard error \[ \mathrm{Pooled \; SE} =\sqrt{\Paren{\sigma_\mathrm{GVZM}^2 + \sigma_\mathrm{SNR}^2} / N} \] appropriate to the \textit{t}-test for the difference of means. \mytable{tab:SNR_vs_GVZM_summary} shows that the GVZM-$\chi^2$ algorithm outperforms the BCI-SNR algorithm on both the confusion and truth rate measures with statistical significance above 99\%. \subsection{SSVEP Frequency Estimation Using the GVZM-\textit{F} and Smoothed-\textit{F} Algorithms}\label{subsec:LM_etal} In \cite{liavas-moustakides-1998}, the authors assume, based on the theory of periodograms developed in detail in \cite{brockwell-davis-book-1991}, that the periodogram random process $S_x\Paren{k}$, $0 \leqslant k \leqslant N-1$ of the EEG background time series $x\Paren{n}$ is given asymptotically by \mybegeq{eq:Liavas_etal} S_x\Paren{k} = \mathsf{E}\Brack{S_x\Paren{k}} \cdot \Paren{1/2} \, \Xi \Paren{k}, \end{equation} where $\Xi\Paren{k}$, $0 \leqslant k \leqslant N-1$ is a process with $\Xi\Paren{k} \sim \chi^2\Paren{2}$ and which are independent for $0 \leqslant k, l < N/2$ with $k \ne l$. If the function $\mathsf{E}\Brack{S_x\Paren{k}}$ were known, then \myeq{eq:Liavas_etal} implies that the test statistics \[ s_x\Paren{k} \overset {\mathrm{def}} = 2 \cdot S_x\Paren{k} / \,\mathsf{E}\Brack{S_x\Paren{k}} \] for $0 \leqslant k \leqslant N-1$ would be iid $\chi^2\Paren{2}$ random variables. A fixed set of indices $\Omega \subseteq \Curly{0,1,\cdots,N-1}$ is selected to represent what we regard as stationary frequencies; e.g., alpha-band frequencies are excluded (cf. \mysec{subsec:Methods}). Then, under the null hypothesis that there is no SSVEP spike at frequency index $k_\mathrm{test}$ we have \begin{align}\label{eq:F-stat} &\frac {\sum_{k \in \Omega_\mathrm{test}} {\! s_x\Paren{k}} \;/\; N_\mathrm{test}} { \sum_{k' \in \Omega \setminus \Omega_\mathrm{test}} {\! s_x\Paren{k'}} \;/ \Paren{N_\Omega - N_\mathrm{test}}} \\ &\qquad\qquad\qquad\qquad \sim F\Paren{N_\mathrm{test}, N_\Omega - N_\mathrm{test}}\nonumber, \end{align} where $\Omega_\mathrm{test}$ is the set of indices $k_\mathrm{test}$ and its harmonics in $\Omega$, $N_\mathrm{test}$ is the size of $\Omega_\mathrm{test}$, $N_\Omega$ the size of $\Omega$, and $F\Paren{d_1,d_2}$ is the $F$--distribution with degrees of freedom $d_1, \, d_2$ \cite{mood-graybill-boes-book-1974}. The key issue is how to obtain the function $\mathsf{E}\Brack{S_x\Paren{k}}$. In \cite{liavas-moustakides-1998}, the authors estimated this function by computing a ``smoothed periodogram'' $S_\textrm{smooth}\Paren{k}$ of a pre-stimulation epoch as described in \mysec{subsec:Methods} and used $S_\textrm{smooth}\Paren{k}$ as a substitute for $\mathsf{E}\Brack{S_x\Paren{k}}$. This constituted their smoothed-\textit{F} algorithm. However, by using the GVZM noise model, we expect to obtain a more accurate baseline estimate by using the GVZM PSD which optimally fits the same pre-stimulus epoch as a substitute for $\mathsf{E}\Brack{S_x\Paren{k}}$. This is our GZVM-\textit{F} algorithm. \myfig{fig:baseline_28Hz} shows the periodogram from the pre-stimulus epoch of the data of \myfig{fig:RawEEG28Hz} (subject 3, trial 1, 28Hz stimulus) with both the smoothed periodogram and the fitted GVZM PSD displayed. The two algorithms are compared as described in Appendix B. \myfig{fig:LM_ROC} shows an example of a minimum-variance, unbiased, single-trial estimate of the comparison ROC graph. \input{\LocalIncludesDir/Figs/07_baseline_28Hz} The dataset is that of \myfig{fig:RawEEG28Hz} (subject 3, trial 1, 28 Hz stimulus). As in \mysec{subsec:SNR}, the GVZM-\textit{F} algorithm outperforms the smoothed-\textit{F} algorithm at nearly every operating point, achieving an optimal performance of over 95\% probability of true identification with just above 20\% FPR. \input{\LocalIncludesDir/Tables/LM_vs_GVZM_summary} \mytable{tab:LM_vs_GVZM_summary} summarizes the pooled ROC results as described in Appendix B for the 56 trials in which at least one of the algorithms had confusion below 35\%. The large number of unconfused trials of these algorithms is a result of the inherent stability of the carefully-designed underlying statistic \myeq{eq:F-stat}. \mytable{tab:LM_vs_GVZM_summary} shows that GVZM-\textit{F} algorithm outperforms the smoothed-\textit{F} algorithm on both the confusion and accuracy measures with statistical significance above 99\%. \input{\LocalIncludesDir/Figs/08_LM_ROC} \section{Real-time BCI Algorithms and EEG Noise}\label{sec:SSVEP} In this section, we explore two new SSVEP frequency estimation algorithms we have designed, based on the GVZM noise model, which we refer to as \textbf{GVZM-}$\boldsymbol{\chi^2}$ and the \textbf{GVZM-}$\boldsymbol{F}$. We evaluate the performance of the new algorithms by comparing each with an existing, commonly-used procedure (to be be described later). Our statistical analysis demonstates that the GVZM-based algorithms outperform both their rivals. In \mysec{subsec:GVZM-Chi2} we examine the GVZM-$\chi^2$ algorithm, which is based on GVZM-$\chi^2$\textbf{-critical levels} for the EEG periodogram. These critical levels are curves drawn on the graph of the periodogram, which are parallel to the GVZM spectrum $S_\mathrm{GVZM}\Paren{f}$ defined in \mysec{subsec:GVZM_def}. Each represents the PSD level beneath which a random $S_\mathrm{GVZM}\Paren{f}\cdot\Paren{1/2}\chi^2\Paren{2}$ variable should remain, with specified probability (see \myfig{fig:chi2_8Hz} and \myfig{fig:chi2_28Hz} for examples of GVZM-$\chi^2$-critical levels.) In \mysec{subsec:SNR}, we perform a statistical performance comparison of GVZM-$\chi^2$ against a commonly-used BCI algorithm \cite{wangs-hong-gaos-2006,wei-xiao-lu-2011,kus-dusyk-etal-2013} we refer to as \textbf{BCI-SNR}. Note that BCI-SNR is based on forming certain ratios of periodogram values around the frequencies that are being tested as SSVEP stimuli (see \mydef{def:SNR} in \mysec{subsec:SNR}). \mysec{subsec:LM_etal} implements two versions of the well-known periodogram $F$-test frequency estimation method used in \cite{liavas-moustakides-1998,baka-tana-cich-neuro-let-2010}. The first version, which we call the \textbf{smoothed-\textit{F}} algorithm, is a direct implementation of \cite{liavas-moustakides-1998}. The second version, which we call the \textbf{GVZM-\textit{F}} algorithm, replaces a key data-estimated periodogram with the optimally-fitting GVZM PSD and making no other alterations. We compare the performance of the GVZM-\textit{F} and the smoothed-\textit{F} algorithms statistically. All four algorithms are used as SSVEP frequency estimators according to the protocol described in Appendix B. This Appendix also describes the procedures we used to generate the summary data statistics in \mytable{tab:SNR_vs_GVZM_summary} and \mytable{tab:LM_vs_GVZM_summary}. \input{5_SSVEP/1_Methods} \input{5_SSVEP/2_GVZMChi2} \input{5_SSVEP/3_SNR} \input{5_SSVEP/4_LM_etal} \section{Conclusions}\label{sec:Summary} In this paper, we showed the necessity of accurate statistical models of EEG background noise for applications to neuroscience, neurology, and real-time BCIs. Based on our analysis and numerical experiments, we proposed a specific, five-parameter statistical family of EEG background periodograms using the GVZM PSD function. To the best of our knowledge, the GVZM PSD function is the only EEG noise PSD model with a fixed number of parameters, matches recorded EEG PSD's with high accuracy over the full spectrum from 0 Hz to 30 Hz, and has approximately $1/f^\theta$ behavior in the mid-frequencies without infinities. We validated this model using three complementary approaches. First, we briefly discussed our theoretical work \cite{paris-atia-vosoughi-berman-2015a} on neurological ion channels and quantum stochastic processes and noted that this theory implies the applicability of the GVZM PSD function to large networks of ion channels in maximum entropy statistical equilibrium. Second, we presented a class of time series we call AR-GVZM, processes which simulate EEG background noise. We showed that the periodograms of AR-GVZM, processes approach the GVZM PSD function as the number of subprocesses becomes large. Third, we designed two algorithms to estimate SSVEP frequencies for real-time BCI applications and applied them to a public set of SSVEP recorded data. We showed statistically that both GVZM-based algorithms were more accurate than two commonly used alternatives, even on difficult data. We conclude that the GVZM noise model accurately characterizes the statistics of EEG background periodograms and, therefore, is a very suitable model for algorithm design, brain signal simulation, and neuroscience investigations. In addition, we believe our applied results indirectly validate quantum ion channel maximum entropy analysis, which is the theoretical foundation of the GVZM noise model. \subsection{The Periodogram Distribution of Periodic ARMA Processes}\label{sec:ARMA_N} \mybegdef{def:N_ARMA} A periodic Gaussian $\boldsymbol{ARMA\Paren{P,Q,N}}$ \myemph{process} is a zero-mean, stationary random process $\Curly{x\Paren{n}}_{n = -\infty}^\infty$ satisfying \mybegeq{eq:ARMA_N} \sum_{p = 0}^P{a_p \, x\Paren{n-p}} = \sum_{q = 0}^Q{b_q \, \nu\Paren{n-q}}, \end{equation} \noindent where $a_0 = b_0 = 1$ and $\Curly{\nu\Paren{n}}_{n = -\infty}^\infty$ is an iid, zero-mean, Gaussian process which is $N$-periodic: $\nu\Paren{n+N} = \nu\Paren{n}$, for all $n$, and the polynomials $A\Paren{z} = \sum_{p=0}^P{a_p z^p}$ and $B\Paren{z} = \sum_{q=0}^Q{b_q z^q}$ have no common zeros. The equality in the periodicity condition is meant to be exact; i.e., there are really only $N$ distinct random processes $\nu\Paren{0}, \ldots, \nu\Paren{N-1}$. \end{definition} \mybegdef{} An $ARMA\Paren{P,Q,N}$ system is \myemph{causal} \cite{brockwell-davis-book-1991} if the polynomial $A\Paren{z}$ defined above has no zeros on or inside the unit circle. \end{definition} \mybegthm{thm:ChiTwo} Let $x\Paren{0}, \ldots, x\Paren{N-1}$ be one period of a causal Gaussian $ARMA\Paren{P,Q,N}$ process and let $S_x\Paren{k}$, $0 \leqslant k \leqslant N-1$, be its periodogram (\mydef{def:periodogram}). Then \[ S_x\Paren{k} = 2\pi \sigma_\nu^2 \cdot \frac{\Abs{B\Paren{\Exp{-i\Paren{2\pi k/N}}}}^2}{\Abs{A\Paren{\Exp{-i\Paren{2\pi k/N}}}}^2} \cdot \Paren{1/2} \, \Xi\Paren{k}, \] \noindent where $\Xi\Paren{k}$, $0 \leqslant k \leqslant N-1$, is a sequence of $\chi^2\Paren{2}$ distributed \cite{mood-graybill-boes-book-1974} random variables which are independent for $0 \leqslant k, l < N/2$ when $k \ne l$ and $\sigma_\nu^2$ is the variance of $\nu\Paren{n}$ . \end{theorem} Because of space limitations, we omit the proof of this result, which is a simple application of the techniques of \cite{brockwell-davis-book-1991}. \subsection{Comparison and Validation Metrics for SSVEP Algorithms}\label{subsec:ROC} The following section presents a preview of an innovative, statististically sound, and extremely flexible methodology we developed specifically for the comparison and validation of SSVEP algorithms. It forms the foundation for the single-trial receiver operating characterstics (ROC) graph of \myfig{fig:SNRTab_ROC} and \myfig{fig:LM_ROC} and the summary statistics of \mytable{tab:SNR_vs_GVZM_summary} and \mytable{tab:LM_vs_GVZM_summary}. The details will be published separately. } \subsection{Comparison Protocols for SSVEP Estimation Algorithms}\label{subsec:Protocols} To simplify analysis of the algorithms of \mysec{sec:SSVEP}, all four were reduced to a common $m$-ary test \cite{benjamini-krieger-yekutieli-2006} protocol, outlined by the flow chart \myfig{fig:CTchart}. Every $f \in F_\mathrm{test}$ in a given set of \myemph{test frequencies} is to be independently judged by the algorithm for its presence or absence as an SSVEP stimulus in the experimental periodogram $S$. No constraint is placed on the number of test frequencies $f \in F_\mathrm{test}$ the algorithm may report as present (positives, P), absent (negatives, N), or undetermined (u). Both pairs in a comparison (GVZM-$\chi^2$ vs. BCI-SNR and GVZM-$F$ vs. smoothed-$F$) are tested against the same \myemph{ground truth}, which has access to the true SSVEP stimulus frequencies and possible harmonics for this experiment. Each algorithm is characterized by a \myemph{test statistic} $X\Paren{\boldsymbol{\mathrm{S}},f}$ with CDFs \[ P_X\Paren{x,f} \overset {\mathrm{def}} = \mathsf{Prob}\Brack{X\Paren{\boldsymbol{\mathrm{S}},f} \leqslant x}, \] where $\boldsymbol{\mathrm{S}}$ is a random variable varying over all possible periodograms that $X\Paren{\, \cdot \,,f}$ could receive ($S$ is a particular value of $\boldsymbol{\mathrm{S}}$). We assume that the larger the value of $X\Paren{\boldsymbol{\mathrm{S}},f}$, the more likely $f$ is a stimulus frequency. \textbf{GVZM-$\boldsymbol{\chi^2}$}: $X\Paren{\boldsymbol{\mathrm{S}},f} = \boldsymbol{\mathrm{S}}\Paren{f}/S_\mathrm{GVZM}\Paren{f}$ and $P_X\Paren{x,f}$ is given by the inverse $\Paren{1/2}\cdot\chi^2\Paren{2}$ distribution (see Eq. \myeq{eq:GVZM_process}). \textbf{BCI-SNR}: $X\Paren{\boldsymbol{\mathrm{S}},f}$ is given by Eq. \myeq{eq:SNR} and the CDFs are obtained empirically by bootstrap resampling as described in \mysec{subsec:Methods}. \textbf{GVZM-\textit{F}}: $X\Paren{\boldsymbol{\mathrm{S}},f}$ is the ratio Eq. \myeq{eq:F-stat}, with $\mathsf{E}\Brack{S_x\Paren{k}}$ the GVZM fit to the baseline data. The CDFs are the inverse \textit{F} distribution with appropriate degrees of freedom. \textbf{smoothed-\textit{F}}: $X\Paren{\boldsymbol{\mathrm{S}},f}$ is the ratio Eq. \myeq{eq:F-stat}, with $\mathsf{E}\Brack{S_x\Paren{k}}$ the smoothed periodogram of \cite{ljung-book-1987}.The CDFs are the inverse \textit{F} distribution with appropriate degrees of freedom. Let $0 \leqslant \alpha \leqslant 1$ be the \myemph{1-ary significance level}. The $\boldsymbol{\alpha^p}$\myemph{-urn} for $X\Paren{\boldsymbol{\mathrm{S}},f}$ is a conceptual container of paired values $x_0 \leqslant x_1$ whose likelihood of occurrence is determined by $P_X\Paren{x,f}$. The $\boldsymbol{\alpha^p}$\myemph{-urn test} is the following randomized procedure: Calculate $X\Paren{\boldsymbol{\mathrm{S}},f}$ and independently select a pair $x_0, x_1$ from the $\alpha^p$-urn. Then $f$ is adjudged present in $\boldsymbol{\mathrm{S}}$ if $X\Paren{\boldsymbol{\mathrm{S}},f} \geqslant x_1$, absent if $X\Paren{\boldsymbol{\mathrm{S}},f} < x_0$, and undetermined otherwise. Ground truth answers questions about binary hypotheses $H_0\Paren{f},H_\mathrm{a}\Paren{f}$, where the null hypothsis $H_0\Paren{f}$ is: frequency $f$ is not an SSVEP stimulus. It may fail to answer, which we symbololize in \myfig{fig:CTchart} by ``$h\Paren{f}$''. Since no estimation algorithm can be 100\% accurate, ground truth must contain a parameter $\delta f$ which determines how much error $\Abs{f - f_\mathrm{ssvep}}$ it will tolerate between a test frequency $f$ and a known stimulus or harmonic frequency $ f_\mathrm{ssvep}$. We have found SSVEP estimation to be very sensitive to $\delta f$ and its optimal value must be determined for each subject during pre-test training. With these definitions, the \myemph{single-trial contingency table} $CT\Paren{\boldsymbol{\mathrm{S}}}$ can be calculated as shown in \myfig{fig:CTchart}. Note that multiple true positives are possible, even with a single stimulus frequency $f_\mathrm{ssvep}$, both because ground truth may report harmonics of $f_\mathrm{ssvep}$ and because the resolution $\delta f > 0$ must report test frequencies in an interval around $f_\mathrm{ssvep}$. When a particular periodogram $\boldsymbol{\mathrm{S}} = S$ is analyzed, the conditional expectation $\overline{CT}\Paren{S} \overset {\mathrm{def}} = \mathsf{E}\Brack{CT\Paren{\, \cdot \,} \; | \; S}$, which is known to be the minimum variance unbiased estimator of $CT\Paren{\, \cdot \,}$ \cite{mood-graybill-boes-book-1974}, can be calculated. From the cells of $\overline{CT}\Paren{S}$ , we can derive the TPR and FPR (\mysec{subsec:SNR}) as $\mathrm{TPR} \overset {\mathrm{def}} = \mathrm{TP} / N_\mathrm{a}$, $\mathrm{FPR} \overset {\mathrm{def}} = \mathrm{FP} / N_0$, where TP, FP are the number of true and false positives and $N_\mathrm{a}$,$N_0$ are the number of true hypotheses $H_\mathrm{a}$,$H_0$ respectively. As seen in \myfig{fig:CTchart}, the estimator $\overline{CT}\Paren{\alpha,\delta f; S}$ depends on the parameters $\alpha,\delta f$. By varying these, we can plot the resulting operating points $\Paren{\mathrm{FPR}\Paren{\alpha,\delta f},\mathrm{TPR}\Paren{\alpha,\delta f}}$ on a \myemph{single-trial ROC} graph \cite{fawcett-2006}. The ROC determines the optimal values of $\alpha,\delta f$ for the periodogram $S$. \myfig{fig:SNRTab_ROC} and \myfig{fig:LM_ROC} show the operating points of 256 choices of $\alpha,\delta f$ for the various algorithms, on the \myfig{fig:RawEEG28Hz} periodogram, as well as the optimal operating points according to the two accuracy measures described in \mysec{subsec:SNR}. By creating single-trial ROCs for all periodograms $S$ in an experiment, the statistical distribution of optimal accuracy measures can be inferred. \mytable{tab:SNR_vs_GVZM_summary} and \mytable{tab:LM_vs_GVZM_summary} show the analysis of $N = 12$ optimal operating point measures corresponding to the three subjects and four possible stimulus frequencies, each of which were tested in five trials (\mysec{subsec:Methods}). \section{Appendices}\label{sec:Appendices} Appendix A presents the background for a useful class of random processes we call $ARMA(P,Q,N)$ processes which provide motivation for the GVZM model of \mysec{sec:GVZM}. Appendix B is an overview of the statistical methodology used for the algorithm comparisons of \mysec{sec:SSVEP}. \input{\LocalIncludesDir/Figs/09_CTchart} \input{7_Appendix/A_ARMA_N} \input{7_Appendix/B_Protocols} \section*{References} \bibliographystyle{IEEETran} \section*{References} \bibliographystyle{IEEETran}
{'timestamp': '2016-08-12T02:07:00', 'yymm': '1608', 'arxiv_id': '1608.03464', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03464'}
arxiv
\section{Introduction} Despite their desirable properties, FIR filters have certain disadvantages when compared to their IIR counterparts. For example, the minimum order required for an FIR filter to approximate a desired filter response within pre-specified bounds is usually much higher than the order of an IIR filter for the same task, which translates into more multiplications and additions per input sample in a hardware implementation and requires larger power and memory. Furthermore, even though linear phase FIR filters introduce no dispersion but only a uniform latency, the amount of this latency in samples is half the filter order and this may become unacceptably high for latency-sensitive applications. Therefore it is crucial to optimize an FIR filter for a given order while keeping this order as low as possible. The optimality can be stated with respect to a particular norm, and several design methods exist to meet different optimality criteria. For example, the windowing methods can be used to minimize the sum of absolute squares ($\l_2$-norm) of the approximation error between the filter response and the desired response for a given order. On the other hand, the Parks-McClellan method \cite{Parks1972} aims to minimize the maximum absolute error ($\l_{\infty}$-norm), also known as the minimax or Chebyshev error. Since minimizing the $l_2$-norm is equivalent to minimizing the energy in the error, it does not prevent large but very narrow deviations between the filter frequency response and the desired response that result in a small $\l_2$-norm. Therefore, even though it is much easier to design for $\l_2$-norm optimality, the minimax-optimality have been adopted widely in the signal processing community due to its superior worst-case performance, and it will be the focus in this paper. The Parks-McClellan design method yields the unique globally-optimal linear phase FIR filter for a given order $N$ by exploiting a theorem that provides the necessary and sufficient conditions for global minimax-optimality, which is known as the alternation theorem \cite{Cheney1966}. Even though it is desirable, asserting linear phase restricts the coefficients of the filter to have even- or odd-symmetry if they are real-valued, or conjugate-symmetry if they are complex-valued. This restriction exhibits itself as halving the number of degrees of freedom available to approximate the desired response because each choice of a filter coefficient already determines another coefficient to generate symmetric pairs. For a variety of applications where linear phase is not crucial, this becomes an unnecessary constraint. Filters with magnitude responses that provide a much better approximation to the desired response can be obtained by removing the linear phase constraint. However, this renders the characterization of optimality by the alternation theorem inapplicable in its currently known form, which in turn prevents direct utilization of the Parks-McClellan method. In this paper, we first provide a characterization method for the global minimax-optimality of FIR filters if no restrictions exist on its phase. In other words, we state the necessary and sufficient conditions for the magnitude response of an FIR filter to be the unique best approximation to a desired response. Of course, due to the restrictions that are imposed in a linear phase design, the optimal filter with unrestricted phase will always be at least as good an approximation to the desired response as the optimal linear phase solution. Since this is a characterization stated in terms of the magnitude response, all the FIR filters sharing the same order and magnitude response will be optimal. Therefore, although the magnitude response is the unique optimal response, there are a finite number of distinct optimal FIR filters related to each other through a cascade with an all-pass filter. Secondly, in this paper, the arguments of the characterization will be shown to naturally lead to a minimax-optimal design method involving the computation of an autocorrelation sequence as an intermediate step, at the end of which the designer will be able to choose from a variety of options for the phase including a minimum phase and a maximum phase design without compromising the global optimality of the magnitude response. Since it was originally introduced in Hermann and Schuessler's work \cite{Schuessler1970}, designing a nonlinear phase FIR filter by first designing an autocorrelation sequence and then finding a filter that admits this as its autocorrelation is a widely known technique \cite{Boite1981, Chen1986, Venkata1999, Kamp1983, Mian1982, Samueli1988, Wu1996}. Spectral factorization is an obvious first choice to obtain the filter coefficients from the designed autocorrelation sequence. This requires finding the roots of the polynomial the coefficients of which are the same as the autocorrelation sequence. Since this is a highly impractical approach for designing high order filters, for minimum phase designs, several algorithms have been proposed as an alternative to polynomial root finding \cite{Boite1981, Chen1986, Venkata1999, Kamp1983, Mian1982}. However, in most of these earlier methods for nonlinear phase FIR filter design, it is the autocorrelation sequence of the filter impulse response that is designed to have minimax optimality in approximating the desired response, which does not necessarily imply the optimality of the filter itself. Furthermore, since the magnitude response of the filter and that of its autocorrelation sequence are related through squaring, the weight function applied during the design of the autocorrelation will not match the desired weight function on the approximation error attained by the final design. In this paper, we first characterize the optimality of the nonlinear phase FIR filter instead of its autocorrelation sequence and then provide a method to compute the correct weight to be applied during the computation of the autocorrelation sequence so that the resulting filter exhibits the desired ratio of passband to stopband deviations. Spectral factorization using polynomial root finding or any of the alternative methods in the current literature \cite{Boite1981, Chen1986, Venkata1999, Kamp1983, Mian1982} can then be used to obtain the final design from the autocorrelation sequence leading to the FIR design with the desired error weights, where the global optimality is certified by our characterization of optimality. \section{Linear Phase vs Nonlinear Phase FIR Filters} Linear phase FIR filters with real-valued coefficients can be expressed as a real-valued amplitude function $A(\omega)$ multiplied by a linear phase term $e^{-j\alpha \omega}$. Since this linear phase corresponds to a time delay by $\alpha$ samples, a usual approach to designing linear phase FIR filters is to first design the zero-phase filter response $A(\omega)$, which is necessarily symmetric in time domain for it to be zero phase. Afterwards, the filter is time delayed until it is causal, which corresponds to multiplying with a phase of the form $e^{-j\alpha \omega}$. Parks and McClellan \cite{Parks1972} exploited the fact that the frequency response $A(\omega)$ of a symmetric zero-phase filter $a[n]$ of even order $N$ can be expressed in terms of real sinusoids. More specifically, for example if $a[n]=a[-n]$, then \begin{equation}\label{eqn:A(w)} A(\omega) = \sum_{-N/2}^{N/2} a[n]e^{-j\omega n} = a[0] + \sum_{n=1}^{N/2}2a[n]cos(n\omega). \end{equation} In other words, $A(\omega)$ can be expressed as a linear combination of the basis functions $\{cos(n\omega),\; n=0,1,\dots,N/2\}$. In order to approximate an ideal filter response $D(\omega)$, we search for the optimal set of linear combination coefficients for these basis functions such that the maximum absolute error is minimized. The alternation theorem asserts that we need $N/2+2$ alternations for the optimal filter, and the Remez Exchange algorithm can be used to efficiently find this set of coefficients. Since nonlinear phase filters cannot be time-shifted by any amount to exhibit a real-valued (zero-phase) response, and since the alternation theorem and the Remez Exchange Algorithm apply only to real-valued functions, they cannot be used to characterize or design minimax optimal nonlinear phase FIR filters directly. \section{Characterization Theorem for Nonlinear Phase Filters}\label{sec:charac} In this section, we describe a very straightforward method to characterize the global minimax optimality of a given nonlinear phase FIR filter $h[n],\;n=0,1,\dots,N$, where the optimality is implied for the magnitude response of this filter, $|H(e^{j\omega})|$, as compared to the desired filter response, $D(\omega)$, which is unity in the passband and zero in the stopband. In other words, by examining the magnitude response $|H(e^{j\omega})|$, we will be able to tell whether this is a filter the magnitude response of which is the best approximation to $D(\omega)$ in that no other magnitude response achievable with the same order can attain a smaller infinity norm on the weighted approximation error $W(\omega)(|H(e^{j\omega})|-D(\omega))$. We will be able to characterize optimality for both real-valued and complex-valued filter coefficients, and we do not require any symmetry in the coefficients, therefore it applies in the most general case. In the next section, the arguments of this characterization will enable us to find an efficient algorithm to design nonlinear phase FIR filters in cases where only the magnitude response is specified and the phase is not restricted. However we will still be able to choose among different available phase characteristics including, for example, a minimum phase design without compromising global optimality with respect to magnitude. Assume that an FIR filter with coefficients $h[n], \;n=0, 1, 2,\dots, N$ and a frequency response $H(e^{j\omega})$ is provided with the passband $\Omega_P$ and the stopband $\Omega_S$, both of which are closed subsets of $(-\pi,\pi]$, to approximate the desired magnitude response \begin{equation}\label{eqn:D} D(\omega)=\left\{\begin{array}{lr} 1, & \omega \in \Omega_P\\ 0,& \omega \in \Omega_S\\ \end{array} \right.. \end{equation} Further assume that a desired weight function $W_{des}(\omega)$ is provided that expresses the relative emphasis on the error in the stopband as compared to the passband. More specifically, \begin{equation}\label{eqn:W_des} W_{des}(\omega)=\left\{\begin{array}{lr} 1, & \omega \in \Omega_P\\ K_{des},& \omega \in \Omega_S\\ \end{array} \right., \end{equation} where $K_{des}$ is a scalar given as a part of the filter specifications. The weighted error function, and the bounds on passband and stopband errors are defined as \begin{equation}\label{eqn:weighted_error} E_W(\omega) = W_{des}(\omega)\left(\left|H(e^{j\omega})\right|-D(\omega)\right), \end{equation} \begin{equation}\label{eqn:delta_P} \delta_P = \max_{\omega\in(\Omega_P \cup \Omega_S)}\left|E_W(\omega)\right| \end{equation} and \begin{equation}\label{eqn:delta_S} \delta_S = \frac{\delta_P}{K_{des}}, \end{equation} respectively. \begin{thm} \label{thm:main_res} $|H(e^{j\omega})|$ is the unique minimax-optimal magnitude response that can be attained by any FIR filter of order $N$ in order to approximate the ideal filter magnitude response $D(\omega)$ with a desired weight function $W_{des}(\omega)$ if and only if the \underline{adjusted} weighted error function \begin{equation}\label{eqn:adjusted_weighted_error} E'_W(\omega)=W'_{des}(\omega)\left(\left|H(e^{j\omega})\right|-D'(\omega)\right) \end{equation} exhibits at least $N+2$ alternations if the filter coefficients $h[n]$ are restricted to be real-valued, or at least $2N+2$ alternations if they are not restricted to be real-valued. Here, $W'_{des}(\omega)$ and $D'(\omega)$ are defined as \begin{equation}\label{eqn:adjusted_W_des} W'_{des}(\omega)=\left\{\begin{array}{lr} 1, & \omega \in \Omega_P\\ 2K_{des},& \omega \in \Omega_S\\ \end{array} \right., \end{equation} and \begin{equation}\label{eqn:adjusted_D} D'(\omega)=\left\{\begin{array}{lr} 1, & \omega \in \Omega_P\\ \frac{\delta_S}{2},& \omega \in \Omega_S\\ \end{array} \right.. \end{equation} \end{thm} Note that in the context of linear phase FIR filters where the alternation theorem is used for characterization, the optimality is characterized by counting the alternations in the weighted error function which is computed using the desired response $D(\omega)$ and the weight function $W_{des}(\omega)$. The characterization given here for nonlinear phase FIR filters is based on the adjusted weighted error function $E'_W$ computed using $D'(\omega)$ and $W'_{des}(\omega)$ as in equation (\ref{eqn:adjusted_weighted_error}). The formal proof of the characterization theorem (Theorem \ref{thm:main_res}) is given in \cite{DemirtasTSP2016} and will be excluded here for brevity. However, intuitively, the optimality of $h[n]$ can be related to the optimality of its autocorrelation sequence $p[n]$ as follows. Due to the specific choice of values in the stopband for $D'(\omega)$ and $W'_{des}(\omega)$, the number of alternations and the points at which alternations occur are the same for $|H(e^{j\omega})|$ and $P(e^{j\omega})=|H(e^{j\omega})|^2$. More specifically, if $|H(e^{j\omega})|$ attains its extreme value at a specific frequency and hence form an alternation in $E'_W(\omega)$, then the Fourier transform of the autocorrelation function $P(e^{j\omega})=|H(e^{j\omega})|^2$ will also attain its extremal value and form an alternation in a related weighted error function at the same frequency. Therefore, the number of required alternations in the magnitude response of the filter can be related to that of the autocorrelation sequence, which is zero-phase and in turn can be characterized for optimality using the traditional form of the alternation theorem. The number of required alternations for filters with complex-valued coefficients are larger than that of filters with real-valued coefficients. This also is consistent with intuition because it reflects the additional degrees of freedom in choosing the filter coefficients by relaxing the constraint to be real-valued. More formally, the autocorrelation function of such filters also have complex-valued coefficients in general, and they exhibit conjugate-symmetry instead of the even-symmetry in the real case. This means that the autocorrelation sequence $p[n]$ of a filter $h[n]$ with complex-valued coefficients satisfy \begin{equation} p[n] = p^*[-n],\; n=0,1,2,\dots, N, \end{equation} or equivalently \begin{equation} p_{re}[n] = p_{re}[-n], \; n=0,1,2,\dots, N \end{equation} and \begin{equation} p_{im}[n] = -p_{im}[-n], \; n=0,1,2,\dots, N, \end{equation} where the subscripts $re$ and $im$ refer to the real and imaginary parts, respectively. The frequency response of a conjugate-symmetric autocorreation sequence $p[n]$ can be represented as \begin{IEEEeqnarray}{lCl}\label{eqn:P(w)_complex} P(e^{j\omega})&=&\sum_{n=-N}^N p[n]e^{-j\omega n}\nonumber\\ &=&p[0]+\sum_{n=1}^N p[n]e^{-j\omega n} + p^*[n]e^{j\omega n}\\ &=&p[0]+\sum_{n=1}^N 2p_{re}[n]cos(n\omega)+\sum_{n=1}^N 2p_{im}[n]sin(n\omega)\nonumber \end{IEEEeqnarray} This implies that the frequency response $P(e^{j\omega})$ can be represented as a linear combination of basis functions given as \begin{equation}\label{eqn:cos_sin_basis} \{cos(n\omega),\;n=0,1,2,\dots,N\}\cup\{sin(n\omega),\;n=1,2,\dots, N\} \end{equation} This means the flexibility in choosing the coefficients of $h[n]$ as complex-valued results in an addition of $N$ basis functions to the set of available functions to represent $P(e^{j\omega})$, potentially leading to smaller approximation errors as intuitively expected. Furthermore, the basis set in (\ref{eqn:cos_sin_basis}) also satisfies the Haar condition and therefore leads to a unique optimal solution \cite{Cheney1966}. These additional $N$ basis functions manifest themselves as an increase by $N$ in the number of required alternations to satisfy the traditional form of the alternation theorem for the design of the autocorrelation. Therefore, Theroem \ref{thm:main_res} applies to complex-valued filters with $2N+2$ alternations as opposed to $N+2$ alternations. \textbf{Example:} Before proceeding to the design procedure, we close this section with an example of an FIR filter that is globally minimax optimal to illustrate the computation of the adjusted desired response $D'(\omega)$, the adjusted weight function $W'_{des}(\omega)$ and the alternation counting process in the characterization of nonlinear phase FIR filters for optimality. Our example design with real-valued coefficients in Figure \ref{fig:comparison}a has smaller ripple sizes than the one designed with MATLAB's \texttt{firpm} function which is based on the Parks-McClellan design \cite{Parks1972}. The filter order is $N=26$ with the passband and the stopband specified as $\Omega_P=[0,0.36\pi]$ and $\Omega_S=[0.42\pi,\pi]$. The weight $K_{des}$ is chosen as $3$ in this example, meaning the degrees of freedom will be chosen to suppress the stopband error more than the passband error by this factor. We compute $E_W(\omega)$ as in equation (\ref{eqn:weighted_error}), which is provided in Figure \ref{fig:comparison}b. From this computation, $\delta_P$ and $\delta_S$ are computed as $0.12$ and $0.04$, respectively. Therefore, $D'(\omega)$ and $W'_{des}(\omega)$ become \begin{equation} D'(\omega)=\left\{\begin{array}{lr} 1, & \omega \in [0,0.36\pi]\\ 0.02,& \omega \in [0.42\pi,\pi]\\ \end{array} \right. \end{equation} and \begin{equation} W'_{des}(\omega)=\left\{\begin{array}{lr} 1, & \omega \in [0,0.36\pi]\\ 6,& \omega \in [0.42\pi,\pi]\\ \end{array} \right.. \end{equation} This leads to an adjusted weight function $E'_W(\omega)$ illustrated in Figure \ref{fig:comparison}c, which was obtained as in (\ref{eqn:adjusted_weighted_error}). This error indeed exhibits $N+2=28$ points, which is a necessary and sufficient condition for the unique and global optimality of the magnitude response $|H(e^{j\omega})|$ asserted by Theorem \ref{thm:main_res}. The \texttt{firpm} design exhibits only $23$ alternations in the adjusted weighted error which is computed similarly and illustrated in Figure \ref{fig:comparison}d; and is clearly suboptimal. \begin{figure} \centering \subfloat[]{\includegraphics[scale =0.35] {comparison_a.eps}}\\ \subfloat[]{\includegraphics[scale =0.35] {comparison_b.eps}}\\ \subfloat[]{\includegraphics[scale =0.35] {comparison_c.eps}}\\ \subfloat[]{\includegraphics[scale =0.35] {comparison_d.eps}} \caption{(a) The magnitude responses of two $26$-th order FIR filters with real-valued coefficients, one designed with the algorithm proposed in Section \ref{sec:design} and the other using \texttt{firpm} function of MATLAB (b) Weighted function $E_W(\omega)$ for our design (c) Adjusted weighted error $E'_W(\omega)$ for our design (d) Adjusted weighted error for the \texttt{firpm} design.}\label{fig:comparison} \end{figure} The formal steps provided for testing optimality can be bypassed by a more practical observation. Setting the maximum error in the passband to $\delta_P$, and the maximum error in the stopband to $\delta_S$, one can directly verify whether the filter satisfies the desired weight by checking if $\frac{\delta_P}{\delta_S}$ equals $K_{des}$. If this is the case, then the alternations can be also counted directly on the magnitude response as the points where the function reaches its extreme points in an alternating fashion including the band edges since $W'_{des}(\omega)$ and $D'(\omega)$ are tailored to turn these points into alternation points of the adjusted weighted error $E'_W(\omega)$. This approach can be verified in Figure \ref{fig:comparison}a where the extremal points are indeed alternations and lead to $28$ alternations including those occur at the band edges. \section{Optimal Nonlinear Phase FIR Filter Design Algorithm}\label{sec:design} In this section, we describe the design algorithm for filters restricted to having real-valued coefficients, therefore we will require $N+2$ alternations. The same arguments apply to filters with complex-valued coefficients simply by requiring $2N+2$ alternations and including sines in the basis functions for the computation of optimal squared response. \subsection{Design Constraints} Designing a zero-phase sequence $g[n]$ that approximates an ideal filter response, lifting its frequency response $G(e^{j\omega})$ until it is nonnegative and treating the lifted sequence $p[n]$ as the autocorrelation of an FIR filter $h[n]$ has been used as a nonlinear phase FIR filter design method at least since 1970 \cite{Schuessler1970}. However, since the design specifications such as relative weight on the stopband versus passband deviation in the autocorrelation domain do not remain the same for the filter due to the squaring relationship between $P(e^{j\omega})$ and $|H(e^{j\omega})|$, the resulting filter $h[n]$ does not necessarily reflect the desired weight. Furthermore, no optimality arguments are available for the final design $h[n]$ because the optimality of the autocorrelation sequence for one set of metrics does not make the corresponding filter optimal for the same metrics. We now provide a design method that correctly accounts for this relationship and computes the weight to be applied in the design of the autocorrelation sequence such that the final design exhibits the desired ratio between passband and stopband deviations. Furthermore, the characterization theorem of Section \ref{sec:charac} will certify the optimality of the filter itself as opposed to the optimality of the autocorrelation sequence. Since the alternation frequencies and the number of alternations are the same for $|H(e^{j\omega})|$ and $P(e^{j\omega})$ due to the specific choice of $D'(\omega)$ and $W'_{des}(\omega)$ in the characterization theorem, designing the autocorrelation sequence $p[n]$ instead of the filter $h[n]$ itself with the correct number of alternations satisfies the conditions of the characterization theorem for the optimality of $h[n]$ itself. Therefore we can design an autocorrelation function that satisfies the required number of alternations and recover the filter coefficients that will accept this function as its autocorrelation function using either spectral factorization, or if a minimum phase filter is particularly desired, any of the methods in \cite{Boite1981, Chen1986, Venkata1999, Kamp1983, Mian1982}. An autocorrelation sequence with at least $N+2$ alternations can be designed by first by computing the coefficients of an optimal even-symmetric sequence $g[n]$ of length $2N+1$ such that its Fourier transform $G(e^{j\omega})$ approximates the ideal filter, and then by scaling and shifting to obtain $P(e^{j\omega})=aG(e^{j\omega})+b$ such that the following constraints are satisfied: \begin{itemize} \item[(i)] $|H(e^{j\omega})|=\sqrt{P(e^{j\omega})}$ swings symmetrically around unity in the passband, i.e. its extremal values become $1+\delta_P$ and $1-\delta_P$ for some positive $\delta_P$, \item[(ii)] the minimum value of $P(e^{j\omega})$ is zero, \item[(iii)] the maximum value $\delta_S$ of $|H(e^{j\omega})|=\sqrt{P(e^{j\omega})}$ in the stopband satisfies the desired weight constraint, i.e., $\frac{\delta_P}{\delta_S}=K_{des}$. \end{itemize} The first condition guarantees that the effects of squaring are properly taken into account in the autocorrelation domain; the second constraint ensures $p[n]=ag[n]+b\delta[n]$ is a proper autocorrelation sequence; and the third constraint ensures that the desired weight is not compromised through squaring. The relationship between $G(e^{j\omega})$, $P(e^{j\omega})$ and $|H(e^{j\omega})|$ is illustrated with an example in Figure \ref{fig:filter_and_autocorr}. Referring to the passband and stopband deviations of $|H(e^{j\omega})|$ as $\delta_P$ and $\delta_S$ and those of $G(e^{j\omega})$ as $\Delta_P$ and $\Delta_S$ respectively, these three constraints can be represented mathematically in terms of the scale and shift coefficients $a$, $b$ and the weight $K$ that will be applied in the design of $g[n]$. More specifically, we choose the scaling coefficient $a$ and the shifting coefficient $b$ such that the midpoints of the passband and stopband ranges of $G(e^{j\omega})$ and $P(e^{j\omega})$ match as in \begin{equation} a\cdot 1 + b = 1 + \delta_P^2 \end{equation} and \begin{equation} a\cdot 0 + b = \frac{\delta_S^2}{2}, \end{equation} which yields \begin{equation}\label{eqn:a} a = 1+\delta_P^2-\frac{\delta_S^2}{2} \end{equation} and \begin{equation}\label{eqn:b} b = \frac{\delta_S^2}{2}. \end{equation} \begin{figure} \centering \subfloat[]{\includegraphics[scale =0.35] {filter_and_autocorr_a.eps}}\\ \subfloat[]{\includegraphics[scale =0.35] {filter_and_autocorr_b.eps}}\\ \subfloat[]{\includegraphics[scale =0.35] {filter_and_autocorr_c.eps}}\\ \caption{An example for (a) the Fourier Transform of the symmetric sequence $g[n]$ that approximates an ideal filter response, (b) that of the autocorrelation $p[n]$ obtained from $g[n]$ through scaling and shifting, i.e. $p[n]=ag[n]+b\delta[n]$, (c) the magnitude response of a nonlinear phase filter $h[n]$ the autocorrelation of which is $p[n]$. In this example, $N=20$, $\Omega_P=[0,0.30\pi]$, $\Omega_S=[0.35\pi,\pi]$ and $K_{des}=0.5$.}\label{fig:filter_and_autocorr} \end{figure} The relative weight between passband and stopband does not change after scaling $G(e^{j\omega})$, therefore the weights are identical in both: \begin{equation} \frac{(1+\delta_P)^2-(1-\delta_P)^2}{\delta_S^2}=\frac{4\delta_P}{\delta_S^2}=\frac{\Delta_P}{\Delta_S}=K \end{equation} Since $\delta_P/\delta_S=K_{des}$, we can write this as \begin{equation} K = \frac{4K_{des}}{\delta_S} \end{equation} or \begin{equation}\label{eqn:delta_S} \delta_S = \frac{4K_{des}}{K}. \end{equation} In order to match the upper bound of the filter response in the stopband to that of the autocorrelation after the scale and shift, we have \begin{equation}\label{eqn:delta_S2} \delta_S^2 = a\cdot \Delta_S + b. \end{equation} Inserting the values of $a$ and $b$ from equations (\ref{eqn:a}) and (\ref{eqn:b}), and inserting $\delta_S^2=\frac{16K_{des}^2}{K^2}$ from equation (\ref{eqn:delta_S}), we obtain \begin{equation} \frac{16K_{des}^2}{K^2}=\left(1+\frac{16K_{des}^4}{K^2}-\frac{8K_{des}^2}{K^2}\right)\Delta_S+\frac{8K_{des}^2}{K^2} \end{equation} Solving this for $\Delta_S$ yields \begin{equation}\label{eqn:Delta_S} \Delta_S = \frac{8K_{des}^2}{K^2+16K_{des}^4-8K_{des}^2}. \end{equation} and, since $\Delta_P = K\Delta_S$, we obtain \begin{equation}\label{eqn:Delta_P} \Delta_P = \frac{8K_{des}^2K}{K^2+16K_{des}^4-8K_{des}^2}. \end{equation} Finally, once the appropriate weight $K$ that satisfies this equation is found, the scaling and shifting coefficients can be computed directly from the parameters of this filter. Using equation (\ref{eqn:delta_S}) and (\ref{eqn:b}), we obtain \begin{equation}\label{eqn:b_better} b = \frac{8K_{des}^2}{K^2}, \end{equation} and from equation (\ref{eqn:b_better}) and (\ref{eqn:delta_S2}), we have \begin{equation}\label{eqn:a_better} a = \frac{8K_{des}^2}{K^2\Delta_S} = \frac{8K_{des}^2}{K\Delta_P}. \end{equation} Equation (\ref{eqn:Delta_P}) is an implicit and nonlinear equation that expresses the correct weight $K$ that needs to be applied in the design of $G(e^{j\omega})$ in terms of the actual passband deviation $\Delta_P$ obtained using the Remez Exchange Algorithm. It can be solved efficiently for example using an iterative procedure where we cut the search space on $K$ each time in a binary search fashion or using Newton-Raphson method. Once the appropriate $K$ is found, we design $G(e^{j\omega})$ with that weight, scale by $a$ and shift by $b$ to obtain the autocorrelation response $P(e^{j\omega})$, and then recover the filter coefficients $h[n]$ using spectral factorization where we can choose the filter to be minimum phase, or maximum phase or anything in between. If the desired filter is minimum phase, then more efficient methods in \cite{Boite1981, Chen1986, Venkata1999, Kamp1983, Mian1982} can be used instead of spectral factorization. \subsection{The Overall Algorithm}\label{subsec:overall} Assume that we want to compute the minimax-optimal magnitude response $|H(e^{j\omega})|$, which is of order $N$ (therefore has $N+1$ coefficients). Given $\Omega_S$, $\Omega_P$ and $K_{des}$, start with an initial guess for $K$ such that $K\ge4K_{des}(K_{des}+1)$ for a physically meaningful design. (See Appendix \ref{app:unique_intersection} for the derivation of this lower bound for weight as well as the justification for why the following iterations converge.) \begin{itemize} \item[1.] Compute the coefficients of the minimax-optimal even-symmetric (therefore zero-phase) filter $g[n]$ of order $2N$ to approximate the target function \begin{equation} D(\omega)=\left\{\begin{array}{lr} 1, & \omega \in \Omega_P\\ 0,& \omega \in \Omega_S\\ \end{array} \right. \end{equation} with the weight function \begin{equation} W(\omega)=\left\{\begin{array}{lr} 1, & \omega \in \Omega_P\\ K,& \omega \in \Omega_S\\ \end{array} \right.. \end{equation} This can be done directly using the Remez Exchange algorithm, or modifying the Parks-McClellan algorithm, etc. \item[2.] Compute $G(e^{j\omega})$, the frequency response of $g[n]$, and compute the maximum value of passband error $\Delta_P$ for this $g[n]$. (This is also equivalent to the maximum value of the absolute weighted error $|W(\omega)(G(e^{j\omega})-D(\omega))|$). \item[3.] If the resulting $\Delta_P$ from step 2 satisfies the equality in equation (\ref{eqn:Delta_P}), go to step 4. Otherwise \begin{itemize} \item[(i)] If $\Delta_P$ is smaller than the expression in equation (\ref{eqn:Delta_P}), then increase the value of $K$ and go to step 1. \item[(i)] If $\Delta_P$ is greater than the expression in equation (\ref{eqn:Delta_P}), then decrease the value of $K$ and go to step 1. \end{itemize} The amount by which $K$ is increased or decreased, or the bounds of the search space, can be decided in several ways, including methods such as binary search (or bisection method), Newton-Raphson method, or any other appropriate numerical method. Any choice of $K$ must satisfy $K\ge4K_{des}(K_{des}+1)$ for a physically meaningful design. \item[4.] Compute scale and shift coefficients $a$ and $b$ using equations (\ref{eqn:b_better}) and (\ref{eqn:a_better}). \item[5.] Compute the function $p[n]$ from $g[n]$ as $p[n]=a\cdot g[n]+b\cdot \delta[n]$, where $\delta[n]$ is the unit impulse function (not to be confused with passband or stopband ripples of $|H(e^{j\omega})|$, namely $\delta_P$ or $\delta_S$.). This $p[n]$ is the autocorrelation that we were looking for. \item[6.] Using any method including but not limited to spectral factorization, obtain the coefficients of $h[n]$ from the autocorrelation sequence $p[n]$. There will be more than one filter for which the autocorrelation sequence is $p[n]$, all of which are related to one another through a cascade with an allpass filter. Choosing the zeros in the unit circle as well as one from each pair of zeros located on the unit circle leads to a minimum phase design. Choosing all the zeros outside the unit circle and one pair from each pair on the unit circle leads to a maximum phase design. If a minimum phase design is desired but the filter order is too high to perform spectral factorization using polynomial root finding, methods in \cite{Boite1981, Chen1986, Venkata1999, Kamp1983, Mian1982} can be used to find the minimum phase solution. Other solutions can then be found by finding the roots of this lower order polynomial and reflecting the zeros from inside the unit circle to outside of the unit circle as desired. \end{itemize} \textbf{Example:} Figure \ref{fig:high_order_example} illustrates the design of a high pass filter where $N=500$, $\Omega_P=[0.40\pi, \pi]$, $\Omega_S=[0,0.39\pi]$ and $K_{des}=2$. In this particular design, for the desired relative ratio of $K_{des}=2$ between the passband and the stopband deviations, the weight $K$ to be applied during the the design of the zero phase sequence $g[n]$ was computed as $9801.96$ corresponding to $\Delta_P=3.2646E-3$ in the iterative procedure in Section \ref{subsec:overall}. This pair of $(K, \Delta_P)$ can be verified to satisfy equation (\ref{eqn:Delta_P}) which was obtained through only few iterations using the bisection method. Figure \ref{fig:high_order_example}a illustrates the minimum phase impulse response obtained using our design algorithm, which is the globally optimal solution that approximates the desired response if no restrictions on phase exist as certified by Theorem \ref{thm:main_res}, and that is designed as a linear phase filter using the \texttt{firpm} function in MATLAB based on the Parks-McClellan algorithm \cite{Parks1972}. Figure \ref{fig:high_order_example}b, \ref{fig:high_order_example}c and \ref{fig:high_order_example}d illustrate the comparisons of magnitude responses in the entire frequency range, in the passband and in the stopband respectively. Removing the restrictions on the phase has clearly led to a sharper magnitude response characteristic. Furthermore, since this is a minimum phase design, the group delay in the entire passband is much less than that of the linear phase design at the expense of a non-constant delay profile. Since this is a very high order filter, a polynomial root finding based spectral factorization was impractical and we exploited the algorithm in \cite{Boite1981} instead to compute $h[n]$ from the computed $p[n]$, where we used a matlab implementation of this algorithm provided in \cite{JOSweb}. \begin{figure} \centering \subfloat[]{\includegraphics[scale =0.25] {high_order_example_a.eps}}\\ \subfloat[]{\includegraphics[scale =0.25] {high_order_example_b.eps}}\\ \subfloat[]{\includegraphics[scale =0.25] {high_order_example_c.eps}}\\ \subfloat[]{\includegraphics[scale =0.25] {high_order_example_d.eps}}\\ \subfloat[]{\includegraphics[scale =0.25] {high_order_example_e.eps}}\\ \caption{Comparison of our optimal design to a linear phase design for a high-pass filter where $N=500$, $\Omega_P=[0.40\pi, \pi]$, $\Omega_S=[0,0.39\pi]$ and $K_{des}=2$. (a) the impulse responses, (b) the magnitude responses, (c) the magnitude response zooming into the passband, (d) the magnitude response zooming into the stopband, (e) the group delays in samples in the passband. }\label{fig:high_order_example} \end{figure} \appendices \section{Proof for Convergence of Iterations}\label{app:unique_intersection} First we show that the resulting passband ripple $\Delta_{P,res}$ of a zero-phase $G(e^{j\omega})$ obtained by applying a weight $K$ is an increasing function of $K$, i.e. if we design a filter for the same passband and stopband specifications but with a larger $K$, then $\Delta_{P,res}$ will be also higher. Here the subscript $res$ stands for ``resulting". We can prove that $\Delta_{P,res}(K)$ is an increasing function of $K$ by contradiction. Assume that the maximum weighted error in a filter $G_1(e^{j\omega})$ designed with a weight function \begin{equation} W_1(\omega)=\left\{\begin{array}{lr} 1, & \omega \in \Omega_P\\ K_1,& \omega \in \Omega_S\\ \end{array} \right. \end{equation} is given by \begin{equation} \Delta_{P1} = \max_{\omega\in(\Omega_P \cup \Omega_S)}\left|E_{W1}(\omega)\right| \end{equation} where \begin{equation} E_{W1}(\omega) = W_1(\omega)\left(G_1(e^{j\omega})-D(\omega)\right). \end{equation} Similarly define $W_2(\omega)$, $E_{W2}(\omega)$ and $\Delta_{P2}$ for another filter $G_2(e^{j\omega})$ and weight scalar $K_2$, which is greater than $K_1$. Since $G_1$ and $G_2$ are real-valued frequency responses, they can be designed using the Remez Exchange Algorithm and they will be the respective unique optimal-minimax designs since they satisfy the alternation theorem with at least $N+2$ alternations. In order to obtain the contradiction, assume $\Delta_{P2}\le \Delta_{P1}$. We can compute another weighted error function $E_{12}(\omega)$ using the weight $W_1(\omega)$ along with $G_2(e^{j\omega})$ as \begin{equation} E_{12}(\omega) = W_1(\omega)\left(G_2(e^{j\omega})-D(\omega)\right). \end{equation} The maximum value of this weighted error $\Delta_{P12}$ becomes \begin{equation} \Delta_{P12}=\max_{\omega\in(\Omega_P \cup \Omega_S)}\left|E_{12}(\omega)\right| = \max\left\{\Delta_{P2},K_1\Delta_{S2} \right\}. \end{equation} Since both $\Delta_{P2}$ and $K_1\Delta_{S2}=K_1\frac{\Delta_{P2}}{K_2}$ are at most $\Delta_{P2}$, the filter $G_2(e^{j\omega})$ is at least as good as $G_1(e^{j\omega})$ in approximating the desired function with the weight function $W_1(\omega)$, which contradicts the unique optimality of the latter which had been established by the alternation theorem. Therefore, for $K_2>K_1$, the passband error $\Delta_{P2}$ cannot be equal or smaller than $\Delta_{P1}$. This implies $\Delta_P(K)$ is a strictly increasing function of $K$. Now consider the range of weights $K$ that results in physically meaningful designs. For a given weight $K_{des}$, we can always design a trivial filter $h[n]=\frac{1}{1+K_{des}}\delta[n]$, which leads to stopband error $\delta_S=\frac{1}{1+K_{des}}$ and passband error $\delta_P=\frac{K_{des}}{1+K_{des}}$, which satisfy the desired weight constraint $\frac{\delta_P}{\delta_S}=K_{des}$. The sum of these errors is exactly unity. Therefore, in an optimal design with $N+1$ coefficients, the sum of these errors can never be larger than unity, and we have \begin{equation} \delta_P+\delta_S = (K_{des}+1)\delta_S \le 1. \end{equation} Inserting $\delta_S$ from equation (\ref{eqn:delta_S}), we obtain \begin{equation} (K_{des}+1)\frac{4K_{des}}{K}\le 1, \end{equation} which yields the physically meaningful lower bound for the weight $K$ as \begin{equation}\label{eqn:physically_meaningful_K} K\ge4K_{des}(K_{des}+1). \end{equation} We need to find the weight $K$ that yields a resulting value of weighted error $\Delta_{P,res}$ that is equal to the expression for $\Delta_P$ in equation (\ref{eqn:Delta_P}). We have already established $\Delta_{P,res}(K)$ is an increasing function of $K$ and is always lower than $1-\Delta_S(K)$. On the other hand, $\Delta_P(K)$ stated in equation (\ref{eqn:Delta_P}) equals $1-\delta_S$ at the lower bound we just found in equation (\ref{eqn:physically_meaningful_K}), is monotonically decreasing for weights greater than this lower bound and asymptotically approaching zero. This means these two functions do intersect once and only once in this regime of weights, and that is the weight we are looking for. This is also another proof that an optimum exists and it is unique. Figure \ref{fig:unique_intersect} illustrates an example of $\Delta_P(K)$ and $\Delta_{P,res}$ curve for $w_{des}=2$, $\Omega_S=[0,0.36\pi]$ and $\Omega_P=[0.42\pi,\pi]$ where the physically meaningful values of $K$ start as $24$. During the iterations, if $\Delta_{P,res}(K)>\Delta_P(K)$, the current value of $K$ is to the right of the intersection and therefore needs to be decreased. Otherwise, it is increased, and the iterations continue until the two values meet. The search is particularly efficient if the search space is halved each time, corresponding to the binary search (or bisection) scheme. \begin{figure} \begin{center} \includegraphics[scale =0.35] {unique_intersect.eps} \caption{An example of the resulting passband deviation $\Delta_{P,res}$ as a function of weight K and the function $\Delta_P$ given in equation (\ref{eqn:Delta_P}).}\label{fig:unique_intersect} \end{center} \end{figure} \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran}
{'timestamp': '2016-08-11T02:07:03', 'yymm': '1608', 'arxiv_id': '1608.03161', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03161'}
arxiv
\section{Conclusion and Discussion} \label{sec:Conclusion} We have studied the sphericity and contact dimension of the complete bipartite graph in various metrics. We have proved lower and upper bounds on these measures for some metrics. However, biclique sphericity and biclique contact dimension in the $L^1$-metric remains poorly understood as we are unable to show any strong upper or lower bounds. However, we believe that both $L^1$ and $L^2$ metrics have linear upper and lower bounds. To be precise, we raise the following conjecture: \begin{conjecture}[$L^1$-Biclique Sphericity Conjecture] $$\mathsf{bsph}(L^1)=\Omega(n).$$ \end{conjecture} We have also shown conditional lower bounds for the Closest Pair problem in the $L^p$-metric, for all $p\in\mathbb{R}_{> 2}\cup\{\infty\}$, by using polar-pair of point-sets. However, it is unlikely that our techniques could get to the regime of $L^2$, $L^1$, and $L^0$, which are popular metrics. An open question is thus whether there exists an alternative technique to derive a lower bound from OVH to the Closest Pair problem for these metrics. The answer might be on the positive side, i.e., there might exist an algorithm that performs well in the $L^2$-metric because there are more tools available, e.g., Johnson-Lindenstrauss' dimension reduction. Thus, it is possible that there exists a strongly subquadratic-time algorithm in the $L^2$-metric. This question remains an outstanding open problem. \section{Fine-Grained Complexity of \mbox{{\sc Closest Pair}}\xspace in $L^{\infty}$} \label{sec:connection-to-closest-pair} In this section, we prove the quadratic-time hardness of \mbox{{\sc Closest Pair}}\xspace in the $L^{\infty}$-metric. Our reduction is from the {\em Orthogonal Vectors} problem (\mbox{{\sc OV}}\xspace), which we phrase it as follows. Given a pair of collections of vectors $U,W\subseteq\{0,1\}^d$, the goal is to find a pair of vectors $u\in U$ and $w\in W$ such that $(u_i,w_i)\in \{(0,0),(0,1),(1,0)\}$ for all $i\in[d]$. Throughout, we denote by $n$ the total number of vectors in $U$ and $W$. \subsection{Reduction} \label{sec:base-reduction} Let $U,W\subseteq\{0,1\}^d$ be an instance of \mbox{{\sc OV}}\xspace. We may assume that $U$ and $W$ have no duplicates. Otherwise, we may sort vectors in $U$ (resp., $W$) in lexicographic order and then sequentially remove duplicates; this preprocessing takes $O(dn\log n)$-time. We construct a pair of sets $A,B\subseteq\mathbb{R}^d$ of \mbox{{\sc BCP}}\xspace from $U,W$ as follows. For each vector $u\in U$ (resp., $w\in W$), we create a point $a\in A$ (resp., $b\in B$) such that \begin{minipage}{0.48\textwidth} $$a_j=\begin{cases} 0& \text{if }u_j=0,\\ 2& \text{if }u_j=1. \end{cases}$$ \end{minipage} \begin{minipage}{0.48\textwidth} $$b_j=\begin{cases} 1& \text{if }w_j=0,\\ -1& \text{if }w_j=1. \end{cases}$$ \end{minipage} \vspace{0.1cm} Observe that, for any vectors $a\in A$ and $b\in B$, $|a_j-b_j|=3$ only if $u_j=w_j=1$; otherwise, $|a_j-b_j|=1$. It can be seen that $\|a-b\|_p=d$ if and only if their corresponding vectors $u\in U$ and $w\in W$ are orthogonal. Thus, this gives an alternate proof for the quadratic-time hardness of $\mbox{{\sc BCP}}\xspace$ under OVH. \subsection{Analysis} \label{sec:max-norm-closest-pair} Here we show that the reduction in Section~\ref{sec:base-reduction} rules out both exact and $2$-approximation algorithm for \mbox{{\sc Closest Pair}}\xspace in $L^{\infty}$ that runs in subquadratic-time (unless OVH is false). That is, we prove Theorem~\ref{thm:closest-hardness-max-norm}, which follows from the theorem below. \begin{theorem}\label{thm:Hardness-ClosestPairinf} Assuming OVH, for any $\varepsilon>0$ and $d=\omega(\log n)$, there is no $O\left(n^{2-\varepsilon}\right)$-time algorithm that, given a point-set $P\subseteq\mathbb{R}^d$, distinguishes between the following two cases: \begin{itemize} \item There exists a pair of vectors in $P$ with $L^{\infty}$-distance one. \item Every pair of vectors in $P$ has $L^{\infty}$-distance two. \end{itemize} In particular, approximating \mbox{{\sc Closest Pair}}\xspace in the $L^{\infty}$-metric to within a factor of two is at least as hard as solving the Orthogonal Vectors problem. \end{theorem} \begin{proof} Consider the sets $A$ and $B$ constructed from an instance of \mbox{{\sc OV}}\xspace in Section~\ref{sec:base-reduction}. First, observe that every inner pair has $L^{\infty}$-distance at least $2$. To see this, consider an inner pair $a,a'\in A$. Since all inner pairs are distinct, they must have at least one different coordinate, say $a_j\neq a'_j$ for some $j\in\{1,\ldots,n/2\}$. Consequently, $(a_j,a'_j)\in\{(0,2),(2,0)\}$, implying that the $L^{\infty}$-distance of $a$ and $a'$ is at least $2$. The case of an inner pair $b,b'\in B$ is similar. Thus, any pair of vectors with $L^{\infty}$-distance less than two must be a crossing pair $a\in A, b\in B$. Now suppose there is a pair of orthogonal vectors $u^*\in U, w^*\in W$, and let $a^*\in A$ and $b^*\in B$ be the corresponding vectors of $u^*$ and $w^*$ in the \mbox{{\sc Closest Pair}}\xspace instance, respectively. Then we know from the construction that $(a^*_j,b^*_j)\in\{(0,1),(0,-1),(2,1)\}$ for all coordinates $j\in[n]$. Thus, the $L^{\infty}$-distance of $a^*$ and $b^*$ must be one. Next suppose that there is no orthogonal pair of vectors in $U \times W$. Then every vectors $u\in U$ and $w\in W$ must have one coordinate, say $j$, such that $u_j=w_j=1$. So, the corresponding vectors $a$ and $b$ (of $u$ and $w$, respectively) must have $a_i=2, b_j=-1$. This means that $a$ and $b$ have $L^{\infty}$-distance at least three. (Note that there might be an inner pair with $L^{\infty}$-distance two.) Therefore, we conclude that every pair of points in $A\cup B$ has $L^{\infty}$-distance at least two. \end{proof} \section{Geometric Representation of Biclique in $L^0$} \label{sec:L0-dim} In this section, we prove a lower bound on $\mathsf{bsph}(L^0)$ and an upper bound on $\mathsf{bcd}(L^0)$. We start by providing a real-to-binary reduction below. Then we proceed to prove the lower bound on $\mathsf{bsph}(L^0)$ in Section~\ref{sec:L0-dim:lower-bound} and then the upper bounds on $\mathsf{bcd}(L^0)$ in Section~\ref{sec:L0-dim:upper-bound}. \paragraph*{Real to Binary Reduction.} \label{sec:L0-dim:str-to-bin} First we prove the following (trivial) lemma, which allows mapping from vectors in $\mathbb{R}^d$ to zero-one vectors. \begin{lemma}[Real to Binary Reduction] \label{lem:trivial-real-to-binary} Let $S\subseteq \mathbb{R}$ be a finite set of real numbers. Then there exists a transformation $\phi:S^d\rightarrow\{0,1\}^{d|S|}$ such that, for any $x,y\in S^d$, \[ \|x-y\|_0 = \frac{1}{2}\cdot\|\phi(x)-\phi(y)\|_0 \] \end{lemma} \begin{proof} First, we order the elements in $S$ in an arbitrary order and write it as $S=\{r_1,r_2,\ldots,r_{|S|}\}$. Next we define $\psi:S\rightarrow\{0,1\}^{|S|}$ so that the $i$-th coordinate of $\psi(r_i)$ is $1$, and the rest are zeroes. That is, \[ \psi(r_i)_j=\left\{ \begin{array}{ll} 1 & \mbox{if $j=i$}\\ 0 & \mbox{otherwise} \end{array}\right. \] Then we define $\phi(x)=(\psi(x_1),\psi(x_2),\ldots,\psi(x_d))$. Clearly, $\|\psi(r_i)-\psi(r_j)\|_0=2$ if and only if $r_i\neq r_j$. Therefore, we conclude that for any $x,y\in P$, \[ \|\phi(x)-\phi(y)\|_0 = 2\cdot \|x-y\|_0.\qedhere \] \end{proof} \subsection{Lower Bound on the Biclique-Sphericity} \label{sec:L0-dim:lower-bound} Now we will show that $\mathsf{bsph}(L^0) \geq n$. Our proof requires the following lemma, which rules out a randomized algorithm that generates a polar-pair of point-sets. \begin{lemma}[No Distribution for $L^0$] \label{lem:no-distribution-for-l0} For any $\alpha > \beta \geq 0$, regardless of dimension, there exist no distributions $\mathcal{A}$ and $\mathcal{B}$ of points in $\mathbb{R}^d$ with finite supports such that \begin{itemize} \item $\mathbb{E}_{x,x'\in_{R}\mathcal{A}}[\|x-x'\|_0] \geq \alpha$. \item $\mathbb{E}_{y,y'\in_{R}\mathcal{B}}[\|y-y'\|_0] \geq \alpha$. \item $\mathbb{E}_{x\in_{R}\mathcal{A},y\in_{R}\mathcal{B}}[\|x-y\|_0] \leq \beta$. \end{itemize} \end{lemma} \begin{proof} We prove by contradiction. Assume to a contrary that such distributions exist. Then \begin{equation} \label{eq:L0-expected-distance} \mathbb{E}_{x,x'\in_{R}\mathcal{A}}[\|x-x'\|_0] + \mathbb{E}_{y,y'\in_{R}\mathcal{B}}[\|y-y'\|_0] - 2\mathbb{E}_{x\in_{R}\mathcal{A},y\in_{R}\mathcal{B}}[\|x-y\|_0] > 0. \end{equation} Let $A$ and $B$ be supports of $\mathcal{A}$ and $\mathcal{B}$, respectively. By Lemma~\ref{lem:trivial-real-to-binary}, we may assume that vectors in $A$ and $B$ are binary vectors. Observe that each coordinate of vectors in $A$ and $B$ contribute to the expectations independently. In particular, Eq.~\eqref{eq:L0-expected-distance} can be written as \begin{equation} \label{eq:L0-expand-the-sum} 2\sum_{i}\rho^A_{0,i}\rho^A_{1,i} + 2\sum_{i}\rho^B_{0,i}\rho^B_{1,i} + 2\sum_{i}\left(\rho^A_{0,i}\rho^B_{1,i} + \rho^B_{0,i}\rho^A_{1,i}\right) >0 \end{equation} where $\rho^A_{0,i}$, $\rho^A_{1,i}$, $\rho^B_{0,i}$ and $\rho^B_{1,i}$ are the probability that the $i$-th coordinate of $x\in A$ (resp., $y\in B$) is $0$ (resp., $1$). Thus, to show a contradiction, it is sufficient to consider the coordinate which contributes the most to the summation in Eq.~\eqref{eq:L0-expand-the-sum}. The contribution of this coordinate to the summation is \begin{equation} \label{eq:L0-one-coordinate-contribution} 2\rho^A_0\rho^A_1 + 2\rho^B_0\rho^B_1 - 2(\rho^A_0\rho^B_1 + \rho^A_1\rho^B_0) = 2(\rho^A_0(\rho^A_1-\rho^B_1) + 2(\rho^B_0(\rho^B_1-\rho^A_1) = 2(\rho^A_0-\rho^B_0)(\rho^A_1-\rho^B_1) \end{equation} Since $\rho^A_0+\rho^A_1=1$ and $\rho^B_0+\rho^B_1=1$, the summation in Eq.\eqref{eq:L0-one-coordinate-contribution} can be non-negative only if $\rho^A_0=\rho^B_0$ and $\rho^A_1=\rho^B_1$. But, then this implies that the summation in Eq.\eqref{eq:L0-one-coordinate-contribution} is zero. We have a contradiction since this coordinate contributes the most to the summation in Eq.~\eqref{eq:L0-expand-the-sum} which we assume to be positive. \end{proof} The next Theorem shows that $\mathsf{bsph}(L^0) \geq n$. \begin{theorem}[Lower Bound for $L^0$ with Arbitrary Alphabet] \label{thm:LB-point-set-l0-arbitrary} For any integers $\alpha>\beta\geq 0$ and $n>0$, there exist no subsets $A,B\subseteq \mathbb{R}^d$ of $n$ vectors with $d<n$ such that \begin{itemize} \item For any $a,a'\in A$, $\|a-a'\|_0 \geq \alpha$. \item For any $b,b'\in B$, $\|b-b'\|_0 \geq \alpha$. \item For any $a\in A$ and $b\in B$, $\|a-b\|_0 \le\beta$. \end{itemize} \end{theorem} \begin{proof} Suppose for a contradiction that such subsets $A$ and $B$ exist with $d<n$. We build uniform distributions $\mathcal{A}$ and $\mathcal{B}$ by uniformly at random picking a vector in $A$ and $B$, respectively. Then it is easy to see that the expected value of inner distance is \[ \mathbb{E}_{x,x'\in_{R}\mathcal{A}}[\|x-x'\|_0] \geq \alpha-\frac{\alpha}{n} \] The inner distance of $B$ is similar. We know that $\alpha-\beta\geq 1$ because they are integers and so are $L^0$-distances. But, then if $\alpha < n$, we would have distributions that contradict Lemma~\ref{lem:no-distribution-for-l0}. Note that $\alpha$ and $\beta$ are at most $d$ (dimension). Therefore, we conclude that $d\geq n$. \end{proof} \subsection{Upper Bound on the Biclique Contact-Dimension} \label{sec:L0-dim:upper-bound} Now we show that $\mathsf{bcd}(L^0)\leq n$. \begin{theorem}[Upper Bound for $L^0$ with Arbitrary Alphabet] \label{thm:ub-point-set-l0-arbitrary} For any integer $n>0$ and $d=n$, there exist subsets $A,B\subseteq \mathbb{R}^d$ each with $n$ vectors such that \begin{itemize} \item For any $a,a'\in A$, $\|a-a'\|_0 = d$. \item For any $b,b'\in B$, $\|b-b'\|_0 = d$. \item For any $a\in A$ and $b\in B$, $\|a-b\|_0 = d-1$. \end{itemize} \end{theorem} \begin{proof} First we construct a set of vectors $A$. For $i=1,2,\ldots,n$, we define the $i$-th vector $a$ of $A$ so that $a$ is an all-$i$ vector. That is, \[ a=(i,i,\ldots,i). \] Next we construct a set of vectors $B$. The first vector of $B$ is $(1,2,\ldots,n)$. Then the $(i+1)$-th vector of $B$ is the left rotation of the $i$-th vector. Thus, the $i$-th vector of $B$ is \[ b=(i,i+1,\ldots,n,1,2,\ldots,i-1). \] It can be seen that the $L^0$-distance between any two vectors from the same set is $d$ because all the coordinates are different. Any vectors from different set, say $a\in A$ and $b\in B$, must have at least one common coordinate. Thus, their $L^0$-distance is $d-1$. This proves the lemma. \end{proof} Below is the upper bound for zero-one vectors, which is a corollary of Theorem~\ref{thm:ub-point-set-l0-arbitrary}. \begin{corollary}[Upper Bound for $L^0$ with Binary Vectors] \label{cor:ub-point-set-l0-binary} For any integer $n>0$ and $d=n^2$, there exist subsets $A,B\subseteq \mathbb{R}^d$ each with $n$ vectors such that \begin{itemize} \item For any $a,a'\in A$, $\|a-a'\|_0 = n$. \item For any $b,b'\in B$, $\|b-b'\|_0 = n$. \item For any $a\in A$ and $b\in B$, $\|a-b\|_0 = n-1$. \end{itemize} \end{corollary} \begin{proof} We take the construction from Theorem~\ref{thm:ub-point-set-l0-arbitrary}. Denote the two sets by $A'$ and $B'$, and denote their dimensions by $d'=n$. We transform $A'$ and $B'$ to sets $A$ and $B$ by applying the transformation $\phi$ in Lemma~\ref{lem:trivial-real-to-binary}. That is, \[ A=\{\phi(a):a\in A'\} \quad\mbox{and}\quad B=\{\phi(b):b\in B'\}. \] Since the alphabet set in Lemma~\ref{lem:trivial-real-to-binary} is $[n]$, we have a construction of $A$ and $B$ with dimension $d=n^2$. \end{proof} \section{Geometric Representation of Biclique in $L^1$} \label{sec:L1-possibility} In this section, we discuss the case of the $L^1$-metric. As discussed in the introduction, this is the only case where we are unable to prove neither strong lower bound nor linear upper bound. A weak lower bound $\mathsf{bsph}(L^1)\geq\Omega(\log n)$ follows from the proof for the $L^p$-metric with $p>2$ in Section~\ref{sec:Lp-dim:lower-bound} (Theorem~\ref{thm:lower-bound-Lp}), and a quadratic upper bound $\mathsf{bcd}(L^1)\leq n^2$ follows from the proof for the $L^0$-metric in Section~\ref{sec:L0-dim:upper-bound} (Corollary~\ref{cor:ub-point-set-l0-binary}). However, we cannot prove any upper bound smaller than $\Omega(n^2)$ or any lower bound larger than $O(\log n)$. Hence, we study an average case relaxation of the question. We show in Theorem~\ref{lem:NoDistL1} that there is no distribution whose expected distances simulate a polar-pair of point-sets in the $L^1$-metric. Consequently, even though we could not prove the biclique sphericity lower bound for the $L^1$-metric, we are able to refute an existence of a geometric representation with {\em large gap} for any dimension as shown in Corollary~\ref{lem:LB-point-set-l1-large-gap}. (A similar result was shown in \cite{DM94} for the $L^2$-metric.) \renewcommand{\sup}{\mathsf{supp}} \begin{definition}[$L^1$-distribution] \label{def:ell1-distribution} For any $d>0$, let $X,Y$ be two random variables taking values from $\mathbb{R}^{d}$. An $L^{1}$-distribution is constructed by $X,Y$ if the following holds. \begin{equation} \label{eq3} \begin{aligned} \underset{x_{1},x_{2}\in_{R}X}{\mathbb{E}}\left[\left\Vert x_{1}-x_{2}\right\Vert _{1}\right]>\underset{x_{1}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}\right],\\ \underset{y_{1},y_{2}\in_{R}Y}{\mathbb{E}}\left[\left\Vert y_{1}-y_{2}\right\Vert _{1}\right]>\underset{x_{1}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}\right]\,. \end{aligned} \end{equation} \end{definition} { \renewcommand{\thetheorem}{\ref{lem:NoDistL1}} \begin{theorem}[Restated] For any two finite-supported random variables $X,Y$ that are taking values from $\mathbb{R}^{d}$, there is no $L^{1}${-distribution.} \end{theorem} \addtocounter{theorem}{-1} } \begin{proof} Assume towards a contradiction that there exist two finite-supported random variables $X,Y$ that are taking values in $\mathbb{R}^{d}$ and that are satisfying Eq.~\ref{eq3} of Definition~\ref{def:ell1-distribution}. Given a vector $x\in\mathbb{R}^{d}$, we denote by $x\left(i\right)$ the value of the $i$-th coordinate of $x$. Hence the following inequalities hold, \begin{align*} 0 & >\underset{x_{1}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}\right]-\underset{x_{1},x_{2}\in_{R}X}{\mathbb{E}}\left[\left\Vert x_{1}-x_{2}\right\Vert _{1}\right]\\ & =\underset{x_{1},x_{2}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}-\left\Vert x_{1}-x_{2}\right\Vert _{1}\right]\\ & =\frac{1}{d}\cdot \underset{x_{1},x_{2}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\underset{i\in_{R}\left[1...d\right]}{\mathbb{E}}\left[| x_{1}\left(i\right)-y_{1}\left(i\right)|-|x_{1}\left(i\right)-x_{2}\left(i\right)|\right]\right]\\ & =\frac{1}{d}\cdot \underset{i\in_{R}\left[1...d\right]}{\mathbb{E}}\left[\underset{x_{1},x_{2}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[| x_{1}\left(i\right)-y_{1}\left(i\right)|-| x_{1}\left(i\right)-x_{2}\left(i\right)|\right]\right]\,. \end{align*} Thus for some $i^{\star}\in[d]$ the following holds, \begin{align} 0>\underset{x_{1},x_{2}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[| x_{1}\left(i^{\star}\right)-y_{1}\left(i^{\star}\right)|-| x_{1}\left(i^{\star}\right)-x_{2}\left(i^{\star}\right)|\right]\,. \label{reduce} \end{align} Fix $i^\star\in [d]$ satisfying the above inequality. For the sake of clarity, we assume that the random variables $X,Y$ are taking values in $\mathbb{R}$ (i.e., projection on the $i^{\star\text{th}}$ coordinate). We can assume that the size of $\sup\left(X\right)\cup \sup\left(Y\right)$ is greater than 1 because if $\sup\left(X\right)\cup \sup\left(Y\right)$ contains a single point, then $\underset{x_{1}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}\right]=\underset{x_{1},x_{2}\in_{R}X}{\mathbb{E}}\left[\left\Vert x_{1}-x_{2}\right\Vert _{1}\right]=0$, contradicting Eq.~\ref{reduce}. Let $\sup\left(X\right)\cup \sup\left(Y\right)$ contains $t\ge 2$ points. We prove by induction on $t$, that there are no $X,Y$ over $\mathbb{R}$ satisfying Eq.~\ref{reduce}. The base case is when $t=2$. By Eq.~\ref{reduce}, there exists 3 points $\tilde{x}_1,\tilde{x}_2,\tilde{y}_1$ in $\mathbb{R}$ such that \begin{equation} 0>\left\Vert \tilde{x}_{1}-\tilde{y}_{1}\right\Vert_{1}-\left\Vert \tilde{x}_{1}-\tilde{x}_{2}\right\Vert_{1}\,.\label{eq:3points} \end{equation} Since $\sup\left(X\right)\cup \sup\left(Y\right)$ contains exactly two points, $\tilde{x}_1,\tilde{x}_2,\tilde{y}_1$ are supported by two distinct points in $\mathbb{R}$. Hence, there are two cases either that $x_{1}=x_{2}$ (and $y_{1}\neq x_{1}$) or that $x_{1}\neq x_{2}$ (and either $\tilde{y}_1=\tilde{x}_1$ or $\tilde{y}_1=\tilde{x}_2$). It is easy to see that none of these cases satisfy Eq.~\ref{eq:3points}, a contradiction. Assume the induction hypothesis that there are no $X,Y$ taking values from $\mathbb{R}$ satisfying Eq.~\ref{reduce} when the size of $\sup\left(X\right)\cup \sup\left(Y\right)$ is equal to $k\ge 2$. Then consider the case when $t=k+1\ge 3$. Sort the points in $\sup\left(X\right)\cup \sup\left(Y\right)$ by their values, and denote by $s_{i}$ the value of the $i$-th point of $\sup\left(X\right)\cup \sup\left(Y\right)$. For the sake of simplicity, we say that we \emph{change} the value of $s_{t-1}$ to $\tilde{s}_{t-1}$, where $s_{t-2}\le\tilde{s}_{t-1}\le s_{t}$, if after changing its value we change the values of (at least one of) $X,Y$ to $\tilde{X},\tilde{Y}$ in such a way that the value of the $(t-1)$-th point (after sorting) of $\sup\left(\tilde{X}\right)\cup \sup\left(\tilde{Y}\right)$ is equal to $\tilde{s}_{t-1}$ (if $s_{t-2}=\tilde{s}_{t-1}$, then the value of the $\left(t-2\right)$-th point of $\sup\left(\tilde{X}\right)\cup \sup\left(\tilde{Y}\right)$ is equal to $\tilde{s}_{t-1}$). Define the function $f:\,\left[s_{t-2},s_{t}\right]\rightarrow\mathbb{R}$ as follows: $$f\left(x\right)= \underset{x_{1}\in_{R}\tilde{X},\,y_{1}\in_{R}\tilde{Y}}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}\right]-\underset{x_{1},x_{2}\in_{R}\tilde{X}}{\mathbb{E}}\left[\left\Vert x_{1}-x_{2}\right\Vert _{1}\right]\,, $$ where $\tilde{X},\tilde{Y}$ are obtained after changing $s_{t-1}$ to $x\in\left[s_{t-2},s_{t}\right]$. The crucial observation is that the function $f$ is linear. Hence, either $f\left(s_{t-2}\right)\ge f\left(s_{t-1}\right)$ or $f\left(s_{t}\right)\ge f\left(s_{t-1}\right)$, and we can reduce the size of $\sup\left(X\right)\cup \sup\left(Y\right)$ by 1. However, this contradicts our induction hypothesis. \end{proof} The following corollary refutes the existence of a polar-pair of point-sets with large gap in any dimension. \begin{corollary}[No Polar-Pair of Point-Sets in $L^1$ with Large Gap] \label{lem:LB-point-set-l1-large-gap} For any $\alpha>0$, there exist no subsets $A,B\subseteq \mathbb{R}^d$ of $n/2$ vectors with $d<n/2$ such that \begin{itemize} \item For any $u,v$ both in $A$, or both in $B$, $\|u-v\|_1 \ge \frac{1}{1-2/n} \cdot \alpha$. \item For any $u\in A$ and $v\in B$, $\|u-v\|_1 < \alpha$. \end{itemize} \end{corollary} \begin{proof} Assume towards a contradiction that there exist a polar-pair of point-sets $(A,B)$ in the $L^1$-metric that satisfies the conditions above. We can create a distribution $X$ and $Y$ such that \[ \underset{x_{1},x_{2}\in_{R}X}{\mathbb{E}}\left[\left\Vert x_{1}-x_{2}\right\Vert _{1}\right] = \underset{y_{1},y_{2}\in_{R}Y}{\mathbb{E}}\left[\left\Vert y_{1}-y_{2}\right\Vert _{1}\right] > \underset{x\in_{R}X,y\in_{R}Y}{\mathbb{E}}\left[\left\Vert x-y\right\Vert _{1}\right] \] To see this, we create a uniform random variable $X$ (resp., $Y$) for the set $A$ (resp., $B$). Now the expected distance of two independent copies of $X$ (resp., $Y$) is at least $\frac{1}{1-2/n}\alpha\cdot \left(1-\frac{1}{n/2}\right) = \alpha$, which follows because we may pick the same point twice. Since the expected distance of the crossing pair $u\in A$ and $v\in B$ is less than $\alpha$. This contradicts Theorem~\ref{lem:NoDistL1}. \end{proof} We can show similar results that there are no polar-pairs of point-sets with large gap in the $L^0$ and $L^2$ metrics. The case of the $L^0$-metric follows directly from Theorem~\ref{lem:NoDistL1} when the alphabet set is $\{0,1\}$. (Please also see Lemma~\ref{lem:no-distribution-for-l0} for an alternate proof.) The case of the $L^2$-metric follows from the fact that $\mathsf{bsph}(L^2) = \Omega(n)$ \cite{FM88,M91} and that we can reduce the dimension of a polar-pairs of point-sets with constant gap to $O(\log n)$ using dimension reduction \cite{JL84}. \section{Geometric Representation of Biclique in $L^2$} \label{sec:L2-dim} \label{sec:L2-dim:lower-bound} In this section we prove a lower bound on $\mathsf{bsph}(L^2)$ of $(n-3)/2$ using spectral analysis. \begin{theorem} \label{thm:Lower bound on the embedding dimension} For every $n,d\in \mathbb{N}$, and any two sets $A,B\subseteq \mathbb{R}^{d}$, each of cardinality $n$, suppose the following holds for some non-negative real numbers $\alpha$ and $\beta$ with $\alpha>\beta$. \begin{enumerate} \item For every $u$ and $v$ both in $A$, $\|u-v\|_2>\alpha$. \item For every $u$ and $v$ both in $B$, $\|u-v\|_2>\alpha$. \item For every $u$ in $A$ and $v$ in $B$, $\|u-v\|_2\le \beta$. \end{enumerate} Then the dimension $d$ must be at least $\frac{n-3}{2}$. \end{theorem} \begin{proof} Let $\left|A\right|=\left|B\right|=n$ be \emph{arbitrary} two sets of vectors in $\mathbb{R}^{d}$ that satisfy the above conditions. We will show that $d\ge \frac{n-3}{2}$. First, we scale all the vectors in $A\cup B$ so that the vector with the largest $L^2$-norm in $A\cup B$ has $L^{2}$-norm equal to $1$ (by this scaling, the parameters $\alpha,\beta$ are scaled as well by, say $s$. For brevity, we will write $\alpha$ for $\alpha/s$ and similarly for $\beta$.). We modify $A$ and $B$ in two steps as follows. First, we add one new coordinate to all of the vectors with value $K\gg1$ (to be determined exactly later) and obtain $A_{1},B_{1}\subseteq\mathbb{R}^{d+1}$. Note that each element in the new set of vectors $A_{1}$ and $B_{1}$ has $L^{2}$-norm roughly equal to $K$. More specifically, the square of the $L^2$-norm is bounded between $K^2$ and $K^2+1$ and the vector with the largest $L^2$-norm in $A_1\cup B_1$ has $L^{2}$-norm equal to $\sqrt{K^2+1}$. By adding to the last coordinate of each vector $u$ in $A_{1}\cup B_{1}$ a positive value $c_u$ smaller than $1/K$, we can impose that all the vectors are with $L^{2}$-norm equal to $\sqrt{K^2+1}$. To see this, note that if we have a vector $u_1$ in $A_1\cup B_1$ that has $L^2$-norm equal to $K$ (namely, as small as possible), then by setting $c_{u_1}$ to satisfy \begin{equation} (K+c_{u_1})^2 = K^2 +1, \label{eq:K>>1} \end{equation} we have that the $L^2$-norm of $u_1$ is $\sqrt{K^2+1}$. So, any $c_{u_1}$ that solves Eq.~\ref{eq:K>>1} is smaller than $1/K$. By assuming that $u_1$ has a larger $L^2$-norm, we would have a better bound on $c_{u_1}$. Let $A'_{1} \cup B'_{1}$ be the set of vectors that was obtained by adding $c_u$'s as described above. Let $u,v$ be vectors in $A_{1}\cup B_{1}$ and let $u',v'$ be the corresponding vectors in $A'_{1}\cup B'_{1}$. By definition, the following holds: \begin{align*} \|u-v\|_2^2\le\|u'-v'\|_2^2 =\|u-v\|_2^2+(c_u-c_v)^2 \le \|u-v\|_2^2 + 1/K^2. \end{align*} Hence, by choosing $K$ to satisfy $1/K^2\le \frac{\alpha^2-\beta^2}{2}$, it follows that $A'_{1} \cup B'_{1}$ satisfies the conditions of the theorem with $\alpha'=\alpha$ and $\beta'=\sqrt{\beta^2+\frac{\alpha^2-\beta^2}{2}}< \alpha'$. Again, for brevity, we refer to $\alpha'$ as $\alpha$ and $\beta'$ as $\beta$. Given $A'_{1},B'_{1}\subseteq\mathbb{R}^{d+1}$, let $a_{1},a_{2},\ldots,a_{n}$ be the vectors from $A'_{1}$, and $b_{1},b_{2},\ldots,b_{n}$ be the vectors from $B'_{1}$. Consider the following matrix in $\mathbb{R}^{2\left(d+1\right)\times 2n}$: \begin{equation} M=\left(\begin{array}{cc} a_{1},a_{2},\ldots,a_{n} & b_{1},b_{2},\ldots,b_{n}\\ b_{1},b_{2},\ldots,b_{n} & a_{1},a_{2},\ldots,a_{n} \end{array}\right)\,\label{eq:Symmetric swap} \end{equation} Define the set $A_{2}$ to be the first $n$ column vectors of $M$ and define $B_{2}$ to be the last $n$ column vectors of $M$. Note that $A_{2}\cup B_{2}\subseteq\mathbb{R}^{2\left(d+1\right)}$ and satisfies the conditions of the theorem with $\alpha''=2\alpha'>2\beta'=\beta''$. Consider the inner product matrix $M^{T}M\in\mathbb{R}^{2n\times 2n}$ written in a block matrix form as follows: $$M^{T}M=cI_{2n\times 2n}+\left(\begin{array}{cc} M_{1,1} & M_{1,2}\\ M_{2,1} & M_{2,2} \end{array}\right) ,$$ where $M_{1,1},M_{1,2},M_{2,1},M_{2,2}\in\mathbb{R}^{n\times n}$ and $c$ is such that the matrix $\left(\begin{array}{cc} M_{1,1} & M_{1,2}\\ M_{2,1} & M_{2,2} \end{array}\right)$ has the value $0$ on the diagonal elements (recall that all the vectors have the same $L^{2}$-norm). By the definition of $M$ (see Eq.~\ref{eq:Symmetric swap}), one can check that the following hold. \begin{enumerate} \item The matrices $M_{1,1},M_{1,2},M_{2,1},M_{2,2}$ are all symmetric: for $M_{1,1},M_{2,2}$ it follows since $M^{T}M$ is a symmetric matrix, and for $M_{1,2},M_{2,1}$ it follows by the way $M$ was defined; see Eq.~\ref{eq:Symmetric swap}. \item $M_{1,1}=M_{2,2}$. This follows by Eq.~\ref{eq:Symmetric swap}. \item $M_{1,2}=M_{2,1}$. This follows since $M_{1,2}=M_{2,1}^{T}=M_{2,1}$. Here the first equality follows since $M^{T}M$ is a symmetric matrix, and the last equality follows by item~1. \end{enumerate} Hence, we can write $ M^{T}M=cI_{2n\times 2n}+\left(\begin{array}{cc} M_{1,1} & M_{1,2}\\ M_{1,2} & M_{1,1} \end{array}\right)\,. $ In the rest of the proof, we analyze some of the eigenvectors of $M^{T}M$. To this end, we consider the matrix $M_{1,1}-M_{1,2}$. Since both $M_{1,1}$ and $M_{1,2}$ are symmetric, we have that $M_{1,1}-M_{1,2}$ is symmetric and has real eigenvalues. Moreover, by the conditions of the theorem, it holds that $M_{1,1}-M_{1,2}$ is strictly negative (i.e., all the entries of the matrix are negative). This follows because all the vectors have the same $L^{2}$-norm. Let $x_{1},x_{2},\ldots,x_{n}$ be the eigenvectors of $M_{1,1}-M_{1,2}$ with eigenvalues $\lambda_{1},\lambda_{2},\ldots,\lambda_{n}$. By the Perron\textendash Frobenius Theorem it follows that $\lambda_{1}$ is strictly smaller than $\lambda_{2},\lambda_{3},\ldots,\lambda_{n}$. Let $x_{i}\in\mathbb{R}^{n}$ be an eigenvector of $M_{1,1}-M_{1,2}$ with eigenvalue $\lambda_{i}$. Then the following holds. \begin{align*} \left(\begin{array}{cc} M_{1,1} & M_{1,2}\\ M_{1,2} & M_{1,1} \end{array}\right)\left(\begin{array}{c} x_{i}\\ -x_{i} \end{array}\right) &=\left(\begin{array}{c} \left(M_{1,1}-M_{1,2}\right)x_{i}\\ -\left(M_{1,1}-M_{1,2}\right)x_{i} \end{array}\right)\\ &=\left(\begin{array}{c} \lambda_{i}x_{i}\\ -\lambda_{i}x_{i} \end{array}\right)\\ &=\lambda_{i}\left(\begin{array}{c} x_{i}\\ -x_{i} \end{array}\right). \end{align*} Hence, the vectors $\left(\begin{array}{c} x_{1}\\ -x_{1} \end{array}\right),\left(\begin{array}{c} x_{2}\\ -x_{2} \end{array}\right),\ldots,\left(\begin{array}{c} x_{n}\\ -x_{n} \end{array}\right)$ are eigenvectors of $\left(\begin{array}{cc} M_{1,1} & M_{1,2}\\ M_{1,2} & M_{1,1} \end{array}\right)$ with eigenvalues $\lambda_{1},\lambda_{2},\ldots,\lambda_{n}$. The operation of adding $cI_{2n\times 2n}$ to $\left(\begin{array}{cc} M_{1,1} & M_{1,2}\\ M_{1,2} & M_{1,1} \end{array}\right)$ shifts the eigenvalues of $M^{T}M$ to $\lambda_{1}+c,\lambda_{2}+c,\ldots,\lambda_{n}+c$. Since $M^{T}M$ is a positive semidefinite matrix, $\lambda_{1}+c,\lambda_{2}+c,\ldots,\lambda_{n}+c\ge0$. More specifically, $\lambda_{1}+c\ge0$ and $\lambda_{2}+c,\ldots,\lambda_{n}+c > 0$ (since $\lambda_{1}<\lambda_{2},\lambda_{3}\ldots,\lambda_{n}$). It follows that $M^{T}M$ has at least $n-1$ positive eigenvalues. Hence, the rank of $M^{T}M$ is at least $n-1$. By standard linear algebra arguments, it holds that the rank of $M$ is at least the rank of $M^{T}M$, and the rank of $M$ is at most $2\left(d+1\right)$. That is, \[ 2(d+1) \geq \mathrm{rank}(M) \geq \mathrm{rank}(M^TM) \geq n - 1.\qedhere \] \end{proof} \section{Geometric Representation of Biclique in $L^p$ for $p\in (1,2)$} \label{sec:Lp-between-1-and-2} In this section, we prove the upper bound on $\mathsf{bcd}(L^p)$ for $p\in(1,2)$. We are unable to show any lower bound for these $L_p$-metrics except for the lower bound of $\Omega(\log n)$ obtained from the $\epsilon$-net lower bound in Theorem~\ref{thm:lower-bound-Lp} (which will be proven in the next Section). \begin{theorem}[Upper Bound for $L^p$ with $1 < p < 2$] \label{thm:ub-point-set-lp12} For every $1 < p < 2$ and for all integers $n\geq 1$, there exist two sets $A,B \subseteq \mathbb{R}^{2n}$ each of cardinality $n$ such that the following holds: \begin{enumerate} \item For every distinct points $u,v\in A$, $\|u-v\|_p=2^{1/p}$. \item For every distinct points $u,v \in B$, $\|u-v\|_p=2^{1/p}$. \item For every points $u\in A$ and $v\in B$, $\|u-v\|_p<2^{1/p}$. \end{enumerate} \end{theorem} \begin{proof} We will construct point-sets as claimed in the theorem for given $p$ and $n$. Let $\alpha$ be a parameter depending on $p$ and $n$, which will be set later. For each $i\in [n]$, we create a point $a\in A$ by setting \[ a_j = \left\{ \begin{array}{ll} 0 & \mbox{if $1 \leq j \leq n$ and $j \neq i$}\\ 1 & \mbox{if $1 \leq j \leq n$ and $i = j$}\\ \alpha & \mbox{if $n+1 \leq j \leq 2n$} \end{array}\right. \] Similarly, for each $i\in [n]$, we create a point $b\in B$ by setting \[ b_j = \left\{ \begin{array}{ll} \alpha & \mbox{if $1 \leq j \leq n$}\\ 0 & \mbox{if $n+1 \leq j \leq 2n$ and $j\neq n+i$}\\ 1 & \mbox{if $n+1 \leq j \leq 2n$ and $j = n+i$} \end{array}\right. \] By construction, for every pair of points $u,v$ both in $A$ or both in $B$, their $L^p$-distance is $\|u-v\|_p=2^{1/p}$, and for every pair of points from different sets, say $u\in A$ and $v\in B$, their $L^p$-distance is \begin{align} \|u-v\|_p = 2^{1/p}\cdot ((1-\alpha)^p+(n-1)\cdot \alpha^p)^{1/p} \leq 2^{1/p}\cdot ((1-\alpha)^p+n\cdot\alpha^p)^{1/p} \label{eq:Lp-12-diff-set} \end{align} Now let us choose $\alpha > n^{-1/(p-1)}$, and consider the term $(1-\alpha)^p+n\cdot\alpha^p$ in Eq.~\eqref{eq:Lp-12-diff-set}. Observe that $\alpha < n\cdot\alpha^p$ for $1<p<2$. Define a function $f(x) = (1-\alpha)^x + n\cdot\alpha^x$. We know that $f(x)$ is less than $1$ as $x$ goes from $\infty$ to $1$ (i.e., $\lim_{x\rightarrow 1^+}((1-\alpha)^x+n\cdot\alpha^x)<1$). Moreover, $f(x)$ is decreasing for $0 < \alpha < 1$, which means that $f(p) < 1$. Consequently, $\|u-v\|_p<2^{1/p}$, and the theorem follows. To finish the proof, we will show that $f(x)$ is decreasing for $x>1$ provided that $0 < \alpha < 1$. It suffices to show that $f'(x) < 0$ for all values of $x$. \begin{align*} f'(x) = \frac{\partial}{\partial{x}}\left( \left(1-\alpha\right)^x + n\cdot\alpha^x\right) = \left(1-\alpha\right)^x\ln\left(1-\alpha\right) + n\cdot\alpha^x\ln\left(\alpha\right) < 0.\\ \end{align*} The last inequality follows from the fact that $\ln(x) < 0$ for $0 < x <1$ and that $0 < \alpha, 1-\alpha < 1$. \end{proof} \section{Geometric Representation of Biclique in $L^p$ for $p>2$} \label{sec:Lp-dim} In this section, we show the lower bound on $\mathsf{bsph}(L^p)$ and an upper bound on $\mathsf{bcd}(L^p)$ for $p>2$. Both bounds are logarithmic. The latter upper bound is constructive and efficient (in the sense that the polar-pair of point-sets can be constructed in $\widetilde O(n)$-time). This implies the subquadratic-time equivalence between \mbox{{\sc Closest Pair}}\xspace and \mbox{{\sc BCP}}\xspace. \subsection{Lower Bound on the Biclique Sphericity} \label{sec:Lp-dim:lower-bound} Now we show the lower bound on the biclique sphericity of a complete bipartite graph in $L^p$-metrics with $p>2$. In fact, we prove the lower bound for the case of a star graph on $n$ vertices, denoted by $S_{n}$, and then use the fact that $\mathsf{bsph}(H) \leq \mathsf{bsph}(G)$ for all induced subgraph $H$ of $G$ (i.e., $\mathsf{bsph}(K_{n/2,n/2},L^p) \geq \mathsf{bsph}(S_{n/2},L^p)$). In short, we show in Lemma~\ref{thm:lower-bound-Lp} that $O(\log n)$ is the maximum number of $L^p$-balls of radius $1/2$ that we can pack in an $L^p$-ball of radius one so that no two of them intersect or touch each other. This upper bounds, in turn, implies the lower bound on the dimension. We proceed with the proof by volume arguments, which are commonly used in proving the minimum number of points in an {\em $\epsilon$-net} that are sufficient to cover all the points in a sphere. \begin{definition}[$\epsilon$-net] The unit $L^{p}$-ball in $\mathbb{R}^{d}$ centered at $o$ is denoted by $$\mathbb{B}\left(L_{p}^{d},o\right)=\left\{ x\in\mathbb{R}^{d}\,|\,\left\Vert x-o\right\Vert _{p}\le1\right\}.$$ For brevity, we write $\mathbb{B}\left(L_{p}^{d}\right)$ to mean $\mathbb{B}\left(L_{p}^{d},o\right)$. Let $\left(X,d\right)$ be a metric space and let $S$ be a subset of $X$ and $\epsilon$ be a constant greater than $0$. A subset $N_{\epsilon}$ of $X$ is called an {\bf $\epsilon$-net} of $S$ under $d$ if for every point $x\in S$ it holds for some point $y\in N_{\epsilon}$ that $d\left(x,y\right)\le\epsilon$. \end{definition} The following lemma is well known in literature (see, e.g., \cite{vershynin2010}). For the sake of completeness, we provide a proof below. \begin{lemma} \label{lem:nets} There exists an $\epsilon$-net for $\mathbb{B}\left(L_{p}^{d}\right)$ under the $L^{p}$-metric of cardinality $\left(1+\frac{2}{\epsilon}\right)^{d}$. \end{lemma} \begin{proof} Let us fix $\epsilon>0$ and choose $N_{\epsilon}$ of maximal cardinality such that $\left\Vert x-y\right\Vert _{p}>\epsilon$ for all $x\neq y$ both in $N_{\epsilon}$. We claim that $N_{\epsilon}$ is an $\epsilon$-net of the $\mathbb{B}\left(L_{p}^{d}\right)$. Otherwise, there would exist a point $x\in \mathbb{B}\left(L_{p}^{d}\right)$ that is at least $\epsilon$-far from all points in $N_{\epsilon}$. Thus, $N_{\epsilon}\cup\left\{ x\right\} $ contradicts the maximality of $N_{\epsilon}$. After establishing that $N_{\epsilon}$ is an $\epsilon$-net, we note that by the triangle inequality, we have that the balls of radii $\epsilon/2$ centered at the points in $N_{\epsilon}$ are disjoint. On the other hand, by the triangle inequality all such balls lie in $\left(1+\epsilon/2\right) \mathbb{B}\left(L_{p}^{d}\right)$. Comparing the volumes gives us that $\text{vol}\left(\frac{\epsilon}{2} \mathbb{B}\left(L_{p}^{d}\right)\right)\cdot \left|N_{\epsilon}\right|\le \text{vol}\left(\left(1+\frac{\epsilon}{2}\right) \mathbb{B}\left(L_{p}^{d}\right)\right)$. Since $\text{vol}\left(r\cdot \mathbb{B}\left(L_{p}^{d}\right)\right)=r^{d}\cdot \text{vol}\left(\mathbb{B}\left(L_{p}^{d}\right)\right)$ for all $r \ge 0$, we conclude that $\left|N_{\epsilon}\right|\le\frac{\left(1+\epsilon/2\right)^{d}}{\left(\epsilon/2\right)^{d}}|=\left(1+\frac{2}{\epsilon}\right)^{d}$ . \end{proof} \begin{theorem} \label{thm:lower-bound-Lp} For every $N,d\in \mathbb{N}$, for $p\geq 1$, and for any two sets $A,B\subseteq\mathbb{R}^{d}$, each of cardinality $N$, suppose the following holds for some non-negative real numbers $\alpha$ and $\beta$ with $\alpha>\beta$. \begin{enumerate} \item For every $u$ and $v$ both in $A$, $\|u-v\|_p>\alpha$. \item For every $u$ and $v$ both in $B$, $\|u-v\|_p>\alpha$. \item For every $u$ in $A$ and $v$ in $B$, $\|u-v\|_p\le \beta$. \end{enumerate} Then the dimension $d$ must be at least $\log_{5}(N)$. \end{theorem} \begin{proof} Scale and translate the sets $A,B$ in such a way that $\beta=1$ and that $\vec{0}\in B$. It follows that $A\subseteq \mathbb{B}\left(L_{p}^{d}\right)$. By Lemma~\ref{lem:nets}, we can fix a $1/2$-net $N_{1/2}$ for $\mathbb{B}\left(L_{p}^{d}\right)$ of size $5^{d}$. Note that, for every $x\in N_{1/2}$, the ball $1/2 \cdot \mathbb{B}\left(L_{p}^{d},x\right)$ contains at most one point from $A$. Note also that $N_{1/2}$ covers $\mathbb{B}\left(L_{p}^{d}\right)$. Thus, $\left|A\right|\le 5^d$ which implies that $d\ge \log_{5}(N)$. \end{proof} \subsection{Upper Bound on the Biclique Contact-Dimension} \label{sec:Lp-dim:upper-bound} We first give a simple randomized construction that gives a logarithmic upper bound on the biclique contact-dimension of $L^p$. The construction is simple. We uniformly at random take a subset $A$ of $n$ vectors from $\{-1,1\}^{d/2}\times \{0\} ^{d/2}$ and a subset $B$ of $n$ vectors from $\{0\}^{d/2}\times \{-1,1\}^{d/2}$. Observe that, for any $p>2$, the $L^p$-distance of any pair of vectors $u\in A$ and $v\in B$ is exactly $d$ while the {\em expected distance} between the inner pair $u,u'\in A$ (resp., $v,v'\in B$) is strictly larger than $d$. Thus, if we choose $d$ to be sufficiently large, e.g., $d\geq 10\ln n$, then we can show by a standard concentration bound (e.g., Chernoff's bound) that the probability that the inner-pair distance is strictly larger than $d$ is at least $1-1/n^{3}$. Applying the union bound over all inner-pairs, we have that the $d$-neighborhood graph of $A\cup B$ is a bipartite complete graph with high probability. Moreover, the distances between any crossing pairs $u\in A$ and $v\in B$ are the same for all pairs. This shows the upper bound for the contact-dimension of a biclique in the $L^p$-metric for $p>2$. The above gives a simple proof of the upper bound on the biclique contact-dimension of the $L^p$-metric. Moreover, it shows a randomized construction of the polar-pair in the $O(\log n)$-dimensional $L^p$-metric, for $p>2$, thus implying that \mbox{{\sc Closest Pair}}\xspace and \mbox{{\sc BCP}}\xspace are equivalent for these $L^p$-metrics. For algorithmic purposes, we provide a deterministic construction. One way to derandomize the above process is to use {\em expanders}. We show it using appropriate codes. \begin{theorem}\label{thm:Codes} For any $p> 2$, let $\zeta=2^{p-3}$. There exist two sets $\left|A\right|=\left|B\right|=n$ of vectors in $\mathbb{R}^{d}$, where $d=2\alpha \log_2{n}$, for some constant $\alpha \ge 1$, such that the following holds. \begin{enumerate} \item[1.] For all $u,u^\prime\in A$, $\|u-u^\prime\|_p> \left((\zeta +1/2)d\right)^{1/p}$. \item[2.] For all $v,v^\prime\in B$, $\|v-v^\prime\|_p> \left((\zeta +1/2)d\right)^{1/p}$. \item[3.] For all $u\in A,\, v\in B$, $\|u-v\|_p=d^{1/p}$. \end{enumerate} Moreover, there exists a deterministic algorithm that outputs $A$ and $B$ in time $\widetilde O(n)$. \end{theorem} \begin{proof} In literature, we note that for any constant $\delta>0$, there is an explicit binary code of (some) constant {\em relative rate} and {\em relative distance} at least $\frac{1}{2}-\delta$ and the entire code can be listed in quasilinear time with respect to the size of the code (see Appendix E.1.2.5 from \cite{G09}, or Justesen codes \cite{J72}). To be more specific, we can construct in $O(n\log^{O(1)}n)$-time a set $C\subseteq\{-1,1\}^{d'}$ such that (1) $|C| = n$, (2) $d'=d/2=\alpha \log_2{n}$ for some constant $ \alpha\ge 1$ and (3) for every two vectors $x,y\in C$, $x$ and $y$ differ on at least $\left(\frac{1}{2}-\delta\right)d'$ coordinates, for some constant $\delta \in\left(0,\frac{1}{4}-\frac{1}{2^p}\right)$. We construct the sets $A$ and $B$ as subsets of $\{-1,0,1\}^{d}$. For every $i\in [n]$, the $i^{\text{th}}$ point of $A$ is given by the concatenation of the $i^{\text{th}}$ point of $C$ with $0^{d'}$. Similarly, the $i^{\text{th}}$ point of $B$ is given by the concatenation of $0^{d'}$ with the $i^{\text{th}}$ point of $C$ (note the reversal in the order of the concatenation). In particular, points in $A$ and $B$ are of the form $(x_i,{\vec{0}})$ and $({\vec{0}},x_i)$, respectively, where $x_i$ is the $i^{\text{th}}$ point in $C$ and ${\vec{0}}$ is the zero-vector of length $\alpha \log_2 n$. First, consider any two points in the same set, say $u,u'\in A$ (resp., $v,v'\in B$). We have from the distance of $C$ that on at least $\left(\frac{1}{2}-\delta\right)d'$ coordinates the two points differ by $2$, thus implying that their $L^p$-distance is at least \begin{align*} \left(\left(\frac{1}{2}-\delta\right){d'}2^p\right)^{1/p} > \left(\left(\frac{1}{4}+\frac{1}{2^p}\right){d'}2^p\right)^{1/p} = \left(\left(2^{p-3}+\frac{1}{2}\right){d}\right)^{1/p}. \end{align*} This proves the first two items of the theorem. Next we prove the third item. Consider any two points from different sets, say $u\in A$ and $v\in B$. It is easy to see from the construction that $u$ and $v$ differ in every coordinate by exactly $1$. Thus, the $L^p$-distance between any two points from different set is exactly \[ \left(2d'\right)^{1/p}=d^{1/p}.\qedhere \] \end{proof} \section{Introduction} \label{sec:intro} This paper studies the geometric representation of a complete bipartite graph in $L^p$-metrics and consequently connects the complexity of the closest pair and bichromatic closest pair problems beyond certain dimensions. Given a point-set $P$ in a $d$-dimensional $L^p$-metric, an {\em $\alpha$-distance graph} is a graph $G=(V,E)$ with a vertex set $V=P$ and an edge set $$E=\{uv:\|u-v\|_p \leq \alpha; u,v\in P; u\neq v\}.$$ In other words, points in $P$ are centers of spheres of radius $\alpha$, and $G$ has an edge $uv$ if and only if the spheres centered at $u$ and $v$ intersect. The {\em sphericity} of a graph $G$ in an $L^p$-metric, denoted by $\mathsf{sph}_p(G)$, is the smallest dimension $d$ such that $G$ is isomorphic to some $\alpha$-distance graph in a $d$-dimensional $L^p$-metric, for some constant $\alpha>0$. The sphericity of a graph in the $L^{\infty}$-metric is known as {\em cubicity}. A notion closely related to sphericity is {\em contact-dimension}, which is defined in the same manner except that the spheres representing $G$ must be non-overlapping. To be precise, an {\em $\alpha$-contact graph} $G=(V,E)$ of a point-set $P$ is an $\alpha$-distance graph of $P$ such that every edge $uv$ of $G$ has the same distance (i.e., $\|u-v\|_p=\alpha$). Thus, $G$ has the vertex set $V=P$ and has an edge set $E$ such that $$ \forall uv\in E, \quad\|u-v\|_p=\alpha \quad\mbox{and}\quad\forall uv\not\in E,\quad \|u-v\|_p>\alpha. $$ The contact-dimension of a graph $G$ in the $L^p$-metric, denoted by $\mathsf{cd}_p(G)$, is the smallest integer $d \geq 1$ such that $G$ is isomorphic to a contact-graph in the $d$-dimensional $L^p$-metric. We will use distance and contact graphs to means $1$-distance and $1$-contact graphs. We are interested in determining the sphericity and the contact-dimension of the biclique $K_{n,n}$ in various $L^p$-metrics. For notational convenience, we denote $\mathsf{sph}_p(K_{n,n})$ by $\mathsf{bsph}(L^p)$, the {\em biclique sphericity} of the $L^p$-metric, and denote $\mathsf{cd}_p(K_{n,n})$ by $\mathsf{bcd}(L^p)$, the {\em biclique contact-dimension} of the $L^p$-metric. We call a pair of point-sets $(A,B)$ \emph{polar} if it is the partition of the vertex set of a contact graph isomorphic to $K_{n,n}$. More precisely, a pair of point-sets $(A,B)$ is polar in an $L^p$-metric if there exists a constant $\alpha>0$ such that every inner-pair $u,u'\in A$ (resp., $v,v'\in B$) has $L^p$-distance greater than $\alpha$ while every crossing-pair $u\in A,v\in B$ has $L^p$-distance exactly $\alpha$. The biclique sphericity and contact-dimension of the $L^2$ and $L^{\infty}$ metrics are well-studied in literature (see \cite{R69cubicity,M84,M85-contact-pattern,FM88,M91,BL05}). Maehara \cite{M91,M84} showed that $n < \mathsf{bsph}(L^2) \leq (1.5)n$, and Maehara and Frankl \& Maehara \cite{M85-contact-pattern, FM88} showed that $(1.286)n-1 < \mathsf{bcd}(L^2) < (1.5)n$. For cubicity, Roberts \cite{R69cubicity} showed that $\mathsf{bcd}(L^{\infty})=\mathsf{bsph}(L^{\infty})=2\log_2{n}$. Nevertheless, for other $L^p$-metrics, contact dimension and sphericity are not well-studied. \subsection{Our Results and Contributions} \label{sec:results} Our main conceptual contribution is connecting the complexity of the (monochromatic) closest pair problem (\mbox{{\sc Closest Pair}}\xspace) to that of the bichromatic closest pair problem (\mbox{{\sc BCP}}\xspace) through the contact dimension of the biclique. This is discussed in subsection~\ref{conceptual}. Our main technical contributions are bounds on the contact dimension and sphericity of the biclique for various $L^p$-metrics. This is discussed in subsection~\ref{technical}. Finally, as an application of the connection discussed in subsection~\ref{conceptual} and the bounds discussed in subsection~\ref{technical}, we show computational equivalence between monochromatic and bichromatic closest pair problems. \subsubsection{Connection between \mbox{{\sc Closest Pair}}\xspace and \mbox{{\sc BCP}}\xspace}\label{conceptual}\label{sec:connection} In \mbox{{\sc Closest Pair}}\xspace, we are asked to find a pair of points in a set of $m$ points with minimum distance. \mbox{{\sc BCP}}\xspace is a generalization of \mbox{{\sc Closest Pair}}\xspace, in which each point is colored red or blue, and we are asked to find a pair of red-blue points (i.e., bichromatic pair) with minimum distance. It is not hard to see that \mbox{{\sc BCP}}\xspace is at least as hard as \mbox{{\sc Closest Pair}}\xspace since we can apply an algorithm for \mbox{{\sc BCP}}\xspace to solve \mbox{{\sc Closest Pair}}\xspace with the same asymptotic running time. However, it is not clear whether the other direction is true. We will give a simple reduction from \mbox{{\sc BCP}}\xspace to \mbox{{\sc Closest Pair}}\xspace using a polar-pair of point-sets. First, take a polar-pair $(A,B)$, each with cardinality $n=m/2$, in the $L^p$-metric. Next, pair up vectors in $A$ and $B$ to red and blue points, respectively, and then attach a vertex $u\in A$ (resp., $v\in B$) to its matching red (resp., blue) point. This reduction increases the distances between every pair of points, but by the definition of the polar-pair, this process has more affect on the distances of the {\em monochromatic} (i.e., red-red or blue-blue) pairs than that of {\em bichromatic pairs}, and the reduction, in fact, has no effect on the order of crossing-pair distances at all. By scaling the vectors in $A$ and $B$ appropriately, this gives an instance of \mbox{{\sc Closest Pair}}\xspace whose closest pair of points is bichromatic. Consequently, provided that the polar-pair of point-sets $(A,B)$ in a $d$-dimensional metric can be constructed within a running time at least as fast as the time for computing \mbox{{\sc Closest Pair}}\xspace in the same metric, this gives a reduction from \mbox{{\sc BCP}}\xspace to \mbox{{\sc Closest Pair}}\xspace, thus implying that they have the same running time lower bound. \subsubsection{Bounds on Contact Dimension and Sphericity of Biclique}\label{technical} Our main technical results are lower and upper bounds on the biclique contact-dimension for the $L^p$-metric space where $p\in \mathbb{R}_{\ge 1}\cup\{0\}$. \begin{theorem} \label{thm:main-all-dim-results} The following are upper and lower bounds on biclique contact-dimension for the $L^p$-metric. \begin{align} \mathsf{bsph}(L^0) = \mathsf{bcd}(L^0) = n \label{eq:L0-bounds}\\ n \leq \mathsf{bsph}(L^0_{\{0,1\}})) \leq \mathsf{bcd}(L^0_{\{0,1\}}) \leq n^2 && \mbox{(i.e., $P\subseteq \{0,1\}^d$)} \label{eq:L0-bin-bounds}\\ \Omega(\log n) \leq \mathsf{bsph}(L^1) \leq \mathsf{bcd}(L^1) \leq n^2 \label{eq:L1-bounds}\\ \Omega(\log n) \leq \mathsf{bsph}(L^p) \leq \mathsf{bcd}(L^p) \leq 2n && \mbox{for $p\in (1,2)$} \label{eq:L2-bounds}\\ \mathsf{bsph}(L^p) = \Theta(\mathsf{bcd}(L^p)) = \Theta(\log n) && \mbox{for $p>2$} \label{eq:Lp-bounds} \end{align} \end{theorem} Note that $\mathsf{bsph}(\Delta) \leq \mathsf{bcd}(\Delta)$ for any metric $\Delta$. Thus, it suffices to prove a lower bound for $\mathsf{bsph}(\Delta)$ and prove an upper bound for $\mathsf{bcd}(\Delta)$. We note that the bounds on the sphericity and the contact dimension of the $L^1$-metric in (\ref{eq:L1-bounds}) are obtained from (\ref{eq:Lp-bounds}) and (\ref{eq:L0-bounds}), respectively. We are unable to show a strong (e.g., linear) lower bound for the $L^1$-metric. However, we prove the weaker (average-case) result below for the $L^1$-metric which can be seen as a progress toward proving stronger lower bounds on the sphericity of the biclique in this metric (see Corollary~\ref{lem:LB-point-set-l1-large-gap} for more discussion on its applications). \begin{theorem} \label{lem:NoDistL1} For any integer $d>0$, there exist no two finite-supported random variables $X,Y$ taking values from $\mathbb{R}^{d}$such that the following hold. \begin{align*} \underset{x_{1},x_{2}\in_{R}X}{\mathbb{E}}\left[\left\Vert x_{1}-x_{2}\right\Vert _{1}\right]&>\underset{x_{1}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}\right]\\ \underset{y_{1},y_{2}\in_{R}Y}{\mathbb{E}}\left[\left\Vert y_{1}-y_{2}\right\Vert _{1}\right]&>\underset{x_{1}\in_{R}X,\,y_{1}\in_{R}Y}{\mathbb{E}}\left[\left\Vert x_{1}-y_{1}\right\Vert _{1}\right]\,. \end{align*} \end{theorem} For an overview on the known bounds on $\mathsf{bsph}$ and $\mathsf{bcd}$ (including the results in this paper), please see Table~\ref{tab:sphericity-contact-dim-bounds}. \begin{table} \begin{center} \begin{tabular}{ |p{2.5cm}||p{7.25cm}|p{3cm}| } \hline \centering \textbf{Metric} & \centering \textbf{Bound} &{\centering \ \ \ \ \ \ \ \textbf{From} }\\ \hline $L^0$ & $ \mathsf{bsph}(L^0) = \mathsf{bcd}(L^0) = n$ & This paper\\ $L^1$& $\Omega(\log n) \leq \mathsf{bsph}(L^1) \leq \mathsf{bcd}(L^1) \leq n^2$ &This paper\\ $L^p$, $p\in (1,2)$& $\Omega(\log n) \leq \mathsf{bsph}(L^p) \leq \mathsf{bcd}(L^p) \leq 2n$ & This paper\\ $L^2$ & $ n< \mathsf{bsph}(L^2) \leq \mathsf{bcd}(L^2) <1.5 \cdot n$ & \cite{M91,FM88}\\ $L^p$, $p>2$ & $\mathsf{bsph}(L^{p})=\Theta(\mathsf{bcd}(L^{p}))=\Theta(\log{n})$ &This paper\\ $L^\infty$& $\mathsf{bsph}(L^{\infty})=\mathsf{bcd}(L^{\infty})=2\log_2{n}$ &\cite{R69cubicity}\\ \hline \end{tabular} \end{center} \caption{Known Bounds on Sphericity and Contact Dimension of Biclique} \label{tab:sphericity-contact-dim-bounds} \end{table} In Appendix~\ref{sec:L2-dim}, we give an alternate proof of the linear lower bound on $\mathsf{bsph}(L^2)$ using spectral analysis similar to that in \cite{BL05}. While our lower bound is slightly weaker than the best known bounds \cite{FM88,M91}, our arguments require no heavy machinery and thus are arguably simpler than the previous works \cite{FM88,M91,BL05}. Alman and Williams \cite{AW15} showed the subquadratic-time hardness for \mbox{{\sc BCP}}\xspace in $L^p$-metrics, for all $p\in \mathbb{R}_{\ge 1}\cup\{0\}$, under the {\em Orthogonal Vector Hypothesis} (OVH). From Theorem~\ref{thm:main-all-dim-results} and the connection between \mbox{{\sc BCP}}\xspace and \mbox{{\sc Closest Pair}}\xspace described in subsection~\ref{sec:connection}, we have the following hardness of \mbox{{\sc Closest Pair}}\xspace. \begin{theorem}\label{thm:closestMainIntro} Let $p>2$. For any $\varepsilon>0$ and $d=\omega(\log n)$, the closest pair problem in the $d$-dimensional $L^{p}$-metric admits no $(n^{2-\varepsilon})$-time algorithm unless the Orthogonal Vectors Hypothesis is false. \end{theorem} We remark here that showing conditional hardness for \mbox{{\sc Closest Pair}}\xspace in the $L^p$ metric for $p\le 2$ remains an outstanding open problem\footnote{The subquadratic-time hardness of \mbox{{\sc Closest Pair}}\xspace in the $L^p$-metric for $p\in \mathbb R_{\ge 1}\cup\{0\}$ was claimed in \cite{ARW17-FOCS17} but later retracted \cite{AR17}.}. Recently, Rubinstein \cite{R17} showed that the subquadratic-time hardness holds even for approximating \mbox{{\sc BCP}}\xspace: Assuming OVH, for every $p\in \mathbb R_{\ge 1}\cup \{0\}$ and every $\varepsilon>0$, there is a constant $\gamma(\varepsilon,p)>0$ such that there is no $(1+\gamma)$-approximation algorithm running in time $O(n^{2-\varepsilon})$ for \mbox{{\sc BCP}}\xspace in the $L^p$-metric. By using the connection between \mbox{{\sc BCP}}\xspace and \mbox{{\sc Closest Pair}}\xspace described in subsection~\ref{sec:connection} and the bounds in Theorem~\ref{thm:main-all-dim-results} (to be precise we need the efficient construction with appropriate gap as given by Theorem~\ref{thm:Codes}), the hardness of approximation result can be extended to \mbox{{\sc Closest Pair}}\xspace for $L^p$ metrics where $p>2$. \begin{theorem}\label{thm:closestApproxIntro} Let $p>2$. For every $\varepsilon>0$ and $d=\omega(\log n)$, there exists a constant $\gamma=\gamma(p,\varepsilon)>0$ such that the closest pair problem in the $d$-dimensional $L^{p}$-metric admits no $(n^{2-\varepsilon})$-time $(1+\gamma)$-approximation algorithm unless the Orthogonal Vectors Hypothesis is false. \end{theorem} We remark that the hardness for the case of the $L^{\infty}$-metric does not follow (at least directly) from \cite{AW15} or \cite{R17}. For independent interest, we show the subquadratic-time hardness of \mbox{{\sc BCP}}\xspace and \mbox{{\sc Closest Pair}}\xspace in the $L^{\infty}$-metric. \begin{theorem} \label{thm:closest-hardness-max-norm} For any $\varepsilon>0$ and $d=\omega(\log n)$, the closest pair problem in the $d$-dimensional $L^{\infty}$-metric admits no $(n^{2-\varepsilon})$-time $(2-o(1))$-approximation algorithm unless the Orthogonal Vectors Hypothesis is false. \end{theorem} We note that the lower bounds on $\mathsf{bsph}$ act as barriers for gadget reductions from \mbox{{\sc BCP}}\xspace to \mbox{{\sc Closest Pair}}\xspace. This partially explains why there has been no progress in showing conditional hardness for \mbox{{\sc Closest Pair}}\xspace in the Euclidean metric for $d=\omega(\log n)$ dimensions (as $\mathsf{bsph}(L^2)=\Omega(n)$). Also, Rubinstein \cite{R17} discussed about the triangle inequality barrier to prove conditional inapproximability results for \mbox{{\sc Closest Pair}}\xspace. Elaborating, he notes that in \emph{any} metric there cannot exist two point-sets $A$ and $B$ such that for some distinct $a,a'\in A$ and $b\in B$, we have that $\|a-a'\|> 2\cdot \max\{\|a-b\|,\|a'-b\|\}$ (as it would violate the triangle inequality). Thus it rules out the possibility of obtaining the conditional hardness for $2$-approximating \mbox{{\sc Closest Pair}}\xspace for any metric via simple gadget reductions. We note that the inapproximability factor of Theorem~\ref{thm:closest-hardness-max-norm} matches the triangle inequality barrier (for the $L^\infty$ metric). \subsection{Related Works}\label{sec:related} While our paper studies sphericity and contact-dimension of the complete bipartite graph, determining the contact-dimension of a complete graph in $L^p$-metrics has also been extensively studied in the notion of {\em equilateral dimension}. To be precise, the equilateral dimension of a metric $\Delta$ which is the maximum number of equidistant points that can be packed in $\Delta$. An interesting connection is in the case of the $L^1$-metric, for which we are unable to establish a strong lower bound for $\mathsf{bsph}(L^1)$. The equilateral dimension of $L^1$ is known to be at least $2d$, and this bound is believed to be tight~\cite{GUY83-KusnerConj}. This is a notorious open problem known as {\em Kusner's conjecture}, which is confirmed for $d=2,3,4$ \cite{BCL98-eqdim,KLS00-eqdim-d4}, and the best upper bound for $d\geq 5$ is $O(d\log d)$ by Alon and Pavel \cite{AP03-eqdim}. If Kusner's conjecture is true for all $d$, then $\mathsf{sph}_1(K_n)=n/2$. \begin{sloppypar}The complexity of \mbox{{\sc Closest Pair}}\xspace has been a subject of study for many decades. There have been a series of developments on \mbox{{\sc Closest Pair}}\xspace in the Euclidean space (see, e.g., \cite{Ben80,HNS88,KM95,SH75,BS76}), which culminates in a deterministic $O(2^{O(d)}n\log n)$-time algorithm \cite{BS76} and a randomized $O(2^{O(d)}n)$-time algorithm \cite{Rabin76,KM95}. For low (i.e., constant) dimensions, these algorithms are tight as the matching lower bound of $\Omega(n\log n)$ was shown by Ben-Or \cite{Ben83} and Yao \cite{Yao91} for the {\em algebraic decision tree} model, thus settling the complexity of \mbox{{\sc Closest Pair}}\xspace in low dimensions. For high dimensions (i.e., $d=\omega(\log n)$), there is no known algorithm that runs in time significantly better than a trivial $O(n^2d)$-time algorithm for general $d$ except for the case that $d \geq \Omega(n)$ whereas there are subcubic-time algorithms in $L^1$ and $L^{\infty}$ metrics \cite{GS16,ILLP04}.\end{sloppypar} \begin{sloppypar}In the last few years, there has been a lot of progress in our understanding of \mbox{{\sc BCP}}\xspace, \mbox{{\sc Closest Pair}}\xspace, and related problems. Alman and Williams \cite{AW15} showed subquadratic time hardness for \mbox{{\sc BCP}}\xspace in $d=\omega(\log n)$ dimensions under OVH in the $L^p$ metric for every $p\in\mathbb R_{\ge 1}\cup\{0\}$. Williams \cite{W17diff} extended the result of \cite{AW15} and showed the above subquadratic-time hardness for \mbox{{\sc BCP}}\xspace even for dimensions $d=\omega((\log\log n)^2)$ under OVH. In a recent breakthrough on hardness of approximation in P,\ Abboud et al. \cite{AR17} showed the subquadratic-time hardness for approximating the Bichromatic Maximum Inner Product problem under OVH in the $L^p$ metric for every $p\in\mathbb R_{\ge 1}\cup\{0\}$, and the result holds for almost polynomial approximation factors. More recently, building upon the ideas in \cite{AR17}, Rubinstein \cite{R17} showed under OVH the inapproximablility of \mbox{{\sc BCP}}\xspace for every $L^p$-metric for $p\in\mathbb R_{\ge 1}\cup \{0\}$. \end{sloppypar} \section{Preliminaries} \label{sec:prelim} We use the following standard terminologies and notations. \paragraph{Distance Measures.} \begin{sloppypar} For any vector $x\in\mathbb{R}^d$, the $L^p$-norm of $x$ is denoted by $||x||_p~=~\left(\sum_{i=1}^d|x_i|^p\right)^{1/p}$. The $L^{\infty}$-norm of $x$ is denoted by $||x||_{\infty} = \underset{{i\in[d]}}{\max}\ \{|x_i|\}$, and the $L^0$-norm of $x$ is denoted by $||x||_0=|\{x_i\neq 0: i\in [d]\}|$, i.e., the number of non-zero coordinates of $x$. These norms define distance measures in $\mathbb{R}^d$. The distance of two points $x$ and $y$ w.r.t. the $L^p$-norm, say {\em $L^p$-distance}, is thus $||x-y||_p$. The distance measures that are well studied in literature are the {\em Hamming distance} $L^0$-norm, the {\em Rectilinear distance} $L^1$-norm, the {\em Euclidean distance} $L^2$-norm, the {\em Chebyshev distance} (a.k.a, {\em Maximum-norm}) $L^{\infty}$-norm. \end{sloppypar} \paragraph{Problems.} Here we give formal definitions of \mbox{{\sc Closest Pair}}\xspace and \mbox{{\sc BCP}}\xspace. In \mbox{{\sc Closest Pair}}\xspace, we are given a collection of points $P\subseteq\mathbb{R}^d$ in a $d$-dimensional $L^p$-metric, and the goal is find a pair of distinct points $a,b\in P$ that minimizes $\|u-v\|_p$. In \mbox{{\sc BCP}}\xspace, the input point-set is partitioned into two color classes (the collections of red and blue points) $A$ and $B$, and the goal is find a pair of points $u\in A$ and $v\in B$ that minimizes $\|u-v\|_p$. \paragraph{Fine-Grained Complexity and Conditional Hardness.} Conditional hardness is the current trend in proving running-time lower bounds for polynomial-time solvable problems. This has now developed into the area of {\em Fine-Grained Complexity}. Please see, e.g., \cite{Williams15,Williams16} and references therein. The {\em Orthogonal Vectors Hypothesis} (OVH) is a popular complexity theoretic assumption in Fine-Grained Complexity. OVH states that in the Word RAM model with $O(\log n)$ bit words, any algorithm requires $n^{2-o(1)}$ time in expectation to determine whether collections of vectors $A,B\subseteq\{0,1\}^d$ with $|A|=|B|=n/2$ and $d = \omega(\log n)$ contain an orthogonal pair $u\in A$ and $v\in B$ (i.e., $\sum_{i=1}^du_i\cdot v_i=0$). Another popular conjecture is the {\em Strong Exponential-Time Hypothesis} for SAT (SETH), which states that, for every $\varepsilon > 0$, there exists an integer $k_{\varepsilon}$ such that $k_{\varepsilon}$-SAT on $n$ variables cannot be solved in $O(2^{(1-\varepsilon)n})$-time. It was shown by Williams that SETH implies OVH \cite{W05}.
{'timestamp': '2017-12-13T02:14:56', 'yymm': '1608', 'arxiv_id': '1608.03245', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03245'}
arxiv
\section{Background} \label{sec:background} Intuitively, a Gaussian process (GP) can be seen as an extension of the multivariate Gaussian distribution to the space of functions. GP is a distribution over functions parameterized by a a \emph{mean function} $\mu(\boldsymbol{x})$ and a \emph{covariance function} or \emph{(positive semidefinite) kernel} $k(\boldsymbol{x_i}, \boldsymbol{x_j})$. Placing a GP prior over a function implies that, for any finite set of points from the function's domain, their corresponding image will be jointly Gaussian-distributed. GPs can be used to model many different learning tasks. Here we are interested in regression, where they are used as follows. We first assume that observations are noise-corrupted evaluations of a latent function $f(\boldsymbol{x})$. That is, \begin{equation} y(\boldsymbol{x}) = f(\boldsymbol{x}) + \epsilon \mbox{, where } \epsilon \sim \mathcal{N}(0, \sigma^2) \label{eq:model} \end{equation} We then assume a GP prior over the latent function: \begin{equation} f \sim \mathcal{GP}(\mu(\boldsymbol{x}), k_f(\boldsymbol{x_i}, \boldsymbol{x_j})) \label{eq:latent} \end{equation} Using \ref{eq:model} and \ref{eq:latent}, we conclude that $y(\boldsymbol{x})$ also follows a GP prior: \begin{equation} y \sim \mathcal{GP}\left(\mu(\boldsymbol{x}), k(\boldsymbol{x_i}, \boldsymbol{x_j}) = k_f(\boldsymbol{x_i}, \boldsymbol{x_j}) + \sigma^2 \delta_{ij}\right) \end{equation} where $\delta_{ij}$ is the Kronecker delta, which is equals to 1 if $i = j$ and 0 otherwise. Finally, given $N$ pairs of observations $(\boldsymbol{x}_i, y_i)$ and an unobserved point of interest $\boldsymbol{x}_*$, we have that \begin{eqnarray} y_*|\boldsymbol{x}_*, X, \boldsymbol{y} & \sim & \mathcal{N}(\hat{\mu}, \hat{k}) \nonumber \\ \hat{\mu} & = & \boldsymbol{k}_*^T (K + \sigma^2 I)^{-1} \boldsymbol{y} \nonumber \\ \hat{k} & = & k(\boldsymbol{x}_*, \boldsymbol{x}_*) - \boldsymbol{k}_*^T (K + \sigma^2 I)^{-1} \boldsymbol{k}_* \label{eq:pred} \end{eqnarray} where $X$ is an $N$-by-$D$ matrix composed of observed points, $\boldsymbol{y}$ is an $N$-length vector of observed targets, $\boldsymbol{k}_*$ is an $N$-length vector with the covariance between $\boldsymbol{x}_*$ and observed points, and $K$ is an $N$-by-$N$ matrix with the covariance between observed points. By this definition, GPs allow us to obtain the exact predictive distribution through a closed-form expression. They are also flexible, since one can use any positive semidefinite kernel as a covariance function. Finally, they generate interpretable models, as one can interpret the covariance function as a measure of similarity between points, providing rich insights about the dependencies between them. For a more complete description, see \cite{Rasmussen:2005:GPM:1162254}. \section{Conclusions and Future Work} \label{sec:conclusion} In this work, we propose to model DIR at Brazilian cities as a GP equipped with a quasi-periodic covariance function. This function allows the model to exploit both local and distant information in order to accurately predict DIR. We showed that the proposed model outperforms a previous model specifically design to dengue fever in Brazil. This gain in accuracy is due to the non-parametric nature of the proposed model and its flexibility, thus being able to automatically adapt to different scenarios. This reasoning is strengthened by the analysis of hyperparameters, which differs from one city to another to capture distinct patterns. The proposed model obtained the best results on cities from Southeast and Center-West regions of Brazil, which exhibit the highest DIR. Therefore, the model can be used as an EWS, since it performs well where it is mostly needed. We would like to highlight that we believe the proposed model to be quite general and applicable to other diseases that exhibit seasonality, which includes virtually all mosquito-borne diseases. In this sense, it is an initial step towards defining accurate EWS for a large number of diseases. As future work, we intend to extend the model to incorporate spatial dependencies. It is known that dengue outbreaks are not geographically isolated events, so that an outbreak in a city may increase the possibility of outbreaks at other cities. \section{Data Collection} \label{sec:data} In this work, we use data provided by the Brazilian Ministry of Health regarding the number of confirmed dengue fever cases for the 298 Brazilian cities that have a population over 100,000 inhabitants. For each city, we have the weekly number of confirmed cases from January 2011 to December 2014, in a total of 209 weeks. In order to make results from cities with distinct population sizes comparable, we calculate the \emph{dengue incidence rate} (DIR) for each city, which is the number of cases of dengue fever per 100,000 inhabitants. We also aggregate three climate covariates to our dataset: weekly average temperature, rainfall and humidity for the period under study. Data was collected from 287 meteorological stations associated with INMET\footnote{Brazilian National Institute of Meteorology - http://www.inmet.gov.br}. Since meteorological stations are not present in every city, we associated each city to its closest geographical station. In order to remove possible recording errors from the time series of confirmed dengue cases, we applied a pre-processing step to remove additive outliers (i.e., outliers of a time series that affect a single point in time) using the method described in \cite{chen1993joint}, which simultaneously estimates an autoregressive model and identifies outliers instead of using a fixed model fitted with all data. Figure \ref{fig:incidence} shows the cumulative distribution function for peak DIR, that is, the highest attained value of DIR for each city from 2011 to 2014. The Brazilian Ministry of Health defines three monthly incidence bands. Low incidence is defined as DIR less than 100, while medium incidence is defined for DIR between 100 and 300 and high incidence is defined as DIR greater than 300 in a month. Since we are dealing with weekly data, we divided these boundaries by four, arriving at 25 and 75. The dashed lines in Figure \ref{fig:incidence} show that around 49\% of the cities reached high incidence during the period under study, and 71\% reached at least medium incidence. \begin{figure} \centering \includegraphics[width=0.64\linewidth]{cdfPeakDIR.png} \caption{Empirical cumulative distribution for maximum DIR attained for all 298 Brazilian cities under study. Dashed lines indicate boundaries between incidence bands.} \label{fig:incidence} \end{figure} \section{Experimental Evaluation} \label{sec:experiments} \begin{figure*}[t!] \centering \includegraphics[width=0.75\linewidth]{comparisonBaselines.png} \caption{Comparison between GP and baselines according to both accuracy metrics. Each point represents a city, where form and color indicates the highest incidence band reached by such city. Points below the solid diagonal line indicates that GP performed better, while points above the solid diagonal line indicates better performance of the baseline. Points below or above the dashed diagonal line indicates difference in performance greater than 0.1.} \label{fig:baselines} \end{figure*} This section evaluates the proposed model in 298 Brazilian cities. Predictions were always made with 4 weeks in advance, starting at the beginning of the third year (week 105). Weeks up to the end of the second year were used only as training. Therefore, in order to predict week $t$, we used as training data from week 1 to $t-4$, for $t = 105, 106, ..., 209$. Climate covariates were normalized to have zero mean and unit variance. Such covariates are usually used with some lag in the dengue modelling literature (\cite{naish2014climate,louis2014modeling}), as we expect it to interact with the life cycle of dengue's vector. Thus, after some excessively hot and/or humid period, we expect to observe a proliferation of mosquitoes that would then be able to acquire the virus and infect humans. This process requires some time, so climate covariates and dengue fever time series are better aligned if we shift the former some weeks into the future. For each city and each covariate, we calculated the optimal lag by computing the correlation between a covariate and target values when applying lags from 4 to 26 weeks, using only training data (the first and second years). Models were evaluated using two performance metrics: (i) Pearson correlation coefficient between predicted and real values and (ii) area under the ROC curve (AUC) using the weekly incidence bands defined in Section \ref{sec:data}. The former was used instead of error-based metrics because it is scale-independent and allows for easier comparison. For the latter, we only use cities that reached medium and/or high incidence, since all low incidence cities only have low incidence throughout the whole period. Comparison between models was done using Wilcoxon test with a confidence level of 95\%, using Bonferroni correction if applicable. \subsection{Comparison with Baselines} In order to assess the accuracy of the proposed model, we compare it with three baselines: a linear model, an autoregressive model and a negative binomial model specifically proposed to model dengue fever in Brazil (\cite{lowe2010spatio}). The linear model (LM) uses the same climate covariates indicated previously. The response variable is also previously transformed via a logarithmic link function. The autoregressive model (AR) is of first order, making predictions for a week $t$ using information from week $t-1$. We obtained predictions within 4 weeks in advance by applying successive predictions. A window of 12 weeks was used, so that we train the model for each week ignoring data from more than 3 months into the past. Again, a logarithmic transformation was previously applied. The negative binomial (NB) proposed in \cite{lowe2010spatio} is a generalized linear mixed model. It was originally proposed to deal with monthly data at microregion (a group of geographically close municipalities) level. Since we are dealing with weekly data at city level, we adapted it by using weekly covariates and defining neighbouring cities as cities within 500 km of each other. The model uses as predictors temperature and precipitation (both as a 13-week average, lagged 8 weeks), Oceanic Ni\~{n}o Index (ONI, lagged 26 weeks), population density and altitude. The random effects include an unstructured spatial effect to allow spatial heterogeneity, a conditional autoregressive (CAR) effect to allow dependences between neighbouring cities and a temporal autoregressive effect. Letting $\mu_t^{(i)}$ and $\kappa$ denote the mean DIR value for city $i$ during week $t$ and the scale parameter, respectively, the model is given by \begin{eqnarray} y_t^{(i)} & \sim & NegativeBinomial\left(\mu_t^{(i)}, \kappa\right) \label{eq:rachel} \\ log\left(\mu_t^{(i)}\right) & = & log\left(e^{(i)}\right) + \alpha + \sum_j \beta_j x_{jt}^{(i)} + \phi^{(i)} + \nonumber\\ & & \nu^{(i)} + \omega_{Month(t)} \nonumber \end{eqnarray} where $y_t^{(i)}$ indicates the DIR during week $t$ at city $i$, $e^{(i)}$ is the expected dengue risk at city $i$ and is based only on the city's population size, $\boldsymbol{x}^{(i)}_t$ is a vector formed of all covariates associated to week $t$ and city $i$ and $x_{jt}^{(i)}$ indicates the $j$-th position of $\boldsymbol{x}^{(i)}_t$. For the formal definition of the random variables in Equation \ref{eq:rachel}, see \cite{lowe2010spatio}. Inferences under this model, however, require expensive Markov Chain Monte Carlo sampling techniques if all cities under study were used. In order to reduce computational effort, we obtained 35 clusters of up to 10 cities and estimated the parameters for each cluster. Previous experiments indicated that clustering cities based on the correlation between each pair of cities on a hierarchical fashion was the best strategy. However, we stress that allowing larger clusters did not lead to a statistically significant improvement of the results obtained. Figure \ref{fig:baselines} shows the comparison between the proposed model (GP) and baselines. Observe that GP obtained better results than all baselines when considering both accuracy metrics, outperforming them in at least 78\% of the cities when considering the correlation coefficient or AUC. A Wilcoxon test indicated that GP obtained more accurate predictions than all baselines with a confidence level of 95\%. The correlation coefficient indicates that GP was better than LM on medium/high DIR cities, with similar results on low DIR cities, while the opposite happened when compared to AR. When considering the AUC, cities where GP is outperformed by some baseline are cities where both models do not work well (AUC close to 0.5). For those cities, the typical DIR during dengue season stays close to the boundaries, thus being harder to predict. \subsection{Analysis of Hyperparameters} Interpretability of GPs come from the hyperparameters of the covariance function, which tell us how data points are related. In this section, we study the hyperparameters obtained after optimization, shown in Table \ref{tab:hyper}. In order to make interpretation easier, some values were reported squared. \begin{table}[h!] \centering \caption{Hyperparameters Obtained After Likelihood Maximization} \label{tab:hyper} \begin{tabular}{cccc} \hline & 1st Quartile & Median & 3rd Quartile \\ \hline $\sigma_{loc}^2$ & 0.039 & 0.101 & 0.186 \\ $\sigma_{qp}^2$ & 0.484 & 1.427 & 2.311 \\ $\sigma_{lin}^2$ & 0.005 & 0.022 & 0.082 \\ $\ell_{loc}$ & 1.000 & 2.000 & 7.000 \\ $\ell_{qp}$ & 41.000 & 58.000 & 99.000 \\ $\ell_{per}$ & 1.000 & 1.000 & 2.000 \\ $\ell_{rain}^2$ & 558.000 & 2675.000 & 10270.000 \\ $\ell_{temp}^2$ & 164.000 & 768.000 & 4316.000 \\ $\ell_{hum}^2$ & 493.000 & 2449.000 & 9879.000 \\ $p$ & 54.000 & 59.000 & 73.000 \\ \hline \end{tabular} \end{table} The hyperparameters $\sigma_{loc}$, $\sigma_{qp}$, $\sigma_{lin}$ tell us the importance of each component of our kernel. The first and the second are the highest value that the local and quasi-periodic component can achieve, respectively, while the third is the value given by the linear component when climate covariates are exactly at their mean value. Notice that the quasi-periodic component has the highest impact in the kernel, confirming the notion that we should explore information from past years' data. The hyperparameters $\ell_{loc}$ and $\ell_{qp}$ indicate how fast is the decay of the covariance signal of the local and quasi-periodic components, respectively. One way to interpret these values is to think that if the difference in time between a pair of points is smaller than $\ell_{*}$, then the covariance signal from a given component will be greater than $\sigma^2_{*}/2$, that is, greater than half of the component's maximum attainable value. For the local component, only points up to two weeks away from each other were highly correlated for most of the cities. For 25\% of the cities, however, more distant relationships were found to be relevant. On the other hard, the quasi-periodic component typically correlates points from subsequent years (52 weeks). For some cities, though, even points separated by two years were correlated. The period, given by $p$, also plays a major role on the quasi-periodic component. As expected, most of the cities exhibited yearly periodicity. For at least 25\% of the cities, the periodicity was found to be greater than 52, indicating some shift on the typical dengue fever season. Finally, $\ell_{rain}$, $\ell_{temp}$, $\ell_{hum}$ provide the relative importance of each covariate. The higher the value, the less important a given covariate is. We see that rainfall was found to be the least important covariate, while temperature proved to be the most relevant one. However, since the values of all these hyperparameters are high, we observe that climate covariates do not add much information to the model. This is probably due to the fact that climate in Brazil also exhibits a yearly periodicity, thus being captured by the quasi-periodic component. It is interesting to notice the variability shown in Table \ref{tab:hyper}, indicating the flexibility of the model. It can automatically shift from a highly periodic scenario to a scenario where local information is more important, thus accommodating a wide range of behaviours within a single model. \subsection{Analysis of Predictions} In this section, we analyse the results obtained by the proposed model in more detail. Figure \ref{fig:regions} shows the results obtained according to the correlation coefficient and AUC for all cities under study, as well as results for each of the five Brazilian geographical regions. When considering the correlation coefficient, the Southeast and Center-West regions obtained the best results, with median correlation of 0.70 and 0.76, respectively, which are greater than the median correlation of all cities, 0.64. When considering AUC, all cities obtained similar results, with a global median of 0.92. This analysis is strengthened by Figure \ref{fig:maps}, which shows the spatial distribution of results obtained by both metrics. Note that most cities from North, Northeast and South exhibit low incidence of dengue fever (black dots on bottom map of Figure \ref{fig:maps}), while cities from Southeast and Center-West typically have higher DIR. This leads us to conclude that the proposed model obtains better results on cities with higher DIR. In fact, data from low incidence cities are usually much noisier, thus being naturally harder to predict. \begin{figure}[!h] \centering \includegraphics[width=0.8\linewidth]{boxplotResults.png} \caption{Results obtained when considering all cities and filtering by each of the five Brazilian regions.} \label{fig:regions} \end{figure} \begin{figure}[!h] \centering \includegraphics[width=0.64\linewidth]{maps2.pdf} \caption{Spatial distribution of correlations and areas under ROC curve obtained. Each dot represent a city and its color and shape indicates its accuracy according to a metric. Black dots on the bottom map indicates cities that never reached medium and/or high incidence and were not evaluated according to AUC.} \label{fig:maps} \end{figure} \begin{figure*}[!t] \centering \includegraphics[width=0.91\linewidth]{examples.png} \caption{Predictions for the six Brazilian capital cities with highest DIR. The black line indicates the real number of confirmed cases, while the blue line indicates the prediction given by the proposed model. The blue shaded area shows the 95\% confidence interval.} \label{fig:examples} \end{figure*} Finally, Figure \ref{fig:examples} provides a more qualitative analysis of the model, showing predictions for the six Brazilian capital cities with highest DIR. Predictions follow a similar pattern to real values, which are almost within the confidence interval. \section{Introduction} Dengue fever is a vector-borne disease transmitted by \emph{Aedes aegypti} \cite{world2009dengue}, the same mosquito that carries the viruses of zika, yellow fever and chikungunya. According to \cite{samir2013global}, dengue fever is ubiquitous throughout the tropics, with highest risk zones in the Americas and Asia. This same study estimates that about 390 million people worldwide contract dengue fever every year, with 96 million of these cases being symptomatic. Although case fatality rate can be as low as 1\% with proper treatment, the disease causes great economical and social burden. Dengue fever is endemic in most Brazilian regions, with its spread facilitated by suitable climatic and urbanization conditions. Brazil is the country with the largest number of dengue fever cases in the Americas, accounting for at least one-fourth of the symptomatic cases in the continent \cite{samir2013global}. Although the country has a successful surveillance program, it still needs an early warning system (EWS) capable of predicting outbreaks with high accuracy, so that health authorities may act in advance to minimize the impacts of the disease. In this direction, previous attempts to model dengue fever incidence have exploited the existent relationship between climate and sociodemographic factors with dengue (\cite{naish2014climate,louis2014modeling}). These works usually employ relatively simple (parametric) models, such as (generalized) linear models (\cite{hu2012spatial, porcasi2012operative, chen2012modeling, earnest2012meteorological}) or (seasonal) autoregressive models (\cite{gharbi2011time, hu2010dengue}). Although these models provide explicit information about the relationship between dengue fever and covariates, they may fail to capture the complexity inherent to dengue dynamics. Besides that, most models cannot be used in EWS, as their main purpose is to \emph{explain} previous data, and not to \emph{predict} future dengue outbreaks. In fact, the survey in \cite{louis2014modeling} indicates that, out of 26 works, only 3 were classified as EWS. In order to handle these issues, this paper proposes to model dengue fever incidence rate in Brazilian cities with Gaussian processes (GPs), a Bayesian non-parametric modelling framework that allows for flexible, accurate and interpretable models. Our main contribution is a model based on GPs equipped with a quasi-periodic kernel for predicting dengue fever incidence at city level with four weeks in advance. This time lag allows health authorities time to act to reduce the impact of future outbreaks. The resulting model proved to be accurate and flexible, obtaining better results than previous approaches in the vast majority of the cities under study. The model is also interpretable and can provide interesting information about dengue dynamics in Brazil. Finally, although we focus on dengue fever in Brazil, we believe the model to be very general and applicable to distinct localities and diseases that exhibit seasonality. This paper is organized as follows. Section \ref{sec:background} gives a brief background on GP regression. Next, we present our data collection. Section \ref{sec:model} introduces the proposed model, while Section \ref{sec:experiments} discusses experimental results. Finally, Section \ref{sec:conclusion} draws our conclusions and indicates directions of future work. \section{Proposed Model} \label{sec:model} This section discusses the proposed non-parametric model for dengue incidence modelling. An initial issue in modelling count data -- such as the number of dengue cases in a city -- as a GP is that this kind of data is usually not appropriately modelled by a Gaussian distribution. Typically, we have two possible strategies to deal with this problem. The first strategy is to change the likelihood model, for instance by modelling the (logarithm transformed) mean function of a Poisson process or a negative binomial model as a Gaussian process. One example of this strategy can be seen in \cite{vanhatalo2007sparse}, where the authors used a Poisson likelihood model. The downside of this approach is that it loses some interesting properties of GPs, namely the exact inference and the closed-form calculations. Inference under this kind of model typically requires approximations, which may be computationally expensive. The second strategy is to apply an appropriate transformation on the response variable and model such transformation as a GP. In this work, we followed the second approach and used a logarithmic transformation on the response variable, which also increased the autocorrelation since it smooths very large outbreaks. The main task in modelling via GPs is to define an appropriate covariance structure ($k_f$ in Equation \ref{eq:latent}), as it is standard practice in the literature to assume a zero-mean GP after centering the response variable. The covariance structure imposed by the GP prior should reflect what we expect from data. In the case of dengue fever incidence, we expect a smooth, possibly seasonal behaviour. We also expect to see a linear relationship between climate covariates and dengue incidence. Therefore, we define a three-part kernel to capture each of these assumptions. Let $\boldsymbol{x}_i$ denote a vector containing all climate covariates associated to week $i$ and $\boldsymbol{x}_j$ denote a similar vector associated to week $j$. Then, the covariance between $\boldsymbol{x}_i$ and $\boldsymbol{x}_j$ is given by \begin{eqnarray} k_f\left(\boldsymbol{x}_i, \boldsymbol{x}_j\right) & = & k_{1}(\Delta t) + k_{2.1}(\Delta t) k_{2.2}(\Delta t) + k_{3}(\boldsymbol{x}_i, \boldsymbol{x}_j) \label{eq:cov} \\ k_{1}(\Delta t) & = & \sigma_{loc}^2 \left( 1 + \frac{\sqrt{5}\Delta t}{\ell_{loc}} + \frac{5\Delta t^2}{3 \ell_{loc}^2} \right) exp \left( - \frac{\sqrt{5}\Delta t}{\ell_{loc}} \right) \nonumber \\ k_{2.1}(\Delta t) & = & \sigma_{qp}^2 \left( 1 + \frac{\sqrt{5}\Delta t}{\ell_{qp}} + \frac{5\Delta t^2}{3 \ell_{qp}^2} \right) exp \left( - \frac{\sqrt{5}\Delta t}{\ell_{qp}} \right) \nonumber \\ k_{2.2}(\Delta t) & = & exp\left(-2 sin^2\left( \frac{\pi \Delta t}{p} \right) / \ell_{per}^2 \right) \nonumber \\ k_{3}\left(\boldsymbol{x}_i, \boldsymbol{x}_j\right) & = & \sigma_{lin}^2 + \boldsymbol{x}_i^T Diag(\ell_{rain}^2, \ell_{temp}^2, \ell_{hum}^2)^{-1} \boldsymbol{x}_j \nonumber \end{eqnarray} where $\Delta t = |i - j|$ is the absolute distance in weeks between points $\boldsymbol{x}_i$ and $\boldsymbol{x}_j$, $Diag$ is a diagonal matrix formed of its arguments, $\sigma_{loc}$, $\sigma_{qp}$, $\ell_{loc}$, $\ell_{qp}$, $\ell_{per}$, $\ell_{rain}$, $\ell_{temp}$, $\ell_{hum}$ and $p$ are hyperparameters learned from data via likelihood (local) maximization. The first component of the kernel ($k_{1}(\Delta t)$) is a Mat\'ern kernel over the time dimension, used to enforce the assumption that following weeks should be correlated. Its hyperparameter, $\ell_{loc}$ and $\sigma_{loc}$, are used to control the range of weeks that should correlate and the strength of the correlation signal, respectively. The second component is a multiplication of a Mat\'ern kernel ($k_{2.1}(\Delta t)$) and a periodic kernel ($k_{2.2}(\Delta t)$). It is used to exploit the yearly periodicity observed in dengue incidence in some cities, while still being able to give more importance to closer years. The hyperparameters $\ell_{qp}$, $\ell_{per}$, $p$ and $\sigma_{qp}$ are useful for controlling the decay of quasi-periodicity (how many past periods should impact the incidence in a given week), the decay of periodicity (how fast the periodic signal should decay), the period and the strength of this correlation signal, respectively. Finally, the third component ($ k_{3}(\boldsymbol{x}_i, \boldsymbol{x}_j)$) is a linear kernel over weather-related covariates, where the diagonal matrix $M$ is used to control the impact of each covariate and $\sigma_{lin}$ allows for a bias term. \section*{Acknowledgment} This work was partially funded by projects InWeb (grant MCT/CNPq 573871/2008- 6), MASWeb (grant FAPEMIG/PRONEX APQ-01400-14), and by the authors’ individual grants from CAPES, CNPq and FAPEMIG. \bibliographystyle{IEEEtran}
{'timestamp': '2016-08-12T02:02:22', 'yymm': '1608', 'arxiv_id': '1608.03343', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03343'}
arxiv
\section{Introduction} Time series of counts can be viewed as realisations of non-negative integer-valued stochastic processes and arise in various applications in the natural, life and social sciences. As such there has been very active research in the various fields and recent textbooks treatments can be found in \cite{CameronTrivedi1998,KedemFokianos2002, Winkelmann2003, DHLR2015} and we refer to \cite{Davisetal1999,McKenzie2003, Ferlandetal2006,Weiss2008,CuiLund2009,DavisWu2009,JungTremayne2011} for recent surveys and some new developments of the literature. However, most of these previous works focus on univariate time series of counts and the literature on multivariate extensions is rather sparse and almost exclusively deals with models formulated in discrete time and borrow ideas from traditional autoregressive time series models. E.g.~\cite{FrankeRao1995} and \cite{Latour1997} introduced the first-order integer-valued autoregression model, which is based on the generalised Steutel and van Harn (1979) thinning operator. Recently, \cite{BoudreaultCharpentier2011} applied such models to earthquake counts. Also, the recent handbook on discrete-valued time series by \cite{DHLR2015} contains the chapter by \cite{Karlis2015} who surveys recent developments in multivariate count time series models. One challenge in handling multivariate time series is the modelling of the cross-sectional dependence. While for continuous distributions the theory of copulas presents a powerful toolbox, it has been pointed out by \cite{GenestNeslehova2007} that a problem arises in the discrete context due to the non-uniqueness of the associated copula. This can be addressed by using the continuous extension approach by \cite{DenuitLambert2005}. Indeed, for instance \cite{HeinenRengifo2007} introduce a multivariate time series model for counts based on copulas applied to continuously extended discrete random variables and fit the model to the numbers of trades of various assets at the New York stock exchange. Also, \cite{KLL2015} study discrete copula distributions with time-varying marginals and dependence structure in financial econometrics. Motivated by the reliability literature, \cite{LindskogMcNeil2003} introduced the so-called common Poisson shock model to describe the arrival of insurance claims in multiple locations or losses due to credit defaults of various types of counterparty. While the models mentioned above are interesting in their own right, the goal of this article is more ambitious since it formulates a more general modelling framework which can handle a variety of marginal distributions as well as different types of serial dependence including, in particular, both short and long memory specifications. That said, motivated by an application in financial econometrics and recognising the success the class of \Levy processes has in such settings, we focus exclusively on models whose marginal distribution is infinitely divisible. This assumption puts a restriction on the cross-sectional dependence due to the well-known result by \cite{Feller1968}, which says that a random vector with infinitely divisible distribution on $\mathbb{N}^n$ always has non-negatively correlated components. Moreover, any non-degenerate distribution on $\mathbb{N}^n$ is infinitely divisible if and only if it can be expressed as a discrete compound Poisson distribution. We will see that this is nevertheless a very rich class of distributions and suitable for our application to high frequency financial data. The new modelling framework is based on so-called multivariate integer-valued trawl processes, which are special cases of multivariate mixed moving average processes where the driving noise is given by an integer-valued \Levy basis. In the univariate case, trawl processes -- not necessarily restricted to the integer-valued case -- have been introduced by \cite{BN2011}. Also, \cite{NVG2015} used such processes in an hierarchical model in the context of extreme value theory. The univariate integer-valued case has been developed in detail in \cite{BNLSV2014}. \cite{ShephardYang2016a} studied likelihood inference for a particular subclass of an integer-valued trawl process and, more recently, \cite{ShephardYang2016b} used such processes to build an econometric model for fleeting discrete price moves. While the multivariate extension was already briefly mentioned in \cite{BNLSV2014}, this article develops the theory of multivariate integer-valued trawl (MVIT) processes in detail and presents new methodology for stochastic simulation and statistical inference for such processes and applies the new results to high frequency financial data from a limit order book. The key feature of MIVT processes, which makes them powerful for a wide range of applications is the fact that the serial dependence and the marginal distribution can be modelled independently of each other, which is for instance not the case in the famous DARMA models, see \cite{JacobsLewis1978a,JacobsLewis1978b}. As such we will present parsimonious ways of parameterising the serial correlation and will show that we can accommodate both short and long memory processes as well as seasonal fluctuations. Moreover, since MITV processes are formulated in continuous time, we can handle both asynchronous and not necessarily equally spaced observations, which is particularly important in a multivariate set-up. The motivation for this study comes from high frequency financial econometrics where discrete data arise in a variety of scenarios, e.g.~high frequent price moves for stocks with fixed tick size resemble step functions supported on a fixed grid. Also, the number of trades can give us an indication of market activity and is widely analysed in the industry. In this article, we will apply our new methodology to model the relationship between the number of submitted and deleted limit orders in a limit order book, which are key quantities in high frequency trading. The outline of this article is as follows. Section \ref{Section:Model} introduces the class of multivariate integer-valued trawl processes and presents its probabilistic properties. Section \ref{Section:crosssection} gives a detailed overview of parametric model specifications focusing on a variety of different cases for modelling the serial correlation. Moreover, we present relevant examples of multivariate marginal distributions which fall into the infinitely divisible framework. In particular, as pointed out by \cite{NKarlis2008}, the negative binomial distribution often appears to be a suitable candidate for various applications. Hence we will derive several approaches to defining a multivariate infinitely divisible distribution which allows for univariate negative binomial marginal law. In Section \ref{Section:SimInf} we will derive an algorithm to simulate from MIVT processes and develop a statistical inference methodology which we will also test in a simulation study. Section \ref{Section:Empirics} applies the new methodology to limit order book data. Finally, Section \ref{Section:conclusion} concludes. The proofs of the theoretical results are relegated to the Appendix, Section \ref{proofs}, and Section \ref{sim} provides more details on the algorithms used in the simulation study. \section{Multivariate integer-valued trawl processes}\label{Section:Model} \subsection{Integer-valued \Levy bases as driving noise} Throughout the paper, we denote by $(\Omega, \mathcal{F}, (\mathcal{F}_t), P)$ the underlying filtered probability space satisfying the usual conditions. Also, we choose a set $E \subset \R^d$ ($d\in \N$) and let the corresponding Borel $\sigma$-algebra be denoted by $\mathcal{E}=\mathcal{B}(E)$. Next we define a Radon measure $\mu$ on $(E, \mathcal{E})$, which by definition satisfies $\mu(B)< \infty$ for every compact measurable set $B \in \mathcal{E}$. In the following, we will always assume that the Assumption (A1) stated below holds. \begin{description} \item[Assumption (A1)] Let $E=\R^n\times [0,1]\times \R$ for $n\in \N$ and let $N$ be a homogeneous Poisson random measure on $E$ with intensity measure $\mu(d{\bf y}, dx, ds) =\E(N (d{\bf y}, dx, ds)) = \nu(d{\bf y}) dx ds$, where $\nu$ is a \Levy measure concentrated on $\mathbb{Z}^n\setminus \{{\bf 0}\}$ and satisfying\\ $\int_{\mathbb{R}^n} \min(1, ||{\bf y}||) \nu(d{\bf y}) < \infty$. \end{description} Using the Poisson random measure, we can define an integer-valued \Levy basis as follows. \begin{definition}\label{DefIVLevyBasis} Suppose that $N$ is a homogeneous Poisson random measure on $(E, \mathcal{E})$ satisfying Assumption (A1). An \emph{$\mathbb{Z}^n$-valued, homogeneous \Levy basis} on $([0,1]\times\mathbb{R}, \mathcal{B}([0,1]\times\mathbb{R}))$ is defined as \begin{align}\label{IVL} {\bf L}(dx, ds) =(L^{(1)}(dx, ds), \dots, L^{(n)}(dx, ds))^{\top}= \int_{\R^n} {\bf y} N(d{\bf y}, dx, ds). \end{align} \end{definition} From the definition, we can immediately see that ${\bf L}$ is infinitely divisible with characteristic function given by \begin{align*} \mathbb{E}(\exp(i \boldsymbol{ \theta}^{\top} {\bf L}(dx, ds)))=\exp(\text{C}_{{\bf L}(dx,ds)}(\boldsymbol{ \theta})), \quad \boldsymbol{ \theta} \in \R^n. \end{align*} Here, $\text{C}$ denotes the associated cumulant function, which is the (distinguished) logarithm of the characteristic function. It can we written as \begin{align*} \text{C}_{{\bf L}(dx, ds)}(\boldsymbol{ \theta}) = \text{C}_{{\bf L}'}(\boldsymbol{ \theta} )dx ds, \end{align*} where the random vector ${\bf L}'$ denotes the corresponding \emph{\Levy seed} with cumulant function given by \begin{align}\label{Mult-LK} \text{C}_{{\bf L}'}(\boldsymbol{ \theta} ) = \int_{\mathbb{R}^n}\left(e^{i\boldsymbol{\theta}^{\top} {\bf y}}-1\right) \nu(d{\bf y}), \end{align} where $\nu$ denotes the corresponding \Levy measure defined above. \begin{remark} It is important to note that the \Levy seed specifies the homogeneous \Levy basis uniquely, and vice versa, with any homogeneous \Levy basis we can associate a unique \Levy seed. Hence, in modelling terms, it will later be sufficient to discuss various modelling choices for the corresponding \Levy seed, since this will fully characterise the associated \Levy basis. \end{remark} \begin{remark} Based on the \Levy seed, we can define a \Levy process denoted by $({\bf L}'_t)_{t\geq 0}$, when setting ${\bf L}_1' = {\bf L}'$. Clearly, in this case, we get $\text{C}_{{\bf L}'_t}(\boldsymbol{ \theta}) = t \text{C}_{{\bf L}'}(\boldsymbol{ \theta})$. \end{remark} Following the construction in \citet[Theorem 4.3]{Sato1999}, we model the \Levy seed by an $n$-dimensional compound Poisson random variable given by \begin{align*} {\bf L}'=\sum_{j=1}^{N_1}{\bf Z}_j, \end{align*} where $N=(N_t)_{t\geq 0}$ is an homogeneous Poisson process of rate $v>0$ and the $({\bf Z}_j)_{j\in \mathbb{N}}$ form a sequence of i.i.d.~random variables independent of $N$ and which have no atom in ${\bf 0}$, i.e.~not all components are simultaneously equal to zero, more precisely, $\mathbb{P}({\bf Z}_j={\bf 0}) = 0$ for all $j$. \begin{remark} Recall that by modelling the \Levy seed by a multivariate compound Poisson process we can only allow for positive correlations between the components. \end{remark} \subsection{The trawls} Following the approach presented in \cite{BN2011}, see also \cite{BNLSV2014}, we now define the so-called \emph{trawls}. \begin{definition}\label{TrawlDef} We call a Borel set $A\subset [0,1]\times (-\infty, 0]$ such that $\leb(A) < \infty$ a \emph{trawl}. Further, we set \begin{align}\label{trawl} A_t = A + (0,t), \quad t \in \mathbb{R}. \end{align} \end{definition} The above definition implies that the trawl at time $t$ is just the shifted trawl from time $0$. \begin{remark} Note that the size of the trawl does not change over time, i.e.~we have $\leb(A_t)=\leb(A)$ for all $t$. \end{remark} Clearly, there is a wide class of sets which can be considered as trawls. Throughout the paper, we will hence narrow down our focus, and will concentrate on a particular subclass of trawls which can be written as \begin{align}\label{StTrawl} A = \{(x, s): s \leq 0,\ 0\leq x \leq d(s)\}, \end{align} where $ d:(-\infty, 0] \mapsto [0,1]$ is a continuous function such that $\leb(A) < \infty$. Typically we refer to $d$ as the \emph{trawl function}. In such a semi-parametric setting, we can easily deduce that \begin{align}\label{dstar} \leb(A) = \int_{-\infty}^0 d(s) ds. \end{align} Moreover, the corresponding trawl at time $t$ is given by \begin{align*} A_t = A + (0,t)= \{(x, s): s \leq t,\ 0\leq x \leq d(s-t)\}. \end{align*} \begin{definition} Let $A$ denote a trawl given by \eqref{StTrawl}. If $d(0)=1$ and $d$ is monotonically non-decreasing, then we call $A$ a \emph{monotonic trawl}. \end{definition} \begin{example} \label{Ex-Ex0} Let $d(s) = \exp(\lambda s)$ for $\lambda > 0, s \leq 0$. Then the corresponding trawl is monotonic with $A_t = A + (0,t)= \{(x, s): s \leq t,\ 0\leq x \leq \exp(\lambda(s-t))\}$. \end{example} In our multivariate framework, we will choose $n$ trawls denoted by $A^{(i)}= A_0^{(i)}$. Then we set $A^{(i)}_t = A^{(i)} + (0,t)$ for $i \in \{1, \dots, n\}$. When we work with trawls of the type \eqref{StTrawl}, we will denote by $d^{(i)}$ the corresponding trawl functions. \subsection{The multivariate integer-valued trawl process and its properties} \begin{definition} The stationary multivariate integer-valued trawl (MIVT) process is defined by \begin{align*} {\bf Y}_t = \left(L^{(1)}(A_t^{(1)}), \dots, L^{(n)}(A_t^{(n)})\right)^{\top},\quad t\in \mathbb{R}, \end{align*} where each component is given by \begin{align*} Y^{(i)}_t= L^{(i)}(A_t^{(i)})=\int_{[0,1]\times \R}\mathbf{I}_{A^{(i)}}(x,s-t)L^{(i)}(dx,ds), \quad i \in \{1, \dots, n\}, \end{align*} where $\mathbf{I}$ denotes the indicator function. \end{definition} Since the trawls have finite Lebesgue measure, the integrals above are well-defined in the sense of \cite{RajRos89}. When we define $\mathbf{I}_{\bf{A}}(x,s-t)=\diag(\mathbf{I}_{A^{(1)}}(x,s-t), \dots,\mathbf{I}_{A^{(n)}}(x,s-t))$, then we can represent the MIVT process as \begin{align*} {\bf Y}_t = \int_{\R^n\times [0,1]\times \R} {\bf y} \mathbf{I}_{\bf{A}}(x,s-t)N(d{\bf y}, dx,ds), \quad t \in \mathbb{R}, \end{align*} which shows that we are dealing with a special case of a multivariate mixed moving average process. The law of the MIVT process is fully characterised by its characteristic function, which we shall present next. \begin{proposition}\label{CharFctTrawl} For any ${\boldsymbol \theta} \in \R^n$, the characteristic function of ${\bf Y}_t$ is given by $\mathbb{E}(\exp(i{\boldsymbol \theta}^{\top}{\bf Y}_t))=\exp(C_{{\bf Y}_t}({\boldsymbol \theta}))$, where the corresponding cumulant function is given by \begin{multline*} C_{{\bf Y}_t}({\boldsymbol \theta})= \sum_{k=1}^n \sum_{\substack{1\leq i_1, \dots, i_k \leq n: \\ i_{\nu}\not = i_{\mu}, \text{ for } \nu \not = \mu}} \leb\left(\bigcap_{l=1}^kA^{(i_l)}\setminus \bigcup_{\substack{1\leq j\leq n,\\ j\not \in\{i_1, \dots, i_k\}}} A^{(j)} \right) C_{(L^{(i_1)},\dots,L^{(i_k)})}((\theta_{i_1},\dots,\theta_{i_k})^{\top}). \end{multline*} \end{proposition} \begin{corollary} In the special case when $A^{(1)}=\cdots=A^{(n)}=A$, the characteristic function simplifies to $\mathbb{E}(\exp(i{\boldsymbol \theta}^{\top}{\bf Y}_t)) = \exp\left(\leb(A) \text{C}_{{\bf L'}}({\boldsymbol \theta})\right)$. \end{corollary} This is an important result, which implies that to any infinitely divisible integer-valued law $\pi$, say, there exists a stationary integer-valued trawl process having $\pi$ as its marginal law. \subsubsection{Cross-sectional and serial dependence} Let us now focus on the cross-sectional and the serial dependence of multivariate integer-valued trawl processes. First, the cross-sectional dependence is entirely characterised through the multivariate \Levy measure $\nu$. For instance, when we focus on the pair of the $i$th and the $j$th component for $i,j \in \{1, \dots, n\}$, we define the corresponding joint \Levy measure by \begin{align*} \nu^{(i,j)}(d\cdot, d\cdot) = \int_{\R} \dots \int_{\R} \nu(dy_1, \dots, dy_{i-1}, d\cdot,dy_{i+1}, \dots, dy_{j-1},d\cdot, dy_{j+1}, \dots, dy_n). \end{align*} Then the covariance between the $i$th and the $j$th \Levy seed is given by \begin{align*} \kappa_{i,j}:=\int_{\R}\int_{\R} y_i y_j\nu^{(i,j)}(dy_i, dy_j). \end{align*} Relevant specifications of $\nu$ will be discussed in Section \ref{MultDist}. Second, the serial dependence is determined through the trawls. More precisely, following \cite{BN2011}, we introduce the so-called \emph{autocorrelator} between the $i$th and the $j$th component, which is defined as \begin{align*} R_{ij}(h) = \leb(A_0^{(i)}\cap A_h^{(j)}), \quad h \geq 0. \end{align*} Let us now focus on the autocorrelators for trawls of type \eqref{StTrawl}. \begin{proposition} Suppose the trawls $A^{(i)}$, $i \in \{1, \dots, n\}$ are of type \eqref{StTrawl}. Then for $h\geq 0$ the intersection of two trawls is given by \begin{align*} A^{(i)}\cap A^{(j)}_h =\{(x,s): s \leq 0, 0 \leq x \leq \min\{d^{(i)}(s), d^{(j)}(s-h)\}\}. \end{align*} I.e.~the autocorrelator satisfies \begin{align*} R_{ij}(h) &= \int_{-\infty}^0\min\{d^{(i)}(s), d^{(j)}(s-h)\} ds. \end{align*} \end{proposition} The proof is straightforward and hence omitted. \begin{remark} Note that the autocorrelators can be computed as soon as the corresponding trawl functions and their parameters are known. We will come back to this aspect when we discuss inference for trawl processes in Section \ref{InfSection}. \end{remark} Let us consider a canonical example when the trawl functions are given by exponential functions. \begin{example}\label{Ex-expR12} Let $d^{(i)}(s) =\exp(\lambda_i s)$. For $i, j \in \{1,\dots, n\}$ suppose that $\lambda_i < \lambda_j$. Then for $s \leq 0$ we have that $e^{\lambda_i s} \geq e^{\lambda_j s}$ and hence $A^{(i)}\cap A^{(j)} = A^{(j)}$. Hence $\leb(A^{(i)}\cap A^{(j)})=\leb(A^{(j)})=1/\lambda_j$. Similarly, we get that $R_{ij}(h)=\leb(A^{(i)}\cap A^{(j)}_h)=\frac{1}{\lambda_j}e^{-\lambda_j h}$, for $h\geq 0$. \end{example} For monotonic trawl functions we observe that there are two possible scenarios: Either, one trawl function is always \lq below\rq\ the other one, which implies that \begin{align*}R_{ij}(h) =\min(\leb(A^{(i)}),\leb(A^{(j)})), \end{align*} see e.g.~Example \ref{Ex-expR12}, or the trawl functions intersect each other. In the latter case, suppose there is one intersection of $d^{(i)}$ and $d^{(j)}$ at time $s^* <0$, say. Consider the scenario when $d^{(i)}(s) \leq d^{(j)}(s)$ for $s \leq s^*$ and $d^{(j)}(s) \leq d^{(i)}(s)$ for $s^* \leq s \leq 0$. Then \begin{align*} R_{ij}(0)&=\leb (A^{(i)}\cap A^{(j)}) = \int_{-\infty}^{s^*}d^{(i)}(s)ds + \int_{s^*}^0d^{(j)}(s)ds. \end{align*} Extensions to a multi-root scenario are straightforward. Clearly, the autocorrelators are closely related to the autocorrelation function. More precisely, we have the following result, which follows directly from the expression of the cumulant function of the multivariate trawl process. \begin{proposition} The covariance between two (possibly shifted) components $1\leq i \leq j\leq n$ for $t, h \geq 0$ is given by \begin{align*} \rho_{ij}(h) &= \Cov\left(L^{(i)}(A_t^{(i)}), L^{(j)}(A_{t+h}^{(j)})\right) = \leb\left(A^{(i)}\cap A_h^{(j)}\right)\left(\int_{\R}\int_{\R} y_i y_j\nu^{(i,j)}(dy_i, dy_j)\right)\\ &= R_{ij}(h) \kappa_{i,j}. \end{align*} Also, the corresponding auto- and cross-correlation function is given by \begin{align*} r_{ij}(h)&:=\Cor\left(L^{(i)}(A_t^{(i)}), L^{(j)}(A_{t+h}^{(j)})\right) = \frac{\leb(A^{(i)}\cap A_h^{(j)}) \left(\int_{\R}\int_{\R} y_i y_j\nu^{(i,j)}(dy_i, dy_j)\right)}{\sqrt{\leb(A^{(i)}) \Var(L^{'(i)}) \leb(A^{(j)}) \Var(L^{'(j)})}}\\ &=\frac{R_{ij}(h)}{\sqrt{\leb(A^{(i)}) \leb(A^{(j)})}} \frac{\kappa_{i,j}}{\sqrt{\Var(L^{'(i)}) \Var(L^{'(j)})}}, \end{align*} i.e.~the autocorrelation function is \emph{proportional} to the autocorrelators. \end{proposition} We will come back to the above result when we turn our attention to parametric inference for MIVT processes in Section \ref{InfSection}. \section{Parametric specifications}\label{Section:crosssection} In order to showcase the flexibility of the new modelling framework, we will discuss various parametric model specifications in this section, where we start off by considering specifications of the trawl, followed by models for the multivariate \Levy seed. \subsection{Specifying the trawl function} We have already covered the case of an exponential trawl function above and will now present alternative choices for the trawl functions and their corresponding autocorrelators, see also \cite{BNLSV2014} for other examples. While an exponential trawl leads to an exponentially decaying autocorrelation function, we sometimes need model specifications which exhibit a more slowly decaying autocorrelation function. Such trawl functions can be constructed from the exponential trawl function by randomising the memory parameter as we will describe in the following example. To simplify the notation we will in the following supress the indices $i$ for the corresponding component in the multivariate construction, i.e.~we set $d=d^{(i)}$ and do not write the sub-/superscripts for the corresponding parameters. \begin{example}\label{Ex-ExGIG} Define the trawl function by \begin{align*} d(z) = \int_{0}^{\infty} e^{\lambda z} \pi(d \lambda), \qquad \text{for} \; z \leq 0, \end{align*} for a probability measure $\pi$ on $(0, \infty)$. Suppose that $\pi$ is absolutely continuous with density $f_{\pi}$, then the corresponding trawl function can be written as \begin{align*} d(z) = \int_{0}^{\infty} e^{\lambda z} f_{\pi}(\lambda) d\lambda, \end{align*} which again leads to a monotonic trawl function. The corresponding autocorrelation function is given by \begin{align*} r(h) &= \frac{\int_0^{\infty}\frac{1}{\lambda}e^{-\lambda h} \pi(d \lambda)}{\int_0^{\infty}\frac{1}{\lambda} \pi(d \lambda)}, \end{align*} assuming that $\int_0^{\infty}\frac{1}{\lambda} \pi(d \lambda)< \infty$. \end{example} \cite{BNLSV2014} discuss various constructions of that type depending on different choices of the probability measure $\pi$ and we refer to that article for more details on the computations. In applications, we often assume that $\pi$ is absolutely continuous with respect to the Lebesgue measure and we denote its density by $f_{\pi}$. A very flexible parametric framework can be obtained by choosing $f_{\pi}$ to be a generalised inverse Gaussian (GIG) density as we shall discuss in the next example. \begin{example}\label{ExGIGDetails} Suppose that $f_{\pi}$ is the density of the GIG distribution, i.e. \begin{align}\label{GIGdensity} f_{\pi}(x) = \frac{(\gamma/\delta)^{\nu}}{2K_{\nu}(\delta \gamma)} x^{\nu -1} \exp\left(-\frac{1}{2}(\delta^2 x^{-1} + \gamma^2 x)\right), \end{align} where $\nu \in \mathbb{R}$ and $\gamma$ and $\delta$ are both nonnegative and not simultaneously equal to zero. Here we denote by $K_{\nu}(\cdot)$ the modified Bessel function of the third kind. Straightforward computation show that the corresponding trawl function is given by \begin{align*} d(z) &= \left(1-\frac{2z}{\gamma^2}\right)^{-\frac{\nu}{2}} \frac{K_{\nu}(\delta\gamma \sqrt{1-\frac{2z}{\gamma^2}})}{K_{\nu}(\delta \gamma)}, \end{align*} and the corresponding size of the trawl set equals \begin{align*} \leb(A)&= \frac{(\gamma/\delta) K_{\nu-1}(\delta \gamma)}{K_{\nu}(\delta \gamma)}. \end{align*} Moreover, the autocorrelation function is given by \begin{align*} r(h) &= \frac{K_{\nu-1}(\delta \sqrt{\gamma^2+ 2h})}{K_{\nu-1}(\delta \gamma)} \left(1+\frac{2h}{\gamma^2} \right)^{\frac{1}{2}(1-\nu)}. \end{align*} \end{example} Some special cases of the GIG distribution include the inverse Gaussian and the gamma distribution, which lead to interesting parametric examples which we shall study next. \begin{example}\label{supIGTrawl} Suppose we choose an inverse Gaussian (IG) density function for $f_{\pi}$. Then we obtain the so-called sup-IG trawl function, which can be written as \begin{align*} d(z) = \left(1-\frac{2z}{\gamma^2}\right)^{-1/2}\exp\left(\delta \gamma\left(1-\sqrt{1-\frac{2z}{\gamma^2}}\right)\right), \end{align*} for nonnegative parameters $\delta, \gamma$ which are assumed not to be simultaneously equal to zero. Then we have that $\leb(A) = \frac{\gamma}{\delta}$ and the corresponding autocorrelation function is given by \begin{align*} r(h) = \exp\left(\delta \gamma \left(1-\sqrt{1+\frac{2h}{\gamma^2}} \right) \right), \quad h \geq 0. \end{align*} \end{example} Next, we consider an example where the trawl function decays according to a power law. \begin{example} A long memory specification can be obtained when the probability measure $\pi$ is chosen to have Gamma distribution. In that case, we obtain a trawl function given by \begin{align*} d(z) = \left( 1-\frac{z}{\alpha}\right)^{-H}, \quad \alpha > 0, H>1. \end{align*} Then $\leb(A)=\alpha/(H-1)$. Also, \begin{align*} r(h)= \left(1 + \frac{h}{\alpha}\right)^{1-H}. \end{align*} I.e.~when $H\in (1,2]$ we have a stationary long memory model, and when when $H>2$ we obtain a stationary short memory model. \end{example} Finally, we consider the case of a seasonal trawl function. \begin{example} A seasonally varying trawl function can be obtained by setting $d(z)=d_m(z)d_s(z)$, where $d_m$ is a monotonic trawl function and $d_s$ is a periodic seasonal function. E.g.~as discussed in \cite[Example 9]{BNLSV2014}, we can consider the following functional form \begin{align*} d(z) = \frac{1}{2}\exp(\lambda x)\left[\cos(az) +1\right], \quad \text{where } a =2\pi\psi. \end{align*} Here $\lambda >0$ determines how quickly the function decays, whereas $\psi\in \R$ denotes the period of the season. In this case, we obtain $\leb(A)=(2\lambda^2 +a^2)/(2\lambda(\lambda^2+a^2))$ and \begin{align*} r(h) = \frac{e^{-\lambda h}}{2\lambda(\lambda^2 + a^2)}\left(\lambda^2\cos(ah)-a\lambda \sin(ah) + \lambda^2 + a^2\right). \end{align*} Note that this construction leads to a seasonal autocorrelation function, but not to seasonality in the levels of the trawl process. \end{example} \subsection{Modelling the cross-sectional dependence}\label{MultDist} The trawl process is completely specified, as soon as both the trawls and the marginal distribution of the multivariate \Levy seed are specified. When it comes to infinitely divisible discrete distributions, the Poisson distribution is the natural starting point and we will review multivariate extensions in Section \ref{MultP}. However, since many count data exhibit overdispersion, it is crucial that we go beyond the Poisson framework. In the univariate context, there have been a variety of articles on suitable discrete distributions, see e.g.~\cite{PuigValero2006} and \cite{NKarlis2008} amongst others. However, the literature on parametric classes of multivariate infinitely divisible discrete distributions with support on $\mathbb{N}^n$ is rather sparse. We know that any such distribution necessarily is of discrete compound Poisson type, see \cite{Feller1968,OspinaGerber1987, Sundt2000}, and always has non-negatively correlated components. In Section \ref{PoissonMix} we will discuss a possible parametrisation based on Poisson mixtures of random additive-effect-type models. \subsubsection{Multivariate Poisson marginal distribution}\label{MultP} As before, we denote by ${\bf L'} =(L^{'(1)},\dots, L^{'(n)})^{\top}$ the \Levy seed. To start off with we present a multivariate Poisson law for the \Levy seed. In order to introduce dependence between the Poisson random variables, one typically uses a so-called \emph{common factor approach}, which we outline in the following, see e.g.~\cite{Karlis2002,KarlisMeligkotsidou2005}. Suppose that we have $m\in \mathbb{N}$ independent random variables $X^{(i)} \sim Poi(\theta_i)$ for $i=1, \dots, m$, and set ${\bf X}=(X^{(1)},\dots, X^{(m)})^{\top}$. Let ${\bf A}$ denote a $n\times m$-matrix (for $n \in \mathbb{N}$) with 0-1 entries and having no duplicate columns. We then set ${\bf L'} ={\bf A}{\bf X}$, which clearly follows a multivariate Poisson distribution. The corresponding mean and variance can be easily computed and are given by $\mathbb{E}({\bf L'})= {\bf A} {\bf M}$ and $\Var({\bf L'}) = {\bf A} {\boldsymbol \Sigma} {\bf A}^{\top}$, respectively, where ${\bf M}=\mathbb{E}({\bf X})$ and ${\boldsymbol \Sigma} = \Var({\bf X})$. Since the components $X^{(i)}$ are independent, we have ${\boldsymbol \Sigma} = \diag(\theta_1, \dots, \theta_m)$ and ${\bf M}^{\top} = (\theta_1, \dots, \theta_m)$. The above construction implies that $L^{'(i)}\sim Poi(v_i)$, where $v_i = \sum_{k=1}^ma_{ik}\theta_i$. Also, for $i\not = j$ we have that \begin{align*} \Cor(L^{'(i)}, L^{'(j)})= \frac{\sum_{k=1}^{m} a_{ik}\theta_k a_{kj}}{\sqrt{\sum_{k=1}^{m} a_{ik}^2\theta_k \sum_{k=1}^{m} a_{jk}^2\theta_k }}. \end{align*} Let us study some relevant examples within this modelling framework. \begin{example} An $n$-dimensional model with one common factor between all components can be obtained by choosing $m=n+1$, and \begin{align*} {\bf A} = \left( \begin{array}{ccccc}1&0&\cdots&\cdots&1 \\ 0 & 1& 0& \cdots & 1\\ \vdots & \ddots & \ddots & \ddots & \vdots\\ 0 & \cdots & 0 & 1 & 1 \end{array}\right), && {\bf X} = \left(\begin{array}{c} X^{(1)}\\ \hdots\\ X^{(n)}\\ X^{(0)} \end{array} \right) \end{align*} and independent Poisson random variables $X^{(i)}\sim Poi(\theta_i)$, for $i=0,1,\dots,n$. Then we have \begin{align*} L^{'(1)} = X^{(1)} + X^{(0)},&& L^{'(2)} = X^{(2)} + X^{(0)}, && \cdots, && L^{'(n)} = X^{(n)} + X^{(0)}. \end{align*} Here each component has marginal Poisson distribution, i.e.~$L^{'(i)}\sim Poi(\theta_i + \theta_0)$ and for $i\not = j$ we have that $\Cov(L^{'(i)},L^{'(j)}) = \theta_0$. \end{example} Beyond the bivariate case, the example above presents a rather restrictive model for applications since it only allows for one common factor. A less sparse choice of ${\bf A}$ would allow for more flexible model specifications. Let us consider a more realistic example in the trivariate case next. \begin{example} Consider a model of the type \begin{align*} L^{'(1)} &= X^{(1)} + X^{(12)} + X^{(13)} + X^{(123)},\\ L^{'(2)} &= X^{(2)} + X^{(12)} + X^{(23)} + X^{(123)},\\ L^{'(3)} &= X^{(3)} + X^{(13)} + X^{(23)} + X^{(123)} \end{align*} for independent Poisson random variables $X^{(i)}$ with parameters $\theta_i$, for \\ $i \in \{\{1\}, \{2\}, \{3\}, \{12\}, \{13\}, \{23\}, \{123\} \}$. Such a model specification corresponds to the choice of \begin{align*} {\bf A } = \left( \begin{array}{ccccccc} 1 & 0 & 0 & 1 & 1& 0 & 1\\ 0 & 1& 0 & 1& 0 & 1 & 1\\ 0 & 0 & 1& 0 & 1 & 1& 1 \end{array} \right), && {\bf X}= \left( X^{(1)}, X^{(2)}, X^{(3)},X^{(12)},X^{(13)},X^{(23)},X^{(123)} \right)^{\top}. \end{align*} Here we have that $L^{'(1)}\sim Poi(\theta_1+\theta_{12}+\theta_{13}+\theta_{123})$, $L^{'(2)}\sim Poi(\theta_2+\theta_{12}+\theta_{23}+\theta_{123})$ and $L^{'(3)}\sim Poi(\theta_3+\theta_{13}+\theta_{23}+\theta_{123})$. \end{example} The above example treats a very general case which allows for all possible bivariate as well as a trivariate covariation effect. A slightly simpler specification is given in the next example, which only considers pairwise interaction terms. \begin{example} Choosing \begin{align*} {\bf A } = \left( \begin{array}{cccccc} 1 & 0 & 0 & 1 & 1& 0 \\ 0 & 1& 0 & 1& 0 & 1 \\ 0 & 0 & 1& 0 & 1 & 1 \end{array} \right), && {\bf X}= \left( X^{(1)}, X^{(2)}, X^{(3)},X^{(12)},X^{(13)},X^{(23)} \right)^{\top}, \end{align*} results in a trivariate model of the form \begin{align*} L^{'(1)} = X^{(1)} + X^{(12)} + X^{(13)},&& L^{'(2)} = X^{(2)} + X^{(12)} + X^{(23)}, && L^{'(3)} = X^{(3)} + X^{(13)} + X^{(23)}, \end{align*} for independent Poisson random variables $X^{(i)}$ with parameters $\theta_i$, for\\ $i \in \{\{1\}, \{2\}, \{3\}, \{12\}, \{13\}, \{23\}\}$. Then we have that $L^{'(1)}\sim Poi(\theta_1+\theta_{12}+\theta_{13})$, $L^{'(2)}\sim Poi(\theta_2+\theta_{12}+\theta_{23})$ and $L^{'(3)}\sim Poi(\theta_3+\theta_{13}+\theta_{23})$; also, \begin{align*} \Var({\bf L'}) = \left( \begin{array}{ccc} \theta_1 + \theta_{12}+\theta_{13} & \theta_{12} & \theta_{13}\\ \theta_{12} & \theta_2 + \theta_{12} +\theta_{23}& \theta_{23}\\ \theta_{13} & \theta_{23} & \theta_{3}+\theta_{13}+\theta_{23} \end{array} \right). \end{align*} \end{example} \subsubsection{Multivariate discrete compound Poisson marginal distribution obtained from Poisson mixtures} \label{PoissonMix} While the Poisson distribution is a good starting point in the context of modelling count data, for many applications it might be too restrictive. In particular, often one needs to work with distributions which allow for overdispersion, i.e.~that the variance is bigger than the mean. Since we are interested in staying within the class of discrete infinitely divisible stochastic processes, the most general class of distributions we can consider are the discrete compound Poisson distributions. To this end, we model the \Levy seed by an $n$-dimensional compound Poisson random variable, see e.g.~\citet[Theorem 4.3]{Sato1999}, given by \begin{align*} {\bf L}'=\sum_{j=1}^{N_1}{\bf C}_j, \end{align*} where $N=(N_t)_{t\geq 0}$ is an homogeneous Poisson process of rate $v>0$ and the $({\bf C}_j)_{j\in \mathbb{N}}$ form a sequence of i.i.d.~random variables independent of $N$ and which have no atom in ${\bf 0}$, i.e.~not all components are simultaneously equal to zero, more precisely, $\mathbb{P}({\bf C}_j={\bf 0}) = 0$ for all $j$.\\ \ \noindent{\bf General Poisson mixtures}\\ \noindent Previous research has clearly documented that Poisson mixture distributions provide a flexible class of distributions which are suitable for various applications, see e.g.~\cite{KarlisXekalaki2005} for a review. In this section, we are going to introduce a parsimonious parametric model class for the $n$-dimensional \Levy seed ${\bf L}'$, which uses Poisson mixtures and is based on the results in Section 5 of \cite{BNBlaesildSeshadri1992}. To this end, consider random variables $X_1, \dots, X_n$ and $Z_1, \dots, Z_n$ for $n \in \mathbb{N}$ and assume that conditionally on $\{Z_1, \dots, Z_n\}$ the $X_1, \dots, X_n$ are independent and Poisson distributed with means given by the $\{Z_1, \dots, Z_n\}$. We then model the joint distribution of the $\{Z_1, \dots, Z_n\}$ by a so-called additive effect model as follows: \begin{align*} Z_i = \alpha_i U + V_i, \quad i = 1, \dots, n, \end{align*} where the random variables $U, V_1, \dots, V_n$ are independent and the $\alpha_1, \dots, \alpha_n$ are nonnegative parameters. We can easily derive the probability generating function of the joint distribution of $X_1, \dots, X_n$, cf.~\citet[Section 5]{BNBlaesildSeshadri1992}: \begin{align*} \mathbb{E} (t_1^{X_1}\cdots t_n^{X_n}) = M_U\left( \sum_{i=1}^n \alpha_i(t_i-1)\right) \prod_{i=1}^n M_{V_i}(t_i-1), \end{align*} where we denote by $M_X(\theta)=\mathbb{E}(e^{\theta X})$ the moment generating function of a random variable $X$ with parameter $\theta$. Also, we can compute the means and the covariance function of the $Y_i$s and find that \begin{align*} \mathbb{E}(X_i) = \alpha_i \mathbb{E}(U) + \mathbb{E}(V_i), \quad i =1, \dots, n, \end{align*} and \begin{align*} \Cov(X_i,X_j) = \left \{ \begin{array}{ll} \alpha_i^2 \Var(U) + \Var(V_i) + \alpha_i \mathbb{E}(U) + \mathbb{E}(V_i), & \text{ if } i= j,\\ \alpha_i \alpha_j \Var(U), & \text{ if } i \not = j. \end{array} \right. \end{align*} Next we derive the joint law of $(X_1, \dots,X_n)$, see \cite{BNBlaesildSeshadri1992} for the bivariate case. \begin{proposition}\label{JointLaw} In the additive random effect model the joint law of $(X_1, \dots,X_n)$ is given by \begin{multline*} P(X_1=x_1, \dots, X_n=x_n) = \frac{1}{x_1!\cdots x_n!} \sum_{j_1=0}^{x_1}\cdots \sum_{j_n=0}^{x_n} {x_1 \choose j_1}\cdots{x_n \choose j_n}\alpha_1^{j_1}\cdots \alpha_j^{j_n} \\ \cdot \E(U^{j_1+\cdots+j_n}e^{-(\alpha_1 + \cdots + \alpha_n)U}) \prod_{k=1}^n \E(V_k^{ y_k-j_k}e^{-V_k}). \end{multline*} \end{proposition} Next, we establish the key result of this section, which links the Poisson mixture distribution based on an additive effect model to a discrete compound Poisson distribution. Recall, see e.g.~\citet[p.~18]{Sato1999}, that an $n$-dimensional compound Poisson random variable ${\bf L}' =\sum_{i=1}^{N_1}{\bf C}_i$ has Laplace transform given by \begin{align}\label{LaplaceCPP1} \mathcal{L}_{{\bf L}'}({\boldsymbol \theta})=\E(e^{-{\boldsymbol \theta}^{\top}{\bf L}'})=\exp(v (\mathcal{L}_{{\bf C}}({\boldsymbol \theta})-1)), \end{align} where $v>0$ is the intensity of the Poisson process $N$ and $\mathcal{L}_{{\bf C}}({\boldsymbol \theta})$ is the Laplace transform of the i.i.d.~jump sizes. \begin{proposition}\label{CPRep} The Poisson mixture model of random-additive-effect type can be represented as a discrete compound Poisson distribution with rate \begin{align*} v &= -\left( \overline K_U(\alpha) + \sum_{i=1}^n \overline K_{V_i}(1)\right) , \end{align*} where $\alpha = \sum_{i=1}^n\alpha_i$ and $\overline K$ denotes the kumulant function, i.e.~the logarithm of the Laplace transform, and the jump size distribution has Laplace transform given by \begin{align*} \mathcal{L}_{{\bf C}}({\boldsymbol \theta}) &= \frac{1}{v}\left\{\sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k q_k^{(U)} +\sum_{i=1}^n\sum_{k=1}^{\infty} e^{-\theta_i k} q_k^{(V_i)} \right\}, \end{align*} where \begin{align*} q_k^{(U)} = \frac{1}{k!} \int_{\R}e^{-\alpha x} x^k\nu_U(dx), && q_k^{(V_i)} = \int_{\R} \frac{x^k}{k!}e^{-x}\nu_{V_i}(dx), \quad \text{ for } i \in \{1, \dots, n\}, \end{align*} where $\nu_U$ and $\nu_{V_i}$ denotes the \Levy measure of $U$ and $V_i$, respectively. \end{proposition} The above result is very important since we need the compound Poisson representation to efficiently simulate the trawl process, as we shall discuss in Section \ref{simalgo}.\\ \ \noindent{\bf Multivariate negative binomial distribution}\\ \noindent In situations where the count data are overdispersed and call for distributions other than the Poisson one, we can in principle choose from a great variety of discrete compound Poisson distributions. Motivated by our empirical study, see Section \ref{Section:Empirics}, and also the results in \cite{BNLSV2014}, we investigate the case of a negative binomial marginal law in more detail since this is one of the infinitely divisible distributions which can cope with overdispersion. Recall that we say that a random variable $X$ has negative binomial law with parameters $\kappa>0, 0<p<1$, i.e.~$X\sim NB(\kappa, p)$ if its probability mass function is given by \begin{align*} \mathbb{P}(X=x) = {\kappa+x-1 \choose x} p^x(1-p)^{\kappa}, \quad x \in \{0,1,\dots\}. \end{align*} Its probability generating function is given by $G(t) =\E(t^X) = \left(1-\frac{p}{1-p}(t-1) \right)^{-\kappa}$. Also, recall that a random variable $X$ is said to be gamma distributed with parameters $a,b>0$, i.e.~$X\sim\Gamma(a,b)$ if its probability density is given by $f(x) =\frac{b^a}{\Gamma(a)}x^{a-1}e^{-bx}$, for $x>0$. Now, we set $U \sim \Gamma(\kappa,1)$ and $V_i \sim \Gamma(\kappa_i,\beta_i^{-1})$ in the Poisson mixture model. Then the probability generating function of $(X_1,\dots,X_n)$ is given by \begin{align*} \mathbb{E} (t_1^{X_1}\cdots t_n^{X_n}) &= \left(1+ \sum_{i=1}^n \alpha_i(t_i-1)\right)^{-\kappa} \prod_{i=1}^n (1-\beta_i(t_i-1))^{-\kappa_i}. \end{align*} Next we are going to describe three examples, see \citet[Example 5.3]{BNBlaesildSeshadri1992}, which lead to negative binomial marginals. The first example, Example \ref{ex_ind}, covers the case of independent components, in the second example, Example \ref{ex_dep}, the fully dependent case is achieved through the presence of a common factor, and the third example, Example \ref{ex_indanddep}, combines the previous two cases by allowing for both a common (dependent) factor and additional independent components. \begin{example}[Independence case]\label{ex_ind} We set $\alpha_i \equiv 0$, for $i =1, \dots, n$ and choose $V_i \sim \Gamma(\kappa_i,1/\beta_i)$. Then $\mathbb{E} (t_1^{X_1}\cdots t_n^{X_n}) = \prod_{i=1}^n (1-\beta_i(t_i-1))^{-\kappa_i}$, which implies that the $X_i$ are independent and satisfy $X_i \sim NB(\kappa_i, \beta_i/(1+\beta_i))$. \end{example} \begin{example}[Dependence through common factor]\label{ex_dep} Choose $U \sim \Gamma(\kappa, 1)$ and $V_i \equiv 0$, for $i =1, \dots, n$. Note that such a construction extends the bivariate case considered in \cite{ArbousKerrich1951}. Then $\mathbb{E} (t_1^{X_1}\cdots t_n^{X_n}) = \left(1+ \sum_{i=1}^n \alpha_i(t_i-1)\right)^{-\kappa}$, which implies that $X_i \sim NB(\kappa, \alpha_i/(1+\alpha_i))$ and also $\sum_{i=1}^n X_i \sim NB\left(\kappa, \frac{\sum_{i=1}^n \alpha_i}{1+\sum_{i=1}^n \alpha_i} \right)$. \end{example} \begin{example}[Dependence through common factor and additional independent factors]\label{ex_indanddep} Suppose that $U \sim \Gamma(\kappa, 1)$ and $V_i \sim \Gamma(\kappa_i,1/\alpha_i)$. Then one can write $Z_i=\alpha_i(U + W_i)$, for $U \sim \Gamma(\kappa, 1)$ and $W_i \sim \Gamma(\kappa_i,1)$. Then we can deduce that $\mathbb{E} (t_1^{X_1}\cdots t_n^{X_n}) = \left(1+ \sum_{i=1}^n \alpha_i(t_i-1)\right)^{-\kappa} \prod_{i=1}^n (1-\alpha_i(t_i-1))^{-\kappa_i}$. Hence $X_i \sim NB(\kappa+\kappa_i, \alpha_i/(1+\alpha_i))$. \end{example} \begin{remark} The dependence concepts used here can be considered as Poisson mixtures of the first kind, see \cite{KarlisXekalaki2005}. \end{remark} We conclude this section by deriving the compound Poisson representation of the multivariate negative binomial distribution. \begin{example}\label{Ex} As before, let $U \sim \Gamma(\kappa,1), V_i \sim \Gamma(\kappa_i,1/\beta_i)$. Recall that for $X\sim \Gamma(a,b)$, $\E(e^{i\theta X}) = (1-i\theta/b)^{-a}$. Hence $\mathcal{L}_U(\theta)=(1+\theta)^{-\kappa}$, and $\mathcal{L}_V(\theta)= (1+\theta\beta_i)^{-\kappa_i}$. Also, $\overline K_U(\theta)=-\kappa\log(1+\theta)$, and $\overline K_V(\theta)= -\kappa_i\log(1+\theta\beta_i)$. Then the rate in the compound Poisson representation is given by $v= \kappa\log(1+\alpha) + \sum_{i=1}^n \kappa_i\log(1+\beta_i)$. Further, we have $\nu_U(dx) = \kappa x^{-1}e^{- x}dx$, and $\nu_{V_i}(dx)=\kappa_ix^{-1}e^{-x/\beta_i}dx$. Then we can compute \begin{align*} q_k^{(U)} &=\frac{1}{k!} \int_{\R}e^{-\alpha x} x^k\nu_U(dx) = \frac{1}{k!} \int_{\R}e^{-\alpha x} x^k \kappa x^{-1}e^{- x}dx = \frac{\kappa}{k!}\int_{\R}e^{-(\alpha+1)x}x^{k-1}dx\\ &=\frac{\kappa}{k}(\alpha+1)^{-k},\\ q_k^{(V_i)} &= \int_{\R} \frac{x^k}{k!}e^{-x}\nu_{V_i}(dx) =\int_{\R} \frac{x^k}{k!}e^{-x}\kappa_ix^{-1}e^{-x/\beta_i}dx =\frac{\kappa_i}{k!}\int_{\R}e^{-(1+1/\beta_i)x}x^{k-1}dx\\ &= \frac{\kappa_i}{k}(1+1/\beta_i)^{-k}. \end{align*} Recall the series expansion of the logarithm: $\sum_{k=1}^{\infty}\frac{x^k}{k} = -\log(1-x)$, for $x\leq 1$ and $x\not = 1$. Hence we conclude that \begin{align*} \mathcal{L}_{{\bf C}}({\boldsymbol \theta}) &= \frac{1}{v}\left\{\sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k q_k^{(U)} +\sum_{i=1}^n\sum_{k=1}^{\infty} e^{-\theta_i k} q_k^{(V_i)} \right\}\\ &= \frac{1}{v}\left\{\sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k \frac{\kappa}{k}(\alpha+1)^{-k} +\sum_{i=1}^n\sum_{k=1}^{\infty} e^{-\theta_i k} \frac{\kappa_i}{k}(1+1/\beta_i)^{-k}\right\}\\ &=\frac{1}{v}\left\{ -\kappa\log\left(1- \sum_{i=1}^n \frac{\alpha_i}{\alpha+1}e^{-\theta_i}\right) -\sum_{i=1}^n\kappa_i \log\left(1-e^{-\theta_i }(1+1/\beta_i)^{-1} \right) \right\}. \end{align*} I.e.~we can either represent the distribution by one discrete compound Poisson distribution. Alternatively, we can write it as convolution of $n+1$ independent compound Poisson laws, where one component has the multivariate logarithmic distribution with parameters $(p_1,\dots,p_n)$ for $p_i =\alpha_i/(\alpha+1)$ as the jump size distribution, see e.g.~\cite{GB1967} and Remark \ref{MLSD} below. The remaining components have a one-dimensional logarithmic distribution in one component of the jump sizes and the other components are set to zero, more precisely, we can write \begin{align*} {\bf L}'_1 = \sum_{j=1}^{N_1^{||}}{\bf C}_j^{||} + \sum_{i=1}^n \sum_{j=1}^{N_1^{(i)\bot }} (0,\dots, 0, C_j^{(i)\bot }, 0, \dots, 0)^{\top}, \end{align*} where the component $C_j^{(i)\bot }$ is in the $i$th row in the $n$-dimensional column vector. The Poisson random variable $N_1^{||}$ has intensity $\kappa \log(1+\alpha)$ and the Poisson random variables $N_1^{(i)\bot }$ have rates $\kappa_i \log(1+\beta_i)$. Further, $C_j^{(i)\bot }\sim \text{Log}(\frac{\beta_i}{1+\beta_i})$. \end{example} \begin{remark}\label{MLSD} Recall the following properties of the multivariate logarithmic series distribution, see e.g.~\cite{GB1967}. ${\bf C}^{||} \sim \text{Log}(p_1,\dots,p_n)$, where $0<p_i<1, p:=\sum_{i=1}^np_i <1$ if for ${\bf c}\in \N_0^n \setminus \{{\bf 0} \}$, \begin{align*} \mathbb{P}({\bf C}^{||}={\bf c})=\frac{\Gamma(c_1+\cdots+c_n)}{c_1! \cdots c_n!}\frac{p_1^{c_1}\cdots p_n^{c_n}}{[-\log(1-p)]}. \end{align*} Each component $C^{||(i)}$ follows the modified univariate logarithmic distribution with parameters $\tilde p_i = p_i/(1-p+p_i)$ and $\delta_i= \log(1-p+p_i)/\log(1-p)$, i.e. \begin{align*} \mathbb{P}(C^{||(i)} =c_i) = \left\{ \begin{array}{ll} \delta_i, & \text{for } c_i=0\\ (1-\delta_i) \frac{1}{c_i}\frac{\tilde p_i^{c_i}}{[-\log(1-\tilde p_i)]}, & \text{for } c_i \in \N. \end{array} \right. \end{align*} \end{remark} \section{Simulation and inference}\label{Section:SimInf} We will now turn our attention to simulation and inference for trawl processes. We will start off by deriving a simulation algorithm which is based on the compound-Poisson-type representation of MIVTs. This will enable us to simulate sample paths from our new class of processes, which can be used for model-based parametric bootstrapping in parametric inference. The inference procedure itself will be based on the (generalised) method of moments, since the cumulants of the multivariate trawl process are readily available. \subsection{Simulation algorithm}\label{simalgo} First of all, we discuss how to simulate a univariate MIVT process. For each component $i\in \{1,\dots,n\}$, we have the following representation. \begin{align*} Y_t^{(i)} &= L^{(i)}(A^{(i)}_t) =X_{0,t}^{(i)}+ X_t^{(i)}, \end{align*} where $X_{0,t}^{(i)}=L^{(i)}(\{(x, s): s \leq 0, 0 \leq x \leq d^{(i)}(s-t)\})$ and $X_t^{(i)}= L^{(i)}(\{(x, s): 0<s \leq t, 0 \leq x \leq d^{(i)}(s-t)\})$, for a trawl function $d^{(i)}$. We would like to argue that the term $X_{0,t}^{(i)}$ is asymptotically negligible in the sense that it converges to zero as $t\to\infty$, which will allow us to concentrate on the term $X_t^{(i)}$ in the following. Indeed, this conjecture holds as the following proposition shows. \begin{proposition}\label{Prop_ConvofIniValue} For a trawl function $d^{(i)}$, we have that $X_{0,t}^{(i)}=L^{(i)}(\{(x, s): s \leq 0, 0 \leq x \leq d^{(i)}(s-t)\})\to 0$ in probability, as $t\to \infty$. \end{proposition} Hence, we will focus on simulating $X_t^{(i)}$ and will work with a burn-in period in the simulation such that the effect of $X_{0,t}^{(i)}$ is negligible. A realisation of ${\bf L}$ consists of a countable set $R$ of points $({\bf y},x,s)$ in $\N_0^n\setminus\{ {\bf 0}\} \times [0,1]\times \R$. When we project the point pattern to the time axis, we obtain the arrival times of a Poisson process $N_t$ with intensity $v= \nu(\R^n)$. The corresponding arrival times are denoted by $t_1, \dots, t_{N_t}$ and we associate uniform heights $U_1, \dots, U_{N_t}$ with them, see \cite{BNLSV2014} for a detailed discussion in the univariate case. So as soon as we have specified the jump size distribution of the ${\bf C}$, we can use the representation \begin{align*} X_t^{(i)}= \sum_{j=1}^{N_t}C_j^{(i)}\mathbb{I}_{\{U_j \leq d^{(i)}(t_j-t)\}}, \end{align*} to simulate each component. \begin{algorithm} \label{GenSimAlgo} In this algorithm we suppress the dependence on the superscript ${(i)}$ and describe how to simulate from the one-dimensional of components of the form \begin{align}\label{CPP} X_t:=\sum_{j=1}^{N_t}C_j\mathbb{I}_{\{U_j \leq d(t_j-t)\}} \end{align} We want to simulate $X$ on a $\Delta$-grid of $[0,t]$, where $\Delta >0$, i.e.~we want to find $(X_0,X_{1\Delta}, \dots, X_{\lfloor t/\Delta \rfloor\Delta})$. \begin{enumerate} \item Generate a realisation $n_t$ of the the Poisson random variable $N_t$ with mean $v t$ for $v>0$. \item Generate the pairs $(t_j, U_j)_{j\in \{1,\dots,n_t\}}$ where the series $(t_1,\dots, t_{n_t})$ consists of realisations of ordered i.i.d.~uniform random variables on $[0,t]$. The $(U_1,\dots,U_{n_t})$ are i.i.d.~and uniformly distributed on $[0,1]$ and independent of the arrival times $(t_1,\dots, t_{n_t})$. \item Simulate the i.i.d.~jump sizes $C_1,\dots, C_{n_t}$. \item Construct the trawl process on a $\Delta$-grid, where $\Delta >0$, by setting $X_0=0$ and \begin{align}\label{simstep} X_{k\Delta}:=\sum_{j=1}^{\text{card}\{t_l:t_l\leq k\Delta \}}C_j\mathbb{I}_{\{U_j \leq d(t_j-k\Delta)\}}, \quad k=1, \dots, \lfloor t/\Delta \rfloor. \end{align} \end{enumerate} \end{algorithm} \begin{remark} Note that the condition in the indicator function in \eqref{simstep} can be expressed in a vectorised form, which allows a fast implementation of the simulation algorithm, see Section \ref{SimTrawlAppendix} for details. \end{remark} In order to generate samples from the multivariate process, it is easiest to split the compound Poisson seed into dependent and independent components and simulate the components separately as we shall describe in more detail in the following example. \begin{example} Suppose we want to simulate from the multivariate trawl process with negative binomial marginal law as described in Example \ref{ex_indanddep}. Then we split each component into a dependent and an independent component as follows: \begin{align*} X_t^{(i)}= \sum_{j=1}^{N_t}C_j^{(i)}\mathbb{I}_{\{U_j \leq d^{(i)}(t_j-t)\}} = \sum_{j=1}^{N_t^{||}}C_j^{||(i)}\mathbb{I}_{\{U_j \leq d^{(i)}(t_j-t)\}} +\sum_{j=1}^{N_t^{(i)\bot }}C_j^{\bot (i)}\mathbb{I}_{\{U_j \leq d^{(i)}(t_j-t)\}}, \end{align*} where ${\bf C}^{||} =(C_j^{||(1)}, \dots,C_j^{||(n)})^{\top} \sim \text{Log}(p_1,\dots,p_n)$, where $p_i=\alpha_i/(1+\alpha)$, $C_j^{\bot (i)} \sim \text{Log}(p_i)$. Note that ${\bf C}^{||}$ and $C_j^{\bot (1)}, \dots, C_j^{\bot (n)}$ are independent for all $j$ and the intensities of the independent Poisson processes $N^{||}, N^{(1)\bot },\dots,N^{(n)\bot }$ are given by $\kappa \log(1+\alpha)$ and $\kappa_1 \log(1+\alpha_1), \dots, \kappa_n \log(1+\alpha_n)$, respectively. Then we can use the algorithm above to simulate each component separately. \end{example} \begin{remark} Since the above scheme ignores the initial value $X_{0,t}$, it is advisable to work with a burn-in period in a practical implementation. In the situation when the support of the trawl function $d$ is bounded, then an exact simulation of the trawl process is possible since its initial value can be generated precisely. \end{remark} \subsection{Inference}\label{InfSection} We propose to estimate the model parameters using a two stage equation-by-equation procedure, where the marginal parameters for each component are estimated first, and the parameter determining the dependence are estimated in a second step. Recent research on inference in multivariate models, see e.g.~\cite{Joe2005} and, more recently, \cite{FrancqZakoian2016}, has highlighted that such a procedure is very powerful in a high-dimensional set-up. Motivated by the results in \cite{BNLSV2014}, we propose to work with the (generalised) method of moments to infer the model parameters since the cumulants are readily available and the procedure works well in our simulation study. Full maximumlikelihood estimation is numerically rather intractable, whereas composite likelihood methods based on pairwise observations also seem to work well in the univariate case, as ongoing work not reported here, reveals. In the following, we shall assume that we have decided on a parametric model for the multivariate trawl process with trawl functions $d^{(i)}$. {\bf Step 1:} We can use the time series for each component to estimate the marginal parameters. We will estimate the parameter of $d^{(i)}$ in Step a) and the ones of $L'^{(i)}$ in Step b). {\bf a)} Recall that for each component we have the following representation for the autocorrelation function: \begin{align*} r_{ii}(h)=\Cor\left(L^{(i)}(A_t^{(i)}), L^{(i)}(A_{t+h}^{(i)})\right) = \frac{\leb(A^{(i)}\cap A^{(i)}_h)}{\leb(A^{(i)})}=\frac{R_{ii}(h)}{\leb(A^{(i)})}, \quad \text{for }i = 1,\dots,n. \end{align*} I.e.~the autocorrelation function only depends on the parameters of the trawl function $d^{(i)}$. These parameters can hence be estimated by using the method of moments or generalised method of moments (depending on the model specification) by matching the empirical and the theoretical autocorrelation function. This will, in particular, provide us with an estimate of $\leb(A^{(i)})$. {\bf b)} In a second step, we can then estimate the parameters determining the marginal distribution of $L^{'(i)}$, again using a method of moments, by using a sufficient number of cumulants of the observed trawl process. Note that the cumulant function for an individual component has the form \begin{align}\label{CumTrawl} C(\xi \ddagger Y_t^{(i)}) = \leb(A^{(i)}) C(\xi \ddagger L^{'(i)}), \quad \text{ for } i =1, \dots, n,. \end{align} I.e.~the cumulants of the trawl process can be easily derived. We denote by $\kappa_k$ the $k$th cumulant for $k \in \mathbb{N}$. Then we have that \begin{align*} \kappa_k(Y_t^{(i)}) = \leb(A^{(i)})\ \kappa_k(L^{'(i)}), \quad \text{ for } i =1, \dots, n. \end{align*} I.e.~as long as the parameters are identified through the cumulants, we can estimated them after having estimated the trawl parameters by setting \begin{align*} \widehat{\kappa_k}(L^{'(i)}) = \frac{\kappa_k^e(Y_t^{(i)})}{\widehat{\leb(A^{(i)})}} , \quad \text{ for } i =1, \dots, n, \end{align*} where $\kappa_k^e$ stands for the corresponding empirical $k$th cumulant. We then just need to solve the equations for the corresponding parameters. If a direct matching does not work, then one can use the generalised method of moments. {\bf Step 2:} After the marginal parameters have been identified, we turn to estimating the parameters describing the dependence. We note that as soon as the trawl parameters have been estimated, the corresponding autocorrelators can be computed. I.e.~we then obtain estimates $\widehat{R}_{ij}(h)=\leb(A^{(i)}\cap A^{(j)}_h)$. Then we get that \begin{align*} \kappa_{i,j} = \frac{\rho_{ij}^e(h)}{\widehat{R}_{ij}(h)}, \quad \text{ for } i\not = j, i,j \in \{1, \dots, n\}, \end{align*} where $\rho_{ij}^e(h)$ denote the empirical autocovariance function between the $i$th and $j$th component evaluated at lag $h$. In fact, it will be sufficient to set $h=0$ when we estimate the parameters $\kappa_{i,j}$. Note here that while we can clearly estimate the pairwise covariance parameter $\kappa_{i,j}$ using this method, depending on the parametric model chosen, there might be more than one parameter describing the dependence structure. As such, not all parameters might be identified through this procedure in which case additional moment conditions need to be considered. However, since this scenario did not arise in the model specifications we studied in relation to our empirical work, we shall refer this aspect to future research. Let us briefly comment on the validity of this estimation method: According to \cite{FuchsStelzer2013} multivariate mixed moving-average processes are mixing as long as they exist. This result implies that our stationary multivariate trawl processes are mixing and hence also weakly mixing and ergodic. Hence we can deduce that moment-based estimation methods are consistent, see e.g. \cite{Matyas1999}. In order to construct confidence bounds for the various parameters, we proceed by implementing a parametric bootstrap procedure, where we plug in the estimated parameters into the model specification, simulate from the model as described in the previous section, and then report the corresponding 95\% confidence bounds. \subsubsection{Simulation study}\label{SimStudy} In order to check how well the inference procedure works in finite samples, we conduct a Monte Carlo study, where we choose the model setting which describes our empirical data well, see Section \ref{Section:Empirics}. To this end, we simulate samples consisting of 3960 observations each from the bivariate version of the negative binomial model with common factor as described in Example \ref{ex_dep}. The distribution of the corresponding \Levy seed is determined by three parameters: $\alpha_1, \alpha_2$ and $\kappa$. In addition, we choose an exponential trawl function for both components, which are parametrised by $\lambda_1$ and $\lambda_2$, respectively. The parameters are set to their empirical counterparts, see Table \ref{table_par} below. Some of the technical details regarding the simulation study can be found in Section \ref{sim} in the Appendix. We draw 5000 samples from the model using the simulation algorithm described above and estimate the parameters for each sample using the method of moments. In Figure \ref{boxplots}, we present the boxplots for the estimates for each of the five parameters. The true values are highlighted by a vertical red line. We observe that all five estimates center around the true values. \begin{figure}[htbp] \includegraphics[width=0.55\textwidth, height=0.7\textheight,angle=270]{boxplots.eps} \caption{Boxplots of the five parameter estimates from a bivariate trawl model with exponential trawl function and negative binomial \Levy seed, see Example \ref{ex_dep}. The results are based on 5000 Monte Carlo runs, where each sample contains 3960 observations. The true values are indicated by a red vertical line. \label{boxplots}} \end{figure} \section{Empirical illustration}\label{Section:Empirics} In this section, we apply our new modelling framework to high frequency financial data. More precisely, we study limit order book data from the database LOBSTER\footnote{LOBSTER: Limit Order Book System - The Efficient Reconstructor at Humboldt Universit\"{a}t zu Berlin, Germany. http://LOBSTER.wiwi.hu-berlin.de}. We have downloaded the limit order book data for Bank of America (ticker: BAC) for one day (21st April 2016). We are interested in investigating the joint behaviour between the time series of the number of newly submitted limit orders versus the number of fully deleted limit orders. Note that the trading day starts at 9:30am and ends at 16:00. For our analysis, we discard the first and last 30 minutes of the data which typically have a peculiar (non-stationary) structure due to the effects caused by the beginning and the end of trading. As such we analyse data for a time period of 5.5 hours. We split this time period into intervals of length five seconds, resulting in 3960 intervals. In each interval we count the number of newly submitted limit orders and the ones which have been fully deleted. \begin{table}[htbp] \center \begin{tabular}{ccccccc} \hline & Min & 1st Quartile & Median & Mean & 3rd Quartile & Max \\ \hline No.~of new submissions & 0& 7 & 13 & 34.06 & 28 & 646 \\ No.~of full deletions & 0& 5.75 & 12 & 29.13 & 27.25 & 571 \\ \hline \end{tabular} \caption{Summary statistics of the BAC data from 21st April 2016 based on intervals of length five seconds. Also, we find that the correlation between the two time series is equal to 0.984. \label{table_subsum}} \end{table} The summary statistics of these two count series are provided in Table \ref{table_subsum}. Moreover, Figure \ref{TSPlot} depicts the corresponding time series plot, which also includes a picture of the difference of the two time series (in the middle), and Figure \ref{Empirical_Histogram} presents histograms of the joint and the marginal distribution of the data. \begin{figure}[htbp] \includegraphics[width=0.55\textwidth, height=0.7\textheight,angle=270]{numberexecutions.eps} \caption{Time series plots of the BAC data from 21st April 2016 based on intervals of length five seconds. Black (top): number of submitted orders; light grey (middle): number of submitted - fully deleted orders; dark grey (bottom): - number of fully deleted orders. \label{TSPlot}} \end{figure} We observe that there is a very strong correlation and co-movement between the two time series, which confirms the well-known fact that, for highly traded stocks such as BAC, the majority of newly submitted limit orders gets deleted rather than executed. \begin{figure}[htbp] \centering \includegraphics[scale=0.4,angle=270]{hist.eps} \caption{Histograms depicting the joint distribution and the marginal distributions of the new submissions (top) and the full cancellations (right). \label{Empirical_Histogram}} \end{figure} \begin{figure}[htbp] \subfigure[ACF of new submissions]{ \includegraphics[scale=0.25,angle=270]{fittedacf1.eps} } \subfigure[ACF of full cancellations.]{ \includegraphics[scale=0.25,angle=270]{fittedacf2.eps} }\caption{Empirical autocorrelation function (ACF) of the number of newly submitted and fully deleted limit orders, respectively. The solid black line shows the estimated exponential trawl function in both cases. \label{Fig-ACF}} \end{figure} Since the empirical autocorrelation function decays rather quickly for both time series, see Figure \ref{Fig-ACF}, we fit an exponential trawl function in both cases and get a good fit. Based on the estimated trawl parameters, we compute $\leb(A^{(1)})$, $\leb(A^{(2)})$, and $\leb(A^{(1)}\cap A^{(2)})$. Next, we estimate the parameters $\alpha_1, \alpha_2$ from the marginal law and finally infer $\kappa$ from the empirical cross-covariance. All parameter estimates are summarised in Table \ref{table_par}. In addition, we provide the corresponding 95\% confidence intervals, which are based on a parametric bootstrap, where we simulated 5000 samples from the estimated model using the estimated parameters as the plug-in values. \begin{table}[h] \center \begin{tabular}{c|cc|ccccc} \hline & $\lambda_1$ & $\lambda_2$ & $\alpha_1$ & $\alpha_2$ & $\kappa$ \\ \hline Estimates & 2.157 & 1.919 &95.161& 73.055 & 0.812\\ CB & {\footnotesize(1.771, 2.673)} & {\footnotesize(1.597, 2.322)} & {\footnotesize(85.321, 106.147)} & {\footnotesize(65.797, 81.222) } & {\footnotesize(0.741, 0.885)} \\ \hline \end{tabular} \caption{Estimated parameters and estimates of the 95\% confidence bounds (CB) from the moment-based estimates. The CB estimates have been computed using a model-based bootstrap, where 5,000 bootstrapped samples were drawn. \label{table_par}} \end{table} \begin{figure}[htbp] \includegraphics[scale=0.5,angle=270]{qq.eps} \caption{Empirical and fitted densities and quantile-quantile plots of the negative binomial marginal law for the new submissions (top) and the full cancellations (bottom). \label{GoodnessOfFit}} \end{figure} \begin{figure}[htbp] \centering \includegraphics[scale=0.4,angle=270]{histsim.eps} \caption{Histograms depicting the joint distribution and the marginal distributions of one path of the simulated bivariate time series in our bootstrap procedure. \label{Sim_Histogram}} \end{figure} \begin{figure}[htbp] \includegraphics[width=0.55\textwidth, height=0.7\textheight,angle=270]{numberexecutionsSim.eps} \caption{Time series plots of one simulated sample path. Black (top): first component; light grey (middle): number of first - second component; dark grey (bottom): - second component. This is the same path as the one used to generate Figure \ref{Sim_Histogram}.\label{TSPlotSim}} \end{figure} In addition to checking the goodness-of-fit of the trawl function, see Figure \ref{Fig-ACF}, we also need to assess whether the parametric model for the bivariate \Levy seed is appropriate. To this end, we first check the marginal fit, which corresponds to a univariate negative binomial law for each component. Figure \ref{GoodnessOfFit} shows the empirical and the estimated probability densities and the corresponding quantile-quantile plots. While the fit seems to be acceptable overall, we note that the fit appears to be better for the time series of the cancelled orders, where the quantile-quantile-plot is closer to a straight line, than in the case of the newly submitted orders, where we observe a mildly wiggly line. Finally, we investigate the goodness-of-fit of the joint law. For this, we draw the bivariate law from one of our bootstrap samples and the corresponding univariate laws, see Figure \ref{Sim_Histogram}. We observe that the histogram of the simulated joint law resembles the one from the empirical data well, cf.~Figure \ref{Empirical_Histogram}. Also a visual inspection of the simulated sample paths, see Figure \ref{TSPlotSim} for one example, shows that the empirical data and the simulated data have indeed very similar features, which supports our hypothesis that a bivariate trawl process can describe the number of order submissions and cancellations in a limit order book well. \section{Conclusion}\label{Section:conclusion} We propose a new modelling framework for multivariate time series of counts, which is based on so-called multivariate integer-valued trawl (MVIT) processes. Such processes are highly analytically tractable and enjoy useful properties, such as stationarity, infinitely divisibility, ergodicity and a mixing property. A variety of serial dependence patterns, including short and long memory, as well as all discrete infinitely divisible marginal distributions can be achieved within this novel framework. In this article, we focused in particular on various specifications of a multivariate infinitely divisible negative binomial distribution, since its univariate counterpart has been widely used in empirical work. Moreover, since the MVIT process is defined in continuous time, it can be applied to non-equidistant and asynchronous data, which increases its broad applicability. Further contributions of this article include a simulation algorithm for MVIT processes and a suitable inference procedure which is based on the two-stage equation-by-equation approach, where the parameters describing the univariate marginal distributions are estimated in the first step, followed by the estimation of the dependence parameters in the second step. A simulation study confirms the effectiveness of this inference method in finite samples. The estimation itself is based on the generalised method of moments and suitable confidence bounds are obtained through a parametric bootstrap procedure. In an empirical illustration, a bivariate version of an MVIT process has been used to successfully describe the relationship between the number of order submissions and cancellations in a limit order book. \begin{appendix} \section{Proofs}\label{proofs} \begin{proof}[Proof of Proposition \ref{CharFctTrawl}] Using the properties of the \Levy basis, we immediately obtain that \begin{align*} &\mathbb{E}(\exp(i{\boldsymbol \theta}^{\top}{\bf Y}_t)) = \exp\left(\int_{\R^n\times [0,1]\times \R} \left\{\exp\left(i\sum_{j=1}^n\theta_j\mathbf{I}_{A^{(j)}}(x,s-t)y_j\right)-1\right\} \nu(d{\bf y}) dx ds\right). \end{align*} The expression for the characteristic function can be further simplified by using a partition $S =\{ S_1, \dots, S_{2^n-1}\}$ of $A^{\cup,n }:=\cup_{i=1}^n A^{(i)}$, see \cite{NVG2015}. More precisely, we have that \begin{align}\label{SP} A^{\cup,n} = \bigcup_{k=1}^{n}\bigcup_{\substack{1\leq i_1, \dots, i_k \leq n: \\ i_{\nu}\not = i_{\mu}, \text{ for } \nu \not = \mu}} \left(\bigcap_{l=1}^kA^{(i_l)}\setminus \bigcup_{\substack{1\leq j\leq n,\\ j\not \in\{i_1, \dots, i_k\}}} A^{(j)}\right). \end{align} Note that \begin{align}\label{thetaY} {\boldsymbol \theta}^{\top}{\bf Y}_t = \sum_{j=1}^n \theta_j L^{(j)}(A^{(j)}_t) = \sum_{j=1}^n \theta_j \sum_{k: S_k\subset A^{(j)}} L^{(j)}(S_k) = \sum_{k=1}^{2^n-1} \sum_{\substack{1\leq j\leq n:\\ A^{(j)}\supset S_k}} \theta_j L^{(j)}(S_k). \end{align} Finally, combining \eqref{thetaY} with the representation \eqref{SP} and using the fact that a \Levy basis is independently scattered, we obtain the result. \end{proof} \begin{proof}[Proof of Proposition \ref{JointLaw}] The joint law is given by \begin{align*} &P(X_1=x_1, \dots, X_n=x_n) \\ &= \int_{(0,\infty)^{n+1}}P(X_1=x_1, \dots, X_n=x_n|U=u, V_1=v_1, \dots, V_n=v_n)\\ & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \cdot f_U(u)f_{V_1}(v_1)\cdots f_{V_n}(v_n)du dv_1 \cdots dv_n\\ &= \int_{(0,\infty)^{n+1}} \prod_{i=1}^n e^{-\alpha_i u + v_i}\frac{(\alpha_i u + v_i)^{x_i}}{x_i!} f_U(u)f_{V_i}(v_i)du dv_i\\ &= \int_{(0,\infty)^{n+1}} f_U(u)\prod_{i=1}^n e^{-\alpha_i u + v_i}\frac{1}{x_i!} \sum_{j_i=0}^{x_i}{x_i \choose j_i}\alpha_i^{j_i}u^{j_i}v_i^{x_i-j_i} f_{V_i}(v_i)du dv_i\\ &= \frac{1}{x_1!\cdots x_n!} \sum_{j_1=0}^{x_1}\cdots \sum_{j_n=0}^{x_n} {x_1 \choose j_1}\cdots{x_n \choose j_n}\alpha_1^{j_1}\cdots \alpha_j^{j_n} \E(U^{j_1+\cdots+j_n}e^{-(\alpha_1 + \cdots + \alpha_n)U}) \\ & \qquad \qquad \qquad \qquad\qquad \qquad \qquad \qquad\cdot \prod_{k=1}^n \E(V_k^{ x_k-j_k}e^{-V_k}). \end{align*} \end{proof} \begin{proof}[Proof of Proposition \ref{CPRep}] Let $M_U$ and $M_{V_i}$ denote the moment generating functions of $U$ and $V_i$, respectively. According to \citet[equation (5.1)]{BNBlaesildSeshadri1992}, the probability generating function of $(X_1, \dots, X_n)$ is given by \begin{align*} G(t_1, \dots, t_n) &= E(t_1^{X_1} \cdots t_n^{X_n})= M_U\left(\sum_{i=1}^n \alpha_i(t_i-1)\right)\prod_{i=1}^n M_{V_i}(t_i-1). \end{align*} Hence, the corresponding Laplace transform for positive $\boldsymbol \theta$ is given by \begin{align}\label{LaplaceCPP2} \mathcal{L}(\theta_1,\dots,\theta_n)&= G(e^{-\theta_1}, \dots,e^{-\theta_n}) = M_U\left(\sum_{i=1}^n \alpha_i(e^{-\theta_i}-1)\right)\prod_{i=1}^n M_{V_i}(e^{-\theta_i}-1). \end{align} The aim is to find $v$ and $\mathcal{L}_{{\bf C}}({\boldsymbol \theta})$ by equating \eqref{LaplaceCPP1} and \eqref{LaplaceCPP2}. Using the relation between the Laplace and the moment generating function, we deduce that \begin{align*} \mathcal{L}(\theta_1,\dots,\theta_n)&= M_U\left(\sum_{i=1}^n \alpha_i(e^{-\theta_i}-1)\right)\prod_{i=1}^n M_{V_i}(e^{-\theta_i}-1)\\ &= \mathcal{L}_U\left(\sum_{i=1}^n \alpha_i(1-e^{-\theta_i})\right)\prod_{i=1}^n \mathcal{L}_{V_i}(1-e^{-\theta_i})\\ &= \exp\left(\log\mathcal{L}_U\left(\sum_{i=1}^n \alpha_i(1-e^{-\theta_i})\right)+\sum_{i=1}^n \log\mathcal{L}_{V_i}(1-e^{-\theta_i})\right). \end{align*} We use the notation $\overline K = \log \mathcal{L}$ for the so-called \emph{kumulant function}. Since $U$ is a subordinator without drift, we have that \begin{align*} &\overline K_U\left(\sum_{i=1}^n \alpha_i(1-e^{-\theta_i})\right) = \int_{\R}\left(e^{-\sum_{i=1}^n \alpha_i(1-e^{-\theta_i})x}-1 \right)\nu_U(dx)\\ &=\int_{\R}\left(e^{-\sum_{i=1}^n \alpha_i x} -e^{-\sum_{i=1}^n \alpha_i x} + e^{\sum_{i=1}^n \alpha_i(1-e^{-\theta_i})x}-1 \right)\nu_U(dx) \\ &=\int_{\R}\left(e^{-\sum_{i=1}^n \alpha_i x} -1 \right)\nu_U(dx) +\int_{\R}e^{-\sum_{i=1}^n \alpha_i x} \left(e^{\sum_{i=1}^n \alpha_ie^{-\theta_i}x}-1 \right)\nu_U(dx). \end{align*} Note that \begin{align*} e^{\sum_{i=1}^n \alpha_ie^{-\theta_i}x}-1 &= \sum_{k=1}^{\infty}\frac{1}{k}\left(\sum_{i=1}^n \alpha_ie^{-\theta_i}x\right)^k =\sum_{k=1}^{\infty}\frac{1}{k!}\left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k x^k. \end{align*} We set $\alpha := \sum_{i=1}^n \alpha_i$. Then \begin{align*} \int_{\R}e^{-\sum_{i=1}^n \alpha_i x} \left(e^{\sum_{i=1}^n \alpha_ie^{-\theta_i}x}-1 \right)\nu_U(dx) &= \int_{\R}e^{-\alpha x} \sum_{k=1}^{\infty}\frac{1}{k!}\left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k x^k\nu_U(dx)\\ &= \sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k \underbrace{ \frac{1}{k!} \int_{\R}e^{-\alpha x} x^k\nu_U(dx)}_{:=q_k^{(U)}}. \end{align*} I.e. \begin{align*} \overline K_U\left(\sum_{i=1}^n \alpha_i(1-e^{-\theta_i})\right) &=\int_{\R}\left(e^{-\alpha x} -1 \right)\nu_U(dx) + \sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k q_k^{(U)}\\ &= \overline K_U(\alpha) + \sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k q_k^{(U)}. \end{align*} Similarly, \begin{align*} \sum_{i=1}^n K_{V_i}(1-e^{-\theta_i})&=\sum_{i=1}^n \left(\overline K_{V_i}(1) + \sum_{k=1}^{\infty} e^{-\theta_i k} q_k^{(V_i)}\right), \text{ where } q_k^{(V_i)} = \int_{\R} \frac{x^k}{k!}e^{-x}\nu_{V_i}(dx). \end{align*} So, overall we have \begin{align*} \overline K_{\bf X}({\boldsymbol \theta}) &=\log \mathcal{L}(\theta_1, \dots, \theta_n) \\ &= \left( \overline K_U(\alpha) + \sum_{i=1}^n \overline K_{V_i}(1)\right) + \sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k q_k^{(U)} +\sum_{i=1}^n\sum_{k=1}^{\infty} e^{-\theta_i k} q_k^{(V_i)}\\ &= -v + v \mathcal{L}_{{\bf C}}({\boldsymbol \theta}), \end{align*} if and only if \begin{align*} v &= -\left( \overline K_U(\alpha) + \sum_{i=1}^n \overline K_{V_i}(1)\right) ,\\ \mathcal{L}_{{\bf C}}({\boldsymbol \theta}) &= \frac{1}{v}\left\{\sum_{k=1}^{\infty} \left(\sum_{i=1}^n \alpha_ie^{-\theta_i}\right)^k q_k^{(U)} +\sum_{i=1}^n\sum_{k=1}^{\infty} e^{-\theta_i k} q_k^{(V_i)} \right\}. \end{align*} \end{proof} \begin{proof}[Proof of Proposition \ref{Prop_ConvofIniValue}] The requirement that $\leb(A^{(i)})<\infty$ implies that $\leb(\{(x, s): s \leq 0, 0 \leq x \leq d(s-t)\})\to 0$ as $t\to \infty$. Since a \Levy basis is countably additive (in the sense that for any sequence $A_n\downarrow \emptyset$ of Borel sets with bounded Lebesgue measure, $L^{(i)}(A_n)\to 0$ in probability as $n\to \infty$, see \cite{BNBV2011}), we can deduce that $X_{0,t}^{(i)} \to 0$ in probability as $t\to \infty$. \end{proof} \section{Details regarding the simulation study}\label{sim} In Section \ref{SimStudy}, we simulate from a bivariate negative binomial trawl process, where both components have an exponential trawl function and their joint law is given by the bivariate negative binomial distribution as described in Example \ref{ex_dep}. In the simulation of the trawl process, we work with the compound-Poisson-type representation \eqref{CPP} and specify the jump size distribution as the bivariate logarithmic series distribution (BLSD) as in Example \ref{Ex}. \subsection{Simulating from the bivariate logarithmic series distribution } First of all, we describe how we can generate random samples ${\bf C}=(C_1,C_2)^{\top}$ from the BLSD with parameters $p_1,p_2$. The algorithm is based on the idea that we can simulate $C_1$ from the modified logarithmic series distribution (ModLSD) (with parameters $\tilde p_1=p_1/(1-p_2)$ and $\delta_1=\log(1-p_2)/\log(1-p_1-p_2)$) in a first step, and then $C_2$ can be simulated from the conditional distribution, given $C_1$, see e.g.~\cite{KempLoukas1978}. We note here, that if $C_1\equiv 0$, then $C_2|C_1$ follows the logarithmic distribution (with parameter $p_2$), and when $C_1>0$, then $C_2|C_1$ follows the negative binomial distribution with parameters $C_1$ and $p_2$, see e.g.~\cite{KK1990}. We describe the simulation algorithm for the BLSD using pseudo code tailored to the ${\tt R}$ language. Throughout the section we use the abbreviation rv for random variable. \begin{algorithm} [Simulation from the bivariate logarithmic series distribution]\label{BLSD_SimAlgo} \begin{algorithmic}[1] \Statex \State {\tt library(VGAM)} \Comment{Load the VGAM package in R.} \Statex \Function{Sim-BLSD}{$N,p_1,p_2$} \State $\tilde p_1 \gets p_1/(1-p_2)$ \Comment{Calculate the parameters of the modified LSD.} \State $\delta_1 \gets \log(1-p_2)/\log(1-p_1-p_2)$ \State $L \gets {\tt rlog}(N,p_1)$ \Comment{Simulate $N$ i.i.d.~Log($p_1$) rvs.} \State $B \gets {\tt rbinom}(N,1,1-\delta_1)$ \Comment{Simulate $N$ i.i.d.~Bernoulli($1-\delta_1$) rvs.} \State $C_1 \gets L * B$ \Comment{Generate $N$ i.i.d.~ModLog($\tilde p_1, \delta_1$) rvs.} \State $C_2 \gets {\tt numeric}(N)$ \For{$i$ in $1:N$} $c_1 \gets C_1[i]$ \If{$c_1==0$} \State $C_2[i] \gets {\tt rlog}(1,p_2)$ \Comment{Simulate a Log($p_2$) rv.}\EndIf \If{$c_1>0$} \State $C_2[i] \gets {\tt rnbinom}(1,size=c_1,prob=1-p_2)$ \Comment{Simulate a NB($c_1,p_2$) rv.} \EndIf \EndFor \State $C \gets {\tt cbind}(C_1,C_2)$ \Comment{Combine the component vectors to an $N\times 2$ matrix.} \State \textbf{return} $C$ \EndFunction \end{algorithmic} \end{algorithm} \subsection{Simulating the bivariate trawl process}\label{SimTrawlAppendix} Next, we provide the pseudo code tailored to the ${\tt R}$ language which has been used to simulate the bivariate trawl process with exponential trawl function and bivariate negative binomial law (as in Example \ref{ex_dep}). Here we are using the same notation as in the general description of Algorithm \ref{GenSimAlgo}. In addition, we denote by $bi$ the length of the burn-in period. I.e.~we will simulate the process over the time interval $[0,t]$ for $t=T+bi$ and then remove the initial burnin period, i.e.~we return the paths over the interval $(bi,bi+T]$. \begin{algorithm} [Simulation from the bivariate trawl process]\label{Trawl_SimAlgo} \begin{algorithmic}[1] \Statex \State {\tt library(VGAM)} \Comment{Load the VGAM {\tt R} package and the function {\tt Sim-BLSD} defined above.} \Function{Expfct}{($x,\lambda$)} \Comment{Choose an exponential trawl function.} \State \textbf{return} $\exp(\lambda * x)$ \EndFunction \Statex \Procedure{Sim-Trawl}{$\Delta,T,bi,\lambda_1, \lambda_2, \alpha_1, \alpha_2, \kappa$} \State $v \gets \kappa *\log(1+\alpha_1+\alpha_2)$ \Comment{Intensity of the driving Poisson process.} \State $p_1 \gets \alpha_1/(\alpha_1+\alpha_2+1); p_2 \gets \alpha_2/(\alpha_1+\alpha_2+1)$ \Comment{Parameters in the BLSD} \State $N_t \gets {\tt rpois}(1,v*t)$ \Comment{Draw the number of jumps in $[0,t]$ from Pois($vt$).} \State $\tau \gets {\tt sort}({\tt runif}(N_t, \min=0, \max=t))$ \Comment{ simulate the $N_t$ jump times from the ordered uniform distribution on $[0,t]$.} \State $h \gets {\tt runif}(N_t, \min=0,\max=1)$ \Comment{Simulate the $N_t$ jump heights of the abstract spatial parameter of the Poisson basis from the uniform distribution on $[0,1]$.} \State $m \gets {\tt Sim-BLSD}(N_t,p_1,p_2)$ \Comment{Draw the jump marks from the BLSD} \State $C_1 \gets m[,1]; C_2 \gets m[,2]$ \Comment{Assign the jump marks to $C_1$ and $C_2$.} \Statex \State \Comment{Determine the number of jumps up to each grid point $k \Delta$ and store them in the vector $V$.} \State $V \gets {\tt vector(mode = "numeric", length = floor}(t/\Delta))$ \State $c \gets{\tt table(cut(jumptimes,seq}(0,t,1),{\tt include.lowest = TRUE))}$ \State $ V[1]<- {\tt as.integer}(c[1])$ \For{$k$ in $2:{\tt floor}(t/\Delta)$} \State $V[k] \gets V[k-1]+{\tt as.integer}(c[k])$ \EndFor \Statex \For{$i$ in $1:2$} \Comment{Simulate the $i$th trawl process} \State $TP_i \gets {\tt vector(mode = "numeric", length = floor}(t/\Delta))$ \For{$k$ in $1:{\tt floor}(t/\Delta)$} \State $N_{k\Delta} \gets V[k]$ \Comment{Number of jumps until time $k\Delta$.} \If{$N_{k\Delta}>0$} \State $d \gets k*\Delta - \tau[1:N_{k\Delta}]$ \Comment{Compute the time differences between $k\Delta$ and each jump time up to $k\Delta$.} \State $cond_i \gets 1-{\tt ceiling}(h[1:N_{k\Delta}]-{\tt Expfct}(-d,\lambda_i))$ \Comment{Check which points are in the trawl.} \State $TP_i[k] \gets {\tt sum}(cond_i*C_i[1:N_{k\Delta}])$ \Comment{Sum up the marks in the trawl.} \EndIf \EndFor \EndFor \Statex \State $b_1 \gets bi/\Delta, b_2 = bi/\Delta+T/\Delta$ \For{$i$ in $1:2$} \State $TrawlProcess_i \gets TP_i[(b_1+1):b_2]$ \Comment{Cut off burn-in period.} \EndFor \EndProcedure \end{algorithmic} \end{algorithm} \end{appendix} \section*{Acknowledgement} A.~E.~D.~Veraart acknowledges financial support by a Marie Curie FP7 Career Integration Grant within the 7th European Union Framework Programme. \bibliographystyle{agsm}
{'timestamp': '2016-08-11T02:06:57', 'yymm': '1608', 'arxiv_id': '1608.03154', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03154'}
arxiv
\section{Introduction and Motivation} \label{sec:intro} The emergence of a wide range of parallel processor architectures continues to present the challenge of identifying an effective programming model that provides access to the capabilities of the architecture while simultaneously providing the programmer with familiar, if not standardized, semantics and syntax. The programmer is often left with the choice of using a non-standard programming model specific to the architecture or a standardized programming model that yields poor control and performance. The parallel RISC processor investigated in this work has presented precisely this challenge as suitable programming models matched to the architecture have been explored. The Adapteva Epiphany RISC array architecture \cite{adapteva} is a scalable 2D array of low-power RISC cores with minimal uncore functionality supported by an on-chip 2D mesh Network-on-Chip (NoC) for fast inter-core communication. The Epiphany architecture is scalable to 4,096 cores and represents an example of an architecture designed for power-efficiency at extreme on-chip core counts. Processors based on this architecture exhibit good performance/power metrics \cite{kickstarting} and scalability via the 2D mesh network \cite{wentzlaff} \cite{taylor}, but require a suitable programming model to fully exploit these capabilities. A 16-core Epiphany-III coprocessor~\cite{datasheet} has been integrated into the Parallella mini-computer platform \cite{reference} where the RISC array is supported by a dual-core ARM CPU and asymmetric shared-memory access to off-chip global memory. RISC array processors such as those based on the Epiphany architecture may offer significant computational power efficiency in the near future with requirements in increased floating point performance, including long-term plans for exascale platforms. The power efficiency of the Epiphany architecture has been specifically identified as both a guide and prospective architecture for such platforms \cite{varghese}. The Epiphany-IV processor has a performance efficiency of 50 GFLOPS/W (single precision) \cite{kickstarting} making it one of the most efficient fully divergent parallel processors based on general-purpose cores. This approaches the threshold for exascale computing requirements of a power budget of 20 megawatts \cite{bergman}. This architecture has characteristics consistent with future processor predictions arguing hundreds \cite{fewcores} and thousands \cite{asanovic}, \cite{borkar} of cores on a chip. One aspect of the low-power design of the Epiphany architecture is the use of a cache-less distributed on-chip memory architecture that for the Epiphany-III provides 32 KB of local memory per core for both instructions and data. Utilizing this core local memory and managing inter-core communication is critical to achieving good performance and this is a central element in the design of the architecture. In previous work, these technical challenges were the primary factors in achieving good performance with threaded MPI and less favorable results using \mbox{OpenCL}. Here we revisit \mbox{OpenCL} with a hybrid model that uses \mbox{OpenSHMEM} to resolve the deficiencies of \mbox{OpenCL} in the context of this architecture. Our main contributions are the presentation of a hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} programming model with benchmarks for the application to matrix-matrix multiplication. An outline of the remainder of the paper is as follows. Section \ref{sec:background} describes the Epiphany architecture and previous work using \mbox{OpenCL} and \mbox{OpenSHMEM} as parallel programming models. Section \ref{sec:hybrid} presents the proposed hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} programming model for device-level programming. Section \ref{sec:application} discusses the application of the proposed programming model to Cannon's algorithm for matrix-matrix multiplication, including benchmark results. Section \ref{sec:conclusions} discusses conclusions and future work. \section{Background} \label{sec:background} Interest in exploring hybrid \mbox{OpenSHMEM} + X programming models has been expressed recently within the \mbox{OpenSHMEM} community \cite{Baker}. Just as the two-tier parallel hybrid OpenMP + MPI model handles both symmetric multiprocessing (SMP) execution within a node and distributed message passing for attached network nodes, it is assumed that similar hybrid models may benefit from mixing code with \mbox{OpenSHMEM}. In the specific case detailed within this paper, the hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} model exists at the same parallelism tier and the combination of the programming models address the deficiencies of each within the context of the Parallella platform and Epiphany architecture. While \mbox{OpenCL} may do well addressing SMP architectures with hierarchical memory, it does not provide semantics for inter-processor communication between processing elements or multiprocessors. \mbox{OpenSHMEM} provides the semantics for non-uniform memory access (NUMA) across a partitioned global address space (PGAS) and may not be ideal for SMP architectures. The \mbox{OpenSHMEM} concept of memory exists virtually in a flat one-dimensional domain and lacks the semantics of the tiered memory hierarchy found in the SMP-based \mbox{OpenCL} programming model. Fundamentally, the Epiphany device-level architecture has characteristics of both SMP and PGAS platforms so it makes sense to address the architecture with a hybrid SMP and PGAS programming model. \subsection{Epiphany Architecture} \label{ssec:epiphany} The Adapteva Epiphany MIMD architecture is a scalable 2D array of RISC cores with minimal uncore functionality connected with a fast 2D mesh Network-on-Chip (NoC). Processors based on this architecture exhibit good energy efficiency and scalability via the 2D mesh network, but require a suitable programming model to fully exploit the architecture. The 16-core Epiphany-III coprocessor has been integrated into the Parallella minicomputer platform where the RISC array is supported by a dual-core ARM CPU and asymmetric shared-memory access to off-chip global memory. Figure \ref{fig:epiphany} shows the high-level architectural features of the coprocessor. Each of the 16~Epiphany-III mesh nodes contains 32~KB of shared local memory (used for both program instructions and data), a mesh network interface, a dual-channel DMA engine, and a RISC CPU core. Each RISC CPU core contains a 64-word register file, sequencer, interrupt handler, arithmetic logic unit, and a floating point unit. Each processor tile is very small at 0.5~mm\textsuperscript{2} on the 65~nm process and 0.128~mm\textsuperscript{2} on the 28~nm process. Peak single-precision performance for the Epiphany-III is 19.2~GFLOPS with a 600~MHz clock. Fabricated on the 65~nm process, the Epiphany-III consumes 594~mW for an energy efficiency of 32.3~GFLOPS per watt [Olofsson, personal communication]. The 64-core Epiphany IV, fabricated on the 28~nm process, has demonstrated energy efficiency exceeding 50~GFLOPS per watt \cite{kickstarting}. The raw performance of currently available Epiphany coprocessors is relatively low compared to modern high-performance CPUs and GPUs; however, the Epiphany architecture provides greater energy efficiency and is designed to be highly scalable. The published architecture road map specifies a scale-out of the architecture to exceed 1,000 cores in the near future and, shortly thereafter, tens of thousands of cores with an energy efficiency approaching one TFLOPS per watt. Within this context of a highly scalable architecture with high energy efficiency, we view it as a competitive processor technology comparable to GPUs and other coprocessors. While architecture energy efficiency is important, achievable performance with a compelling programming model is equally, if not more, important. Key to performance with the Epiphany architecture is data re-use, requiring precise control of inter-core communication since the architecture does not provide a hardware cache at any level. The cores can access off-chip mapped memory with a significant performance penalty in both latency and bandwidth relative to accessing on-chip core memory of any core. \begin{figure} \centering \includegraphics[width=1.0\textwidth]{EpiphanyIII.pdf} \caption{Adapteva Epiphany-III architecture diagram} \label{fig:epiphany} \end{figure} \subsection{\mbox{OpenCL} for Epiphany} \label{ssec:opencl} \mbox{OpenCL} is an industry standard API for parallel programming accelerators or coprocessors on heterogeneous platforms \cite{stone}. Designed primarily for computing with general-purpose graphics processing units (GPUs), the API may be used to access the compute capability of other types of devices including multi-core CPUs and other accelerators. \mbox{OpenCL} support is provided for most mainstream high-performance computing accelerators including Nvidia and AMD GPUs, Intel and AMD multi-core CPUs, Intel Xeon Phi, and mobile CPU+GPU hybrid processors. In this context, there is merit in exploring the use of \mbox{OpenCL} for exposing the compute capability of the Epiphany coprocessor on the Parallella. \mbox{OpenCL} consists of a kernel programming API used to program the coprocessor device and a run-time host API used to coordinate the execution of these kernels and perform other operations such as memory synchronization so that parallel computationally intensive work can be offloaded from the host platform. The \mbox{OpenCL} programming model is based on the parallel execution of a kernel over many threads to exploit SIMD or SIMT architectures. From the perspective of the host platform, parallel kernels are enqueued for execution on the coprocessor device. Each kernel is executed over a global n-dimensional range of work items logically partitioned into local workgroups. Threads of execution within a workgroup are allowed limited synchronization through the use of barriers, and no synchronization between workgroups is allowed. \mbox{OpenCL} was the first standard parallel programming API implemented for the Epiphany architecture, and partial support for the \mbox{OpenCL} 1.1 standard was available as part of the COPRTHR-1.5 SDK for Epiphany \cite{coprthr}. The selection of \mbox{OpenCL} was supported by several factors. The Epiphany-III coprocessor was available as part of a heterogeneous mini-computer (Parallella) that included a dual-core ARM CPU host running Linux. As a result, the \mbox{OpenCL} co-design programming model premised on the host-directed offload of parallel work to a coprocessor was well suited to the platform. The focus of the implementation of \mbox{OpenCL} for Epiphany was to leverage the API to support effective parallel programming and take advantage of the underlying architecture. As with other non-GPU architectures, limitations and constraints exist in the use of \mbox{OpenCL} for targeting the Epiphany architecture. \mbox{OpenCL} was designed for massively multithreaded architectures such as GPUs. However Epiphany has no hardware support for multithreading and early experiments with software supported multithreading were not successful due in part to resource constraints. As a result, implementation of the \mbox{OpenCL} device execution model for Epiphany must constrain the workgroup size to the number of physical cores on the device. The most significant technical issue encountered in the implementation of \mbox{OpenCL} for Epiphany was reconciling the physical memory architecture of the Epiphany coprocessor with the logical memory model defined by the \mbox{OpenCL} standard, shown in Figure \ref{fig:opencl}. \mbox{OpenCL} address space qualifiers co-mingle the concepts of physical locality and visibility. For the Epiphany architecture, the physical memory co-located with each core executing a thread in an \mbox{OpenCL} workgroup is best described as symmetric distributed shared memory. This memory is physically local to the executing thread while also having shared visibility with all other threads since remote cores have non-uniform memory access to the local memory of any core. Managing the use and re-use of this symmetric distributed memory is critical to performance with the Epiphany architecture. An implementation treating this memory as \mbox{OpenCL} local may prove functionally correct and consistent within the standard, but the programmer will be left with poor performance without an interface to treat the memory correctly. Therefore, an interface for the symmetric distributed shared memory is needed to properly manage on-chip data movement. \begin{figure} \centering \includegraphics[width=0.67\textwidth]{OpenCL.pdf} \caption{OpenCL memory model} \label{fig:opencl} \end{figure} For this reason extensions were initially provided within the \mbox{OpenCL} implementation for Epiphany. A set of inter-thread memory copy routines were provided to allow for the direct copying of data between the local memory of one core to another. These routines resolved the problem with \mbox{OpenCL} in a non-standard way that nevertheless enabled algorithms to be implemented with good performance. At the time of this development the \mbox{OpenSHMEM} standard was close to publication but not yet released. In hindsight, \mbox{OpenSHMEM} was precisely the interface that was needed to resolve this critical issue that arises from the use of \mbox{OpenCL} for Epiphany. \subsection{OpenSHMEM for Epiphany} \label{ssec:openshmem} An implementation of \mbox{OpenSHMEM} targeting the Epiphany architecture was recently developed \cite{ARLOpenSHMEM}. The interface provides access the complete \mbox{OpenSHMEM} 1.3 standard for Epiphany device-level execution. It fills the void left by the lack of a standard programming model able to achieve good performance with on-chip memory distributed through the NoC. Conceptually, the physical memory of the Epiphany architecture maps directly to the \mbox{OpenSHMEM} and PGAS memory model (shown in Figure \ref{fig:openshmem}). The \mbox{OpenSHMEM} interface for Epiphany does not address the concept of coprocessor offload or off-chip memory. For applications requiring these concepts, a hybrid programming model is required. \begin{figure} \centering \includegraphics[width=0.67\textwidth]{OpenSHMEM.pdf} \caption{OpenSHMEM memory model} \label{fig:openshmem} \end{figure} \section{Hybrid OpenCL + OpenSHMEM Programming Model} \label{sec:hybrid} Based on this prior work we propose a hybrid programming model that combines \mbox{OpenCL} with \mbox{OpenSHMEM} for device-level programming of parallel processors like those based on the Epiphany architecture. In the simplest terms, \mbox{OpenSHMEM} directly resolves the most critical technical issue encountered in the implementation of \mbox{OpenCL} for such architectures, and replaces the non-standard extensions that were originally introduced to support inter-core data re-use and achieve good performance when implementing algorithms for Epiphany. At the same time, \mbox{OpenCL} complements \mbox{OpenSHMEM} in that for hybrid platforms that employ a parallel coprocessor, \mbox{OpenCL} provides support for the \mbox{offload} of parallel work to the coprocessor while there is no equivalent operation defined within the \mbox{OpenSHMEM} standard. \mbox{OpenSHMEM} for Epiphany provides the inter-core communication between the \mbox{OpenCL} concept of a processing element or multiprocessor. In the case of the Epiphany architecture, they are one in the same. There is a single processing element per multiprocessor in order to address the hierarchical memory concept of local memory within the \mbox{OpenCL} specification. The \mbox{OpenCL} interface defines the global or constant memory (shown in Figure \ref{fig:hybrid}) The hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} programming model uses \mbox{OpenCL} for the development of host code that controls the overall application and directs the operations of the coprocessor through the offload of parallel computational kernels. The \mbox{OpenCL} kernel programming language, closely related to standard C, is used for the implementation of kernels. The distributed shared memory for which \mbox{OpenCL} provides no suitable API is then exposed using \mbox{OpenSHMEM} from within the \mbox{OpenCL} kernel. The \mbox{OpenSHMEM} programming model is nested within \mbox{OpenCL} and may be thought of as extending the latter. Developing applications with this hybrid programming model will follow closely the approach taken with \mbox{OpenCL}. \begin{figure} \centering \includegraphics[width=0.67\textwidth]{Hybrid.pdf} \caption{Hybrid OpenCL + OpenSHMEM memory model} \label{fig:hybrid} \end{figure} From an application development perspective, the \mbox{OpenCL} co-design model is still used with no change in the development of \mbox{OpenCL} host code. It is the \mbox{OpenCL} device programming API that is extended with \mbox{OpenSHMEM}. In this way each \mbox{OpenCL} kernel would contain within it a unique \mbox{OpenSHMEM} parallel job with a context inherited from the \mbox{OpenCL} kernel. All initialization and allocation requirements in support of the \mbox{OpenSHMEM} API are performed within the \mbox{OpenCL} kernel each time it is enqueued for execution. Whereas \mbox{OpenCL} kernels are permitted to communicate through global memory, no communication using the \mbox{OpenSHMEM} API is permitted between kernels or between \mbox{OpenCL} work groups. This follows from the \mbox{OpenCL} execution model that allows synchronization within a work group but disallows synchronization between work groups. The restriction upon synchronization between \mbox{OpenCL} work groups has limited significance since the nested parallelism of \mbox{OpenCL} mode in which work is distributed across multiple work groups containing multiple work items can be ignored if a single work group is used. This simplification is employed in the application of \mbox{OpenCL} to the Epiphany architecture. Since the \mbox{OpenSHMEM} API is contained within the \mbox{OpenCL} device kernel context, all \mbox{OpenSHMEM} memory allocation is only visible within a kernel and is not persistent across multiple kernel invocations. This aspect of the hybrid programming model could be revisited in the future but was unnecessary for the initial demonstrations reported here. It is worth addressing the issue of portability in the context of the proposed hybrid programming model. As with the case of the use of non-standard extensions originally employed to achieve good performance for \mbox{OpenCL} development targeting Epiphany, the use of a hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} programming model will not be compliant with the \mbox{OpenCL} standard and will not be portable to other architectures for which only a pure \mbox{OpenCL} implementation exists. This issue cuts directly to the relevance of standards in the development of high-performance code across differing architectures. The very concept of performance-portability is questionable and completely separate from that of portability in general. A code that is non-standard and utilizes architecture-specific features is no less useful than a code that is completely portable and compliant with a given programming standard but achieves poor performance. For this reason, we contend that the utility of programming standards such as \mbox{OpenCL} has less to do with portability and more to do with providing programmers familiar syntax and semantics for creating architecture-specific code. Therefore the lack of general portability of our proposed programming model is not a significant concern for programmers developing high-performance code. \section{Application and Results} \label{sec:application} Multiplication of matrices is a central building block in many scientific applications. We apply the hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} programming model to matrix-matrix multiplication using the Cannon algorithm \cite{cannon}. Cannon's algorithm exemplifies the use of 2D parallel decomposition to effectively exploit this type of parallel architecture. The algorithm decomposes a square matrix-matrix multiplication problem (C = A*B) across an N-by-N collection of processing elements. Sub-matrices are shared between neighboring processing elements after each submatrix-submatrix multiplication. As illustrated in Figure \ref{fig:cannon}, the communication pattern begins by skewing the columns of matrix A left and the rows of B upward within the 2D mesh network topology. \begin{figure} \centering \includegraphics[width=1.0\textwidth]{Cannon.pdf} \caption{The 2D mesh network topology communication patterns for submatrix skewing and shifting. A submatrix-submatrix multiplication occurs after each communication step. For the Epiphany-III processor, this figure represents the full inter-core communication pattern between the 16 cores on the device although the communication pattern can be applied generally to larger or smaller square arrays of cores. The initial skew communication may be unnecessary if the submatrices are read in pre-skewed. An additional communication step is needed to restore the shifted and skewed matrices if desired, but this is unnecessary since a copy of the A and B matrices remains within shared device memory.} \label{fig:cannon} \end{figure} For reference, a purely \mbox{OpenCL} implementation is benchmarked in which each thread per core must read in submatrices from global memory. This implementation lacks the data re-use that will lead to higher performance. Instead of communicating submatrices for A and B to the left and upward, respectively, equivalent bookkeeping is used to allow each thread to simply read in the submatrix that is needed from global memory. The performance using \mbox{OpenCL} alone achieves up to 794 MFLOPS for a matrix sizes of 128x128. It is worth noting that the architecture is quite limited by the off-chip bandwidth, particularly when loading memory directly rather than by using the off-chip DMA engine (a feature not addressed by either \mbox{OpenCL} or \mbox{OpenSHMEM} standards). The same \mbox{OpenCL} code is then modified with \mbox{OpenSHMEM}. No changes are required for the \mbox{OpenCL} host code. The \mbox{OpenSHMEM} header is included in the \mbox{OpenCL} kernel, and the core-local buffers for matrices A, B and C are allocated using \mbox{OpenSHMEM} semantics for symmetric shared memory. The \mbox{OpenCL} kernel is further modified to use an \mbox{OpenSHMEM} put call with appropriate barrier synchronization between threads to implement the shifting of submatrices. The result is that a submatrix is read once from global memory and then re-used. This is known to be necessary to achieve optimal performance on the Epiphany architecture. The performance of the hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} programming model achieves up to 1812 MFLOPS. With data re-use supported by \mbox{OpenSHMEM} the hybrid implementation easily outperforms the reference \mbox{OpenCL}-only implementation. Performance for this application is still limited by off-chip bandwidth, however, the inclusion of the inter-core communication with the \mbox{OpenSHMEM} interface increases performance by a factor of 2.3x. Results for various matrix sizes are shown in Table \ref{tab:cannon}. \begin{table} \centering \caption{On-chip matrix-matrix multiplication performance with pure OpenCL and hybrid OpenCL + OpenSHMEM programming model} \label{tab:cannon} \begin{tabular}{l c c r} \hline \noalign{\smallskip} \multirow{2}{*}{Matrix Size~~~~} & \multicolumn{2}{c}{Programming Model Performance (MFLOPS)} & \multirow{2}{*}{~~~~Speedup} \\ \cline{2-3} \noalign{\smallskip} & OpenCL & OpenCL + OpenSHMEM & \\ \hline \noalign{\smallskip} $32\times32$ & 218 & 504 & 2.3x \\ $64\times64$ & 424 & 1000 & 2.4x \\ $128\times128$ & 794 & 1817 & 2.3x \\ \hline \end{tabular} \end{table} \section{Conclusions and Future Work} \label{sec:conclusions} We have proposed and demonstrated a hybrid \mbox{OpenCL} + \mbox{OpenSHMEM} programming model for device-level parallel programming architectures like the low-power Epiphany RISC array processor. This hybrid model directly resolves the most critical deficiency encountered in the use of \mbox{OpenCL} alone for this architecture. The introduction of \mbox{OpenSHMEM} allows the proper management of the on-chip distributed symmetric shared memory, which is critical for obtaining high performance with this architecture. Benchmarks for matrix-matrix multiplication demonstrate that the hybrid programming model can achieve better performance for this architecture and substantially outperforms the use of \mbox{OpenCL} alone.
{'timestamp': '2016-08-12T02:09:40', 'yymm': '1608', 'arxiv_id': '1608.03549', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03549'}
arxiv
\section{Methods} \label{sec:approach} The proposed solution consists of three main components (see Fig.~\ref{pic:overview}). We describe each of these in the following. \subsection{Temporal-based Ranking on History Items} \label{sec:rank} The first component of our system is motivated by the observation that \textit{users have a strong tendency to re-interact with items that they already did in the past}. Statistically, on average $2$ out of $7$ items from the first 14 weeks re-appear in the $15^{th}$ week's interaction list. It makes it very plausible to recommend the old items to users. Similarly, items that appeared in the ``impression'' list are also preferred. It motivates us to consider the set of items from past interactions and impressions as a candidate set for user. Given a user $u$ and an item $i$, the historical interactions between $u$ and $i$ before time $t$ is represented as $M_{i,u,t}\in\mathbb{N}^{K\times T}$, where $T$ is number of time stamps from time 1 to time $t$, $K$ is number of types of interactions (e.g., click, bookmark, or reply), and $M_{i,u,t}(k,\tau)$ is the number of $k$-type interactions at time $\tau\in\{1,\cdots, t\}$. Given a user $u$, a na\"ive model is to rank each item simply based on the aggregation adoption of history, which leads to \begin{equation*} \small{ S(u, i, t)=\sum_{k}\sum_{\tau=1}^tM_{i,u,t}(k,\tau) } \end{equation*} where $S(u, i, t)$ evaluates how likely user $u$ is to re-interact with an item $i$ given their historical interactions. However, not every historical interaction by a user has the same importance. For example, a user may prefer re-clicking an item from previous day over one clicked 10 weeks ago. We conjecture that the importance of user-item interactions depends on the time of interaction. With this assumption, given a user $u$, item $i$ and a particular time $t$, we propose a time reweighed linear ranking model, which is defined as: \begin{equation*} S(u, i,t)=wM_{u, i, t}^T \end{equation*} where $w$ is the coefficient associated with time, with $w(k,\tau)$ indicating the relative contribution of $k$-type interactions at time $\tau$. To learn $w$, we construct triplet constraints $$\mathcal{T} = \left\{u\text{ prefers to re-interacting with } i_1 \text{ to } i_2 \text{ at time } \tau\right\}_{n=1}^N.$$ when \textit{$u$ interacted with $i_1$, $i_2$ before $\tau$, but only interacted with $i_1$ at $\tau$}. We thus obtain the solution of $w$ by minimizing an objective function that incurs a smoothed hinge loss when a constraint is violated. \subsection{Factorizing Temporal Interactions} \label{sec:mf} \subsubsection{Hybrid Matrix Factorization and Categorical Feature Learning} \label{sec:hmf} In order to recommend items that one user interacted with to another similar user or to recommend newly appearing items, we exploit the availability of user/item features, and characterize items/users by vectors of latent factors inferred from their features. Our approach starts with hybrid matrix factorization technique~\cite{kula_metadata_2015}. To briefly review, we model each user/item as a sum of the representations of its associated features and learn a $d$-dimensional representation for each feature value (together with a $1$-dimensional bias). Let $\vec{x}^U_j$/$\vec{x}^I_j$ denote the embedding (i.e., vectors of factors) of the user/item feature $j$, $\vec{q}_u$/$\vec{q}_i$ denote the embedding of user $u$ /item $i$, and $b_j^U/b_j^I$ denote the user/item bias for feature $j$. Then \begin{equation} \vec{q}_u = \sum_{j\in f_u} \vec{x}_j^U , \vec{q}_i = \sum_{j\in f_i} \vec{x}_j^I; \qquad b_u = \sum_{j\in f_u} b_j^U , b_i = \sum_{j\in f_i} b_j^I \end{equation} The model prediction score for pair \{$u$, $i$\} is then given by \begin{equation} \label{eq:score} S(u,i) = \vec{q}_u \cdot \vec{q}_i + b_u + b_i \end{equation} The model is trained by minimizing the sum of a loss on $S(u,i)$ and the observed ground truth $t(u,i)$, \begin{equation} L = \sum_{\{u,i\} \in I } \ell(S(u,i), t(u,i)) \end{equation} where $I$ is set of interactions between user $u$ and item $i$, $\ell$ is chosen to be Weighted Approximately Ranked Pairwise (WARP) loss~ \cite{usunier2009ranking,weston2010large}, which in our case empirically performs better than other loss functions (e.g. Bayesian Personal Ranking \cite{rendle2009bpr}). \subsubsection{Temporal re-weighted Matrix Factorization} \label{sec:thmf} Our approach is grounded on the assumption that the time factor plays an important role in determining the user's future preference. To this end, we place a non-negative weight associated with time on the loss, which leads to the following equation: \begin{equation} L' = \sum_{\{u,i,\tau\} \in I } \ell(S(u,i), t(u,i,\tau)) \times \gamma(\tau) \end{equation} Here the re-weighting term $\gamma$ depends on the time $\tau$ when the user-item interaction happens, which captures the contribution from interactions over time. Additionally, some zero weight $\gamma$ reduces training set size to speed up training and could possibly help prevent over-fitting. In general $\gamma$ can be learned jointly with other embedding parameters in the model. In practice, we only fixed $\gamma$ as the learned weights $w$ from Model \ref{sec:rank} to speed up training. \section{Conclusions} In this paper, we presented our innovative combination of new and existing recommendation techniques for \textit{RecSys Challenge 2016}. Empirical study verified the effectiveness of 1) utilizing historical information in predicting users' preferences and 2) both temporal learning and sequence modeling in improving recommendation. Notably, the proposed RNN-based model outperforms the commonly used matrix factorization models. In the future, we would like to extend our research in model designs (e.g. to incorporate features in the output layer and to support other loss functions) and in result analysis to understand why and when the sequence modeling really helps recommendation. \section{Introduction} The problem of matching job seekers to postings~\cite{malinowski2006matching} has attracted lots of attention from both academia and industry (e.g., Xing\footnote{https://www.xing.com/} and LinkedIn) in recent years. \textit{Recsys Challenge 2016} is organized around a particular flavor of this problem. Given the profile of users, job postings (items), and their interaction history on Xing, the goal is to predict a ranked list of items of interest to a user. To develop a high quality job recommendation system, one needs to understand and characterize the individual profile and behaviors of users, items, and their interactions. The commonly used factor models \cite{weimer2007maximum,koren2009matrix} learn factors for user and item by decomposing user-item interaction matrices. Neighborhood methods \cite{sarwar2001item,koren2008factorization} rely on similarities between users and items that are derived from content or co-occurrence. These popular methods often ignore or under-exploit important temporal dynamics and sequence properties between users and items. To address the aforementioned limitations, we explore temporal and sequence modeling to characterize both temporal behaviors and content similarity of users and items. First, we propose a time-based ranking model that leverages historical interactions for item recommendation. Second, we investigate how to learn latent temporal factors from both user-item interactions and their associated features. Instead of factoring a single aggregated matrix, we extend the context-aware matrix factorization model to explicitly consider temporal interactions. Finally, motivated by recent success of sequence modeling \cite{graves2009offline, luong2014addressing, sutskever2014sequence, donahue2015long, karpathy2015deep}, we explore the Recurrent Neural Networks (RNNs) approach to capture user-items behavior patterns. We suggest that sequence modeling is very helpful in terms of modeling both item-item similarity and item temporal transition patterns and it consequently leads to a more effective way of utilizing item history. Towards this end, we develop an Encoder-Decoder sequence recommendation system that incorporates feature learning, which significantly increases model flexibility. The contributions of this work are summarized as follows: 1) A novel temporal ranking approach to recommend items from history; 2) An enhanced hybrid matrix factorization model that explicitly incorporating temporal information; 3) A RNN-based sequence model that considerably outperforms matrix factorization models; and 4) Our final system, an ensemble of the above components, achieving $5^{th}$ place in \textit{RecSys Challenge 2016}. \section{Problem and Data: \textit{RecSys 2016}} \textit{RecSys Challenge 2016} provides 16 weeks of interactions data for a subset of users and job items from the social networking and job search website - \textit{Xing.com}. The task is to predict the items that a set of target users will positively interact with (click, bookmark or reply) in the following week. \noindent\textbf{Data Set. }Users and items are described by a rich set of categorical or numerical features or descriptor features. Categorical features take several to dozens of values and descriptor features have a vocabulary size around $100K$. Observation including positive interactions and impressions (items shown to users by \textit{Xing}'s existing recommendation system) at different weeks are also available. The detailed quantitative information of this dataset is shown in Fig.~\ref{fig:data}. \begin{figure}[!ht] \centering \begin{tabular}{|c|c|} \hline \textbf{Data splits} & \textbf{Sizes}\\ \hline Target/all users & 150K/1.5M \\ \hline Active/all items & 327K/1.3M \\ \hline Interactions & 8.8M \\ \hline Impressions & 202M \\ \hline \end{tabular} \qquad \begin{tabular}{|c|c|} \hline \textbf{Feature types} & \textbf{Features} \\ \hline \multirow{3}{*}{Categorical (U)} & career\_lever, discipline\_id, industry\_id,\\ & id, country, region, exp\_years,\\ & exp\_in\_entries\_class, exp\_in\_current\\ \hline Descriptors (U) & job\_roles, field\_of\_studies \\ \hline \multirow{2}{*}{Categorical (I)} & id, career\_level, discipline\_id, \\ & country, region, employment \\ \hline Numerical (I) & latitude, longitude, created\_at \\ \hline Descriptor (I) & title, tags \\ \hline \end{tabular} \caption{Statistics of Dataset and Feature Description (U: user; I: item).} \label{fig:data} \end{figure} \noindent\textbf{Task and Evaluation Metric. }Given a user, the goal of this challenge is to predict a ranked list of items from the active item set. The score is a sum over scores of each user $S(u)$, which is defined as follows: \begin{align*} \textbf{S}(u) = &20 * (P@2+P@4+R + \textsc{UserSuccess}) \\ + &10 * (P@6 + P@20) \label{eq:score} \end{align*} where $P@N$ denotes the precision at $N$, $R$ is the recall, and \textsc{UserSuccess} equals 1 if there is at least one item correctly predicted for that user. \subsection{Sequence Modeling via RNNs} \label{sec:lstm} In this section, instead of viewing user-item interactions as independent pairs, we model the entire set of user-item interactions from the same user as a sequence ordered by time. Sequence modeling may reveal the sequential patterns in user-item interactions such as the shifting of user interests over time and the demanding evolving of job items. \subsubsection{Encoder-Decoder modeling} \begin{figure*}[!htb] \includegraphics[width=15.0cm]{pics/FeatureLSTM_v2} \hspace{0.1em} \caption{Encoder-Decoder model for recommendation.}\label{pic:rnns} \end{figure*} We develop an Encoder-Decoder model \cite{sutskever2014sequence} based on LSTM \cite{hochreiter1997long} shown in Fig~\ref{pic:rnns}. Given a user $u$ and its interaction item sequence $\mathtt{I} = \{i^{1}, ... , i^{T}\}$, $u$ is encoded into hidden representation $\vec{h}_{enc}$ and cell state $\vec{c}_{enc}$ via \begin{equation} \vec{h}_{enc}, \vec{c}_{enc} = LSTM(f(u), \vec{0}, \vec{0}). \label{eq:enc} \end{equation} At decoding phase time step $t$, $\vec{h}_{dec}^{t}$ and $\vec{c}_{dec}^{t}$ are updated by \begin{equation} \label{eq:dec} \vec{h}_{dec}^{t}, \vec{c}_{dec}^{t} = LSTM(f(i^{t-1}), \vec{h}_{dec}^{t-1}, \vec{h}_{dec}^{t-1}) \end{equation} and $\vec{h}_{dec}^{t}$ is used to predict $i^{t}$. $i^{0}$ here is a special ``<START>'' item. Cross Entropy is used as the training loss. \subsubsection{Novel Extensions} \paragraph{Features.} $f$ in Eq.~(\ref{eq:enc}) (\ref{eq:dec}) and Fig.~\ref{pic:rnns} is a function that maps a user/item index (profile) into a vector by concatenating its features' embedding. For categorical features, the embedding is extracted from a look-up table, and descriptor features are considered as multi-hot features and average pooling is used. The look-up table is jointly learned during training. \paragraph{Anonymous users.} Item IDs are used as categorical features to capture item characteristics that are beyond feature descriptions. However, we remove user IDs from user feature set to prevent overfitting to those IDs and empirically observe better performance. It also leads to our natural train/validation set split by randomly splitting user set. \paragraph{Sampling and data augmentation.} Unlike the common success of data augmentation \cite{krizhevsky2012imagenet,simonyan2014very} and existing item sampling techniques \cite{improved16Tan}, our results indicate that it is better to use the original sequences, \textit{without sampling items}, to construct training set. Results and analysis are reported in Section \ref{sec:res}. \section{Related Works} Deep Feedforward Networks have been successfully applied in recommender systems. \cite{salakhutdinov2007restricted} used Restricted Boltzmann Machines for Collaborative Filtering and achieved remarkable results. Other feedforward models (e.g. Convolutional Neural Networks, Stacked Denoising Autoencoders) have also been used to extract feature representations from items to improve recommendation \cite{van2013deep,wang2015collaborative}. \cite{hidasi2015session}~introduced RNNs to recommendation system on the task of session based recommendation. They devised a GRU based RNNs and demonstrated good performance with one hot encoding item input and rank based loss functions. Further improvements on session based recommendation include exploiting rich features like image \cite{hidasiparallel} and data augmentation \cite{improved16Tan}. \section{Experiments} \subsection{Settings} \label{sec:exp_set} We take user-item interaction data from the $26^{th}$ to the $44^{th}$ weeks as training data and validate our model on the $45^{th}$ week. Submitted results come from models re-trained on data from $26^{th}$ to $45^{th}$ week under the same hyper-parameters. We observe very strong correlation between validation and test scores for all our models and thus \textbf{mostly report validation scores} below due to submission quota. \subsection{Results}\label{sec:res} \subsubsection{Recommend from History} Our model in Section~\ref{sec:rank} (\texttt{TRank}) is compared to two baseline models: randomized score (\texttt{Rand}) and recency-based sorting (\texttt{TSort}) that sorts items by the latest time they appear in the history. The results on historical ``interactions''(\texttt{INTS}), ``impressions''(\texttt{IMPS}), and their combinations (\texttt{\texttt{INTS}+IMPS}) are reported in Table~\ref{tHistory}. \texttt{TRank}~clearly outperforms the other two in all the three cases. Figure~\ref{pic:weights} shows the learned weights $w$ associated with the designed temporal features. The coefficients are decaying with time in both Figure~\ref{fints} and~\ref{fimps} across different types of interactions, indicating that more recent interactions have a larger statistical impact over the users' future preferences. Furthermore, although recency is important, simply using the latest time performs worse than \texttt{TRank}, which smoothly combines the most recent interactions with historical interactions using the learned weights $w$. \begin{table} \small \centering \caption{Scores in thousands ($\mathtt{K}$) based on history interactions.} \label{tHistory} \vspace{0.5em} \begin{tabular}{cccc}\hline Models & \texttt{Rand}& \texttt{TSort} & \texttt{TRank} \\ \hline \texttt{INTS} & 266 & 284& \textbf{299} \\ \hline \texttt{IMPS} & 324 & 375 & \textbf{380}\\ \hline \texttt{INTS+IMPS} & 463 & 509 & \textbf{524} \\ \hline \end{tabular} \vskip -1.0em \end{table} \begin{figure}[t] \centering \subfigure[interactions]{\label{fints}\includegraphics[width=0.485\columnwidth]{pics/w3} } \hspace{-0.2cm} \subfigure[impressions]{\label{fimps}\includegraphics[width=0.485\columnwidth]{pics/w2} } \vskip -0.5em \caption{Weights learned in Model \ref{sec:rank} for interactions \ref{fints} and impressions \ref{fimps}. $K$=4 for \texttt{INTS} and $K$=1 for \texttt{IMPS}, where type 1 denotes user-item impression pairs, and type 2,3,4 denote click, bookmark and reply, resp. }\label{pic:weights} \vskip -1.0em \end{figure} \subsubsection{Recommend via Matrix Factorization} We compare hybrid matrix factorization model in \ref{sec:hmf} (\texttt{HMF}) and the model in \ref{sec:thmf} (\texttt{THMF}) with different number of latent factor $d$, without and with features. Two important measures are used: score$_{all}$~and score$_{new}$. score$_{all}$~is the challenge score and score$_{new}$~is the score after removing all history user-item pairs. We found score$_{new}$~more important in model ensemble and chose in our experiments to early stop model training at the best score$_{new}$. As shown in Table \ref{tMF}, \texttt{THMF}~models achieve significant improvements on score$_{all}$~and score$_{new}$~for all $d$, with and without features. Meanwhile, the time comparison shows that the best models achieved by \texttt{THMF}~require significantly less training time. \begin{table} \centering \caption{Scores ($\mathtt{K}$) achieved by hybrid matrix factorization models and training time (in hours $h$) .} \label{tMF} \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline \multicolumn{2}{|c|}{Models} & \multicolumn{3}{c|}{\texttt{HMF}} & \multicolumn{3}{c|}{\texttt{THMF}} \\ \hline Fea& $d$ & score$_{all}$ & score$_{new}$ &T & score$_{all}$ & score$_{new}$ &T \\ \hline \multirow{4}{*}{No}&16 & 235 & 61 & 8.8 & 269 & 65 & 2.8 \\ \cline{2-8} &32 & 301 & 71 & 3.4 & 320 & 75 & 1.5 \\ \cline{2-8} &48 & 313 & 78 & 7.7 & 326 & 84 & 1.7 \\ \cline{2-8} &64 & 330 & 76 & 3.3 & 340 & 86 & 0.7 \\ \hline \multirow{3}{*}{Yes}&16 & 311 & 124 & 74 & 361 & 146 & 34 \\ \cline{2-8} &32 & 326 & 125 & 26 & \textbf{381} & \textbf{148} & 14 \\ \cline{2-8} &48 & 354 & 128 & 76 & 378 & 144 & 12 \\ \hline \end{tabular} \vspace{-1.0em} \end{table} Finally, we use items in the ``impression'' list in last week and treat them as ``interactions'' (with $0.01$ down-weight). This boosts performance as seen in Table \ref{tIMP}. \begin{table} \centering \caption{Scores ($\mathtt{K}$) by \texttt{THMF}~with some ``impression''s as additional observation inputs.} \label{tIMP} \begin{tabular}{ccc}\hline Observations & INTS & INTS + IMPS \\ \hline score$_{all}$ & 381 & \textbf{438} \\ \hline score$_{new}$ & 148 & \textbf{164} \\ \hline \end{tabular} \vskip -1.0em \end{table} \vspace{-1.0 em} \subsubsection{Recommend via LSTMs} \noindent\textbf{Setting, Tuning, Details.} With extensive tuning, we choose to train the encoder-decoder model (\texttt{LSTM}) using a single layer LSTM with hidden vector size as 256 and dropout rate as 0.6. All parameters are uniformly initialized before $[-0.08, 0.08]$. The learning rate of Stochastic Gradient Descent (SGD) is initially set as 1.0 and will decay with rate 0.7 once the perplexity on development set starts to increase. We only consider the top 50,000 frequent item and replace the remaining item as ``<UNK>''. The final result is ensembled using 6 models with different random seeds. \noindent\textbf{Performance.} Table \ref{tLSTM12} reports the comparison between \texttt{HMF}, \texttt{THMF}~and \texttt{LSTM}. Models are trained on the datasets\footnote{To make fair comparison, all models are trained on full user set and active item set. \texttt{HMF}, \texttt{THMF}~do benefit from training with additional items (see Table \ref{tMF}); however, currently we don't have efficient implementation of \texttt{LSTM}~supporting additional items.} with and without features. Provided with features, \texttt{LSTM}~obtains superior results to the rest. It verifies that sequence modeling is a promising direction for job recommendation tasks We also note when features are not provided, \texttt{LSTM} ~does not show advantages to \texttt{THMF}. We don't know the exact reason yet but suspect it is due to the inflexibility of non-feature sequence model which has a hard time capturing item transition pattern. \begin{minipage}{0.95\textwidth} \begin{minipage}[b]{0.52\textwidth} \centering \small \begin{tabular}{|c|c|c|c|c|c|c|} \hline Fea & \multicolumn{3}{c|}{No} & \multicolumn{3}{c|}{Yes} \\ \hline Models & \texttt{HMF} & \texttt{THMF} & \texttt{LSTM} & \texttt{HMF} & \texttt{THMF} & \texttt{LSTM} \\ \hline score$_{all}$ & 313 & \textbf{347} & 313 & 312 & 366 & \textbf{391} \\ \hline score$_{new}$ & 78 & 87 & \textbf{89} & 104 & 130 & \textbf{140} \\ \hline \end{tabular} \label{tLSTM12} \vspace{3em} \captionof{table}{Scores ($\mathtt{K}$) comparison among \texttt{HMF}, \texttt{THMF}, and \texttt{LSTM}~models. All models are trained on active item set.} \end{minipage} \hfill \begin{minipage}[b]{0.40\textwidth} \centering \epsfig{file=pics/order3.eps, height=1in, width=0.8\columnwidth} \label{pic:order} \vspace{-0.3em} \captionof{figure}{\texttt{LSTM}~scores ($\mathtt{K}$) on original and ``manipulated'' data sets. ``Orig'' denotes the complete sequence. $x_N$ denotes the manipulated data set obtained by randomly sampling sub-sequence proportional to $N$ times.}\label{pic:order} \end{minipage} \vspace{1.0em} \end{minipage} \noindent\textbf{Does sequence help?} When applying sequence modeling to the recommendation problem, we implicitly assume that sequence or order provides additional information beyond that provided by item frequency alone. To test the validity of this assumption, we generated new training data through sampling sub-sequences in which items were dropped out with certain probability. At the same time, on the average, item appearance frequency would remain unchanged in data with more sampled sub-sequences. Experimental results with the new generated training data are shown in Fig \ref{pic:order}. First, increasing sub-sequence sampling leads to decreasing scores (from $x_1$ to $x_8$); Second, original data set (full sequences) gives the best score. These results suggest that item sequences do indeed provide additional information and merit further investigation. \subsubsection{Ensemble and Final Results} Given the prediction and confidence scores from the above model components, we perform model ensemble to obtain our final result. The final scores are achieved by using a Random-Forests-based ensemble approach, which outperforms the linear fusion by greedy grid search in our preliminary experiment. Final scores for different components and the ensemble model are reported in Table \ref{tFinal}. \begin{table} \vspace{-.5em} \centering \caption{Final Component and Ensemble Results.} \label{tFinal} \vspace{0.5em} \begin{tabular}{ccccc}\hline Component & History & MF (ints+imps) & LSTMs & Ensemble \\ \hline Valid & 524 & 438 & 391 & 613 \\ \hline Test & 502 & 441 & 384 & 615\\ \hline \end{tabular} \end{table}
{'timestamp': '2016-08-12T02:01:58', 'yymm': '1608', 'arxiv_id': '1608.03333', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03333'}
arxiv
\section{Introduction} With their high mobility and reducing cost, unmanned aerial vehicles (UAVs) have found applications in wireless communication systems \cite{ZengUAVmag}, either to support the existing cellular networks in high-demand and overloaded situations \cite{UAVoverload}, or to provide wireless connectivity in areas without infrastructure coverage such as battle fields or disaster scenes \cite{UAVpublicSafety}. Compared to terrestrial communications, UAV-aided wireless systems are in general faster to deploy, more flexibly reconfigured, and likely to have better communication channels due to line-of-sight links. For example, the UAV can be deployed as a quasi-stationary aerial base station (BS) for the ground terminals (GTs) \cite{LAPlosProbability,DroneSmallCell}. Thanks to high mobility, UAVs can also be deployed as mobile relays to provide wireless connectivity between distant GTs whose direct links are severely blocked \cite{UAVrelay,ZengMobileRelay}. The deployment of UAVs is also considered in \cite{HanZhuUAV} to improve connectivity of wireless ad-hoc networks. In this letter, we consider a wireless system with the UAV deployed as a mobile BS to provide wireless connectivity for a group of distributed GTs. Compared to static UAV BSs in \cite{LAPlosProbability,DroneSmallCell}, the UAV controlled mobility is exploited to improve channel quality and thus system throughput. We assume that the UAV flies cyclically above the GTs at a fixed altitude, which results in cyclically varying patterns of the strength of the UAV-GT channels. We thus propose a new \textit{cyclical multiple access (CMA)} scheme where GTs are scheduled to communicate with the UAV in a cyclical time-division manner to exploit the good channel when the UAV flies closer to each of them. We propose an algorithm to allocate the time to different GTs based on the flying UAV's position to maximize their minimum throughput. We also analyze the access delay patterns of the GTs due to CMA and reveal a fundamental trade-off between throughput and delay. Numerical results show that the max-min throughput is significantly improved by the proposed CMA with a mobile UAV BS over the case of a static BS, at the expense of increased access delay. Thus, the proposed UAV-assisted mobile BS with CMA is most suitable in delay-tolerant applications \cite{DTNsurvey} such as periodic sensing, large data transfer, etc. The mobile UAV BS case is also considered in \cite{UAVunderlayD2D} to optimize the coverage performance. \section{System Model}\label{SectionModel} We consider a wireless communication system where a UAV is employed as a mobile BS to communicate with $K$ GTs. We assume that the GTs are equally spaced on the ground along a straight line with the length of $\Delta$ meters, as shown in Fig.~\ref{UAV2DtInterval}. Thus, the location $x_k$ of the $k$th GT can be expressed as $x_k=-\Delta/2+(k-1)\Delta/(K-1)$, $k=1,\cdots, K$. Note that the assumption of one-dimensional (1D) uniform GT locations is for the purpose of exposition to draw essential insights to the performance and design of the new UAV-assisted communication system. The results can be extended to arbitrary GT locations in general 2D or 3D setups, which are left for our future work. In practice, each GT in the considered 1D model could correspond to a cluster head that serves as a gateway for a cluster of nearby nodes communicating with the UAV. When the nodes are densely populated and the number of clusters is large, the cluster heads can be approximated to be equally spaced. \begin{figure} \centering \includegraphics[width=0.85\linewidth, trim=0 0 0 0,clip]{UAV2DtInterval} \caption{A wireless communication system with a UAV-aided mobile BS moving along a straight line.\vspace{-3ex}} \label{UAV2DtInterval} \end{figure} We assume that the UAV flies horizontally above the GTs following a cyclical trajectory with period $T$, i.e., the UAV position repeats every $T$ seconds. For simplicity, we assume that the UAV flies at a fixed altitude $H$, which could correspond to the minimum value required for safety considerations (e.g., terrain or building avoidance). The extension to variable $H$ will be left as future work. For the symmetric 1D GT distribution considered in this letter, it is intuitive that the UAV's trajectory $x(t), 0\leq t\leq T$, should be symmetric over the origin. Thus, assuming the UAV flies with a constant speed $V$, we have $x(t)\in[-D/2,D/2]$, $\forall 0\leq t\leq T$, with the trajectory length $D=VT/2$, as shown in Fig. \ref{UAV2DtInterval}. We consider the downlink communications where the UAV sends independent messages to the GTs over a given frequency band, whereas the obtained results can be similarly applied to uplink communications. We assume the communication channels are dominated by line-of-sight (LoS) links, and the Doppler effect due to the UAV's mobility is assumed to be perfectly compensated. Though simplified, the LoS model offers a good approximation for the UAV-GT channels in practice, which suffices for us to characterize the fundamental performance tradeoff. Therefore, at time instant $t$, the channel power gain from the UAV to each GT $k$ follows the free-space path loss model given by \begin{equation}\label{PathLoss} h_k(t)=\beta_0 d_k^{-2}(t)=\frac{\beta_0}{(x(t) - x_k)^2+H^2}, 0\leq t\leq T, \end{equation} where $\beta_0$ denotes the channel power gain at the reference distance $d_0=1$ meter (m), whose value depends on the carrier frequency, antenna gain, etc., and $d_k(t)=\sqrt{(x(t) - x_k)^2+H^2}$ is the link distance between the UAV and the $k$-th GT at time $t$. Note that from (\ref{PathLoss}), it follows that for each GT $k$ with fixed location $x_k$, its channel with the moving UAV with position $x(t)$ varies in a periodic manner over $T$, which is perfectly known at the UAV. By assuming a constant transmission power $P$ by the UAV, the instantaneous channel capacity from the UAV to the $k$-th GT in bits/second/Hz (bps/Hz) can be expressed as \begin{equation}\label{rkt} r_k(t)=\log_2\bigg(1+\frac{P h_k(t)}{\sigma^2}\bigg), 0\leq t\leq T, \end{equation} where $\sigma^2$ denotes the noise power at each GT receiver. In the following, we use the unit of bps/Hz to measure the throughput per unit bandwidth, also known as the spectrum efficiency. \section{Cyclical Multiple Access}\label{CyclicalMultipleAccess} To exploit periodic channel variations of different GTs, we propose a new multiple access scheme called CMA where GTs communicate with the UAV in a cyclical time-division manner, for which the details are given in this section. \subsection{Cyclical TDMA} From \eqref{PathLoss} and \eqref{rkt}, the maximum achievable rate $r_k$ of GT $k$ as a function of the UAV horizontal position $x$ is given by \begin{equation}\label{rkx} r_k(x)=\log_2\bigg(1+\frac{P\gamma_0}{(x - x_k)^2+H^2}\bigg), k=1,\cdots,K, \end{equation} where $\gamma_0\triangleq \beta_0/\sigma^2$ represents the reference signal-to-noise ratio (SNR). From \eqref{rkx}, it follows that for each GT $k$, the rate $r_k$ is symmetric and unimodal, which achieves its maximum at $x=x_k$. Moreover, the rate expressions of different GTs are identical except that they have different shifts along the x-coordinate according to different GT locations $x_k$'s . As an illustration, Fig.~\ref{K10plot}(a) plots the instantaneous rate of each GT versus the UAV position $x$, with $K=10$, $P=10$dBm, $\gamma_0=80$dB, $H=100$m, and $\Delta=1000$m. \begin{figure} \centering \includegraphics[width=1\linewidth, trim=80 0 50 0,clip]{K10plot} \caption{Cyclical multiple access with 10 GTs: (a) UAV-GT rate distribution; (b) transmission time allocation for different GTs.\vspace{-3ex}} \label{K10plot} \end{figure} Since each GT has its highest rate $r_k$ when $x=x_k$, it is intuitive to allocate the segment of the UAV trajectory near $x=x_k$ to GT $k$ for communication, so as to maximize the throughput to all GTs. Motivated by this, we propose a simple time-division based CMA, termed \textit{cyclical TDMA}, to schedule the communications from the UAV to different GTs based on the UAV position. Specifically, the one-way UAV trajectory of length $D$ is divided into $K$ contiguous horizontal segments: $[-D/2,b_1], [b_1,b_2], \cdots, [b_{K-1},D/2]$, which are allocated to the $K$ GTs for orthogonal transmissions, respectively. For convenience, let $b_0=-D/2$ and $b_K=D/2$. Then the UAV trajectory segment $[b_{k-1},b_{k}]$ and its corresponding time interval $[t_{k-1},t_{k}]$ is allocated to GT $k$. With such a periodic TDMA scheme, the average throughput of GT $k$ in bps/Hz is obtained as \begin{equation}\label{Throughput} \theta_k=\frac{2}{T}\int_{t_{k-1}}^{t_k} r_k(t)\diff t=\frac{2}{T}\int_{b_{k-1}}^{b_k} r_k(x)\diff x \frac{\diff t}{\diff x}=\frac{1}{D}\int_{b_{k-1}}^{b_k} r_k(x)\diff x, \end{equation} where we have used the identity $\frac{\diff t}{\diff x}=1/V$ and $D=VT/2$. The integral of the rate function $r_k(x)$ can be obtained in closed-form as \begin{multline}\label{rkIntegral} R_k (x)=\int r_k(x)\diff x=(x-x_k)\log_2\bigg(1+\frac{P\gamma_0}{(x - x_k)^2+H^2}\bigg)\\ +2\bigg(H\tan^{-1}\frac{x_k-x}{H} -\sqrt{H^2+P\gamma_0}\tan^{-1}\frac{x_k-x}{\sqrt{H^2+P\gamma_0}}\bigg)/\ln 2. \end{multline} Therefore, the throughput of GT $k$ is given by \begin{equation}\label{Throughputb} \theta_k=\frac{1}{D}R_k(x)|_{b_{k-1}}^{b_k}=\frac{1}{D}\bigg(R_k(b_k)-R_k(b_{k-1})\bigg). \end{equation} \subsection{Max-Min Throughput}\label{SectionFixedTraj} For a fixed UAV trajectory length $D$, we study the problem of maximizing the minimum throughput among all GTs, denoted by $\tau$, by optimizing the delimiting variables $b_1,b_2,\cdots,b_{K-1}$ for their time allocations. The max-min throughput is used to maximize the overall throughput while ensuring fairness among all GTs. The problem can be formulated as \begin{align} \mathrm{(P1)}: \begin{cases} \underset{\{b_k\}_{k=1}^{K-1}}{\max} & \ \tau \notag \\ \text{s.t.} & \ \theta_k\geq \tau, k=1,\cdots, K,\\ & \ -D/2\leq b_1\leq b_2\leq\cdots\leq b_{K-1}\leq D/2, \end{cases} \end{align}% where $\theta_k$ is a non-concave function of $b_{k-1}$ and $b_k$ from \eqref{rkIntegral} and \eqref{Throughputb}. Therefore, (P1) is non-convex and thus cannot be directly solved via standard convex optimization techniques. Fortunately, (P1) can be efficiently solved by exploiting the following two properties. Firstly, it can be proved that all GTs have equal throughput when the max-min throughput $\tilde\tau$ is achieved. Secondly, note that if all other delimiting variables are fixed, the optimization variable $b_k$ only affects the throughputs of GT $k$ and GT $k+1$. The first property can be proved by contradiction. Assume that the max-min throughput $\tilde\tau$ is achieved at a single GT $k$ while its neighboring GT $k+1$ (or $k-1$ if $k=K$) has a higher throughput, i.e., \begin{equation}\label{ThroughputbCompare} \tilde\tau=\tilde\theta_k=\frac{1}{D}R_k(x)|_{\tilde b_{k-1}}^{\tilde b_{k}}<\frac{1}{D}R_{k+1}(x)|_{\tilde b_{k}}^{\tilde b_{k+1}}=\tilde\theta_{k+1}. \end{equation} As $b_k$ increases from $\tilde b_{k-1}$ to $\tilde b_{k+1}$, $\theta_k$ monotonically increases from $0$ while $\theta_{k+1}$ monotonically decreases to $0$. Therefore, there exists a unique value of $b_k=\hat b_k>\tilde b_{k}$ which makes \begin{equation}\label{ThroughputbCompare1} \hspace*{-0.3cm}\hat\theta_{k+1}=\frac{1}{D}R_{k+1}(x)|_{\hat b_{k}}^{\tilde b_{k+1}}=\hat\theta_k=\frac{1}{D}R_k(x)|_{\tilde b_{k-1}}^{\hat b_{k}}>\tilde\theta_k=\tilde\tau. \end{equation} This contradicts with the assumption that $\tilde\tau$ is the max-min throughput, since it can be increased to $\hat\theta_k$. The cases in which the max-min throughput $\tilde\tau$ is achieved at multiple GTs can be proved in a similar way. The above proof also suggests a method to obtain the max-min throughput $\tilde\tau$. Based on the above two properties, we can fix $b_1,\cdots,b_{k-1},b_{k+1},\cdots,b_{K-1}$ and optimize $b_k$ to ensure that $\theta_k=\theta_{k+1}$, i.e., $b_k$ can be updated by solving for $b$ from the following equation: \begin{equation}\label{ThroughputEqual} R_k(b)-R_k(b_{k-1})=R_{k+1}(b_{k+1})-R_{k+1}(b), b_{k-1}\leq b\leq b_{k+1}. \end{equation} We therefore propose Algorithm \ref{Alg1} to iteratively tune the delimiting variables to achieve the max-min throughput for (P1). In each iteration, we pick the delimiting variable $b_{k_0}$ that corresponds to the largest throughput gap $\zeta_{max}$ between two neighboring GTs $k_0$ and $k_0+1$. Then we tune $b_{k_0}$ to eliminate this gap by solving equation (\ref{ThroughputEqual}). The iterations repeat until all the throughput gaps between two neighboring GTs are smaller than a certain threshold $\epsilon$. \begin{algorithm}[H]\caption{Max-Min Throughput with Cyclical TDMA}\label{Alg1} \begin{small} \textbf{Input:} GT locations $x_k, 1\leq k\leq K$; UAV altitude $H$, trajectory length $D$; transmit power $P$, reference SNR $\gamma_0$.\\ \textbf{Output:} Trajectory delimiting variables $b_1,\cdots, b_{K-1}$; max-min throughput $\tilde\tau$.\\ \textbf{Initialization:} $b_0=-D/2$, $b_K=D/2$, $b_k=b_0+k(D/K)$, $1\leq k\leq K-1$; $\epsilon=10^{-5}$. \begin{algorithmic}[1] \REPEAT \STATE Calculate throughput $\theta_k,\forall k$ from (\ref{Throughputb}). \STATE Find the largest throughput gap $\zeta_{max}=\max\limits_{1\leq k\leq K-1}|\theta_{k+1}-\theta_k|$ and corresponding index $k_0$. \STATE Solve for $b$ in equation (\ref{ThroughputEqual}) with $k=k_0$. Update $b_{k_0}=b$. \UNTIL{$\zeta_{max}<\epsilon$} \STATE The max-min throughput $\tilde\tau=\theta_1$. \end{algorithmic} \end{small} \end{algorithm} Algorithm \ref{Alg1} achieves the max-min throughput $\tilde\tau$ for any fixed trajectory length $D$, which can be proved by contradiction. First of all, Algorithm \ref{Alg1} is guaranteed to converge since the largest throughput gap $\zeta_{max}$ is bounded below by 0 and is decreasing in each iteration. After convergence, Algorithm \ref{Alg1} returns the delimiting variables $\tilde b_1,\cdots, \tilde b_{K-1}$ which yields $\zeta_{max}\rightarrow 0$ and thus all GTs have equal throughputs given by \begin{equation}\label{ThroughputbContradict} \frac{1}{D}R_1(x)|_{-\frac{D}{2}}^{\tilde b_{1}}=\frac{1}{D}R_2(x)|_{\tilde b_{1}}^{\tilde b_{2}}=\cdots=\frac{1}{D}R_K(x)|_{\tilde b_{K-1}}^{\frac{D}{2}}=\tilde\tau, \end{equation} where $\tilde\tau$ denotes the achievable max-min throughput. Now assume there exists a higher max-min throughput $\hat\tau>\tilde\tau$, with the delimiting variables $\hat b_1,\cdots, \hat b_{K-1}$. Then we have \begin{equation}\label{ThroughputbCompare} \frac{1}{D}R_1(x)|_{-\frac{D}{2}}^{\hat b_{1}}\geq\hat\tau>\tilde\tau=\frac{1}{D}R_1(x)|_{-\frac{D}{2}}^{\tilde b_{1}}. \end{equation} Since the integral function $R_1(x)$ is monotonically increasing, from (\ref{ThroughputbCompare}) we have $\hat b_{1}>\tilde b_{1}$. By induction, we can similarly conclude that $\hat b_{2}>\tilde b_{2}, \cdots, \hat b_{K-1}>\tilde b_{K-1}$. However, this contradicts with the assumption that $\hat\tau>\tilde\tau$, which also results in $\hat b_{K-1}<\tilde b_{K-1}$ from the following inequality: \begin{equation}\label{ThroughputbCompare2} \frac{1}{D}R_K(x)|_{\hat b_{K-1}}^{\frac{D}{2}}\geq\hat\tau>\tilde\tau=\frac{1}{D}R_K(x)|_{\tilde b_{K-1}}^{\frac{D}{2}}. \end{equation} Therefore, $\tilde\tau$ achieved by Algorithm \ref{Alg1} is indeed the max-min throughput. The proof is thus completed.$\blacksquare$ For the example in Fig. \ref{K10plot}(a) with $K=10$, assume that the one-way trajectory length is set to $D=\Delta/2$. Denote the portion of the UAV trajectory allocated to GT $k$ as $\delta_k$, i.e., \begin{equation}\label{portion} \delta_k=\frac{b_{k}-b_{k-1}}{D}. \end{equation} Algorithm \ref{Alg1} is applied to obtain the optimal delimiting variables $b_1,\cdots, b_{9}$ shown in Fig. \ref{K10plot}(b), which achieve the max-min throughput $\tilde{\tau}=0.4663$ bps/Hz. Note that the allocated trajectory portions are non-uniform for different GTs. In general, the middle GTs require a smaller portion of the trajectory to achieve the same throughput since they enjoy better channels than the GTs on the two sides. For benchmark comparison with a static UAV BS, since all GTs are symmetric around the origin, the optimal fixed UAV position for max-min throughput is $(0,H)$ due to symmetry. Since the UAV-GT channels are fixed, by optimizing the time allocation, the max-min throughput $\tilde\tau$ in the static UAV case can be obtained as \begin{equation}\label{Tauc} \tilde\tau=\frac{1}{\sum_{k=1}^K 1/ r_k}, \end{equation} which has a value of 0.3488 bps/Hz for the example in Fig. \ref{K10plot}(a). The static UAV BS scenario can be treated as an extreme case of the proposed cyclical TDMA with zero UAV trajectory length, i.e., $D=0$. It is found that the max-min throughput achieved by the mobile UAV BS with $D=\Delta/2$ is 33.7\% higher than that of the static UAV BS case. This gain is owing to the UAV mobility, which can be further improved by optimizing the trajectory length $D$ (as will be shown later in Section \ref{SectionSimu}). However, for a fixed UAV speed $V$, the trajectory period $T=2D/V$ and hence the access delay of the GT communications increases with $D$. Therefore, there exists a general tradeoff between maximizing the throughput and minimizing the access delay, in selecting the value of $D$ in the proposed mobile UAV BS with CMA. \subsection{Access Delay}\label{SectionDelay} Within each period $T$ of the UAV cyclical trajectory from $x=-D/2$ to $D/2$ and then back to $-D/2$, each GT $k$ can communicate with the UAV in two non-consecutive time windows corresponding to the UAV position $x\in[b_{k-1},b_{k}]$. This results in two non-consecutive ``mute" time windows in which GT $k$ cannot communicate with the UAV whose lengths are denoted as $\varphi_{k,\rm L}$ and $\varphi_{k,\rm R}$, corresponding to the UAV trajectory on the left and right sides, respectively. For the example with 10 GTs, the UAV trajectory segment $x\in[b_2,b_3]$ is allocated to GT 3, with $\varphi_{3,\rm L}$ and $\varphi_{3,\rm R}$ also shown in Fig. \ref{K10plot}(b). Define the access delay $\phi_k$ as the longest contiguous mute time of GT $k$ in a UAV flying period $T$, i.e., \begin{equation}\label{Delay} \phi_k=\max\{\varphi_{k,\rm L},\varphi_{k,\rm R}\}=\max\bigg\{\frac{2(D/2+b_{k-1})}{V} , \frac{2(D/2-b_{k})}{V}\bigg\}. \end{equation} According to this definition, the GTs have different access delays depending on their relative locations along the UAV trajectory. In general, the middle GTs have smaller access delays since $\varphi_{k,\rm L}$ and $\varphi_{k,\rm R}$ are roughly the same, while the GTs on the two sides have larger access delays since $\varphi_{k,\rm L}$ and $\varphi_{k,\rm R}$ are unbalanced. Such access delay patterns need to be considered when designing upper-layer protocols or applications with different delay requirements. Note that the access delay depends on the flying speed $V$, UAV trajectory length $D$, as well as the delimiting variables $b_k, 1\leq k\leq K-1$, which need to be obtained using Algorithm \ref{Alg1}. There could be various ways to characterize the overall access delay of all GTs. In this letter, we adopt the root-mean-square (RMS) access delay $\phi_{rms}$ defined as \begin{equation}\label{rmsDelay} \phi_{rms}=\sqrt{\frac{1}{K}(\phi_1^2+\phi_2^2+\cdots+\phi_K^2)}, \end{equation} which accounts for both the average value and variations of the delay. In general, $\phi_{rms}$ monotonically increases with $D$, since the round-trip period $T=2D/V$ is proportional to $D$ with fixed $V$. In this letter, we assume the system requires an RMS access delay no larger than $\Phi$, i.e., $\phi_{rms}\leq \Phi$. Note that the access delay considered in this letter is different from the conventional communication delay. Access delay is caused by the cyclical TDMA in which the GTs take turns to access the channel when the UAV flies above them. In the limiting case with a static UAV BS (or equivalently, $D=0$ in the mobile UAV BS case), the access delay can be arbitrarily small since the time frame can be divided into arbitrarily small mini-slots, each assigned to one GT for communication. However, this is not the case in cyclical TDMA with non-zero trajectory length $D$, since given a finite value of UAV speed $V>0$, each GT $k$ may need to wait a maximum time equal to its access delay $\phi_k$ given in (\ref{Delay}) for any two adjacent communications with the UAV (which in practice can be significantly larger than the conventional delay due to packet transmission). \section{Numerical Results}\label{SectionSimu} In this section, we normalize the trajectory length $D$ to the GT location range $\Delta$ for convenience, denoted as $\bar D=D/\Delta$. The following parameters are used: $P=10$ dBm, $\gamma_0=80$ dB, $H=100$ m, and $V=30$ m/s. For the same example in Fig. \ref{K10plot}(a) with $K=10$ GTs, we compare the max-min throughput $\tilde\tau$ under different RMS access delay tolerance values $\Phi$ to show the fundamental throughput-delay trade-off. For each pair of their values shown in Fig. \ref{K10Tradeoff}, the corresponding optimal $\bar D$ is obtained by searching $\bar D$ subject to that the resulted RMS access delay $\phi_{rms}$ is no larger than the given tolerance value $\Phi$, as follows. First, based on Algorithm \ref{Alg1}, we obtain the max-min throughput $\tilde\tau$ among all GTs for a fixed value of $\bar D$. Then, we find the optimal $\bar D$ such that the resulted RMS delay $\phi_{rms}$ satisfies the given $\Phi$ (i.e., $\phi_{rms}\leq \Phi$) to maximize $\tilde\tau$. This can be done by a simple one-dimensional search as the RMS access delay $\phi_{rms}$ in general monotonically increases with $\bar D$. Besides the optimal time/segment allocation proposed in Algorithm \ref{Alg1}, we also consider a simple equal time allocation scheme for comparison, which corresponds to $\delta_k=1/K, \forall k$, with $\delta_k$ similarly defined as in (\ref{portion}). First, it is observed that for the case of $\Delta=1000$m, the two schemes with optimal and equal time allocations achieve their peak values $\tilde\tau^*=0.6524$ bps/Hz and 0.6523 bps/Hz at $\bar D^*=1.10$ and 1.11, respectively, and the corresponding RMS delays are $\phi_{rms}=52.37$s and 52.85s, respectively. Therefore, if sufficiently large access delay can be tolerated, e.g., $\Phi>60$s, the simple equal time allocation with the optimal trajectory length $\bar D^*=1.11$ achieves the near-optimal performance. On the other hand, for relatively stringent access delay requirement, e.g., $\Phi<30$s, the cyclical TDMA with the optimal time allocation by Algorithm~\ref{Alg1} significantly outperforms that with the equal time allocation. Next, we investigate the throughput gain of the mobile UAV BS over its static UAV BS special case ($\bar D=0$), both with optimal time allocations. We have shown in Section \ref{SectionFixedTraj} that for fixed trajectory length $\bar D=0.5$, a throughput gain of 33.7\% is achievable by the mobile UAV BS, whereas the gain further increases to 87\% with optimized $\bar D^*=1.10$ as shown in Fig. \ref{K10Tradeoff}, at the cost of increased access delay. This gain is further increased in the case of a larger GT location range $\Delta$, i.e., up to 236\% when $\Delta=2000$m as shown in Fig. \ref{K10Tradeoff}. The rationale is that when $\Delta$ increases, the GTs on the two sides experience even poorer channels in the static UAV BS case, which degrades the max-min throughput significantly. On the contrary, cyclical TDMA still maintains a high max-min throughput, since all GTs can enjoy good channels in their allocated UAV trajectory segments, if the trajectory length $\bar D$ is optimized with respect to the location range $\Delta$ accordingly. \begin{figure} \centering \includegraphics[width=1\linewidth, trim=30 0 70 0,clip]{K10Tradeoff} \caption{Max-min throughput $\tilde\tau$ versus RMS access delay tolerance $\Phi$} \label{K10Tradeoff} \vspace{-1em} \end{figure} \section{Conclusions}\label{Conclusion} This letter proposed a new cyclical multiple access scheme in UAV-aided wireless communications, and characterized the max-min throughput by optimally allocating the transmission time to GTs based on the UAV position. Simulation results showed significant throughput gains with the proposed design over the static UAV BS case in delay-tolerant scenarios. Possible extensions of this letter for future work may include the general GT locations in 2D or 3D setups, variable speed/altitude control of the UAV, deployment and cooperation of multiple UAVs, etc.
{'timestamp': '2018-05-22T02:10:18', 'yymm': '1608', 'arxiv_id': '1608.03180', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03180'}
arxiv
\section{Introduction} The connection of the players is a crucial ingredient of any team sports. This is utmost valid in case of soccer, where teams are having hundreds of passes per game to design their gameplay. Despite the fact that passes are having a significant role in the game, the state-of-the-art evaluation of the quality of passes is way to simplistic. In case of the media, the passing capability and quality of a player are measured using metrics such as the number of passes and their success ratio. In case of the soccer industry, this is supplemented by metrics related to creating scoring opportunities like number of assists, key passes, and forward passes. These benchmarks are easy to be interpreted, however, they are missing the context of the passes. For example, a player may have 50 successful lateral passes at its own half of the pitch, delivering eye-catching statistics without real impact on the team's performance. Similarly, solely focusing on the number of assists a player is making neglects the build-up of the attack in which other players might have had more significant role. Previous works that analyze soccer-related datasets focus on the game-related performance of players and teams. Vast majority of these methodologies concentrate on descriptive statistics that capture some part of the players' strategy or focus on analyzing the outcome of the strategies that teams apply~\cite{pena2012network,narizuka2013statistical,lucey2013assessing,gyarmati2014,gyarmati2015,Wang2015,luceyquality}. A quantification of scoring opportunities called expected goals has been proposed in the soccer analytics domain~\cite{expected_goals}, however, passing ability is lacking such a metric. The state-of-the-art quantitative analysis of players' passing ability does not consider the players' real contribution to the passing and ball possession strategy of their team. Which player is delivering passes into critical parts of the field? We introduce a novel methodology called QPass to answer questions like this quantitatively. Our main contributions are: \begin{itemize} \item First, we propose a scheme to quantify the value of having the ball at a particular part of the field. The methodology is team-specific, \ie, it takes into account the way a team organizes its defense and attack. \item Second, we introduce a metric called QPass that derives the intrinsic value of passes building on the computed field values. \item Third, we determine pass trajectories for diverse playing styles and the identity of players applying them. We reveal players with the highest and lowest quality of passes. \item Finally, we show that making unsuccessful passes is beneficial in some cases and such leads to better chances to win a soccer game. \end{itemize} Applying QPass in practice can increase the comprehension of the core value of passes and thus the efforts players are making to help their teams. Player and opponent scouting is a prime area to apply the findings of our methodology in practice. \section{Methodology}\label{sec:algorithm} We next introduce our methodology called QPass to evaluate the intrinsic value of soccer passes. The method has three main steps, namely \begin{itemize} \item first, we create a partitioning of the field that reflects the playing style of a team; \item second, we derive the value of having or not having the ball at a particular part of the field; \item third, we evaluate the merit of a pass based on the change in the field values owed to a pass. \end{itemize} Our methodology uses event-based datasets of soccer games, where major events like passes and shots of the games are annotated. The events are accompanied by the identity of the players and location information, among others. We add new, virtual passes to the dataset if the end coordinates of two consecutive passes are not identical. Let $p=(x_s,y_s,f_s,x_e,y_e,f_e) \in P_i$ denote a pass (either original or virtual), where $x_s$ and $y_s$ are the coordinates of the start of the pass, while $f_s$ is the field value of the starting position. Analogously, $x_e,y_e,f_e$ denote the same in case of the end of the pass. We apply the first two steps of the methodology iteratively to reduce the impact of the granularity of field partitioning on the field values. We show the high-level steps of our method in Algorithm~\ref{alg:high_level}. As inputs, we use all the passes and shots of the teams we are analyzing. We determine the partitioning of the pitch and the field values team by team. Let $P_i$ and $S_i$ denote the passes and shots of team $i$, respectively. We combine all the passes ($\hat{P}_i$) and shots ($\hat{S}_i$) made by an opponent against team $i$. We start with $c_{max}$ number of clusters and smoothly decrease their number to $c_{min}$ (with steps of $c_{step}$). In each iteration, we use the events of the teams, the actual clustering, and the derived field values of the previous round. \begin{algorithm}[tb] \scriptsize \caption{Deriving field values and clusters of a team} \label{alg:high_level} \begin{algorithmic} \STATE \textbf{Input}: $P$, set of passes; $S$, set of shots; $T$, set of teams \STATE \textbf{Output}: $C$, clustering of the field; $F$, field values; \STATE $c \leftarrow c_{max}$ \STATE $C \leftarrow \oslash, F \leftarrow \oslash$ \FORALL{$t_i \in T$} \STATE $P_i \leftarrow passes\_of\_team(i)$ \STATE $\hat{P}_i \leftarrow passes\_of\_opponent(i)$ \STATE $S_i \leftarrow shots\_of\_team(i)$ \STATE $\hat{S}_i \leftarrow shots\_of\_opponent(i)$ \WHILE{$c \geq c_{min}$} \STATE $C \leftarrow create\_clustering(c,P_i,\hat{P}_i,F_i,\hat{F}_i)$ \STATE $F \leftarrow compute\_field\_values(C,P_i,\hat{P}_i,S_i,\hat{S}_i)$ \STATE $c \leftarrow c - c_{step}$ \ENDWHILE \ENDFOR \end{algorithmic} \end{algorithm} \subsection{Partitioning the soccer field} In case of soccer analytics, the de facto method of aggregating and grouping events is to use a grid that divides the field into uniform cells (\eg, 5-by-5 meters). The drawback of this technique is that it is reluctant to consider the differences of teams' strategies. To overcome this, we use a team specific partitioning of the field; we outline the method in Algorithm~\ref{alg:clustering}. First, we extract the location information of the start and end of all the passes of the teams along with the value of these positions computed in the previous iteration. We scale the values and then we use the mini batch K-means algorithm~\cite{sculley2010web} to create $c$ clusters. Once we have the clusterings, for each pass we determine to which cluster their locations are belonging to. If a team loses the ball, the other team gains possession at the end location of an unsuccessful pass. These coordinates have to be transformed as the events of both teams are coded based on their direction of attack. We train two, separate classifier to determine the clusters ($l_e$) these transformed locations are belonging to. \begin{algorithm}[tb] \scriptsize \caption{$create\_clustering$: Partitioning the field based on the events of a team} \label{alg:clustering} \begin{algorithmic} \STATE $P_1 \leftarrow P_i, F_1 \leftarrow F_i$, $P_2 \leftarrow \hat{P}_i, F_2 \leftarrow \hat{F}_i$ \FORALL{$i \in {1,2}$} \STATE $P_i \leftarrow P_i \cup F_i$, $P_s \leftarrow {(x_s,y_s,f_s) \in P_i}$, $P_e \leftarrow {(x_e,y_e,f_e) \in P_i}$ \STATE $P \leftarrow min\_max\_scaling(P_s \cup P_e)$ \STATE $C_i \leftarrow mini\_batch\_kmeans(P,c)$ \ENDFOR \FORALL{$i \in {1,2}$} \FORALL{$p=(x_s,y_s,f_s,x_e,y_e,f_e) \in P_i$} \STATE $c_s \leftarrow C((x_s,y_s,f_s))$, $c_e \leftarrow C((x_e,y_e,f_e))$ \ENDFOR \STATE $NN_i \leftarrow nearest\_neighbors(P_i)$ \ENDFOR \FORALL{$p=(x_s,y_s,f_s,x_e,y_e,f_e) \in P_1$} \STATE $l_e \leftarrow {NN}_2(mirror(x_e,y_e))$ \ENDFOR \FORALL{$p=(x_s,y_s,f_s,x_e,y_e,f_e) \in P_2$} \STATE $l_e \leftarrow {NN}_1(mirror(x_e,y_e))$ \ENDFOR \end{algorithmic} \end{algorithm} In our evaluation, we use the following parameters to generate the clusters: $c_{max}=1000$, $c_{min}=100$, and $c_{step}=50$. We illustrate the partitioning of the field in case of two teams in Figure~\ref{fig:clusters}. FC Barcelona, the champion of the season, has more clusters and thus more fine-grained precision in the opponent's half of the pitch than Levante, the worst team of the league. For example, Barcelona has six clusters along the right sideline, two more than Levante, where the method focuses more on their own half of the pitch. \begin{figure}[tb] \centering \includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=4cm]{figs/clustervis100_team_178.pdf} \includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=4cm]{figs/clustervis100_team_855.pdf} \vspace{-5mm} \caption{Team specific partitioning of the soccer field. The method considers the parts of the field teams are using more intensely. Teams attack from left to right. Left: FC Barcelona, right: Levante.} \label{fig:clusters} \end{figure} \subsection{Field value} Using the partitioning, we compute the field values in case of two scenarios: a team has or does not have the ball at a specific part of the field. We compute the field values by solving a system of linear equations as shown in Algorithm~\ref{alg:field_values}. We use matrix $A$ to capture the transitions from one cluster to another, while vector $b$ stores the field values of the clusters. The first $c$ items of $b$ represent the field values when team $i$ has the ball, while the next $c$ items are for the cases where the opponents have the ball. Scoring or conceding a goal has a value of $1$ and $-1$. Similarly, let $s$ denote the value of taking a shot If a pass is successful, a transition happens from the cluster of the start of the pass to the cluster of the end of the pass. If the pass is the last one in a given ball possession (\ie, sequence of uninterrupted, consecutive passes of a team), we add an additional state transition describing the change of ball possession ($l_e + c$). We also handle the shots based on their outcome. If a shot had an assist, we create a new transition from the end of the assist to the location of the shot. The procedure is identical in case of the opponent team except the addressing of the appropriate states in the transitions. After considering all the potential state transitions, we normalize the transition matrix and finally solve the system of linear equations. \begin{algorithm}[tb] \scriptsize \caption{$compute\_field\_values$: Computing the field values given a clustering of the field} \label{alg:field_values} \begin{algorithmic} \STATE $c \leftarrow |C|$, $A \leftarrow zeros(2c+4,2c+4)$, $b \leftarrow zeros(2c+4)$ \STATE $b_{2c+1} \leftarrow 1$, $b_{2c+2} \leftarrow s$, $b_{2c+3} \leftarrow -1$, $b_{2c+4} \leftarrow -s$ \FORALL{$i \in {1,2}$} \FORALL{$p=(c_s,c_e,l_e) \in \hat{P}_i$} \IF{$successful(p)$} \STATE $A(c_s,c_e) \leftarrow A(c_s,c_e) + 1$ \IF{$last\_pass(p)$ \AND $no\_shot(p)$} \STATE $A(c_e,l_e) \leftarrow A(c_e,l_e) + 1$ \ENDIF \ELSE \STATE $A(c_s,l_e) \leftarrow A(c_s,l_e) + 1$ \ENDIF \ENDFOR \FORALL{$s=(c_s) \in \hat{S}_i$} \IF{$goal(s)$} \STATE $A(c_s,2c+1) \leftarrow A(c_s,2c+1) + 1$ \ELSE \STATE $A(c_s,2c+2) \leftarrow A(c_s,2c+2) + 1$ \ENDIF \IF{$p=has\_assist(s)$} \STATE $A(c_e(p),c_s) \leftarrow A(c_e(p),c_s) + 1$ \ENDIF \ENDFOR \ENDFOR \STATE $normalize(A)$ \STATE $solve(A,b)$ \end{algorithmic} \end{algorithm} The used system of linear equations has a nice feedback mechanism to determine the field value of the different clusters. The field value of a cluster depends on the field values of the clusters to where passes were made, on the number of shots and goals created, and on the field values of clusters where ball possessions were lost. However, the field value of not having the ball at a given cluster depends on the field values of multiple scenarios: both with and without ball possessions. To illustrate the behavior of the field value metric, we present three scenarios in Figure~\ref{fig:field_values}. The ball possession of FC Barcelona is not that valuable up until the final 30 meters of the field, \ie, the field values are less then zero (Figure~\ref{fig:field_values_fcb}). The numerous passes FC Barcelona is making and their ball possession focused style (\ie, they are seldom having attacks with only few passes) cause this behavior. The figure reveals an imbalance between the two sides of their attacks: the team is better off having the ball on the right side of the field. Figure~\ref{fig:field_values_fcb_not} shows the field values of FC Barcelona, if they are not having ball. The behavior of the metric is inline with common sense: the farther the opponent controls the ball from the goal of FC Barcelona the better. We also show the field values of Levante in Figure~\ref{fig:field_values_levante}. The field values are positive if Levante has the ball at the opponent's half of the pitch---a harsh contrast to FC Barcelona. Teams like Levante have possession of the ball less frequently in these parts of the field and they usually apply direct attacks. \begin{figure*}[tb] \centering \subfigure[Ball possession of FC Barcelona]{\includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=5cm]{figs/fieldvalue_100_team_178.pdf}\label{fig:field_values_fcb}} \subfigure[Ball at theopponents of FCB]{\includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=5cm]{figs/fieldvalue_100_team_178_t2.pdf}\label{fig:field_values_fcb_not}} \subfigure[Ball possession of Levante]{\includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=5cm]{figs/fieldvalue_100_team_855.pdf}\label{fig:field_values_levante}} \vspace{-5mm} \caption{The values of parts of the field reflect both the attacking and the defending strategies of the teams. The intensity of the colors denote how beneficial the given location is; red represents the most worthy positions while blue areas are the least beneficial ones.} \label{fig:field_values} \end{figure*} \subsection{The value of a pass: QPass} We use the derived field values to evaluate the merit of every pass. We compute QPass as the change in the field values as the result of a pass \begin{equation} \textrm{QPass}(p) = \left\{ \begin{array}{rl} f_e - f_s & \mbox{ if p is successful} \\ l_e - f_s & \mbox{ otherwise} \end{array} \right. \end{equation} \noindent QPass depends not only on the location of the endpoints of a pass but also on the outcome of the pass. If the pass is unsuccessful, we use the field value of the end location given the opponent is having the ball possession. \section{Empirical Results} We next present an empirical evaluation of the QPass metric. We use an event-based dataset covering the 2015/16 season of the Spanish La Liga. The dataset contains all major events of a soccer game including passes and shots. The dataset has more than 330,000 passes and nearly 8,600 shots. We pick $s=0.7$ to be the value of having or conceding a shot. We only consider players who had at least 100 passes throughout the season. We use the median QPass values in our analysis because outlier values may exist due to the cluster driven computation of QPass. First, we present the distribution of median QPass values based on the number of passes the players have (Figure~\ref{fig:qpass_median}). The number of passes has negligible impact on QPass values. The players' position however affects the median values: goalkeepers have the largest QPass while attackers usually cannot increase the field values via passing. Midfielders have positive or negative impact on field values. \begin{figure}[tb] \centering \includegraphics[width=7cm]{figs/field_value_delta_per_season_filtered.eps} \vspace{-6mm} \caption{Median QPass values as a function of the number of passes players have throughout a season. There are clear separations among the positions of the players.} \label{fig:qpass_median} \end{figure} \subsection{Ranking of players} QPass is able to capture the diversity of the roles players have in a soccer team. We next focus on the best and worst players of each role with respect to the players' contribution to the play of the teams. Goalkeepers and defenders start the build-up of the attacks and also responsible to prevent the opponent's scoring chances. If a team plays in a direct style, players with high QPass are preferred such as T. Kolodziejczak (Sevilla, defender) or G. Iraizoz (Athletic Club, goalkeeper). For keeping the ball safe (\ie, having passes with low QPass values), midfielders like N. Amrabat of Malaga are preferred. The other end of the spectrum is S. Cristoforo (Sevilla), who is able to make passes into more beneficial parts of the field. We show the case of attackers in Table~\ref{tab:ranking_attackers}. Attackers with the highest QPass values are crucial for creating chances. The ranking of QPass values reveal players who are capable and willing to create key attacking passes like L. Vazquez, A. Griezmann, or L. Messi. Players whose main role is to score are having the lowest median QPass values including R. Marti, A. Aduriz, and L. Suarez. \begin{table}[tb] \caption{Top and bottom five attackers. High QPass reveals the players' involvement in creating chances. Strikers have low QPass values: they are already at a prime location to score, an additional pass moves the ball to a less valuable part of the field.} \label{tab:ranking_attackers} \scriptsize \centering \begin{tabular}{lrl} \toprule Player & QPass (median) & Team \\ \midrule Rodrigo de Paul & -0.005673 & Valencia \\ Lucas Vazquez & -0.006612 & Real Madrid \\ David Barral & -0.008006 & Granada \\ Antoine Griezmann & -0.008176 & Atletico Madrid \\ Lionel Messi & -0.009155 & Barcelona \\ \midrule Nabil Ghilas & -0.022783 & Levante \\ Fernando Llorente & -0.027046 & Sevilla \\ Luis Suarez & -0.027562 & Barcelona \\ Aritz Aduriz & -0.028058 & Athletic Club \\ Roger Marti & -0.039211 & Levante \\ \bottomrule \end{tabular} \end{table} We take a closer look at the passes the two types of attackers tend to make. Figure~\ref{fig:good_passes} presents the top 30 passes with the highest QPass values in case of Messi and Suarez. Messi helps his team by making passes from outside of the box into the opponent's box---a premier spot to shot on target. On the other hand, the passes of Suarez start already inside the box. These are lateral passes from a good part of the field to an even better one. \begin{figure}[tb] \centering \subfigure[Lionel Messi]{\includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=4cm]{figs/field_value_delta_positive_successful_passes_19054.eps}} \subfigure[Luis Suarez]{\includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=4cm]{figs/field_value_delta_positive_successful_passes_39336.eps}} \vspace{-5mm} \caption{The top 30 passes with the highest QPass value. QPass is able to distinguish the specific roles of players in the attack: playmaking or finishing.} \label{fig:good_passes} \end{figure} \subsection{Lose the ball to win the game} It is part of the game to make errors, \ie, to lose the ball now and then. In fact, the constant change of ball possession is one of the main reasons why soccer is such a dynamic game. Losing the ball is considered to be a bad thing, however, as our study reveals, a team can be better off with a lost ball in some circumstances. The methodology of QPass is able to identify unsuccessful passes that were useful, \ie, increased the field value of a team. To justify this, we present the cumulative distribution of the QPass values of unsuccessful passes in Figure~\ref{fig:losing_ball}. Almost 50 percent of the failed passes of defenders are actually helping their team despite the fact that the opponent will possess the ball afterwards. Similarly, goalkeepers are making good decisions by risking a pass that may be unsuccessful in 80 percent of the time. In some particular cases, even attackers' ``mistakes'' are beneficial after all. \begin{figure}[tb] \centering \includegraphics[width=5.5cm]{figs/field_value_delta_failed_ccdf.eps} \vspace{-5mm} \caption{Team can be better off by losing the ball.} \label{fig:losing_ball} \end{figure} To give an idea on the nature of these scenarios, we present the unsuccessful passes of Pique and Messi of FC Barcelona that result in elevated field values (Figure~\ref{fig:lost_balls_beneficial}). In case of Pique, these passes are either clearances to avoid conceding shots or crosses to the wings to start building up an attack. Messi on the other hand tries to pass the ball into the attacking third (or even into the box of the opponent) to prepare immediate scoring opportunities. \begin{figure}[tb] \centering \subfigure[Gerard Pique]{\includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=4cm]{figs/field_value_delta_positive_failed_passes_18221.eps}} \subfigure[Lionel Messi]{\includegraphics[clip=true, trim=1cm 2.5cm 1cm 3cm,width=4cm]{figs/field_value_delta_positive_failed_passes_19054.eps}} \vspace{-5mm} \caption{Lose the ball to win: unsuccessful passes that lead to increased field values.} \label{fig:lost_balls_beneficial} \end{figure} \section{Conclusion} We introduced a novel methodology called QPass to evaluate the intrinsic value of passes, \ie, how they contribute to having more scoring opportunities than the opponent. Through the analysis of an entire season, we rank the players based on their passing capabilities using QPass, and identify players best suitable for specific styles of play. Our counterintuitive finding reveals that making unsuccessful passes may lead to better chance to win a game. Applying QPass in practice can help player and opponent scouting by revealing the merit of the players' passing game. \bibliographystyle{abbrv} \small{ \vspace{1mm}
{'timestamp': '2016-08-12T02:09:07', 'yymm': '1608', 'arxiv_id': '1608.03532', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03532'}
arxiv
\section{Introduction}\label{sec:intro} \input{sections/intro.tex} \section{A smart street light control system}\label{sec:example} \input{sections/example.tex} \section{The calculus \IoTLySa}\label{sec:semantics} \input{sections/semantics.tex} \section{Control flow analysis}\label{sec:analysis} \input{sections/analysis.tex} \section{Security properties} \input{sections/extendedCFA.tex}\label{sec:extendedCFA} \section{Conclusions}\label{sec:conclusion} \input{sections/concl.tex} \bibliographystyle{eptcs}
{'timestamp': '2016-08-12T02:01:38', 'yymm': '1608', 'arxiv_id': '1608.03327', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03327'}
arxiv
\section{Introduction} The growth of media content combined with advances in machine learning, vision, and robotics has catalyzed the growth and demand for applications such as document retrieval~\cite{document_distances}, content-based search~\cite{content_based_search}, and deduplication~\cite{dedup}. In 2010, Internet users had shared more than 260 billion images on Facebook~\cite{facebook-photos}, and, by 2014, uploaded upwards of 300 hours of YouTube per minute~\cite{youtube-statistics}. Furthermore, the rate of multimedia content generation is projected to grow exponentially~\cite{rebooting-the-it-revolution}. To make these volumes of data searchable, applications rely on similarity search which manifests as k-nearest neighbors (kNN)~\cite{google-images, facebook-search}. The kNN algorithm consists of many parallelizable distance calculations and a single global top-k sort. While computationally very simple, scaling kNN beyond a single node is challenging as the algorithm is memory bound in both CPUs and GPUs. Distance calculations are relatively cheap and task parallel but moving feature vector data from memory to the compute device is a huge bottleneck. Moreover, this data is used only once per kNN query and discarded, and the result of a kNN query is only a handful of identifiers. In order to amortize data movement cost, queries are typically batch processed which has intrinsic limitations when constrained to meet tight latency targets. Because of its significance, generality, parallelism, simplicity, and small result set, kNN is an ideal candidate for near-data processing. The key insight is that by exploiting higher bandwidths and applying large data reductions near memory we can substantially reduce data movement requirements over interconnects such as PCIe. There have been many proposals for near-data processing and processing-in-memory (PIM) in the past~\cite{McKee95,iram,flexram,activepages}. In this paper, we evaluate kNN on the Micron Automata Processor (AP), a recent PIM architecture for high speed automata evaluation. Most prior work on the AP has focused on the domain of pattern mining such as biological motif search~\cite{ap-motif-search}, frequent itemset mining~\cite{ap-apriori}, and graph processing~\cite{ap-graph}. In contrast, our work is the first to explore and evaluate similarity search on the AP which presents unique design challenges and opportunities. We propose a novel nondeterministic finite automata design for kNN using temporal encodings and show current generation hardware can achieve $\sim$50$\times$ performance over multicore processors. We also evaluate AP performance and energy efficiency against competing FPGA and GPU solutions. We then propose mutually orthogonal optimization techniques and architectural extensions which can yield an additional $\sim$70$\times$ potential performance improvement which can make the AP a competitive alternative to existing heterogeneous computing substrates. Our work makes the following contributions: (1) We present a novel automata design which exploits temporal encodings to solve the sorting phase of kNN in linear time with respect to dimensionality (as opposed to linear time with respect to dimensionality \emph{times} cardinality). (2) We introduce automata design optimizations that can reduce the resource footprint and improve throughput on future generation APs. (3) We propose and evaluate the potential of architectural extensions to augment the capabilities and efficiency of the AP architecture. The paper is organized as follows. Section~\ref{sec:background} provides background on the AP and kNN. Section~\ref{sec:automata-design} presents our novel kNN automata design and Section~\ref{sec:methodology} outlines evaluation methodology. Section~\ref{sec:evaluation} presents performance and energy efficiency results. Section~\ref{sec:optimizations} presents automata optimization techniques, Section~\ref{sec:analysis} proposes AP architectural extensions, and Section~\ref{sec:related-work} highlights related work. \section{Background} \label{sec:background} \subsection{k-nearest neighbors} \label{sec:knn} Performing similarity search between a query and a dataset of candidate vectors is done through k-nearest neighbors (kNN), and consists of distance calculations and global top-k sorting (Algorithm~\ref{knn_algorithm}). Intuitively, the goal of kNN is to find the closest neighbors for a \textit{query vector} against a set of candidate vectors in a database. A query and candidate vector are considered more similar if the metric space distance between them is smaller. For instance, two images in content-based search~\cite{content_based_search} are considered more similar if the distance between their feature descriptor vectors is smaller. Feature vectors are generated by applying feature extractors like word embeddings~\cite{document-distances}, scale invariant feature transforms (SIFT)~\cite{sift}, or semantic embeddings~\cite{tagspace} to target media. The exact kNN algorithm scans through the dataset for each query/candidate pair resulting in a total complexity of $O(qnd)$ where $q$ is the number of query vectors, $n$ is the number of dataset vectors, and $d$ is the vector dimensionality. The algorithm presents two opportunities to exploit parallelism: query level parallelism where multiple queries are batch processed, and data level parallelism where multiple dataset vectors are processed in parallel for a single query. \begin{algorithm} \begin{algorithmic} \FOR {each query $q \in Q$} \STATE Result set $R \leftarrow \emptyset$ \FOR {each point $p \in$ dataset $D$} \STATE $d \leftarrow distance(p, q)$ \STATE $R = R \cup (ID = p, dist = d)$ \ENDFOR \STATE Sort $R$ by $dist$ \RETURN Top $k$ points $\in R$ with smallest $dist$ \ENDFOR \end{algorithmic} \caption{kNN} \label{knn_algorithm} \end{algorithm} Approximate variants of kNN employ spatial indexing structures to trade accuracy for run time by using heuristics to prune the search space. We consider three approximate kNN algorithms: randomized kd-trees, hierarchical k-means, and locality sensitive hashing~\cite{flann, lsh}. In randomized kd-trees, the dataset is indexed across multiple parallel trees which each partition the dataset based on dimensions with highest variance. The index structure size scales exponentially with depth so the height of the tree is often constrained. Each leaf in the tree is associated with a bucket of candidate points; when a traversal reaches a leaf, the associated bucket is linearly scanned to compute the result. Similarly, hierarchical k-means generates an index by hierarchically partitioning the dataset into clusters. Unlike randomized kd-trees, traversing the k-means index requires a distance calculation at each node to determine the next traversal. Again, each leaf in the index represents a bucket of candidate points which is scanned linearly after the traversal. Finally, locality sensitive hashing (LSH) uses a set of hash functions to hash similar query vectors into the same bucket~\cite{lsh}; the bucket each vector hashes to is again linearly scanned at search time. Automata processors do not have hardened arithmetic units so implementing Euclidean distance is inefficient. Instead, we subset our design space by evaluating Hamming distances which map well to the AP. Real-valued vectors can be converted to Hamming space by applying techniques like iterative quantization (ITQ)~\cite{gong2011ITQ}. Some information in the features is lost as quantization narrows the possible dynamic range of feature values. In practice, Hamming codes have been shown to be a viable alternative to Euclidean space encodings~\cite{lazebnik09, wang12, facebook-search}. For instance, work by Lin et al.~\cite{lin16} shows that despite the loss of accuracy, well-crafted Hamming codes can achieve competitive or even better results compared to those of full precision representations. In this paper, we assume dataset vectors are quantized offline using techniques like ITQ which removes this process from the critical path of the kNN kernel. \subsection{Micron Automata Processor} \label{sec:ap-description} { \setlength{\belowcaptionskip}{-15pt} \begin{figure*} \centering \includegraphics[width=0.9\linewidth]{system-diagram.pdf} \caption{System architecture of AP for kNN. (a) Software stack for an AP application. (b) Host processor system. (c) Internal architecture of AP device. (d) Data vectors are encoded into NFAs and mapped to STEs.} \label{system-architecture} \end{figure*} } \noindent\textbf{Hardware architecture.} The AP is a non-von Neumann architecture which uses a nondeterministic finite automata (NFA) driven execution model~\cite{MAP}; the system architecture is shown in Fig.~\ref{system-architecture}. A typical AP device is composed of four \textit{ranks} each containing eight automata processors. The eight automata processors are further subdivided into two half cores (AP cores). Each half core is composed of 96 \textit{AP blocks} and each block contains 256 state transition elements (STEs); this results in a maximum of 24,576 STEs per half core or 1,572,864 STEs per device. In the context of an NFA, each STE implements one state. Since NFAs cannot span AP cores, the maximum size automata that can be implemented is limited to 24,576 states. A central reconfigurable routing matrix (not shown) is responsible for connecting STEs to implement different NFAs. Each AP block also contains four counters, 12 boolean elements, and a maximum of 32 reporting STEs. Counters have an increment-by-one and reset port. The increment-by-one port increments the internal count when the connected state is active while the reset port resets the internal count. Counters are always programmed to user-specified threshold values and activate downstream states if the internal count exceeds this static threshold; counters cannot be incremented by more than one and do not expose internal count values. Finally, each AP block contains \textit{boolean elements} which can each be programmed to function as any standard two input logic gate. \noindent\textbf{Programming model.} To program the AP, applications must be converted to equivalent NFAs expressed in terms of states, counters, and boolean elements. Applications can either be compiled to NFAs by supplying a Perl Compatible Regular Expression (PCRE), or an XML-based Automata Network Markup Language (ANML) file which contains an NFA specification. For applications that cannot be easily expressed as PCREs, the programmer must specify an ANML file. The primary strength of the AP architecture is its capacity for high internal bandwidth and parallel computing; to fully harness this compute and bandwidth, it is ideal to instantiate many NFAs in parallel. Each state in the NFA is associated with an 8-bit symbol or set of 8-bit symbols defined by a PCRE. A state is activated when the input symbol matches the symbol set associated with it and any previous state connected to it is active on the previous time step. The sequence of symbols is driven by a \textit{symbol stream} from the host processor; NFA state activations themselves cannot be combined to form a new symbol stream from inside the AP. Each NFA also has specially designated \textit{start states} and \textit{reporting states} which are used to initiate state activations and return results from the AP respectively. Start states do not need an upstream state to be active when matching the input symbol, and activate whenever the input symbol matches its symbol set. Reporting states generate a signal which returns a unique identification number associated with it, and the offset (i.e. cycle accurate time stamp) within the symbol stream at which the state was activated. This information is then used by a host processor application to resolve the result of the calculation. \noindent\textbf{System integration.} An AP device interfaces to a host processor over a PCIe x8 Gen 3 interface (much like a GPU or FPGA). The host processor is responsible for configuring the device, driving the symbol streams, and processing the signals generated by the reporting states. Typically a host processing application will use provided APIs to operate the AP. \subsection{Automata Design Constraints} \noindent\textbf{Arithmetic operations are inefficient.} The AP fabric does not contain hardened arithmetic units. While STEs can be treated as lookup tables, implementing arithmetic units with lookup tables is inefficient and difficult to program. This makes it difficult for the AP to calculate Euclidean distances. On the other hand, Hamming distance and Jaccard similarity on the AP is well-documented and can be efficiently implemented~\cite{ap-hamming-distance}. \noindent\textbf{No nested finite automata.} The programming model for the AP assumes that the symbol stream that drives NFAs is provided exclusively by an external host processor. This means, state activations or output values from an NFA cannot be combined to dynamically form a symbol stream to drive another nested NFA. \noindent\textbf{Symbol streams cannot be dynamically modified.} The external symbol streams that drive the NFAs in the AP cannot be modified; thus symbol streams must be defined statically before being streamed into the AP. This eliminates any feedback interactions between the NFAs and symbol stream, making constructs such as dynamically inserting a reset symbol into the symbol stream impossible. \section{Proposed Automata Design} \label{sec:automata-design} We now present our automata design for Hamming distance kNN which is subdivided into two components: \textit{Hamming macros} for distance calculations and \textit{sorting macros} to sort distance scores. \subsection{Hamming Macros} The highly parallelizable distance calculation tasks in kNN are an excellent match for the AP. In von-Neumann architectures, typically the dataset vectors are streamed from memory and the number of calculations performed is limited by the rate at which vectors can be streamed from memory; for $n$ vectors each with $d$ dimensions this takes $O(nd)$ time to complete all the distance calculations per query. For the AP we instead stream the queries to the dataset vectors encoded in NFAs on the AP, and perform comparisons against all candidate vectors in parallel much like a ternary content addressable memory. This allows the AP to exploit the theoretical maximal degree of data parallelism in the context of kNN and reduces the run time to $O(d)$ per query; the only limitation is the number of spatial resources required to implement the large number of parallel automata. \begin{figure}[!b] \centering \includegraphics[width=\linewidth]{full-hamming-macro.pdf} \caption{Automata design encoding the vector $x = \{x_0, x_1, x_2, x_3, .., x_{d-1}\}$. (a) Hamming macro. (b) Sorting macro. (c) Symbol stream for a query $q = \{q_0, q_1, q_2, ..., q_{d-1}\}$.} \label{full-hamming-macro} \end{figure} We instantiate one Hamming macro per vector NFA in the dataset as shown in Fig.~\ref{full-hamming-macro}a; each Hamming macro computes the \textit{``inverted Hamming distance''} or the number of dimensions minus the Hamming distance. Effectively, this measures the similarity between the feature vector and the query. Each Hamming macro encodes a unique feature vector from the dataset and operates in parallel with all other Hamming macros. Since Hamming macros can be replicated arbitrarily, the factor of parallelism we can achieve is only limited by the capacity of the AP. The Hamming macro is composed of a \textit{guard state}, \textit{compute states}, and \textit{collector states}. The guard state is a designated start state which is responsible for detecting the start of file (SOF) symbol; this SOF symbol demarcates the start of an input query vector and protects the rest of the NFA from unintentional state activations. The compute states are composed of a sequence of ``*'' PCRE states\footnote{``*'' states match any symbol.} and matching states; each matching state activates when the input query vector value matches for the dimension in the encoded dataset vector. To compute the inverted Hamming distance, states which correspond to matches are first fed into one or more collector states that effectively function as a large OR reduction. The collector states then drive a counter which we refer to as a \textit{inverted Hamming distance counter} in the sorting macro. This counter keeps track of how many matches occurred. For larger dimensional vectors we implement the collector states as a reduction tree of ``*'' states to limit the maximum state fan in and improve routability. \subsection{Sorting Macros} The second phase of kNN consists of distilling the distance scores across every element in the dataset to the top $k$ neighbors. Typically on von-Neumann architectures this is done using priority queue insertions which takes $O(n\log n)$ time per query, or alternative algorithms like k-selection. For the AP, this must be conveyed using the activation signals from reporting states which consist of the unique state ID that map back to the feature vector, and the cycle offset into the symbol stream on which the state activated. Furthermore, the sorting latency must be comparable to that of the Hamming macros otherwise it will dominate execution time. We use a temporally encoded sort inspired by~\cite{race-logic} and~\cite{spaghetti-sort} which yields an $O(d)$ time sort. Our sorting approach is based on the fact that vectors with lower Hamming distances have a higher inverted Hamming distance score. To sort the vectors in parallel, we uniformly increment the inverted Hamming distance counters until they reach a static threshold equal to $d$; we use the pulse mode on the counter so that when the threshold is reached, a single cycle pulse activation is emitted from the counter. Hamming macros which are most similar to the query vector have a higher inverted Hamming distance and activate their reporting states first. As a result, the temporal order of the reporting state activations is sorted by increasing Hamming distance. Note that the total number of cycles required to perform this temporally encoded sort is $O(d)$ making the sort latency the same as the Hamming macro latency. To support temporal sort, a \textit{sorting macro} shown in Fig.~\ref{full-hamming-macro}b is appended to the Hamming macro. To provide time for the sort to execute, we pad the symbol stream with filler symbols (\^{}EOF) for $O(d)$ cycles (Fig.~\ref{full-hamming-macro}c). A \textit{sort state} is responsible for waiting until an end of file (EOF) symbol is detected before triggering the EOF state which resets the counter. The sort state also doubles as an unconditional increment signal for the inverted Hamming distance counter to perform the temporally encoded sort. A \textit{reporting state} after the counter is responsible for reporting at which offset the inverted Hamming distance counter exceeded the threshold and the unique state ID assigned to that reporting state. The unique state ID is used to reverse lookup which dataset vector it corresponds to before returning the result. The concrete behavior of a \textit{single} combined Hamming and sorting macro is best illustrated with an example execution shown in Fig.~\ref{large-example}. In this example, we show the state activations at each time step for an NFA which encodes the data vector \{1, 0, 1, 1\} and a symbol stream which encodes the query vector \{1, 0, 0, 1\}. The activations during time steps 2 to 6 drive the Hamming distance calculation while time steps 7 to 11 drive the temporally encoded sort by uniformly incrementing the inverted Hamming distance counters towards the threshold. The temporally encoded sort across vector NFAs is illustrated in Fig.~\ref{race-sort} which shows the NFA execution of two different data vectors. In this example, vector $A$ has an inverted Hamming distance of 3 while vector $B$ has an inverted Hamming distance of 2. During the sorting phase, the counter for vector $A$ reaches the target threshold $d$ first and triggers the reporting state for vector $A$ before vector $B$. The resulting temporal order of the reporting state activations thus correctly encodes that $A$ has a lower Hamming distance than $B$ since $A$ reported first. \begin{figure*} \centering \includegraphics[width=\linewidth]{large-example.pdf} \caption{Example execution for an NFA encoding the data vector \{1, 0, 1, 1\} and a symbol stream encoding the query vector \{1, 0, 0, 1\}. Grey states indicate active states or ports at each time step. The counter activates at time step t = 8 and emits a single activation pulse to the reporting state which activates the next cycle (t = 9).} \label{large-example} \end{figure*} { \setlength{\belowcaptionskip}{-10pt} \begin{figure*} \centering \includegraphics[width=\linewidth]{race-logic.pdf} \caption{Temporally encoded sort for two vectors A = \{1,0,1,1\} and B = \{0,0,0,0\} for a query vector C = \{1,0,0,1\}. The time step at which each state is activated is indicated next to each state. Vector A activates its reporting state first because it has a higher inverted Hamming distance.} \label{race-sort} \end{figure*} } \subsection{Partial Reconfiguration} \label{sec:partial-reconfiguration} The STE resources required by our design scales with both dataset size and vector dimensionality. This means the capacity of the AP limits the total number of vectors that can be processed per configuration. To scale to arbitrarily large datasets, we exploit the reconfiguration capability of the AP which allows the AP to be reconfigured much like an FPGA. We assume these additional configurations are precompiled into a set of board images. Once the queries are streamed through the first dataset partition, a reconfiguration prepares the AP with the next dataset partition until the entire dataset is processed. This requires the host processor to also keep track of intermediary results per query across board reconfigurations as sort results are computed. Current generation APs (Gen 1) require 45 ms~\cite{ap-apriori} per reconfiguration but next generation APs (Gen 2) are projected to be two orders of magnitude faster ($\sim$100$\times$)~\cite{ap-personal} which is closer to that of production-grade FPGAs~\cite{papadimitriou11}. \subsection{Implementing Spatial Indexing Structures} So far our automata design has been constrained to implementing linear kNN search. While some index traversals are possible to express as automata, it is more efficient to factor the index traversal out to the host processor in software. Since the AP is a spatial architecture, every encoded vector NFA needs to evaluate whether it is part of the pruned search space by traversing an index NFA. In practice, only a few index traversals per query will be relevant making a vast majority of the traversals unnecessary. Instead, the host processor can traverse the index and pick which set of vector NFAs to load and query. This modification is synergistic with kNN since the number of dataset vectors supported by each AP board configuration provides a natural bucket size limit for each indexing structure. Finally, by offloading index traversal to the host processor, we can also support any arbitrary spatial indexing structures. \section{Evaluation Methodology} \label{sec:methodology} To evaluate the performance and energy efficiency gains of the AP, we compare against the CPUs, GPUs, and FPGAs shown in Table~\ref{evaluated-platforms}. The Gen 1 AP board is not a production-ready platform so in order to provide a fair evaluation of the AP's potential, we provide a Gen 2 performance evaluation with better partial reconfiguration times. We also provide a more aggressive evaluation using optimizations and extensions proposed in later sections (AP Opt+Ext). AP Gen 2 more accurately reflects the capabilities of a production ready platform while AP Opt+Ext reflects an upper bounds with design optimizations and architectural extensions. \begin{table} \centering \caption{Evaluated platforms.} \begin{tabular}{@{}ccccc@{}} \toprule Platform & Type & Cores & Process (nm)& Clock (MHz) \\ \midrule Xeon E5-2620 & CPU & 6 & 32 & 2000 \\ Cortex A15 & CPU & 4 & 28 & 2300 \\ Tegra Jetson K1 & GPU & 192 & 28 & 852 \\ Titan X & GPU & 3072 & 28 & 1075 \\ Kintex-7 & FPGA & N/A & 28 & 185 \\ Automata Processor & AP & 64 & 50 & 133 \\ \bottomrule \end{tabular} \label{evaluated-platforms} \end{table} \subsection{Workload Parameters} The run time of our NFA design scales with dimensionality so we use different feature vector lengths. Practical vector dimensionality for feature descriptors like word embeddings~\cite{document-distances}, SIFT~\cite{sift}, and semantic embeddings~\cite{tagspace} range from 64 to 256; higher dimensional feature descriptors like those produced by AlexNet~\cite{alexnet} can be reduced using techniques like principle component analysis~\cite{pca}. Past literature also shows the number of nearest neighbors $k$ ranges anywhere between 1 (exclusively nearest neighbor) and 20~\cite{sift, document-distances, motion-planning, how-many-results}. The parameter sets we choose to evaluate are shown in Table~\ref{knn-parameters} for 4096 queries. \begin{table}[t!] \centering \caption{kNN workload parameters.} \begin{tabular}{@{}ccc@{}} \toprule Workload & Dimensionality & Neighbors \\ \midrule kNN-WordEmbed & 64 & 2 \\ kNN-SIFT & 128 & 4 \\ kNN-TagSpace & 256 & 16 \\ \bottomrule \end{tabular} \label{knn-parameters} \end{table} \subsection{Micron Automata Processor} To estimate the performance of the AP, we simulate the design using the AP SDK 1.7.26 since full AP driver stacks at the time of writing were not available. We implemented our designs in ANML, validated our design using the AP Workbench, and compiled each design to obtain resource utilization and frequency estimates. We assume that the host processing program can operate concurrently (non-blocking API calls) with the AP much like how a CUDA program offloads to GPUs. Since datasets in kNN applications are typically static, we do not include compile times since compilation can be done offline. To estimate power, we connected a power meter to a single rank AP, and measured static and load power consumption; dynamic power is computed as the average load minus average static power and scaled to reflect a four rank device. To estimate energy consumption for the AP we take the simulated run time and multiply by the dynamic power. We then apply linear scaling factors to normalize the 50 nm AP lithography~\cite{ap-technode} to match the 28 nm lithographies of competing baselines. \subsection{CPU, GPU, and FPGA} For CPU baselines, we use the Hamming distance implementation from the Fast Library for Approximate Nearest Neighbors (FLANN)~\cite{flann}. For GPU baselines, we modify an off-the-shelf CUDA implementation~\cite{gpu-knn} that uses a 32-bit XOR and population count (POPCOUNT) operation instead of a 32-bit Euclidean distance operation. Run time is recorded as wall clock time and dynamic power is measured using a power meter by taking the difference between the load and idle power. Energy consumption is estimated by multiplying dynamic power by run time. To benchmark indexing times for spatial data structures, we use custom implementations and an off-the-shelf ITQ LSH implementation~\cite{lshbox}. For simplicity, we use four hash tables for LSH and four parallel kd-trees; for kd-trees and k-means each tree traversal checks one bucket of vectors. For FPGAs, we implement an AXI4-Stream compliant fixed-function kNN accelerator in Verilog for a Xilinx Kintex-7-325T. The accelerator architecture consists of a scratchpad, XOR/POPCOUNT distance unit, and hardware priority queue. It also processes multiple queries in parallel; data vectors are streamed through the core, once per batch of queries. We use Vivado 2014.4 to synthesize, place, and route the design, and report the estimated post-placement and route power using worst case activity factors. To estimate run time, we simulate the design using the Vivado simulator, and estimate power using the Vivado power analyzer. \section{Results} \label{sec:evaluation} \subsection{Resource Utilization} We first evaluate resource utilization since the number of vectors that can be processed per board configuration will affect AP performance. We report the total rectangular block area based on compilation reports generated by the \code{apadmin} tool. For each of our parameter sets kNN-WordEmbed, kNN-SIFT, and kNN-TagSpace, we observe resource utilizations of 41.7\%, 90.9\%, and 78.6\% of the total resource capacity respectively~\footnote{For kNN-WordEmbed, we are limited by the theoretical peak PCIe bandwidth and thus cannot exploit all the resources.}. This equates up to 128 Kb of encoded data per board configuration on current generation APs (1024$\times$128 dimensions or 512$\times$256 dimensions). Finally, we note that resource utilization does not depend on the number of neighbors $k$ since sorting does not require additional automata states. \subsection{Run Time Performance} We now compare AP run time performance against competing solutions. Run time performance comparisons are shown in Table~\ref{small-dataset} and Table~\ref{large-dataset} for a small dataset (512-1024 points) and large dataset ($2^{20} \approx$ 1 million points) respectively. The small dataset illustrates the performance of the AP for kNN problems that fit on one AP board configuration. For the small dataset, the AP achieves an order of magnitude performance improvement over competing CPU solutions. This performance improvement can be attributed to a combination of the parallel processing capacity of the AP, and temporally encoded sort which dramatically lowers the run time of the sorting step from $O(n\log n)$ to $O(d)$. We observe poor GPU performance likely due to poor blocking of the binarized data; since vectors are now 32 times smaller (1 bit per dimension), the finer grained memory accesses are less optimal for the off-the-shelf baseline. In contrast, the large dataset reflects the performance for kNN problems that exceed the capacity of a single AP board. For the large dataset, AP Gen 1 performance degrades due to dynamic reconfiguration overheads which account for upwards of 98\% of the execution time. To quantify the impact of this bottleneck, we provide a second estimate with AP Gen 2 reconfiguration latencies ($\sim$100$\times$ better). Our results show that the reconfiguration time improvement yields 19.4$\times$ performance improvement between Gen 1 and Gen 2, and shifts the bottleneck back to the computation. Finally, we also show the projected performance of the AP with the automata optimizations and architectural extensions presented in Section~\ref{sec:optimizations} and~\ref{sec:analysis} (AP Opt+Ext). { \setlength{\belowcaptionskip}{-10pt} \begin{table}[!t] \centering \caption{kNN Performance and Energy Efficiency for Small Datasets.} \label{small-dataset} \begin{tabular}{@{}cccccc@{}} \toprule \multicolumn{6}{c}{\textbf{Run Time Performance (ms) - Lower is Better}} \\ \midrule kNN-Workload & \begin{tabular}[c]{@{}c@{}}Xeon\\ E5-2620\end{tabular} & \begin{tabular}[c]{@{}c@{}}Cortex\\ A15\end{tabular} & \begin{tabular}[c]{@{}c@{}}Jetson\\ TK1\end{tabular} & \begin{tabular}[c]{@{}c@{}}Kintex\\ 7\end{tabular} & \begin{tabular}[c]{@{}c@{}}AP\\ Gen 1\end{tabular} \\ WordEmbed ($n$=1024) & 23.33 & 103.63 & 125.80 & 1.89 & 1.97 \\ SIFT ($n$=1024) & 37.50 & 191.44 & 155.94 & 3.78 & 3.94 \\ TagSpace ($n$=512) & 33.97 & 185.34 & 160.15 & 4.33 & 7.88 \\ \midrule \multicolumn{6}{c}{\textbf{Energy Efficiency (query / Joule) - Higher is Better}} \\ \midrule kNN-Workload & \begin{tabular}[c]{@{}c@{}}Xeon\\ E5-2620\end{tabular} & \begin{tabular}[c]{@{}c@{}}Cortex\\ A15\end{tabular} & \begin{tabular}[c]{@{}c@{}}Jetson\\ TK1\end{tabular} & \begin{tabular}[c]{@{}c@{}}Kintex\\ 7\end{tabular} & \begin{tabular}[c]{@{}c@{}}AP\\ Gen 1\end{tabular} \\ WordEmbed ($n$=1024) & 3344 & 4941 & 27133 & 579214 & 110445 \\ SIFT ($n$=1024) & 2081 & 2674 & 21889 & 289607 & 44603 \\ TagSpace ($n$=512) & 2297 & 2762 & 21314 & 253406 & 22301 \\ \bottomrule \end{tabular} \end{table} } { \captionsetup{skip=-10pt} \begin{table*}[!t] \centering \caption{kNN Performance and Energy Efficiency for Large Datasets.} \label{large-dataset} \begin{tabular}{@{}ccccccccc@{}} \\ \toprule \multicolumn{9}{c}{\textbf{Run Time Performance (s) - Lower is Better}} \\ \midrule Workload & Xeon E5-2620 & Cortex A15 & Jetson TK1 & Titan X & Kintex 7 & AP Gen 1 & AP Gen 2 & AP (Opt+Ext) \\ WordEmbed & 19.89 & 109.06 & 16.09 & 0.99 & 1.85 & 48.10 & 2.48 & 0.039 \\ SIFT & 33.18 & 199.5 & 16.73 & 1.02 & 3.69 & 50.11 & 4.50 & 0.062 \\ TagSpace & 60.12 & 382.82 & 16.41 & 1.03 & 7.38 & 108.31 & 17.07 & 0.23 \\ \midrule \multicolumn{9}{c}{\textbf{Energy Efficiency (query / Joule) - Higher is Better}} \\ \midrule Workload & Xeon E5-2620 & Cortex A15 & Jetson TK1 & Titan X & Kintex 7 & AP Gen 1 & AP Gen 2 & AP (Opt+Ext) \\ WordEmbed & 3.92 & 4.69 & 212.14 & 83.84 & 593.89 & 4.53 & 87.81 & 1737.92 \\ SIFT & 2.35 & 2.57 & 204.02 & 81.94 & 296.95 & 4.34 & 48.40 & 1091.86 \\ TagSpace & 1.30 & 1.34 & 208.00 & 81.05 & 148.47 & 1.62 & 10.20 & 236.30 \\ \bottomrule \end{tabular} \end{table*} } We now evaluate and compare the efficacy of spatial indexing techniques relative to equivalent CPU baselines. We use an analytical model to estimate run time by benchmarking the index traversals on the CPU, and adding it to estimated AP reconfiguration and simulated run time. In our model, we batch searches to the same bucket where possible and report the average run time over several iterations; each bucket size is set to the capacity of one AP board configuration (512-1024 points). Decreasing bucket sizes further would not yield run time improvements, underutilize the AP, and unnecessarily lower search accuracy since less data is scanned. Table~\ref{spatial-indexing} shows the relative performance of the AP for indexing techniques compared to single threaded CPU baselines for a large kNN-TagSpace workload. For indexing, we observe poorer performance for AP Gen 1 because reconfiguration time dominates run time. For for Gen 2, we observe good run time improvements since run time is now dominated by the linear bucket scan. { \begin{table}[!ht] \centering \caption{Relative speeds up for spatial indexing techniques on kNN-TagSpace.} \begin{tabular}{@{}cccc@{}} \toprule Indexing & ARM + AP Gen 1 & ARM + AP Gen 2 \\ \midrule Linear (No Index) & 16$\times$ & 91$\times$ \\ KD-Tree & 0.89$\times$ & 106$\times$ \\ K-Means & 0.88$\times$ & 120$\times$ \\ MPLSH & 0.62$\times$ & 3.5$\times$ \\ \bottomrule \end{tabular} \label{spatial-indexing} \end{table} } \subsection{Energy Efficiency} The estimated energy efficiency of the AP for the small and large datasets are shown in Table~\ref{small-dataset} and Table~\ref{large-dataset} respectively. Our results show that the Gen 1 AP can provide up to 43$\times$ energy efficiency improvement over general purpose cores and is largely in line with the run time improvements we observe. When compared to production FPGA and GPU platforms, our results show that the Gen 1 AP is again severely outperformed due to high reconfiguration overheads. However, with Gen 2 reconfiguration times the AP achieves competitive energy efficiency and is within one order of magnitude of competing production platforms. With architectural extensions and design optimizations on next generation devices, we expect the AP could potentially surpass FPGA fabrics in energy efficiency. \section{Automata Optimization Techniques} \label{sec:optimizations} We now introduce three mutually orthogonal automata design optimizations: \textit{vector packing}, \textit{symbol stream multiplexing}, and \textit{statistical activation reduction}. \subsection{Vector Packing} To more efficiently utilized the STE resources, we propose \textit{vector packing}. The key insight is that Hamming macros share common portions which can be combined by overlaying them over the same base NFA to reduce resource utilization. Fig.~\ref{vector-packing} shows how to pack Hamming macros encoding the vectors $\{1, 1, 0, 1\}$ (Fig.~\ref{vector-packing}a) and $\{1, 0, 0, 0\}$ (Fig.~\ref{vector-packing}b) into a single NFA (Fig.~\ref{vector-packing}c). We refer to the boxed portion in Fig.~\ref{vector-packing}c as a \textit{vector ladder} that is the base NFA used to overlay vectors on. For each vector packed, we instantiate extra collector states, and sorting macros and connect them to the appropriate states in the vector ladder. In theory, with unlimited routing, all dataset vectors can be packed into a single NFA but in practice we are limited by the maximum state in-degree, and NFA size. So instead, vectors would be packed until we reach one of these limitations; we would then start a new NFA and repeat until all vectors are processed. We evaluate vector packing by running a microbenchmark which places and routes eight vectors across 32, 64, and 128 dimensions, and compare their resource utilizations. Surprisingly, we find that vector packing is ineffective in practice at reducing the resource footprint when compared to the theoretical gains projected by a simple analytical model. We believe this is due to the increased routing pressure which imposes reduced compilation feasibility. For high dimensional designs, we find that the compiler has difficulty routing the design leading to placed but only partially routed compilations. The routing pressure is most likely due to the vector ladder which introduces many states with high fan outs. However, we expect that in future generation APs and with tool chain maturity, that vector packing will eventually provide viable improvements. To estimate the potential improvements, we build a simple analytical model where each NFA state incurs one STE resource cost. The maximum potential savings is then computed as the resource cost of the original NFA over the resource cost of the vector packed NFA. { \setlength{\belowcaptionskip}{-10pt} \begin{figure*}[!ht] \centering \includegraphics[width=\linewidth]{./vector-packing.pdf} \caption{Vector packing for two distinct Hamming macros. (a) Hamming macro encoding \{1, 1, 0, 1\}. (b) Hamming macro encoding \{1, 0, 0, 0\}. (c) Combined NFA encoding both vectors.} \label{vector-packing} \end{figure*} } \subsection{Symbol Stream Multiplexing} Another inefficiency in our automata design is that each state in the vector ladder only effectively uses one bit of information in the symbol stream (the symbol is either 0 or 1). However, symbol streams are 8 bits wide so processing a single query vector at a time is wasteful. To improve the throughput of the design, the unused bits in the symbol stream can encode additional parallel query vectors which can provide up to an 7$\times$ throughput improvement by exploiting query level parallelism. To support parallel queries, up to seven parallel NFAs for each dataset vector can be instantiated where each NFA PCRE is programmed to process a different bit slice of the symbol stream. We cannot achieve an 8$\times$ improvement because of special symbols like the SOF and EOF. To discriminate among the bits in the symbol, the STEs can be programmed to effectively perform a ternary match similar to how ternary matches are encoded on TCAMs. This can be achieved by exhaustively encoding all extended ASCII characters which satisfy the ternary match. For instance, an NFA which matches the first bit in the symbol as 1 would require a PCRE corresponding with the ternary match \code{0b*******1} (where \code{*} denotes a ternary match). Similarly, the PCRE for a STE that matches 0 as the first bit would be \code{0b*******0} A similar set of ternary matches can be constructed to discriminate among other bit slices in the stream. Finally, symbol stream multiplexing is orthogonal to vector packing since it only requires duplicating existing NFA structures and replacing STE symbols. \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{./stream-slicing.pdf} \caption{Symbol stream multiplexing: NFA STEs are replicated and encoded to discriminate among different bit slices of the symbol stream.} \label{stream-slicing} \end{figure} For the current generation AP, there is neither sufficient resources, nor sufficient external bandwidth to implement stream multiplexing. Replicating the base design 7$\times$ is infeasible since our design already uses 41-91\% of the board capacity. Similarly, replicating the number of reporting states 7$\times$ requires in excess of 200 Gbps of external PCIe bandwidth to convey all the activations. However, with future technology scaling, higher board capacities, better PCIe interconnects, and statistical reduction (discussed next), stream multiplexing should become viable. \subsection{Statistical Activation Reduction} As the sorting step completes, the AP reports state activations to the host processing unit. We assume the AP communicates state activations by using a bit mask and reporting an offset; the offset indicates which cycle in the symbol stream the activations correspond to. Since activations are often sparse, the bit mask can be compressed to use a sparse vector encoding (with 32-bit offsets). For a kNN design that encodes $n$ vectors on the AP, we expect $32 \times n$ bits to convey the activations plus $32 \times d$ bits to convey the activation time step. A single query (which has a latency of $2d$ cycles), requires the AP to convey $32 \times (n + d)$ bits every $2d \times 7.5 ns$ (133 MHz design). This amounts to 36.2, 18.1, and 9.0 Gbps of sustained external bandwidth for kNN-WordEmbed, kNN-SIFT, and kNN-TagSpace respectively which are significant fractions of the PCIe Gen 3$\times$ 8 bandwidth (63 Gbps). Ideally, we want to suppress state activations after the top $k$ results from the temporal sort have been communicated. However, dynamically inserting an EOF symbol to reset the automata is not possible (Section~\ref{sec:ap-description}), and building an NFA to generate a global reset signal would couple all NFAs and exceed the maximum NFA size. So instead, we propose a combination of local reductions and statistical approximations to suppress additional state activations while still providing mostly correct results. This can be done by first partitioning vector NFAs into groups of $p$ NFAs. For a dataset $D$ this yields $R = |D|/p$ NFA partitions. For each partition, we use a counter to track how many reporting state activations have occurred locally. If the global number of desired neighbors is $k$, for each group of Hamming macros we only report the top $k'$ results where $k' < k$ and $k' \times R > k$. This is can be done by resetting all of the inverted Hamming distance counters after $k'$ reporting states have activated within a set of macros shown in Fig.~\ref{reduction-macro}. Each of the $k'$ local result sets can then be sorted globally on the host processing unit. The key insight is that instead of reporting all $p$ state activations per set, we only need to report $k'$ states which provides a bandwidth reduction by a factor of $p/k'$ and still maintain mostly correct results. For appropriately set values of $k'$, $k$, and $p$, the probability that the global result set does not contain the global top $k$ neighbors can be made arbitrarily small. Even for failing cases, the result sets returned by this approximation will be mostly correct. We use a statistical model to determine how much data reduction is achieved without compromising accuracy. For each configuration, we randomly generate dataset and query vectors, partition the dataset vectors, execute local kNN, and perform global top-$k$ sort to determine if exact kNN results are computed. We repeat the process 100 times to determine statistically how often an incorrect result is returned. Table~\ref{statistical-model} shows results for different values of $k'$ and $k$ used in our evaluation. Our results show that for reasonable parameters we can achieve good bandwidth reductions and still achieve acceptable result accuracy. Finally, we note this optimization is synergistic with vector packing since vector packing provides a natural grouping of vectors. { \begin{figure}[!t] \centering \includegraphics[width=\linewidth]{./state-reduction.pdf} \caption{Automata for four vectors with reduction states and counter. The Local Neighbor Counter resets all other counters suppressing unnecessary activations.\protect\footnotemark} \label{reduction-macro} \end{figure} } \footnotetext{Edges from sorting macro to counter enables not shown for clarity.} { \captionsetup{skip=-10pt} \begin{table}[!t] \centering \caption{Percentage of incorrect results out 100 randomized runs for $p=16$, $n=1024$ (lower is better).} \begin{tabular}{@{}ccccccccc@{}} \\ \toprule Workload & $k$ & $k'=1$ & $k'=2$ & $k'=3$ & $k'>= 4$ \\ \midrule WordEmbed & 2 & 100\% & 1\% & 0\% & 0\% \\ SIFT & 4 & 100\% & 1\% & 0\% & 0\% \\ TagSpace & 16 & 100\% & 72\% & 5\% & 0\% \\ \bottomrule \end{tabular} \label{statistical-model} \end{table} } \begin{comment} We evaluate vector packing by running a microbenchmark which places and routes eight vectors across 32, 64, and 128 dimensions, and compare their resource utilizations shown in Fig.~\ref{vector-packing-plot}. Surprisingly, we find that vector packing (``Vector Packed - Actual'') is ineffective in practice at reducing the resource footprint when compared to the theoretical gains an analytical model projects (``Vector Packed -Theoretical'') and even baseline implementations (``No Vector Packing''). We believe this is due to the increased routing pressure and reduced compilation feasibility. For high dimensional designs, we find that the compiler has difficulty routing the design which resulted in placed but not routed results. The routing pressure is most likely due to the vector ladder which introduces many states with high fan outs. However, we expect that in future generation APs and with tool chain maturity, that vector packing will eventually provide viable improvements. \begin{table}[!ht] \centering \caption{Vector packing microbenchmark STE utilization.} \begin{tabular}{@{}cccc@{}} \\ \toprule Dimensions& 32& 64& 128 \\ \midrule No Vector Packing& 2& 9& 16 \\ Vector Packed - Theoretical& 1& 4& 7 \\ Vector Packed - Actual& 7& 14& 29 \\ \bottomrule \end{tabular} \end{table} \end{comment} \section{Architecture Extension Recommendations} \label{sec:analysis} We now present microarchitectural extensions and briefly evaluate their resource utilization and performance impact on future AP hardware. \subsection{Counter Increment Extension} One limitation of the AP is the lack of arithmetic units which limits arithmetic calculations to those that increment by at most one (e.g., Hamming or Jaccard distance). In the context of kNN, allowing the counters to take multiple increment signals would enable processing of multiple vector dimensions in parallel per time step by encoding up to 7 dimensions per symbol. Applying this optimization would preclude stream multiplexing for kNN since it uses the higher symbol bits to encode dimensions of the same query instead of the same dimension across queries. This optimization would reduce the query latency by 7$\times$ but leave the sorting latency unchanged. Quantitatively, since the Hamming macro and sorting macro each take $d$ cycles to execute, the counter increment extension reduces the query latency to $d + d/7$ cycles which is a 43\% improvement or 1.75$\times$ better. More generally, this also reduces the need for collector states when performing reductions or counting multiple activations in parallel. For example, this modification can also enhance the throughput and latency of the apriori frequent item set mining automata presented in~\cite{ap-apriori} to increase the number of dataset vectors processed in parallel for a given itemset. Modifying the 8-bit counters to increment by up to 8 can efficiently be done with a carry save adder but requires 2.8$\times$ more two-input gates. However, since the AP fabric contains roughly two orders of magnitude fewer counters than STEs this modification should incur minimal overall area overhead. \subsection{Counter Dynamic Threshold Extension} A second counter extension is to allow dynamic counter thresholds; currently counter thresholds are fixed at design time which eliminates any way of implementing data dependent dynamic comparisons and control structures. A simple extension is to expose a reconfigurable counter threshold port which can be driven by the internal count of another counter enabling computations that require dynamically computed information. Most notably this modification can be used to build automata constructs that require arithmetic comparisons between two dynamic values as shown in Fig.~\ref{comparison-automata}. This automata can be used to build a more powerful ``if (A $>$ B) ... else ...'' construct which is more useful than the currently available ``if (A $>$ threshold) ... else ...''. This extension requires no extra hardware resources and only requires a few wires in the routing fabric to accommodate newly exposed internal counts. \begin{figure}[!th] \centering \includegraphics[width=\linewidth]{./threshold-counter.pdf} \caption{Comparison macro using dynamically thresholded counters.} \label{comparison-automata} \end{figure} \subsection{STE Decomposition Extension} Another key challenge of the AP fabric is fully utilizing the symbol address space of the STEs. For instance, in the context of kNN, only one bit of information is used by each STE per symbol to determine the state output. This means our kNN automata design underutilizes an 8-input STE or lookup table (LUT) effectively as a 1-input LUT since the remaining 7 bits of the input are not used. In terms of resource usage this is wasteful; a simple extension is to allow decomposition of STEs into multiple smaller STEs, or reducing the STE size so that they can be composed when larger STEs are needed. The key insight is that an 8-input LUT can easily be composed from two smaller 7-input LUTs (Fig.~\ref{ste-decomposition}), which can each be further decomposed if necessary. We refer to the degree to which an 8-input STE is decomposed as the \textit{decomposition factor} $x$; for instance, if we use an 8-input LUT as 4 $\times$ 6-input LUTs, the decomposition factor is $x = 4\times$. By performing this decomposition, more NFA states can be packed into roughly the same number of 8-input STE resources; this is because states in the NFA that can be implemented using smaller lookup tables or STEs can be packed together. To evaluate this extension, we build an analytical model to estimate savings in the context of kNN. In our model we assume each state in the original automata has a resource cost of one 8-input STE. We then estimate how many 8-input STEs would be required if different degrees of STE decomposition are implemented. For instance, if an 8-input STE can be decomposed into 2 $\times$ 7-input STEs, three states which each only need to see 6 bits of the symbol can be packed into two 8-input STEs incurring a cost of two in our analytical model. Similarly, these three states can be packed into a single 8-input STE if it can be broken down into 4 $\times$ 6 input STEs incurring a cost of one. Since the Hamming macro portion of the kNN automata dominates the STE cost, our model shows STE decomposition can potentially provide close to linear reductions in STE resources (Table~\ref{ste-decomposition-resources}). More generally, STE decomposition can improve resource usage for generalized regular expressions. It is not unreasonable to assume that the extended ASCII characters (ASCII values 128-255) frequently remain unused in many PCREs. Since the original ASCII character set consists of only 128 symbols, two 7-bit STEs can be encoded in a decomposed 8-bit STE yielding 2$\times$ resource utilization improvement. Practically there is a limit to which STEs should be decomposed (e.g., FPGAs use 6-LUTs) since decomposing STEs indefinitely incurs increased circuit control overheads. \begin{figure}[!t] \centering \includegraphics[width=0.9\linewidth]{./ste-decomposition.pdf} \caption{STE decomposition from a 8-LUT (a) to two 7-LUTs (b).} \label{ste-decomposition} \end{figure} { \captionsetup{skip=-10pt} \begin{table}[!b] \centering \caption{STE decomposition resource savings.} \begin{tabular}{@{}ccccccc@{}} \\ \toprule \begin{tabular}[c]{@{}c@{}}Decomposition\\Factor\end{tabular} & $x=1$ & $x=2$ & $x=4$ & $x=8$ & $x=16$ & $x=32$ \\ \midrule WordEmbed & 1$\times$ & 1.98$\times$ & 3.86$\times$ & 7.38$\times$ & 13.56$\times$ & 23.34$\times$ \\ SIFT & 1$\times$ & 1.99$\times$ & 3.93$\times$ & 7.67$\times$ & 14.68$\times$ & 27.00$\times$ \\ TagSpace & 1$\times$ & 1.99$\times$ & 3.96$\times$ & 7.83$\times$ & 15.31$\times$ & 29.26$\times$ \\ Theoretical & 1$\times$ & 2$\times$ & 4$\times$ & 8$\times$ & 16$\times$ & 32$\times$ \\ \bottomrule \end{tabular} \label{ste-decomposition-resources} \end{table} } \subsection{Summary} Resource savings on the AP translates directly to performance improvements since more parallel NFAs can be executed in parallel. By compounding the mutually orthogonal architectural extensions with automata design optimizations, we estimate that APs can achieve \textit{up to an additional} 73$\times$ potential performance improvement over Gen 2 results. The additional compute density from technology scaling incurs power overheads so we expect energy efficiency to only improve by up to 23$\times$. Table~\ref{summary-table} summarizes the projected improvements assuming natural technology scaling from 50nm to 28nm, 4$\times$ decomposition factor, vector packing into groups of 4, and 8-input counter increment extensions. Performance improvement yields from vector packing and STE decomposition are calculated using analytical models based on the number of states saved in the original NFA (1 NFA state $\approx$ 1 STE resource). For STE decomposition, we assume a decomposition factor of 4 which effectively breaks 8-input STEs into 6-input STEs; this is roughly equivalent to the 6-LUTs used in FPGA fabrics. With these additional improvements, \textit{the AP has the potential to be comparable to or even better than FPGAs and GPUs} for the kNN workloads presented in this paper. { \begin{table}[!ht] \centering \caption{Total compounded \textit{additional} potential performance gains from optimizations and architectural extensions.} \label{summary-table} \begin{tabular}{@{}cccc@{}} \\ \toprule Workload& kNN-WordEmbed& kNN-SIFT& kNN-TagSpace \\ \midrule Technology Scaling& 3.19$\times$& 3.19$\times$& 3.19$\times$ \\ Vector Packing& 2.93$\times$& 3.28$\times$& 3.31$\times$ \\ STE Decomposition& 3.86$\times$& 3.93$\times$& 3.96$\times$ \\ Counter Increment Ext.& 1.75$\times$& 1.75$\times$& 1.75$\times$ \\ \textbf{Total Improvement}& \textbf{63.14$\times$}&\textbf{71.96$\times$}& \textbf{73.17$\times$} \\ \bottomrule \end{tabular} \end{table} } \section{Related Work} \label{sec:related-work} We are not the first to propose accelerating kNN using alternative computing substrates or near-data processing techniques. As far back as the late 1980s, Kanerva et al.~\cite{sparse-distributed-memory} proposed Sparse Distributed Memory (SDM) for nearest neighbor search. This was followed by Roberts et al.~\cite{pcam} who proposed proximity content-addressable memory (PCAM) which employed the ideas behind SDM. Lipman et al.~\cite{smart-access-memory} then proposed Smart Access Memory which integrated distance calculation units with a systolic array sort for kNN. Finally, Tandon et al.~\cite{tandon13} proposed an all-pairs similarity search accelerator extension for the L2-cache to accelerate NLP applications. More recently, work has shown it is possible to implement approximate variants of kNN using TCAMs. Most notably, Shinde et al.~\cite{shinde10} propose ternary locality sensitive hashing (TLSH) and Bremler-Barr et al.~\cite{bremler-barr15} propose using binary-reflected Gray code to implement approximate nearest neighbors. Unfortunately the accessibility of TCAMs has traditionally been limited to niche hardware applications (e.g., routers) making them difficult to program, access, and evaluate. To our knowledge, we are the first to take advantage of temporal encodings in NFAs to accelerate automata calculations for kNN on the AP. Past work in the AP application space has focused mainly on pattern mining applications like biological motif search~\cite{ap-motif-search}, frequent itemset mining~\cite{ap-apriori}, and graph pattern mining~\cite{ap-graph}. There have also been efforts at porting decision tree applications like random forests~\cite{ap-random-forest} to the AP. The most relevant work to ours in this space is by Ly et al.~\cite{ly16} who propose automata-based feature extraction and image retrieval encodings. However, their proposed automata only supports exact categorical matches for image retrieval while our work implements kNN which is significantly more general. Thus, our work augments the AP application space by introducing a novel similarity search automata design which we have shown is both fast and energy efficient. Finally, application-driven PIM accelerators are not a new idea but have enjoyed renewed interest with the advent of new technologies like die-stacked memory; recent proposals have also ranged from fully programmable solutions, to domain specific accelerator fabrics, to fixed-function accelerators. Examples of fully programmable solutions can be found in work by Zhang et al.~\cite{zhang14} and Hsieh et al.~\cite{hsieh16} which both propose integrating GPUs with 3D memory to alleviate bandwidth bottlenecks. Farmahini-Farahani et al.~\cite{farmahini-farahani15} also propose a PIM architecture which integrates a coarse-grained reconfigurable array on top of commodity DRAMs; tasks were then offloaded to the array via a general purpose processor. Instances of more domain specific PIM proposals include work by Ahn et al.~\cite{ndp-graph} who propose a PIM architecture for parallel graph processing, and Xie et al.~\cite{pim-graphics} who propose PIM to accelerate 3D graphics rendering on top of Hybrid Memory Cube. Our work is another instantiation of the general trends towards exploiting the benefits of application-driven PIM offload using the AP. \section{Conclusion} \label{sec:conclusion} We presented a novel automata design and several optimization techniques for similarity search which exploits a temporally encoded sort for automata processors. Our results show that our automata design can achieve significant performance gains at comparable energy efficiency as competing CPU solutions. We also proposed architectural modifications and NFA design optimizations that expose the latent potential of the AP for similarity search. We expect that with better technology scaling, and improved reconfiguration latency that the AP will be able to support significantly larger workloads. We also expect that as the platform matures the architecture, resource capacity, and energy efficiency will improve dramatically making the AP a promising platform for many other automata-based applications. \section{Acknowledgements} We would like to thank all of our anonymous reviewers and colleagues for their valuable and insightful feedback. We especially thank Matt Grimm, Matt Tanner, and Indranil Roy at Micron Technologies Incorporated for taking the time to help guide, and validate our designs, and provide power measurements on actual AP hardware. This work was also supported in part by NSF under grant CCF-1518703, gifts by Oracle, and by C-FAR, one of the six SRC STARnet Centers, sponsored by MARCO and DARPA. \section{Introduction} This demo file is intended to serve as a ``starter file'' for IEEE conference papers produced under \LaTeX\ using IEEEtran.cls version 1.7 and later. All manuscripts must be in English. These guidelines include complete descriptions of the fonts, spacing, and related information for producing your proceedings manuscripts. Please follow them and if you have any questions, direct them to the production editor in charge of your proceedings at Conference Publishing Services (CPS): Phone +1 (714) 821-8380 or Fax +1 (714) 761-1784. \subsection{Subsection Heading Here} Subsection text here. \subsubsection{Subsubsection Heading Here} Subsubsection text here. \section{Type style and Fonts} Wherever Times is specified, Times Roman or Times New Roman may be used. If neither is available on your system, please use the font closest in appearance to Times. Avoid using bit-mapped fonts if possible. True-Type 1 or Open Type fonts are preferred. Please embed symbol fonts, as well, for math, etc. \section{Conclusion} The conclusion goes here. this is more of the conclusion \section*{Acknowledgment} The authors would like to thank... more thanks here
{'timestamp': '2017-06-09T02:00:55', 'yymm': '1608', 'arxiv_id': '1608.03175', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03175'}
arxiv
\section*{Introduction} Gusti et al. present clique topology -- a novel matrix analysis technique to extract structural features from neural activity data that contains hidden nonlinearities. This represents a significant improvement upon the previous eigenvalue-based approaches that fail under similar conditions. Structural features can yield significant insight into neurological processes.\\ Their findings are verified by showing that the geometric structure of neural correlations in the rat hippocampus is determined by hippocampal circuits rather than being a consequence of positional coding. \section*{Background} \subsection*{Clique topology and Betti curves} Clique topology is a central theme in this paper and is best explained by breaking it down into two terms. A clique is a complete graph, $C$ that is a subgraph of a directed graph $G = (V,E)$. Alternatively, a clique in an undirected graph $G$ is a subset of vertices, $C \subseteq V$ where every pair of distinct vertices are adjacent. Topology in this case refers to the study of the orientation of clique connections in an order complex.\\ \pagebreak \vspace*{\fill} For a matrix, $A$, an \textit{order complex} is defined as a subsequence of graphs, ${G_0 \subseteq G_1 \subseteq ... \subseteq G_p}$ such that $G_0$ is the graph having $N$ vertices and no edges, $G_1$ has a single edge $i,j$ corresponding to the highest off-diagonal matrix value $A_{ij}$, and with each subsequent graph having an additional edge for the next-highest off-diagonal matrix entry for any $N \times N$ symmetric matrix $A$ with constant and distinct order of entries. The following figure from the paper illustrates this concept. \\ \begin{figure}[h!] \centerline{\includegraphics[scale=0.4]{order_complex.png}} \caption{(Top) The order complex of A is represented as a sequence of binary adjacency matrices, indexed by the density of non-zero entries. (Bottom) Graphs corresponding to the adjacency matrices. Minimal examples of a 1-cycle (yellow square), a 2-cycle (red octahedron) and a 3-cycle (blue orthoplex) appear at ${\rho = 0.1}$, 0.25, and 0.45, respectively. } \end{figure} \vfill \pagebreak \enlargethispage{2cm} As connections are introduced to the order complex, non-contractible holes, or cycles, appear. Cycles are created, modified, and eventually destroyed as the edge density of cliques increases. Betti numbers are used to quantify this behavior. A Betti number $\beta_m$ is a function of the number of cycles in a graph $G$ and the edge density $\rho$. Considering the complete set of edge densities for all $m$-cycles allows for the generation of Betti curves, which provide a summary of the topological features of a given matrix.\\ To compare Betti curves to a control matrix, Gusti et al. introduce the concept of integrated Betti values, $\overline{\beta}_m$.\\ \[\overline{\beta}_m = \int_0^1 \beta_m (\rho) d \rho\] The values $\beta_1$, $\beta_2$, and $\beta_3$ were computed for each data set. An example for random matrices is shown in the following figure from the original publication.\\ \begin{figure}[h!] \centerline{\includegraphics[scale=0.35]{betti_curves.png}} \caption{For a distribution of 1000 random $N \times N$ symmetric matrices ${(N = 88)}$, average Betti curves $\beta_1(\rho),\; \beta_2(\rho),$ and $\beta_3(\rho)$ are shown (yellow, red, and blue dashed curves), together with 95\% confidence intervals (shaded areas). } \end{figure} Matrices containing random data have Betti curves distinct from those containing geometric data. Random data produces unimodal Betti curves that increase as a function of edge density ($\rho$), while geometric data results in Betti curve values that decrease as a function of $\rho$ as they contain significantly fewer cycles. Betti curves for distributions of geometric matrices are shown in the figure below.\\ Note the significant difference in peak values from the previous figure.\\ \vfill \pagebreak \vfill \enlargethispage{2cm} \begin{figure}[h!] \centerline{\includegraphics[scale=0.27]{betti_curves_geometric.png}} \caption{Betti curves for distributions of geometric matrices ${(N = 88)}$ in dimensions $d$ = 5, 10, 16, 24, and 88. Mean Betti curves $\beta_1(\rho), \; \beta_2(\rho),$ and $\beta_3(\rho)$ are shown (yellow, red, and blue curves), with darker (and higher) curves corresponding to larger $d$.} \end{figure} \subsection*{Computation of pairwise correlation matrices} Neural connectivity data is often represented as a matrix whose entries $C_{ij}$ correspond to the strength of connection between pairs of neurons, with strong connections indicating a high degree of \textit{neural correlation}. The clique topology technique serves to extract structural features from this data.\\ In the following figure, neural connectivity data is represented as ``spike trains'' -- time-series electrical signals recorded from individual neurons. \begin{figure}[h!] \centerline{\includegraphics[scale=0.25]{spike_trains.png}} \caption{Computation of pairwise correlation matrices from spike train data.} \end{figure} \vfill \pagebreak \vspace*{\fill} For a pair of spike trains $\left\{ t_\ell^i \right\}_{\ell=1...n_j}$ for neurons $i$ and $j$ (top of figure), the cross-correlogram $\ccg_{ij}(\tau)$ is computed as \[ \ccg_{ij}(\tau) = \frac{1}{T} \int_0^T f_i(t)f_j(t+\tau)dt, \] where $f_i(t)=\sum_{\ell=1}^{n_i}\delta \left( t - t_\ell^i \right)$ is the instantaneous firing rate of the $i$-th neuron. The graph in Figure 4 shows a smoothed $\ccg_{ij}(\tau)$ as a black curve along with the expected value of the cross-correlogram, $r_i r_j$ in red for uncorrelated spike trains with matching firing rates, $r_i = \frac{n_i}{T}$. The blue line illustrates the pairwise correlations $C_{ij}$ with timescale $\tau_{\max}$, which were computed as \[ C_{ij} = \frac{1}{\tau_{\max} r_i r_j} \max \left( \int_0^{\tau_{\max}} \ccg_{ij} (\tau) d \tau, \int_0^{\tau_{\max}} \ccg_{ji} (\tau) d \tau \right) \] The right of the figure shows a blue $88 \times 88$ matrix $C$, with the $C_{14,15}$-th entry corresponding to the cross correlogram to the left. \\ Previous approaches to this type of problem rely on eigenvalues, which are invariant under change of basis and thus not an ideal solution as structure in neural data should be invariant under transformations of the form $C_{ij}=f(A_{ij})$ for a monotonically increasing function $f$.\\ Eigenvalue based approaches utilize symmetric eigenvalue decomposition to generate a set of eigenvalues that can be further analyzed. For example, eigenvalues were calculated for a random, symmetric $N \times N$ matrix were observed to follow the normal distribution. This sort of analysis is the foundation of the traditional eigenvalue approaches that this paper improves upon.\\ The limitations of eigenvalue based analysis is illustrated in the following figure. Note the destruction of spectral signatures for matrix structure by nonlinear monotonically increasing transformations. \\ \vfill \pagebreak \enlargethispage{2cm} \begin{figure}[h!] \centerline{\includegraphics[scale=0.45]{eigenvalue_method.png}} \caption{Spectral signatures of matrix structure are destroyed by nonlinear monotonically increasing transformations.} \end{figure} (\textbf{a}) Consider a $100 \times 100$ symmetric matrix $A$ with $\texttt{rank}(A) = 4$. (\textbf{b}) The spectrum of $A$ includes four positive eigenvalues, indicating that $A$ has rank 4 and is positive semidefinite. The graph (\textbf{c}) depicts ${f(x) = (x-0.2)^3}$, a monotonically increasing function. The spectrum of the matrix $f(A)$ is shown in (\textbf{d}). Note that it contains many nonzero eigenvalues. The spatial signature that $A$ has a low-rank structure has been destroyed by $f$. \section*{Methods and Analysis} Observing structure is critical to understanding the organization and function of the underlying neural circuits -- structure may reflect the coding properties of neurons, rather than their physical locations. Geometric structure is expected here due to the existence of spatially localized receptive fields (place fields), but has not been previously detected \textit{intrinsically} using pattern correlations alone. A key question addressed by this work is whether the spatial coding properties of place cells is \textit{sufficient} to account for the observed geometric organization of correlations during spatial navigation. Alternatively, does this structure reflect finer features of the correlations, beyond what is expected from the place cells alone?\\ \vfill \pagebreak \enlargethispage{3cm} To demonstrate successful extraction of geometric features using clique topology, data was taken from the pyramidal neurons of a rat hippocampus during a variety of activities including REM sleep, running, and spatial navigation. These neurons function as position sensors, firing at a high rate when the animal's position lies within the neuron's \textit{place field} -- its preferred region of the spatial environment. This sort of organization leads to a decrease in pairwise correlation $C_{ij}$ between place cells as a function of the distances between the centers of place fields.\\ Place fields $F_i(\mathbf{x})$ were computed for each place cell with a two-dimensional spatial trajectory $\mathbf{x}(t)$. Synthetic spike trains were generated for each neuron as inhomogeneous Poisson processes with rate functions ${r_i(t) = F_i(\mathbf{x}(t))}$ given by the simple place field model. The synthetic spike trains preserved the influence of place fields while suppressing all other features, including non-spatial correlations. Betti curves derived from the place field model expressed all of the signatures for geometric organization. \\ The necessity of place field \textit{geometry} was also examined to determine if the Betti curves observed during spatial navigation could be attributed to the global signal that drives each neuron, $\mathbf{x}(t)$, filtered by a cell-specific function $F_i(\textbf{x})$. Place field data was scrambled by permuting the values of $F_i(\textbf{x})$ inside ``pixels'' of a $100 \times 100$ grid to produce non-geometric receptive fields $\widetilde{F}_i(\mathbf{x})$. Spike-trains were generated using the scrambled place fields $\widetilde{F}_i(\mathbf{x})$, and it was found that the second and third Betti curves lacked indication of geometric organization. This is illustrated in Figure 6. \begin{figure}[h!] \centerline{\includegraphics[scale=0.35]{scrambled.png}} \caption{Scrambled vs non-scrambled place fields with associated Betti curves and integrated Betti curves.} \end{figure} \pagebreak Gusti et al. conclude that geometric signatures observed during spatial navigation reflect the geometry of place fields, and are not simply a consequence of neurons being driven by the global signal $\mathbf{x}(t)$. This suggests that geometric structure in place cell correlations is a consequence of positional coding and is not expected during non-spatial behaviors, however this notion was dismissed upon further analysis of non-spatial conditions (wheel running and REM sleep). It was found that Betti curves were again non-random and were consistent with signatures of geometric organization. \\ \begin{figure}[h!] \centerline{\includegraphics[scale=0.3]{non_spatial.png}} \caption{Geometric organization in hippocampus during non-spatial behaviors.} \end{figure} The geometric organization in the non-spatial Betti curves is shown in the figure above. Please refer to the original publication for a more detailed explanation of the figure. \section*{Results} Neural connections have many unknown nonlinearities, therefore clique topology must be used in lieu of eigenvalues to preserve nonlinear features present in the connectivity data. Using pairwise correlations of neurons in the hippocampus, Gusti et al. demonstrate that clique topology can be used to detect intrinsic structure in neural activity that is invariant under nonlinear monotone transformations without appealing to external stimuli or receptive fields. This demonstration serves to verify their newly discovered technique and represents a significant contribution towards the analysis of nonlinear systems. \section*{Critiques and Extension} More general uses of clique topology are not discussed in the original publication. For example, Gusti mentions that the symmetric eigenvalue decomposition method is often used with success in physics applications, however there are many nonlinear systems in physics that could potentially benefit from analysis using clique topology. \\ The Van der Pol oscillator is a non-conservative oscillator that undergoes nonlinear damping, evolving according to the second order differential equation ${d^2x \over dt^2}-\mu(1-x^2){dx \over dt}+x= 0$. This equation has also been extended to model action potentials of neurons. It would be interesting to see clique topology applied to physical and chemical systems of nonlinear oscillators to detect some form of ``structure'' or pattern within the system.\\ \begin{figure}[h!] \centerline{\includegraphics[scale=0.55]{vanderpol.png}} \caption{Evolution of the Van der Pol oscillator limit cycle in the phase plane.} \end{figure} \section*{References} \setlength{\parindent}{0cm} Cartwright, M.L., ``Balthazar van der Pol", J. London Math. Soc., 35, 367-376, (1960).\\ C. Giusti, E. Pastalkova, C. Curto, and V. Itskov. Clique topology reveals intrinsic geometric structure in neural correlations. Proc. Natl. Acad. Sci., 112(44):13455–13460, 2015.\\ FitzHugh, R., Impulses and physiological states in theoretical models of nerve membranes'', Biophysics J, 1, 445-466, (1961). \end{document}
{'timestamp': '2016-08-12T02:06:59', 'yymm': '1608', 'arxiv_id': '1608.03463', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03463'}
arxiv
\section{Introduction} \label{sec:intro} The \textsc{Set Cover}\xspace problem is, after determining satisfiability of CNF formulas or Boolean circuits, one of the canonical NP-complete problems. It not only directly models many applications in practical settings, but also algorithms for it routinely are used as tools for theoretical algorithmic results (e.g.,~\cite{Dantsin200269}). It is a problem `whose study has led to the development of fundamental techniques for the entire field' of approximation algorithms.\footnote{As the Wikipedia page on Set Cover quotes the textbook by Vazirani~\cite[p15]{Vazirani:2001:AA:500776}.} However, the exact exponential time complexity of \textsc{Set Cover}\xspace is still somewhat mysterious: We know algorithms need to use super-polynomial time assuming $P\neq NP$ and (denoting $n$ for the universe size) $O^*(2^{\Omega(n)})$ time assuming the Exponential Time Hypothesis, but how large the exponential should be is not clear. In particular, no non-trivial consequences of an $O^*(1.01^n)$-time algorithm are currently known. Even though it is one of the canonical NP-complete problems, the amount of studies of exact algorithms for \textsc{Set Cover}\xspace pales in comparison with the amount of literature on exact algorithms for \textsc{CNF-Sat}: Many works focus on finding $O^*(c^n)$-time algorithms for $c<2$ for \textsc{CNF-Sat} on $n$-variable CNF-formulas in special cases such as, among others, bounded clause width~\cite{DBLP:journals/algorithmica/Schoning02,Dantsin200269,DBLP:conf/soda/ChanW16}, bounded clause density~\cite{DBLP:conf/coco/CalabroIP06,DBLP:journals/corr/ImpagliazzoLPS14} or few projections~\cite{DBLP:conf/iwpec/KaskiKN12,Paulusma2015,saether}. Improved exponential time algorithms for special cases of problems other than \textsc{CNF-Sat} were also studied for e.g. \textsc{Graph Coloring} or \textsc{Traveling Salesman} on graphs bounded degree/average degree~\cite{DBLP:journals/mst/BjorklundHKK10,DBLP:journals/talg/BjorklundHKK12,DBLP:journals/iandc/CyganP15, DBLP:conf/icalp/GolovnevKM14}. In this paper we are interested in the exponential time complexity of \textsc{Set Cover}\xspace, and study which properties are sufficient to have improved exponential time algorithms. Our interest in finding faster exponential time algorithms for \textsc{Set Cover}\xspace does not only stem from it being a canonical NP-complete problem, but also from its unclear relation with \textsc{CNF-Sat}. Intriguingly, on one hand \textsc{Set Cover}\xspace has some similarities with the \textsc{CNF-Sat}: \begin{inparaenum} \item Both problems take an (annotated) hypergraph as input \item The improvability of the worst-case complexity of \textsc{CNF-Sat} is essentially equivalent to the improvability of the worst-case complexity of \textsc{Hitting Set}~\cite{DBLP:conf/coco/CyganDLMNOPSW12}, which is just a reparametrization\footnote{One way of stating \textsc{Hitting Set} in this context, is that we have an instance of the \textsc{Set Cover}\xspace problem but aim to find an $O^*(2^{(1-\Omega(1))m})$ time algorithm, where $m$ denotes the number of sets.} of \textsc{Set Cover}\xspace.\end{inparaenum}\ But, on the other hand the problems are quite different to our understanding: \begin{inparaenum} \item Most algorithms for \textsc{Set Cover}\xspace use dynamic programming or some variant of inclusion exclusion, while most algorithms for \textsc{CNF-Sat} are based on branching \item No connection between the exponential time complexities of both problems is known (see~\cite{DBLP:conf/coco/CyganDLMNOPSW12})\end{inparaenum}. One hope would be that a better understanding of the exact complexity of \textsc{Set Cover}\xspace might shed more light on this unclarity. Moreover, Cygan et al.~\cite{DBLP:conf/coco/CyganDLMNOPSW12} also show that if we would like to improve the run time $O^*(f(k))$ of several parameterized algorithms to $O^*(f(k)^{1-\Omega(1)})$, we first need to find an $O^*(2^{(1-\Omega(1))n})$-time algorithm for \textsc{Set Cover}\xspace. These parameterized algorithms include the classic algorithm for \textsc{Subset Sum}{}, as well as more recent algorithms for \textsc{Connected Vertex Cover} and \textsc{Steiner Tree}. \subparagraph{Relevant previous work} The algorithmic results on \textsc{Set Cover}\xspace that are the most relevant to our work are as follows: The folklore dynamic programming algorithm runs in $O^*(2^n)$ time. A notable special case of \textsc{Set Cover}\xspace that can be solved in $O^*(2^{(1-\Omega(1))n})$ time is due to Koivisto~\cite{DBLP:conf/iwpec/Koivisto09}: He gives an algorithm that runs in time $O^*(2^{(1-\frac{1}{O(r)})n})$-time algorithm if all sets are at most of size $r$. Bj\"orklund et al.~\cite{DBLP:journals/siamcomp/BjorklundHK09} show that the problem can be solved in $2^n\poly(n)$ time (which is faster if the number of sets is exponentially large in $n$). Bj\"orklund et al.~\cite{DBLP:journals/corr/abs-1007-1161} give a randomized algorithm that assumes all sets are of size $q$ and determines whether there exist $p$ pairwise disjoint sets in $O^*(2^{(1-\epsilon)pq})$ time where $\epsilon >0$ depends on $q$. \subparagraph{Our Main Results} We investigate what are sufficient structural properties of instances of \textsc{Set Cover}\xspace, and the closely related \textsc{Set Partition}\xspace (in which the picked sets need to be disjoint), problems to be solvable in time significantly faster than the currently known algorithms. We will outline our main results now: \begin{theorem}\label{thm:largesol} There is a Monte Carlo algorithm that takes an instance of \textsc{Set Cover}\xspace on $n$ elements and $m$ sets and an integer $\solsize$ as input and determines whether there exists a set cover of size $s$ in $O(2^{(1-\Omega(\sigma^4))n}m)$ time, where $\sigma=s/n$. \end{theorem} We remark that this generalizes the result of Koivisto~\cite{DBLP:conf/iwpec/Koivisto09} in the sense that it solves a larger class of instances in $O^*(2^{(1-\Omega(1))n})$ time: If all set sizes are bounded by a constant $r$, a set partition needs to consist of at least $n/r$ sets and Theorem~\ref{thm:largesol} applies with $\sigma = 1/r$ (although this gives a slower algorithm than Koivisto's in this special case). Moreover, it seems hard to extend the approach of Koivisto to our more general setting. The second result demonstrates that our techniques are also applicable to \textsc{Set Cover}\xspace instances with exponentially many sets, a canonical example of which being graph coloring: \begin{theorem}\label{thm:col} There is a randomized algorithm that given graph $G$ and integer $\solsize=\sigma n$, in $O^*(2^{(1-\Omega(\sigma^4))n})$ time outputs \yes with constant probability, if $\chi(G) < \solsize$, and \no, if $\chi(G) > \solsize$. \end{theorem} \subparagraph{Representation method for Set Cover} We feel the main technique used in this paper is equally interesting as the result, and will therefore elaborate on its origin here. Our technique is on a high level inspired by the following simple observation ingeniously used by Howgrave-Graham and Joux~\cite{DBLP:conf/eurocrypt/Howgrave-GrahamJ10}: Suppose $\mathcal{S} \subseteq 2^{[m]}$ is a set of solutions implicitly given and we seek for a solution $X \in \mathcal{S}$ with $|X|=s$ by listing all sets of $\binom{[m]}{s/2}$ and performing pairwise checks to see which two combine to an element of $\mathcal{S}$. Then we can restrict our search in various ways since there will be as many as $\binom{s}{s/2}$ pairs guiding us to $X$. In~\cite{DBLP:conf/eurocrypt/Howgrave-GrahamJ10} and all subsequent works (including~\cite{DBLP:conf/eurocrypt/BeckerCJ11,eurocrypt-2012-24271,DBLP:conf/stacs/AustrinKKN15,DBLP:journals/corr/AustrinKKN15}), this idea was used to speed up `meet-in-the-middle attacks' (also called `birthday attacks'~\cite[Chapter 6]{Joux:2009:AC:1642719}). We will refer to uses of this idea as the `representation method' since it crucially relies on the fact that $X$ has many representations as pairs. To indicate the power of this technique in the context of \textsc{Set Cover}\xspace and \textsc{Set Partition}\xspace we show that without changes it already gives an $O^*(2^{0.3399m})$-time Monte Carlo algorithm for the \textsc{Set Partition}\xspace problem with $m$ sets, and even for a more general linear satisfiability problem on $m$ variables. For the latter problem this improves the $O^*(2^{m/2})$ time algorithm based on the meet-in-the-middle attack that was the fastest known before. At first sight the representation method seemed to be inherently only useful for improving algorithms based on the meet-in-the-middle attack. However, the main conceptual contribution of this work is to show that it is also useful in other settings, or at least for improving the dynamic programming algorithm for the \textsc{Set Cover}\xspace and \textsc{Set Partition}\xspace problems if the solution size is large. On a high level, we show this as follows in the case of \textsc{Set Partition}\xspace:\footnote{The algorithm for \textsc{Set Cover}\xspace actually reduces to \textsc{Set Partition}\xspace.} for a subset $W$ of the elements of the \textsc{Set Partition}\xspace instance, define $T[W]$ to be the minimum number of disjoint sets needed to cover all elements of $W$. Stated slightly oversimplified, we argue that if a minimal set partition of size $s$ is large, we have that $T[W]+T[[n] \setminus W]=s$ for $\binom{s}{s/2}$ sets $W$ with $|W|$ close to $n/2$. To relate this to later sections, let us remark we refer to such a set $W$ as a \emph{witness halve}. Subsequently, we exploit the presence of many witness halves by using a dynamic programming algorithm that samples a set of the subsets with size close to $n/2$ and only evaluates table entries from this sample plus the table entries required to compute the table entries from the sample. \subparagraph{Organization} This paper is organized as follows: In Section~\ref{sec:prel}, we recall preliminaries and introduce notation. In Section~\ref{sec:vars}, we discuss new observations and basic results that we feel are useful for developing a better understanding of the complexity of \textsc{Set Cover}\xspace with respect to several structural properties of instances. In Section~\ref{sec:manyhalves} we formally present the notion of witness halves and prepare tools for exploiting the existence of many witness halves. In Section~\ref{sec:mainproofs} we prove our main results and in Section~\ref{sec:concremark} we suggest further research. \section{Preliminaries and Notation}\label{sec:prel} For a real number $x$, $|x|$ denotes the absolute value of $x$. For a Boolean predicate $p$, we let $[p]$ denote $1$ if $p$ is true and $0$ otherwise. On the other hand, if $p$ is an integer we let $[p]$ denote $\{1,\ldots,p\}$. As usual, $\mathbb{N}$ denotes all positive integers. Running times of algorithms are often stated using $O^*(\cdot)$ notation which suppresses factors polynomial in the input size. To avoid superscript, we sometimes use $\exp(x)$ to denote $e^x$. We denote $\lg$ for the base-$2$ logarithm. If $G=(V,E)$ and $v \in V$ we denote $N(v)= \{w \in V: (v,w)\in E\}$ and for $X \subseteq V$ we extend this notation to $N(X)=\bigcup_{v \in X}N(v)$. For reals $a,b>0$ we let $a \pm b$ denote the interval $[a-b,a+b]$. A false positive (negative) of an algorithm is an instance on which it incorrectly outputs YES (respectively, NO). In this work we call an algorithm Monte Carlo if it has no false positives and if any instance is a false negative with probability at most $1/4$. We denote vectors with boldface for clarity. For a real number $x \in [0,1]$, $h(x)= -x \lg x - (1 - x) \lg (1 - x)$ denotes the binary entropy of $x$, where $0 \lg 0$ should be thought of as $0$. It is well known that $\binom{b}{a} \leq 2^{h(a/b)b}$ (and this can for example be proved using Stirling's approximation). It is easy to see from the definition that $h(\cdot)$ is symmetric in the sense that $h(x)=h(1-x)$. \begin{lemma} The following can be verified using standard calculus: \label{fact:bounds} \begin{enumerate} \item $h(1/2 - x) = h(1/2+x) \leq 1 - x^2$ for all $x \in (0,1/2)$, \item $h(x) \leq x \lg( 4/x )$ for all $x \in (0,1)$, \item $(1-1/n)^n \leq 1/e$. \end{enumerate} \end{lemma} \begin{lemma}[Hoeffding bound~\cite{hoeffding}]\label{lem:hoeff} If $X_1,\ldots,X_s$ are independent, $Y = \sum_{i=1}^s X_i$ and $a_i \leq X_i \leq b_i$ for $i=1,\ldots,s$ then $\Pr[|Y- \mathbb{E}[Y]| \geq t] \leq 2 \cdot \exp\left(\frac{-2t^2}{\sum_{i=1}^s (b_i-a_i)^2} \right)$. \end{lemma} \subparagraph{Set Cover / Set Partition} In the \textsc{Set Cover}\xspace problem we are given a bipartite graph $G=(F \dot{\cup} U, E)$ (where $F$ and $U$ shorthand `Family' and `Universe' respectively), together with an integer $\solsize$ and the task is to determine whether there exists a \emph{solution} $S \subseteq F$ such that $N(S)=U$ and $|S| \leq \solsize$. In the \textsc{Set Partition}\xspace problem we are given the same input as in the \textsc{Set Cover}\xspace problem, but we are set to determine whether there exists $S \subseteq F$ with $N(S)=U$, $|S| = \solsize$ and additionally $N(f) \cap N(f')=\emptyset$ for every $f,f' \in S$ with $f\neq f'$. We will refer to solutions of both problems as set covers and set partitions. Throughout this paper, we let $n,m$ respectively denote $|U|$ and $|F|$, and refer to instances of \textsc{Set Cover}\xspace or \textsc{Set Partition}\xspace as $(n,m,\solsize)$-instances to quantify their parameters. Since this work concerns \textsc{Set Cover}\xspace or \textsc{Set Partition}\xspace with large solutions we record the following basic observation that follows by constructing for each\footnote{For \textsc{Set Partition}\xspace only do this for $c$-tuples $(f_1,\ldots,f_c)$ with $N(f_i)$ disjoint.} $c$-tuple $t=(f_1,\ldots,f_c) \in F^c$ of sets in the original instance a set $f^t$ with $N(f^t)=\bigcup_{i=1}^t f_i$ in the output instance: \begin{observation}[\cite{DBLP:conf/coco/CyganDLMNOPSW12}]\label{obs:redsolsize} There is a polynomial time algorithm that takes a constant $c \geq 1$ dividing $\solsize$, and a $(n,m,\solsize)$-instance of \textsc{Set Cover}\xspace (resp. \textsc{Set Partition}\xspace) as input and outputs an equivalent $(n,m^c,\solsize/c)$-instance of \textsc{Set Cover}\xspace (resp. \textsc{Set Partition}\xspace). \end{observation} Often it will be useful dispense with linear sized sets. To this end, the following can be achieved by simply iterating over all $f \in F$ with $|N(f)| \geq \epsilon n$ and checking for each such set whether there is a solution containing it using the $2^{n}\poly(n)$ algorithm for \textsc{Set Cover}\xspace~\cite{DBLP:journals/siamcomp/BjorklundHK09}. \begin{observation}\label{obs:nolinear} There is an algorithm that, given a real number $\epsilon >0$, takes an $(n,m,\solsize)$-instance of \textsc{Set Cover}\xspace as input and outputs an equivalent $(n,m',\solsize)$-instance with $m' \leq m$ satisfying $|N(f)| \leq \epsilon n$ for every $f \in F$. The algorithm runs in $O(m2^{(1-\epsilon)n}\poly(n))$ time. \end{observation} As we will see in Theorem~\ref{thm:subtle}, it makes a difference in the \textsc{Set Partition}\xspace problem whether empty sets are allowed since we need to find a set partition of size exactly $s$. To exclude such sets, we will simply say that an instance is `without empty sets'. \section{Observations and Basic Results on Set Cover and Set Partition.}\label{sec:vars} To improve our understanding of which properties of instances of \textsc{Set Cover}\xspace and \textsc{Set Partition}\xspace allow faster algorithms, and which techniques are useful for obtaining such faster algorithms, we will record some observations and basic results in this section. To stress that the proof techniques in this section are \emph{not our main technical contribution}, we postpone all proofs to Appendix~\ref{app:A}. We prefer to state our results in terms of \textsc{Set Cover}\xspace because it is slightly more natural and common, but since \textsc{Set Partition}\xspace often is easier to deal with for our purposes we will sometimes use the following easy reduction, all of whose steps are contained in~\cite{DBLP:conf/coco/CyganDLMNOPSW12}: \begin{theorem}\label{thm:redcovpart} There is an algorithm that, given a real $0 <\epsilon < 1/2$, takes an $(n,m,\solsize)$-instance of \textsc{Set Cover}\xspace as input and outputs an equivalent $(n,m',\solsize)$-instance of \textsc{Set Partition}\xspace with $m' \leq m2^{\epsilon n}$ sets in time $O(m2^{(1-\epsilon)n})$. \end{theorem} For completeness, we show that in fact \textsc{Set Cover}\xspace and \textsc{Set Partition}\xspace are equivalent with respect to being solvable in time $O^*(2^{(1-\Omega(1))n})$. This was never stated in print to the best of our knowledge, but the proof uses standard ideas and is found in Appendix~\ref{app:covparteq}. \begin{theorem}\label{thm:covparteq} For some $\epsilon >0$ there is an $O^*(2^{(1-\epsilon)n})$ time algorithm for \textsc{Set Cover}\xspace if and only if for some $\epsilon' >0$ there is an $O^*(2^{(1-\epsilon')n})$ time algorithm for \textsc{Set Partition}\xspace. \end{theorem} The following natural result is a rather direct consequence of a paper by Koivisto~\cite{DBLP:conf/iwpec/Koivisto09}. It reveals some more similarity with the \textsc{$k$-CNF-Sat} problem: Koivisto shows\footnote{Koivisto only showed this for \textsc{Set Partition}\xspace, but the straightforward reductions in this section carry this result over to \textsc{Set Cover}\xspace.} that for maximum set size $r$, \textsc{Set Cover}\xspace can be solved in $O^*(2^{(1-\Omega(\frac{1}{r}))n})$ which is analogous to \textsc{$k$-CNF-Sat} being in $O^*(2^{(1-\Omega(\frac{1}{k}))n})$ time~\cite{DBLP:journals/algorithmica/Schoning02,Dantsin200269,DBLP:conf/soda/ChanW16}, and similarly the following result is the counterpart of $O^*(2^{(1-\Omega(\frac{1}{\delta}))n})$-time algorithms for CNF-formula's of density $\delta$ (i.e. at most $\delta n$ clauses)~\cite{DBLP:conf/coco/CalabroIP06,DBLP:journals/corr/ImpagliazzoLPS14}. Again, this result was never explicitly stated in print to the best of our knowledge, and therefore is proved in Appendix~\ref{app:fewsets}. \begin{theorem}\label{thm:fewsets} There is an algorithm solving $(n,m,\solsize)$-instances of \textsc{Set Cover}\xspace or \textsc{Set Partition}\xspace in time $m\cdot\mathsf{poly}(n)2^{n-\frac{n}{O(\lg(m/n))}}$. \end{theorem} Relevant to our work is the following subtlety on solution sizes in \textsc{Set Partition}\xspace. It shows that for \textsc{Set Partition}\xspace with empty sets, finding large solutions is as hard as the general case. The proof is postponed to Appendix~{\ref{app:subtle}}. \begin{theorem}\label{thm:subtle} Suppose there exist $0<\epsilon_1,\epsilon_2 <1/2$ and an algorithm solving $(n,m,\epsilon_1n)$-instances of \textsc{Set Partition}\xspace in time $O^*(2^{(1-\epsilon_2)n})$. Then there exists an $O^*(2^{(1-\epsilon_2/2)n})$-time algorithm for \textsc{Set Partition}\xspace. \end{theorem} Finally, it is insightful to see how well the representation method performs on the \textsc{Set Partition}\xspace problem with few sets (e.g., we consider running times of the $O^*(2^{m})$, where $m$ is the number of sets). A straightforward approach of the meet-in-the-middle attack leads directly to an $O^*(2^{m/2})$ time algorithm. We show that the representation method combined with the analysis of~\cite{DBLP:journals/corr/AustrinKKN15, DBLP:conf/stacs/AustrinKKN15} in fact solves the more general \textsc{Linear Sat} problem. In \textsc{Linear Sat} one is given an integer $t$, matrix $A \in \mathbb{Z}^{n\times m}_{2}$, and vectors $\vec{b} \in \mathbb{Z}^n_2$ and $\vec{\omega} \in \mathbb{N}^m$. The task is to find $\vec{x} \in \mathbb{Z}^m_2$ satisfying $A\vec{x}\equiv\vec{b}$ and $\vec{\omega} \cdot \vec{x} \leq t$. \begin{theorem}\label{thm:linsat} There is an $O^*(2^{0.3399m})$-time Monte Carlo algorithm solving \textsc{Linear Sat}. \end{theorem} To our best knowledge no $O^*(2^{(0.5-\Omega(1))m})$-time algorithm for \textsc{Linear Sat} was known before. We get as a corollary that, given a bipartite graph $G=(F\dot{\cup}U,E)$, we can determine the smallest size of a set partition in time $O^*(2^{0.3399m})$. We take this as a first signal that the representation method is useful for solving \textsc{Set Partition}\xspace (and \textsc{Set Cover}\xspace) for instances with small universe. To see this consequence, note we can reduce this problem to \textsc{Linear Sat} as follows: For every $f \in F$ add the incidence vector of $N(f)$ as a column to $A$, and set the cost $\omega_i$ of picking this column to be $n|N(f)|+1$. Then the minimum of $\vec{\omega} \cdot \vec{x}$ subject to $A\vec{x}\equiv\vec{1}$ will be $n^2+s$ where $s$ is the number of sets in a minimum set partition. Let us remark that \cite[Page 130]{Dahllof22042} solves (a counting version) of \textsc{Set Partition}\xspace in time $O^*(1.2561^m)=O^*(2^{0.329m})$, and Drori and Peleg~\cite{Drori2002473} solve the problem in $O^*(2^{0.3212m})$ time,\footnote{We attempted to find any more recent faster algorithm, but did not find this. Though, we would not be surprised if using more recent tools in branching algorithms as~\cite{DBLP:journals/jacm/FominGK09} one should be able to more significantly outperform our algorithm for \textsc{Set Partition}\xspace.} so by no means our algorithm is the fastest in this setting. However, both use sophisticated branching and we find it intriguing that the representation method does work quite well even for the seemingly more general \textsc{Linear Sat} problem. \section{Exploiting the Presence of Many Witness $\beta$-halves.}\label{sec:manyhalves} For convenience we will work with \textsc{Set Partition}\xspace in this section; the results straightforwardly extend to \textsc{Set Cover}\xspace but we will not need this in the subsequent section. \begin{definition} Given an $(n,m,s)$ instance of \textsc{Set Partition}\xspace, a subset $W \subseteq U$ is said to be a \emph{witness $\beta$-halve} if $|W|\in (\tfrac{1}{2}\pm\beta)n$ and there exist disjoint subsets $S_1,S_2 \subseteq F$ such that $N(S_1 \cup S_2)=U$, $\sum_{f \in S_1 \cup S_2}|N(f)|=n$, $N(S_1) = W$, $N(S_2) = U \setminus W$ and $|S_1|+|S_2|=s$. \end{definition} Note that this is similar to the intuitive definition outlined in Section~\ref{sec:intro}, except that we require $|W|\in (\tfrac{1}{2}\pm\beta) |U|$ and we adjusted the definition to the \textsc{Set Partition}\xspace problem. Since $S_1 \cup S_2$ is a set partition of size $s$ we see that if a witness $\beta$-halve exists, we automatically have a yes instance. In this section we will give randomized algorithms that solve promise-variants of \textsc{Set Partition}\xspace with the promise that, if the instance is a yes-instance, there will be an exponential number of witness halves that are sufficiently balanced (i.e. of size close to $n/2$). In the first subsection we outline the basic algorithm and in the second subsection we show how tools from the literature can be combined with our approach to also give a faster algorithm if the number of sets is exponential in $n$. \subsection{The basic algorithm} \begin{theorem}\label{thm:main} There exists an algorithm $\mathtt{A1}$ that takes an $(n,m,\solsize)$-instance of \textsc{Set Partition}\xspace and real numbers $\beta,\zeta >0$ satisfying $2\sqrt{\beta} \leq \zeta < 1/4$ as input, runs in time $2^{(1-(\zeta/2)^4)n}\poly(n)m$, and has the following property: If there exist at least $\Omega(2^{\zeta n})$ witness $\beta$-halves it returns \yes with at least constant probability, and if there does not exist a set partition of size $\solsize$ it returns \no. \end{theorem} Note that the theorem does not guarantee anything on Algorithm~$\mathtt{A1}$ if a partition of $\solsize$ sets exists and there are only few witness halves, but we will address this later. A high level description of the Algorithm~$\mathtt{A1}$ is given in Figure~\ref{alg:mainalg}: \begin{figure}[H] \begin{framed} \begin{algorithmic}[1] \REQUIRE $\mathsf{A1}(G=(F\mathop{\dot{\cup}}U,E), \solsize,\zeta,\beta)$. \hfill\algorithmiccommentt{Assumes $2\sqrt{\beta}\leq \zeta < 1/4$} \ENSURE An estimate of whether there exists a set partition of size $\solsize$. \FOR{integer $l$ satisfying $\lfloor(1/2-\beta)n\rfloor < l < \lceil(1/2+\beta)n\rceil$}\label{line:startloop} \STATE Sample $\mathcal{W} \subseteq \binom{U}{l}$ by including every set of $\binom{U}{l}$ with probability $2^{-\zeta n}$.\label{lin:smpl} \STATE For every $W\in \mathcal{W}$ and $i \in [n]$, compute $c_i(W)$ and $c_i(U \setminus W)$.\label{lin:lem} \LineIf{$\exists i \in [n]: c_i(W) \wedge c_{s-i}(U \setminus W) $}{\algorithmicreturn\ \yes.} \ENDFOR \STATE \algorithmicreturn\ \no. \end{algorithmic} \end{framed} \caption{High level description of the Algorithm implementing Theorem~\ref{thm:main}.} \label{alg:mainalg} \end{figure} Here, we define $c_i(W)$ to be true if and only if there exists $S_1 \subseteq F$ with $|S_1|=i$, $N(S_1)=W$, and for every $f,f' \in S_1$ with $f \neq f'$, $N(f) \cap N(f') = \emptyset$. Given a set family $\mathcal{W}$, we denote ${\downarrow}\mathcal{W}=\{X: \exists W \in \mathcal{W} \wedge X \subseteq W \}$ for the \emph{down-closure} of $\mathcal{W}$. The following lemma concerns the sub-routine invoked in Algorithm~\ref{alg:mainalg} and can be proved via known dynamic programming techniques, and is postponed to Appendix~\ref{app:knowndp}. \begin{lemma}\label{lem:downclosure1} There exists an algorithm that given a bipartite graph $G=(F \mathop{\dot{\cup}} U,E)$ and $\mathcal{W} \subseteq 2^{U}$ with $|U|=n$ and $|F|=m$, computes $c_i(W)$ for all $W \in \mathcal{W}$ and $i \in [n]$ in $O(\poly(n)|{\downarrow}\mathcal{W}| m)$ time. \end{lemma} Thus, for further preparation of the proof of Theorem~\ref{thm:main}, we need to analyze the maximum size of the (down/up)-closure of $\mathcal{W}$ in Algorithm~$\mathtt{A1}$ in Figure~\ref{alg:mainalg}. \begin{lemma}\label{lem:bndclosure} Let $\zeta>0$, $\beta$ (which may be negative) be real numbers satisfying $2\sqrt{|\beta|} \leq \zeta < 1/4$ and $|U|=n$. Suppose $\mathcal{W}\subseteq \binom{U}{(1/2 +\beta)n}$ with $|\mathcal{W}|\leq 2^{(1-\zeta)n}$. Then $|{\downarrow}\mathcal{W}| \leq n2^{(1-(\zeta/2)^4)n}$. \end{lemma} \begin{proof} Let $\lambda \leq \beta$ and $w_\lambda = |\{ W \in {\downarrow}\mathcal{W}: |W|=\lambda n\}|$, so $|{\downarrow}\mathcal{W}| \leq n\cdot\max_{\lambda}w_\lambda$. Then we have the following upper bounds: \[ w_\lambda \leq \binom{n}{\lambda n} \leq 2^{h(\lambda)n}, \qquad w_\lambda \leq |\mathcal{W}|\binom{(1/2+\beta) n}{\lambda n} \leq 2^{\left((1-\zeta)+h\left(\frac{\lambda}{1/2+\beta}\right)(1/2+\beta)\right) n}. \] To see the second upper bound, note that any set $W \in \mathcal{W}$ can have at most $\binom{(1/2+\beta) n}{\lambda n}$ subsets of size $\lambda n$. Thus, we see that $|{\downarrow}\mathcal{W}|/n$ is upper bounded by $2^{f(\zeta,\beta)n}$, where \[ f(\zeta,\beta) = \max_{\lambda\leq 1/2+ \beta} \min \left\{h(\lambda), (1-\zeta)+h\left(\frac{\lambda}{1/2+\beta}\right)(1/2+\beta) \right\}. \] The remainder of the proof is therefore devoted to upper bounding $f(\zeta,\beta)$. We establish this by evaluating both terms of the minimum, setting $\lambda$ to be $\lambda'=(1-\zeta^2)(1/2+\beta)$. First note that by our assumption \begin{align*} \lambda' = (1-\zeta^2)(1/2+\beta) &= 1/2-\zeta^2/2+\beta-\zeta^2\beta \leq 1/2-\zeta^2/2+\zeta^2/4-\zeta^2\beta &< 1/2,\\ \lambda' / (1/2+\beta) &= 1-\zeta^2 &> 1/2. \end{align*} Therefore, since $h(x)$ is increasing for $x < 1/2$, $h(\lambda) \leq h(\lambda')$ for $\lambda \leq \lambda'$. Similarly, $h\left(\frac{\lambda}{1/2+\beta}\right)$ is at most $h\left(\frac{\lambda'}{1/2+\beta}\right)$ for $\lambda \geq \lambda'$, and we may upper bound $f(\zeta,\beta)$ by the maximum of the two terms of the minimum in $f(\zeta,\beta)$ obtained by setting $\lambda=\lambda'$. For the first term of the minimum, note that by Lemma~\ref{fact:bounds}, Item 1: \begin{align*} h(\lambda') = h((1-\zeta^2)(1/2+\beta)) &\leq 1-(1/2-(1-\zeta^2)(1/2+\beta))^2\\ &= 1-\left( \zeta^2/2-\beta+\beta\zeta^2 \right)^2\\ &\leq 1-\left( \zeta^2/2-\beta \right)^2\\ &\leq 1-(\zeta^2/4)^2 = 1-(\zeta/2)^4. \end{align*} For the second term we have \begin{align*} 1-\zeta + h\left(\frac{\lambda'}{1/2+\beta}\right)(1/2+\beta) &= 1-\zeta + h(1-\zeta^2)(1/2+\beta) &\hfill\algorithmiccommentt{by Lemma~\ref{fact:bounds}, Item 2}\\ &= 1-\zeta + h(\zeta^2)(1/2+\beta) &\algorithmiccommentt{$\beta < \frac{1}{64}$ by assumption} \\ &\leq 1-\zeta+\zeta^2\lg\left(\frac{4}{\zeta^2}\right)\tfrac{33}{64}&\algorithmiccommentt{$\zeta\lg\left(\frac{4}{\zeta^2}\right) \leq \tfrac{3}{2}$}\\ &\leq 1-\zeta+\zeta\tfrac{3}{2}\cdot\tfrac{33}{64}&\\ &\leq 1- \zeta/10.& \end{align*} note for the penultimate inequality that $\zeta\lg(\frac{4}{\zeta^2})$ is monotone increasing for $0\leq \zeta \leq 1/4$ and substituting $\zeta=1/4$ in this expression thus upper bounds it with $3/2$. \end{proof} Now we are ready to wrap up this section with the proof of Theorem~\ref{thm:main}: \begin{proof}[Proof of Theorem~\ref{thm:main}] We can implement Line~\ref{lin:lem} by invoking the algorithm of Lemma~\ref{lem:downclosure1} with both $|\mathcal{W}|$ and $\mathcal{W}' = \{W: [n] \setminus W \in \mathcal{W}\}$. This will take time $O(\poly(n)(|{\downarrow}W|+|{\downarrow} \mathcal{W}'|)m)$. This is clearly the bottleneck of the algorithm, so it remains to upper bound (the expectation of) $|{\downarrow}W|+|{\downarrow} \mathcal{W}'|$ by applying Lemma~\ref{lem:bndclosure}. To do this, note that $\mathcal{W} \subseteq \binom{n}{l}$, $\mathcal{W}' \subseteq \binom{n}{n-l}$, and we have that $(1/2-\beta)n \leq l,n-l \leq (1/2+\beta)n$. Also, $2\sqrt{|\beta|} \leq \zeta$ by assumption so indeed Lemma~\ref{lem:bndclosure} applies. Then on expectation $|\mathcal{W}| \leq \binom{n}{(1/2+\beta) n}2^{-\zeta n} \leq 2^{(1-\zeta)n}$, and thus the running time\footnote{Due to the sampling in Line~\ref{lin:smpl}, we actually only get an upper bound on the expectation of the running time, but by Markov's inequality we can simply ignore iterations where $\mathcal{W}$ exceeds twice the expectation.} indeed is as claimed. For the correctness, it is easily checked that the algorithm never returns false positives. Moreover, if there exist at least $\Omega(2^{\zeta n})$ witness $\beta$-halves then for some $l$ in the loop of Line~\ref{line:startloop}, there are at least $\Omega(2^{\zeta n}/n)$ witness halves of size $l$. Thus in this iteration we see by Lemma~\ref{fact:bounds}, Part 3 that \begin{equation}\label{eq:probwit} \Pr[\nexists \text{ witness halve } W \in \mathcal{W} ] \leq \left(1-\frac{1}{2^{\zeta n}}\right)^{\Omega(2^{\zeta n}/n)} \leq e^{-1/n}. \end{equation} and if a witness halve $W \in \mathcal{W}$ exists the algorithm returns $\mathbf{yes}$ since $c_i(W) \wedge c_{s-i}(U \setminus W)$ holds for some $i$ by the definition of witness halve. Therefore, if we perform $n$ independent trials of Algorithm $\mathtt{A_1}$ it return $\mathbf{yes}$ with probability at least $1-1/e$. \end{proof} \subsection{Improvement in the case with exponentially many input sets.} In this section we show that under some mild conditions, the existence of many witness halves can also be exploited in the presence of exponentially many sets. This largely builds upon machinery developed by Bj\"orklund et al.~\cite{DBLP:journals/siamcomp/BjorklundHK09,DBLP:journals/mst/BjorklundHKK10}. To state our result as general as possible we assume the sets are given via an oracle so our running can be sublinear in the input if the number of sets is close to $2^n$. \begin{theorem}\label{thm:manysets} There exists an algorithm that, given oracle access to an $(n,m,\solsize)$-instance of \textsc{Set Partition}\xspace and real numbers $\beta,\zeta >0$ satisfying $2\sqrt{\beta} \leq \zeta < 1/4$, runs in time $2^{(1-(\zeta/2)^4)n}\poly(n)T$ and has the following property: if there exist at least $\Omega(2^{\zeta n})$ witness $\beta$-halves, it outputs \yes with constant probability and if there does not exist a set partition of size $\solsize$ it outputs \no. Here the oracle algorithm accepts $X\subseteq U$ as input, and decides whether there exists $f \in F$ with $N(f)=X$ in time $T$. \end{theorem} The proof of Theorem~\ref{thm:manysets} is identical to the proof of Theorem~\ref{thm:main} (and therefore omitted), except that here we use the following lemma instead of Lemma~\ref{lem:downclosure1}: \begin{lemma}\label{lem:downclosure2} There exists an algorithm that, given $\mathcal{W} \subseteq 2^{U}$ and oracle access to a bipartite graph $G=(F \mathop{\dot{\cup}} U,E)$, computes the values $c_i(W)$ for all $W \in \mathcal{W}$ in $O(T|{\downarrow}\mathcal{W}|\poly(n))$ time. Here the oracle algorithm accepts $X\subseteq U$ as input, and decides whether there exists $f \in F$ with $N(f)=X$ in time $T$. \end{lemma} This lemma mainly reiterates previous work developed by Bj\"orklund et al.~\cite{DBLP:journals/siamcomp/BjorklundHK09,DBLP:journals/mst/BjorklundHKK10}, but since they did not prove this lemma as such we include a proof here in Appendix~\ref{subsec:yates}. \section{Finding Large Set Covers Faster}\label{sec:mainproofs} In this section we will use the tools of the previous sections to prove our main results, Theorems~\ref{thm:largesol} and~\ref{thm:col}. We first connect the existence of large solutions to the existence of many witness halves in the following lemma: \begin{lemma}\label{lem:largesolutionmanywitnesssplits} If an $(n,m,\solsize)$-instance of \textsc{Set Partition}\xspace has no empty sets and satisfies $\solsize \geq \sigma_0 n$ and $|N(f)| \leq \sigma_0^4n/8$ for every $f \in F$, there is a solution if and only if there exist at least $2^{\sigma_0 n}/4$ witness $(\sigma_0^2/4)$-halves. \end{lemma} \begin{proof} Note that the backward direction is trivial since by definition the existence of a witness halve implies the existence of a solution. For the other direction, suppose $S = \{f_1,\ldots,f_s\}$ is a set partition, and denote $d_i = |N(f_i)|$. Suppose $S' \subseteq S$ is obtained by including every element of $S$ with probability $1/2$ in $S'$. since $N(f_i)\cap N(f_j)=\emptyset$ for $i\neq j$, we have that the random variable $|N(S')|$ is a sum of $s$ independent random variables that equal $0$ and $d_i$ with probability $1/2$. By the Hoeffding bound (Lemma~\ref{lem:hoeff}) we see that \[ \Pr\left[\Big|\left| N(S') \right| - \mathbb{E}[|N(S')|] \Big| \geq n\sigma_0^2/4\right] \leq 2\cdot \exp\left( \frac{-n^2\sigma_0^4/8}{\sum_{e \in S}d_e^2}\right) \leq 2\cdot \exp\left( \frac{-n^2\sigma_0^4/8}{n^2\sigma_0^4/8}\right) < \tfrac{3}{4}, \] where the second inequality follows from $d_e \leq \sigma_0^4n/8$ and $\sum_{e \in S}d_e =n$. So for at least $2^{|S|}/4 \geq 2^{\sigma_0 n}/4$ subsets $S' \subseteq S$ we have that $|N(S')| \in (\tfrac{1}{2}\pm \sigma_0^2/4)n$. Thus, since for each such $S'$, $N(S')$ determines $S'$ and thus gives rise to a distinct witness halve, there are at least $2^{\sigma_0 n}/4$ witness $(\sigma_0^2/4)$-halves. \end{proof} Now we are ready to prove the first main theorem, which we recall here for convenience. \begin{reptheorem}{thm:largesol} There is a Monte Carlo algorithm that takes an instance of \textsc{Set Cover}\xspace on $n$ elements and $m$ sets and an integer $\solsize$ as input and determines whether there exists a set cover of size $s$ in $O(2^{(1-\Omega(\sigma^4))n}m)$ time, where $\sigma=s/n$. \end{reptheorem} \begin{proof} The algorithm implementing Theorem~\ref{thm:largesol} is given in Figure~\ref{alg:alglargesol}. \begin{figure}[H] \begin{framed} \begin{algorithmic}[1] \REQUIRE $\mathsf{A2}(G=(F\mathop{\dot{\cup}}U,E),\sigma)$. \STATE Ensure $|N(f)| \leq \sigma^4n/1000$ using Observation~\ref{obs:nolinear}\label{lin:redlin}. \FOR{every integer $s$ satisfying $\lfloor \sigma n/2 \rfloor \leq s \leq \sigma n$}\label{lin:forl} \STATE Create an $(n,m',s)$-instance $((F' \mathop{\dot{\cup}} U,E),s)$ of \textsc{Set Partition}\xspace where $F'$ is constructed by adding a vertex $f'$ with $N(f')=X$ for all $ f \in F, X \subseteq N(f)$.\label{lin:setpart} \STATE Let $\sigma_0 = s/n$. \LineIf{$\mathsf{A1}((F' \mathop{\dot{\cup}} U,E),s,\sigma_0,\sigma_0^2/4)= \yes$}{\algorithmicreturn\ \yes.}\label{lin:subrout} \ENDFOR \STATE Pick an arbitrary subset $X \in \binom{U}{n/2}$.\label{lintr1} \STATE Find the sizes $l$ and $r$ of the smallest set covers in the instances induced by elements $X$ and respectively elements $U \setminus X$ in $O(2^{n/2}\poly(n)m)$ time with standard dynamic programming.\label{lintr2} \LineIfElse{$l+r <= \sigma n$}{\algorithmicreturn\ \yes}{\algorithmicreturn\ \no.}\label{lin:retyes2} \end{algorithmic} \end{framed} \caption{Algorithm for \textsc{Set Cover}\xspace large solutions (implementing Theorem~\ref{thm:largesol}).} \label{alg:alglargesol} \end{figure} We first focus on the correctness of this algorithm. It is clear that the algorithm never returns false positives on Line~\ref{lin:subrout} since Algorithm~$\mathsf{A1}$ also has this property. If $\mathbf{yes}$ is returned on Line~\ref{lin:retyes2} it is also clear there exists a solution. Now suppose that a set cover $S$ of size at most $\sigma n$ exists. First suppose $\sigma n/2 \leq |S| \leq \sigma n$. We consider $\solsize=|S|$ in some iteration of the loop on Line~\ref{lin:forl}. Notice that now in Line~\ref{lin:setpart} we have reduced the problem to a yes-instance of \textsc{Set Partition}\xspace without empty sets satisfying $|N(f)| \leq \sigma^4n/1000$ for every $f \in F$. Therefore Lemma~\ref{lem:largesolutionmanywitnesssplits} applies with $\sigma_0\geq \sigma/2$ and we see there are at least $2^{\sigma_0 n}/4$ witness $(\sigma_0^2/4)$-halves. Thus, we can apply Theorem~\ref{thm:main} with $\zeta=\sigma_0$ and $\beta=\sigma^2_0/4$ to find the set $S$ with constant probability, since $\beta \leq (\zeta/2)^2$. Now suppose $|S| \leq \sigma n/2$. Then picking every element in $S$ twice is a solution (as a multiset), and it implies that for every $X \subseteq U$ the sizes of the smallest set covers $l$ and $r$ (as defined in the algorithm) satisfy $l+r \leq \sigma n$. Thus Lines~\ref{lintr1}-\ref{lin:retyes2} find such a set and the algorithm returns $\mathbf{yes}$. For the running time, Line~\ref{lin:redlin} takes at most $O(2^{(1-\sigma^4/1000)n}\poly(n)m)$ due to Observation~\ref{obs:nolinear}. For Line~\ref{lin:subrout}, due to Theorem~\ref{thm:main} this runs in time \begin{align*} O(2^{(1-(\zeta/2)^4)n}\poly(n)m') &= O(2^{(1-(\sigma_0/2)^4)n}\poly(n)2^{\sigma^4n/1000}m) \\ &\leq O(2^{(1-(\sigma/4)^4)n}\poly(n)2^{\sigma^4n/1000}m) \\ &= O(2^{(1+\sigma^4(1/1000-1/4^4))n}\poly(n)m) \\ &\leq O(2^{(1-\Omega(\sigma^4))n}\poly(n)m). \end{align*} as claimed in the theorem statement. \end{proof} As a more direct consequence of the tools of the previous section we also get the following result for \textsc{Set Partition}\xspace: \begin{theorem}\label{thm:manysets2} There exists a Monte Carlo algorithm for \textsc{Set Partition}\xspace that, given oracle access to an $(n,m,\sigma n)$-instance satisfying $0 < |N(f)| \leq \sigma^4 n/8$ for every $f \in F$, runs in $2^{(1-\Omega(\sigma^4))n}\poly(n)T$ time. Here the oracle algorithm accepts $X\subseteq U$ as input, and decides whether there exists $f \in F$ with $N(f)=X$ in time $T$. \end{theorem} \begin{proof} Lemma~\ref{lem:largesolutionmanywitnesssplits} implies the instance is a YES-instance if and only if there exist $2^{\sigma n}/4$ witness $(\sigma^2/4)$-halves. Thus Theorem~\ref{thm:manysets} implies the theorem statement. \end{proof} Note that this theorem also implies an $O((m+2^{(1-\Omega(\sigma^4))n})\poly(n))$ time algorithm for \textsc{Set Partition}\xspace where the sets are given explicitly because we can construct a binary search tree after which we can implement the oracle to run in $T=n$ query time. We remark that it would be interesting to see whether the assumption $|N(f)| \leq \sigma^2 n/4$ is needed, but removing this assumption seems to require more ideas than the ones from this work: For example if the solution has three sets of size $3n/10$ there will be no witness halve that is sufficiently balanced, and alternatively using Observation~\ref{obs:nolinear} seems to be too slow. However, if we settle for a additive $1$-approximation we can deal with this issue in a simple way and have as a particular consequence the second result mentioned in the beginning of this paper: \begin{reptheorem}{thm:col} There is a randomized algorithm that given graph $G$ and integer $\solsize=\sigma n$, in $O^*(2^{(1-\Omega(\sigma^4))n})$ time outputs \yes with constant probability, if $\chi(G) < \solsize$, and \no, if $\chi(G) > \solsize$. \end{reptheorem} \begin{proof} Let $G=(V,E)$ and define a \textsc{Set Partition}\xspace instance where for every independent set $I \subseteq V$ of $G$ there is an element $f \in F$ with $N(f)=I$. It is easy to see that this instance of \textsc{Set Partition}\xspace has a solution of size $s$ if and only if $\chi(G) \leq s$. Check in $\binom{n}{\sigma^4 n/8}$ time whether $G$ has an independent set of size $\sigma^4n/8$. If such an independent set is found, remove this set from the graph and return yes if the obtained graph has a $(k-1)$-coloring and no otherwise. Using the $O^*(2^{n})$ time algorithm by Bj\"orklund et al.~\cite{DBLP:journals/siamcomp/BjorklundHK09} in the second step, this procedure clearly runs in time $O^*(2^{(1-\Omega(\sigma^4))n})$, and always finds a coloring using at most one more color than the minimum number of colors if a large enough independent set exists. On the other hand, if the maximum independent set of $G$ is of size at most $\sigma^4n/8$, we may apply Theorem~\ref{thm:manysets2} with $T=\poly(n)$ since it can be verified in polynomial time whether a given $X \subseteq V$ is an independent set, and the theorem follows. \end{proof} \section{Directions for Further Research}\label{sec:concremark} In this section, we relate the work presented to some notorious open problems. The obvious open question is to determine the exact complexity of the \textsc{Set Cover}\xspace problem: \begin{openproblem} Can \textsc{Set Cover}\xspace be solved in time $O^*((2-\Omega(1))^n)$? \end{openproblem} This question was already stated at several places. It is known that if a version of \textsc{Set Cover}\xspace where the number of solutions modulo $2$ is counted can be solved in $(2-\Omega(1))^{n}$ the Strong Exponential Time Hypothesis fails. We refer to~\cite{DBLP:conf/coco/CyganDLMNOPSW12}, for more details. Less ambitiously, it is natural to wonder whether our dependency on $\sigma$ can be improved. Our algorithm and analysis seem loose, but we feel the gain of a sharpening this analysis does not outweigh the technical effort currently: For a better dependence, we need both a better bound in Lemma~\ref{lem:bndclosure} and to reduce the set sizes more efficiently than in Observation~\ref{obs:nolinear}. As further research we suggest to find a different algorithmic way to deal with the case where many witness halves are unbalanced. But this alone will not suffice to give linear dependence in $\sigma$ since in Lemma~\ref{lem:bndclosure} we do not expect to get linear dependence on $\zeta$ even if $\beta=0$. It would also be interesting to see which other instances of \textsc{Set Cover}\xspace can be solved in $O^*((2-\Omega(1))^n)$ time. One that might be worthwhile studying is whether this includes instances with optimal set covers in which the sum of the set sizes is at least $(1+\Omega(1))n$; one may hope to find exponentially many (balanced) witness halves here as well. In~\cite{DBLP:conf/coco/CyganDLMNOPSW12}, the authors also give a reduction from \textsc{Subset Sum}{} to \textsc{Set Partition}\xspace{}. The exact complexity of \textsc{Subset Sum}{} with small integers is also something we explicitly like to state as open problem here, especially since the $O^*(t)$ time algorithm (where $t$ is the target integer) is perhaps one of the most famous exponential time algorithms: \begin{openproblem} Can \textsc{Subset Sum}{} with target $t$ be solved in time $O^*(t^{1-\Omega(1)})$, or can we exclude the existence of such an assuming the Strong Exponential Time Hypothesis? \end{openproblem} Note this question was before asked in~\cite{husfeldt_et_al:DR:2013:4342} by the present author. It would be interesting to study the complexity of \textsc{Subset Sum}{} in a similar vein as we did in this paper: are there some special properties allowing a faster algorithm? For example, a faster algorithm for instances of high `density' (e.g., $n/\lg t$) may be used for improving an algorithm of Horowitz\&Sahni~\cite{HorowitzSahni74}. Note that here the `density' of a \textsc{Subset Sum}{} instance is the inverse of what one would expect when relating to the definition of density of $k$-CNF formula. Another question that has already open for a while is \begin{openproblem} Can \textsc{Graph Coloring} be solved in time $O^*(2^{(1-\Omega(1))n})$? \end{openproblem} Could the techniques of this paper be used to make progress towards resolving this question? While our algorithm seems to benefit from the existence of many optimal colorings, in an interesting paper Bj\"orklund~\cite{DBLP:journals/corr/Bjorklund15} actually shows that the existence of \emph{few} optimal colorings can be exploited in graphs of small pathwidth. Related to this is also the Hamiltonicity problem. In our current understanding this problem becomes easier when there is a promise that there are few Hamiltonian cycles (see~\cite{DBLP:conf/icalp/BjorklundDH15}, but also e.g.~\cite{DBLP:journals/siamcomp/ChariRS95} allows derandomizations of known probabilistic algorithms in this case), so a natural approach would be to deal explicitly with instances with many solutions by sampling dynamic programming table in a similar vein as done in this paper. \subparagraph{Acknowledgements} The author would like to thank Per Austrin, Petteri Kaski, Mikko Koivisto for their collaborations resulting in~\cite{DBLP:conf/stacs/AustrinKKN15,DBLP:journals/corr/AustrinKKN15} that mostly inspired this work, Karl Bringmann for discussions on applications of~\cite{DBLP:journals/corr/AustrinKKN15} to \textsc{Set Partition}, and anonymous reviewers for their useful comments. \bibliographystyle{plain}
{'timestamp': '2016-08-12T02:06:20', 'yymm': '1608', 'arxiv_id': '1608.03439', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03439'}
arxiv
\section{Introduction} SQL is the {\em de facto} relational database query language that stands still \cite{Atzeni:2013:RMD:2503792.2503808} despite the advent of new trends as Big Data, NoSQL, RDF stores and others. It builds upon the Codd's \cite{Codd70,Codd72} seminal relational data model accompanied by an algebra and calculus to operate on data. Former proposals such as \cite{Grefen1994} better provide a formal framework for current SQL implementations. As a query language, SQL can be well understood from Codd's tuple relational calculus but also from logic programming (in particular, \cite{Ullman88} includes equivalences between relational operations and logic rules). However, among other features beyond the original relational model, SQL provides the notion of temporary view defined in {\tt WITH} clauses (as described in Section \ref{with}), whose definition is available only to the query in which it occurs \cite{Silberschatz6th}. This is no longer representable either in relational formal languages or directly in logic programming.\footnote{Obviously, logic programming implementations provide general-purpose languages as Prolog that can emulate a temporary definition.} Here is when intuitionistic logic programming may come at help to providing first-class citizen semantics: Approaches as \cite{DBLP:journals/jlp/Gabbay85,DBLP:journals/jlp/McCarty88,MillerModulesJLP,Bonner90hypotheticaldatalog,Hodas94} fit into this logic, an extension of logic programming including in particular embedded implications. Adding negation to intuitionistic logic programming might develop paradoxes which are circumvented in \cite{bonner90adding} by dealing with two kind of implications: for rules ($\leftarrow$) and for goals ($\Leftarrow$, i.e., an embedded implication). Whereas in the formula $A \leftarrow B$, the atom $B$ is ''executed" for proving $A$, in the formula $A \Leftarrow B$, the atom $B$ is ``assumed" to be true for proving $A$. Hypothetical Datalog \cite{Bonner89hypotheticaldatalog,Bonner90hypotheticaldatalog,bonner90adding,bonner89expressing} incorporated this logic and has been a proposal thoroughly studied from semantic and complexity point-of-views. The work \cite{sae13c-ictai13} (recalled in Section \ref{hypothetical-datalog}) presented an extended (w.r.t. \cite{Bonner89hypotheticaldatalog,Bonner90hypotheticaldatalog,bonner90adding,bonner89expressing}) intuitionistic setting along with an implementation in the deductive system DES \cite{saenzDES}, in which a rule is accepted in the antecedent of an embedded implication, and not only facts as in \cite{bonner90adding}. Driven from the need for supporting a broader subset of SQL in this system, we show how to take advantage of the intuitionistic embedded implication to model {\tt WITH} SQL queries in a logic setting, an application which has not been proposed to the best of our knowledge so far. Thus, as shown in Section \ref{translating}, it is possible to have such SQL queries translated into Datalog, and can be therefore processed by a deductive engine. But Hypothetical Datalog is powerful enough to even apply the same technique to model assumptions in SQL queries, with the (non-standard) clause \mytt{ASSUME}. This clause enables both positive and negative assumptions on data, as shown in Section \ref{assume}, which are useful for modelling ``what-if'' scenarios. Finally, we present the deductive system DES at work with examples of \mytt{WITH} and \mytt{ASSUME} queries in Section \ref{examples}. Our approach is also useful for connecting with external relational database systems which cannot process these clauses. DES then behaves as a front-end capable of processing either novel or unsupported features in such systems. \section{The SQL {\tt WITH} Clause} \label{with} Typically, complex SQL queries are broken-down for applying the {\em divide-and-conquer} principle as well as for enhancing readability and maintenance. Introducing intermediate views with {\tt CREATE VIEW} statements is in the order of the day, but this might neither be recommendable (making these views observable for other users) nor possible (only certain users with administration permissions are allowed to create views). The {\tt WITH} clause provides a form of encapsulation in SQL by locally defining those broken-down views, making their realms to pertain to the context of a given query. Next, the syntax of a query $Q$ including this clause is recalled: \vspace{2mm} \begin{tabular}{ll} \mytt{WITH} &\mytt{{\em R}$_1$ AS {\em SQL}$_1$,}\\ &\mytt{\ldots,} \\ &\mytt{{\em R}$_n$ AS {\em SQL}$_n$}\\ \mytt{{\em SQL}} \end{tabular} \noindent where each \mytt{{\em R}$_i$} is a temporary view name defined by the SQL statement \mytt{{\em SQL}$_i$}, and which can be referenced only in \mytt{{\em SQL}}, the ultimate query that builds the outcome of the query $Q$. This query can be understood as a relation with name \mytt{{\em R}} and defined with the DDL statement \mytt{CREATE VIEW {\em R} AS} $Q$. With respect to the semantics of an SQL query, we recall and adapt the notation in \cite{cgs12a-flops2012} which in turn is based on \cite{Grefen1994}. A {\em table instance} is a multiset of facts (following logic programming instead of relational databases). A {\em database instance} $\Delta$ of a database schema is a set of table instances, one for each defined table ({\em extensional} relation) in the database. The notation $\Delta(T)$ represents the instance of a table $T$ in $\Delta$. Each query or view ({\em intensional} relation) $R$ is defined as a multiset of facts, and $\Phi_R$ represents the ERA (Extended Relational Algebra) expression associated to an SQL query or view $R$, as explained in \cite{Molina08}. An intensional relation usually depends on previously defined relations, and sometimes it will be useful to write $\Phi_R(R_1,\dots,R_n)$ indicating that $R$ depends on $R_1, \dots, R_n$. Here, we assume that each extensional relation in a database instance has attached type information for each one of its named arguments. As well, each intensional relation argument receives its type via inferencing and arbitrary names if not provided in its definition. Tables are denoted by their names, that is, $\Phi_T = T$ if $T$ is a table. \begin{definition} \label{def:SQLERA} {\em The \emph{computed answer} of an ERA expression $\Phi_R$ with respect to some schema instance $\Delta$ is denoted by $\evalSQL{\Phi_R}{\Delta}$, where: \begin{itemize} \item If $R$ is an extensional relation, $\evalSQL{\Phi_R}{\Delta} =\, \Delta(R)$. \item If $R$ is an intensional relation and $R_1, \dots, R_n$ the relations defined in $R$, then $\evalSQL{\Phi_R}{\Delta} =\, \Phi_R(\evalSQL{\Phi_{R_1}}{\Delta}, \dots, \evalSQL{\Phi_{R_n}}{\Delta})$. \hfill $_\square$ \end{itemize} } \end{definition} Queries are executed by SQL systems. The answer for a query $Q$ and a database instance $\Delta$ in an implementation is represented by $\ans_\Delta$($Q$). The notation $\ans_\Delta$($R$) abbreviates $\ans_\Delta$(\mytt{SELECT * FROM $R$}). In particular, we assume the existence of \emph{correct} SQL implementations. \begin{definition} \label{def:correctSQL} {\em A \emph{correct} SQL implementation verifies that $\ans_\Delta$($Q$) = $\evalSQL{\Phi_Q}{\Delta}$ for every query $Q$.\hfill $_\square$ } \end{definition} \section{Hypothetical Datalog} \label{hypothetical-datalog} Hypothetical Datalog is an extension of function-free Horn logic \cite{bonner90adding}. Following \cite{sae13c-ictai13}, the syntax of the logic is first order and includes a universe of constant symbols, a set of variables and a set of predicate symbols. For concrete symbols, we write variables starting with either an upper-case letter or an underscore, and the rest of symbols starting with lower-case. Removing function symbols from the logic is a condition for finiteness of answers, a natural requirement of relational database users. As in Horn-logic, a rule has the form $A \leftarrow \phi$, where $A$ is an atom and $\phi$ is a conjunction of goals. Since we consider a hypothetical system, a goal can also take the form $R_1 \land \ldots \land R_n \Rightarrow G$, a construction known as an {\em embedded implication}. The following definition captures the syntax of the language, where $vars(T)$ is the set of variables occurring in $T$: \begin{definition} {\em \quad \\ $R := A \mid A \leftarrow G_1 \land \ldots \land G_n$ \\ $G := A \mid \neg G \mid R_1 \land \ldots \land R_n \Rightarrow G$\\ \noindent where $R$ and $R_i$ stand for rules, $G$ and $G_i$ for goals, $A$ for an atom (possibly containing variables and constants, but no compound terms), and $\bigcup vars(R_i) \cap vars(R) = \emptyset$, and $vars(R_i)$ and $vars(G)$ are disjoint.\hfill $_\square$ } \end{definition} Disjoint conditions ensure that assumed rules do not depend on actual substitutions along inference, i.e., assumed rules take the form they have in the program. Semantics is built with a stratified inference system which can be consulted in \cite{sae13c-ictai13}. Here we recall the inference rule for the embedded implication:\footnote{Each rule in this inference system is read as: If the formulas above the line can be inferred, then those below the line can also be inferred.} For any goal $\phi$ and database instance $\Delta$: \begin{center} \medskip $\infer[]{\Delta \vdash R_1 \land \ldots \land R_n \Rightarrow \phi}{\Delta \cup \{R_1, \ldots, R_n\} \vdash \phi}$ \medskip \end{center} This means that for proving the conclusion $\phi$, rules $R_i$, together with the current database instance $\Delta$ can be used in subsequent inference steps. The {\em unified stratified semantics} defined in \cite{sae13c-ictai13} builds a set of axioms $\mathcal{E}$ that provides a means to assign a meaning to a goal as: $solve(\phi,\mathcal{E}) = \{\Delta \vdash id:\psi \in \mathcal{E} ~ \mbox{such that} ~ \phi\theta = \psi\}$, where $\theta$ is a substitution and each axiom in $\mathcal{E}$ is mapped to the database $\Delta$ it was deduced for, and the inferred fact $\psi$ is labelled with its data source (for supporting duplicates). We use $\Delta(\mathcal{E})$ to denote the multiset of facts $\psi$ so that $\Delta \vdash id:\psi \in \mathcal{E}$ for any $id$. So, this inference rule captures what SQL {\tt WITH} statements need if translated to Hypothetical Datalog, because each $R_i$ can represent each temporary view definition, as will be shown in the next section. \section{Translating SQL into Datalog} \label{translating} We consider standard SQL as found in many textbooks (e.g., \cite{Silberschatz6th}), but also allowing \verb|FROM|-less statements, i.e., providing a single-row output constructed with the comma-separated expressions after the \verb|SELECT| keyword (Oracle, for instance, resorts to feed the row from the \verb|dual| table to express the same feature). Here, we define a function \mytt{{\em SQL\_to\_DL}} that takes a relation name and an SQL statement as input and returns a multiset of Datalog rules providing the same meaning as the SQL relation for a corresponding predicate with the same name as the relation. The following (incomplete) definition for this function includes only a couple of the basic cases, where others can be easily developed from \cite{Ullman88}. From here on, set-related operators and symbols refer to multisets, as SQL relations can contain duplicates. \medskip \noindent {\em \% Basic SELECT statement} \\ \noindent \mytt{{\em SQL\_to\_DL}}($r$, \mytt{SELECT A$_1$,\ldots,A$_n$ FROM $Rel$ WHERE $Cond$}) =\\ \indent \{ $r(\overline{X_i}) \leftarrow DLRel(\overline{X_i}), DLCond(\overline{X_j}) ~ \} \bigcup RelRules \bigcup CondRules$, \\ where \mytt{{\em SQLREL\_to\_DL}}$(Rel)=(DLRel(\overline{X_i}), RelRules)$, and \\ \indent \mytt{{\em SQLCOND\_to\_DL}}$(Cond)=(DLCond(\overline{X_j}), CondRules)$ \medskip \noindent {\em \% Duplicate-preserving union} \\ \noindent \mytt{{\em SQL\_to\_DL}}($r$, \mytt{{\em SQL}}$_1$ \mytt{UNION ALL} \mytt{{\em SQL}}$_2$) = \\ \indent \mytt{{\em SQL\_to\_DL}}($r$, \mytt{{\em SQL}}$_1$) $\bigcup$ \mytt{{\em SQL\_to\_DL}}($r$, \mytt{{\em SQL}}$_2$) \medskip Here, each \mytt{A}$_i$ is an argument name present in the relation $Rel$ with corresponding logic variable $X_i$. $Rel$ is constructed with either a single defined relation (table or view), or a join of relations, or an SQL statement. Function \mytt{{\em SQLREL\_to\_DL}} (resp., \mytt{{\em SQLCOND\_to\_DL}}) takes an SQL relation (resp. condition) and returns a goal and, possibly, additional rules which result from the translation. Variables $\overline{X_j}$ come as a result of the translation of the condition $DLCond$ to a goal. As well, some basic cases are presented next for these functions, where $GoalName$ is an arbitrary, fresh new goal name: \medskip \noindent {\em \% Extensional/Intensional Relation Name} \\ \noindent \mytt{{\em SQLREL\_to\_DL}}$(RelName)=(RelName(\overline{X_i}), \{ \})$ \\ \noindent where $\overline{X_i}$ are the $n$ variables corresponding to the $n$-degree relation $RelName$. \medskip \noindent {\em \% SQL Statement} \\ \noindent \mytt{{\em SQLREL\_to\_DL}}$(SQL)=(GoalName(\overline{X_i})$, \mytt{{\em SQL\_to\_DL}}$(GoalName, SQL)$)\\ \noindent where $\overline{X_i}$ are the $n$ variables corresponding to the $n$-degree statement $SQL$. \medskip \noindent {\em \% NOT IN Condition} \\ \noindent \mytt{{\em SQLCOND\_to\_DL}}(\mytt{A$_i$ NOT IN} $Rel)=(not ~ DLRel(\overline{X_j}), RelRules)$\\ where \mytt{{\em SQLREL\_to\_DL}}$(Rel)=(DLRel(\overline{X_j}), RelRules)$, and $X_i \in \overline{X_j}$ is the corresponding variable to argument \mytt{A}$_i$. \medskip Completing this function by including the \mytt{WITH} statement is straightforward because every temporary view can be represented by a predicate resulting from the translation of the temporary view definition into Datalog rules. Assuming such predicates as the antecedent of an embedded implication can be used to augment the (local, temporary) database for interpreting the meaning of the translated SQL outcome query: \medskip \noindent {\mytt{{\em SQL\_to\_DL}}($r$, \mytt{WITH $r_1$ AS {\em SQL}$_1$, \ldots, $r_n$ AS {\em SQL}$_n$ {\em SQL}}) =}\\ \indent \{ $r(\overline{X_i}) \leftarrow$ \\ \indent \hspace*{1.7mm} $\land($\mytt{{\em SQL\_to\_DL}}($r_1$,\mytt{{\em SQL}}$_1$)) $\land$ \ldots \\ \indent \hspace*{1.7mm} $\land($\mytt{{\em SQL\_to\_DL}}($r_n$,\mytt{{\em SQL}}$_n$)) $\Rightarrow$ $s(\overline{X_i})$ \} $\bigcup$ \texttt{{\em SQL\_to\_DL}}($s$,\texttt{{\em SQL}}) \medskip \noindent where $\land(Bag)$ denotes $B_1 \land \cdots \land B_m$ ($B_i \in Bag$). The following theorem establishes the semantic equivalence of an SQL relation and its counterpart Datalog translation. \begin{theorem} {\em The semantics of an SQL $n$-degree relation $r$ defined by the query $Q$ on a database instance $\Delta$ coincides with the meaning of a goal $r(\overline{X_i})$, $1 \leq i \leq n$, for $\Delta' = \Delta \bigcup$ \mytt{{\em SQL\_to\_DL}}($r$,$Q$), that is: $\ans_\Delta(Q) = \Delta(solve(r(\overline{X_i}),\mathcal{E}))$, where $\mathcal{E}$ is the unified stratified semantics for $\Delta'$.} \hfill $_\square$ \end{theorem} \section{Beyond the WITH Clause: Expressing Assumptions} \label{assume} As a novel feature, hypothetical SQL queries (absent in the standard) were introduced (inspired in \cite{nss-flops08}) in DES version 2.6 for solving ``what-if'' scenarios. Syntax for such queries is: {\fontsize{11}{11} \vspace{3mm} \noindent {\tt ASSUME {\em SQL}$_1$ IN {\tt {\em Rel}}$_1$, ..., {\em SQL}$_n$ IN {\tt {\em Rel}}$_n$} {\tt {\em SQL};} \vspace{3mm} } \noindent which makes to {\em assume} the result of {\tt {\em SQL}}$_i$ in {\tt {\em Rel}}$_i$ when processing {\tt {\em SQL}}. This means that the semantics of each {\tt {\em Rel}}$_i$ is either overloaded (if the relation already exists) or otherwise defined with the facts of {\tt {\em SQL}}$_i$. Implementing this resorted to {\em globally} define each {\tt {\em Rel}}$_i$, which is not the expected behaviour as its definition must be local to {\tt {\em SQL}}. Roughly, solving an \mytt{ASSUME} query resorted to overload the meanings of each {\tt {\em Rel}}$_i$ (by inserting the required facts) before computing {\tt {\em SQL}} and, after solving, to restore them (by deleting the same facts). This also precluded nested assumptions, and such statements were allowed only as top-level queries but not as part of query definitions. For instance, if it would be allowed, the following query would be incorrectly computed in that scenario: {\fontsize{11}{11} \begin{verbatim} ASSUME SELECT 1 IN r(a), (ASSUME SELECT 2 IN r(a) SELECT * FROM r) IN s SELECT * FROM r,s; \end{verbatim} } \noindent because the meaning of \mytt{r} in the context of \mytt{SELECT * FROM r,s} would be overloaded with both \mytt{\{(1)\}} and \mytt{\{(2)\}}, instead of just with \mytt{\{(1)\}}. Applying hypothetical reasoning in this case solves this issue, allowing us not only to use nested assumptions in both top-level queries and views, but also to take advantage of negative assumptions. A negative assumption allows to {\em remove} facts from the meaning of a relation, which broadens the applicability of queries in decision-support scenarios. To specify negative assumptions, \mytt{NOT IN} is used instead of just \mytt{IN}. Hypothetical Datalog in \cite{Sae15c} introduces the notion of {\em restricted predicate} to handle negative assumptions in embedded implications. A restricted predicate includes at least a restricting rule whose head is an atom preceded by a minus sign. Its meaning is the set of facts deduced from regular rules minus the set of facts deduced from restricting rules. So, a negative assumption is modelled with a restricting rule in the antecedent of an embedded implication, so that the translation from SQL to Hypothetical Datalog for \mytt{ASSUME} statements becomes: \medskip \noindent \begin{tabular}{m{0.1cm}m{0.1cm}l} \multicolumn{3}{l}{\mytt{{\em SQL\_to\_DL}}($r$, \mytt{ASSUME {\em SQL}$_1$ [NOT] IN $r_1$,\ldots,{\em SQL}$_n$ [NOT] IN $r_n$} \mytt{{\em SQL}}) =}\\ & \{ & $r(\overline{X_i}) \leftarrow$ \\ & & $\land$(\mytt{{\em SQL\_to\_DL}}($r_1$, \mytt{{\em SQL}}$_1$)$[$\mytt{[-]}$r_1$/$r_1]$) $\land$ \ldots \\ & & $\land$(\mytt{{\em SQL\_to\_DL}}($r_n$, \mytt{{\em SQL}}$_n$)$[$\mytt{[-]}$r_n$/$r_n]$) \texttt{=>} $s(\overline{X_i})$ \} \\ & & $\cup$ $\texttt{{\em SQL\_to\_DL}}(s,\texttt{{\em SQL}})$ \end{tabular} \medskip \noindent where $A[B/C]$ represents the application of the syntactic substitution $C$ by $B$ in all the rule heads in $A$, \mytt{[{\em T}]} represents that \mytt{{\em T}} is optional but it must occur if the corresponding $i$-th entry also occurs (i.e., if \mytt{NOT} occurs in the assumption for $r_i$, then \mytt{-} also occurs in the corresponding substitution). \section{Playing with the System} \label{examples} Translating an SQL query to Datalog in a practical system involves more features that the ones briefly suggested before and are out of the scope of this extended abstract. For example, the {\tt SELECT} list can include expressions and scalar SQL statements, nested statements can be correlated, aggregate functions and grouping can be used, and so on. Also, from a capacity point-of-view, a needed stage in the translation is folding/unfolding of rules \cite{prolog} to simplify the Datalog program resulting from the translation. This is quite relevant because deducing the meaning (either complete or restricted to a given call) of the involved relations along query solving is needed, therefore significantly augmenting their space and time requirements. Next, we introduce a couple of examples of this translation with the system DES \cite{saenzDES}, which in particular supports such features and inputs from several query languages, including Datalog and SQL. Here, we resort to the actual textual syntax of Datalog rules in this system, which follows the syntax of Prolog. \begin{wrapfigure}{r}{45mm} \vspace{-35pt} \begin{center} \begin{tabular}{cc} \begin{minipage}[c]{2cm} \begin{tabular}{|c|} \hline \mytt{student}\\ \hline \mytt{(adam)} \\ \mytt{(bob)} \\ \mytt{(pete)} \\ \mytt{(scott)} \\ \hline \end{tabular} \end{minipage} & \begin{tabular}{|c|} \hline \mytt{take}\\ \hline \mytt{(adam,db)} \\ \mytt{(pete,db)} \\ \mytt{(pete,lp)} \\ \mytt{(scott,lp)} \\ \hline \end{tabular} \end{tabular} \end{center} \vspace{-25pt} \end{wrapfigure} Let us consider a database containing the relations \mytt{student(name)} and \mytt{take(name, title)}. The first one states names of students and the second one the course (\mytt{title}) each student (\mytt{name}) is enrolled in. Types can be specified either with a Datalog assertion (as \mytt{:-type(student(name:string))} for the first case) or a DDL SQL statement (as \mytt{create table take(name string, title string)} for the second one, where a foreign key \mytt{take.name} $\rightarrow$ \mytt{student.name} could be stated as well). We consider the database instance depicted in the tables above. The next SQL statement (looking for students that have not been already enrolled in a course) is translated as follows in a system session with DES 4.0: {\fontsize{11}{11} \begin{verbatim} DES> select * from student where name not in (select name from take) Info: SQL statement compiled to: answer(A) :- student(A), not take(A,_B). answer(student.name:string) -> { answer(bob) } Info: 1 tuple computed. \end{verbatim} } This example shows a few of things. First, as a query $Q$ is allowed at the system prompt, the call to the translation function becomes \mytt{{\em SQL\_to\_DL}}(\mytt{answer},$Q$), i.e., the outcome relation is automatically renamed to the reserved keyword \mytt{answer}. Second, the outcome schema \mytt{answer(student.name:string)} shows that the single output argument comes from the argument \mytt{name} of the relation \mytt{student}, with type \mytt{string}. Third, following the definition of the translation function, this query should be translated into: {\fontsize{11}{11} \begin{verbatim} answer(A) :- student(A), goal1(A). goal1(A) :- not take(A,_B) \end{verbatim} } But folding/unfolding simplifies this as it was displayed in the system session. These translations have been displayed because it was specified so by issuing the command \mytt{/show\_compilations on}. Finally, non-relevant variables to a rule outcome are underscored (otherwise, they would be signalled as anonymous). This is important in this case to identify as safe the rule in which this underscored variable occurs. Classical safety \cite{Ullman88} would tag the rule \mytt{answer(A) :- student(A), not take(A,\_B)} as unsafe, but an equivalent set of safe rules can be found: \mytt{answer(A) :- student(A), not goal1(A)} and \mytt{goal1(A) :- take(A,\_B)}. Underscored variables are a means to encapsulate this form of safety, which is identified by the system and processed correspondingly. In general, there can be several rules for \mytt{answer} (e.g., when a \mytt{UNION} is involved) and others on which this predicate depends on. As an example of a \mytt{WITH} query, the following statement defines the relation \mytt{grad} intended to retrieve the eligible students for graduation (those that took both \mytt{db} and \mytt{lp} in this tiny example): {\fontsize{11}{11} \begin{verbatim} DES> with grad(name) as (select student.name from student, take t1, take t2 where student.name=t1.name and t1.name=t2.name and t1.title='db' and t2.title='lp') select * from grad; Info: SQL statement compiled to: answer(A) :- (grad(B) :- student(B), take(B,db), take(B,lp)) => grad(A). answer(grad.name:varchar(30)) -> { answer(pete) } Info: 1 tuple computed. \end{verbatim} } As an example of an \mytt{ASSUME} query, we reuse the \mytt{grad} definition above, assume that \mytt{adam} is not an eligible student, and that \mytt{adam} and \mytt{scott} took \mytt{lp} and \mytt{db} respectively: {\fontsize{11}{11} \begin{verbatim} DES> assume (select 'adam') not in student, (select 'adam','lp' union all select 'scott','db') in take, (select student.name from student, take t1, take t2 where student.name=t1.name and t1.name=t2.name and t1.title='lp' and t2.title='db') in grad(name) select * from grad; Info: SQL statement compiled to: answer(A) :- -student(adam) /\ take(adam,lp) /\ take(scott,db) /\ (grad(B) :- student(B), take(B,lp), take(B,db)) => grad(A). answer(grad.name:varchar(30)) -> { answer(pete), answer(scott) } Info: 2 tuples computed. \end{verbatim} } Here, the assumption on \mytt{student} is negative and is compiled to a restricting fact. The second one is compiled to a couple of facts because of the union. The last one is the same as the previous example. The SQL statement after the assumptions simply leads to the goal \mytt{grad(A)}, for which even when \mytt{adam} took the courses to graduate, he was removed as an eligible student and therefore from the answer. If the extensional relations \mytt{student} and \mytt{take} are already defined in an external relational database (as, e.g., MySQL or PostgreSQL), they can be made available to DES via an ODBC connection (with the command \mytt{/open\_db}), and queried as if they were local \cite{Sae14a}. This way, DES behaves as a front-end for both straight calls to native (i.e., supported by the external relational system) SQL queries and non-native queries (as those including \mytt{ASSUME}). For non-native statements, prepending the command \mytt{/des} to the query makes DES to handle such queries which are unsupported in the external database. For example: {\fontsize{11}{11} \begin{verbatim} DES> /open_db postgresql DES> /des assume ... DES> /open_db mysql DES> /des with ... \end{verbatim} } \noindent obtaining the same answers as before for the same queries (both omitted here in the ellipses). Note that, in particular, \mytt{WITH} is unsupported in both MySQL and MS Access. Even when \mytt{WITH} is supported in several relational database systems, they are somewhat restricted because, referring to the syntax in Section \ref{with}, \mytt{{\em SQL}} cannot contain a \mytt{WITH} clause, whereas we do allow for it. \section{Conclusions} This work has presented a proposal to take advantage of intuitionistic logic programming to model both temporary definitions (with the \mytt{WITH} clause) and assumptions (with the \mytt{ASSUME} clause) in SQL. Its motivation lies in providing a clean semantics that makes assumptions to behave as first-class citizen in the object language. The deductive database system DES was used as a test bed to experiment with assumptions, translating SQL queries into Hypothetical Datalog. Further, this system can be used as a front-end to relational systems lacking features as the \mytt{WITH} clause. The most related work is \cite{ANSS13d}, which includes assumptions in SQL with a tailored semantics, and generates SQL scripts implementing fixpoint computations. With respect to the intuitionistic formal framework, our work is based on \cite{Bonner89hypotheticaldatalog,Bonner90hypotheticaldatalog,bonner90adding,bonner89expressing} and adapted to assume rules and deal with duplicates in \cite{sae13c-ictai13}. However, it is not powerful enough to include embedded universal quantifiers in premises as in \cite{bonner89expressing}, which provides the ability to create new constant symbols hypothetically along inference. Though this is not directly applicable to the current work, it is indeed an interesting subject to explore by considering that domains can be finitely constrained in practical applications, as with foreign keys. \section*{Acknowledgements} Thanks to the anonymous referees for their suggestions to improve this work, which has been partially supported by the Spanish MINECO project CAVI-ART (TIN2013-44742-C4-3-R), Madrid regional project N-GREENS Software-CM (S2013/ICE-2731) and UCM grant GR3/14-910502.
{'timestamp': '2016-09-23T02:06:46', 'yymm': '1608', 'arxiv_id': '1608.03535', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03535'}
arxiv
\section{Introduction} \label{sec:Introduction} A sequence can be defined as a contiguous chain of discrete \emph{alphabets}, where an alphabet can be an event, a value or a symbol, sequentially tied together in a certain order, e.g., $\mathtt{BAABCCADECDBBA}$. Sequences are one of the most common data types found in diverse fields such as social science, web, healthcare, bioinformatics, marketing and text mining. Some examples of sequences are: web logs, music listening histories, patient movements through hospital wards, and protein sequences in bioinformatics. The omnipresence of sequence data has made development of new sequence mining methods important. Some examples of its applications include: a) understanding users' behavior from their web surfing and buying sequences data to serve them better advertisements, product placements, promotions, and so on, b) assessing process flows (sequences) in a hospital to find the expected patient movement based on diagnostic profiles to better optimize the hospital resource and service, and c) analysis of biological sequences to understand human evolution, physiology and diseases. A fundamental requirement for data mining is the ability to measure the (dis)similarity, often translated as measuring a distance between the objects. In sequence mining, sequences are the objects, but finding the distances between them is challenging because they are unstructured---arbitrary strings of arbitrary length. To mitigate this challenge, feature representations of sequence are often used. For example, an \emph{n}-gram method extracts sequence features by looking at the substrings up to length \emph{n} and embeds them in a feature vector; in an \emph{n}-order Markov model, the sequence features are represented by the transition probability matrix. However, in addition to other limitations (discussed in \S\ref{subsec:related-work}), most of the existing methods either limit themselves by extracting only short-term patterns or suffer from exponentially increasing computation upon extracting the long-term patterns. For instance, in the abovementioned \emph{n}-gram and -Markov models, \emph{n} is kept small due to computational limitations, and thus, unable to capture long-term patterns.. \begin{wrapfigure}{r}{3.6cm} \begin{centering} \includegraphics[scale=0.33]{computation-comparison} \par\end{centering} \caption{SGT's unique property.\label{fig:sgt-unique-property}} \end{wrapfigure} In this paper, we develop a new function, Sequence Graph Transform (SGT), that extracts the short- and long-term sequence features without any increase in the computation. As depicted in Fig.~\ref{fig:sgt-unique-property}, SGT can extract any amount of short- to long-term sequence patterns just by dialing a hyperparameter $\kappa$. This unique property of SGT removes the computation limitations; it enables us to tune the amount of short- to long-term patterns that will be optimal for a given sequence mining problem. Additionally, SGT is a finite-dimensional feature space that can be used as a vector for implementing any mainstream data mining, and as a graph for applying graph mining methods and interpretable visualizations. These properties lead to a significantly higher sequence data modeling accuracy with lower computation. We theoretically prove the SGT properties, and experimentally and practically validate its efficacy. In the following, \S\ref{subsec:related-work}-\S\ref{subsec:Solution}, we discuss the related work and the problem specification in more detail. \subsection{Related Work\label{subsec:related-work}} Early research works used \emph{edit}-distances between sequences after alignment. Methods for global alignment and local alignment, with or without overlapping, were developed by \cite{needleman1970, smith1981}. Based on these methods, heuristic approaches were proposed for larger datasets \cite{edgar2004, edgar2010, Fu2012}. These methods mainly focus on bioinformatics sequence problems and lack general applicability due to difficulty in tuning, high computational complexity, and inability to work on sequences with significantly varying lengths. Additionally, these methods do not provide any feature representation of sequences. More universally applicable and relatively powerful methods broadly work on one of the following assumptions: a) the sequence process has an underlying parametric distribution, b) similar sequences have common substrings, and c) a sequence evolves from hidden strings. The parametric methods typically make Markovian distribution assumptions (more specifically a first-order Markovian) on the sequence process \cite{cadez2003, ranjan2015}. However, such distributional assumptions are not always valid. General \emph{n-}order Markov models were also proposed but not popular in practice due to high computation. Beyond them, Hidden Markov model-based approaches are popular in both bioinformatics and general sequence problems \cite{remmert2012, helske2016}. This assumes a hidden layer of latent states that results in the observed sequence. Due to the multi-layer setting, the first-order property is not transmitted to the observed sequence. However, tuning HMM (finding optimal hidden states) is difficult and computationally intensive, thus effecting HMM's \emph{generality }and \emph{scalability}. \emph{N}-gram methods (also known as \emph{k}-mer\emph{ }methods in the bioinformatics area) are the most popular approaches that work on the second assumption \cite{tomovic2006}. Although the pretext of this assumption seems appropriate, the optimal selection of substring length, i.e. \emph{n} in \emph{n}-gram or \emph{k }in \emph{k}-mer, is difficult. In sequence mining, selection of a small value for \emph{n }can lead to inclusion of noise, but increasing it severely increases the computation. Some other variants, such as \emph{spaced-words} and adaptive \emph{n}, are more difficult to optimize \cite{comin2012}. Another class of methods hypothesizes that sequences are generated from some evolutionary process in which a sequence is produced by reproducing complex strings from simpler substrings (\cite{siyari2016} and references therein). This method solves an NP-hard optimization problem to identify the underlying evolution hierarchy and corresponding substrings. These substrings can also be used as features for sequence data mining. However, the estimation algorithms for this and similar methods are heuristics that usually do not guarantee optimality. The algorithms can also lead to several solutions that will cause identifiability and ambiguity issues. Moreover, the evolutionary assumption may not be always true. The above methods either limit the extent of sequence pattern extraction due to restrictive assumptions or search for (hidden) states or strings in an unobservable universe. This causes limited accuracy and/or computational issues. Besides these methods, Prefixspan \cite{han2001} is another sequence pattern mining approach, but it works on a different type of sequence in which the sequence is a list of elements and each element consists of a set of items, e.g. \textlangle{}a(abc)(ac)d(cf)\textrangle{}. For the sequence problems addressed here, Prefixspan's performance will be similar to n-grams. Sequence mining problems have also been given attention by the deep learning research community. Embedding spaces for sequences have been proposed using Recurrent Neural Networks (RNN) and Long Short Term Memory \cite{graves2013}. However, the dimension of these embeddings is typically large, and finding the optimal dimension and embeddings requires the use of rigorous optimization problems in a deep learning network. Training such models is computationally intensive, sometimes not interpretable and requires a large amount of training data. \subsection{Problem Specification\label{subsec:Solution}} The related methods discussed above fail to address at least one of the following challenges: a) feature mapping: effective extraction of sequence characteristics into a finite-dimensional feature space (a vector), b) universal applicability: this requires the absence of distributional or domain-specific assumptions and a small number of tuning hyper-parameters, and c) scalability: it relies on the computational complexity, which should be small with respect to sequence length, size of the database and the alphabets set. We propose a new sequence feature extraction function, Sequence Graph Transform (SGT), that addresses all of the above challenges and is shown to outperform existing state-of-the-art methods in sequence data mining. SGT works by quantifying the pattern in a sequence by scanning the positions of all alphabets relative to each other. We call it a \emph{graph }transform because of its inherent property of interpretation as a graph, where the alphabets form the nodes and a directed connection between two nodes shows their ``association.'' These ``associations'' between all alphabets represent the signature features of a sequence. A Markov model transition matrix can be compared analogously with the SGT's feature space; however, among other differences (explored further in the paper), the associations (graph edges) do not represent a probability, and SGT is non-parametric. The non-parametric property also makes it robust to any underlying sequence generation distribution. Regardless, sequence analysis problems can be broadly divided into: a) \emph{length-sensitive}: the inherent patterns, as well as the sequence lengths, should match to render two sequences as similar, e.g., in protein sequence clustering; and b) \emph{length-insensitive}: the inherent patterns should be similar, irrespective of the lengths, e.g., weblog comparisons. In contrast with the existing literature, SGT provides a solution for both scenarios. The advantage of this property becomes more pronounced when we have to perform both types of analysis on the same data and implementing different methods for each becomes cumbersome. In this paper, our major contribution is the development of a new feature extraction function, SGT, for sequences. In the following, we develop SGT, and provide its theoretical support and extensions. We perform an extensive experimental evaluation, and show that SGT bridges the gap between sequence mining and mainstream data mining through implementation of fundamental methods, viz. PCA, k-means, SVM and graph visualization via SGT on real sequence data analysis. \section{Sequence Graph Transform (SGT)} \label{sec:Sequence-Graph-Transform} \subsection{Overview and Intuition} \label{subsec:SGT-Overview} \begin{figure} \begin{centering} \includegraphics[scale=0.3]{overview-example} \par\end{centering} \caption{Showing ``effect'' of elements on each other.\label{fig:Illustration-of-effect}} \end{figure} By definition, a sequence can be either feed-forward or ``undirected.'' In a feed-forward sequence, events (alphabet instances) occur in succession; e.g., in a clickstream sequence, the click events occur one after another in a ``forward direction.'' On the other hand, in an ``undirected'' sequence, the directional or chronological order of alphabet instances is not present or not important. In this paper, we present SGT for feed-forward sequences; SGT for undirected is given in the extended version. For either of these sequence types, the developed Sequence Graph Transform works on the same fundamental premise\textemdash{}the relative positions of alphabets in a sequence characterize the sequence\textemdash{}to extract the pattern features of the sequence. This premise holds true for most sequence mining problems because similarity in sequences is often measured based on the similarities in their pattern from the alphabet positions. In the following, we illustrate and develop the SGT's feature extraction approach for a feed-forward sequence and later extend it to ``undirected'' sequences. Fig.~\ref{fig:Illustration-of-effect} shows an illustrative example of a feed-forward sequence. In this example, the presence of alphabet $\mathtt{B}$ at positions 5 and 8 should be seen in context with or as a result of all other predecessors. To extract the sequence features, we take the relative positions of one alphabet pair at a time. For example, the relative positions for pair ($\mathtt{A}$,$\mathtt{B}$) are \{(2,3),5\} and \{(2,3,6),8\}, where the values in the position set for $\mathtt{A}$ are the ones preceding $\mathtt{B}$. In the SGT procedure defined and developed in the following sections (\S\ref{subsec:SGT-definition}-\ref{subsec:SGT-properties}), the sequence features are shown to be extracted from these positions information. \begin{figure} \subfloat[Feature extracted as a vector with a graph interpretation.\label{fig:SGT-overview-a-one-seq}]{% \includegraphics[scale=0.26]{sample-one-seq-flowchart} } \subfloat[Use of sequences' SGT features for data mining.\label{fig:SGT-overview-b-seq-data}]{% \includegraphics[scale=0.23]{sequence-dataset-flowchart} } \caption{SGT overview.} \end{figure} These extracted features are an ``association'' between $\mathtt{A}$ and $\mathtt{B}$, which can be interpreted as a connection feature representing ``$\mathtt{A}$ leading to $\mathtt{B}$.'' We should note that ``$\mathtt{A}$ leading to $\mathtt{B}$'' will be different from ``$\mathtt{B}$ leading to $\mathtt{A}$.'' The associations between all alphabets in the alphabet set, denoted as $\mathcal{V}$, can be extracted similarly to obtain sequence features in a $|\mathcal{V}|^{2}$-dimensional feature space. This is similar to the Markov probabilistic models, in which the transition probability of going from $\mathtt{A}$ to $\mathtt{B}$ is estimated. However, SGT is different because the connection feature 1) is not a probability, and 2) takes into account all orders of relationship without any increase in computation. Besides, the SGT features also make it easy to visualize the sequence as a directed graph, with sequence alphabets in $\mathcal{V}$ as graph nodes and the edge weights equal to the directional association between nodes. Hence, we call it a sequence \emph{graph} transform. Moreover, we show that under certain conditions, the SGT also allows node (alphabet) clustering. A high level overview of our approach is given in Fig.~\ref{fig:SGT-overview-a-one-seq}-\ref{fig:SGT-overview-b-seq-data}. In Fig.~\ref{fig:SGT-overview-a-one-seq}, we show that applying SGT on a sequence, $s$, yields a finite-dimensional SGT feature vector, $\Psi^{(s)}$, for the sequence, also interpreted and visualized as a directed graph. For a general sequence data analysis, SGT can be applied on each sequence in a data corpus, as shown in Fig.~\ref{fig:SGT-overview-b-seq-data}, to yield a finite and equal dimensional representation for each sequence. This facilitates a direct distance-based comparison between sequences and thus makes application of mainstream data mining methods for sequence analysis rather straightforward. \subsection{Notations\label{subsec:Notations}} Suppose we have a dataset of sequences denoted by $\mathcal{S}$. Any sequence in the dataset, denoted by $s$($\in\mathcal{S}$), is made of alphabets in set $\mathcal{V}$. A sequence can have instances of one or many alphabets from $\mathcal{V}$. For example, sequences from a dataset, $\mathcal{S}$, made of alphabets in $\mathcal{V}=\{\mathtt{A,B,C,D,E}\}$(suppose) can be $\mathcal{S}=\{\mathtt{AABAAABCC,DEEDE}$, $\mathtt{ABBDECCABB,}\ldots\}$. The length of a sequence, $s$, denoted by, $L^{(s)}$, is equal to the number of events (in this paper, the term ``event'' is used for an alphabet instance) in it. In the sequence, $s_{l}$ will denote the alphabet at position $l$, where $l=1,\ldots,L^{(s)}$ and $s_{l}\in\mathcal{V}$. As mentioned in the previous section, we extract a sequence $s$'s features in the form of ``associations'' between the alphabets, represented as $\psi_{uv}^{(s)}$, where $u,v\in\mathcal{V}$, are the corresponding alphabets and $\psi$ is a function of a helper function $\phi$. $\phi_{\kappa}(d)$ is a function that takes a ``distance,'' $d$, as an input and $\kappa$ as a tuning hyper-parameter. \subsection{SGT Definition\label{subsec:SGT-definition}} As also explained in \S\ref{subsec:SGT-Overview}, SGT extracts the features from the relative positions of events. A quantification for an ``effect'' from the relative positions of two events in a sequence is given by $\phi(d(l,m))$, where $l,m$ are the positions of the events and $d(l,m)$ is a distance measure. This quantification is an effect of the preceding event on the later event. For example, see Fig.~\ref{fig:phi-individual-effect}, where $u$ and $v$ are at positions $l$ and $m$, and the directed arc denotes the effect of $u$ on $v$. For developing SGT, we require the following conditions on $\phi$: a) strictly greater than 0: $\phi_{\kappa}(d)>0;\:\forall\,\kappa>0,\,d>0$; b) strictly decreasing with $d$: $\frac{\partial}{\partial d}\phi_{\kappa}(d)<0$; and c) strictly decreasing with $\kappa$: $\frac{\partial}{\partial\kappa}\phi_{\kappa}(d)<0$. The first condition is to keep the extracted SGT feature, $\psi=f(\phi)$, easy to analyze and interpret. The second condition strengthens the effect of closer neighbors. The last condition helps in tuning the procedure, allowing us to change the effect of neighbors. There are several functions that satisfy the above conditions: e.g., Gaussian, Inverse and Exponential. We take $\phi$ as an exponential function because it will yield interpretable results for the SGT properties (\S\ref{subsec:SGT-properties}) and $d(l,m)=|m-l|$. \begin{equation} \phi_{\kappa}(d(l,m))=e^{-\kappa|m-l|},\:\forall\,\kappa>0,\,d>0\label{eq:phi-expression} \end{equation} \begin{figure} \begin{raggedright} \begin{minipage}[t]{0.45\columnwidth}% \begin{center} \subfloat[\label{fig:phi-individual-effect}]{\begin{centering} \includegraphics[scale=0.38]{phi-illustration-uv-shorter} \par\end{centering} } \par\end{center}% \end{minipage} \smallskip{} \begin{minipage}[t]{0.45\columnwidth}% \begin{center} \subfloat[\label{fig:phi-general-effect}]{\begin{centering} \includegraphics[scale=0.35]{phi-illustration-big-uv-shorter} \par\end{centering} } \par\end{center}% \end{minipage} \par\end{raggedright} \caption{Visual illustration of the effect of alphabets' relative positions.\label{fig:phi-illustration}} \end{figure} In a general sequence, we will have several instances of an alphabet pair. For example, see Fig.~\ref{fig:phi-general-effect}, where there are five $(u,v)$ pairs, and an arc for each pair shows an effect of $u$ on $v$. Therefore, the first step is to find the number of instances of each alphabet pair. The instances of alphabet pairs are stored in a $|\mathcal{V}|\times|\mathcal{V}|$ asymmetric matrix, $\Lambda$. Here, $\Lambda_{uv}$ will have all instances of alphabet pairs $(u,v)$, such that in each pair instance, $v$'s position is after $u$. \begin{eqnarray} \Lambda_{uv}(s) & = & \{(l,m):\,s_{l}=u,s_{m}=v,\nonumber \\ & & l<m,(l,m)\in1,\ldots,L^{(s)}\} \label{eq:psi-lambda-main} \end{eqnarray} After computing $\phi$ from each $(u,v)$ pair instance for the sequence, we define the ``association'' feature $\psi_{uv}$ as a normalized aggregation of all instances, as shown below in Eq.~\ref{eq:psi-main-len-sensi}-\ref{eq:psi-main-len-insensi}. Here, $|\Lambda_{uv}|$ is the size of the set $\Lambda_{uv}$, which is equal to the number of $(u,v)$ pair instances. Eq.~\ref{eq:psi-main-len-sensi} gives the feature expression for a \emph{length-sensitive }sequence analysis problem because it also contains the sequence length information within it (proved with a closed-form expression under certain conditions in \S\ref{subsec:SGT-properties}). In Eq.~\ref{eq:psi-main-len-insensi}, the length effect is removed by standardizing $|\Lambda_{uv}|$ with the sequence length $L^{(s)}$ for \emph{length-insensitive }problems. \begin{subequations} \begin{align} \psi_{uv}(s) &= \cfrac{\sum_{\forall(l,m)\in\Lambda_{uv}(s)}e^{-\kappa |m-l|}}{|\Lambda_{uv}(s)|};\textnormal{\,length\,sensitive} \label{eq:psi-main-len-sensi} \\ &= \cfrac{\sum_{\forall(l,m)\in\Lambda_{uv}(s)}e^{-\kappa |m-l|}}{|\Lambda_{uv}(s)|/L^{(s)}};\textnormal{\,length\,insensitive} \label{eq:psi-main-len-insensi} \end{align} \end{subequations} and $\Psi(s)=[\psi_{uv}(s)],\:u,v\in\mathcal{V}$ is the SGT feature representation of sequence $s$. For illustration, the SGT feature for alphabet pair $\mathtt{(A,B)}$ in sequence in Fig.~\ref{fig:Illustration-of-effect} can be computed as (for $\kappa=1$ in length-sensitive SGT): $\Lambda_{\mathtt{AB}}$$=$$\{(2,5);(3,5);$$(2,8);$$(3,8);$$(6,8)\}$ and $\psi_{\mathtt{AB}}$$=$$\frac{\sum_{\forall(l,m)\in\Lambda_{\mathtt{AB}}}e^{-|m-l|}}{|\Lambda_{\mathtt{AB}}|}= \\ \frac{e^{-|5-2|}+e^{-|5-3|}+e^{-|8-2|}+e^{-|8-3|}+e^{-|8-6|}}{5}=0.066$. The features, $\Psi^{(s)}$, can be either interpreted as a directed ``graph,'' with edge weights, $\mathcal{\psi}$, and nodes in $\mathcal{V}$, or vectorized to a $|\mathcal{V}|^{2}$-vector denoting the sequence $s$ in the feature space. \subsection{SGT properties} \label{subsec:SGT-properties} In this section, we show SGT's property of capturing both short- and long-term sequence pattern features. This is shown by a closed-form expression for the expectation and variance of SGT feature, $\psi_{uv}$, under some assumption. Note that the assumption defined below is only for showing an interpretable expression and is not required in practice. \begin{assumption}\label{main_assump} A sequence of length $L$ with an inherent pattern: $u$,$v$ occurs closely together with in-between stochastic gap as $X\sim N(\mu_{\alpha},\sigma_{\alpha}^{2})$, and the intermittent stochastic gap between the pairs as $Y\sim N(\mu_{\beta},\sigma_{\beta}^{2})$, such that, $\mu_{\alpha}<\mu_{\beta}$ (See Fig.~\ref{fig:Representation-of-short-long}). $X$ and $Y$ characterize the short- and long-term patterns, respectively. \end{assumption} \begin{figure} \begin{centering} \includegraphics[scale=0.31]{illustration-long-short-patterns} \par\end{centering} \caption{Representation of short- and long-term pattern.\label{fig:Representation-of-short-long}} \end{figure} \begin{theorem_new} The expectation and variance of SGT feature, $\psi_{uv}$, has a closed-form expression under Assumption~1, which shows that it captures both short- and long-term patterns present in a sequence in both length-sensitive and -insensitive SGT variants. \begin{eqnarray} E[\psi_{uv}] & = & \begin{cases} \cfrac{2}{pL+1}\gamma & ;\text{length sensitive}\\ \cfrac{2L}{pL+1}\gamma & ;\text{length insensitive} \end{cases}\label{eq:E-phi-AB-part-2-2} \\ \lim_{L\rightarrow\infty}\text{var}(\psi_{uv}) & \rightarrow & 0 \end{eqnarray} where, \begin{equation} \begin{array}{ccc} \gamma & = & \frac{e^{-\tilde{\mu}_{\alpha}}}{\left|\left(1-e^{-\tilde{\mu}_{\beta}}\right)\left[1-\frac{1-e^{-pL\tilde{\mu}_{\beta}}}{pL(e^{\tilde{\mu}_{\beta}}-1)}\right]\right|} \end{array}\label{eq:weight-constant-lambda-1} \end{equation} and, $\tilde{\mu}_{\alpha}=\kappa\mu_{\alpha}-\frac{\kappa^{2}}{2}\sigma_{\alpha}^{2};\tilde{\mu}_{\beta}=\kappa\mu_{\beta}-\frac{\kappa^{2}}{2}\sigma_{\beta}^{2}$, $p\rightarrow \text{constant}$. \end{theorem_new} \begin{proof}See Appendix~A. \end{proof} As we can see in Eq.~\ref{eq:E-phi-AB-part-2-2}, the expected value of the SGT feature is proportional to the term $\gamma$. The numerator of $\gamma$ contains the information about the short-term pattern, and its denominator has the long-term pattern information. In Eq.~\ref{eq:weight-constant-lambda-1}, we can observe that if either of $\mu_{\alpha}$ (the closeness of $u$ and $v$ in the short-term) and/or $\mu_{\beta}$ (the closeness of $u$ and $v$ in the long-term) decreases, $\gamma$ will increase, and vice versa. This emphasizes two properties: a) the SGT feature, $\psi_{uv}$, is affected by changes in both short- and long-term patterns, and b) $\psi_{uv}$ increases when $u,v$ becomes closer in the short or long range in the sequence, providing an analytical connection between the observed pattern and the extracted feature. Besides, it also proves the graph interpretation of SGT: $\psi_{uv}$ that denotes the edge weight for nodes $u$ and $v$ (in the SGT-graph) increases if closeness between $u,v$ increases in the sequence, meaning that the nodes become closer in the graph space (and vice versa). Furthermore, the length-sensitive SGT feature expectation in Eq.~\ref{eq:E-phi-AB-part-2-2} contains the sequence length, $L$. This shows that the SGT feature has the information of the sequence pattern, as well as the sequence length. This enables an effective length-sensitive sequence analysis because sequence comparisons via SGT will require both patterns and sequence lengths to be similar. In the length-insensitive SGT feature expectation in Eq.~\ref{eq:E-phi-AB-part-2-2}, it is straightforward to show that it becomes independent of the sequence length as the length increases. Therefore, as sequence length, $L$, increases, the $(u,v)$ SGT feature approaches a constant, given as $\lim_{L\rightarrow\infty}E[\psi_{uv}] \rightarrow \cfrac{2}{p}\left|\cfrac{e^{-\tilde{\mu}_{\alpha}}}{1-e^{-\tilde{\mu}_{\beta}}}\right|$. Besides, it is shown in Appendix~A, $\lim_{L\rightarrow\infty}\text{var}(\psi_{uv})\underset{1/L}{\rightarrow}0$. Thus, the expected value of the SGT feature becomes independent of the sequence length at a rate of inverse to the length. In our experiments, we observe that the SGT feature approaches a length-invariant constant when $L>30$. \begin{eqnarray} \lim_{L\rightarrow\infty}\Pr\left\{ \psi_{uv}=\cfrac{2}{p}\left|\cfrac{e^{-\tilde{\mu}_{\alpha}}}{1-e^{-\tilde{\mu}_{\beta}}}\right|\right\} & \underset{1/L}{\rightarrow} & 1\label{eq:E-psi-AB-len-insensi-lim-approaches-1} \end{eqnarray} Furthermore, if the pattern variances, $\sigma_{\alpha}^{2}$ and $\sigma_{\beta}^{2}$, in the above scenario are small, $\kappa$ allows regulating the feature extraction: higher $\kappa$ reduces the effect from long-term patterns and vice versa. The properties discussed above play an important role in SGT's effectiveness. Due to these properties, unlike the methods discussed in \S\ref{subsec:related-work}, SGT can capture higher orders of relationship without any increase in computation. Besides, SGT can effectively find sequence features without the need for any hidden string/state(s) search. \subsection{Extensions of SGT} \label{subsec:Extensions-of-SGT} \subsubsection{Undirected sequences} \label{subsec:SGT-for-undirected-seq} SGT can be extended to work on undirected sequences. In such sequences, the directional pattern or directional relationships (as in feed-forward) are not important. In other words, it is immaterial whether $\mathtt{B}$ occurs before or after $\mathtt{A}$; occurring closely (or farther) is important. From SGT's operation standpoint, we have to remove the condition, $l<m$, from Eq.~\ref{eq:psi-lambda-main}, denoted by $\tilde{\Lambda}$. It is easy to show that $\tilde{\Lambda}=\Lambda+\Lambda^{T}$ and \begin{equation} \tilde{\Psi}=\cfrac{|\Lambda|\Psi+|\Lambda^{T}|\Psi^{T}}{|\Lambda|+|\Lambda^{T}|}\label{eq:Psi-tilde-expanded} \end{equation} where $\Lambda$ and $\Psi$ are given in Eq.~\ref{eq:psi-lambda-main} and Eq.~\ref{eq:psi-main-len-sensi}-\ref{eq:psi-main-len-insensi}, respectively (see Appendix B for proof). Moreover, for sequences with a uniform marginal distribution of occurrence of elements, $v\in\mathcal{V}$, $\Lambda$ will be close to symmetric; thus, the undirected sequence graph can be approximated as, $\tilde{\Psi}\approx\cfrac{\Psi+\Psi^{T}}{2}$. In practice, this approximation is useful in most cases. \subsubsection{Alphabet clustering} \label{subsec:SGT-for-element-clustering} \begin{figure} \begin{raggedright} \begin{minipage}[t]{0.45\columnwidth}% \begin{center} \subfloat[$u,v$ are closer than $u,w$. \label{fig:Illustrative-sequence-example-ele-clus}]{\begin{centering} \includegraphics[scale=0.3]{element-clustering-eg-flatter} \par\end{centering} } \par\end{center}% \end{minipage} \smallskip{} \begin{minipage}[t]{0.45\columnwidth}% \begin{center} \subfloat[Corresponding SGT's Graph view.]{\begin{centering} \includegraphics[scale=0.22]{alphabet-clustering-graph-flatter} \par\end{centering} } \par\end{center}% \end{minipage} \par\end{raggedright} \caption{Illustrative sequence example for alphabet clustering.} \end{figure}% Node clustering in graphs is a classical problem solved by various techniques, including spectral clustering, graph partitioning and others. SGT's graph interpretation facilitates grouping of alphabets that occur closely via any of these node clustering methods. This is because SGT gives larger weights to the edges, $\psi_{uv}$, corresponding to alphabet pairs that occur closely. For instance, consider a sequence in Fig.~\ref{fig:Illustrative-sequence-example-ele-clus}, in which $v$ occurs closer to $u$ than $w$, also implying $E[X]<E[Y]$. Therefore, in this sequence's SGT, the edge weight for $u$$\rightarrow$$v$ should be greater than for $u$$\rightarrow$$w$, i.e. $\psi_{uv}>\psi_{uw}$. From Assumption.~\ref{main_assump} in \S\ref{subsec:SGT-properties}, we will have, $E[|\Lambda_{uv}|]=E[|\Lambda_{uw}|]$ (see Appendix~C). Therefore, $\psi_{uv}\propto E[\phi(X)]$ and $\psi_{uw}\propto E[\phi(Y)]$, and due to Condition~2 on $\phi$ given in \S\ref{subsec:SGT-definition}, if $E[X]<E[Y]$, then $E[\psi_{uv}]>E[\psi_{uw}]$. Moreover, for an effective clustering, it is important to bring the ``closer'' alphabets in the sequence \emph{more} close in the graph space. In the SGT's graph interpretation, it implies that $\psi_{uv}$ should go as high as possible to bring $v$ closer to $u$ in the graph and vice versa for $(u,w)$. Thus, effectively, $\Delta=E[\psi_{uv}-\psi_{uw}]$ should be increased. It is proved in Appendix~C that $\Delta$ will increase with $\kappa$, if $\kappa d>1,\forall d$, where we have $d \in \mathbb{N}$. Thus, an SGT can represent a sequence as a graph with its alphabets connected with weighted edges, which enables clustering of associated alphabets. \section{SGT Algorithm} \label{sec:SGT-Algorithm} \begin{figure} \begin{minipage}[t]{1.0\columnwidth}% \begin{algorithm}[H] \small \caption{Parsing a sequence to obtain its SGT.} \label{alg:Parsing-Sequence-algo} \begin{algorithmic}[1] \INPUT A sequence, $s\in\mathcal{S}$ , alphabet set, $\mathcal{V}$ , and $\kappa$. \Initialize{$\mathbf{W}^{(0)},\mathbf{W}^{(\kappa)} \gets \mathbf{0}_{\mathcal{V}\times\mathcal{V}}$, and length, $L \gets 1$} \For{$i\in\{1,\ldots,(\text{length}(s)-1)\}$} \For{$j\in\{(i+1),\ldots,\text{length}(s)\}$} \State{$\mathbf{W}^{(0)}_{s_i,s_j}\gets \mathbf{W}^{(0)}_{s_i,s_j} + 1$} \State{$\mathbf{W}^{(\kappa)}_{s_i,s_j}\gets\mathbf{W}^{(\kappa)}_{s_i,s_j} + \exp(-\kappa|j-i|)$} \State{where, $s_i, s_j \in \mathcal{V}$} \EndFor \State{$L \gets L + 1$} \EndFor \If{$\text{length-sensitive}\; is \; \text{True}$} \State $\mathbf{W}^{(0)}\gets\mathbf{W}^{(0)}/L$ \EndIf \OUTPUT {$\psi_{uv}(s)\gets\left(\frac{W^{(\kappa)}_{u,v}}{W^{(0)}_{u,v}}\right)^{\frac{1}{\kappa}}$;$\Psi(s)=[\psi_{uv}(s)],\:u,v\in\mathcal{V}$} \end{algorithmic} \end{algorithm}% \end{minipage}\end{figure}% We have devised two algorithms for SGT. The first algorithm (see Algorithm~\ref{alg:Parsing-Sequence-algo}) is faster for $L<|\mathcal{V}|^{2}$, while the second (see Algorithm~\ref{alg:Parsing-Sequence-algo-1}) is faster for $L>|\mathcal{V}|^{2}$. Their time complexities are $O(L^{2})$ and $O(|\mathcal{V}|(L+|\mathcal{V}|))$, respectively. The space complexity is $O(|\mathcal{V}|^{2})$. However, in most datasets, not all alphabets in $\mathcal{V}$ are present in a sequence, resulting in a sparse SGT features representation. In such cases, the complexity reduces by a factor of the sparsity level. Additionally, as also evident from Fig.~\ref{fig:SGT-overview-b-seq-data}, the SGT operation on any sequence in a dataset is independent of the other. This means we can easily parallelize the SGT operation on sequences in dataset $\mathcal{S}$ to reduce the computation time. The resulting SGT for the sequence, $s$, will be a $|\mathcal{V}|\times|\mathcal{V}|$ matrix, which can be vectorized (size, $|\mathcal{V}|^{2}$) for use in distance-based data mining methods, or it can be used as is for visualization and interpretation purposes. Note that we output the $\kappa^{\text{th }}$ root as the final SGT features as it makes the SGTs easy to interpret and comparable for any $\kappa$. The optimal selection of the hyper-parameter $\kappa$ will depend on the problem in hand. If the end objective is building a supervised learning model, methods such as cross-validation can be used. For unsupervised learning, any goodness-of-fit criteria can be used for the selection. In cases of multiple parameter optimization, e.g. the number of clusters (say, $n_{c}$) and $\kappa$ together in clustering, we can use a random search procedure. In such a procedure, we randomly initialize $n_{c}$, compute the best $\kappa$ based on some goodness-of-fit measure, then fix $\kappa$ to find the best $n_{c}$, and repeat until there is no change. From our experiments on real and synthesized data, the results of SGT-based data mining are not sensitive to minor differences in $\kappa$. In our implementations, we selected $\kappa$ from $\{1,5,10\}$. \begin{figure} \begin{minipage}[t]{1\columnwidth}% \begin{algorithm}[H] \small \caption{Extract SGT features by scanning alphabet positions of a sequence.} \label{alg:Parsing-Sequence-algo-1} \begin{algorithmic}[1] \INPUT A sequence, $s\in\mathcal{S}$ , alphabet set, $\mathcal{V}$ , and $\kappa$. \Function{GetAlphabetPositions}{$s,\mathcal{V}$} \State $\text{positions}\leftarrow\{\emptyset\}$ \For{$v\in\mathcal{V}$} \State{$\text{positions}(v)\leftarrow\{i:s_i=v,i=1,\ldots,\text{length}(s)\}$} \EndFor \State \Return {$\text{positions}$} \EndFunction \Initialize{$\mathbf{W}^{(0)},\mathbf{W}^{(\kappa)} \gets \mathbf{0}_{\mathcal{V}\times\mathcal{V}}$, and length, $L \gets 0$ \\$\text{positions}$ $\gets$ \Call{GetAlphabetPositions}{$s,\mathcal{V}$} } \For{$u\in\mathcal{V}$} \State{$U\leftarrow\text{positions}(u)$} \For{$v\in\mathcal{V}$} \State{$V\leftarrow\text{positions}(v)$} \State{$C\leftarrow(U\times V)^{+}=\{(i,j)|i\in U,j\in V,\,\&\,j>i\}$} \State{$\mathbf{W}^{(0)}_{u,v}\leftarrow\text{length}(C)$} \State{$\mathbf{W}^{(\kappa)}_{u,v}\leftarrow\text{sum}(\exp(-\kappa|C_{:,u}-C_{:,v}|))$} \EndFor \State{$L \gets L + \text{length}(U)$} \EndFor \If{$\text{length-sensitive}\; is \; \text{True}$} \State $\mathbf{W}^{(0)}\gets\mathbf{W}^{(0)}/L$ \EndIf \OUTPUT {SGT: $\psi_{uv}(s)\gets\left(\frac{W^{(\kappa)}_{u,v}}{W^{(0)}_{u,v}}\right)^{\frac{1}{\kappa}}$; $\Psi(s)=[\psi_{uv}(s)],\:u,v\in\mathcal{V}$} \end{algorithmic} \end{algorithm}% \end{minipage} \end{figure} \section{Experimental Analysis} \label{sec:Experimental-Analysis} Here we perform an experimental analysis to assess the performance of the proposed SGT. The most important motivation behind SGT is the need for an accurate method to find (dis)similarity between sequences. Therefore, to test SGT's efficacy in finding sequence (dis)similarities, we built a sequence clustering experimental setup. A clustering operation requires accurate computation of (dis)similarity between objects and thus is a good choice for efficacy assessment. We performed four types of experiments: a) Exp-1: length-insensitive with non-parametric sequence pattern, b) Exp-2: length-insensitive with parametric sequence pattern, c) Exp-3: length-sensitive sequence problem, and d) Exp-4: alphabet clustering. The settings for each are given in Table~\ref{tab:Experimentation-settings}. Alphabet set is, $\mathcal{V}=\{\mathtt{A},\mathtt{B}\ldots,\mathtt{Z}\}$, for all sequences. Except for Exp-2, clustered sequences were generated such that sequences within a cluster share common patterns. Here two sequences having a common pattern primarily means that the sequences have some common subsequences of any length, and these subsequences can be present anywhere in the sequence. The sequences also comprise of other events, which can be either \emph{noise} or some other pattern. This setting is non-parametric; however, the subsequences can also bring some inherent parametric properties, such as a mixture of Markov distribution of different orders. In Exp-2, clustered sequences were generated from a mixture of parametric distributions. In all the experiments, k-means with Manhattan distance was applied on the sequences' SGTs. \begin{table} \caption{Experimentation settings.\label{tab:Experimentation-settings}} \begin{centering} \begin{tabular}{>{\raggedright}p{1.2cm} >{\raggedright}p{2.2cm} >{\raggedright}p{0.8cm} >{\raggedright}p{1.2cm}} \hline \textbf{\scriptsize{}Experiment} & \textbf{\scriptsize{}Sequence length,$\mu,\sigma$} & \textbf{\scriptsize{}Noise} & \textbf{\scriptsize{}\#clusters,$n_{c}$}\tabularnewline \hline {\scriptsize{}Exp-1} & {\scriptsize{}116.4, 47.7} & {\scriptsize{}35-65\%} & {\scriptsize{}5}\tabularnewline {\scriptsize{}Exp-2} & {\scriptsize{}98.2, 108.3} & {\scriptsize{}\textendash{}} & {\scriptsize{}5}\tabularnewline {\scriptsize{}Exp-3} & {\scriptsize{}424.6, 130.6} & {\scriptsize{}45-50\%} & {\scriptsize{}5}\tabularnewline {\scriptsize{}Exp-4} & {\scriptsize{}103.9, 33.6} & {\scriptsize{}30-50\%} & {\scriptsize{}3}\tabularnewline \hline \end{tabular} \par\end{centering} \end{table}% In Exp-1, we compared SGT with commonly used sequence analysis techniques, viz. n-gram, mixture Hidden Markov model (HMM), Markov model (MM) and semi-Markov model (SMM)-based clustering. For n-gram, we take $n=\{1,2,3\}$, and their combinations. Note that 1-gram is equivalent to the bag-of-words method. For these methods, we provided the known\emph{ }$n_{c}$ to the algorithms. We use F1-score as the accuracy metric. In this experiment, we set different scenarios such that the overlap of the clusters' ``centroid'' is increased. A high overlap between clusters implies that the sequences belonging to these clusters have a higher number of common patterns. Thus, separating them for clustering becomes difficult, and clustering accuracy is expected to be lower. The Exp-1's result in Fig.~\ref{fig:Overlap-f1}-\ref{fig:Overlap-time} shows the accuracy (F1-score) and the runtimes (with the legend) for each method, where SGT is seen to outperform all others in accuracy. MM and SMM have a poorer accuracy because of the first-order Markovian assumption. HMM is found to have a comparable accuracy, but its runtime is more than six times that of SGT, proving SGT's superiority. N-gram methods' accuracies lie in between. Low-order n-grams have smaller runtime than SGT but significantly lower accuracy. Interestingly, the 1-gram method is better when overlapping is high, showing the higher order n-grams' inability to distinguish between sequences when pattern overlap is high. \begin{figure} \subfloat[F1 scores.\label{fig:Overlap-f1}]{% \includegraphics[scale=0.16]{simulation-f1score} } \subfloat[Run times.\label{fig:Overlap-time}]{% \includegraphics[scale=0.16]{simulation-time} } \caption{Exp-1 results.} \end{figure} Furthermore, we did Exp-2 to see the performance of SGT in sequence datasets having an underlying mixture of parametric distributions, viz. mixture of HMM, MM and SMM. The objective of this experiment is to test SGT's efficacy on parametric datasets against parametric methods. In addition to obtaining datasets from mixed HMM and first-order mixed MM and SMM distributions, we also get second-order Markov (MM2) and third-order Markov (MM3) datasets. Fig.~\ref{fig:Beating-f1}-\ref{fig:Beating-time} shows the F1-score and the runtime (as bar labels). As expected, the mixture clustering method corresponding to the underlying distribution is performing the best. Note that SMM is slightly better than MM in the MM setting because of its over-representative formulation, i.e. a higher dimensional model to include a variable time distribution. However, the proposed SGT's accuracy is always close to the best. This shows SGT's robustness to underlying distribution and its universal applicability. And, again, its runtime is smaller than all others. \begin{figure} \subfloat[F1 scores.\label{fig:Beating-f1}]{% \includegraphics[scale=0.16]{simu-underlying-distri-f1} } \subfloat[Run times.\label{fig:Beating-time}]{% \includegraphics[scale=0.16]{simu-underlying-distri-time} } \caption{Exp-2 results.} \end{figure} In Exp-3, we compared SGT with length-sensitive algorithms, viz. MUSCLE, UCLUST and CD-HIT, which are popular in bioinformatics. These methods are hierarchical in nature, and thus, themselves find the optimal number of clusters. For SGT-clustering, the number of clusters is found using the random search procedure recommended in \S3. Fig.~\ref{fig:Exp-1} shows the results, where the y-axis is the ratio of the estimated optimal number of clusters, $\hat{n}_{c}$, and the true number of clusters, $n_{c}$. On the x-{}axis, it shows the clustering accuracy, i.e. the proportion of sequences assigned to a same cluster given that they were actually from the same cluster. For a best performing algorithm, both metrics should be close to 1. As shown in the figure, CD-HIT and UCLUST overestimated the number of clusters by about twice and five times, respectively. MUSCLE had a better $n_{c}$ estimate but had about 95\% accuracy. On the other hand, SGT could accurately estimate $n_{c}$ and has a 100\% clustering accuracy. \begin{figure} \begin{centering} \includegraphics[scale=0.35]{simu-length-sensi-protein-methods-small} \par\end{centering} \captionof{figure}{Exp-3 results.} \label{fig:Exp-1} \end{figure}% \begin{figure} \begin{centering} \includegraphics[scale=0.5]{alphabet_clusters_pdf_refined2} \par\end{centering} \captionof{figure}{Exp-4 results.} \label{fig:Heat-map-showing-alphabets'} \end{figure}% Finally, we validated the efficacy of the SGT extensions given in \S\ref{subsec:Extensions-of-SGT} in Exp-4. Our main aim in this validation is to perform alphabet clustering (in \S\ref{subsec:SGT-for-element-clustering}). Additionally, we use the undirected SGT (in \S\ref{subsec:SGT-for-element-clustering}). We set up a test experiment such that across different sequence clusters some alphabets occur closer to each other. We create a dataset that has sequences from three clusters and alphabets belonging to two clusters (alphabets A-H in one cluster and I-P in another). This emulates a biclustering scenario in which sequences in different clusters have distinct patterns; however, the pattern of closely occurring alphabets is common across all sequences. This is a complex scenario in which clustering both sequences and alphabets can be challenging. Upon clustering the sequences, the F1-score is found to be 1.0. For alphabet clustering, we applied spectral clustering on the aggregated SGT of all sequences, which yielded an accurate result with only one alphabet as mis-clustered. Moreover, a heat map in Fig.~\ref{fig:Heat-map-showing-alphabets'} clearly shows that alphabets within same underlying clusters have significantly higher associations. Thus, it validates that SGT can accurately cluster alphabets along with clustering the sequences. \section{Applications on Real Data} \label{sec:Applications} \subsection{Clustering\label{sec:Example:-Understanding-user}} Sequence clustering is an important application area across various fields. One important problem in this area is clustering user activity on the web (web log sequences) to understand user behavior. This analysis can result into better services and design. We took users' navigation data on msnbc.com collected during a 24-hour period. The navigation data are weblogs that correspond to the page views of each user. The alphabets of these sequences are the events corresponding to a user's page request. These requests are recorded at a higher abstract level of page category, e.g. \texttt{frontpage, tech}, which are representative of the structure of the website. The dataset has a random sample of 100,000 sequences for our analysis. The sequences' average length is 6.9 and their standard deviation is 27.3, with the range between 2 and 7440 and a skewed distribution. \begin{figure} \begin{minipage}[t]{1.0\columnwidth}% \begin{center} \includegraphics[scale=0.35]{msnbc_clusters_histo_pdf} \par\end{center} \caption{Frequency distribution.\label{fig:Frequency-distribution-of-msnbc-clusters}} \end{minipage} \end{figure} Our objective is to cluster the users with similar navigation patterns, irrespective of differences in their session lengths. We, therefore, take the \emph{length-insensitive }SGT and use the random search procedure for optimal clustering in \S3. We performed k-means clustering with Manhattan distance and the goodness-of-fit criterion as db-index, and found the optimality at $n_{c}=104$ for $\kappa=9$. The frequency distribution (Fig.~\ref{fig:Frequency-distribution-of-msnbc-clusters}) of the number of members in each cluster has a long-tail\textemdash{}the majority of users belong to a small set of clusters. These clusters tell us the distinct behaviors of both the majority and minority user types. \subsection{Visualization\label{subsec:Analysis-using-SGT}} Effective visualization is a critical need for easy interpretation of data and its underlying properties. For example, in the above msnbc.com navigation data analysis, interpreting behavior of different user clusters is quite important. \begin{figure} \begin{centering} \begin{minipage}[b][1\totalheight][t]{0.45\columnwidth}% \begin{center} \subfloat[Cluster \#1\label{fig:Cluster=000023-1}]{\begin{centering} \includegraphics[scale=0.15]{clust3-actual12-outlier-removed} \par\end{centering} } \par\end{center}% \end{minipage} \begin{minipage}[b][1\totalheight][t]{0.45\columnwidth}% \begin{center} \subfloat[Cluster \#3\label{fig:Cluster=000023-3}]{\begin{centering} \includegraphics[scale=0.10]{clust11_long-actual75-outlier-removed} \par\end{centering} } \par\end{center}% \end{minipage} \par\end{centering} \caption{Graphical visualization of cluster centroids.} \end{figure} SGT enables a visual interpretation of the different user behaviors. In Fig.~\ref{fig:Cluster=000023-1}-\ref{fig:Cluster=000023-3}, we show a graph visualization of some clusters' centroids (which are in the SGT space), because a centroid represents the behavior of users present in the cluster. We have filtered edges with small weights for better visualization. Fig.~\ref{fig:Cluster=000023-1} shows the centroid for the first cluster that contains the highest membership ($\sim$12\%) and thus indicates the ``most'' general behavior. This cluster's users' behavior is centered around \texttt{frontpage }and \texttt{misc}, with users' tendency to navigate between \texttt{frontpage, misc, weather, opinion, news, travel }and \texttt{business} at different levels. Fig.~\ref{fig:Cluster=000023-3} shows another majority cluster with about 7.5\% membership. This group of users seems to have a liking for sports. They primarily visit \texttt{sports}-related pages (the box around the \texttt{sports} node indicates a self-visiting edge), and also move back and forth from \texttt{sports} to \texttt{frontpage, travel} and others. \subsection{Classification} At many occasions, we have labeled sequence data where it is required to build a classification model. SGT can be used for this, and is demonstrated on two datasets: a) protein sequences\footnote{www.uniprot.org} having either of two known functions, which act as the labels, and b) network intrusion data\footnote{https://www.ll.mit.edu/ideval/data/1998data.html} containing audit logs and any attack as a positive label. \begin{table} \caption{Dataset attributes.\label{tab:Dataset-attributes}} \begin{centering} \begin{tabular}{l l l} \hline \textbf{\scriptsize{}Attribute} & \textbf{\scriptsize{}Protein}{\scriptsize{}} & \textbf{\scriptsize{}Network}{\scriptsize{}}\tabularnewline \hline {\scriptsize{}Sample size} & {\scriptsize{}2113} & {\scriptsize{}115}\tabularnewline {\scriptsize{}Sequence length range} & {\scriptsize{}(289, 300)} & {\scriptsize{}(12, 1773)}\tabularnewline {\scriptsize{}Class distribution} & {\scriptsize{}46.4\%+} & {\scriptsize{}11.3\%+}\tabularnewline {\scriptsize{}Alphabet set size} & {\scriptsize{}20 (amino acids)} & {\scriptsize{}49 (log events)}\tabularnewline \hline \end{tabular} \par\end{centering} \end{table} The dataset details are given in Table~\ref{tab:Dataset-attributes}. For both problems we use the \emph{length-sensitive} SGT. For proteins, it is due to their nature, while for network logs, the lengths are important because sequences with similar patterns but different lengths can have different labels. Take a simple example of following two sessions: \{\texttt{\small{}login, password, login, password, mail,...}\} and \{\texttt{\small{}login, password,...(repeated several times)..., login, password}\}. While the first session can be a regular user mistyping the password once, the other session is possibly an attack to guess the password. Thus, the sequence lengths are as important as the patterns. For the network intrusion data, the sparsity of SGTs was high. Therefore, we performed principal component analysis (PCA) on it and kept the top 10 PCs as sequence features. We call it SGT-PC, for further modeling. For proteins, the SGTs are used directly. \begin{table} \caption{Classification accuracy (F1-score) based on 10-fold cross-validation results.\label{tab:Classification-accuracy-(F1-score)}} \noindent \begin{centering} {\scriptsize{}}% \begin{tabular}{l l l} \hline \textbf{\scriptsize{}SVM on- \{$\gamma_{protein};\gamma_{network}$\}} & \textbf{\scriptsize{}Protein } & \textbf{\scriptsize{}Network}\tabularnewline \hline {\scriptsize{}SGT\{$0.0014;0.1$\}} & \textbf{\scriptsize{}99.61\%,\(\kappa=1\)} & \textbf{\scriptsize{}89.65\%,\(\kappa=10\)}\tabularnewline {\scriptsize{}Bag-of-words\{$0.05;0.02$\}} & {\scriptsize{}88.45\%} & {\scriptsize{}48.32\%}\tabularnewline {\scriptsize{}2-gram\{$0.0025;0.00041$\}} & {\scriptsize{}93.87\%} & {\scriptsize{}63.12\%}\tabularnewline {\scriptsize{}3-gram\{$0.00012;8.4e-6$\}} & {\scriptsize{}95.12\%} & {\scriptsize{}49.09\%}\tabularnewline {\scriptsize{}1+2-gram\{$0.0012;0.0004$\}} & {\scriptsize{}94.34\%} & {\scriptsize{}64.39\%}\tabularnewline {\scriptsize{}1+2+3-gram\{$4.0e-5;8.2e-6$\}} & {\scriptsize{}96.89\%} & {\scriptsize{}49.74\%}\tabularnewline \hline \end{tabular} \par\end{centering}{\scriptsize \par} \end{table} After obtaining the SGT (-PC) features, we trained an SVM classifier on them. For comparison, we used popular n-gram sequence classifiers, viz. bag-of-words (1-gram), 2-, 3-, 1+2-, and 1+2+3-gram. The SVM was built with an RBF kernel. The cost parameter, $c$, is equal to 1, while the value for the kernel parameter, $\gamma$, is shown within braces in Table~\ref{tab:Classification-accuracy-(F1-score)}. The table reports the average test accuracy (F1-score) from a 10-fold cross-validation. As we can see in Table~\ref{tab:Classification-accuracy-(F1-score)}, the F1-scores are high for all methods in the protein data, with SGT-based SVM surpassing all others. On the other hand, the accuracies are small for the network intrusion data. This is primarily due to: a) a small dataset but high dimension (related to the alphabet set size), leading to a weak predictive ability of models, and b) a few positive class examples (unbalanced data) causing a poor recall rate. Still, SGT outperformed other methods by a significant margin. Although the accuracies of the methods can be further increased using other classifiers such as Boosting and Random Forest, it is beyond the scope of this paper. Here our purpose is to make a simplistic comparison to highlight the superiority of SGT features in building a supervised learning model. \subsection{Search} Most sequence databases found in the real world are very large. For example, protein databases have billions of sequences and increasing. Here we show that SGT sequence features can lead to a fast and accurate sequence search. \begin{table} \caption{Protein search query (Q9ZIM1) result.\label{tab:Protein-search-query-result}} \noindent \begin{centering} {\footnotesize{}}% \begin{tabular}{>{\raggedright}p{2.5cm}>{\raggedright}p{1.2cm}>{\raggedright}p{1.2cm}} \hline \textbf{\scriptsize{}Protein} & \textbf{\scriptsize{}SGT-PC } & \textbf{\scriptsize{}Identity}\tabularnewline \hline {\scriptsize{}S9A4Q5} & {\scriptsize{}33.02} & {\scriptsize{}46.3\%}\tabularnewline {\scriptsize{}S8TYW5} & {\scriptsize{}34.78} & {\scriptsize{}46.3\%}\tabularnewline {\scriptsize{}A0A029UVD9} & {\scriptsize{}39.21} & {\scriptsize{}45.1\%}\tabularnewline {\scriptsize{}A0A030I738} & {\scriptsize{}39.34} & {\scriptsize{}45.1\%}\tabularnewline {\scriptsize{}A0A029UWE3} & {\scriptsize{}39.41} & {\scriptsize{}45.1\%}\tabularnewline \hline \end{tabular} \par\end{centering}{\footnotesize \par} \end{table} We collected a random sample of 1000 protein sequences from the UniProtKB database on www.uniprot.org. We transformed them to feature space using \emph{length-sensitive }SGT (with $\kappa=1$) to incorporate their lengths' information. Thereafter, to reduce the dimension we applied principal component analysis and preserved the first 40 principal components (explaining $\sim$83\% of variance), denoted by SGT-PC. We arbitrarily chose a protein sequence, Q9ZIM1\footnote{The protein sequence of Q9ZIM1 is, \texttt{MSYQQQQCKQPCQPPPVCPTPKCPEPCPPPKC\\PEPYLPPPCPPEHCPPPPCQDKCPPVQPYPPCQQKYPPKSK}} (ID notation from UniProtKB), as the search query. We compute the Manhattan distance between the SGT-PCs of the query and each sequence in the dataset. The top five closest sequences are shown with their SGT-PC distances in Table~\ref{tab:Protein-search-query-result}. For a reference, we also find the \emph{identities}---an identity between two sequences is the edit-distance between them after alignment. Here we find the identities after a global alignment, with cost of gap-opening as 0 and gap-extension as 1. Note that alignment algorithms are approximate heuristics; thus, the identities should be seen only as a guideline and not ground truth. We find that the maximum pairwise identity (=46.3\%) corresponds to the smallest SGT-PC distance (33.02) for \{Q9ZIM1 (query), S9A4Q5\} and the identity decreases with increasing SGT-PC differences. This shows a consistency between SGT results and commonly accepted identity measures. However, the computation time for finding SGT-PC distances between the query and the entire dataset is found to be 0.0014 sec on 2.2GHz Intel i7, while identity computations took 194.4 sec. Although the current in-use methods for protein data-bases, such as BLAST, have a faster alignment and identity computation procedure than a pairwise, its runtime will still be more than finding vector differences as in SGT-based search. \section{Discussion and Conclusion} \label{sec:Discussion-and-conclusion} As we showed in \S\ref{subsec:SGT-properties} and validated in \S\ref{sec:Experimental-Analysis}-\ref{sec:Applications}, SGT's ability to capture the overall pattern\textemdash{}short- and long-range structures\textemdash{}of a sequence into a fixed finite-dimensional space with shorter computation time makes it stand out. The other methods were found to have lower performance than SGT for this reason. To bring this into perspective, compare SGT with a first-order Markov model. Suppose we are analyzing sequences in which ``$\mathtt{B}$ occurs \emph{closely} after $\mathtt{A}$.'' Due to stochasticity, the observed sequences can be like: a) \textbf{$\mathtt{\mathbf{AB}CDE\mathbf{AB}}$}, and b) $\mathtt{\mathbf{AB}CDE\mathbf{A}X\mathbf{B}}$, where (b) is same as (a) but a noise $\mathtt{X}$, appearing in between $\mathtt{A}$ and $\mathtt{B}$. While the transition probability in the Markov model will be significantly different for (a:1.0) and (b:0.5), SGT is robust to such noises, (a:0.50) and (b:0.45) for $\kappa=5$. The effect of the intermittent noise can be easily regulated by changing $\kappa$: choose a high $\kappa$ to reduce the noise effect, with a caution that sometimes it may be part of the pattern. Furthermore, a Markov model cannot easily distinguish between these two sequences: \textbf{$\mathtt{\mathbf{AB}CDE\mathbf{AB}}$} and $\mathtt{\mathbf{AB}CDEFGHIJ\mathbf{AB}}$, from the ($\mathtt{A}$,$\mathtt{B}$) transition probabilities (=1 for both). Differently, the SGT feature for ($\mathtt{A}$,$\mathtt{B}$) changes from 1.72 to 2.94 ($\kappa=1$), because it looks at the overall pattern. On another note, although deep learning methods can capture such overall patterns, their representations are in an arbitrary and usually very high dimension. Besides, SGT may have poor performance if the alphabet set, $\mathcal{V}$, is small. This is because the feature space, $|\mathcal{V}|\times|\mathcal{V}|$, will be small to sufficiently capture the pattern characteristics. Typically, this is found to happen if $|\mathcal{V}|<4$. Additionally, for clustering Manhattan distance is found to outperform Euclidean distance. This can be due to the differences in SGT features typically having small values. In summary, SGT is a novel approach for feature extraction of a sequence to give it a finite-dimensional representation. This bridges an existing gap between sequence problems and powerful mainstream data mining methods. SGT estimation does not require any numerical optimization, which makes it simple and fast. Due to SGT's faster execution and ease of parallelization, it can be scaled to most big sequence data problems. For future research, SGT-based methods can be developed for sequence problems in speech recognition, text analysis, bioinformatics, etc., or used as an embedding layer in deep learning. In addition, efficacy of higher-order SGTs can also be explored.
{'timestamp': '2017-05-02T02:05:36', 'yymm': '1608', 'arxiv_id': '1608.03533', 'language': 'en', 'url': 'https://arxiv.org/abs/1608.03533'}
arxiv